diff --git a/public/app/features/dashboard/dashboardSrv.js b/public/app/features/dashboard/dashboardSrv.js index 458ec703e35..170cce52fbf 100644 --- a/public/app/features/dashboard/dashboardSrv.js +++ b/public/app/features/dashboard/dashboardSrv.js @@ -217,7 +217,7 @@ function (angular, $, kbn, _, moment) { p.formatDate = function(date, format) { if (!moment.isMoment(date)) { - date = moment(date) + date = moment(date); } format = format || 'YYYY-MM-DD HH:mm:ss'; diff --git a/public/app/features/dashboard/timepicker/dropdown.html b/public/app/features/dashboard/timepicker/dropdown.html index 95cbe3d4c9f..02e7cc855dc 100644 --- a/public/app/features/dashboard/timepicker/dropdown.html +++ b/public/app/features/dashboard/timepicker/dropdown.html @@ -10,7 +10,7 @@
- +
@@ -21,6 +21,10 @@ +
+ +
+ diff --git a/public/app/features/dashboard/timepicker/input_date.js b/public/app/features/dashboard/timepicker/input_date.js index 2cdbd88fd1a..24eb04cd250 100644 --- a/public/app/features/dashboard/timepicker/input_date.js +++ b/public/app/features/dashboard/timepicker/input_date.js @@ -1,7 +1,8 @@ define([ "angular", + "lodash", "moment", -],function (angular, moment) { +],function (angular, _, moment) { 'use strict'; angular. @@ -11,22 +12,30 @@ define([ restrict: 'A', require: 'ngModel', link: function ($scope, $elem, attrs, ngModel) { - // var format = 'YYYY-MM-DD HH:mm:ss.SSS'; - // // $elem.after('
' + format + '
'); - // - // // What should I make with the input from the user? - // var fromUser = function (text) { - // var parsed = moment(text, format); - // return parsed.isValid() ? parsed : undefined; - // }; - // - // // How should I present the data back to the user in the input field? - // var toUser = function (datetime) { - // return moment(datetime).format(format); - // }; - // - // ngModel.$parsers.push(fromUser); - // ngModel.$formatters.push(toUser); + var format = 'YYYY-MM-DD HH:mm:ss'; + // $elem.after('
' + format + '
'); + + // What should I make with the input from the user? + var fromUser = function (text) { + console.log('fromUser: ' + text); + return text; + // if (_.isString(text)) { + // } + // var parsed = moment(text, format); + // return parsed.isValid() ? parsed : undefined; + }; + + // How should I present the data back to the user in the input field? + var toUser = function (currentValue) { + if (moment.isMoment(currentValue)) { + return currentValue.format(format); + } else { + return currentValue; + } + }; + + ngModel.$parsers.push(fromUser); + ngModel.$formatters.push(toUser); } }; }); diff --git a/public/app/features/dashboard/timepicker/timepicker.ts b/public/app/features/dashboard/timepicker/timepicker.ts index 5a488e1f25a..6e27eebc082 100644 --- a/public/app/features/dashboard/timepicker/timepicker.ts +++ b/public/app/features/dashboard/timepicker/timepicker.ts @@ -54,7 +54,7 @@ export class TimePickerCtrl { this.$scope.dashboard.formatDate(time.to, format); } - this.$scope.absoluteJs = {form: time.from.toDate(), to: time.to.toDate()}; + this.$scope.absolute = {fromJs: time.from.toDate(), toJs: time.to.toDate()}; this.$scope.timeRaw = timeRaw; this.$scope.tooltip = this.$scope.dashboard.formatDate(time.from) + '
to
'; this.$scope.tooltip += this.$scope.dashboard.formatDate(time.to); @@ -92,6 +92,14 @@ export class TimePickerCtrl { this.$scope.appEvent('hide-dash-editor'); } + absoluteFromChanged() { + this.$scope.timeRaw.from = moment(this.$scope.absolute.fromJs); + } + + absoluteToChanged() { + this.$scope.timeRaw.to = moment(this.$scope.absolute.toJs); + } + setRelativeFilter(timespan) { this.$scope.panel.now = true; diff --git a/public/less/timepicker.less b/public/less/timepicker.less index d35c90bd0fe..8bdc2d570b7 100644 --- a/public/less/timepicker.less +++ b/public/less/timepicker.less @@ -44,13 +44,18 @@ } .gf-timepicker-component { + margin-bottom: 10px; button.btn-sm { .buttonBackground(@btnInverseBackground, @btnInverseBackgroundHighlight); background-image: none; border: none; padding: 6px 9px; color: @textColor; - &.active .text-info { + &.active span { + color: @blue; + font-weight: bold; + } + .text-info { color: @orange; font-weight: bold; } diff --git a/public/test/test-main.js b/public/test/test-main.js index eec309d1890..4c5d63ede2e 100644 --- a/public/test/test-main.js +++ b/public/test/test-main.js @@ -19,7 +19,7 @@ require.config({ 'angular-sanitize': 'vendor/angular-sanitize/angular-sanitize', angularMocks: 'vendor/angular-mocks/angular-mocks', 'angular-dragdrop': 'vendor/angular-native-dragdrop/draganddrop', - 'angular-ui': 'vendor/angular-ui/tabs', + 'angular-ui': 'vendor/angular-ui/ui-bootstrap-tpls', 'angular-strap': 'vendor/angular-other/angular-strap', timepicker: 'vendor/angular-other/timepicker', datepicker: 'vendor/angular-other/datepicker',