diff --git a/public/app/features/dashboard/timepicker/input_date.js b/public/app/features/dashboard/timepicker/input_date.js deleted file mode 100644 index caec5ba55fe..00000000000 --- a/public/app/features/dashboard/timepicker/input_date.js +++ /dev/null @@ -1,44 +0,0 @@ -define([ - "angular", - "lodash", - "moment", -],function (angular, _, moment) { - 'use strict'; - - angular. - module("grafana.directives"). - directive('inputDatetime', function () { - return { - restrict: 'A', - require: 'ngModel', - link: function ($scope, $elem, attrs, ngModel) { - var format = 'YYYY-MM-DD HH:mm:ss'; - - var fromUser = function (text) { - if (text.indexOf('now') !== -1) { - return text; - } - var parsed; - if ($scope.ctrl.isUtc) { - parsed = moment.utc(text, format); - } else { - parsed = moment(text, format); - } - - return parsed.isValid() ? parsed : undefined; - }; - - 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/input_date.ts b/public/app/features/dashboard/timepicker/input_date.ts new file mode 100644 index 00000000000..66173ffd1b9 --- /dev/null +++ b/public/app/features/dashboard/timepicker/input_date.ts @@ -0,0 +1,41 @@ +/// + +import _ from 'lodash'; +import angular from 'angular'; +import moment from 'moment'; + +export function inputDateDirective() { + return { + restrict: 'A', + require: 'ngModel', + link: function ($scope, $elem, attrs, ngModel) { + var format = 'YYYY-MM-DD HH:mm:ss'; + + var fromUser = function (text) { + if (text.indexOf('now') !== -1) { + return text; + } + var parsed; + if ($scope.ctrl.isUtc) { + parsed = moment.utc(text, format); + } else { + parsed = moment(text, format); + } + + return parsed.isValid() ? parsed : undefined; + }; + + 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 6ac7d73436e..b44f6ed8a9a 100644 --- a/public/app/features/dashboard/timepicker/timepicker.ts +++ b/public/app/features/dashboard/timepicker/timepicker.ts @@ -1,5 +1,4 @@ /// -/// import _ from 'lodash'; import kbn from 'app/core/utils/kbn'; @@ -9,8 +8,6 @@ import moment from 'moment'; import * as dateMath from 'app/core/utils/datemath'; import * as rangeUtil from 'app/core/utils/rangeutil'; -declare var inputDate: any; - export class TimePickerCtrl { static tooltipFormat = 'MMM D, YYYY HH:mm:ss'; @@ -179,3 +176,6 @@ export function timePickerDirective() { angular.module('grafana.directives').directive('gfTimePickerSettings', settingsDirective); angular.module('grafana.directives').directive('gfTimePicker', timePickerDirective); + +import {inputDateDirective} from './input_date'; +angular.module("grafana.directives").directive('inputDatetime', inputDateDirective); diff --git a/public/app/grafana.ts b/public/app/grafana.ts index bc126e7b56f..11d521e6757 100644 --- a/public/app/grafana.ts +++ b/public/app/grafana.ts @@ -56,7 +56,7 @@ export class GrafanaApp { 'ang-drag-drop', 'grafana', 'pasvaz.bindonce', - 'ui.bootstrap.tabs', + 'ui.bootstrap', 'ui.bootstrap.tpls', ];