[icinga-checkins] icinga.org: icinga-web/mhein/default: * Lazy loading for relation ( refs #1941)

git at icinga.org git at icinga.org
Fri Nov 18 17:58:31 CET 2011


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

Author: Marius Hein <marius.hein at netways.de>
Date:   Fri Nov 18 17:20:01 2011 +0100

* Lazy loading for relation (refs #1941)

---

 .../Cronks/lib/js/Cronks/Tackle/Relation/Head.js   |   27 +++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/app/modules/Cronks/lib/js/Cronks/Tackle/Relation/Head.js b/app/modules/Cronks/lib/js/Cronks/Tackle/Relation/Head.js
index 0e3711f..caab1cd 100644
--- a/app/modules/Cronks/lib/js/Cronks/Tackle/Relation/Head.js
+++ b/app/modules/Cronks/lib/js/Cronks/Tackle/Relation/Head.js
@@ -8,8 +8,12 @@ Icinga.Cronks.Tackle.Relation.Head = Ext.extend(Ext.Panel, {
             align: 'stretch',
             pack: 'start'
     },
+    
 	stores : [],
 	
+	objectId : null,
+	loaded : false,
+	
     constructor : function(config) {
     	if (Ext.isEmpty(config.type)) {
                 throw ("config.type is needed: host or service!");
@@ -142,14 +146,35 @@ Icinga.Cronks.Tackle.Relation.Head = Ext.extend(Ext.Panel, {
             this.buildGroupGrid()
         ]);
         
+        this.on('show', this.loadData.createDelegate(this, [], false));
+        
         this.doLayout();
     },
     
     loadDataForObjectId : function(objectId) {
-    	this.loadData(objectId);
+    	if (Ext.isEmpty(objectId) === false && objectId === this.objectId) {
+    		return;
+    	}
+    	
+    	this.objectId = objectId;
+    	this.loaded = false;
+    	
+    	
+    	if (this.isVisible()) {
+    		this.loadData();
+    	}
     },
     
     loadData : function(id) {
+    	
+    	if (this.loaded === true) {
+    		return;
+    	}
+    	
+    	if (Ext.isEmpty(id) && this.objectId) {
+    		id = this.objectId;
+    	}
+    	
     	Ext.Ajax.request({
     		url : String.format('{0}/web/api/relation/{1}', AppKit.util.Config.get('path'), id),
     		success : function(response, opts) {





More information about the icinga-checkins mailing list