Load dashboard refresh rate from URL.

This commit is contained in:
Arik Fraimovich 2018-03-23 19:22:06 +03:00
parent 2f24cff33c
commit 6685cb9e21

View File

@ -96,29 +96,22 @@ function DashboardCtrl(
this.isGridDisabled = false;
this.showPermissionsControl = clientConfig.showPermissionsControl;
this.globalParameters = [];
this.refreshRates = [
{ name: '10 seconds', rate: 10 },
{ name: '30 seconds', rate: 30 },
{ name: '1 minute', rate: 60 },
{ name: '5 minutes', rate: 60 * 5 },
{ name: '10 minutes', rate: 60 * 10 },
{ name: '30 minutes', rate: 60 * 30 },
{ name: '1 hour', rate: 60 * 60 },
{ name: '12 hour', rate: 12 * 60 * 60 },
{ name: '24 hour', rate: 24 * 60 * 60 },
];
this.refreshRates =
clientConfig.dashboardRefreshIntervals.map(interval => ({ name: durationHumanize(interval), rate: interval }));
this.refreshRates = clientConfig.dashboardRefreshIntervals.map(interval => ({
name: durationHumanize(interval),
rate: interval,
}));
$rootScope.$on('gridster-mobile-changed', ($event, gridster) => {
this.isGridDisabled = gridster.isMobile;
});
this.setRefreshRate = (rate) => {
this.setRefreshRate = (rate, load = true) => {
this.refreshRate = rate;
if (rate !== null) {
if (load) {
this.loadDashboard(true);
}
this.autoRefresh();
}
};
@ -210,6 +203,17 @@ function DashboardCtrl(
this.editLayout(true);
}
if ($location.search().refresh !== undefined) {
if (this.refreshRate === null) {
const refreshRate = Math.max(30, parseFloat($location.search().refresh));
this.setRefreshRate({
name: durationHumanize(refreshRate),
rate: refreshRate,
}, false);
}
}
savedWidgetPositions = collectWidgetPositions(dashboard.widgets);
},
(rejection) => {