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
7289e6e5
Commit
7289e6e5
authored
Jan 11, 2019
by
Dominik Prokop
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addedd assertions about raw time range when panel time overriden
parent
c3fdc1a0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
3 deletions
+15
-3
public/app/features/dashboard/utils/panel.test.ts
+6
-0
public/app/features/dashboard/utils/panel.ts
+9
-3
No files found.
public/app/features/dashboard/utils/panel.test.ts
View file @
7289e6e5
...
...
@@ -33,6 +33,8 @@ describe('applyPanelTimeOverrides', () => {
expect
(
overrides
.
timeRange
.
from
.
toISOString
()).
toBe
(
moment
([
2019
,
1
,
11
,
12
]).
toISOString
());
expect
(
overrides
.
timeRange
.
to
.
toISOString
()).
toBe
(
fakeCurrentDate
.
toISOString
());
expect
(
overrides
.
timeRange
.
raw
.
from
).
toBe
(
'now-2h'
);
expect
(
overrides
.
timeRange
.
raw
.
to
).
toBe
(
'now'
);
});
it
(
'should apply time shift'
,
()
=>
{
...
...
@@ -48,6 +50,8 @@ describe('applyPanelTimeOverrides', () => {
expect
(
overrides
.
timeRange
.
from
.
toISOString
()).
toBe
(
expectedFromDate
.
toISOString
());
expect
(
overrides
.
timeRange
.
to
.
toISOString
()).
toBe
(
expectedToDate
.
toISOString
());
expect
((
overrides
.
timeRange
.
raw
.
from
as
moment
.
Moment
).
toISOString
()).
toEqual
(
expectedFromDate
.
toISOString
());
expect
((
overrides
.
timeRange
.
raw
.
to
as
moment
.
Moment
).
toISOString
()).
toEqual
(
expectedToDate
.
toISOString
());
});
it
(
'should apply both relative time and time shift'
,
()
=>
{
...
...
@@ -64,5 +68,7 @@ describe('applyPanelTimeOverrides', () => {
expect
(
overrides
.
timeRange
.
from
.
toISOString
()).
toBe
(
expectedFromDate
.
toISOString
());
expect
(
overrides
.
timeRange
.
to
.
toISOString
()).
toBe
(
expectedToDate
.
toISOString
());
expect
((
overrides
.
timeRange
.
raw
.
from
as
moment
.
Moment
).
toISOString
()).
toEqual
(
expectedFromDate
.
toISOString
());
expect
((
overrides
.
timeRange
.
raw
.
to
as
moment
.
Moment
).
toISOString
()).
toEqual
(
expectedToDate
.
toISOString
());
});
});
public/app/features/dashboard/utils/panel.ts
View file @
7289e6e5
...
...
@@ -142,10 +142,16 @@ export function applyPanelTimeOverrides(panel: PanelModel, timeRange: TimeRange)
const
timeShift
=
'-'
+
timeShiftInterpolated
;
newTimeData
.
timeInfo
+=
' timeshift '
+
timeShift
;
const
from
=
dateMath
.
parseDateMath
(
timeShift
,
newTimeData
.
timeRange
.
from
,
false
);
const
to
=
dateMath
.
parseDateMath
(
timeShift
,
newTimeData
.
timeRange
.
to
,
true
);
newTimeData
.
timeRange
=
{
from
:
dateMath
.
parseDateMath
(
timeShift
,
newTimeData
.
timeRange
.
from
,
false
),
to
:
dateMath
.
parseDateMath
(
timeShift
,
newTimeData
.
timeRange
.
to
,
true
),
raw
:
newTimeData
.
timeRange
.
raw
,
from
,
to
,
raw
:
{
from
,
to
,
},
};
}
...
...
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