[icinga-checkins] icinga.org: icinga-web/cdoebler/default: * updated status map for support of multiple views
git at icinga.org
git at icinga.org
Wed Oct 7 12:59:17 CEST 2009
Module: icinga-web
Branch: cdoebler/default
Commit: 90d032d19abdf45c0f94f946cb7659b6da9efa53
URL: https://git.icinga.org/?p=icinga-web.git;a=commit;h=90d032d19abdf45c0f94f946cb7659b6da9efa53
Author: Christian Doebler <christian.doebler at netways.de>
Date: Wed Oct 7 12:58:36 2009 +0200
* updated status map for support of multiple views
---
.../Cronks/models/System/StatusMapModel.class.php | 27 +++++----
.../Cronks/templates/System/StatusMapSuccess.php | 62 ++++++++++++++------
pub/styles/statusmap.css | 16 +++---
3 files changed, 67 insertions(+), 38 deletions(-)
diff --git a/app/modules/Cronks/models/System/StatusMapModel.class.php b/app/modules/Cronks/models/System/StatusMapModel.class.php
index feabf97..851e079 100644
--- a/app/modules/Cronks/models/System/StatusMapModel.class.php
+++ b/app/modules/Cronks/models/System/StatusMapModel.class.php
@@ -45,6 +45,8 @@ class Cronks_System_StatusMapModel extends ICINGACronksBaseModel
$hosts = array();
$hostReferences = array();
+ $idPrefix = sha1(microtime()) . '-';
+
$apiResHosts = $this->api->API()
->createSearch()
->setResultType(IcingaApi::RESULT_ARRAY)
@@ -59,8 +61,9 @@ class Cronks_System_StatusMapModel extends ICINGACronksBaseModel
->fetch();
foreach ($apiResHosts as $row) {
- $hosts[$row['host_object_id']] = array(
- 'id' => $row['host_object_id'],
+ $objectId = $idPrefix . $row['host_object_id'];
+ $hosts[$objectId] = array(
+ 'id' => $objectId,
'name' => $row['host_name'],
'data' => array(
'relation' => $this->getHostDataTable($row),
@@ -70,14 +73,16 @@ class Cronks_System_StatusMapModel extends ICINGACronksBaseModel
}
foreach ($apiResHostParents as $row) {
- if (!array_key_exists($row->host_child_object_id, $hostReferences)) {
- $hostReferences[$row->host_child_object_id] = $hosts[$row->host_child_object_id];
+ $childObjectId = $idPrefix . $row->host_child_object_id;
+ $parentObjectId = $idPrefix . $row->host_parent_object_id;
+ if (!array_key_exists($childObjectId, $hostReferences)) {
+ $hostReferences[$childObjectId] = $hosts[$childObjectId];
}
- unset($hosts[$row->host_child_object_id]);
- if (array_key_exists($row->host_parent_object_id, $hosts)) {
- $hosts[$row->host_parent_object_id]['children'][$row->host_child_object_id] =& $hostReferences[$row->host_child_object_id];
- } elseif (array_key_exists($row->host_parent_object_id, $hostReferences)) {
- $hostReferences[$row->host_parent_object_id]['children'][$row->host_child_object_id] =& $hostReferences[$row->host_child_object_id];
+ unset($hosts[$childObjectId]);
+ if (array_key_exists($parentObjectId, $hosts)) {
+ $hosts[$parentObjectId]['children'][$childObjectId] =& $hostReferences[$childObjectId];
+ } elseif (array_key_exists($parentObjectId, $hostReferences)) {
+ $hostReferences[$parentObjectId]['children'][$childObjectId] =& $hostReferences[$childObjectId];
}
}
@@ -86,7 +91,7 @@ class Cronks_System_StatusMapModel extends ICINGACronksBaseModel
if (count($hostsFlatStruct) == 1) {
$hostsFlat = $hostsFlatStruct;
$icingaProc = array(
- 'id' => '-1',
+ 'id' => $idPrefix . '-1',
'name' => 'Icinga',
'data' => array(
'relation' => 'Icinga Monitoring Process',
@@ -96,7 +101,7 @@ class Cronks_System_StatusMapModel extends ICINGACronksBaseModel
array_push($hostsFlat[0]['children'], $icingaProc);
} else {
$hostsFlat = array(
- 'id' => '-1',
+ 'id' => $idPrefix . '-1',
'name' => 'Icinga',
'data' => array(
'relation' => 'Icinga Monitoring Process',
diff --git a/app/modules/Cronks/templates/System/StatusMapSuccess.php b/app/modules/Cronks/templates/System/StatusMapSuccess.php
index 8037583..e98441c 100644
--- a/app/modules/Cronks/templates/System/StatusMapSuccess.php
+++ b/app/modules/Cronks/templates/System/StatusMapSuccess.php
@@ -15,9 +15,9 @@
var JitLog = {
elem: false,
- write: function(text) {
+ write: function(elementId, text) {
if (!this.elem)
- this.elem = document.getElementById("jitLog");
+ this.elem = document.getElementById(elementId);
this.elem.innerHTML = text;
this.elem.style.left = (500 - this.elem.offsetWidth / 2) + "px";
}
@@ -37,13 +37,25 @@
this.configWritable = ["url", "params", "method", "timeout", "disableCaching"];
+ this.elementIds = {
+ jitContainer: "jitContainer",
+ jitContainerCenter: "jitContainerCenter",
+ jitMap: "jitMap",
+ jitContainerRight: "jitContainerRight",
+ jitDetails: "jitDetails",
+ jitLog: "jitLog",
+ jitCanvas: "jitCanvas"
+ };
+
+ this.elementIdsWrite = ["jitContainer", "jitContainerCenter", "jitMap", "jitContainerRight", "jitDetails", "jitLog", "jitCanvas"];
+
this.jitJson = false;
- function jitInit (json) {
- var infovis = document.getElementById("jitMap");
+ function jitInit (json, elementIds) {
+ var infovis = document.getElementById(elementIds.jitMap);
var w = infovis.offsetWidth, h = infovis.offsetHeight;
- var canvas = new Canvas("mycanvas", {
- "injectInto": "jitMap",
+ var canvas = new Canvas(elementIds.jitCanvas, {
+ "injectInto": elementIds.jitMap,
"width": w,
"height": h,
"backgroundCanvas": {
@@ -70,14 +82,14 @@
color: "#ccddee"
},
Edge: {
- color: "#56A5EC"
+ color: "#56a5ec"
},
onBeforeCompute: function(node){
- JitLog.write("centering " + node.name + "...");
- document.getElementById("jitDetails").innerHTML = node.data.relation;
+ JitLog.write(elementIds.jitLog, "centering " + node.name + "...");
+ document.getElementById(elementIds.jitDetails).innerHTML = node.data.relation;
},
onAfterCompute: function(){
- JitLog.write("done");
+ JitLog.write(elementIds.jitLog, "done");
},
onCreateLabel: function(domElement, node){
domElement.innerHTML = node.name;
@@ -105,11 +117,12 @@
});
rgraph.loadJSON(json);
rgraph.refresh();
- document.getElementById("jitDetails").innerHTML = rgraph.graph.getNode(rgraph.root).data.relation;
+ document.getElementById(elementIds.jitDetails).innerHTML = rgraph.graph.getNode(rgraph.root).data.relation;
}
this.init = function (config) {
this.setConfig(config);
+ this.setElementIds();
this.createContainer();
this.getMapData();
}
@@ -125,32 +138,43 @@
}
}
+ this.setElementIds = function () {
+ var numElements = this.elementIdsWrite.length;
+ for (var x = 0; x < numElements; x++) {
+ this.elementIds[this.elementIdsWrite[x]] += AppKit.Ext.genRandomId('cronk');
+ }
+ }
+
this.createContainer = function () {
var container = new Ext.Container({
- id: "jitContainer",
+ id: this.elementIds.jitContainer,
autoEl: 'div',
layout: 'column',
defaults: {
xtype: 'container',
autoEl: 'div',
layout: 'auto',
- //columnWidth: 0.5,
style: {
border: "none"
}
},
items : [{
- id: "jitContainerCenter",
+ id: this.elementIds.jitContainerCenter,
+ cls: "jitContainerCenter",
items: {
- id: "jitMap"
+ id: this.elementIds.jitMap,
+ cls: "jitMap"
}
},{
- id: "jitContainerRight",
+ id: this.elementIds.jitContainerRight,
+ cls: "jitContainerRight",
items: {
- id: "jitDetails"
+ id: this.elementIds.jitDetails,
+ cls: "jitDetails"
}
},{
- id: "jitLog"
+ id: this.elementIds.jitLog,
+ cls: "jitLog"
}]
});
this.cmp.add(container);
@@ -179,7 +203,7 @@
this.getMapDataSuccess = function (response, o) {
this.jitJson = Ext.util.JSON.decode(response.responseText);
- jitInit(this.jitJson);
+ jitInit(this.jitJson, this.elementIds);
this.mask.hide();
this.mask.disable();
}
diff --git a/pub/styles/statusmap.css b/pub/styles/statusmap.css
index 55355af..6d25a7a 100644
--- a/pub/styles/statusmap.css
+++ b/pub/styles/statusmap.css
@@ -1,35 +1,35 @@
-#jitContainer {
+.jitContainer {
width: 1000px;
height: 600px;
margin:0;
position:relative;
}
-#jitContainerRight, #jitContainerCenter {
+.jitContainerRight, .jitContainerCenter {
height:600px;
position:absolute;
top:0;
}
-#jitContainerRight {
+.jitContainerRight {
color:#383a60;
text-align: left;
overflow: auto;
left: 605px;
}
-#jitContainerCenter {
+.jitContainerCenter {
width:600px;
border-right:1px solid #ddd;
}
-#jitDetails {
+.jitDetails {
font-size:1em;
list-style:none;
margin:7px;
}
-#jitLog {
+.jitLog {
position:absolute;
top:10px;
font-size:1.0em;
@@ -37,7 +37,7 @@
color:#23A4FF;
}
-#jitMap {
+.jitMap {
position:relative;
width:600px;
height:600px;
@@ -45,6 +45,6 @@
overflow:hidden;
}
-#jitMap div {
+.jitMap div {
border: none;
}
\ No newline at end of file
More information about the icinga-checkins
mailing list