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
ad33cd5c
Unverified
Commit
ad33cd5c
authored
Dec 03, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix time regions using zero hours
parent
e9a8185d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
10 deletions
+37
-10
public/app/plugins/panel/graph/specs/time_region_manager.test.ts
+27
-0
public/app/plugins/panel/graph/time_region_manager.ts
+10
-10
No files found.
public/app/plugins/panel/graph/specs/time_region_manager.test.ts
View file @
ad33cd5c
...
...
@@ -130,6 +130,33 @@ describe('TimeRegionManager', () => {
});
});
plotOptionsScenario
(
'for time from/to region'
,
ctx
=>
{
const
regions
=
[{
from
:
'00:00'
,
to
:
'05:00'
,
fill
:
true
,
colorMode
:
'red'
}];
const
from
=
moment
(
'2018-12-01T00:00+01:00'
);
const
to
=
moment
(
'2018-12-03T23:59+01:00'
);
ctx
.
setup
(
regions
,
from
,
to
);
it
(
'should add 3 markings'
,
()
=>
{
expect
(
ctx
.
options
.
grid
.
markings
.
length
).
toBe
(
3
);
});
it
(
'should add one fill between 00:00 and 05:00 each day'
,
()
=>
{
const
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
moment
(
markings
[
0
].
xaxis
.
from
).
format
()).
toBe
(
moment
(
'2018-12-01T01:00:00+01:00'
).
format
());
expect
(
moment
(
markings
[
0
].
xaxis
.
to
).
format
()).
toBe
(
moment
(
'2018-12-01T06:00:00+01:00'
).
format
());
expect
(
markings
[
0
].
color
).
toBe
(
colorModes
.
red
.
color
.
fill
);
expect
(
moment
(
markings
[
1
].
xaxis
.
from
).
format
()).
toBe
(
moment
(
'2018-12-02T01:00:00+01:00'
).
format
());
expect
(
moment
(
markings
[
1
].
xaxis
.
to
).
format
()).
toBe
(
moment
(
'2018-12-02T06:00:00+01:00'
).
format
());
expect
(
markings
[
1
].
color
).
toBe
(
colorModes
.
red
.
color
.
fill
);
expect
(
moment
(
markings
[
2
].
xaxis
.
from
).
format
()).
toBe
(
moment
(
'2018-12-03T01:00:00+01:00'
).
format
());
expect
(
moment
(
markings
[
2
].
xaxis
.
to
).
format
()).
toBe
(
moment
(
'2018-12-03T06:00:00+01:00'
).
format
());
expect
(
markings
[
2
].
color
).
toBe
(
colorModes
.
red
.
color
.
fill
);
});
});
plotOptionsScenario
(
'for day of week from/to region'
,
ctx
=>
{
const
regions
=
[{
fromDayOfWeek
:
7
,
toDayOfWeek
:
7
,
fill
:
true
,
colorMode
:
'red'
}];
const
from
=
moment
(
'2018-01-01T18:45:05+01:00'
);
...
...
public/app/plugins/panel/graph/time_region_manager.ts
View file @
ad33cd5c
...
...
@@ -87,6 +87,14 @@ export class TimeRegionManager {
continue
;
}
if
(
timeRegion
.
from
&&
!
timeRegion
.
to
)
{
timeRegion
.
to
=
timeRegion
.
from
;
}
if
(
!
timeRegion
.
from
&&
timeRegion
.
to
)
{
timeRegion
.
from
=
timeRegion
.
to
;
}
hRange
=
{
from
:
this
.
parseTimeRange
(
timeRegion
.
from
),
to
:
this
.
parseTimeRange
(
timeRegion
.
to
),
...
...
@@ -108,21 +116,13 @@ export class TimeRegionManager {
hRange
.
to
.
dayOfWeek
=
Number
(
timeRegion
.
toDayOfWeek
);
}
if
(
!
hRange
.
from
.
h
&&
hRange
.
to
.
h
)
{
hRange
.
from
=
hRange
.
to
;
}
if
(
hRange
.
from
.
h
&&
!
hRange
.
to
.
h
)
{
hRange
.
to
=
hRange
.
from
;
}
if
(
hRange
.
from
.
dayOfWeek
&&
!
hRange
.
from
.
h
&&
!
hRange
.
from
.
m
)
{
if
(
hRange
.
from
.
dayOfWeek
&&
hRange
.
from
.
h
===
null
&&
hRange
.
from
.
m
===
null
)
{
hRange
.
from
.
h
=
0
;
hRange
.
from
.
m
=
0
;
hRange
.
from
.
s
=
0
;
}
if
(
hRange
.
to
.
dayOfWeek
&&
!
hRange
.
to
.
h
&&
!
hRange
.
to
.
m
)
{
if
(
hRange
.
to
.
dayOfWeek
&&
hRange
.
to
.
h
===
null
&&
hRange
.
to
.
m
===
null
)
{
hRange
.
to
.
h
=
23
;
hRange
.
to
.
m
=
59
;
hRange
.
to
.
s
=
59
;
...
...
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