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
80a2c3b1
Commit
80a2c3b1
authored
Dec 12, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redone state
parent
50cd8d99
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
41 deletions
+23
-41
public/app/plugins/panel/gauge/MappingRow.tsx
+23
-41
No files found.
public/app/plugins/panel/gauge/MappingRow.tsx
View file @
80a2c3b1
...
...
@@ -10,7 +10,13 @@ interface Props {
}
interface
State
{
mapping
:
ValueMap
|
RangeMap
;
from
:
string
;
id
:
number
;
operator
:
string
;
text
:
string
;
to
:
string
;
type
:
MappingType
;
value
:
string
;
}
const
mappingOptions
=
[
...
...
@@ -23,60 +29,38 @@ export default class MappingRow extends PureComponent<Props, State> {
super
(
props
);
this
.
state
=
{
mapping
:
props
.
mapping
,
...
props
.
mapping
,
};
}
onMappingValueChange
=
event
=>
{
const
{
mapping
}
=
this
.
state
;
const
updatedMapping
=
{
...
mapping
,
value
:
event
.
target
.
value
};
this
.
setState
({
mapping
:
updatedMapping
});
this
.
setState
({
value
:
event
.
target
.
value
});
};
onMappingFromChange
=
event
=>
{
const
{
mapping
}
=
this
.
state
;
const
updatedMapping
=
{
...
mapping
,
from
:
event
.
target
.
value
};
this
.
setState
({
mapping
:
updatedMapping
});
this
.
setState
({
from
:
event
.
target
.
value
});
};
onMappingToChange
=
event
=>
{
const
{
mapping
}
=
this
.
state
;
const
updatedMapping
=
{
...
mapping
,
to
:
event
.
target
.
value
};
this
.
setState
({
mapping
:
updatedMapping
});
this
.
setState
({
to
:
event
.
target
.
value
});
};
onMappingTextChange
=
event
=>
{
const
{
mapping
}
=
this
.
state
;
const
updatedMapping
=
{
...
mapping
,
text
:
event
.
target
.
value
};
this
.
setState
({
mapping
:
updatedMapping
});
this
.
setState
({
text
:
event
.
target
.
value
});
};
onMappingTypeChange
=
mappingType
=>
{
const
{
mapping
}
=
this
.
state
;
const
updatedMapping
=
{
...
mapping
,
type
:
mappingType
};
this
.
setState
({
mapping
:
updatedMapping
});
this
.
setState
({
type
:
mappingType
});
};
updateMapping
=
()
=>
{
const
{
mapping
}
=
this
.
state
;
this
.
props
.
updateMapping
(
mapping
);
this
.
props
.
updateMapping
({
...
this
.
state
});
};
renderRow
()
{
const
{
mapping
}
=
this
.
state
;
if
(
mapping
.
type
===
MappingType
.
RangeToText
)
{
const
rangeMap
=
mapping
as
RangeMap
;
const
{
from
,
text
,
to
,
type
,
value
}
=
this
.
state
;
if
(
type
===
MappingType
.
RangeToText
)
{
return
(
<
div
className=
"gf-form"
>
<
div
className=
"gf-form-inline mapping-row-input"
>
...
...
@@ -84,7 +68,7 @@ export default class MappingRow extends PureComponent<Props, State> {
<
div
>
<
input
className=
"gf-form-input"
value=
{
rangeMap
.
from
}
value=
{
from
}
onBlur=
{
this
.
updateMapping
}
onChange=
{
this
.
onMappingFromChange
}
/>
...
...
@@ -95,7 +79,7 @@ export default class MappingRow extends PureComponent<Props, State> {
<
div
>
<
input
className=
"gf-form-input"
value=
{
rangeMap
.
to
}
value=
{
to
}
onBlur=
{
this
.
updateMapping
}
onChange=
{
this
.
onMappingToChange
}
/>
...
...
@@ -106,7 +90,7 @@ export default class MappingRow extends PureComponent<Props, State> {
<
div
>
<
input
className=
"gf-form-input"
value=
{
rangeMap
.
text
}
value=
{
text
}
onBlur=
{
this
.
updateMapping
}
onChange=
{
this
.
onMappingTextChange
}
/>
...
...
@@ -116,8 +100,6 @@ export default class MappingRow extends PureComponent<Props, State> {
);
}
const
valueMap
=
mapping
as
ValueMap
;
return
(
<
div
className=
"gf-form"
>
<
div
className=
"gf-form-inline mapping-row-input"
>
...
...
@@ -127,7 +109,7 @@ export default class MappingRow extends PureComponent<Props, State> {
className=
"gf-form-input"
onBlur=
{
this
.
updateMapping
}
onChange=
{
this
.
onMappingValueChange
}
value=
{
value
Map
.
value
}
value=
{
value
}
/>
</
div
>
</
div
>
...
...
@@ -137,7 +119,7 @@ export default class MappingRow extends PureComponent<Props, State> {
<
input
className=
"gf-form-input"
onBlur=
{
this
.
updateMapping
}
value=
{
valueMap
.
text
}
value=
{
text
}
onChange=
{
this
.
onMappingTextChange
}
/>
</
div
>
...
...
@@ -147,7 +129,7 @@ export default class MappingRow extends PureComponent<Props, State> {
}
render
()
{
const
{
mapping
}
=
this
.
state
;
const
{
type
}
=
this
.
state
;
return
(
<
div
className=
"mapping-row"
>
...
...
@@ -156,7 +138,7 @@ export default class MappingRow extends PureComponent<Props, State> {
<
SimplePicker
placeholder=
"Choose type"
options=
{
mappingOptions
}
value=
{
mappingOptions
.
find
(
o
=>
o
.
value
===
mapping
.
type
)
}
value=
{
mappingOptions
.
find
(
o
=>
o
.
value
===
type
)
}
getOptionLabel=
{
i
=>
i
.
label
}
getOptionValue=
{
i
=>
i
.
value
}
onSelected=
{
type
=>
this
.
onMappingTypeChange
(
type
.
value
)
}
...
...
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