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
1791e732
Commit
1791e732
authored
Oct 31, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: handle default state
parent
3c5f8325
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
29 deletions
+15
-29
public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx
+15
-29
No files found.
public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx
View file @
1791e732
...
...
@@ -49,7 +49,13 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
name
:
m
.
displayName
,
}));
const
metricType
=
this
.
state
.
metricType
||
metricTypes
[
0
].
value
;
this
.
setState
({
services
,
service
,
metricTypes
,
metricType
,
metricDescriptors
});
let
state
:
any
=
{
services
,
service
,
metricTypes
,
metricType
,
metricDescriptors
};
if
(
this
.
isLabelQuery
(
this
.
state
.
queryType
))
{
const
labels
=
await
this
.
getLabelKeys
(
this
.
state
.
metricType
);
const
labelKey
=
labels
.
indexOf
(
this
.
state
.
labelKey
)
!==
-
1
?
this
.
state
.
labelKey
:
labels
[
0
];
state
=
{
...
state
,
labels
,
labelKey
};
}
this
.
setState
(
state
);
}
async
handleQueryTypeChange
(
event
)
{
...
...
@@ -107,31 +113,6 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
return
[
MetricFindQueryTypes
.
MetricLabels
,
MetricFindQueryTypes
.
ResourceLabels
].
indexOf
(
queryType
)
!==
-
1
;
}
getLabelType
(
queryType
)
{
switch
(
queryType
)
{
case
MetricFindQueryTypes
.
ResourceLabels
:
return
(
<
SimpleDropdown
value=
{
this
.
state
.
labelKey
}
options=
{
this
.
state
.
labels
.
map
(
l
=>
({
value
:
l
,
name
:
l
}))
}
onValueChange=
{
this
.
onLabelKeyChange
}
label=
"Resource Labels"
/>
);
case
MetricFindQueryTypes
.
MetricLabels
:
return
(
<
SimpleDropdown
value=
{
this
.
state
.
labelKey
}
options=
{
this
.
state
.
labels
.
map
(
l
=>
({
value
:
l
,
name
:
l
}))
}
onValueChange=
{
this
.
onLabelKeyChange
}
label=
"Metric Labels"
/>
);
default
:
return
''
;
}
}
renderQueryTypeSwitch
(
queryType
)
{
switch
(
queryType
)
{
case
MetricFindQueryTypes
.
MetricTypes
:
...
...
@@ -146,10 +127,8 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
case
MetricFindQueryTypes
.
MetricLabels
:
case
MetricFindQueryTypes
.
ResourceLabels
:
case
MetricFindQueryTypes
.
ResourceTypes
:
const
labelSelect
=
this
.
getLabelType
(
queryType
);
return
(
<
React
.
Fragment
>
{
this
.
state
.
labels
.
join
(
','
)
}
<
SimpleDropdown
value=
{
this
.
state
.
service
}
options=
{
this
.
state
.
services
}
...
...
@@ -162,7 +141,14 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
onValueChange=
{
this
.
onMetricTypeChange
}
label=
"Metric Types"
/>
{
labelSelect
}
<
SimpleDropdown
value=
{
this
.
state
.
labelKey
}
options=
{
this
.
state
.
labels
.
map
(
l
=>
({
value
:
l
,
name
:
l
}))
}
onValueChange=
{
this
.
onLabelKeyChange
}
label=
{
this
.
state
.
type
===
MetricFindQueryTypes
.
ResourceLabels
?
'Resource Label Key'
:
'Metric Label Key'
}
/>
</
React
.
Fragment
>
);
case
MetricFindQueryTypes
.
Alignerns
:
...
...
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