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
dc4b0cf2
Commit
dc4b0cf2
authored
Oct 02, 2018
by
David Kaltschmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid new metrics options being passed selector, made PromField pure
parent
538ea112
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
+19
-10
public/app/features/explore/PromQueryField.tsx
+18
-9
public/app/features/explore/QueryField.tsx
+1
-1
No files found.
public/app/features/explore/PromQueryField.tsx
View file @
dc4b0cf2
...
...
@@ -156,6 +156,7 @@ interface PromQueryFieldState {
labelValues
:
{
[
index
:
string
]:
{
[
index
:
string
]:
string
[]
}
};
// metric -> labelKey -> [labelValue,...]
logLabelOptions
:
any
[];
metrics
:
string
[];
metricsOptions
:
any
[];
metricsByPrefix
:
CascaderOption
[];
}
...
...
@@ -167,7 +168,7 @@ interface PromTypeaheadInput {
value
?:
Value
;
}
class
PromQueryField
extends
React
.
Component
<
PromQueryFieldProps
,
PromQueryFieldState
>
{
class
PromQueryField
extends
React
.
Pure
Component
<
PromQueryFieldProps
,
PromQueryFieldState
>
{
plugins
:
any
[];
constructor
(
props
:
PromQueryFieldProps
,
context
)
{
...
...
@@ -189,6 +190,7 @@ class PromQueryField extends React.Component<PromQueryFieldProps, PromQueryField
logLabelOptions
:
[],
metrics
:
props
.
metrics
||
[],
metricsByPrefix
:
props
.
metricsByPrefix
||
[],
metricsOptions
:
[],
};
}
...
...
@@ -258,10 +260,22 @@ class PromQueryField extends React.Component<PromQueryFieldProps, PromQueryField
};
onReceiveMetrics
=
()
=>
{
if
(
!
this
.
state
.
metrics
)
{
const
{
histogramMetrics
,
metrics
,
metricsByPrefix
}
=
this
.
state
;
if
(
!
metrics
)
{
return
;
}
// Update global prism config
setPrismTokens
(
PRISM_SYNTAX
,
METRIC_MARK
,
this
.
state
.
metrics
);
// Build metrics tree
const
histogramOptions
=
histogramMetrics
.
map
(
hm
=>
({
label
:
hm
,
value
:
hm
}));
const
metricsOptions
=
[
{
label
:
'Histograms'
,
value
:
HISTOGRAM_GROUP
,
children
:
histogramOptions
},
...
metricsByPrefix
,
];
this
.
setState
({
metricsOptions
});
};
onTypeahead
=
(
typeahead
:
TypeaheadInput
):
TypeaheadOutput
=>
{
...
...
@@ -453,7 +467,7 @@ class PromQueryField extends React.Component<PromQueryFieldProps, PromQueryField
const
histogramSeries
=
this
.
state
.
labelValues
[
HISTOGRAM_SELECTOR
];
if
(
histogramSeries
&&
histogramSeries
[
'__name__'
])
{
const
histogramMetrics
=
histogramSeries
[
'__name__'
].
slice
().
sort
();
this
.
setState
({
histogramMetrics
});
this
.
setState
({
histogramMetrics
}
,
this
.
onReceiveMetrics
);
}
});
}
...
...
@@ -545,12 +559,7 @@ class PromQueryField extends React.Component<PromQueryFieldProps, PromQueryField
render
()
{
const
{
error
,
hint
,
supportsLogs
}
=
this
.
props
;
const
{
histogramMetrics
,
logLabelOptions
,
metricsByPrefix
}
=
this
.
state
;
const
histogramOptions
=
histogramMetrics
.
map
(
hm
=>
({
label
:
hm
,
value
:
hm
}));
const
metricsOptions
=
[
{
label
:
'Histograms'
,
value
:
HISTOGRAM_GROUP
,
children
:
histogramOptions
},
...
metricsByPrefix
,
];
const
{
logLabelOptions
,
metricsOptions
}
=
this
.
state
;
return
(
<
div
className=
"prom-query-field"
>
...
...
public/app/features/explore/QueryField.tsx
View file @
dc4b0cf2
...
...
@@ -132,7 +132,7 @@ export interface TypeaheadOutput {
suggestions
:
SuggestionGroup
[];
}
class
QueryField
extends
React
.
Component
<
TypeaheadFieldProps
,
TypeaheadFieldState
>
{
class
QueryField
extends
React
.
Pure
Component
<
TypeaheadFieldProps
,
TypeaheadFieldState
>
{
menuEl
:
HTMLElement
|
null
;
plugins
:
any
[];
resetTimer
:
any
;
...
...
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