Skip to content

Commit b60ca28

Browse files
committed
Merge pull request #101 from benjisg/fix-DashboardRefreshSelector
Fix 'disabled' auto-refresh option
2 parents b598fd5 + 9c311fb commit b60ca28

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

mrq/dashboard/static/js/views/index.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
});

mrq/dashboard/templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<option value="60">1m</option>
7979
<option value="300">5m</option>
8080
<option value="600">10m</option>
81-
<option value="0">Disabled</option>
81+
<option value="-1">Disabled</option>
8282
</select></a>
8383
</li>
8484

0 commit comments

Comments
 (0)