[icinga-checkins] icinga.org: icinga-web/mhein/default: * added cronk links to status summary rows
git at icinga.org
git at icinga.org
Thu Oct 8 13:45:23 CEST 2009
Module: icinga-web
Branch: mhein/default
Commit: f90a0ef5a2ecc0bb121638e7b24143db16b67f2b
URL: https://git.icinga.org/?p=icinga-web.git;a=commit;h=f90a0ef5a2ecc0bb121638e7b24143db16b67f2b
Author: Christian Doebler <christian.doebler at netways.de>
Date: Thu Oct 8 12:02:49 2009 +0200
* added cronk links to status summary rows
---
.../models/System/StatusSummaryModel.class.php | 18 ++-
.../templates/System/StatusSummarySuccess.php | 112 ++++++++++++++++---
.../System/StatusSummarySuccessView.class.php | 1 -
lib/appkit/database/AppKitSQLConstants.class.php | 9 ++-
pub/styles/Icinga.css | 5 +
5 files changed, 119 insertions(+), 26 deletions(-)
diff --git a/app/modules/Cronks/models/System/StatusSummaryModel.class.php b/app/modules/Cronks/models/System/StatusSummaryModel.class.php
index ea6e376..e9852c7 100644
--- a/app/modules/Cronks/models/System/StatusSummaryModel.class.php
+++ b/app/modules/Cronks/models/System/StatusSummaryModel.class.php
@@ -9,16 +9,16 @@ class Cronks_System_StatusSummaryModel extends ICINGACronksBaseModel
private $dataStates = array (
'host' => array (
- 0 => 'OK',
- 1 => 'UNKNOWN',
- 2 => 'DOWN',
+ 0 => 'UP',
+ 1 => 'DOWN',
+ 2 => 'UNREACHABLE',
10 => 'NOT OK',
20 => 'All',
),
'hostchart' => array (
- 0 => 'OK',
- 1 => 'UNKNOWN',
- 2 => 'DOWN',
+ 0 => 'UP',
+ 1 => 'DOWN',
+ 2 => 'UNREACHABLE',
),
'service' => array (
0 => 'OK',
@@ -57,6 +57,11 @@ class Cronks_System_StatusSummaryModel extends ICINGACronksBaseModel
),
);
+ private $typeNames = array (
+ 'host' => 'Hosts',
+ 'service' => 'Services',
+ );
+
private $type = false;
private $dataTmp = array();
private $data = false;
@@ -96,6 +101,7 @@ class Cronks_System_StatusSummaryModel extends ICINGACronksBaseModel
'state_name' => $this->dataStates[$type][$state],
'count' => $count,
'type' => $type,
+ 'type_name' => $this->typeNames[$type],
);
return $data;
}
diff --git a/app/modules/Cronks/templates/System/StatusSummarySuccess.php b/app/modules/Cronks/templates/System/StatusSummarySuccess.php
index 9f0f631..f3f12e3 100644
--- a/app/modules/Cronks/templates/System/StatusSummarySuccess.php
+++ b/app/modules/Cronks/templates/System/StatusSummarySuccess.php
@@ -5,7 +5,6 @@
$parentid = $rd->getParameter('parentid');
?>
<script type="text/javascript">
-
var dummyCronkDisplayStateSummary = function () {
var CronkDisplayStateSummary = {
@@ -15,15 +14,15 @@ var dummyCronkDisplayStateSummary = function () {
panelDefs : {
host : {
- itemId : AppKit.Ext.genRandomId('cronk'),
+ itemId : AppKit.Ext.genRandomId("cronk"),
title : false,
},
service : {
- itemId : AppKit.Ext.genRandomId('cronk'),
+ itemId : AppKit.Ext.genRandomId("cronk"),
title : false,
},
chart : {
- itemId : AppKit.Ext.genRandomId('cronk'),
+ itemId : AppKit.Ext.genRandomId("cronk"),
title : false
}
},
@@ -118,7 +117,7 @@ var dummyCronkDisplayStateSummary = function () {
url: this.url + type,
root: "status_data.data",
autoLoad: false,
- fields: ["state_id", "state_name", "type", "count"],
+ fields: ["state_id", "state_name", "type", "type_name", "count"],
listeners: {
load: function(s) {
s.filter("type", type);
@@ -132,7 +131,7 @@ var dummyCronkDisplayStateSummary = function () {
// Template to display the cronks
this.tpl = new Ext.XTemplate(
"<tpl for=\".\">",
- "<div class=\"test-l\" id=\"{state_id}\">",
+ "<div class=\"status-summary-row\" id=\"{state_id}\">",
"<span class=\"x-editable\">{count}</span> ",
"<span class=\"x-editable\">{state_name}</span>",
"</div>",
@@ -142,12 +141,77 @@ var dummyCronkDisplayStateSummary = function () {
// The dataview container
this.view = new Ext.DataView({
- id: AppKit.Ext.genRandomId('cronk'),
- title: "test",
+ id: AppKit.Ext.genRandomId("cronk"),
+ title: false,
store: this.store,
tpl: this.tpl,
- itemSelector:"div.test-l",
- emptyText: "No data"
+ itemSelector:"div.status-summary-row",
+ emptyText: "No data",
+ trackOver: true,
+ singleSelect: true,
+
+ listeners: {
+ click: function(view, index, node, e) {
+ var record = view.getStore().getAt(index);
+ var type = record.data.type;
+ var params = {};
+ var filter = {};
+
+ var id = (type || "empty") + "searchResultComponent";
+
+ switch (type) {
+ case "host":
+ switch (record.data.state_id) {
+ case 0:
+ case 1:
+ case 2:
+ filter["f[host_status-value]"] = record.data.state_id;
+ filter["f[host_status-operator]"] = 50;
+ break;
+ case 10:
+ filter["f[host_status-value]"] = 0;
+ filter["f[host_status-operator]"] = 71;
+ break;
+ }
+ params["template"] = "icinga-host-template";
+ break;
+
+ case "service":
+ switch (record.data.state_id) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ filter["f[service_status-value]"] = record.data.state_id;
+ filter["f[service_status-operator]"] = 50;
+ break;
+ case 10:
+ filter["f[service_status-value]"] = 0;
+ filter["f[service_status-operator]"] = 71;
+ break;
+ }
+ params["template"] = "icinga-service-template";
+ break;
+
+ default:
+ Ext.Msg.alert("Search", "This type is not ready implemented yet!");
+ return;
+ break;
+ }
+
+ var cronk = {
+ parentid: id,
+ title: record.data.type_name + " - " + record.data.state_name,
+ crname: "gridProc",
+ closable: true,
+ params: params
+ };
+
+ AppKit.Ext.util.InterGridUtil.gridFilterLink(cronk, filter);
+
+ return true;
+ }
+ }
});
this.panel.getComponent(this.panelDefs[type].itemId).add(this.view);
@@ -162,7 +226,7 @@ var dummyCronkDisplayStateSummary = function () {
url: this.url + type + "chart",
root: "status_data.data",
autoLoad: false,
- fields: ["type", "OK", "UNKNOWN", "DOWN", "WARNING", "CRITICAL"]
+ fields: ["type", "UP", "DOWN", "UNREACHABLE", "OK", "WARNING", "CRITICAL", "UNKNOWN"]
});
this.store.load();
@@ -191,22 +255,28 @@ var dummyCronkDisplayStateSummary = function () {
},
series: [
{
- xField: "OK",
- displayName: "OK",
+ xField: "UP",
+ displayName: "UP",
style: {
color: 0x00ff00
}
},{
- xField: "UNKNOWN",
- displayName: "UNKNOWN",
+ xField: "DOWN",
+ displayName: "DOWN",
+ style: {
+ color: 0xff0000
+ }
+ },{
+ xField: "UNREACHABLE",
+ displayName: "UNREACHABLE",
style: {
color: 0xff8040
}
},{
- xField: "DOWN",
- displayName: "DOWN",
+ xField: "OK",
+ displayName: "OK",
style: {
- color: 0xff0000
+ color: 0x00ff00
}
},{
xField: "WARNING",
@@ -220,6 +290,12 @@ var dummyCronkDisplayStateSummary = function () {
style: {
color: 0xff0000
}
+ },{
+ xField: "UNKNOWN",
+ displayName: "UNKNOWN",
+ style: {
+ color: 0xff8040
+ }
}
]
});
diff --git a/app/modules/Cronks/views/System/StatusSummarySuccessView.class.php b/app/modules/Cronks/views/System/StatusSummarySuccessView.class.php
index dc9b32c..a96eb72 100644
--- a/app/modules/Cronks/views/System/StatusSummarySuccessView.class.php
+++ b/app/modules/Cronks/views/System/StatusSummarySuccessView.class.php
@@ -30,7 +30,6 @@ class Cronks_System_StatusSummarySuccessView extends ICINGACronksBaseView
// store final count
$jsonData['status_data']['count'] = count($jsonData['status_data']['data']);
- //return '{"status_data":{"count":1,"data":[{"OK":52,"UNKNOWN":8,"DOWN":0,"type":"Hosts"}]}}';
return json_encode($jsonData);
}
diff --git a/lib/appkit/database/AppKitSQLConstants.class.php b/lib/appkit/database/AppKitSQLConstants.class.php
index c7a2d4d..58eeaae 100644
--- a/lib/appkit/database/AppKitSQLConstants.class.php
+++ b/lib/appkit/database/AppKitSQLConstants.class.php
@@ -11,6 +11,9 @@ class AppKitSQLConstants {
const SQL_OP_LESSTHAN = 70;
const SQL_OP_GREATERTHAN = 71;
+ const SQL_OP_LESSOREQUAL = 80;
+ const SQL_OP_GREATEROREQUAL = 81;
+
private static $SQL_OPERATORS = array (
self::SQL_OP_CONTAIN => 'LIKE',
self::SQL_OP_NOTCONTAIN => 'NOT LIKE',
@@ -24,7 +27,11 @@ class AppKitSQLConstants {
private static $ICINGA_OPERATORS = array (
self::SQL_OP_IS => IcingaApi::MATCH_EXACT,
- self::SQL_OP_CONTAIN => IcingaApi::MATCH_LIKE
+ self::SQL_OP_CONTAIN => IcingaApi::MATCH_LIKE,
+ self::SQL_OP_GREATERTHAN => IcingaApi::MATCH_GREATER_THAN,
+ self::SQL_OP_LESSTHAN => IcingaApi::MATCH_LESS_THAN,
+ self::SQL_OP_GREATEROREQUAL => IcingaApi::MATCH_GREATER_OR_EQUAL,
+ self::SQL_OP_LESSOREQUAL => IcingaApi::MATCH_LESS_OR_EQUAL
);
/**
diff --git a/pub/styles/Icinga.css b/pub/styles/Icinga.css
index 51ee2e2..b8f91bf 100644
--- a/pub/styles/Icinga.css
+++ b/pub/styles/Icinga.css
@@ -266,6 +266,11 @@ table.icinga-attribute-table td.val {
background: none;
}
+/** STATUS-SUMMARY VIEW **/
+.status-summary-row {
+ cursor: pointer;
+}
+
/** MISC **/
.no-background {
background: none;
More information about the icinga-checkins
mailing list