[icinga-checkins] icinga.org: icinga-web/jmosshammer/default2: * Added external link example for xml templates (icinga-host-template)

git at icinga.org git at icinga.org
Mon Jul 19 10:36:00 CEST 2010


Module: icinga-web
Branch: jmosshammer/default2
Commit: 19d75d482d3e2d9c59efcb160d46bc1ef21dbc4b
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=19d75d482d3e2d9c59efcb160d46bc1ef21dbc4b

Author: Marius Hein <marius.hein at netways.de>
Date:   Tue Jun 15 14:25:33 2010 +0200

* Added external link example for xml templates (icinga-host-template)

---

 .../Cronks/data/xml/icinga-host-template.xml       |   79 +++++++++++++++++---
 app/modules/Cronks/lib/js/grid/ColumnRenderer.js   |    1 -
 .../System/ViewProc/js/IcingaColumnRenderer.js     |   27 +++++++-
 3 files changed, 95 insertions(+), 12 deletions(-)

diff --git a/app/modules/Cronks/data/xml/icinga-host-template.xml b/app/modules/Cronks/data/xml/icinga-host-template.xml
index 66e07ff..a23a41e 100644
--- a/app/modules/Cronks/data/xml/icinga-host-template.xml
+++ b/app/modules/Cronks/data/xml/icinga-host-template.xml
@@ -668,7 +668,75 @@
                 <parameter name="default">false</parameter>
             </order>
         </field>
-        
+
+		<!--
+
+		External link example:
+			* Url is an Ext.XTemplate (http://www.sencha.com/deploy/dev/docs/?class=Ext.XTemplate)
+			* Fields are encapsulated by {my_field_name}
+			* Fields are declared by <field> or datasource->additional_fields
+				* Here e.g. host_name, host_id, external_link_example, ...
+
+		<field name="external_link_example">
+			<datasource>
+        		<parameter name="field">HOST_ID</parameter>
+        	</datasource>
+
+			<display>
+                <parameter name="visible">true</parameter>
+                <parameter name="label"></parameter>
+
+				<parameter name="width">22</parameter>
+
+                <parameter name="Ext.grid.Column">
+                	<parameter name="menuDisabled">true</parameter>
+                	<parameter name="fixed">true</parameter>
+                </parameter>
+
+                <parameter name="jsFunc">
+
+                	<parameter>
+	                	<parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
+	                	<parameter name="function">columnImage</parameter>
+
+	                	<parameter name="type">renderer</parameter>
+
+	                	<parameter name="arguments">
+							<parameter name="image">images/fam/book.png</parameter>
+							<parameter name="css">x-icinga-grid-link</parameter>
+							<parameter name="attr">
+								<parameter name="qtip">Click here for history</parameter>
+							</parameter>
+	                	</parameter>
+	                </parameter>
+
+					<parameter>
+	                	<parameter name="namespace">Cronk.grid.IcingaColumnRenderer</parameter>
+	                	<parameter name="function">hyperLink</parameter>
+
+	                	<parameter name="type">cellclick</parameter>
+
+	                	<parameter name="arguments">
+							<parameter name="url">/mywiki/index.php?hostname={host_name}</parameter>
+							<parameter name="newWindow">false</parameter>
+	                	</parameter>
+	                </parameter>
+
+                </parameter>
+
+            </display>
+
+            <filter>
+                <parameter name="enabled">false</parameter>
+            </filter>
+
+            <order>
+                <parameter name="enabled">false</parameter>
+                <parameter name="default">false</parameter>
+            </order>
+		</field>
+		-->
+
         <field name="plugin_output">
         	<datasource>
         		<parameter name="field">HOST_OUTPUT</parameter>
@@ -685,15 +753,6 @@
 						<parameter name="length">40</parameter>
                 	</parameter>
                 </parameter>
-
-				
-                <parameter name="jsFunc">
-                	<parameter name="class">AppKit.Ext.ColumnRenderer.Icinga</parameter>
-                	<parameter name="method">ajaxPopup</parameter>
-                	
-                	<parameter name="filterField">host_object_id</parameter>
-                	<parameter name="type">HostStatus</parameter>
-                </parameter>
                 
             </display>
         	
diff --git a/app/modules/Cronks/lib/js/grid/ColumnRenderer.js b/app/modules/Cronks/lib/js/grid/ColumnRenderer.js
index bfbd264..f633d98 100755
--- a/app/modules/Cronks/lib/js/grid/ColumnRenderer.js
+++ b/app/modules/Cronks/lib/js/grid/ColumnRenderer.js
@@ -113,5 +113,4 @@ Cronk.grid.ColumnRenderer = {
 			return Icinga.StatusData.wrapElement(type, value);
 		}
 	}
-	
 };
diff --git a/app/modules/Cronks/templates/System/ViewProc/js/IcingaColumnRenderer.js b/app/modules/Cronks/templates/System/ViewProc/js/IcingaColumnRenderer.js
index fd98fdc..26ec500 100755
--- a/app/modules/Cronks/templates/System/ViewProc/js/IcingaColumnRenderer.js
+++ b/app/modules/Cronks/templates/System/ViewProc/js/IcingaColumnRenderer.js
@@ -17,7 +17,7 @@ Cronk.grid.IcingaColumnRenderer = {
 					title: (cfg.titlePrefix || '') + " " + record.data[ cfg.labelField ],
 					crname: 'gridProc',
 					closable: true,
-					params: { template: cfg.targetTemplate }
+					params: {template: cfg.targetTemplate}
 				};
 				
 				var filter = {};
@@ -65,5 +65,30 @@ Cronk.grid.IcingaColumnRenderer = {
 			}
 		}
 
+	},
+
+	hyperLink : function(cfg) {
+
+		if (!'url' in cfg) {
+			throw('url XTemplate configuration needed! (parameter name="url")');
+		}
+
+		return function(grid, rowIndex, colIndex, e) {
+			
+			var fieldName = grid.getColumnModel().getDataIndex(colIndex);
+
+			if (fieldName == cfg.field) {
+				var data = grid.getStore().getAt(rowIndex).data;
+				var tpl = new Ext.XTemplate(cfg.url);
+				var url = tpl.apply(data);
+				var windowName = fieldName;
+
+				if (Ext.isEmpty(cfg.newWindow) || cfg.newWindow == false) {
+					windowName = '_self';
+				}
+
+				window.open(url, windowName);
+			}
+		}
 	}
 };





More information about the icinga-checkins mailing list