[icinga-checkins] icinga.org: icinga-web/master: * Better loading for object info component ( fixes #2132)

git at icinga.org git at icinga.org
Tue Feb 21 15:01:06 CET 2012


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

Author: Marius Hein <marius.hein at netways.de>
Date:   Tue Feb 21 15:00:42 2012 +0100

* Better loading for object info component (fixes #2132)

---

 .../lib/js/Cronks/Tackle/Information/Head.js       |    4 +
 .../grid/renderer/ObjectInfoComponentRenderer.js   |  160 +++++++++++---------
 doc/CHANGELOG-1.6                                  |    1 +
 3 files changed, 94 insertions(+), 71 deletions(-)

diff --git a/app/modules/Cronks/lib/js/Cronks/Tackle/Information/Head.js b/app/modules/Cronks/lib/js/Cronks/Tackle/Information/Head.js
index c6a0361..ecd348f 100644
--- a/app/modules/Cronks/lib/js/Cronks/Tackle/Information/Head.js
+++ b/app/modules/Cronks/lib/js/Cronks/Tackle/Information/Head.js
@@ -127,6 +127,10 @@ Ext.ns('Icinga.Cronks.Tackle.Information');
             });
 
             this.store.load();
+        },
+        
+        getStore: function() {
+        	return this.store;
         }
     });
 
diff --git a/app/modules/Cronks/lib/js/grid/renderer/ObjectInfoComponentRenderer.js b/app/modules/Cronks/lib/js/grid/renderer/ObjectInfoComponentRenderer.js
index bf4bd51..17c18f6 100644
--- a/app/modules/Cronks/lib/js/grid/renderer/ObjectInfoComponentRenderer.js
+++ b/app/modules/Cronks/lib/js/grid/renderer/ObjectInfoComponentRenderer.js
@@ -3,55 +3,74 @@ Ext.ns('Cronk.grid');
 (function() {
 
     Cronk.grid.ObjectInfoComponentRenderer = new (Ext.extend(Ext.Window, {
-    	width: '80%',
-    	height: 400,
-    	title: _('Object information'),
-    	closeAction: 'hide',
-    	layout: 'fit',
-    	
+        width: '80%',
+        height: 400,
+        title: _('Object information'),
+        closeAction: 'hide',
+        layout: 'fit',
+        modal: true,
+        
         constructor : function() {
-        	this.addEvents({
-        		"showobjectinfo" : true
-        	});
-        	
-        	Ext.Window.prototype.constructor.call(this, {});
+            this.addEvents({
+                "showobjectinfo" : true
+            });
+            
+            Ext.Window.prototype.constructor.call(this, {});
         },
         
         initComponent : function() {
-        	Ext.Window.prototype.initComponent.call(this);
-        	
-        	this.tabs = new Ext.TabPanel();
-        	
-        	this.tabItems = {
-        		host: {},
-        		service: {}
-        	};
-        	
-        	Ext.iterate(this.tabItems, function(k, v) {
-        		v.information = new Icinga.Cronks.Tackle.Information.Head({
-        			type: k
-        		});
-        		
-        		v.relation = new Icinga.Cronks.Tackle.Relation.Head({
+            this.bbar = ['->', {
+                text: _('Close'),
+                iconCls: 'icinga-action-icon-cancel',
+                handler: (function(b, e) {
+                    this.hide();
+                }).createDelegate(this)
+            }];
+            
+            Ext.Window.prototype.initComponent.call(this);
+            
+            this.tabs = new Ext.TabPanel();
+            
+            this.tabItems = {
+                host: {},
+                service: {}
+            };
+            
+            Ext.iterate(this.tabItems, function(k, v) {
+                v.information = new Icinga.Cronks.Tackle.Information.Head({
+                    type: k
+                });
+                
+                // We do not want to call this explicit
+                v.information.getStore().on('beforeload', function() {
+                    this.show();
+                    this.getEl().mask(_('Loading . . .'));
+                }, this);
+                
+                v.information.getStore().on('load', function() {
+                    this.getEl().unmask();
+                }, this);
+                
+                v.relation = new Icinga.Cronks.Tackle.Relation.Head({
                     type: k
                 });
                 
                 Ext.iterate(v, function(k2, v2) {
-                	this.tabs.add(v2)
+                    this.tabs.add(v2)
                 }, this);
-        	}, this);
-        	
-        	this.add(this.tabs);
-        	
-        	this.doLayout();
-        	
-        	this.on('showobjectinfo', this.onShowObjectInfo, this);
-        	
-        	this.on('beforeshow', function(me) {
-        		if (me.type) {
-        			me.prepareView(me.type);
-        		}
-        	})
+            }, this);
+            
+            this.add(this.tabs);
+            
+            this.doLayout();
+            
+            this.on('showobjectinfo', this.onShowObjectInfo, this);
+            
+            this.on('beforeshow', function(me) {
+                if (me.type) {
+                    me.prepareView(me.type);
+                }
+            });
         },
         
         prepareView : function(type) {
@@ -69,49 +88,48 @@ Ext.ns('Cronk.grid');
         
        // Private
         onShowObjectInfo : function(type, oid) {
-        	this.type = type;
-        	
-        	Ext.iterate(this.tabItems[type], function(k, object) {
-        		if (!Ext.isEmpty(object.loadDataForObjectId)) {
-        		  object.loadDataForObjectId(oid);
-        		} else {
-        			throw("WHOO, loadDataForObjectId is not implemented!");
-        		}
-        	}, this);
-        	
-        	this.tabs.setActiveTab(this.tabItems[type].information);
-        	
-        	this.show();
+            this.type = type;
+            
+            Ext.iterate(this.tabItems[type], function(k, object) {
+                if (!Ext.isEmpty(object.loadDataForObjectId)) {
+                  object.loadDataForObjectId(oid);
+                } else {
+                    throw("WHOO, loadDataForObjectId is not implemented!");
+                }
+            }, this);
+            
+            this.tabs.setActiveTab(this.tabItems[type].information);
+            
         },
         
         showObjectInfo : function(type, oid) {
-        	this.fireEvent('showobjectinfo', type, oid);
+            this.fireEvent('showobjectinfo', type, oid);
         },
         
         infoColumn : function(cfg) {
-        	if (Ext.isEmpty(cfg.object_id)) {
+            if (Ext.isEmpty(cfg.object_id)) {
                 throw('object_id must be configured');
             }
-        	
-        	if (Ext.isEmpty(cfg.type)) {
+            
+            if (Ext.isEmpty(cfg.type)) {
                 throw('object_id must be configured');
             }
-        	
-			return function(grid, rowIndex, colIndex, e) {
-				var fieldName = grid.getColumnModel().getDataIndex(colIndex);
+            
+            return function(grid, rowIndex, colIndex, e) {
+                var fieldName = grid.getColumnModel().getDataIndex(colIndex);
                 if (fieldName == cfg.field) {
-                	var data = grid.getStore().getAt(rowIndex).data;
-                	
-                	if (Ext.isEmpty(data[cfg.object_id])) {
-                		throw("Could not find object_id in field " + cfg.object_id);
-                	}
-                	
-                	var id = data[cfg.object_id];
-                	var type = cfg.type;
-                	
-                	Cronk.grid.ObjectInfoComponentRenderer.showObjectInfo(type, id);
+                    var data = grid.getStore().getAt(rowIndex).data;
+                    
+                    if (Ext.isEmpty(data[cfg.object_id])) {
+                        throw("Could not find object_id in field " + cfg.object_id);
+                    }
+                    
+                    var id = data[cfg.object_id];
+                    var type = cfg.type;
+                    
+                    Cronk.grid.ObjectInfoComponentRenderer.showObjectInfo(type, id);
                 }
-			};
+            };
         }
     }));
 
diff --git a/doc/CHANGELOG-1.6 b/doc/CHANGELOG-1.6
index 5fb3b19..729b962 100644
--- a/doc/CHANGELOG-1.6
+++ b/doc/CHANGELOG-1.6
@@ -17,6 +17,7 @@ Features
     * New security layer for new api (DOCTRINE filter chain) #2297
     * Removed useless SQL counts for views: history, logs, notification 
     * Fixed old JS objects the JSHINT way (performance, IE compat)
+    * Added tackle components for object info #2132
 
 Bugs
     * Fixed Auth.Dispatch import group assign #2284





More information about the icinga-checkins mailing list