From 7da57e0aa500cdd7515dfdf85716eac92818f54c Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Wed, 2 Mar 2016 13:15:35 +0900 Subject: [PATCH 1/3] align refresh interval --- public/app/features/dashboard/timeSrv.js | 10 ++++++++-- public/app/features/dashboard/timepicker/dropdown.html | 1 + public/app/features/dashboard/timepicker/timepicker.ts | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/public/app/features/dashboard/timeSrv.js b/public/app/features/dashboard/timeSrv.js index 62d7b8c591e..b0e89e32590 100644 --- a/public/app/features/dashboard/timeSrv.js +++ b/public/app/features/dashboard/timeSrv.js @@ -65,11 +65,17 @@ define([ } }; - this.setAutoRefresh = function (interval) { + this.setAutoRefresh = function (interval, align) { this.dashboard.refresh = interval; if (interval) { var _i = kbn.interval_to_ms(interval); - this.start_scheduled_refresh(_i); + var wait_ms = 0; + if (align) { + wait_ms = _i - (Date.now() % _i); + } + $timeout(function () { + self.start_scheduled_refresh(_i); + }, wait_ms); } else { this.cancel_scheduled_refresh(); } diff --git a/public/app/features/dashboard/timepicker/dropdown.html b/public/app/features/dashboard/timepicker/dropdown.html index 8b6d0c24a0c..7e40b055e9b 100644 --- a/public/app/features/dashboard/timepicker/dropdown.html +++ b/public/app/features/dashboard/timepicker/dropdown.html @@ -40,6 +40,7 @@
+
diff --git a/public/app/features/dashboard/timepicker/timepicker.ts b/public/app/features/dashboard/timepicker/timepicker.ts index 453eaaf3204..b0eb93fe894 100644 --- a/public/app/features/dashboard/timepicker/timepicker.ts +++ b/public/app/features/dashboard/timepicker/timepicker.ts @@ -109,7 +109,7 @@ export class TimePickerCtrl { applyCustom() { if (this.refresh.value !== this.dashboard.refresh) { - this.timeSrv.setAutoRefresh(this.refresh.value); + this.timeSrv.setAutoRefresh(this.refresh.value, this.refresh.align); } this.timeSrv.setTime(this.timeRaw, true); From ef22a87fcf8a5db2d32c6f54a9245c130af5e19c Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Wed, 2 Mar 2016 16:02:08 +0900 Subject: [PATCH 2/3] remove align option --- public/app/features/dashboard/timeSrv.js | 7 ++----- public/app/features/dashboard/timepicker/dropdown.html | 1 - public/app/features/dashboard/timepicker/timepicker.ts | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/public/app/features/dashboard/timeSrv.js b/public/app/features/dashboard/timeSrv.js index b0e89e32590..833530d69fe 100644 --- a/public/app/features/dashboard/timeSrv.js +++ b/public/app/features/dashboard/timeSrv.js @@ -65,14 +65,11 @@ define([ } }; - this.setAutoRefresh = function (interval, align) { + this.setAutoRefresh = function (interval) { this.dashboard.refresh = interval; if (interval) { var _i = kbn.interval_to_ms(interval); - var wait_ms = 0; - if (align) { - wait_ms = _i - (Date.now() % _i); - } + var wait_ms = _i - (Date.now() % _i); $timeout(function () { self.start_scheduled_refresh(_i); }, wait_ms); diff --git a/public/app/features/dashboard/timepicker/dropdown.html b/public/app/features/dashboard/timepicker/dropdown.html index 7e40b055e9b..8b6d0c24a0c 100644 --- a/public/app/features/dashboard/timepicker/dropdown.html +++ b/public/app/features/dashboard/timepicker/dropdown.html @@ -40,7 +40,6 @@
-
diff --git a/public/app/features/dashboard/timepicker/timepicker.ts b/public/app/features/dashboard/timepicker/timepicker.ts index b0eb93fe894..453eaaf3204 100644 --- a/public/app/features/dashboard/timepicker/timepicker.ts +++ b/public/app/features/dashboard/timepicker/timepicker.ts @@ -109,7 +109,7 @@ export class TimePickerCtrl { applyCustom() { if (this.refresh.value !== this.dashboard.refresh) { - this.timeSrv.setAutoRefresh(this.refresh.value, this.refresh.align); + this.timeSrv.setAutoRefresh(this.refresh.value); } this.timeSrv.setTime(this.timeRaw, true); From fa0b06ac6006f4afeac685b1893ab060fee4c464 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Wed, 2 Mar 2016 16:06:49 +0900 Subject: [PATCH 3/3] fix align bug --- public/app/features/dashboard/timeSrv.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/app/features/dashboard/timeSrv.js b/public/app/features/dashboard/timeSrv.js index 833530d69fe..13f5ad07bab 100644 --- a/public/app/features/dashboard/timeSrv.js +++ b/public/app/features/dashboard/timeSrv.js @@ -72,6 +72,7 @@ define([ var wait_ms = _i - (Date.now() % _i); $timeout(function () { self.start_scheduled_refresh(_i); + self.refreshDashboard(); }, wait_ms); } else { this.cancel_scheduled_refresh();