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
f243da75
Commit
f243da75
authored
Sep 17, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: fix init labels bug
parent
0b41303e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
11 deletions
+22
-11
public/app/plugins/datasource/stackdriver/query_ctrl.ts
+22
-11
No files found.
public/app/plugins/datasource/stackdriver/query_ctrl.ts
View file @
f243da75
...
...
@@ -30,7 +30,7 @@ export class StackdriverQueryCtrl extends QueryCtrl {
defaultFilterValue
=
'select value'
;
defaultRemoveGroupByValue
=
'-- remove group by --'
;
defaultRemoveFilterValue
=
'-- remove filter --'
;
init
Promise
:
Promise
<
any
>
;
loadLabels
Promise
:
Promise
<
any
>
;
defaults
=
{
project
:
{
...
...
@@ -80,15 +80,9 @@ export class StackdriverQueryCtrl extends QueryCtrl {
this
.
panelCtrl
.
events
.
on
(
'data-received'
,
this
.
onDataReceived
.
bind
(
this
),
$scope
);
this
.
panelCtrl
.
events
.
on
(
'data-error'
,
this
.
onDataError
.
bind
(
this
),
$scope
);
this
.
initPromise
=
new
Promise
(
async
resolve
=>
{
this
.
getCurrentProject
()
.
then
(
this
.
getMetricTypes
.
bind
(
this
))
.
then
(
this
.
getLabels
.
bind
(
this
))
.
then
(
resolve
)
.
catch
(
err
=>
{
console
.
log
(
err
);
});
});
.
then
(
this
.
getLabels
.
bind
(
this
));
this
.
initSegments
();
}
...
...
@@ -161,6 +155,8 @@ export class StackdriverQueryCtrl extends QueryCtrl {
}
async
getLabels
()
{
this
.
loadLabelsPromise
=
new
Promise
(
async
resolve
=>
{
try
{
const
data
=
await
this
.
datasource
.
getTimeSeries
({
targets
:
[
{
...
...
@@ -178,6 +174,11 @@ export class StackdriverQueryCtrl extends QueryCtrl {
this
.
metricLabels
=
data
.
results
[
this
.
target
.
refId
].
meta
.
metricLabels
;
this
.
resourceLabels
=
data
.
results
[
this
.
target
.
refId
].
meta
.
resourceLabels
;
resolve
();
}
catch
(
error
)
{
resolve
();
}
});
}
async
onMetricTypeChange
()
{
...
...
@@ -186,9 +187,7 @@ export class StackdriverQueryCtrl extends QueryCtrl {
}
async
getGroupBys
(
segment
,
index
,
removeText
?:
string
,
removeUsed
=
true
)
{
if
(
!
this
.
metricLabels
||
Object
.
keys
(
this
.
metricLabels
).
length
===
0
)
{
await
this
.
initPromise
;
}
await
this
.
loadLabelsPromise
;
const
metricLabels
=
Object
.
keys
(
this
.
metricLabels
)
.
filter
(
ml
=>
{
if
(
!
removeUsed
)
{
...
...
@@ -256,8 +255,18 @@ export class StackdriverQueryCtrl extends QueryCtrl {
}
if
(
segment
.
type
===
'key'
||
segment
.
type
===
'plus-button'
)
{
if
(
this
.
metricLabels
&&
Object
.
keys
(
this
.
metricLabels
).
length
===
0
&&
segment
.
value
&&
segment
.
value
!==
this
.
defaultRemoveFilterValue
)
{
this
.
removeSegment
.
value
=
this
.
defaultRemoveFilterValue
;
return
Promise
.
resolve
([
this
.
removeSegment
]);
}
else
{
return
this
.
getGroupBys
(
null
,
null
,
this
.
defaultRemoveFilterValue
,
false
);
}
}
if
(
segment
.
type
===
'value'
)
{
const
filterKey
=
this
.
filterSegments
[
index
-
2
].
value
;
...
...
@@ -339,6 +348,7 @@ export class StackdriverQueryCtrl extends QueryCtrl {
if
(
anySeriesFromQuery
)
{
this
.
lastQueryMeta
=
anySeriesFromQuery
.
meta
;
this
.
lastQueryMeta
.
rawQueryString
=
decodeURIComponent
(
this
.
lastQueryMeta
.
rawQuery
);
}
else
{
}
}
...
...
@@ -359,5 +369,6 @@ export class StackdriverQueryCtrl extends QueryCtrl {
this
.
lastQueryError
=
jsonBody
.
error
.
message
;
}
}
console
.
error
(
err
);
}
}
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