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
42a0e9eb
Commit
42a0e9eb
authored
Oct 02, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'day_rounding' of
https://github.com/ctide/grafana
into ctide-day_rounding2
parents
d4e5a7d3
3e0b92d6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
3 deletions
+19
-3
public/app/core/utils/datemath.ts
+5
-1
public/app/features/dashboard/time_srv.ts
+3
-2
public/app/features/panel/metrics_panel_ctrl.ts
+3
-0
public/test/core/utils/datemath_specs.ts
+8
-0
No files found.
public/app/core/utils/datemath.ts
View file @
42a0e9eb
...
...
@@ -5,7 +5,7 @@ import moment from 'moment';
var
units
=
[
'y'
,
'M'
,
'w'
,
'd'
,
'h'
,
'm'
,
's'
];
export
function
parse
(
text
,
roundUp
?)
{
export
function
parse
(
text
,
roundUp
?
,
timezone
?
)
{
if
(
!
text
)
{
return
undefined
;
}
if
(
moment
.
isMoment
(
text
))
{
return
text
;
}
if
(
_
.
isDate
(
text
))
{
return
moment
(
text
);
}
...
...
@@ -16,7 +16,11 @@ export function parse(text, roundUp?) {
var
parseString
;
if
(
text
.
substring
(
0
,
3
)
===
'now'
)
{
if
(
timezone
===
'utc'
)
{
time
=
moment
.
utc
();
}
else
{
time
=
moment
();
}
mathString
=
text
.
substring
(
'now'
.
length
);
}
else
{
index
=
text
.
indexOf
(
'||'
);
...
...
public/app/features/dashboard/time_srv.ts
View file @
42a0e9eb
...
...
@@ -195,10 +195,11 @@ class TimeSrv {
from
:
moment
.
isMoment
(
this
.
time
.
from
)
?
moment
(
this
.
time
.
from
)
:
this
.
time
.
from
,
to
:
moment
.
isMoment
(
this
.
time
.
to
)
?
moment
(
this
.
time
.
to
)
:
this
.
time
.
to
,
};
var
timezone
=
this
.
dashboard
&&
this
.
dashboard
.
getTimezone
?
this
.
dashboard
.
getTimezone
()
:
'local'
;
return
{
from
:
dateMath
.
parse
(
raw
.
from
,
false
),
to
:
dateMath
.
parse
(
raw
.
to
,
true
),
from
:
dateMath
.
parse
(
raw
.
from
,
false
,
timezone
),
to
:
dateMath
.
parse
(
raw
.
to
,
true
,
timezone
),
raw
:
raw
};
}
...
...
public/app/features/panel/metrics_panel_ctrl.ts
View file @
42a0e9eb
...
...
@@ -217,7 +217,10 @@ class MetricsPanelCtrl extends PanelCtrl {
"__interval_ms"
:
{
text
:
this
.
intervalMs
,
value
:
this
.
intervalMs
},
});
var
timezone
=
this
.
dashboard
.
getTimezone
?
this
.
dashboard
.
getTimezone
()
:
'local'
;
var
metricsQuery
=
{
timezone
:
timezone
,
panelId
:
this
.
panel
.
id
,
range
:
this
.
range
,
rangeRaw
:
this
.
range
.
raw
,
...
...
public/test/core/utils/datemath_specs.ts
View file @
42a0e9eb
...
...
@@ -46,6 +46,14 @@ describe("DateMath", () => {
expect
(
startOfDay
).
to
.
be
(
expected
.
getTime
());
});
it
(
"now/d on a utc dashboard should be start of the current day in UTC time"
,
()
=>
{
var
today
=
new
Date
();
var
expected
=
new
Date
(
Date
.
UTC
(
today
.
getFullYear
(),
today
.
getMonth
(),
today
.
getDate
(),
0
,
0
,
0
,
0
));
var
startOfDay
=
dateMath
.
parse
(
'now/d'
,
false
,
'utc'
).
valueOf
();
expect
(
startOfDay
).
to
.
be
(
expected
.
getTime
());
});
describe
(
'subtraction'
,
()
=>
{
var
now
;
var
anchored
;
...
...
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