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
85baa501
Commit
85baa501
authored
Apr 18, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
recfactor: added unit test for the new scenario, #8143
parent
a64e000f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
5 deletions
+25
-5
public/app/plugins/datasource/graphite/query_ctrl.ts
+5
-5
public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts
+20
-0
No files found.
public/app/plugins/datasource/graphite/query_ctrl.ts
View file @
85baa501
...
@@ -28,7 +28,6 @@ export class GraphiteQueryCtrl extends QueryCtrl {
...
@@ -28,7 +28,6 @@ export class GraphiteQueryCtrl extends QueryCtrl {
}
}
toggleEditorMode
()
{
toggleEditorMode
()
{
this
.
target
.
textEditor
=
!
this
.
target
.
textEditor
;
this
.
parseTarget
();
this
.
parseTarget
();
}
}
...
@@ -220,17 +219,17 @@ export class GraphiteQueryCtrl extends QueryCtrl {
...
@@ -220,17 +219,17 @@ export class GraphiteQueryCtrl extends QueryCtrl {
this
.
target
.
target
=
_
.
reduce
(
this
.
functions
,
this
.
wrapFunction
,
metricPath
);
this
.
target
.
target
=
_
.
reduce
(
this
.
functions
,
this
.
wrapFunction
,
metricPath
);
}
}
this
.
resolve
Target
(
this
.
target
);
this
.
updateRendered
Target
(
this
.
target
);
// loop through other queries and update targetFull as needed
// loop through other queries and update targetFull as needed
for
(
const
target
of
this
.
panelCtrl
.
panel
.
targets
||
[])
{
for
(
const
target
of
this
.
panelCtrl
.
panel
.
targets
||
[])
{
if
(
target
.
refId
!==
this
.
target
.
refId
)
{
if
(
target
.
refId
!==
this
.
target
.
refId
)
{
this
.
resolve
Target
(
target
);
this
.
updateRendered
Target
(
target
);
}
}
}
}
}
}
resolve
Target
(
target
)
{
updateRendered
Target
(
target
)
{
// render nested query
// render nested query
var
targetsByRefId
=
_
.
keyBy
(
this
.
panelCtrl
.
panel
.
targets
,
'refId'
);
var
targetsByRefId
=
_
.
keyBy
(
this
.
panelCtrl
.
panel
.
targets
,
'refId'
);
...
@@ -240,6 +239,8 @@ export class GraphiteQueryCtrl extends QueryCtrl {
...
@@ -240,6 +239,8 @@ export class GraphiteQueryCtrl extends QueryCtrl {
var
nestedSeriesRefRegex
=
/
\#([
A-Z
])
/g
;
var
nestedSeriesRefRegex
=
/
\#([
A-Z
])
/g
;
var
targetWithNestedQueries
=
target
.
target
;
var
targetWithNestedQueries
=
target
.
target
;
// Keep interpolating until there are no query references
// The reason for the loop is that the referenced query might contain another reference to another query
while
(
targetWithNestedQueries
.
match
(
nestedSeriesRefRegex
))
{
while
(
targetWithNestedQueries
.
match
(
nestedSeriesRefRegex
))
{
var
updated
=
targetWithNestedQueries
.
replace
(
nestedSeriesRefRegex
,
(
match
,
g1
)
=>
{
var
updated
=
targetWithNestedQueries
.
replace
(
nestedSeriesRefRegex
,
(
match
,
g1
)
=>
{
var
t
=
targetsByRefId
[
g1
];
var
t
=
targetsByRefId
[
g1
];
...
@@ -249,7 +250,6 @@ export class GraphiteQueryCtrl extends QueryCtrl {
...
@@ -249,7 +250,6 @@ export class GraphiteQueryCtrl extends QueryCtrl {
// no circular references
// no circular references
delete
targetsByRefId
[
g1
];
delete
targetsByRefId
[
g1
];
return
t
.
target
;
return
t
.
target
;
});
});
...
...
public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts
View file @
85baa501
...
@@ -186,4 +186,24 @@ describe('GraphiteQueryCtrl', function() {
...
@@ -186,4 +186,24 @@ describe('GraphiteQueryCtrl', function() {
expect
(
ctx
.
ctrl
.
target
.
targetFull
).
to
.
be
(
'scaleToSeconds(nested.query.count)'
);
expect
(
ctx
.
ctrl
.
target
.
targetFull
).
to
.
be
(
'scaleToSeconds(nested.query.count)'
);
});
});
});
});
describe
(
'when updating target used in other query'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
ctrl
.
target
.
target
=
'metrics.a.count'
;
ctx
.
ctrl
.
target
.
refId
=
'A'
;
ctx
.
ctrl
.
datasource
.
metricFindQuery
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([{
expandable
:
false
}]));
ctx
.
ctrl
.
parseTarget
();
ctx
.
ctrl
.
panelCtrl
.
panel
.
targets
=
[
ctx
.
ctrl
.
target
,
{
target
:
'sumSeries(#A)'
,
refId
:
'B'
}
];
ctx
.
ctrl
.
updateModelTarget
();
});
it
(
'targetFull of other query should update'
,
function
()
{
expect
(
ctx
.
ctrl
.
panel
.
targets
[
1
].
targetFull
).
to
.
be
(
'sumSeries(metrics.a.count)'
);
});
});
});
});
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