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
018fef04
Commit
018fef04
authored
Jan 21, 2019
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added refId to missing queries on panel model init
parent
db2a15da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
public/app/features/dashboard/panel_model.ts
+15
-3
public/app/features/dashboard/specs/panel_model.test.ts
+8
-0
No files found.
public/app/features/dashboard/panel_model.ts
View file @
018fef04
...
...
@@ -62,7 +62,7 @@ const mustKeepProps: { [str: string]: boolean } = {
const
defaults
:
any
=
{
gridPos
:
{
x
:
0
,
y
:
0
,
h
:
3
,
w
:
6
},
datasource
:
null
,
targets
:
[{}],
targets
:
[{
refId
:
'A'
}],
cachedPluginOptions
:
{},
transparent
:
false
,
};
...
...
@@ -83,7 +83,7 @@ export class PanelModel {
collapsed
?:
boolean
;
panels
?:
any
;
soloMode
?:
boolean
;
targets
:
an
y
[];
targets
:
DataQuer
y
[];
datasource
:
string
;
thresholds
?:
any
;
...
...
@@ -118,6 +118,18 @@ export class PanelModel {
// defaults
_
.
defaultsDeep
(
this
,
_
.
cloneDeep
(
defaults
));
// queries must have refId
this
.
ensureQueryIds
();
}
ensureQueryIds
()
{
if
(
this
.
targets
)
{
for
(
const
query
of
this
.
targets
)
{
if
(
!
query
.
refId
)
{
query
.
refId
=
this
.
getNextQueryLetter
();
}
}
}
}
getOptions
(
panelDefaults
)
{
...
...
@@ -243,7 +255,7 @@ export class PanelModel {
addQuery
(
query
?:
Partial
<
DataQuery
>
)
{
query
=
query
||
{
refId
:
'A'
};
query
.
refId
=
this
.
getNextQueryLetter
();
this
.
targets
.
push
(
query
);
this
.
targets
.
push
(
query
as
DataQuery
);
}
getNextQueryLetter
():
string
{
...
...
public/app/features/dashboard/specs/panel_model.test.ts
View file @
018fef04
...
...
@@ -9,6 +9,10 @@ describe('PanelModel', () => {
model
=
new
PanelModel
({
type
:
'table'
,
showColumns
:
true
,
targets
:
[
{
refId
:
'A'
},
{
noRefId
:
true
}
]
});
});
...
...
@@ -20,6 +24,10 @@ describe('PanelModel', () => {
expect
(
model
.
showColumns
).
toBe
(
true
);
});
it
(
'should add missing refIds'
,
()
=>
{
expect
(
model
.
targets
[
1
].
refId
).
toBe
(
'B'
);
});
it
(
'getSaveModel should remove defaults'
,
()
=>
{
const
saveModel
=
model
.
getSaveModel
();
expect
(
saveModel
.
gridPos
).
toBe
(
undefined
);
...
...
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