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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
30 deletions
+41
-30
public/app/plugins/datasource/stackdriver/query_ctrl.ts
+41
-30
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
);
});
});
this
.
getCurrentProject
()
.
then
(
this
.
getMetricTypes
.
bind
(
this
))
.
then
(
this
.
getLabels
.
bind
(
this
));
this
.
initSegments
();
}
...
...
@@ -161,23 +155,30 @@ export class StackdriverQueryCtrl extends QueryCtrl {
}
async
getLabels
()
{
const
data
=
await
this
.
datasource
.
getTimeSeries
({
targets
:
[
{
refId
:
this
.
target
.
refId
,
datasourceId
:
this
.
datasource
.
id
,
metricType
:
this
.
target
.
metricType
,
aggregation
:
{
crossSeriesReducer
:
'REDUCE_NONE'
,
},
view
:
'HEADERS'
,
},
],
range
:
this
.
timeSrv
.
timeRange
(),
});
this
.
loadLabelsPromise
=
new
Promise
(
async
resolve
=>
{
try
{
const
data
=
await
this
.
datasource
.
getTimeSeries
({
targets
:
[
{
refId
:
this
.
target
.
refId
,
datasourceId
:
this
.
datasource
.
id
,
metricType
:
this
.
target
.
metricType
,
aggregation
:
{
crossSeriesReducer
:
'REDUCE_NONE'
,
},
view
:
'HEADERS'
,
},
],
range
:
this
.
timeSrv
.
timeRange
(),
});
this
.
metricLabels
=
data
.
results
[
this
.
target
.
refId
].
meta
.
metricLabels
;
this
.
resourceLabels
=
data
.
results
[
this
.
target
.
refId
].
meta
.
resourceLabels
;
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,7 +255,17 @@ export class StackdriverQueryCtrl extends QueryCtrl {
}
if
(
segment
.
type
===
'key'
||
segment
.
type
===
'plus-button'
)
{
return
this
.
getGroupBys
(
null
,
null
,
this
.
defaultRemoveFilterValue
,
false
);
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'
)
{
...
...
@@ -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