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
92972eed
Commit
92972eed
authored
Feb 18, 2019
by
Hugo Häggmark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #15477
parent
abddb442
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
2 deletions
+48
-2
public/app/features/dashboard/state/PanelModel.test.ts
+29
-0
public/app/features/dashboard/state/PanelModel.ts
+19
-2
No files found.
public/app/features/dashboard/state/PanelModel.test.ts
View file @
92972eed
...
...
@@ -10,6 +10,20 @@ describe('PanelModel', () => {
type
:
'table'
,
showColumns
:
true
,
targets
:
[{
refId
:
'A'
},
{
noRefId
:
true
}],
options
:
{
thresholds
:
[
{
color
:
'#F2495C'
,
index
:
1
,
value
:
50
,
},
{
color
:
'#73BF69'
,
index
:
0
,
value
:
null
,
},
],
},
});
});
...
...
@@ -35,6 +49,21 @@ describe('PanelModel', () => {
expect
(
saveModel
.
events
).
toBe
(
undefined
);
});
it
(
'should restore -Infinity value for base threshold'
,
()
=>
{
expect
(
model
.
options
.
thresholds
).
toEqual
([
{
color
:
'#F2495C'
,
index
:
1
,
value
:
50
,
},
{
color
:
'#73BF69'
,
index
:
0
,
value
:
-
Infinity
,
},
]);
});
describe
(
'when changing panel type'
,
()
=>
{
beforeEach
(()
=>
{
model
.
changeType
(
'graph'
,
true
);
...
...
public/app/features/dashboard/state/PanelModel.ts
View file @
92972eed
...
...
@@ -3,7 +3,7 @@ import _ from 'lodash';
// Types
import
{
Emitter
}
from
'app/core/utils/emitter'
;
import
{
DataQuery
,
TimeSeries
}
from
'@grafana/ui'
;
import
{
DataQuery
,
TimeSeries
,
Threshold
}
from
'@grafana/ui'
;
import
{
TableData
}
from
'@grafana/ui/src'
;
export
interface
GridPos
{
...
...
@@ -91,7 +91,9 @@ export class PanelModel {
timeFrom
?:
any
;
timeShift
?:
any
;
hideTimeOverride
?:
any
;
options
:
object
;
options
:
{
[
key
:
string
]:
any
;
};
maxDataPoints
?:
number
;
interval
?:
string
;
...
...
@@ -119,6 +121,8 @@ export class PanelModel {
_
.
defaultsDeep
(
this
,
_
.
cloneDeep
(
defaults
));
// queries must have refId
this
.
ensureQueryIds
();
this
.
restoreInfintyForThresholds
();
}
ensureQueryIds
()
{
...
...
@@ -131,6 +135,19 @@ export class PanelModel {
}
}
restoreInfintyForThresholds
()
{
if
(
this
.
options
&&
this
.
options
.
thresholds
)
{
this
.
options
.
thresholds
=
this
.
options
.
thresholds
.
map
((
threshold
:
Threshold
)
=>
{
// JSON serialization of -Infinity is 'null' so lets convert it back to -Infinity
if
(
threshold
.
index
===
0
&&
threshold
.
value
===
null
)
{
return
{
...
threshold
,
value
:
-
Infinity
};
}
return
threshold
;
});
}
}
getOptions
(
panelDefaults
)
{
return
_
.
defaultsDeep
(
this
.
options
||
{},
panelDefaults
);
}
...
...
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