[icinga-checkins] icinga.org: icinga-web/mhein/reporting-lov: Finish LOV handling, fixes non parameterized reports

git at icinga.org git at icinga.org
Mon Oct 15 09:53:21 CEST 2012


Module: icinga-web
Branch: mhein/reporting-lov
Commit: 4b0442cb9240da9d2ac797c6b13f160f8b94f9ae
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=4b0442cb9240da9d2ac797c6b13f160f8b94f9ae

Author: Marius Hein <marius.hein at netways.de>
Date:   Mon Oct 15 09:52:34 2012 +0200

Finish LOV handling, fixes non parameterized reports

---

 app/modules/Reporting/config/javascript.xml        |    1 +
 app/modules/Reporting/config/module.xml.in         |    4 ++-
 .../Icinga.Reporting.inputControl.ResourceList.js  |   27 ++++++++++++++----
 .../Icinga.Reporting.util.InputControlBuilder.js   |   13 +++++++-
 .../lib/js/Icinga.Reporting.util.RunReportPanel.js |   29 +++++++++++++++----
 etc/conf.d/module_reporting.xml                    |    2 +-
 6 files changed, 60 insertions(+), 16 deletions(-)

diff --git a/app/modules/Reporting/config/javascript.xml b/app/modules/Reporting/config/javascript.xml
index ac391b1..a96562b 100644
--- a/app/modules/Reporting/config/javascript.xml
+++ b/app/modules/Reporting/config/javascript.xml
@@ -29,6 +29,7 @@
             <ae:parameter>%core.module_dir%/Reporting/lib/js/Icinga.Reporting.inputControl.ApiSelectionField.js</ae:parameter> 
             <ae:parameter>%core.module_dir%/Reporting/lib/js/Icinga.Reporting.inputControl.OutputFormatSelector.js</ae:parameter>
             <ae:parameter>%core.module_dir%/Reporting/lib/js/Icinga.Reporting.inputControl.ResourceList.js</ae:parameter>
+            <ae:parameter>%core.module_dir%/Reporting/lib/js/Icinga.Reporting.inputControl.DateField.js</ae:parameter>
             
             <!-- Misc stuff --> 
             <ae:parameter>%core.module_dir%/Reporting/lib/js/Icinga.Reporting.util.InputControlBuilder.js</ae:parameter> 
diff --git a/app/modules/Reporting/config/module.xml.in b/app/modules/Reporting/config/module.xml.in
index 01a1ee3..6c13965 100644
--- a/app/modules/Reporting/config/module.xml.in
+++ b/app/modules/Reporting/config/module.xml.in
@@ -112,8 +112,10 @@
                 -->
                 <setting name="parameter.mapping.control">
                     <ae:parameter name="2">
-                        <ae:parameter name="className">Ext.form.DateField</ae:parameter>
+                        <ae:parameter name="className">Icinga.Reporting.inputControl.DateField</ae:parameter>
                         <ae:parameter name="format">Y-m-d H:i:s</ae:parameter>
+                        <ae:parameter name="setToNow">true</ae:parameter>
+                        <ae:parameter name="allowBlank">true</ae:parameter>
                         <!-- H:i:s -->
                     </ae:parameter>
                     
diff --git a/app/modules/Reporting/lib/js/Icinga.Reporting.inputControl.ResourceList.js b/app/modules/Reporting/lib/js/Icinga.Reporting.inputControl.ResourceList.js
index c7678e2..d82787d 100644
--- a/app/modules/Reporting/lib/js/Icinga.Reporting.inputControl.ResourceList.js
+++ b/app/modules/Reporting/lib/js/Icinga.Reporting.inputControl.ResourceList.js
@@ -22,18 +22,33 @@
 
 Ext.ns('Icinga.Reporting.inputControl');
 
-Icinga.Reporting.inputControl.ResourceList = Ext.extend(Ext.form.Label, {
+Icinga.Reporting.inputControl.ResourceList = Ext.extend(Ext.form.ComboBox, {
+    
+    triggerAction: 'all',
+    displayField: 'label',
+    valueField: 'id',
+    mode: 'local',
+    typeAhead: true,
     
     constructor : function(config) {
-        config = Ext.apply(config || {}, {
-            text: 'test',
-            label: 'test'
-        });
-        
+        config.hiddenName = config.name;
         Icinga.Reporting.inputControl.ResourceList.superclass.constructor.call(this, config);
     },
     
     initComponent : function() {
+        if (this.jsData) {
+            var arrayData = [];
+            Ext.iterate(this.jsData, function(k, v) {
+                arrayData.push([k, v]);
+            }, this);
+            
+            this.store = new Ext.data.ArrayStore({
+                autoDestroy: true,
+                fields: ['id', 'label'],
+                data: arrayData
+            });
+        }
+        
         Icinga.Reporting.inputControl.ResourceList.superclass.initComponent.call(this);
     }
     
diff --git a/app/modules/Reporting/lib/js/Icinga.Reporting.util.InputControlBuilder.js b/app/modules/Reporting/lib/js/Icinga.Reporting.util.InputControlBuilder.js
index a963983..8dface1 100644
--- a/app/modules/Reporting/lib/js/Icinga.Reporting.util.InputControlBuilder.js
+++ b/app/modules/Reporting/lib/js/Icinga.Reporting.util.InputControlBuilder.js
@@ -56,14 +56,23 @@ Ext.ns('Icinga.Reporting.util');
                 readonly : v.PROP_INPUTCONTROL_IS_READONLY=="true" ? true : false,
                 name : namePrefix + v.name,
                 width: 250,
-                fieldLabel : v['label'],
-                allowBlank : false
+                fieldLabel : v['label']
             });
             
             Ext.applyIf(v.jsControl, Icinga.Reporting.DEFAULT_JSCONTROL);
             
             inputConfig = v.jsControl;
             
+            if (!Ext.isEmpty(v.jsData)) {
+                inputConfig.jsData = v.jsData;
+            } else {
+                inputConfig.jsData = false;
+            }
+            
+            if (Ext.isEmpty(inputConfig.allowBlank)) {
+                inputConfig.allowBlank = false;
+            }
+            
             if (!Ext.isEmpty(inputConfig.className)) {
                 var inputClass = eval('window.' + inputConfig.className);
                 var inputControl = new inputClass(inputConfig);
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 95ad126..e78283c 100644
--- a/app/modules/Reporting/lib/js/Icinga.Reporting.util.RunReportPanel.js
+++ b/app/modules/Reporting/lib/js/Icinga.Reporting.util.RunReportPanel.js
@@ -27,6 +27,9 @@ Icinga.Reporting.DEFAULT_JSCONTROL = {
 };
 
 Icinga.Reporting.util.RunReportPanel = Ext.extend(Icinga.Reporting.abstract.ApplicationWindow, {
+    
+    REPORT_UNIT: 'com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportUnit',
+    
     title : _('Report details'),
     border : false,
     
@@ -51,12 +54,14 @@ Icinga.Reporting.util.RunReportPanel = Ext.extend(Icinga.Reporting.abstract.Appl
                 text : _('Run report'),
                 iconCls : 'icinga-icon-report-run',
                 handler: this.runReport,
-                scope : this
+                scope : this,
+                itemId: 'tb-run-report'
             }, {
                 text : _('Preview'),
                 iconCls : 'icinga-icon-report-preview',
                 handler : this.previewReport,
-                scope : this
+                scope : this,
+                itemId: 'tb-preview-report'
             }]
         });
         
@@ -74,7 +79,6 @@ Icinga.Reporting.util.RunReportPanel = Ext.extend(Icinga.Reporting.abstract.Appl
                 + '</h3></div>'
         });
         
-        
         this.setToolbarEnabled(false);
     },
     
@@ -105,7 +109,8 @@ Icinga.Reporting.util.RunReportPanel = Ext.extend(Icinga.Reporting.abstract.Appl
             cls : 'simple-content-box'
         });
         
-        if (this.parameterData.length == 0) {
+        if (this.nodeAttributes.PROP_RESOURCE_TYPE !== this.REPORT_UNIT) {
+            this.setToolbarEnabled(false);
             this.add({
                 layout: 'fit',
                 html: String.format('<h4>{0}</h4><i>{1}</i>', _('No report'), _('Sorry, no report selected. Please select a report item in the tree on the left'))
@@ -128,6 +133,18 @@ Icinga.Reporting.util.RunReportPanel = Ext.extend(Icinga.Reporting.abstract.Appl
             
             this.formPanel.add(outputSelector);
             
+            if (this.parameterData.length == 0) {
+                this.formPanel.add({
+                    layout:'fit',
+                    border: false,
+                    html: String.format(
+                        '<h4>{0}</h4><i>{1}</i>', 
+                        _('No more parameters'),
+                        _('Nothing else needed here, just press "Run" or "Preview" to proceed')
+                    )
+                });
+            }
+            
             this.messagePanel = new Ext.Container({
                 border : false,
                 width : 356,
@@ -141,11 +158,11 @@ Icinga.Reporting.util.RunReportPanel = Ext.extend(Icinga.Reporting.abstract.Appl
             this.formPanel.add(this.messagePanel);
             
             this.add(this.formPanel);
+            
+            this.setToolbarEnabled(true);
         }
         
         this.doLayout();
-        
-        this.setToolbarEnabled();
     },
     
     addMessage : function(html, cls) {
diff --git a/etc/conf.d/module_reporting.xml b/etc/conf.d/module_reporting.xml
index 3945f17..ecfed1f 100644
--- a/etc/conf.d/module_reporting.xml
+++ b/etc/conf.d/module_reporting.xml
@@ -13,7 +13,7 @@
                         <ae:parameter name="jasper_url">http://10.121.0.82:8080/jasperserver</ae:parameter>
                         <ae:parameter name="jasper_user">jasperadmin</ae:parameter>
                         <ae:parameter name="jasper_pass">jasperadmin</ae:parameter>
-                        <ae:parameter name="tree_root">/icinga</ae:parameter>
+                        <ae:parameter name="tree_root">/icinga/reports</ae:parameter>
                     </setting>
             </settings>
     </module>





More information about the icinga-checkins mailing list