Commit 4b567e35 by Mitsuhiro Tanda Committed by Torkel Ödegaard

suppress refresh when user is inactive (#7219)

parent f045fbf2
......@@ -57,6 +57,10 @@ export class ContextSrv {
store.set('grafana.sidemenu.pinned', val);
}
isGrafanaVisible() {
return !!(document.visibilityState === undefined || document.visibilityState === 'visible');
}
toggleSideMenu() {
this.sidemenu = !this.sidemenu;
if (!this.sidemenu) {
......
......@@ -10,7 +10,7 @@ define([
var module = angular.module('grafana.services');
module.service('timeSrv', function($rootScope, $timeout, $routeParams, timer) {
module.service('timeSrv', function($rootScope, $timeout, $routeParams, timer, contextSrv) {
var self = this;
// default time
......@@ -95,7 +95,9 @@ define([
self.cancel_scheduled_refresh();
self.refresh_timer = timer.register($timeout(function () {
self.start_scheduled_refresh(after_ms);
self.refreshDashboard();
if (contextSrv.isGrafanaVisible()) {
self.refreshDashboard();
}
}, after_ms));
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment