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
1dd65f7a
Unverified
Commit
1dd65f7a
authored
May 09, 2018
by
Aman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add options to colorize prefix and postfix in singlestat
parent
b2187b70
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
public/app/plugins/panel/singlestat/editor.html
+4
-0
public/app/plugins/panel/singlestat/module.ts
+12
-7
No files found.
public/app/plugins/panel/singlestat/editor.html
View file @
1dd65f7a
...
@@ -59,6 +59,10 @@
...
@@ -59,6 +59,10 @@
<gf-form-switch
class=
"gf-form"
label-class=
"width-4"
label=
"Value"
checked=
"ctrl.panel.colorValue"
on-change=
"ctrl.render()"
></gf-form-switch>
<gf-form-switch
class=
"gf-form"
label-class=
"width-4"
label=
"Value"
checked=
"ctrl.panel.colorValue"
on-change=
"ctrl.render()"
></gf-form-switch>
</div>
</div>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form-inline"
>
<gf-form-switch
class=
"gf-form"
label-class=
"width-6"
label=
"Prefix"
checked=
"ctrl.panel.colorPrefix"
on-change=
"ctrl.render()"
></gf-form-switch>
<gf-form-switch
class=
"gf-form"
label-class=
"width-6"
label=
"Postfix"
checked=
"ctrl.panel.colorPostfix"
on-change=
"ctrl.render()"
></gf-form-switch>
</div>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form max-width-21"
>
<div
class=
"gf-form max-width-21"
>
<label
class=
"gf-form-label width-8"
>
Thresholds
<label
class=
"gf-form-label width-8"
>
Thresholds
<tip>
Define two threshold values
<
br /
>
50,80 will produce: value
<
50 = Green, 50
<
= value
<
80 = Yellow, value
>
= 80 = Red
</tip>
<tip>
Define two threshold values
<
br /
>
50,80 will produce: value
<
50 = Green, 50
<
= value
<
80 = Yellow, value
>
= 80 = Red
</tip>
...
...
public/app/plugins/panel/singlestat/module.ts
View file @
1dd65f7a
...
@@ -405,10 +405,6 @@ class SingleStatCtrl extends MetricsPanelCtrl {
...
@@ -405,10 +405,6 @@ class SingleStatCtrl extends MetricsPanelCtrl {
elem
=
elem
.
find
(
'.singlestat-panel'
);
elem
=
elem
.
find
(
'.singlestat-panel'
);
function
applyColoringThresholds
(
value
,
valueString
)
{
function
applyColoringThresholds
(
value
,
valueString
)
{
if
(
!
panel
.
colorValue
)
{
return
valueString
;
}
var
color
=
getColorForValue
(
data
,
value
);
var
color
=
getColorForValue
(
data
,
value
);
if
(
color
)
{
if
(
color
)
{
return
'<span style="color:'
+
color
+
'">'
+
valueString
+
'</span>'
;
return
'<span style="color:'
+
color
+
'">'
+
valueString
+
'</span>'
;
...
@@ -426,15 +422,24 @@ class SingleStatCtrl extends MetricsPanelCtrl {
...
@@ -426,15 +422,24 @@ class SingleStatCtrl extends MetricsPanelCtrl {
var
body
=
'<div class="singlestat-panel-value-container">'
;
var
body
=
'<div class="singlestat-panel-value-container">'
;
if
(
panel
.
prefix
)
{
if
(
panel
.
prefix
)
{
var
prefix
=
applyColoringThresholds
(
data
.
value
,
panel
.
prefix
);
var
prefix
=
panel
.
prefix
;
if
(
panel
.
colorPrefix
)
{
prefix
=
applyColoringThresholds
(
data
.
value
,
panel
.
prefix
);
}
body
+=
getSpan
(
'singlestat-panel-prefix'
,
panel
.
prefixFontSize
,
prefix
);
body
+=
getSpan
(
'singlestat-panel-prefix'
,
panel
.
prefixFontSize
,
prefix
);
}
}
var
value
=
applyColoringThresholds
(
data
.
value
,
data
.
valueFormatted
);
var
value
=
data
.
valueFormatted
;
if
(
panel
.
colorValue
)
{
value
=
applyColoringThresholds
(
data
.
value
,
value
);
}
body
+=
getSpan
(
'singlestat-panel-value'
,
panel
.
valueFontSize
,
value
);
body
+=
getSpan
(
'singlestat-panel-value'
,
panel
.
valueFontSize
,
value
);
if
(
panel
.
postfix
)
{
if
(
panel
.
postfix
)
{
var
postfix
=
applyColoringThresholds
(
data
.
value
,
panel
.
postfix
);
var
postfix
=
panel
.
postfix
;
if
(
panel
.
colorPostfix
)
{
postfix
=
applyColoringThresholds
(
data
.
value
,
panel
.
postfix
);
}
body
+=
getSpan
(
'singlestat-panel-postfix'
,
panel
.
postfixFontSize
,
postfix
);
body
+=
getSpan
(
'singlestat-panel-postfix'
,
panel
.
postfixFontSize
,
postfix
);
}
}
...
...
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