Commit 1a3dac0c by Torkel Ödegaard

Fix for timepicker dates and tooltip when UTC timzone is selected,

custom date modal is still local time, Closes #277
parent ffd73e8b
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
**Fixes** **Fixes**
- [Issue #696](https://github.com/grafana/grafana/issues/696). Graph: Fix for y-axis format 'none' when values are in scientific notation (ex 2.3e-13) - [Issue #696](https://github.com/grafana/grafana/issues/696). Graph: Fix for y-axis format 'none' when values are in scientific notation (ex 2.3e-13)
- [Issue #697](https://github.com/grafana/grafana/issues/697). Graphite: Fix for Glob syntax in graphite queries ([1-9] and ?) that made the query editor / parser bail and fallback to a text box. - [Issue #697](https://github.com/grafana/grafana/issues/697). Graphite: Fix for Glob syntax in graphite queries ([1-9] and ?) that made the query editor / parser bail and fallback to a text box.
- [Issue #277](https://github.com/grafana/grafana/issues/277). Dashboard: Fix for timepicker date & tooltip when UTC timezone selected. Closes #277
**Tech** **Tech**
- Upgraded from angularjs 1.1.5 to 1.3 beta 17; - Upgraded from angularjs 1.1.5 to 1.3 beta 17;
......
define(['jquery','lodash','moment'], define([
'jquery',
'lodash',
'moment'
],
function($, _, moment) { function($, _, moment) {
'use strict'; 'use strict';
......
...@@ -354,10 +354,7 @@ function (angular, $, kbn, moment, _) { ...@@ -354,10 +354,7 @@ function (angular, $, kbn, moment, _) {
} }
value = kbn.getFormatFunction(format, 2)(value); value = kbn.getFormatFunction(format, 2)(value);
timestamp = dashboard.formatDate(item.datapoint[0]);
timestamp = dashboard.timezone === 'browser' ?
moment(item.datapoint[0]).format('YYYY-MM-DD HH:mm:ss') :
moment.utc(item.datapoint[0]).format('YYYY-MM-DD HH:mm:ss');
$tooltip.html(group + value + " @ " + timestamp).place_tt(pos.pageX, pos.pageY); $tooltip.html(group + value + " @ " + timestamp).place_tt(pos.pageX, pos.pageY);
} else { } else {
......
...@@ -80,9 +80,14 @@ function (angular, app, _, moment, kbn) { ...@@ -80,9 +80,14 @@ function (angular, app, _, moment, kbn) {
$scope.temptime = cloneTime($scope.time); $scope.temptime = cloneTime($scope.time);
$scope.tempnow = $scope.panel.now; $scope.tempnow = $scope.panel.now;
$scope.temptime.from.date.setHours(0,0,0,0);
$scope.temptime.to.date.setHours(0,0,0,0);
// Date picker needs the date to be at the start of the day // Date picker needs the date to be at the start of the day
$scope.temptime.from.date.setHours(1,0,0,0); if(new Date().getTimezoneOffset() < 0) {
$scope.temptime.to.date.setHours(1,0,0,0); $scope.temptime.from.date = moment($scope.temptime.from.date).add('days',1).toDate();
$scope.temptime.to.date = moment($scope.temptime.to.date).add('days',1).toDate();
}
$q.when(customTimeModal).then(function(modalEl) { $q.when(customTimeModal).then(function(modalEl) {
modalEl.modal('show'); modalEl.modal('show');
...@@ -175,8 +180,8 @@ function (angular, app, _, moment, kbn) { ...@@ -175,8 +180,8 @@ function (angular, app, _, moment, kbn) {
var model = { from: getTimeObj(from), to: getTimeObj(to), }; var model = { from: getTimeObj(from), to: getTimeObj(to), };
if (model.from.date) { if (model.from.date) {
model.tooltip = moment(model.from.date).format('YYYY-MM-DD HH:mm:ss') + ' <br>to<br>'; model.tooltip = $scope.dashboard.formatDate(model.from.date) + ' <br>to<br>';
model.tooltip += moment(model.to.date).format('YYYY-MM-DD HH:mm:ss'); model.tooltip += $scope.dashboard.formatDate(model.to.date);
} }
else { else {
model.tooltip = 'Click to set time filter'; model.tooltip = 'Click to set time filter';
...@@ -188,8 +193,8 @@ function (angular, app, _, moment, kbn) { ...@@ -188,8 +193,8 @@ function (angular, app, _, moment, kbn) {
moment(model.to.date).fromNow(); moment(model.to.date).fromNow();
} }
else { else {
model.rangeString = moment(model.from.date).format('MMM D, YYYY hh:mm:ss') + ' to ' + model.rangeString = $scope.dashboard.formatDate(model.from.date, 'MMM D, YYYY hh:mm:ss') + ' to ' +
moment(model.to.date).format('MMM D, YYYY hh:mm:ss'); $scope.dashboard.formatDate(model.to.date, 'MMM D, YYYY hh:mm:ss');
} }
} }
......
...@@ -3,9 +3,10 @@ define([ ...@@ -3,9 +3,10 @@ define([
'jquery', 'jquery',
'kbn', 'kbn',
'lodash', 'lodash',
'moment',
'../timer', '../timer',
], ],
function (angular, $, kbn, _) { function (angular, $, kbn, _, moment) {
'use strict'; 'use strict';
var module = angular.module('grafana.services'); var module = angular.module('grafana.services');
...@@ -108,6 +109,14 @@ function (angular, $, kbn, _) { ...@@ -108,6 +109,14 @@ function (angular, $, kbn, _) {
this.rows.push(newRow); this.rows.push(newRow);
}; };
p.formatDate = function(date, format) {
format = format || 'YYYY-MM-DD HH:mm:ss';
return this.timezone === 'browser' ?
moment(date).format(format) :
moment.utc(date).format(format);
};
p.emit_refresh = function() { p.emit_refresh = function() {
$rootScope.$broadcast('refresh'); $rootScope.$broadcast('refresh');
}; };
......
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