[icinga-checkins] icinga.org: icinga-web/master: * Fixes grid filter (fixes #1564)

git at icinga.org git at icinga.org
Mon Jul 18 10:39:19 CEST 2011


Module: icinga-web
Branch: master
Commit: f771adeb410e4fef4b78c6946190337f87133be7
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=f771adeb410e4fef4b78c6946190337f87133be7

Author: Marius Hein <marius.hein at netways.de>
Date:   Mon Jul 18 10:37:04 2011 +0200

* Fixes grid filter (fixes #1564)
* REPORTING: Resource view ready now

---

 app/modules/Cronks/lib/js/FilterHandler.js         |   28 ++++++++++++++++++-
 ...nga.Reporting.inputControl.ApiSelectionField.js |   27 +++++++++++++++++-
 .../Icinga.Reporting.util.ContentResourcePanel.js  |   12 ++++++++
 .../lib/js/Icinga.Reporting.util.RunReportPanel.js |    1 +
 .../Provider/ContentResourceSuccessView.class.php  |    9 ++++++
 5 files changed, 73 insertions(+), 4 deletions(-)

diff --git a/app/modules/Cronks/lib/js/FilterHandler.js b/app/modules/Cronks/lib/js/FilterHandler.js
index 8bd1842..b767097 100755
--- a/app/modules/Cronks/lib/js/FilterHandler.js
+++ b/app/modules/Cronks/lib/js/FilterHandler.js
@@ -46,6 +46,8 @@ Cronk.IcingaApiComboBox = Ext.extend(Ext.form.ComboBox, {
 			autoDestroy : true,
 			url : AppKit.c.path + this.def_webpath,
 
+			root : 'result',
+
 			baseParams : {
 				target : meta.api_target,
 				order_col: (meta.api_order_col || meta.api_keyfield),
@@ -55,8 +57,28 @@ Cronk.IcingaApiComboBox = Ext.extend(Ext.form.ComboBox, {
 
 			idProperty : (meta.api_id || meta.api_keyfield),
 
-			fields : fields
+			fields : fields,
+			
+			listeners : {
+				beforeload : function(store, options) {
+					if (!Ext.isEmpty(store.baseParams.query)) {
+						store.baseParams.filters_json = Ext.util.JSON.encode({
+							type : 'AND',
+							field : [{
+								type : 'atom',
+								field : [vf],
+								method : ['like'],
+								value : [String.format('*{0}*', store.baseParams.query)]
+							}]
+						});
+					}
+				}
+			}
 		});
+		
+		apiStore.load();
+		
+		AppKit.log(apiStore);
 
 		cfg = Ext.apply(cfg || {}, {
 			store : apiStore,
@@ -72,6 +94,8 @@ Cronk.IcingaApiComboBox = Ext.extend(Ext.form.ComboBox, {
 
 		// Notify the parent class
 		Cronk.IcingaApiComboBox.superclass.constructor.call(this, cfg);
+		
+		AppKit.log(this);
 	}
 });
 
@@ -296,7 +320,7 @@ Cronk.FilterHandler = Ext.extend(Ext.util.Observable, {
 	getApiCombo : function(meta) {
 		return new Cronk.IcingaApiComboBox({
 			typeAhead: false,
-			triggerAction: 'query',
+			triggerAction: 'all',
 			forceSelection: false,
 			'name': meta.name + '-field',
 			'id': meta.name + '-field',
diff --git a/app/modules/Reporting/lib/js/Icinga.Reporting.inputControl.ApiSelectionField.js b/app/modules/Reporting/lib/js/Icinga.Reporting.inputControl.ApiSelectionField.js
index 9e03d1a..7493411 100644
--- a/app/modules/Reporting/lib/js/Icinga.Reporting.inputControl.ApiSelectionField.js
+++ b/app/modules/Reporting/lib/js/Icinga.Reporting.inputControl.ApiSelectionField.js
@@ -27,14 +27,37 @@ Icinga.Reporting.inputControl.ApiSelectionField = Ext.extend(Ext.form.ComboBox,
 		var displayField = config.displayField;
 		var valueField = config.valueField;
 		
+		var url = AppKit.util.Config.getBaseUrl() + String.format('/web/api/{0}/json', config.target.toLowerCase());
+		
 		var store = new Ext.data.JsonStore({
-			url : AppKit.util.Config.getBaseUrl() + String.format('/web/api/{0}/json', config.target.toLowerCase()),
+			url : url,
 			autoDestroy : true,
 			root : 'result',
 			idProperty : displayField,
-			fields : [displayField, valueField]
+			fields : [displayField, valueField],
+			baseParams : {
+				order_col : displayField
+			},
+			
+			listeners : {
+				beforeload : function(store, options) {
+					if (!Ext.isEmpty(store.baseParams.query)) {
+						store.baseParams.filters_json = Ext.util.JSON.encode({
+							type : 'AND',
+							field : [{
+								type : 'atom',
+								field : [displayField],
+								method : ['like'],
+								value : [String.format('*{0}*', store.baseParams.query)]
+							}]
+						});
+					}
+				}
+			}
 		});
 		
+		store.load();
+		
 		return store;
 	},
 	
diff --git a/app/modules/Reporting/lib/js/Icinga.Reporting.util.ContentResourcePanel.js b/app/modules/Reporting/lib/js/Icinga.Reporting.util.ContentResourcePanel.js
index aed63a3..bfb598a 100644
--- a/app/modules/Reporting/lib/js/Icinga.Reporting.util.ContentResourcePanel.js
+++ b/app/modules/Reporting/lib/js/Icinga.Reporting.util.ContentResourcePanel.js
@@ -144,7 +144,18 @@ Icinga.Reporting.util.ContentResourcePanel = Ext.extend(Ext.Panel, {
 	},
 	
 	processDownload : function(b, e) {
+		var eId = 'icinga-reporting-dl-resource-iframe';
+		Ext.DomHelper.append(Ext.getBody(), {
+			tag : 'iframe',
+			id : eId,
+			src : Ext.urlAppend(this.content_url, Ext.urlEncode({
+				uri : this.node.attributes.uri
+			}))
+		});
 		
+		(function() {
+			Ext.get(eId).remove();
+		}).defer(2000);		
 	},
 	
 	processPreview : function(b, e) {
@@ -152,6 +163,7 @@ Icinga.Reporting.util.ContentResourcePanel = Ext.extend(Ext.Panel, {
 		tabs.setActiveTab(tabs.add({
 			title : this.data.data.name,
 			closable : true,
+			iconCls : 'icinga-icon-eye',
 			bodyCfg : {
 				tag : 'iframe',
 				src : Ext.urlAppend(this.content_url, Ext.urlEncode({
diff --git a/app/modules/Reporting/lib/js/Icinga.Reporting.util.RunReportPanel.js b/app/modules/Reporting/lib/js/Icinga.Reporting.util.RunReportPanel.js
index 9f2bfcc..aed558f 100644
--- a/app/modules/Reporting/lib/js/Icinga.Reporting.util.RunReportPanel.js
+++ b/app/modules/Reporting/lib/js/Icinga.Reporting.util.RunReportPanel.js
@@ -282,6 +282,7 @@ Icinga.Reporting.util.RunReportPanel = Ext.extend(Ext.Panel, {
 		var previewTab = tabs.add({
 			xtype : 'panel',
 			title : this.nodeAttributes.text,
+			iconCls : 'icinga-icon-eye',
 			closable : true,
 			bodyCfg : {
 				tag : 'iframe',
diff --git a/app/modules/Reporting/views/Provider/ContentResourceSuccessView.class.php b/app/modules/Reporting/views/Provider/ContentResourceSuccessView.class.php
index 0813efd..01bbc51 100644
--- a/app/modules/Reporting/views/Provider/ContentResourceSuccessView.class.php
+++ b/app/modules/Reporting/views/Provider/ContentResourceSuccessView.class.php
@@ -47,6 +47,15 @@ class Reporting_Provider_ContentResourceSuccessView extends ReportingBaseView {
 	    if ($m['has_attachment'] && $m['download_allowed']) {
 	        $this->getResponse()->setHttpHeader('content-length', $m['content_length'], true);
 	        $this->getResponse()->setHttpHeader('content-type', $m['content_type'], true);
+	        
+	        $content_disposition = sprintf(
+	        	'%s; filename=%s',
+	        	$rd->getParameter('inline') ? 'inline' : 'attachment',
+	        	$m['name']
+	        );
+	        
+	        $this->getResponse()->setHttpHeader('content-disposition', $content_disposition, true);
+	        
 	        return $resource->getContent();
 	    }
 	    





More information about the icinga-checkins mailing list