mirror of https://gitee.com/bigwinds/arangodb
update checkboxes dynamically
This commit is contained in:
parent
38ce7df1a8
commit
40baf853f4
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
<ul class="dropdown-menu interval-dropdown">
|
<ul class="dropdown-menu interval-dropdown">
|
||||||
<li class="nav-header">Update every:</li>
|
<li class="nav-header">Update every:</li>
|
||||||
<li><a><label class="radio"><input type="radio" name="updateInterval" id="every5seconds" value="5" checked>5 seconds</label></a></li>
|
<li><a><label class="radio"><input type="radio" name="updateInterval" id="every5seconds" value="5">5 seconds</label></a></li>
|
||||||
<li><a><label class="radio"><input type="radio" name="updateInterval" id="every15seconds" value="15">15 seconds</label></a></li>
|
<li><a><label class="radio"><input type="radio" name="updateInterval" id="every15seconds" value="15">15 seconds</label></a></li>
|
||||||
<li><a><label class="radio"><input type="radio" name="updateInterval" id="every30seconds" value="30">30 seconds</label></a></li>
|
<li><a><label class="radio"><input type="radio" name="updateInterval" id="every30seconds" value="30">30 seconds</label></a></li>
|
||||||
<li><a><label class="radio"><input type="radio" name="updateInterval" id="every60seconds" value="60">60 seconds</label></a></li>
|
<li><a><label class="radio"><input type="radio" name="updateInterval" id="every60seconds" value="60">60 seconds</label></a></li>
|
||||||
|
|
|
@ -10,7 +10,7 @@ var dashboardView = Backbone.View.extend({
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.initUnits();
|
this.initUnits();
|
||||||
|
|
||||||
this.collection.fetch({
|
this.collection.fetch({
|
||||||
|
@ -69,6 +69,8 @@ var dashboardView = Backbone.View.extend({
|
||||||
self.renderFigure(this);
|
self.renderFigure(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('input[name=every'+self.updateInterval/1000 +']').attr('checked', true);
|
||||||
|
|
||||||
if (this.collection.models[0] === undefined) {
|
if (this.collection.models[0] === undefined) {
|
||||||
this.collection.fetch({
|
this.collection.fetch({
|
||||||
success: function() {
|
success: function() {
|
||||||
|
@ -85,7 +87,6 @@ var dashboardView = Backbone.View.extend({
|
||||||
self.calculateSeries();
|
self.calculateSeries();
|
||||||
self.renderCharts();
|
self.renderCharts();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -147,19 +148,19 @@ var dashboardView = Backbone.View.extend({
|
||||||
var identifier = figure.identifier;
|
var identifier = figure.identifier;
|
||||||
var chart;
|
var chart;
|
||||||
|
|
||||||
if (self.charts[identifier] === undefined) {
|
if (self.charts[identifier] === undefined) {
|
||||||
chart = self.charts[identifier] = nv.models.lineChart();
|
chart = self.charts[identifier] = nv.models.lineChart();
|
||||||
chart.xAxis.axisLabel('').tickFormat(function (d) {
|
chart.xAxis.axisLabel('').tickFormat(function (d) {
|
||||||
if (isNaN(d)) {
|
if (isNaN(d)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function pad (value) {
|
function pad (value) {
|
||||||
return (value < 10 ? "0" + String(value) : String(value));
|
return (value < 10 ? "0" + String(value) : String(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
var date = new Date(d / 10);
|
var date = new Date(d / 10);
|
||||||
|
|
||||||
return pad(date.getHours()) + ":" + pad(date.getMinutes()) + ":" + pad(date.getSeconds());
|
return pad(date.getHours()) + ":" + pad(date.getMinutes()) + ":" + pad(date.getSeconds());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -167,9 +168,9 @@ var dashboardView = Backbone.View.extend({
|
||||||
|
|
||||||
if (figure.units === 'bytes') {
|
if (figure.units === 'bytes') {
|
||||||
label = "megabytes";
|
label = "megabytes";
|
||||||
}
|
}
|
||||||
chart.yAxis.axisLabel(label);
|
chart.yAxis.axisLabel(label);
|
||||||
|
|
||||||
nv.addGraph (function () {
|
nv.addGraph (function () {
|
||||||
nv.utils.windowResize(function () {
|
nv.utils.windowResize(function () {
|
||||||
d3.select('#' + identifier + 'Chart svg').call(chart);
|
d3.select('#' + identifier + 'Chart svg').call(chart);
|
||||||
|
@ -181,7 +182,7 @@ var dashboardView = Backbone.View.extend({
|
||||||
else {
|
else {
|
||||||
chart = self.charts[identifier];
|
chart = self.charts[identifier];
|
||||||
}
|
}
|
||||||
|
|
||||||
chart.yDomain([ 0, self.getMaxValue(identifier) ]);
|
chart.yDomain([ 0, self.getMaxValue(identifier) ]);
|
||||||
|
|
||||||
d3.select("#" + identifier + "Chart svg")
|
d3.select("#" + identifier + "Chart svg")
|
||||||
|
@ -211,7 +212,7 @@ var dashboardView = Backbone.View.extend({
|
||||||
self.seriesData[identifier].values.push({ x: timeStamp, y: undefined, value: undefined });
|
self.seriesData[identifier].values.push({ x: timeStamp, y: undefined, value: undefined });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var responseValue = self.collection.models[0].attributes[figure.group][identifier];
|
var responseValue = self.collection.models[0].attributes[figure.group][identifier];
|
||||||
|
|
||||||
if (responseValue !== undefined && responseValue !== null) {
|
if (responseValue !== undefined && responseValue !== null) {
|
||||||
|
|
Loading…
Reference in New Issue