[icinga-checkins] icinga.org: icinga-web/mhein/default: * Prevented tackle refresh from going mad and kill your browser when being closed before initial refresh has been done

git at icinga.org git at icinga.org
Thu Nov 24 16:35:18 CET 2011


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

Author: Jannis Mosshammer <jannis.mosshammer at netways.de>
Date:   Wed Nov 23 18:07:49 2011 +0100

* Prevented tackle refresh from going mad and kill your browser when being closed before initial refresh has been done

---

 .../Cronks/Tackle/Filter/TackleMainFilterTbar.js   |   42 +++++++++++++-------
 1 files changed, 28 insertions(+), 14 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 6f8162c..9eccfc0 100644
--- a/app/modules/Cronks/lib/js/Cronks/Tackle/Filter/TackleMainFilterTbar.js
+++ b/app/modules/Cronks/lib/js/Cronks/Tackle/Filter/TackleMainFilterTbar.js
@@ -15,14 +15,18 @@ Icinga.Cronks.Tackle.Filter.TackleMainFilterTbar = Ext.extend(Ext.Toolbar, {
             filterUpdateTask.delay(200,null);
         };
         Ext.Toolbar.prototype.constructor.call(this,{
-            items: this.createTbar(config)
+            items: this.createTbar(config),
+            autoDestroy: true
         });
-
+        
+        this.on("destroy", this.stopAutoRefresh.createCallback(true), this);
+        this.on("show", this.startAutoRefresh, this);
     },
+
     startAutoRefresh: function() {
         if(this.arTask)
             return;
-       this.autoRefreshEnabled = false;
+       this.autoRefreshEnabled = true;
        this.arTask = new Ext.util.TaskRunner();
        this.arTask.start({
             run: this.updateFilterImpl,
@@ -30,24 +34,34 @@ Icinga.Cronks.Tackle.Filter.TackleMainFilterTbar = Ext.extend(Ext.Toolbar, {
             scope:this
         });
     },
-    stopAutoRefresh: function() {
+    stopAutoRefresh: function(onDestroy) {
+        // prevents restart of the autorefresh when view is destroyed before the
+        // initial delay restart delay has passed
         if(!this.arTask)
             return;
         this.autoRefreshEnabled = false;
         this.arTask.stopAll()
-        delete(this.arTask);
+        if(onDestroy)
+            this.arTask = true;
+        else
+            delete(this.arTask);
 
     },
     updateFilterImpl: function() {
-       if(!this.isVisible)
-            return;
-      
-        var jsonFilter = this.buildFilter();
-        this.store.setFilter(jsonFilter);
-        this.ownerCt.bottomToolbar.doLoad();
-        if(this.autoRefreshEnabled && !this.arTask) {
-            this.startAutoRefresh.defer(this.autoRefreshInterval,this);
-        }
+       try {
+           if(!this.isVisible())
+                return;
+
+            var jsonFilter = this.buildFilter();
+            this.store.setFilter(jsonFilter);
+
+            this.ownerCt.bottomToolbar.doLoad();
+            if(this.autoRefreshEnabled && !this.arTask) {
+                this.startAutoRefresh.defer(this.autoRefreshInterval,this);
+            }
+       } catch(e) {
+           this.stopAutoRefresh(); // prevent error madness 
+       }
     },
     getSVCFilter : function() {
         if(!Ext.getCmp('filterbuttons_filter_svc_'+this.parentId).pressed)





More information about the icinga-checkins mailing list