mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(timepicker): fixed recent breaking of datetime picker when swithing from requirejs to systemjs
This commit is contained in:
parent
7cad3c89d3
commit
52644bb28a
@ -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);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
41
public/app/features/dashboard/timepicker/input_date.ts
Normal file
41
public/app/features/dashboard/timepicker/input_date.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
///<reference path="../../../headers/common.d.ts" />
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,4 @@
|
|||||||
///<reference path="../../../headers/common.d.ts" />
|
///<reference path="../../../headers/common.d.ts" />
|
||||||
///<amd-dependency path="./input_date" name="inputDate" />
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import kbn from 'app/core/utils/kbn';
|
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 dateMath from 'app/core/utils/datemath';
|
||||||
import * as rangeUtil from 'app/core/utils/rangeutil';
|
import * as rangeUtil from 'app/core/utils/rangeutil';
|
||||||
|
|
||||||
declare var inputDate: any;
|
|
||||||
|
|
||||||
export class TimePickerCtrl {
|
export class TimePickerCtrl {
|
||||||
|
|
||||||
static tooltipFormat = 'MMM D, YYYY HH:mm:ss';
|
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('gfTimePickerSettings', settingsDirective);
|
||||||
angular.module('grafana.directives').directive('gfTimePicker', timePickerDirective);
|
angular.module('grafana.directives').directive('gfTimePicker', timePickerDirective);
|
||||||
|
|
||||||
|
import {inputDateDirective} from './input_date';
|
||||||
|
angular.module("grafana.directives").directive('inputDatetime', inputDateDirective);
|
||||||
|
@ -56,7 +56,7 @@ export class GrafanaApp {
|
|||||||
'ang-drag-drop',
|
'ang-drag-drop',
|
||||||
'grafana',
|
'grafana',
|
||||||
'pasvaz.bindonce',
|
'pasvaz.bindonce',
|
||||||
'ui.bootstrap.tabs',
|
'ui.bootstrap',
|
||||||
'ui.bootstrap.tpls',
|
'ui.bootstrap.tpls',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user