[icinga-checkins] icinga.org: icinga-web/mhein/default: * extended simple-data provider

Christian Doebler christian.doebler at netways.de
Sat Oct 3 10:04:24 CEST 2009


Module: icinga-web
Branch: mhein/default
Commit: 78723d46233055d45c3eea2410591b05f45d97ab
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=78723d46233055d45c3eea2410591b05f45d97ab

Author: Christian Doebler <christian.doebler at netways.de>
Date:   Wed Sep 30 16:05:25 2009 +0200

* extended simple-data provider

---

 app/config/databases.xml                           |    6 +-
 app/config/icinga.xml                              |   12 ++--
 .../System/ViewProc/js/IcingaColumnRenderer.js     |   32 ++++++++++-
 lib/appkit/js/SimpleDataProvider.js                |   30 +++++++---
 res/xml/icinga-host-template.xml                   |   64 +++++++++++++++++++-
 5 files changed, 124 insertions(+), 20 deletions(-)

diff --git a/app/config/databases.xml b/app/config/databases.xml
index c48a6f6..853a105 100755
--- a/app/config/databases.xml
+++ b/app/config/databases.xml
@@ -6,16 +6,16 @@
 			
 			<database name="appkit_default" class="AgaviDoctrineDatabase">
 
-								 
+				<!-- 								 
 				<ae:parameter name="dsn">mysql://icinga_dev:icinga_dev@127.0.0.1:3307/icinga</ae:parameter>
 				<ae:parameter name="username">icinga_dev</ae:parameter>
 				<ae:parameter name="password">icinga_dev</ae:parameter>
+				-->
 				
-				<!-- 
 				<ae:parameter name="dsn">mysql://icinga_web:icinga_web@127.0.0.1:3306/icinga_web</ae:parameter>
 				<ae:parameter name="username">icinga_web</ae:parameter>
 				<ae:parameter name="password">icinga_web</ae:parameter>
-				-->
+
 				<ae:parameter name="charset">utf8</ae:parameter>
 				
 				<ae:parameter name="manager_attributes">
diff --git a/app/config/icinga.xml b/app/config/icinga.xml
index b8c58aa..92d5643 100644
--- a/app/config/icinga.xml
+++ b/app/config/icinga.xml
@@ -215,20 +215,20 @@
 			<parameter name="config_type">mysql</parameter>
 			<parameter name="config_host">127.0.0.1</parameter>
 
-			 			 			
+			<!--
 			<parameter name="config_port">3307</parameter>
 			<parameter name="config_database">ndo_demo</parameter>
-			
-			<!--
+			-->			
+
 			<parameter name="config_port">3306</parameter>
 			<parameter name="config_database">icinga</parameter>
-			-->
+
 			<parameter name="config_user">icinga</parameter>
 			<parameter name="config_password">icinga</parameter>
 			
 			
-			<parameter name="config_table_prefix">nagios_</parameter>
-			<!-- <parameter name="config_table_prefix">icinga_</parameter> -->
+			<!-- <parameter name="config_table_prefix">nagios_</parameter> -->
+			<parameter name="config_table_prefix">icinga_</parameter>
 		</parameter>
 	</setting>
 	
diff --git a/app/modules/Cronks/templates/System/ViewProc/js/IcingaColumnRenderer.js b/app/modules/Cronks/templates/System/ViewProc/js/IcingaColumnRenderer.js
index 8fd6321..408b852 100644
--- a/app/modules/Cronks/templates/System/ViewProc/js/IcingaColumnRenderer.js
+++ b/app/modules/Cronks/templates/System/ViewProc/js/IcingaColumnRenderer.js
@@ -1,8 +1,9 @@
 Ext.ns('AppKit.Ext.grid');
 
-// This are the javascript methods available within
+// These are the javascript methods available within
 // the namespace
 AppKit.Ext.grid.IcingaColumnRenderer = {
+	
 	subGrid : function(cfg) {
 		return function(grid, rowIndex, colIndex, e) {
 			var fieldName = grid.getColumnModel().getDataIndex(colIndex);
@@ -27,5 +28,34 @@ AppKit.Ext.grid.IcingaColumnRenderer = {
 				AppKit.Ext.util.InterGridUtil.gridFilterLink(cronk, filter);
 			}
 		}
+	},
+	
+	ajaxClick : function(cfg) {
+
+		return function(grid, rowIndex, colIndex, e) {
+			var fieldName = grid.getColumnModel().getDataIndex(colIndex);
+			if (fieldName == cfg.field) {
+
+				cfg.processedFilterData = [];
+
+				Ext.iterate(
+					cfg.filter,
+					function (key, value) {
+						this.push({key: key, value: grid.getStore().getAt(rowIndex).data[value]});
+					},
+					cfg.processedFilterData
+				);
+
+				var sdp = new SimpleDataProvider({
+					targetXY: [e.getPageX(), e.getPageY() - 50],
+					srcId: cfg.src_id,
+					width: 200,
+					delay: 15000,
+					filter: cfg.processedFilterData
+				});
+
+			}
+		}
+
 	}
 };
diff --git a/lib/appkit/js/SimpleDataProvider.js b/lib/appkit/js/SimpleDataProvider.js
index 67c6636..350636b 100644
--- a/lib/appkit/js/SimpleDataProvider.js
+++ b/lib/appkit/js/SimpleDataProvider.js
@@ -10,17 +10,17 @@ function SimpleDataProvider (config) {
 			srcId:			false,
 			width:			false,
 			filter:			false,
-			target:			false,
+			targetXY:		false,
 			delay:			false,
 			autoDisplay:	true
 		};
 
 		this.reset = function () {
-			this.config.url = "http://icinga-web/web/simpleDataProvider/json?src_id=";
+			this.config.url = "/web/simpleDataProvider/json?src_id=";
 			this.config.srcId = "";
 			this.config.width = 200;
 			this.config.filter = {};
-			this.config.target = "";
+			this.config.targetXY = [0, 0];
 			this.config.delay = 15000;
 			this.config.autoDisplay = true;
 			return this;
@@ -39,7 +39,7 @@ function SimpleDataProvider (config) {
 		};
 
 		this.getUrl = function () {
-			url = this.config.url + this.config.srcId + this.getFilter();
+			var url = this.config.url + this.config.srcId + this.getFilter();
 			return url;
 		};
 
@@ -61,19 +61,33 @@ function SimpleDataProvider (config) {
 
 		this.display = function () {
 			if (this.checkData()) {
-				new Ext.ToolTip({
-					target: this.config.target,
+
+				var toolTip = new Ext.ToolTip({
 					width: this.config.width,
-					autoLoad: {url: this.getUrl()},
 					dismissDelay: this.config.delay
 				});
+
+				toolTip.render(Ext.getBody());
+				toolTip.targetXY = this.config.targetXY;
+
+				toolTip.getUpdater().update({
+					url: this.getUrl(),
+					callback: this.outputTable
+				});
+
+				toolTip.show();
+
 			}
 		};
 
+		this.outputTable = function (el, success, response, options) {
+			//console.log(response.responseText);
+		};
+
 		this.reset();
 		this.setConfig(config);
 		if (this.config.autoDisplay) {
 			this.display();
-		}
+		};
 
 }
\ No newline at end of file
diff --git a/res/xml/icinga-host-template.xml b/res/xml/icinga-host-template.xml
index 8317578..e6e3edb 100644
--- a/res/xml/icinga-host-template.xml
+++ b/res/xml/icinga-host-template.xml
@@ -146,7 +146,7 @@
 							<parameter name="labelField">host_name</parameter>
 	                	</parameter>
 	                </parameter>
-                
+	                
                 </parameter>
                 
             </display>
@@ -167,7 +167,67 @@
                 <!--  <parameter name="field">A_NEW_FIELD_TO_SORT</parameter> -->
             </order>
         </field>  
-        
+
+        <field name="host_info">
+            <datasource>
+            	<parameter name="field">HOST_NAME</parameter>
+            </datasource>
+
+            <display>
+                <parameter name="visible">true</parameter>
+                <parameter name="label"></parameter>
+
+                <parameter name="width">22</parameter>
+
+                <!-- Config for the AJAX grid (see http://www.extjs.com/deploy/dev/docs/?class=Ext.grid.Column) -->
+                <parameter name="Ext.grid.Column">
+                	<parameter name="menuDisabled">true</parameter>
+                	<parameter name="fixed">true</parameter>
+                </parameter>
+
+                <parameter name="jsFunc">
+                	<parameter>
+	                	<parameter name="namespace">AppKit.Ext.grid.ColumnRenderer</parameter>
+	                	<parameter name="function">columnImage</parameter>
+	                	
+	                	<!-- renderer/gridevent[cellclick|celldblclick|...] -->
+	                	<parameter name="type">renderer</parameter>
+	                	
+	                	<parameter name="arguments">
+							<parameter name="image">fam.information</parameter>
+							<parameter name="css">x-icinga-grid-link</parameter>
+							<parameter name="attr">
+								<parameter name="qtip">Click here for information</parameter>
+							</parameter>
+	                	</parameter>
+	                </parameter>
+
+					<parameter>
+	                	<parameter name="namespace">AppKit.Ext.grid.IcingaColumnRenderer</parameter>
+	                	<parameter name="function">ajaxClick</parameter>
+
+	                	<!-- renderer/gridevent[cellclick|celldblclick|...] -->
+	                	<parameter name="type">celldblclick</parameter>
+
+	                	<parameter name="arguments">
+	                		<parameter name="src_id">hostinfo</parameter>
+	                		<parameter name="filter">
+	                			<parameter name="host">host_name</parameter>
+	                		</parameter>
+	                	</parameter>
+	                </parameter>
+                </parameter>
+            </display>
+
+            <filter>
+                <parameter name="enabled">false</parameter>
+            </filter>
+
+            <order>
+                <parameter name="enabled">false</parameter>
+            </order>
+        </field>
+
         <field name="host_history_link">
             <datasource>
             	<parameter name="field">HOST_NAME</parameter>





More information about the icinga-checkins mailing list