Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
fa63d264
Commit
fa63d264
authored
Jan 31, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(timepicker): added validation to timepicker, and validation state to apply button, fixes #3870
parent
d617d029
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
51 deletions
+17
-51
public/app/features/dashboard/timepicker/custom.html
+0
-47
public/app/features/dashboard/timepicker/dropdown.html
+3
-3
public/app/features/dashboard/timepicker/input_date.ts
+14
-1
No files found.
public/app/features/dashboard/timepicker/custom.html
deleted
100644 → 0
View file @
d617d029
<div
class=
"gf-box-header"
>
<div
class=
"gf-box-title"
>
<i
class=
"fa fa-clock-o"
></i>
Custom time range
</div>
<button
class=
"gf-box-header-close-btn"
ng-click=
"dismiss();"
>
<i
class=
"fa fa-remove"
></i>
</button>
</div>
<div
class=
"gf-box-body"
>
<div
class=
"timepicker form-horizontal"
>
<form
name=
"timeForm"
style=
"margin-bottom: 0"
>
<div
class=
"timepicker-from-column"
>
<label
class=
"small"
>
From
</label>
<div
class=
"fake-input timepicker-input"
>
<input
class=
"timepicker-date"
type=
"text"
ng-change=
"validate(temptime)"
ng-model=
"temptime.from.date"
data-date-format=
"yyyy-mm-dd"
required
bs-datepicker
/>
@
<input
class=
"timepicker-hms"
type=
"text"
maxlength=
"2"
ng-change=
"validate(temptime)"
ng-model=
"temptime.from.hour"
required
ng-pattern=
"patterns.hour"
onClick=
"this.select();"
/>
:
<input
class=
"timepicker-hms"
type=
"text"
maxlength=
"2"
ng-change=
"validate(temptime)"
ng-model=
"temptime.from.minute"
required
ng-pattern=
"patterns.minute"
onClick=
"this.select();"
/>
:
<input
class=
"timepicker-hms"
type=
"text"
maxlength=
"2"
ng-change=
"validate(temptime)"
ng-model=
"temptime.from.second"
required
ng-pattern=
"patterns.second"
onClick=
"this.select();"
/>
.
<input
class=
"timepicker-ms"
type=
"text"
maxlength=
"3"
ng-change=
"validate(temptime)"
ng-model=
"temptime.from.millisecond"
required
ng-pattern=
"patterns.millisecond"
onClick=
"this.select();"
/>
</div>
</div>
<div
class=
"timepicker-to-column"
>
<label
class=
"small"
>
To (
<a
class=
"link"
ng-class=
"{'strong':temptime.now}"
ng-click=
"ctrl.setNow();temptime.now=true"
>
set now
</a>
)
</label>
<div
class=
"fake-input timepicker-input"
>
<div
ng-hide=
"temptime.now"
>
<input
class=
"timepicker-date"
type=
"text"
ng-change=
"validate(temptime)"
ng-model=
"temptime.to.date"
data-date-format=
"yyyy-mm-dd"
required
bs-datepicker
/>
@
<input
class=
"timepicker-hms"
type=
"text"
maxlength=
"2"
ng-change=
"validate(temptime)"
ng-model=
"temptime.to.hour"
required
ng-pattern=
"patterns.hour"
onClick=
"this.select();"
/>
:
<input
class=
"timepicker-hms"
type=
"text"
maxlength=
"2"
ng-change=
"validate(temptime)"
ng-model=
"temptime.to.minute"
required
ng-pattern=
"patterns.minute"
onClick=
"this.select();"
/>
:
<input
class=
"timepicker-hms"
type=
"text"
maxlength=
"2"
ng-change=
"validate(temptime)"
ng-model=
"temptime.to.second"
required
ng-pattern=
"patterns.second"
onClick=
"this.select();"
/>
.
<input
class=
"timepicker-ms"
type=
"text"
maxlength=
"3"
ng-change=
"validate(temptime)"
ng-model=
"temptime.to.millisecond"
required
ng-pattern=
"patterns.millisecond"
onClick=
"this.select();"
/>
</div>
<span
type=
"text"
ng-show=
"temptime.now"
ng-disabled=
"temptime.now"
>
&
nbsp
<i
class=
"pointer fa fa-remove"
ng-click=
"ctrl.setNow();temptime.now=false;"
></i>
Right Now
<input
type=
"text"
name=
"dummy"
style=
"visibility:hidden"
/></span>
</div>
</div>
<br>
<button
ng-click=
"ctrl.setAbsoluteTimeFilter(ctrl.validate(temptime));dismiss();"
ng-disabled=
"!timeForm.$valid"
class=
"btn btn-success"
>
Apply
</button>
<span
class=
""
ng-hide=
"input.$valid"
>
Invalid date or range
</span>
</form>
</div>
</div>
public/app/features/dashboard/timepicker/dropdown.html
View file @
fa63d264
<div
class=
"row pull-right"
>
<div
class=
"row pull-right"
>
<
div
class=
"gf-timepicker-absolute-section"
>
<
form
name=
"timeForm"
class=
"gf-timepicker-absolute-section"
>
<h3>
Time range
</h3>
<h3>
Time range
</h3>
<label
class=
"small"
>
From:
</label>
<label
class=
"small"
>
From:
</label>
<div
class=
"input-prepend"
>
<div
class=
"input-prepend"
>
...
@@ -29,10 +29,10 @@
...
@@ -29,10 +29,10 @@
<select
ng-model=
"ctrl.refresh.value"
class=
'input-medium'
ng-options=
"f.value as f.text for f in ctrl.refresh.options"
>
<select
ng-model=
"ctrl.refresh.value"
class=
'input-medium'
ng-options=
"f.value as f.text for f in ctrl.refresh.options"
>
</select>
</select>
<button
class=
"btn btn-inverse gf-timepicker-btn-apply"
type=
"button"
ng-click=
"ctrl.applyCustom()
"
>
<button
type=
"submit"
class=
"btn btn-primary"
ng-click=
"ctrl.applyCustom();"
ng-disabled=
"!timeForm.$valid
"
>
Apply
Apply
</button>
</button>
</
div
>
</
form
>
<div
class=
"gf-timepicker-relative-section"
>
<div
class=
"gf-timepicker-relative-section"
>
<h3>
Quick ranges
</h3>
<h3>
Quick ranges
</h3>
...
...
public/app/features/dashboard/timepicker/input_date.ts
View file @
fa63d264
///<reference path="../../../headers/common.d.ts" />
///<reference path="../../../headers/common.d.ts" />
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
*
as
dateMath
from
'app/core/utils/datemath'
;
export
function
inputDateDirective
()
{
export
function
inputDateDirective
()
{
return
{
return
{
...
@@ -11,8 +12,14 @@ export function inputDateDirective() {
...
@@ -11,8 +12,14 @@ export function inputDateDirective() {
var
fromUser
=
function
(
text
)
{
var
fromUser
=
function
(
text
)
{
if
(
text
.
indexOf
(
'now'
)
!==
-
1
)
{
if
(
text
.
indexOf
(
'now'
)
!==
-
1
)
{
if
(
!
dateMath
.
isValid
(
text
))
{
ngModel
.
$setValidity
(
"error"
,
false
);
return
undefined
;
}
ngModel
.
$setValidity
(
"error"
,
true
);
return
text
;
return
text
;
}
}
var
parsed
;
var
parsed
;
if
(
$scope
.
ctrl
.
isUtc
)
{
if
(
$scope
.
ctrl
.
isUtc
)
{
parsed
=
moment
.
utc
(
text
,
format
);
parsed
=
moment
.
utc
(
text
,
format
);
...
@@ -20,7 +27,13 @@ export function inputDateDirective() {
...
@@ -20,7 +27,13 @@ export function inputDateDirective() {
parsed
=
moment
(
text
,
format
);
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
)
{
var
toUser
=
function
(
currentValue
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment