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
57227734
Commit
57227734
authored
Nov 19, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'unit-picker' into gauge-value-options
parents
f72e7517
5916f769
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
191 additions
and
22 deletions
+191
-22
public/app/core/components/Picker/Unit/UnitGroup.tsx
+43
-0
public/app/core/components/Picker/Unit/UnitOption.tsx
+22
-0
public/app/core/components/Picker/Unit/UnitPicker.tsx
+68
-0
public/app/core/utils/kbn.ts
+2
-1
public/app/features/dashboard/dashgrid/DataPanel.tsx
+1
-0
public/app/features/dashboard/dashgrid/PanelChrome.tsx
+0
-2
public/app/plugins/datasource/elasticsearch/config_ctrl.ts
+4
-2
public/app/plugins/panel/gauge/module.tsx
+15
-7
public/app/viz/Gauge.tsx
+10
-1
public/sass/_grafana.scss
+1
-0
public/sass/components/_unit-picker.scss
+24
-0
yarn.lock
+1
-9
No files found.
public/app/core/components/Picker/Unit/UnitGroup.tsx
0 → 100644
View file @
57227734
import
React
,
{
PureComponent
}
from
'react'
;
import
{
GroupProps
}
from
'react-select/lib/components/Group'
;
interface
ExtendedGroupProps
extends
GroupProps
<
any
>
{
data
:
any
;
}
interface
State
{
expanded
:
boolean
;
}
export
default
class
UnitGroup
extends
PureComponent
<
ExtendedGroupProps
,
State
>
{
state
=
{
expanded
:
false
,
};
componentDidUpdate
(
nextProps
)
{
if
(
nextProps
.
selectProps
.
inputValue
!==
''
)
{
this
.
setState
({
expanded
:
true
});
}
}
onToggleChildren
=
()
=>
{
this
.
setState
(
prevState
=>
({
expanded
:
!
prevState
.
expanded
,
}));
};
render
()
{
const
{
children
,
label
}
=
this
.
props
;
const
{
expanded
}
=
this
.
state
;
return
(
<
div
className=
"width-21 unit-picker-group"
style=
{
{
marginBottom
:
'5px'
}
}
>
<
div
className=
"unit-picker-group-item"
onClick=
{
this
.
onToggleChildren
}
>
<
span
style=
{
{
textTransform
:
'capitalize'
}
}
>
{
label
}
</
span
>
<
i
className=
{
`fa ${expanded ? 'fa-minus' : 'fa-plus'}`
}
/>
{
' '
}
</
div
>
{
expanded
&&
children
}
</
div
>
);
}
}
public/app/core/components/Picker/Unit/UnitOption.tsx
0 → 100644
View file @
57227734
import
React
,
{
SFC
}
from
'react'
;
import
{
components
}
from
'react-select'
;
import
{
OptionProps
}
from
'react-select/lib/components/Option'
;
interface
ExtendedOptionProps
extends
OptionProps
<
any
>
{
data
:
any
;
}
const
UnitOption
:
SFC
<
ExtendedOptionProps
>
=
props
=>
{
const
{
children
,
isSelected
,
className
}
=
props
;
return
(
<
components
.
Option
{
...
props
}
>
<
div
className=
{
`unit-picker-option__button btn btn-link ${className}`
}
>
{
isSelected
&&
<
i
className=
"fa fa-check pull-right"
aria
-
hidden=
"true"
/>
}
<
div
className=
"gf-form"
>
{
children
}
</
div
>
</
div
>
</
components
.
Option
>
);
};
export
default
UnitOption
;
public/app/core/components/Picker/Unit/UnitPicker.tsx
0 → 100644
View file @
57227734
import
React
,
{
PureComponent
}
from
'react'
;
import
Select
from
'react-select'
;
import
UnitGroup
from
'./UnitGroup'
;
import
UnitOption
from
'./UnitOption'
;
import
ResetStyles
from
'../ResetStyles'
;
import
kbn
from
'../../../utils/kbn'
;
interface
Props
{
onSelected
:
(
item
:
any
)
=>
{}
|
void
;
defaultValue
?:
string
;
}
export
default
class
UnitPicker
extends
PureComponent
<
Props
>
{
render
()
{
const
{
defaultValue
,
onSelected
}
=
this
.
props
;
const
unitGroups
=
kbn
.
getUnitFormats
();
// Need to transform the data structure to work well with Select
const
groupOptions
=
unitGroups
.
map
(
group
=>
{
const
options
=
group
.
submenu
.
map
(
unit
=>
{
return
{
label
:
unit
.
text
,
value
:
unit
.
value
,
};
});
return
{
label
:
group
.
text
,
options
,
};
});
const
styles
=
{
...
ResetStyles
,
menu
:
()
=>
({
maxHeight
:
'500px'
,
overflow
:
'scroll'
,
}),
menuList
:
()
=>
({
overflowY
:
'auto'
,
position
:
'relative'
,
}
as
React
.
CSSProperties
),
};
const
value
=
groupOptions
.
map
(
group
=>
{
return
group
.
options
.
find
(
option
=>
option
.
value
===
defaultValue
);
});
return
(
<
Select
classNamePrefix=
"gf-form-select-box"
className=
"width-20 gf-form-input--form-dropdown"
defaultValue=
{
value
}
isSearchable=
{
true
}
options=
{
groupOptions
}
placeholder=
"Choose"
onChange=
{
onSelected
}
components=
{
{
Group
:
UnitGroup
,
Option
:
UnitOption
,
}
}
styles=
{
styles
}
/>
);
}
}
public/app/core/utils/kbn.ts
View file @
57227734
...
@@ -405,7 +405,8 @@ kbn.valueFormats.percentunit = (size, decimals) => {
...
@@ -405,7 +405,8 @@ kbn.valueFormats.percentunit = (size, decimals) => {
};
};
/* Formats the value to hex. Uses float if specified decimals are not 0.
/* Formats the value to hex. Uses float if specified decimals are not 0.
* There are two options, one with 0x, and one without */
* There are two submenu
* , one with 0x, and one without */
kbn.valueFormats.hex = (value, decimals) => {
kbn.valueFormats.hex = (value, decimals) => {
if (value == null) {
if (value == null) {
...
...
public/app/features/dashboard/dashgrid/DataPanel.tsx
View file @
57227734
...
@@ -134,6 +134,7 @@ export class DataPanel extends Component<Props, State> {
...
@@ -134,6 +134,7 @@ export class DataPanel extends Component<Props, State> {
render
()
{
render
()
{
const
{
queries
}
=
this
.
props
;
const
{
queries
}
=
this
.
props
;
const
{
response
,
loading
,
isFirstLoad
}
=
this
.
state
;
const
{
response
,
loading
,
isFirstLoad
}
=
this
.
state
;
const
timeSeries
=
response
.
data
;
const
timeSeries
=
response
.
data
;
if
(
isFirstLoad
&&
loading
===
LoadingState
.
Loading
)
{
if
(
isFirstLoad
&&
loading
===
LoadingState
.
Loading
)
{
...
...
public/app/features/dashboard/dashgrid/PanelChrome.tsx
View file @
57227734
...
@@ -70,7 +70,6 @@ export class PanelChrome extends PureComponent<Props, State> {
...
@@ -70,7 +70,6 @@ export class PanelChrome extends PureComponent<Props, State> {
};
};
onRender
=
()
=>
{
onRender
=
()
=>
{
console
.
log
(
'onRender'
);
this
.
setState
({
this
.
setState
({
renderCounter
:
this
.
state
.
renderCounter
+
1
,
renderCounter
:
this
.
state
.
renderCounter
+
1
,
});
});
...
@@ -87,7 +86,6 @@ export class PanelChrome extends PureComponent<Props, State> {
...
@@ -87,7 +86,6 @@ export class PanelChrome extends PureComponent<Props, State> {
const
{
datasource
,
targets
}
=
panel
;
const
{
datasource
,
targets
}
=
panel
;
const
PanelComponent
=
this
.
props
.
component
;
const
PanelComponent
=
this
.
props
.
component
;
console
.
log
(
'panelChrome render'
);
return
(
return
(
<
AutoSizer
>
<
AutoSizer
>
{
({
width
,
height
})
=>
{
{
({
width
,
height
})
=>
{
...
...
public/app/plugins/datasource/elasticsearch/config_ctrl.ts
View file @
57227734
...
@@ -28,9 +28,11 @@ export class ElasticConfigCtrl {
...
@@ -28,9 +28,11 @@ export class ElasticConfigCtrl {
];
];
indexPatternTypeChanged
()
{
indexPatternTypeChanged
()
{
if
(
!
this
.
current
.
database
||
if
(
!
this
.
current
.
database
||
this
.
current
.
database
.
length
===
0
||
this
.
current
.
database
.
length
===
0
||
this
.
current
.
database
.
startsWith
(
'[logstash-]'
))
{
this
.
current
.
database
.
startsWith
(
'[logstash-]'
)
)
{
const
def
=
_
.
find
(
this
.
indexPatternTypes
,
{
const
def
=
_
.
find
(
this
.
indexPatternTypes
,
{
value
:
this
.
current
.
jsonData
.
interval
,
value
:
this
.
current
.
jsonData
.
interval
,
});
});
...
...
public/app/plugins/panel/gauge/module.tsx
View file @
57227734
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
{
Label
}
from
'app/core/components/Label/Label'
;
import
SimplePicker
from
'app/core/components/Picker/SimplePicker'
;
import
UnitPicker
from
'app/core/components/Picker/Unit/UnitPicker'
;
import
Gauge
from
'app/viz/Gauge'
;
import
Gauge
from
'app/viz/Gauge'
;
import
{
NullValueMode
,
PanelOptionsProps
,
PanelProps
}
from
'app/types'
;
import
{
NullValueMode
,
PanelOptionsProps
,
PanelProps
}
from
'app/types'
;
import
{
getTimeSeriesVMs
}
from
'app/viz/state/timeSeries'
;
import
{
getTimeSeriesVMs
}
from
'app/viz/state/timeSeries'
;
import
{
Label
}
from
'../../../core/components/Label/Label'
;
import
SimplePicker
from
'../../../core/components/Picker/SimplePicker'
;
export
interface
Options
{
export
interface
Options
{
stat
:
{
value
:
string
;
text
:
string
};
stat
:
{
value
:
string
;
text
:
string
};
unit
:
{
label
:
string
;
value
:
string
};
}
}
interface
Props
extends
PanelProps
<
Options
>
{}
interface
Props
extends
PanelProps
<
Options
>
{}
...
@@ -25,7 +27,7 @@ const statOptions = [
...
@@ -25,7 +27,7 @@ const statOptions = [
{
value
:
'last_time'
,
text
:
'Time of last point'
},
{
value
:
'last_time'
,
text
:
'Time of last point'
},
];
];
export
class
GaugePanel
extends
PureComponent
<
Props
>
{
class
GaugePanel
extends
PureComponent
<
Props
>
{
render
()
{
render
()
{
const
{
timeSeries
,
width
,
height
}
=
this
.
props
;
const
{
timeSeries
,
width
,
height
}
=
this
.
props
;
...
@@ -39,13 +41,15 @@ export class GaugePanel extends PureComponent<Props> {
...
@@ -39,13 +41,15 @@ export class GaugePanel extends PureComponent<Props> {
}
}
class
GaugeOptions
extends
PureComponent
<
PanelOptionsProps
<
Options
>>
{
class
GaugeOptions
extends
PureComponent
<
PanelOptionsProps
<
Options
>>
{
onUnitChange
=
value
=>
{
this
.
props
.
onChange
({
...
this
.
props
.
options
,
unit
:
value
});
};
onStatChange
=
value
=>
{
onStatChange
=
value
=>
{
this
.
props
.
onChange
({
...
this
.
props
.
options
,
stat
:
value
});
this
.
props
.
onChange
({
...
this
.
props
.
options
,
stat
:
value
});
};
};
render
()
{
render
()
{
const
{
stat
}
=
this
.
props
.
options
;
return
(
return
(
<
div
>
<
div
>
<
div
className=
"section gf-form-group"
>
<
div
className=
"section gf-form-group"
>
...
@@ -53,15 +57,19 @@ class GaugeOptions extends PureComponent<PanelOptionsProps<Options>> {
...
@@ -53,15 +57,19 @@ class GaugeOptions extends PureComponent<PanelOptionsProps<Options>> {
<
div
className=
"gf-form-inline"
>
<
div
className=
"gf-form-inline"
>
<
Label
width=
{
5
}
>
Stat
</
Label
>
<
Label
width=
{
5
}
>
Stat
</
Label
>
<
SimplePicker
<
SimplePicker
defaultValue=
{
statOptions
.
find
(
option
=>
option
.
value
===
stat
.
value
)
}
defaultValue=
{
statOptions
.
find
(
option
=>
option
.
value
===
this
.
props
.
options
.
stat
.
value
)
}
width=
{
11
}
width=
{
11
}
options=
{
statOptions
}
options=
{
statOptions
}
getOptionLabel=
{
i
=>
i
.
text
}
getOptionLabel=
{
i
=>
i
.
text
}
getOptionValue=
{
i
=>
i
.
value
}
getOptionValue=
{
i
=>
i
.
value
}
onSelected=
{
this
.
onStatChange
}
onSelected=
{
this
.
onStatChange
}
value=
{
stat
}
value=
{
this
.
props
.
options
.
stat
}
/>
/>
</
div
>
</
div
>
<
div
className=
"gf-form-inline"
>
<
Label
width=
{
5
}
>
Unit
</
Label
>
<
UnitPicker
defaultValue=
{
this
.
props
.
options
.
unit
.
value
}
onSelected=
{
value
=>
this
.
onUnitChange
(
value
)
}
/>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
);
);
...
...
public/app/viz/Gauge.tsx
View file @
57227734
...
@@ -2,6 +2,7 @@ import React, { PureComponent } from 'react';
...
@@ -2,6 +2,7 @@ import React, { PureComponent } from 'react';
import
$
from
'jquery'
;
import
$
from
'jquery'
;
import
{
TimeSeriesVMs
}
from
'app/types'
;
import
{
TimeSeriesVMs
}
from
'app/types'
;
import
config
from
'../core/config'
;
import
config
from
'../core/config'
;
import
kbn
from
'../core/utils/kbn'
;
interface
Props
{
interface
Props
{
timeSeries
:
TimeSeriesVMs
;
timeSeries
:
TimeSeriesVMs
;
...
@@ -10,6 +11,7 @@ interface Props {
...
@@ -10,6 +11,7 @@ interface Props {
showThresholdMarkers
?:
boolean
;
showThresholdMarkers
?:
boolean
;
thresholds
?:
number
[];
thresholds
?:
number
[];
showThresholdLables
?:
boolean
;
showThresholdLables
?:
boolean
;
unit
:
{
label
:
string
;
value
:
string
};
width
:
number
;
width
:
number
;
height
:
number
;
height
:
number
;
stat
?:
{
value
:
string
;
text
:
string
};
stat
?:
{
value
:
string
;
text
:
string
};
...
@@ -37,6 +39,13 @@ export class Gauge extends PureComponent<Props> {
...
@@ -37,6 +39,13 @@ export class Gauge extends PureComponent<Props> {
this
.
draw
();
this
.
draw
();
}
}
formatValue
(
value
)
{
const
{
unit
}
=
this
.
props
;
const
formatFunc
=
kbn
.
valueFormats
[
unit
.
value
];
return
formatFunc
(
value
);
}
draw
()
{
draw
()
{
const
{
const
{
timeSeries
,
timeSeries
,
...
@@ -96,7 +105,7 @@ export class Gauge extends PureComponent<Props> {
...
@@ -96,7 +105,7 @@ export class Gauge extends PureComponent<Props> {
value
:
{
value
:
{
color
:
fontColor
,
color
:
fontColor
,
formatter
:
()
=>
{
formatter
:
()
=>
{
return
Math
.
round
(
timeSeries
[
0
].
stats
[
stat
.
value
]);
return
this
.
formatValue
(
timeSeries
[
0
].
stats
[
stat
.
value
]);
},
},
font
:
{
font
:
{
size
:
fontSize
,
size
:
fontSize
,
...
...
public/sass/_grafana.scss
View file @
57227734
...
@@ -102,6 +102,7 @@
...
@@ -102,6 +102,7 @@
@import
'components/delete_button'
;
@import
'components/delete_button'
;
@import
'components/add_data_source.scss'
;
@import
'components/add_data_source.scss'
;
@import
'components/page_loader'
;
@import
'components/page_loader'
;
@import
'components/unit-picker'
;
// PAGES
// PAGES
@import
'pages/login'
;
@import
'pages/login'
;
...
...
public/sass/components/_unit-picker.scss
0 → 100644
View file @
57227734
.unit-picker-option
{
position
:
relative
;
width
:
100%
;
display
:
block
;
border-radius
:
0
;
white-space
:
normal
;
i
.fa-check
{
padding-left
:
2px
;
}
}
.unit-picker-group
{
margin-bottom
:
5px
;
}
.unit-picker-group-item
{
display
:
flex
;
align-items
:
center
;
justify-content
:
space-between
;
padding
:
10px
;
font-size
:
14px
;
border-bottom
:
1px
solid
#555
;
}
yarn.lock
View file @
57227734
...
@@ -397,15 +397,7 @@
...
@@ -397,15 +397,7 @@
dependencies:
dependencies:
"@types/react" "*"
"@types/react" "*"
"@types/react@*":
"@types/react@*", "@types/react@16.7.6", "@types/react@^16.1.0", "@types/react@^16.7.6":
version "16.4.16"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.4.16.tgz#99f91b1200ae8c2062030402006d3b3c3a177043"
integrity sha512-lxyoipLWweAnLnSsV4Ho2NAZTKKmxeYgkTQ6PaDiPDU9JJBUY2zJVVGiK1smzYv8+ZgbqEmcm5xM74GCpunSEA==
dependencies:
"@types/prop-types" "*"
csstype "^2.2.0"
"@types/react@^16.1.0", "@types/react@^16.7.6":
version "16.7.6"
version "16.7.6"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.7.6.tgz#80e4bab0d0731ad3ae51f320c4b08bdca5f03040"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.7.6.tgz#80e4bab0d0731ad3ae51f320c4b08bdca5f03040"
integrity sha512-QBUfzftr/8eg/q3ZRgf/GaDP6rTYc7ZNem+g4oZM38C9vXyV8AWRWaTQuW5yCoZTsfHrN7b3DeEiUnqH9SrnpA==
integrity sha512-QBUfzftr/8eg/q3ZRgf/GaDP6rTYc7ZNem+g4oZM38C9vXyV8AWRWaTQuW5yCoZTsfHrN7b3DeEiUnqH9SrnpA==
...
...
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