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
60842751
Commit
60842751
authored
Nov 20, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
started on thresholds
parent
ac94fc93
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
130 additions
and
60 deletions
+130
-60
public/app/features/dashboard/dashgrid/DashboardPanel.tsx
+1
-1
public/app/features/dashboard/dashgrid/PanelChrome.tsx
+6
-6
public/app/features/dashboard/dashgrid/VisualizationTab.tsx
+3
-1
public/app/features/dashboard/panel_model.ts
+2
-2
public/app/plugins/panel/gauge/GaugeOptions.tsx
+3
-7
public/app/plugins/panel/gauge/Options.tsx
+0
-28
public/app/plugins/panel/gauge/Thresholds.tsx
+56
-0
public/app/plugins/panel/gauge/ValueOptions.tsx
+3
-7
public/app/plugins/panel/gauge/module.tsx
+43
-3
public/app/types/index.ts
+2
-1
public/app/types/panel.ts
+6
-0
public/app/types/plugins.ts
+1
-0
public/app/viz/Gauge.tsx
+4
-4
No files found.
public/app/features/dashboard/dashgrid/DashboardPanel.tsx
View file @
60842751
...
@@ -136,7 +136,7 @@ export class DashboardPanel extends PureComponent<Props, State> {
...
@@ -136,7 +136,7 @@ export class DashboardPanel extends PureComponent<Props, State> {
return
(
return
(
<
div
className=
{
containerClass
}
>
<
div
className=
{
containerClass
}
>
<
div
className=
{
panelWrapperClass
}
onMouseEnter=
{
this
.
onMouseEnter
}
onMouseLeave=
{
this
.
onMouseLeave
}
>
<
div
className=
{
panelWrapperClass
}
onMouseEnter=
{
this
.
onMouseEnter
}
onMouseLeave=
{
this
.
onMouseLeave
}
>
<
PanelChrome
component=
{
plugin
.
exports
.
Panel
}
panel=
{
panel
}
dashboard=
{
dashboard
}
/>
<
PanelChrome
plugin=
{
plugin
}
panel=
{
panel
}
dashboard=
{
dashboard
}
/>
</
div
>
</
div
>
{
panel
.
isEditing
&&
(
{
panel
.
isEditing
&&
(
<
PanelEditor
panel=
{
panel
}
plugin=
{
plugin
}
dashboard=
{
dashboard
}
onTypeChanged=
{
this
.
onPluginTypeChanged
}
/>
<
PanelEditor
panel=
{
panel
}
plugin=
{
plugin
}
dashboard=
{
dashboard
}
onTypeChanged=
{
this
.
onPluginTypeChanged
}
/>
...
...
public/app/features/dashboard/dashgrid/PanelChrome.tsx
View file @
60842751
// Libraries
// Libraries
import
React
,
{
ComponentClass
,
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
{
AutoSizer
}
from
'react-virtualized'
;
import
{
AutoSizer
}
from
'react-virtualized'
;
// Services
// Services
...
@@ -16,12 +16,12 @@ import { PANEL_HEADER_HEIGHT } from 'app/core/constants';
...
@@ -16,12 +16,12 @@ import { PANEL_HEADER_HEIGHT } from 'app/core/constants';
// Types
// Types
import
{
PanelModel
}
from
'../panel_model'
;
import
{
PanelModel
}
from
'../panel_model'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
import
{
TimeRange
,
PanelProps
}
from
'app/types'
;
import
{
PanelPlugin
,
TimeRange
}
from
'app/types'
;
export
interface
Props
{
export
interface
Props
{
panel
:
PanelModel
;
panel
:
PanelModel
;
dashboard
:
DashboardModel
;
dashboard
:
DashboardModel
;
component
:
ComponentClass
<
PanelProps
>
;
plugin
:
PanelPlugin
;
}
}
export
interface
State
{
export
interface
State
{
...
@@ -80,11 +80,11 @@ export class PanelChrome extends PureComponent<Props, State> {
...
@@ -80,11 +80,11 @@ export class PanelChrome extends PureComponent<Props, State> {
}
}
render
()
{
render
()
{
const
{
panel
,
dashboard
}
=
this
.
props
;
const
{
panel
,
dashboard
,
plugin
}
=
this
.
props
;
const
{
refreshCounter
,
timeRange
,
timeInfo
,
renderCounter
}
=
this
.
state
;
const
{
refreshCounter
,
timeRange
,
timeInfo
,
renderCounter
}
=
this
.
state
;
const
{
datasource
,
targets
}
=
panel
;
const
{
datasource
,
targets
}
=
panel
;
const
PanelComponent
=
this
.
props
.
component
;
const
PanelComponent
=
plugin
.
exports
.
Panel
;
return
(
return
(
<
AutoSizer
>
<
AutoSizer
>
...
@@ -111,7 +111,7 @@ export class PanelChrome extends PureComponent<Props, State> {
...
@@ -111,7 +111,7 @@ export class PanelChrome extends PureComponent<Props, State> {
loading=
{
loading
}
loading=
{
loading
}
timeSeries=
{
timeSeries
}
timeSeries=
{
timeSeries
}
timeRange=
{
timeRange
}
timeRange=
{
timeRange
}
options=
{
panel
.
getOptions
()
}
options=
{
panel
.
getOptions
(
plugin
.
exports
.
PanelDefaults
)
}
width=
{
width
}
width=
{
width
}
height=
{
height
-
PANEL_HEADER_HEIGHT
}
height=
{
height
-
PANEL_HEADER_HEIGHT
}
renderCounter=
{
renderCounter
}
renderCounter=
{
renderCounter
}
...
...
public/app/features/dashboard/dashgrid/VisualizationTab.tsx
View file @
60842751
...
@@ -24,7 +24,9 @@ export class VisualizationTab extends PureComponent<Props> {
...
@@ -24,7 +24,9 @@ export class VisualizationTab extends PureComponent<Props> {
const
{
PanelOptions
}
=
plugin
.
exports
;
const
{
PanelOptions
}
=
plugin
.
exports
;
if
(
PanelOptions
)
{
if
(
PanelOptions
)
{
return
<
PanelOptions
options=
{
panel
.
getOptions
()
}
onChange=
{
this
.
onPanelOptionsChanged
}
/>;
return
(
<
PanelOptions
options=
{
panel
.
getOptions
(
plugin
.
exports
.
PanelDefaults
)
}
onChange=
{
this
.
onPanelOptionsChanged
}
/>
);
}
else
{
}
else
{
return
<
p
>
Visualization has no options
</
p
>;
return
<
p
>
Visualization has no options
</
p
>;
}
}
...
...
public/app/features/dashboard/panel_model.ts
View file @
60842751
...
@@ -70,8 +70,8 @@ export class PanelModel {
...
@@ -70,8 +70,8 @@ export class PanelModel {
_
.
defaultsDeep
(
this
,
_
.
cloneDeep
(
defaults
));
_
.
defaultsDeep
(
this
,
_
.
cloneDeep
(
defaults
));
}
}
getOptions
()
{
getOptions
(
panelDefaults
)
{
return
this
[
this
.
getOptionsKey
()]
||
{}
;
return
_
.
defaultsDeep
(
this
[
this
.
getOptionsKey
()]
||
{},
panelDefaults
)
;
}
}
updateOptions
(
options
:
object
)
{
updateOptions
(
options
:
object
)
{
...
...
public/app/plugins/panel/gauge/GaugeOptions.tsx
View file @
60842751
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
{
OptionsProps
}
from
'./Options'
;
import
{
Switch
}
from
'app/core/components/Switch/Switch'
;
import
{
Switch
}
from
'app/core/components/Switch/Switch'
;
import
{
PanelOptionsProps
}
from
'app/types'
;
import
{
OptionsProps
}
from
'./module'
;
interface
Props
{
export
default
class
GaugeOptions
extends
PureComponent
<
PanelOptionsProps
<
OptionsProps
>>
{
onChange
:
(
item
:
any
)
=>
any
;
options
:
OptionsProps
;
}
export
default
class
GaugeOptions
extends
PureComponent
<
Props
>
{
toggleThresholdLabels
=
()
=>
toggleThresholdLabels
=
()
=>
this
.
props
.
onChange
({
...
this
.
props
.
options
,
showThresholdLabels
:
!
this
.
props
.
options
.
showThresholdLabels
});
this
.
props
.
onChange
({
...
this
.
props
.
options
,
showThresholdLabels
:
!
this
.
props
.
options
.
showThresholdLabels
});
...
...
public/app/plugins/panel/gauge/Options.tsx
deleted
100644 → 0
View file @
ac94fc93
import
React
,
{
PureComponent
}
from
'react'
;
import
ValueOptions
from
'./ValueOptions'
;
import
{
PanelOptionsProps
}
from
'app/types'
;
import
GaugeOptions
from
'./GaugeOptions'
;
export
interface
OptionsProps
{
decimals
:
number
;
prefix
:
string
;
showThresholdLabels
:
boolean
;
showThresholdMarkers
:
boolean
;
stat
:
string
;
suffix
:
string
;
unit
:
string
;
thresholds
:
number
[];
minValue
:
number
;
maxValue
:
number
;
}
export
default
class
Options
extends
PureComponent
<
PanelOptionsProps
<
OptionsProps
>>
{
render
()
{
return
(
<
div
>
<
ValueOptions
onChange=
{
this
.
props
.
onChange
}
options=
{
this
.
props
.
options
}
/>
<
GaugeOptions
onChange=
{
this
.
props
.
onChange
}
options=
{
this
.
props
.
options
}
/>
</
div
>
);
}
}
public/app/plugins/panel/gauge/Thresholds.tsx
0 → 100644
View file @
60842751
import
React
,
{
PureComponent
}
from
'react'
;
import
{
PanelOptionsProps
,
Threshold
}
from
'app/types'
;
import
{
OptionsProps
}
from
'./module'
;
import
{
Label
}
from
'../../../core/components/Label/Label'
;
interface
State
{
thresholds
:
Threshold
[];
}
export
default
class
Thresholds
extends
PureComponent
<
PanelOptionsProps
<
OptionsProps
>
,
State
>
{
state
=
{
thresholds
:
[{
label
:
'Min'
,
value
:
0
},
{
label
:
'Max'
,
value
:
100
}],
};
onAddThreshold
=
()
=>
{
this
.
setState
(
prevState
=>
({
thresholds
:
[
prevState
.
thresholds
[
0
],
{
label
:
''
,
value
:
0
},
{
label
:
'Max'
,
value
:
100
}],
}));
};
render
()
{
const
{
thresholds
}
=
this
.
state
;
return
(
<
div
className=
"section gf-form-group"
>
<
h5
className=
"page-heading"
>
Thresholds
</
h5
>
<
div
style=
{
{
display
:
'flex'
,
alignItems
:
'flexStart'
}
}
>
<
div
style=
{
{
width
:
'20px'
,
minHeight
:
'40px'
,
flex
:
'0 1 auto'
,
background
:
'linear-gradient(to bottom, green, red)'
,
}
}
/>
<
div
style=
{
{
flex
:
'1 0 auto'
}
}
>
{
thresholds
.
map
((
threshold
,
index
)
=>
{
return
(
<
div
className=
"gf-form"
key=
{
`${threshold}-${index}`
}
>
<
Label
width=
{
5
}
>
{
threshold
.
label
}
</
Label
>
<
input
className=
"gf-form-input"
type=
"text"
value=
{
threshold
.
value
}
/>
</
div
>
);
})
}
<
div
className=
"gf-form"
>
<
Label
width=
{
5
}
>
Add
</
Label
>
<
span
className=
"gf-form-input"
onClick=
{
this
.
onAddThreshold
}
>
+
</
span
>
</
div
>
</
div
>
</
div
>
</
div
>
);
}
}
public/app/plugins/panel/gauge/ValueOptions.tsx
View file @
60842751
...
@@ -2,7 +2,8 @@ import React, { PureComponent } from 'react';
...
@@ -2,7 +2,8 @@ import React, { PureComponent } from 'react';
import
{
Label
}
from
'app/core/components/Label/Label'
;
import
{
Label
}
from
'app/core/components/Label/Label'
;
import
SimplePicker
from
'app/core/components/Picker/SimplePicker'
;
import
SimplePicker
from
'app/core/components/Picker/SimplePicker'
;
import
UnitPicker
from
'app/core/components/Picker/Unit/UnitPicker'
;
import
UnitPicker
from
'app/core/components/Picker/Unit/UnitPicker'
;
import
{
OptionsProps
}
from
'./Options'
;
import
{
PanelOptionsProps
}
from
'app/types'
;
import
{
OptionsProps
}
from
'./module'
;
const
statOptions
=
[
const
statOptions
=
[
{
value
:
'min'
,
text
:
'Min'
},
{
value
:
'min'
,
text
:
'Min'
},
...
@@ -20,12 +21,7 @@ const statOptions = [
...
@@ -20,12 +21,7 @@ const statOptions = [
const
labelWidth
=
6
;
const
labelWidth
=
6
;
interface
Props
{
export
default
class
ValueOptions
extends
PureComponent
<
PanelOptionsProps
<
OptionsProps
>>
{
onChange
:
(
arg
:
any
)
=>
void
;
options
:
OptionsProps
;
}
export
default
class
ValueOptions
extends
PureComponent
<
Props
>
{
onUnitChange
=
unit
=>
this
.
props
.
onChange
({
...
this
.
props
.
options
,
unit
:
unit
.
value
});
onUnitChange
=
unit
=>
this
.
props
.
onChange
({
...
this
.
props
.
options
,
unit
:
unit
.
value
});
onStatChange
=
stat
=>
this
.
props
.
onChange
({
...
this
.
props
.
options
,
stat
:
stat
.
value
});
onStatChange
=
stat
=>
this
.
props
.
onChange
({
...
this
.
props
.
options
,
stat
:
stat
.
value
});
...
...
public/app/plugins/panel/gauge/module.tsx
View file @
60842751
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
Gauge
from
'app/viz/Gauge'
;
import
Gauge
from
'app/viz/Gauge'
;
import
Options
,
{
OptionsProps
}
from
'./Options'
;
import
{
NullValueMode
,
PanelOptionsProps
,
PanelProps
,
Threshold
}
from
'app/types'
;
import
{
NullValueMode
,
PanelProps
}
from
'app/types'
;
import
{
getTimeSeriesVMs
}
from
'app/viz/state/timeSeries'
;
import
{
getTimeSeriesVMs
}
from
'app/viz/state/timeSeries'
;
import
ValueOptions
from
'./ValueOptions'
;
import
GaugeOptions
from
'./GaugeOptions'
;
import
Thresholds
from
'./Thresholds'
;
export
interface
OptionsProps
{
decimals
:
number
;
prefix
:
string
;
showThresholdLabels
:
boolean
;
showThresholdMarkers
:
boolean
;
stat
:
string
;
suffix
:
string
;
unit
:
string
;
thresholds
:
Threshold
[];
minValue
:
number
;
maxValue
:
number
;
}
export
const
defaultProps
=
{
options
:
{
minValue
:
0
,
maxValue
:
100
,
prefix
:
''
,
showThresholdMarkers
:
true
,
showThresholdLabels
:
false
,
suffix
:
''
,
},
};
interface
Props
extends
PanelProps
<
OptionsProps
>
{}
interface
Props
extends
PanelProps
<
OptionsProps
>
{}
...
@@ -19,4 +45,18 @@ class GaugePanel extends PureComponent<Props> {
...
@@ -19,4 +45,18 @@ class GaugePanel extends PureComponent<Props> {
}
}
}
}
export
{
GaugePanel
as
Panel
,
Options
as
PanelOptions
};
class
Options
extends
PureComponent
<
PanelOptionsProps
<
OptionsProps
>>
{
static
defaultProps
=
defaultProps
;
render
()
{
return
(
<
div
>
<
ValueOptions
onChange=
{
this
.
props
.
onChange
}
options=
{
this
.
props
.
options
}
/>
<
GaugeOptions
onChange=
{
this
.
props
.
onChange
}
options=
{
this
.
props
.
options
}
/>
<
Thresholds
onChange=
{
this
.
props
.
onChange
}
options=
{
this
.
props
.
options
}
/>
</
div
>
);
}
}
export
{
GaugePanel
as
Panel
,
Options
as
PanelOptions
,
defaultProps
as
PanelDefaults
};
public/app/types/index.ts
View file @
60842751
...
@@ -20,7 +20,7 @@ import {
...
@@ -20,7 +20,7 @@ import {
DataQueryResponse
,
DataQueryResponse
,
DataQueryOptions
,
DataQueryOptions
,
}
from
'./series'
;
}
from
'./series'
;
import
{
PanelProps
,
PanelOptionsProps
}
from
'./panel'
;
import
{
PanelProps
,
PanelOptionsProps
,
Threshold
}
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
{
...
@@ -89,6 +89,7 @@ export {
...
@@ -89,6 +89,7 @@ export {
AppNotificationTimeout
,
AppNotificationTimeout
,
DashboardSearchHit
,
DashboardSearchHit
,
UserState
,
UserState
,
Threshold
,
};
};
export
interface
StoreState
{
export
interface
StoreState
{
...
...
public/app/types/panel.ts
View file @
60842751
...
@@ -28,3 +28,9 @@ export interface PanelMenuItem {
...
@@ -28,3 +28,9 @@ export interface PanelMenuItem {
shortcut
?:
string
;
shortcut
?:
string
;
subMenu
?:
PanelMenuItem
[];
subMenu
?:
PanelMenuItem
[];
}
}
export
interface
Threshold
{
label
:
string
;
value
:
number
;
color
?:
string
;
}
public/app/types/plugins.ts
View file @
60842751
...
@@ -13,6 +13,7 @@ export interface PluginExports {
...
@@ -13,6 +13,7 @@ export interface PluginExports {
PanelCtrl
?;
PanelCtrl
?;
Panel
?:
ComponentClass
<
PanelProps
>
;
Panel
?:
ComponentClass
<
PanelProps
>
;
PanelOptions
?:
ComponentClass
<
PanelOptionsProps
>
;
PanelOptions
?:
ComponentClass
<
PanelOptionsProps
>
;
PanelDefaults
?:
any
;
}
}
export
interface
PanelPlugin
{
export
interface
PanelPlugin
{
...
...
public/app/viz/Gauge.tsx
View file @
60842751
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
$
from
'jquery'
;
import
$
from
'jquery'
;
import
{
TimeSeriesVMs
}
from
'app/types'
;
import
{
T
hreshold
,
T
imeSeriesVMs
}
from
'app/types'
;
import
config
from
'../core/config'
;
import
config
from
'../core/config'
;
import
kbn
from
'../core/utils/kbn'
;
import
kbn
from
'../core/utils/kbn'
;
...
@@ -10,7 +10,7 @@ interface Props {
...
@@ -10,7 +10,7 @@ interface Props {
minValue
:
number
;
minValue
:
number
;
maxValue
:
number
;
maxValue
:
number
;
showThresholdMarkers
:
boolean
;
showThresholdMarkers
:
boolean
;
thresholds
:
number
[];
thresholds
:
Threshold
[];
showThresholdLabels
:
boolean
;
showThresholdLabels
:
boolean
;
unit
:
string
;
unit
:
string
;
width
:
number
;
width
:
number
;
...
@@ -32,7 +32,7 @@ export class Gauge extends PureComponent<Props> {
...
@@ -32,7 +32,7 @@ export class Gauge extends PureComponent<Props> {
showThresholdMarkers
:
true
,
showThresholdMarkers
:
true
,
showThresholdLabels
:
false
,
showThresholdLabels
:
false
,
suffix
:
''
,
suffix
:
''
,
thresholds
:
[
0
,
100
],
thresholds
:
[
{
label
:
'Min'
,
value
:
0
},
{
label
:
'Max'
,
value
:
100
}
],
};
};
componentDidMount
()
{
componentDidMount
()
{
...
@@ -75,7 +75,7 @@ export class Gauge extends PureComponent<Props> {
...
@@ -75,7 +75,7 @@ export class Gauge extends PureComponent<Props> {
const
formattedThresholds
=
thresholds
.
map
((
threshold
,
index
)
=>
{
const
formattedThresholds
=
thresholds
.
map
((
threshold
,
index
)
=>
{
return
{
return
{
value
:
threshold
,
value
:
threshold
.
value
,
color
:
colors
[
index
],
color
:
colors
[
index
],
};
};
});
});
...
...
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