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
edbde6c0
Unverified
Commit
edbde6c0
authored
Dec 11, 2020
by
Peter Holmberg
Committed by
GitHub
Dec 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expressions: Add placeholders to hint on input (#29773)
* math placeholder * resample changes
parent
6118ab41
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
20 deletions
+57
-20
public/app/features/expressions/ExpressionQueryEditor.tsx
+57
-20
No files found.
public/app/features/expressions/ExpressionQueryEditor.tsx
View file @
edbde6c0
// Libraries
import
React
,
{
PureComponent
,
ChangeEvent
}
from
'react'
;
import
{
css
}
from
'emotion'
;
import
{
InlineField
,
InlineFieldRow
,
Input
,
Select
,
TextArea
}
from
'@grafana/ui'
;
import
{
SelectableValue
,
ReducerID
,
QueryEditorProps
}
from
'@grafana/data'
;
...
...
@@ -39,6 +40,11 @@ const upsamplingTypes: Array<SelectableValue<string>> = [
{
value
:
'fillna'
,
label
:
'fillna'
,
description
:
'Fill with NaNs'
},
];
const
mathPlaceholder
=
'Math operations on one more queries, you reference the query by ${refId} ie. $A, $B, $C etc
\
n'
+
'Example: $A + $B
\
n'
+
'Available functions: abs(), log(), nan(), inf(), null()'
;
export
class
ExpressionQueryEditor
extends
PureComponent
<
Props
,
State
>
{
state
=
{};
...
...
@@ -123,42 +129,73 @@ export class ExpressionQueryEditor extends PureComponent<Props, State> {
const
reducer
=
reducerTypes
.
find
(
o
=>
o
.
value
===
query
.
reducer
);
const
downsampler
=
downsamplingTypes
.
find
(
o
=>
o
.
value
===
query
.
downsampler
);
const
upsampler
=
upsamplingTypes
.
find
(
o
=>
o
.
value
===
query
.
upsampler
);
const
labelWidth
=
14
;
return
(
<
div
>
<
InlineField
label=
"Operation"
>
<
InlineField
label=
"Operation"
labelWidth=
{
labelWidth
}
>
<
Select
options=
{
gelTypes
}
value=
{
selected
}
onChange=
{
this
.
onSelectGELType
}
width=
{
25
}
/>
</
InlineField
>
{
query
.
type
===
GELQueryType
.
math
&&
(
<
InlineField
label=
"Expression"
>
<
TextArea
value=
{
query
.
expression
}
onChange=
{
this
.
onExpressionChange
}
rows=
{
2
}
/>
<
InlineField
label=
"Expression"
labelWidth=
{
labelWidth
}
className=
{
css
`
align-items: baseline;
`
}
>
<
TextArea
value=
{
query
.
expression
}
onChange=
{
this
.
onExpressionChange
}
rows=
{
4
}
placeholder=
{
mathPlaceholder
}
/>
</
InlineField
>
)
}
{
query
.
type
===
GELQueryType
.
reduce
&&
(
<
InlineFieldRow
>
<
InlineField
label=
"Function"
>
<
InlineField
label=
"Function"
labelWidth=
{
labelWidth
}
>
<
Select
options=
{
reducerTypes
}
value=
{
reducer
}
onChange=
{
this
.
onSelectReducer
}
width=
{
25
}
/>
</
InlineField
>
<
InlineField
label=
"Input"
>
<
Input
onChange=
{
this
.
onExpressionChange
}
value=
{
query
.
expression
}
width=
{
25
}
/>
<
InlineField
label=
"Query"
labelWidth=
{
labelWidth
}
>
<
Input
onChange=
{
this
.
onExpressionChange
}
value=
{
query
.
expression
}
width=
{
30
}
placeholder=
"Choose query by refId (eg. $A or A)"
/>
</
InlineField
>
</
InlineFieldRow
>
)
}
{
query
.
type
===
GELQueryType
.
resample
&&
(
<
InlineFieldRow
>
<
InlineField
label=
"Input"
>
<
Input
onChange=
{
this
.
onExpressionChange
}
value=
{
query
.
expression
}
width=
{
25
}
/>
</
InlineField
>
<
InlineField
label=
"Window"
>
<
Input
onChange=
{
this
.
onWindowChange
}
value=
{
query
.
window
}
width=
{
25
}
/>
</
InlineField
>
<
InlineField
label=
"Downsample"
>
<
Select
options=
{
downsamplingTypes
}
value=
{
downsampler
}
onChange=
{
this
.
onSelectDownsampler
}
width=
{
25
}
/>
</
InlineField
>
<
InlineField
label=
"Upsample"
>
<
Select
options=
{
upsamplingTypes
}
value=
{
upsampler
}
onChange=
{
this
.
onSelectUpsampler
}
width=
{
25
}
/>
</
InlineField
>
</
InlineFieldRow
>
<>
<
InlineFieldRow
>
<
InlineField
label=
"Query"
labelWidth=
{
labelWidth
}
>
<
Input
onChange=
{
this
.
onExpressionChange
}
value=
{
query
.
expression
}
width=
{
30
}
placeholder=
"Choose query by refId (eg. $A or A)"
/>
</
InlineField
>
</
InlineFieldRow
>
<
InlineFieldRow
>
<
InlineField
label=
"Resample to"
labelWidth=
{
labelWidth
}
tooltip=
"10s, 1m, 30m, 1h"
>
<
Input
onChange=
{
this
.
onWindowChange
}
value=
{
query
.
window
}
width=
{
15
}
/>
</
InlineField
>
<
InlineField
label=
"Downsample"
>
<
Select
options=
{
downsamplingTypes
}
value=
{
downsampler
}
onChange=
{
this
.
onSelectDownsampler
}
width=
{
25
}
/>
</
InlineField
>
<
InlineField
label=
"Upsample"
>
<
Select
options=
{
upsamplingTypes
}
value=
{
upsampler
}
onChange=
{
this
.
onSelectUpsampler
}
width=
{
25
}
/>
</
InlineField
>
</
InlineFieldRow
>
</>
)
}
</
div
>
);
...
...
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