suppress refresh when user is inactive (#7219)

This commit is contained in:
Mitsuhiro Tanda 2017-01-12 03:46:34 +09:00 committed by Torkel Ödegaard
parent f045fbf267
commit 4b567e35d5
2 changed files with 8 additions and 2 deletions

View File

@ -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) {

View File

@ -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);
if (contextSrv.isGrafanaVisible()) {
self.refreshDashboard();
}
}, after_ms));
};