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
6fff8e4a
Commit
6fff8e4a
authored
Dec 06, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial stuff
parent
8fa7a71d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
131 additions
and
7 deletions
+131
-7
public/app/core/components/Picker/SimplePicker.tsx
+2
-2
public/app/plugins/panel/gauge/ValueMappings.tsx
+96
-0
public/app/plugins/panel/gauge/module.tsx
+16
-4
public/app/types/index.ts
+3
-1
public/app/types/panel.ts
+14
-0
No files found.
public/app/core/components/Picker/SimplePicker.tsx
View file @
6fff8e4a
...
@@ -6,8 +6,8 @@ import ResetStyles from './ResetStyles';
...
@@ -6,8 +6,8 @@ import ResetStyles from './ResetStyles';
interface
Props
{
interface
Props
{
className
?:
string
;
className
?:
string
;
defaultValue
?:
any
;
defaultValue
?:
any
;
getOptionLabel
:
(
item
:
any
)
=>
string
;
getOptionLabel
?
:
(
item
:
any
)
=>
string
;
getOptionValue
:
(
item
:
any
)
=>
string
;
getOptionValue
?
:
(
item
:
any
)
=>
string
;
onSelected
:
(
item
:
any
)
=>
{}
|
void
;
onSelected
:
(
item
:
any
)
=>
{}
|
void
;
options
:
any
[];
options
:
any
[];
placeholder
?:
string
;
placeholder
?:
string
;
...
...
public/app/plugins/panel/gauge/ValueMappings.tsx
0 → 100644
View file @
6fff8e4a
import
React
,
{
PureComponent
}
from
'react'
;
import
{
Label
}
from
'app/core/components/Label/Label'
;
import
SimplePicker
from
'app/core/components/Picker/SimplePicker'
;
import
{
OptionModuleProps
}
from
'./module'
;
import
{
RangeMap
,
ValueMap
}
from
'app/types'
;
interface
State
{
valueMaps
:
ValueMap
[];
rangeMaps
:
RangeMap
[];
}
enum
MappingType
{
ValueToText
=
1
,
RangeToText
=
2
,
}
const
mappingOptions
=
[
{
name
:
'Value to text'
,
value
:
MappingType
.
ValueToText
},
{
name
:
'Range to text'
,
value
:
MappingType
.
RangeToText
},
];
export
default
class
ValueMappings
extends
PureComponent
<
OptionModuleProps
,
State
>
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
valueMaps
:
props
.
options
.
valueMaps
,
rangeMaps
:
props
.
options
.
rangeMaps
,
};
}
onMappingTypeChange
=
option
=>
this
.
props
.
onChange
({
...
this
.
props
.
options
,
mappingType
:
option
.
value
});
addValueMap
=
()
=>
this
.
setState
(
prevState
=>
({
valueMaps
:
[...
prevState
.
valueMaps
,
{
op
:
''
,
value
:
''
,
text
:
''
}],
}));
addRangeMap
=
()
=>
{
this
.
setState
=
()
=>
this
.
setState
(
prevState
=>
({
valueMaps
:
[...
prevState
.
valueMaps
,
{
op
:
''
,
value
:
''
,
text
:
''
,
from
:
''
,
to
:
''
}],
}));
};
updateGauge
=
()
=>
{};
renderValueMapList
()
{
const
{
mappingType
,
rangeMaps
,
valueMaps
}
=
this
.
props
.
options
;
if
(
mappingType
===
MappingType
.
RangeToText
)
{
return
(
<
div
>
{
rangeMaps
.
length
>
0
?
rangeMaps
.
map
((
range
,
index
)
=>
{
return
<
div
>
{
`${range.from}-${range.to}`
}
</
div
>;
})
:
'aint no ranges, add one?'
}
</
div
>
);
}
return
(
<
div
>
{
valueMaps
.
length
>
0
?
valueMaps
.
map
((
value
,
index
)
=>
{
return
<
div
>
{
`${value}`
}
</
div
>;
})
:
'aint no values, add one?'
}
</
div
>
);
}
render
()
{
const
{
mappingType
}
=
this
.
props
.
options
;
return
(
<
div
className=
"gf-form-group"
>
<
div
className=
"gf-form"
>
<
Label
width=
{
5
}
>
Type
</
Label
>
<
SimplePicker
options=
{
mappingOptions
}
defaultValue=
{
MappingType
.
ValueToText
}
getOptionLabel=
{
i
=>
i
.
name
}
onSelected=
{
option
=>
this
.
onMappingTypeChange
(
option
)
}
width=
{
5
}
value=
{
mappingType
}
/>
</
div
>
<
div
className=
"section gf-form-group"
>
<
h5
className=
"page-heading"
>
Set value mappings
</
h5
>
<
div
className=
"gf-form"
>
{
this
.
renderValueMapList
()
}
</
div
>
</
div
>
</
div
>
);
}
}
public/app/plugins/panel/gauge/module.tsx
View file @
6fff8e4a
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
Gauge
from
'app/viz/Gauge'
;
import
Gauge
from
'app/viz/Gauge'
;
import
{
NullValueMode
,
PanelOptionsProps
,
PanelProps
,
Threshold
}
from
'app/types'
;
import
{
NullValueMode
,
PanelOptionsProps
,
PanelProps
,
RangeMap
,
Threshold
,
ValueMap
}
from
'app/types'
;
import
{
getTimeSeriesVMs
}
from
'app/viz/state/timeSeries'
;
import
{
getTimeSeriesVMs
}
from
'app/viz/state/timeSeries'
;
import
ValueOptions
from
'./ValueOptions'
;
import
ValueOptions
from
'./ValueOptions'
;
import
GaugeOptions
from
'./GaugeOptions'
;
import
GaugeOptions
from
'./GaugeOptions'
;
import
Thresholds
from
'./Thresholds'
;
import
Thresholds
from
'./Thresholds'
;
import
ValueMappings
from
'./ValueMappings'
;
export
interface
OptionsProps
{
export
interface
OptionsProps
{
decimals
:
number
;
decimals
:
number
;
...
@@ -15,6 +16,9 @@ export interface OptionsProps {
...
@@ -15,6 +16,9 @@ export interface OptionsProps {
suffix
:
string
;
suffix
:
string
;
unit
:
string
;
unit
:
string
;
thresholds
:
Threshold
[];
thresholds
:
Threshold
[];
valueMaps
:
ValueMap
[];
rangeMaps
:
RangeMap
[];
mappingType
:
number
;
}
}
export
interface
OptionModuleProps
{
export
interface
OptionModuleProps
{
...
@@ -52,11 +56,19 @@ class Options extends PureComponent<PanelOptionsProps<OptionsProps>> {
...
@@ -52,11 +56,19 @@ class Options extends PureComponent<PanelOptionsProps<OptionsProps>> {
static
defaultProps
=
defaultProps
;
static
defaultProps
=
defaultProps
;
render
()
{
render
()
{
const
{
onChange
,
options
}
=
this
.
props
;
return
(
return
(
<
div
>
<
div
>
<
ValueOptions
onChange=
{
this
.
props
.
onChange
}
options=
{
this
.
props
.
options
}
/>
<
div
className=
"form-section"
>
<
GaugeOptions
onChange=
{
this
.
props
.
onChange
}
options=
{
this
.
props
.
options
}
/>
<
div
className=
"form-section__header"
>
Options
</
div
>
<
Thresholds
onChange=
{
this
.
props
.
onChange
}
options=
{
this
.
props
.
options
}
/>
<
ValueOptions
onChange=
{
onChange
}
options=
{
options
}
/>
<
GaugeOptions
onChange=
{
onChange
}
options=
{
options
}
/>
<
Thresholds
onChange=
{
onChange
}
options=
{
options
}
/>
</
div
>
<
div
className=
"form-section"
>
<
div
className=
"form-section__header"
>
Value mappings
</
div
>
<
ValueMappings
onChange=
{
onChange
}
options=
{
options
}
/>
</
div
>
</
div
>
</
div
>
);
);
}
}
...
...
public/app/types/index.ts
View file @
6fff8e4a
...
@@ -20,7 +20,7 @@ import {
...
@@ -20,7 +20,7 @@ import {
DataQueryResponse
,
DataQueryResponse
,
DataQueryOptions
,
DataQueryOptions
,
}
from
'./series'
;
}
from
'./series'
;
import
{
PanelProps
,
PanelOptionsProps
,
Threshold
}
from
'./panel'
;
import
{
PanelProps
,
PanelOptionsProps
,
RangeMap
,
Threshold
,
ValueMap
}
from
'./panel'
;
import
{
PluginDashboard
,
PluginMeta
,
Plugin
,
PanelPlugin
,
PluginsState
}
from
'./plugins'
;
import
{
PluginDashboard
,
PluginMeta
,
Plugin
,
PanelPlugin
,
PluginsState
}
from
'./plugins'
;
import
{
Organization
,
OrganizationState
}
from
'./organization'
;
import
{
Organization
,
OrganizationState
}
from
'./organization'
;
import
{
import
{
...
@@ -92,6 +92,8 @@ export {
...
@@ -92,6 +92,8 @@ export {
Threshold
,
Threshold
,
ValidationEvents
,
ValidationEvents
,
ValidationRule
,
ValidationRule
,
ValueMap
,
RangeMap
,
};
};
export
interface
StoreState
{
export
interface
StoreState
{
...
...
public/app/types/panel.ts
View file @
6fff8e4a
...
@@ -36,3 +36,17 @@ export interface Threshold {
...
@@ -36,3 +36,17 @@ export interface Threshold {
color
?:
string
;
color
?:
string
;
canRemove
:
boolean
;
canRemove
:
boolean
;
}
}
interface
BaseMap
{
op
:
string
;
text
:
string
;
}
export
interface
ValueMap
extends
BaseMap
{
value
:
string
;
}
export
interface
RangeMap
extends
BaseMap
{
from
:
string
;
to
:
string
;
}
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