[frontend] Remember the selected granularity in the performance graph
<script type="text/html" id="performance-graph-template">
<div style="position: relative" data-bind="template: { afterRender: componentRendered }">
- <h3 style="float: left;">${ _('Resources') }</h3>
- <div style="padding-top: 22px; float: right;" data-bind="foreach: availableGranularities"><a class="margin-right-20" href="javascript: void(0);" data-bind="text: label, click: function () { $parent.selectedGranularity($data); }"></a></div>
+ <div style="padding: 10px; float: right;" data-bind="foreach: availableGranularities">
+ <!-- ko if: $data === $parent.selectedGranularity() -->
+ <span class="margin-right-20" data-bind="text: label"></span>
+ <!-- /ko -->
+ <!-- ko if: $data !== $parent.selectedGranularity() -->
+ <a class="margin-right-20" href="javascript: void(0);" data-bind="text: label, click: function () { $parent.selectedGranularity($data); }"></a>
+ <!-- /ko -->
+ </div>
<div style="clear: both;" class="performance-graph" data-bind="style: { height: graphHeight + 'px', width: graphWidth + 'px' }"></div>
</div>
</script>
points: 2016 // Every 5 minutes
}];
- self.selectedGranularity = ko.observable(self.availableGranularities[1]);
+ self.selectedGranularity = ko.observable(self.availableGranularities[ApiHelper.getInstance().getFromTotalStorage('warehouses', 'performanceGraphGranularity', 0)]);
// Load the initial data
var now = Date.now();
initialLoadPromise.done(function () {
self.redrawGraph();
self.selectedGranularity.subscribe(function (granularity) {
+ for (var i = 0; i < self.availableGranularities.length; i++) {
+ if (granularity === self.availableGranularities[i]) {
+ ApiHelper.getInstance().setInTotalStorage('warehouses', 'performanceGraphGranularity', i);
+ break;
+ }
+ }
window.clearTimeout(self.appendTimeout);
self.data = undefined;
self.loadData(now - granularity.totalTime, now, granularity.points).done(function () {
