[icinga-checkins] icinga.org: icinga-web/master: * Added service flags, added filterbutton for services

git at icinga.org git at icinga.org
Fri Nov 11 15:02:23 CET 2011


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

Author: Jannis Mosshammer <jannis.mosshammer at netways.de>
Date:   Fri Nov 11 14:50:22 2011 +0100

* Added service flags, added filterbutton for services

---

 .../Cronks/Tackle/Filter/TackleMainFilterTbar.js   |   46 ++++++++++++------
 .../Cronks/lib/js/Cronks/Tackle/ObjectGrid.js      |    3 +
 .../Tackle/Renderer/FlagIconColumnRenderer.js      |    2 +-
 .../Cronks/lib/js/Cronks/Tackle/ServicesSubGrid.js |   52 +++++++++++++++-----
 4 files changed, 75 insertions(+), 28 deletions(-)

diff --git a/app/modules/Cronks/lib/js/Cronks/Tackle/Filter/TackleMainFilterTbar.js b/app/modules/Cronks/lib/js/Cronks/Tackle/Filter/TackleMainFilterTbar.js
index 64ddad0..4b95fff 100644
--- a/app/modules/Cronks/lib/js/Cronks/Tackle/Filter/TackleMainFilterTbar.js
+++ b/app/modules/Cronks/lib/js/Cronks/Tackle/Filter/TackleMainFilterTbar.js
@@ -37,8 +37,23 @@ Icinga.Cronks.Tackle.Filter.TackleMainFilterTbar = Ext.extend(Ext.Toolbar, {
 
     },
     updateFilterImpl: function() {
-         if(!this.isVisible)
+       if(!this.isVisible)
             return;
+      
+        var jsonFilter = this.buildFilter();
+        this.store.setFilter(jsonFilter);
+        this.ownerCt.bottomToolbar.doLoad();
+        if(this.autoRefreshEnabled) {
+            this.startAutoRefresh()
+        }
+    },
+    getSVCFilter : function() {
+        if(!Ext.getCmp('filterbuttons_filter_svc_'+this.parentId).pressed)
+            return false;
+        return this.buildFilter()
+    },
+
+    buildFilter: function() {
         var filter = {
             states: {
                 0 : Ext.getCmp('filterbuttons_host_state_up_'+this.parentId).pressed,
@@ -46,14 +61,11 @@ Icinga.Cronks.Tackle.Filter.TackleMainFilterTbar = Ext.extend(Ext.Toolbar, {
                 2 : Ext.getCmp('filterbuttons_host_state_unreachable_'+this.parentId).pressed,
                 99: Ext.getCmp('filterbuttons_host_state_pending_'+this.parentId).pressed
             },
+
             ack : Ext.getCmp('filterbuttons_host_ack_'+this.parentId).pressed,
             dtime : Ext.getCmp('filterbuttons_host_downtime_'+this.parentId).pressed,
             text : Ext.getCmp('filtertxt_search_'+this.parentId).getValue()
         };
-        this.buildFilter(filter);
-    },
-
-    buildFilter: function(filter) {
         var jsonFilter = {
             type: 'AND',
             field: []
@@ -106,12 +118,8 @@ Icinga.Cronks.Tackle.Filter.TackleMainFilterTbar = Ext.extend(Ext.Toolbar, {
                }]
            });
         }
-        this.store.setFilter(jsonFilter);
-        this.ownerCt.bottomToolbar.doLoad();
-        if(this.autoRefreshEnabled) {
-            this.startAutoRefresh()
-        }
-
+       
+        return jsonFilter;
     },
 
     createTbar : function(config) {
@@ -204,26 +212,22 @@ Icinga.Cronks.Tackle.Filter.TackleMainFilterTbar = Ext.extend(Ext.Toolbar, {
                 bubbleEvents: ['toggle']
             },
             items: [{
-                toggled: true,
                 ctCls: 'tackle_qbtn state_up',
                 id: 'filterbuttons_host_state_up_'+id,
                 pressed: true,
                 text: _('Up')
             },{
-                toggled: true,
                 ctCls: 'tackle_qbtn state_down',
                 id: 'filterbuttons_host_state_down_'+id,
                 pressed: true,
                 text: _('Down')
             },{
-                toggled: true,
                 ctCls: 'tackle_qbtn state_unreachable',
                 id: 'filterbuttons_host_state_unreachable_'+id,
                 pressed: true,
                 tooltip: _('Unreachable'),
                 text: _('Unreach.')
             },{
-                toggled: true,
                 ctCls: 'tackle_qbtn state_pending',
                 id: 'filterbuttons_host_state_pending_'+id,
                 pressed: true,
@@ -257,6 +261,18 @@ Icinga.Cronks.Tackle.Filter.TackleMainFilterTbar = Ext.extend(Ext.Toolbar, {
 
             style: 'position:relative;margin-left:-25px',
             disabled:true
+        },{
+            xtype: 'button',
+            iconCls: 'icinga-icon-service',
+            id: 'filterbuttons_filter_svc_'+id,
+            tooltip: 'Filter service results, too',
+            enableToggle: true,
+            listeners: {
+                toggle: function(btn) {
+                    this.updateFilter();
+                },
+               scope:this
+            }
         }];
     }
 });
\ No newline at end of file
diff --git a/app/modules/Cronks/lib/js/Cronks/Tackle/ObjectGrid.js b/app/modules/Cronks/lib/js/Cronks/Tackle/ObjectGrid.js
index ef6c1a0..de5ac66 100644
--- a/app/modules/Cronks/lib/js/Cronks/Tackle/ObjectGrid.js
+++ b/app/modules/Cronks/lib/js/Cronks/Tackle/ObjectGrid.js
@@ -32,6 +32,7 @@ Icinga.Cronks.Tackle.ObjectGrid = Ext.extend(Ext.grid.GridPanel, {
             store: this.store
         });
         this.updateFilter = config.tbar.updateFilter;
+        this.getSVCFilter = config.tbar.getSVCFilter.createDelegate(config.tbar);
         Icinga.Cronks.Tackle.ObjectGrid.superclass.constructor.call(this, config);
 	},
 
@@ -152,7 +153,9 @@ Icinga.Cronks.Tackle.ObjectGrid = Ext.extend(Ext.grid.GridPanel, {
     openServicePanel: function(id, el) {
         if(this.visibleServicePanels[id])
             this.visibleServicePanels[id].destroy();
+        
         this.visibleServicePanels[id] = new Icinga.Cronks.Tackle.ServicesSubGrid({
+            filter: this.getSVCFilter(),
             hostId: id,
             renderTo: el,
             parent:this,
diff --git a/app/modules/Cronks/lib/js/Cronks/Tackle/Renderer/FlagIconColumnRenderer.js b/app/modules/Cronks/lib/js/Cronks/Tackle/Renderer/FlagIconColumnRenderer.js
index 675e554..025dbe1 100644
--- a/app/modules/Cronks/lib/js/Cronks/Tackle/Renderer/FlagIconColumnRenderer.js
+++ b/app/modules/Cronks/lib/js/Cronks/Tackle/Renderer/FlagIconColumnRenderer.js
@@ -8,7 +8,7 @@ Icinga.Cronks.Tackle.Renderer.FlagIconColumnRenderer =  function (value, metaDat
     var isFlapping = parseInt(record.get(type.toUpperCase()+'_IS_FLAPPING'),10);
     var isNotifying = parseInt(record.get(type.toUpperCase()+'_NOTIFICATIONS_ENABLED'),10);
     var isActive = parseInt(record.get(type.toUpperCase()+'_ACTIVE_CHECKS_ENABLED'),10);
-    var value = "";
+    value = "";
     var tpl = new Ext.XTemplate("<div class='{icon}' qtip='{tip}' style='width:20px;height:18px;float:left' id='{id}'></div>");
     var idBase = Ext.id();
     if(!isActive) {
diff --git a/app/modules/Cronks/lib/js/Cronks/Tackle/ServicesSubGrid.js b/app/modules/Cronks/lib/js/Cronks/Tackle/ServicesSubGrid.js
index f30f0af..6b55737 100644
--- a/app/modules/Cronks/lib/js/Cronks/Tackle/ServicesSubGrid.js
+++ b/app/modules/Cronks/lib/js/Cronks/Tackle/ServicesSubGrid.js
@@ -20,7 +20,7 @@ Icinga.Cronks.Tackle.ServicesSubGrid = Ext.extend(Ext.grid.GridPanel, {
 
     constructor : function(config) {
         
-        config.store = this.createStore(config.hostId);
+        config.store = this.createStore(config.hostId,config.filter);
 
         config.bbar = new Ext.PagingToolbar({
             store: config.store,
@@ -30,7 +30,8 @@ Icinga.Cronks.Tackle.ServicesSubGrid = Ext.extend(Ext.grid.GridPanel, {
         
         Icinga.Cronks.Tackle.ServicesSubGrid.superclass.constructor.call(this, config);
     },
-    createStore: function(hostId) {
+    
+    createStore: function(hostId,filter) {
 
         this.store = new Icinga.Api.RESTStore({
             target: 'service',
@@ -50,21 +51,38 @@ Icinga.Cronks.Tackle.ServicesSubGrid = Ext.extend(Ext.grid.GridPanel, {
                 'SERVICE_LAST_CHECK',
                 'SERVICE_NEXT_CHECK',
                 'SERVICE_SCHEDULED_DOWNTIME_DEPTH',
-                'SERVICE_PROBLEM_HAS_BEEN_ACKNOWLEDGED'
+                'SERVICE_PROBLEM_HAS_BEEN_ACKNOWLEDGED',
+                'SERVICE_ACTIVE_CHECKS_ENABLED',
+                'SERVICE_PASSIVE_CHECKS_ENABLED',
+                'SERVICE_NOTIFICATIONS_ENABLED',
+                'SERVICE_IS_FLAPPING'
+
             ]
            
         });
-        this.store.setFilter({
-            type: 'AND',
-            field: [{
-                type: 'atom',
-                method: ['='],
-                field: ['HOST_ID'],
-                value: [hostId]
-            }]
-        });
+        var jsonFilter;
+        var hostFilter = {
+            type: 'atom',
+            method: ['='],
+            field: ['HOST_ID'],
+            value: [hostId]
+        }
+        if(filter) {
+            jsonFilter = filter;
+            jsonFilter["field"].push(hostFilter);
+        } else {
+            jsonFilter =  {
+                type: 'AND',
+                field: [hostFilter]
+            }
+        }
+        this.store.setFilter(
+            jsonFilter
+        );
+
         return this.store;
     },
+
     realign: function() {
         try {
             this.setWidth(this.parent.getInnerWidth()-50);
@@ -148,6 +166,16 @@ Icinga.Cronks.Tackle.ServicesSubGrid = Ext.extend(Ext.grid.GridPanel, {
                        return "<div qtip='"+str+"'>"+value+"</div>";
                    return "<div qtip='"+value+"'>"+str+"</div>";
                 }
+            }, {
+                header: _('Flags'),
+                dataIndex: 'SERVICE_ID',
+                width: 100,
+                renderer: Icinga.Cronks.Tackle.Renderer.FlagIconColumnRenderer,
+                listeners: {
+                    click: Icinga.Cronks.Tackle.Renderer.FlagIconColumnClickHandler,
+                    scope: this
+                }
+
             }]
 		});
         Icinga.Cronks.Tackle.ServicesSubGrid.superclass.initComponent.call(this);





More information about the icinga-checkins mailing list