[icinga-checkins] icinga.org: icinga-web/mhein/default: * Added host and service status filter

git at icinga.org git at icinga.org
Mon Jan 11 16:14:04 CET 2010


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

Author: Marius Hein <marius.hein at netways.de>
Date:   Mon Jan 11 16:13:53 2010 +0100

* Added host and service status filter

---

 .../System/ViewProc/js/IcingaGridFilterHandler.js  |    1 +
 lib/appkit/js/ext/FilterHandler.js                 |   69 ++++++++++++++++++--
 res/xml/icinga-host-template.xml                   |    8 ++-
 res/xml/icinga-service-template.xml                |    8 ++-
 4 files changed, 79 insertions(+), 7 deletions(-)

diff --git a/app/modules/Cronks/templates/System/ViewProc/js/IcingaGridFilterHandler.js b/app/modules/Cronks/templates/System/ViewProc/js/IcingaGridFilterHandler.js
index f1336c4..cbc4b53 100644
--- a/app/modules/Cronks/templates/System/ViewProc/js/IcingaGridFilterHandler.js
+++ b/app/modules/Cronks/templates/System/ViewProc/js/IcingaGridFilterHandler.js
@@ -181,6 +181,7 @@ var IcingaGridFilterWindow = function() {
 	
 	function getFormValues() {
 		var data = oCoPanel.getForm().getValues();
+		
 		var o = {};
 		
 		for (var k in data) {
diff --git a/lib/appkit/js/ext/FilterHandler.js b/lib/appkit/js/ext/FilterHandler.js
index 2168031..7853c01 100644
--- a/lib/appkit/js/ext/FilterHandler.js
+++ b/lib/appkit/js/ext/FilterHandler.js
@@ -11,7 +11,9 @@ AppKit.Ext.FilterHandler = Ext.extend(Ext.util.Observable, {
 	
 	oFilterOp : {
 		'appkit.ext.filter.text': 'text',
-		'appkit.ext.filter.number': 'number'
+		'appkit.ext.filter.number': 'number',
+		'appkit.ext.filter.servicestatus': 'number',
+		'appkit.ext.filter.hoststatus': 'number'
 	},
 	
 	oOpList : {
@@ -63,7 +65,7 @@ AppKit.Ext.FilterHandler = Ext.extend(Ext.util.Observable, {
 	},
 	
 	setMeta : function (meta) {
-		if (this.fireEvent('metaload', this, meta) !== false) {
+		if (tis.fireEvent('metaload', this, meta) !== false) {
 			this.meta = meta;
 		}
 		
@@ -183,14 +185,71 @@ AppKit.Ext.FilterHandler = Ext.extend(Ext.util.Observable, {
 		return oCombo;
 	},
 	
-	getFilterComponent : function(meta) {
+	getComboComponent : function(data, meta) {
+		var def = {
+			store: new Ext.data.ArrayStore({
+				idIndex: 0,
+				fields: ['fId', 'fStatus', 'fLabel'],
+				data: data
+			}),
+			
+			'name': '__status_name_' + meta.name,
+			'id': '__status_name_' + meta.name,
+			// 'name': meta.name + '-value',
+			
+			mode: 'local',
+			typeAhead: true,
+			triggerAction: 'all',
+			forceSelection: true,
+			
+			
+			fieldLabel: 'Status',
+			
+			valueField: 'fStatus',
+			displayField: 'fLabel',
+			
+			width: 150,
+			
+			hiddenName: meta.name + '-value',
+			hiddenId: meta.name + '-value'
+		};
+		
+		return new Ext.form.ComboBox(def);
 		
-		var item_config = {
+	},
+	
+	getFilterComponent : function(meta) {
+		var oDef = {
 			'name' : meta.name + '-value',
 			id : meta.name + '-value'
 		};
 		
-		return new Ext.form.TextField(item_config);
+		switch (meta.subtype) {
+			
+			case 'appkit.ext.filter.servicestatus':
+				return this.getComboComponent([
+					['1', '0', 'OK'],
+					['2', '1', 'Warning'],
+					['3', '2', 'Critical'],
+					['4', '3', 'Unknown']
+				], meta);
+			break;
+			
+			case 'appkit.ext.filter.hoststatus':
+				return this.getComboComponent([
+					['1', '0', 'UP'],
+					['2', '1', 'Down'],
+					['3', '2', 'Unreachable']
+				], meta);
+			break;
+			
+			default:
+				return new Ext.form.TextField(oDef);	
+			break;
+			
+		}
+		
+		
 	},
 	
 	createComponent : function(meta) {
diff --git a/res/xml/icinga-host-template.xml b/res/xml/icinga-host-template.xml
index 089650f..ae05c85 100644
--- a/res/xml/icinga-host-template.xml
+++ b/res/xml/icinga-host-template.xml
@@ -462,7 +462,13 @@
             </display>
         	
             <filter>
-                <parameter name="enabled">false</parameter>    
+                <parameter name="enabled">true</parameter>
+                
+                <!-- Filter configuration -->
+                <parameter name="type">extjs</parameter>
+                <parameter name="subtype">appkit.ext.filter.hoststatus</parameter>
+                
+                <parameter name="no_operator">false</parameter>
             </filter>
             
             <order>
diff --git a/res/xml/icinga-service-template.xml b/res/xml/icinga-service-template.xml
index 43f59bb..c7f1293 100644
--- a/res/xml/icinga-service-template.xml
+++ b/res/xml/icinga-service-template.xml
@@ -471,7 +471,13 @@
             </display>
         	
             <filter>
-                <parameter name="enabled">false</parameter>    
+                <parameter name="enabled">true</parameter>
+                
+                <!-- Filter configuration -->
+                <parameter name="type">extjs</parameter>
+                <parameter name="subtype">appkit.ext.filter.servicestatus</parameter>
+                
+                <parameter name="no_operator">false</parameter>
             </filter>
             
             <order>





More information about the icinga-checkins mailing list