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
de5a39f3
Commit
de5a39f3
authored
May 02, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Revert "Merge branch 'utkarshcmu-rangeMaps'""
This reverts commit
58b91bef
.
parent
58b91bef
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
136 additions
and
44 deletions
+136
-44
public/app/plugins/panel/singlestat/editor.html
+0
-32
public/app/plugins/panel/singlestat/mappings.html
+58
-0
public/app/plugins/panel/singlestat/module.ts
+53
-12
public/app/plugins/panel/singlestat/specs/singlestat-specs.ts
+25
-0
No files found.
public/app/plugins/panel/singlestat/editor.html
View file @
de5a39f3
...
@@ -204,35 +204,3 @@
...
@@ -204,35 +204,3 @@
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"editor-row"
>
<div
class=
"section"
style=
"margin-bottom: 20px"
>
<div
class=
"tight-form last"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
>
<strong>
Value to text mapping
</strong>
</li>
<li
class=
"tight-form-item"
ng-repeat-start=
"map in ctrl.panel.valueMaps"
>
<i
class=
"fa fa-remove pointer"
ng-click=
"ctrl.removeValueMap(map)"
></i>
</li>
<li>
<input
type=
"text"
ng-model=
"map.value"
placeholder=
"value"
class=
"input-mini tight-form-input"
ng-blur=
"ctrl.render()"
>
</li>
<li
class=
"tight-form-item"
>
<i
class=
"fa fa-arrow-right"
></i>
</li>
<li
ng-repeat-end
>
<input
type=
"text"
placeholder=
"text"
ng-model=
"map.text"
class=
"input-mini tight-form-input"
ng-blur=
"ctrl.render()"
>
</li>
<li>
<a
class=
"pointer tight-form-item last"
ng-click=
"ctrl.addValueMap();"
>
<i
class=
"fa fa-plus"
></i>
</a>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
</div>
</div>
public/app/plugins/panel/singlestat/mappings.html
0 → 100644
View file @
de5a39f3
<div
class=
"editor-row"
>
<div
class=
"gf-form-group"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label"
>
Type
</span>
<div
class=
"gf-form-select-wrapper"
>
<select
class=
"gf-form-input"
ng-model=
"ctrl.panel.mappingType"
ng-options=
"f.value as f.name for f in ctrl.panel.mappingTypes"
ng-change=
"ctrl.render()"
></select>
</div>
</div>
</div>
</div>
<div
class=
"editor-row"
ng-if=
"ctrl.panel.mappingType==1"
>
<h5
class=
"page-heading"
>
Set valuea mappings
</h5>
<div
class=
"gf-form-group"
>
<div
class=
"gf-form"
ng-repeat=
"map in ctrl.panel.valueMaps"
>
<span
class=
"gf-form-label"
>
<i
class=
"fa fa-remove pointer"
ng-click=
"ctrl.removeValueMap(map)"
></i>
</span>
<input
type=
"text"
ng-model=
"map.value"
placeholder=
"value"
class=
"gf-form-input max-width-6"
ng-blur=
"ctrl.render()"
>
<span
class=
"gf-form-label"
>
<i
class=
"fa fa-arrow-right"
></i>
</span>
<input
type=
"text"
placeholder=
"text"
ng-model=
"map.text"
class=
"gf-form-input max-width-8"
ng-blur=
"ctrl.render()"
>
</div>
<div
class=
"gf-form-button-row"
>
<button
class=
"btn btn-inverse"
ng-click=
"ctrl.addValueMap();"
>
<i
class=
"fa fa-plus"
></i>
Add a value mapping
</button>
</div>
</div>
</div>
<div
class=
"editor-row"
ng-if=
"ctrl.panel.mappingType==2"
>
<h5
class=
"page-heading"
>
Set range mappings
</h5>
<div
class=
"gf-form-group"
>
<div
class=
"gf-form"
ng-repeat=
"rangeMap in ctrl.panel.rangeMaps"
>
<span
class=
"gf-form-label"
>
<i
class=
"fa fa-remove pointer"
ng-click=
"ctrl.removeRangeMap(rangeMap)"
></i>
</span>
<span
class=
"gf-form-label"
>
From
</span>
<input
type=
"text"
ng-model=
"rangeMap.from"
class=
"gf-form-input max-width-6"
ng-blur=
"ctrl.render()"
>
<span
class=
"gf-form-label"
>
To
</span>
<input
type=
"text"
ng-model=
"rangeMap.to"
class=
"gf-form-input max-width-6"
ng-blur=
"ctrl.render()"
>
<span
class=
"gf-form-label"
>
Text
</span>
<input
type=
"text"
ng-model=
"rangeMap.text"
class=
"gf-form-input max-width-8"
ng-blur=
"ctrl.render()"
>
</div>
<div
class=
"gf-form-button-row"
>
<button
class=
"btn btn-inverse"
ng-click=
"ctrl.addRangeMap()"
>
<i
class=
"fa fa-plus"
></i>
Add a range mapping
</button>
</div>
</div>
</div>
public/app/plugins/panel/singlestat/module.ts
View file @
de5a39f3
...
@@ -35,6 +35,14 @@ class SingleStatCtrl extends MetricsPanelCtrl {
...
@@ -35,6 +35,14 @@ class SingleStatCtrl extends MetricsPanelCtrl {
valueMaps
:
[
valueMaps
:
[
{
value
:
'null'
,
op
:
'='
,
text
:
'N/A'
}
{
value
:
'null'
,
op
:
'='
,
text
:
'N/A'
}
],
],
mappingTypes
:
[
{
name
:
'value to text'
,
value
:
1
},
{
name
:
'range to text'
,
value
:
2
},
],
rangeMaps
:
[
{
from
:
'null'
,
to
:
'null'
,
text
:
'N/A'
}
],
mappingType
:
1
,
nullPointMode
:
'connected'
,
nullPointMode
:
'connected'
,
valueName
:
'avg'
,
valueName
:
'avg'
,
prefixFontSize
:
'50%'
,
prefixFontSize
:
'50%'
,
...
@@ -73,6 +81,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
...
@@ -73,6 +81,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
onInitEditMode
()
{
onInitEditMode
()
{
this
.
fontSizes
=
[
'20%'
,
'30%'
,
'50%'
,
'70%'
,
'80%'
,
'100%'
,
'110%'
,
'120%'
,
'150%'
,
'170%'
,
'200%'
];
this
.
fontSizes
=
[
'20%'
,
'30%'
,
'50%'
,
'70%'
,
'80%'
,
'100%'
,
'110%'
,
'120%'
,
'150%'
,
'170%'
,
'200%'
];
this
.
addEditorTab
(
'Options'
,
'public/app/plugins/panel/singlestat/editor.html'
,
2
);
this
.
addEditorTab
(
'Options'
,
'public/app/plugins/panel/singlestat/editor.html'
,
2
);
this
.
addEditorTab
(
'Value Mappings'
,
'public/app/plugins/panel/singlestat/mappings.html'
,
3
);
this
.
unitFormats
=
kbn
.
getUnitFormats
();
this
.
unitFormats
=
kbn
.
getUnitFormats
();
}
}
...
@@ -197,23 +206,45 @@ class SingleStatCtrl extends MetricsPanelCtrl {
...
@@ -197,23 +206,45 @@ class SingleStatCtrl extends MetricsPanelCtrl {
}
}
}
}
// check value to text mappings
// check value to text mappings if its enabled
for
(
var
i
=
0
;
i
<
this
.
panel
.
valueMaps
.
length
;
i
++
)
{
if
(
this
.
panel
.
mappingType
===
1
)
{
var
map
=
this
.
panel
.
valueMaps
[
i
];
for
(
var
i
=
0
;
i
<
this
.
panel
.
valueMaps
.
length
;
i
++
)
{
// special null case
var
map
=
this
.
panel
.
valueMaps
[
i
];
if
(
map
.
value
===
'null'
)
{
// special null case
if
(
data
.
value
===
null
||
data
.
value
===
void
0
)
{
if
(
map
.
value
===
'null'
)
{
if
(
data
.
value
===
null
||
data
.
value
===
void
0
)
{
data
.
valueFormated
=
map
.
text
;
return
;
}
continue
;
}
// value/number to text mapping
var
value
=
parseFloat
(
map
.
value
);
if
(
value
===
data
.
valueRounded
)
{
data
.
valueFormated
=
map
.
text
;
data
.
valueFormated
=
map
.
text
;
return
;
return
;
}
}
continue
;
}
}
}
else
if
(
this
.
panel
.
mappingType
===
2
)
{
for
(
var
i
=
0
;
i
<
this
.
panel
.
rangeMaps
.
length
;
i
++
)
{
var
map
=
this
.
panel
.
rangeMaps
[
i
];
// special null case
if
(
map
.
from
===
'null'
&&
map
.
to
===
'null'
)
{
if
(
data
.
value
===
null
||
data
.
value
===
void
0
)
{
data
.
valueFormated
=
map
.
text
;
return
;
}
continue
;
}
// value/number to text mapping
// value/number to range mapping
var
value
=
parseFloat
(
map
.
value
);
var
from
=
parseFloat
(
map
.
from
);
if
(
value
===
data
.
valueRounded
)
{
var
to
=
parseFloat
(
map
.
to
);
data
.
valueFormated
=
map
.
text
;
if
(
to
>=
data
.
valueRounded
&&
from
<=
data
.
valueRounded
)
{
return
;
data
.
valueFormated
=
map
.
text
;
return
;
}
}
}
}
}
...
@@ -232,6 +263,16 @@ class SingleStatCtrl extends MetricsPanelCtrl {
...
@@ -232,6 +263,16 @@ class SingleStatCtrl extends MetricsPanelCtrl {
this
.
panel
.
valueMaps
.
push
({
value
:
''
,
op
:
'='
,
text
:
''
});
this
.
panel
.
valueMaps
.
push
({
value
:
''
,
op
:
'='
,
text
:
''
});
}
}
removeRangeMap
(
rangeMap
)
{
var
index
=
_
.
indexOf
(
this
.
panel
.
rangeMaps
,
rangeMap
);
this
.
panel
.
rangeMaps
.
splice
(
index
,
1
);
this
.
render
();
};
addRangeMap
()
{
this
.
panel
.
rangeMaps
.
push
({
from
:
''
,
to
:
''
,
text
:
''
});
}
link
(
scope
,
elem
,
attrs
,
ctrl
)
{
link
(
scope
,
elem
,
attrs
,
ctrl
)
{
var
$location
=
this
.
$location
;
var
$location
=
this
.
$location
;
var
linkSrv
=
this
.
linkSrv
;
var
linkSrv
=
this
.
linkSrv
;
...
...
public/app/plugins/panel/singlestat/specs/singlestat-specs.ts
View file @
de5a39f3
...
@@ -84,4 +84,29 @@ describe('SingleStatCtrl', function() {
...
@@ -84,4 +84,29 @@ describe('SingleStatCtrl', function() {
expect
(
ctx
.
data
.
valueFormated
).
to
.
be
(
'OK'
);
expect
(
ctx
.
data
.
valueFormated
).
to
.
be
(
'OK'
);
});
});
});
});
singleStatScenario
(
'When range to text mapping is specifiedfor first range'
,
function
(
ctx
)
{
ctx
.
setup
(
function
()
{
ctx
.
datapoints
=
[[
41
,
50
]];
ctx
.
ctrl
.
panel
.
mappingType
=
2
;
ctx
.
ctrl
.
panel
.
rangeMaps
=
[{
from
:
'10'
,
to
:
'50'
,
text
:
'OK'
},{
from
:
'51'
,
to
:
'100'
,
text
:
'NOT OK'
}];
});
it
(
'Should replace value with text OK'
,
function
()
{
expect
(
ctx
.
data
.
valueFormated
).
to
.
be
(
'OK'
);
});
});
singleStatScenario
(
'When range to text mapping is specified for other ranges'
,
function
(
ctx
)
{
ctx
.
setup
(
function
()
{
ctx
.
datapoints
=
[[
65
,
75
]];
ctx
.
ctrl
.
panel
.
mappingType
=
2
;
ctx
.
ctrl
.
panel
.
rangeMaps
=
[{
from
:
'10'
,
to
:
'50'
,
text
:
'OK'
},{
from
:
'51'
,
to
:
'100'
,
text
:
'NOT OK'
}];
});
it
(
'Should replace value with text NOT OK'
,
function
()
{
expect
(
ctx
.
data
.
valueFormated
).
to
.
be
(
'NOT OK'
);
});
});
});
});
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