diff --git a/public/app/features/dashboard/timepicker/custom.html b/public/app/features/dashboard/timepicker/custom.html deleted file mode 100644 index 519637bf5a3..00000000000 --- a/public/app/features/dashboard/timepicker/custom.html +++ /dev/null @@ -1,47 +0,0 @@ -
-
- - Custom time range -
- -
- -
-
-
- -
- -
- @ - : - : - . - -
-
- -
- - - -
-
- @ - : - : - . - -
-   Right Now -
-
- -
- - Invalid date or range -
-
-
diff --git a/public/app/features/dashboard/timepicker/dropdown.html b/public/app/features/dashboard/timepicker/dropdown.html index 6205e8102b1..30074770e45 100644 --- a/public/app/features/dashboard/timepicker/dropdown.html +++ b/public/app/features/dashboard/timepicker/dropdown.html @@ -1,5 +1,5 @@
-
+

Time range

@@ -29,10 +29,10 @@ - -
+

Quick ranges

diff --git a/public/app/features/dashboard/timepicker/input_date.ts b/public/app/features/dashboard/timepicker/input_date.ts index cf215b9e25e..b6988a3ff16 100644 --- a/public/app/features/dashboard/timepicker/input_date.ts +++ b/public/app/features/dashboard/timepicker/input_date.ts @@ -1,6 +1,7 @@ /// import moment from 'moment'; +import * as dateMath from 'app/core/utils/datemath'; export function inputDateDirective() { return { @@ -11,8 +12,14 @@ export function inputDateDirective() { var fromUser = function (text) { if (text.indexOf('now') !== -1) { + if (!dateMath.isValid(text)) { + ngModel.$setValidity("error", false); + return undefined; + } + ngModel.$setValidity("error", true); return text; } + var parsed; if ($scope.ctrl.isUtc) { parsed = moment.utc(text, format); @@ -20,7 +27,13 @@ export function inputDateDirective() { parsed = moment(text, format); } - return parsed.isValid() ? parsed : undefined; + if (!parsed.isValid()) { + ngModel.$setValidity("error", false); + return undefined; + } + + ngModel.$setValidity("error", true); + return parsed; }; var toUser = function (currentValue) {