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
8499d140
Unverified
Commit
8499d140
authored
Nov 09, 2020
by
Torkel Ödegaard
Committed by
GitHub
Nov 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TestData: Fix issue with numeric inputs in TestData query editor (#28936)
parent
ef2de2d3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
public/app/plugins/datasource/testdata/QueryEditor.tsx
+16
-12
No files found.
public/app/plugins/datasource/testdata/QueryEditor.tsx
View file @
8499d140
...
...
@@ -23,9 +23,6 @@ const endpoints = [
{
value
:
'annotations'
,
label
:
'Annotations'
},
];
// Fields that need to be transformed to numbers
const
numberFields
=
[
'lines'
,
'seriesCount'
,
'timeStep'
];
const
selectors
=
editorSelectors
.
components
.
DataSource
.
TestData
.
QueryTab
;
export
interface
EditorProps
{
...
...
@@ -80,22 +77,29 @@ export const QueryEditor = ({ query, datasource, onChange, onRunQuery }: Props)
};
const
onInputChange
=
(
e
:
FormEvent
<
HTMLInputElement
|
HTMLTextAreaElement
>
)
=>
{
const
{
name
,
value
}
=
e
.
target
as
HTMLInputElement
|
HTMLTextAreaElement
;
let
newValue
:
Partial
<
TestDataQuery
>
=
{
[
name
]:
value
};
const
{
name
,
value
,
type
}
=
e
.
target
as
HTMLInputElement
|
HTMLTextAreaElement
;
let
newValue
:
any
=
value
;
if
(
type
===
'number'
)
{
newValue
=
Number
(
value
);
}
if
(
name
===
'levelColumn'
)
{
newValue
=
{
levelColumn
:
(
e
.
target
as
HTMLInputElement
).
checked
};
}
else
if
(
numberFields
.
includes
(
name
))
{
newValue
=
{
[
name
]:
Number
(
value
)
};
newValue
=
(
e
.
target
as
HTMLInputElement
).
checked
;
}
onUpdate
({
...
query
,
...
newValue
});
onUpdate
({
...
query
,
[
name
]:
newValue
});
};
const
onFieldChange
=
(
field
:
string
)
=>
(
e
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
{
name
,
value
}
=
e
.
target
as
HTMLInputElement
;
const
formattedValue
=
numberFields
.
includes
(
name
)
?
Number
(
value
)
:
value
;
onUpdate
({
...
query
,
[
field
]:
{
...
query
[
field
as
keyof
TestDataQuery
],
[
name
]:
formattedValue
}
});
const
{
name
,
value
,
type
}
=
e
.
target
as
HTMLInputElement
;
let
newValue
:
any
=
value
;
if
(
type
===
'number'
)
{
newValue
=
Number
(
value
);
}
onUpdate
({
...
query
,
[
field
]:
{
...
query
[
field
as
keyof
TestDataQuery
],
[
name
]:
newValue
}
});
};
const
onEndPointChange
=
({
value
}:
SelectableValue
)
=>
{
...
...
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