diff --git a/public/app/features/dashboard/dashboardCtrl.js b/public/app/features/dashboard/dashboardCtrl.js
index ea0d91019b8..b6702631155 100644
--- a/public/app/features/dashboard/dashboardCtrl.js
+++ b/public/app/features/dashboard/dashboardCtrl.js
@@ -134,6 +134,10 @@ function (angular, $, config, moment) {
});
};
+ $scope.timezoneChanged = function() {
+ $rootScope.$broadcast("refresh");
+ };
+
$scope.formatDate = function(date) {
return moment(date).format('MMM Do YYYY, h:mm:ss a');
};
diff --git a/public/app/features/dashboard/dashboardSrv.js b/public/app/features/dashboard/dashboardSrv.js
index b3194868d97..ed119f6e23f 100644
--- a/public/app/features/dashboard/dashboardSrv.js
+++ b/public/app/features/dashboard/dashboardSrv.js
@@ -9,7 +9,7 @@ function (angular, $, _, moment) {
var module = angular.module('grafana.services');
- module.factory('dashboardSrv', function() {
+ module.factory('dashboardSrv', function(contextSrv) {
function DashboardModel (data, meta) {
if (!data) {
@@ -25,7 +25,7 @@ function (angular, $, _, moment) {
this.originalTitle = this.title;
this.tags = data.tags || [];
this.style = data.style || "dark";
- this.timezone = data.timezone || 'browser';
+ this.timezone = data.timezone || '';
this.editable = data.editable !== false;
this.hideControls = data.hideControls || false;
this.sharedCrosshair = data.sharedCrosshair || false;
@@ -208,6 +208,14 @@ function (angular, $, _, moment) {
});
};
+ p.isTimezoneUtc = function() {
+ return this.getTimezone() === 'utc';
+ };
+
+ p.getTimezone = function() {
+ return this.timezone ? this.timezone : contextSrv.user.timezone;
+ };
+
p._updateSchema = function(old) {
var i, j, k;
var oldVersion = this.schemaVersion;
diff --git a/public/app/features/dashboard/partials/settings.html b/public/app/features/dashboard/partials/settings.html
index ca591c0c481..2a2287613ae 100644
--- a/public/app/features/dashboard/partials/settings.html
+++ b/public/app/features/dashboard/partials/settings.html
@@ -34,7 +34,7 @@
diff --git a/public/app/features/dashboard/timepicker/timepicker.ts b/public/app/features/dashboard/timepicker/timepicker.ts
index 453eaaf3204..2f757d36357 100644
--- a/public/app/features/dashboard/timepicker/timepicker.ts
+++ b/public/app/features/dashboard/timepicker/timepicker.ts
@@ -44,7 +44,7 @@ export class TimePickerCtrl {
var time = angular.copy(this.timeSrv.timeRange());
var timeRaw = angular.copy(this.timeSrv.timeRange(false));
- if (this.dashboard.timezone === 'browser') {
+ if (!this.dashboard.isTimezoneUtc()) {
time.from.local();
time.to.local();
if (moment.isMoment(timeRaw.from)) {
@@ -125,7 +125,7 @@ export class TimePickerCtrl {
}
getAbsoluteMomentForTimezone(jsDate) {
- return this.dashboard.timezone === 'browser' ? moment(jsDate) : moment(jsDate).utc();
+ return this.dashboard.isTimezoneUtc() ? moment(jsDate).utc() : moment(jsDate);
}
setRelativeFilter(timespan) {
diff --git a/public/app/features/org/prefs_control.ts b/public/app/features/org/prefs_control.ts
index bd1cee06bac..53704d5e390 100644
--- a/public/app/features/org/prefs_control.ts
+++ b/public/app/features/org/prefs_control.ts
@@ -2,7 +2,7 @@
import config from 'app/core/config';
import _ from 'lodash';
-import coreModule from '../../core/core_module';
+import coreModule from 'app/core/core_module';
export class PrefsControlCtrl {
prefs: any;
@@ -42,9 +42,7 @@ export class PrefsControlCtrl {
};
this.backendSrv.put(`/api/${this.mode}/preferences`, cmd).then(() => {
- if (this.oldTheme !== cmd.theme) {
- window.location.href = config.appSubUrl + this.$location.path();
- }
+ window.location.href = config.appSubUrl + this.$location.path();
});
}
diff --git a/public/app/plugins/panel/graph/graph.js b/public/app/plugins/panel/graph/graph.js
index 0443a294eed..4e948bf8e5b 100755
--- a/public/app/plugins/panel/graph/graph.js
+++ b/public/app/plugins/panel/graph/graph.js
@@ -279,7 +279,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
var max = _.isUndefined(ctrl.range.to) ? null : ctrl.range.to.valueOf();
options.xaxis = {
- timezone: dashboard.timezone,
+ timezone: dashboard.getTimezone(),
show: panel['x-axis'],
mode: "time",
min: min,
diff --git a/public/app/plugins/panel/table/module.ts b/public/app/plugins/panel/table/module.ts
index d5ac802a62b..2d39d349d9e 100644
--- a/public/app/plugins/panel/table/module.ts
+++ b/public/app/plugins/panel/table/module.ts
@@ -155,7 +155,7 @@ class TablePanelCtrl extends MetricsPanelCtrl {
}
function appendTableRows(tbodyElem) {
- var renderer = new TableRenderer(panel, data, ctrl.dashboard.timezone);
+ var renderer = new TableRenderer(panel, data, ctrl.dashboard.isTimezoneUtc());
tbodyElem.empty();
tbodyElem.html(renderer.render(ctrl.pageIndex));
}
diff --git a/public/app/plugins/panel/table/renderer.ts b/public/app/plugins/panel/table/renderer.ts
index 0a306b103a4..c00656071be 100644
--- a/public/app/plugins/panel/table/renderer.ts
+++ b/public/app/plugins/panel/table/renderer.ts
@@ -8,7 +8,7 @@ export class TableRenderer {
formaters: any[];
colorState: any;
- constructor(private panel, private table, private timezone) {
+ constructor(private panel, private table, private isUtc) {
this.formaters = [];
this.colorState = {};
}
@@ -45,7 +45,7 @@ export class TableRenderer {
return v => {
if (_.isArray(v)) { v = v[0]; }
var date = moment(v);
- if (this.timezone === 'utc') {
+ if (this.isUtc) {
date = date.utc();
}
return date.format(style.dateFormat);