From 37c43199cad28df5d12138cb19aaae42f8c45a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 21 Jul 2014 18:49:30 +0200 Subject: [PATCH] Fix for annotations hover tooltip and timestamp when timezone set to utc, Fixes #611, #394 --- src/app/panels/graph/module.js | 1 - src/app/services/annotationsSrv.js | 9 ++++++++- src/app/services/dashboard/dashboardModel.js | 2 +- src/app/services/graphite/graphiteDatasource.js | 6 +++--- src/config.sample.js | 12 ------------ 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/app/panels/graph/module.js b/src/app/panels/graph/module.js index 32a3dfc490e..b41dc9ce3a6 100644 --- a/src/app/panels/graph/module.js +++ b/src/app/panels/graph/module.js @@ -272,7 +272,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { format: $scope.panel.renderer === 'png' ? 'png' : 'json', maxDataPoints: $scope.resolution, datasource: $scope.panel.datasource, - timezone: $scope.dashboard.timezone }; $scope.annotationsPromise = annotationsSrv.getAnnotations($scope.filter, $scope.rangeUnparsed, $scope.dashboard); diff --git a/src/app/services/annotationsSrv.js b/src/app/services/annotationsSrv.js index 958df500db5..7ce3cdbc3e3 100644 --- a/src/app/services/annotationsSrv.js +++ b/src/app/services/annotationsSrv.js @@ -11,6 +11,7 @@ define([ var promiseCached; var annotationPanel; var list = []; + var timezone; this.init = function() { $rootScope.$on('refresh', this.clearCache); @@ -31,6 +32,7 @@ define([ return promiseCached; } + var timezone = dashboard,timezone; var annotations = _.where(annotationPanel.annotations, { enable: true }); var promises = _.map(annotations, function(annotation) { @@ -65,7 +67,12 @@ define([ tooltip += (options.tags || '') + '
'; } - tooltip += '' + moment(options.time).format('YYYY-MM-DD HH:mm:ss') + '
'; + if (timezone === 'browser') { + tooltip += '' + moment(options.time).format('YYYY-MM-DD HH:mm:ss') + '
'; + } + else { + tooltip += '' + moment.utc(options.time).format('YYYY-MM-DD HH:mm:ss') + '
'; + } if (options.text) { tooltip += options.text.replace(/\n/g, '
'); diff --git a/src/app/services/dashboard/dashboardModel.js b/src/app/services/dashboard/dashboardModel.js index 767ba61a7d1..13c4f913520 100644 --- a/src/app/services/dashboard/dashboardModel.js +++ b/src/app/services/dashboard/dashboardModel.js @@ -20,7 +20,7 @@ function (angular, $, kbn, _) { this.title = data.title; this.tags = data.tags || []; this.style = data.style || "dark"; - this.timezone = data.browser || 'browser'; + this.timezone = data.timezone || 'browser'; this.editable = data.editble || true; this.rows = data.rows || []; this.pulldowns = data.pulldowns || []; diff --git a/src/app/services/graphite/graphiteDatasource.js b/src/app/services/graphite/graphiteDatasource.js index 00c7752c0c6..4bf95f65ea2 100644 --- a/src/app/services/graphite/graphiteDatasource.js +++ b/src/app/services/graphite/graphiteDatasource.js @@ -27,8 +27,8 @@ function (angular, _, $, config, kbn, moment) { GraphiteDatasource.prototype.query = function(filterSrv, options) { try { var graphOptions = { - from: this.translateTime(options.range.from, options.timezone, 'round-down'), - until: this.translateTime(options.range.to, options.timezone, 'round-up'), + from: this.translateTime(options.range.from, 'round-down'), + until: this.translateTime(options.range.to, 'round-up'), targets: options.targets, format: options.format, maxDataPoints: options.maxDataPoints, @@ -125,7 +125,7 @@ function (angular, _, $, config, kbn, moment) { } }; - GraphiteDatasource.prototype.translateTime = function(date, timezone, rounding) { + GraphiteDatasource.prototype.translateTime = function(date, rounding) { if (_.isString(date)) { if (date === 'now') { return 'now'; diff --git a/src/config.sample.js b/src/config.sample.js index 98f3ad41ed9..e151a6c311d 100644 --- a/src/config.sample.js +++ b/src/config.sample.js @@ -35,18 +35,6 @@ function (Settings) { // Elasticsearch index for storing dashboards grafana_index: "grafana-dash", - // timezoneOFfset: - // If you experiance problems with zoom, it is probably caused by timezone diff between - // your browser and the graphite-web application. timezoneOffset setting can be used to have Grafana - // translate absolute time ranges to the graphite-web timezone. - // Example: - // If TIME_ZONE in graphite-web config file local_settings.py is set to America/New_York, then set - // timezoneOffset to "-0500" (for UTC - 5 hours) - // Example: - // If TIME_ZONE is set to UTC, set this to "0000" - // - timezoneOffset: null, - // set to false to disable unsaved changes warning unsaved_changes_warning: true,