@@ -107,27 +107,35 @@ define(["jquery", "underscore", "views/generic/page", "models", "moment", "circl
107107 refreshStats : function ( poolSize , currentJobs , utilization , doneJobs ) {
108108 var self = this ;
109109 var values = self . addToCounter ( "overall-done-jobs" , doneJobs , 50 ) . join ( "," ) ;
110- var refreshInterval = parseInt ( $ ( ".js-autorefresh" ) . val ( ) , 10 ) * 1000 ;
111110
112111 self . $ ( ".inlinesparkline" ) . attr ( "values" , values ) ;
113112 self . $ ( ".inlinesparkline" ) . sparkline ( "html" , { "width" : "250px" , "height" : "200px" , "defaultPixelsPerValue" : 1 } ) ;
114113 self . refreshCircleStats ( poolSize , currentJobs , utilization ) ;
115-
116- setTimeout ( function ( ) {
117- self . fetchStats ( self . refreshStats ) ;
118- } , refreshInterval ) ;
114+ self . autoUpdateStats ( ) ;
119115 } ,
120116
121117 render : function ( ) {
122118 var self = this ;
123- var refreshInterval = parseInt ( $ ( ".js-autorefresh" ) . val ( ) , 10 ) * 1000 ;
124119
125120 self . renderTemplate ( ) ;
126121 self . fetchStats ( self . renderStats ) ;
122+ self . autoUpdateStats ( ) ;
123+ } ,
127124
128- setTimeout ( function ( ) {
129- self . fetchStats ( self . refreshStats ) ;
130- } , refreshInterval ) ;
125+ autoUpdateStats : function ( ) {
126+ var self = this ;
127+ var refreshInterval = parseInt ( $ ( ".js-autorefresh" ) . val ( ) , 10 ) * 1000 ;
128+
129+ if ( refreshInterval > 0 ) {
130+ setTimeout ( function ( ) {
131+ self . fetchStats ( self . refreshStats ) ;
132+ } , refreshInterval ) ;
133+ } else {
134+ // Check if the option has changed again in 2 seconds
135+ setTimeout ( function ( ) {
136+ self . autoUpdateStats ( ) ;
137+ } , 2000 ) ;
138+ }
131139 }
132140
133141 } ) ;
0 commit comments