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
7f9c8a19
Commit
7f9c8a19
authored
Nov 12, 2015
by
utkarshcmu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added hours, days units and tests for all
parent
3c54d144
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
2 deletions
+54
-2
public/app/core/utils/kbn.js
+33
-2
public/test/core/utils/kbn_specs.js
+21
-0
No files found.
public/app/core/utils/kbn.js
View file @
7f9c8a19
...
...
@@ -432,7 +432,7 @@ function($, _) {
kbn
.
valueFormats
.
s
=
function
(
size
,
decimals
,
scaledDecimals
)
{
if
(
size
===
null
)
{
return
""
;
}
if
(
Math
.
abs
(
size
)
<
60
0
)
{
if
(
Math
.
abs
(
size
)
<
60
)
{
return
kbn
.
toFixed
(
size
,
decimals
)
+
" s"
;
}
// Less than 1 hour, devide in minutes
...
...
@@ -502,13 +502,44 @@ function($, _) {
return
kbn
.
toFixedScaled
(
size
/
1440
,
decimals
,
scaledDecimals
,
3
,
" day"
);
}
else
if
(
Math
.
abs
(
size
)
<
604800
)
{
return
kbn
.
toFixedScaled
(
size
/
8640
0
,
decimals
,
scaledDecimals
,
4
,
" week"
);
return
kbn
.
toFixedScaled
(
size
/
1008
0
,
decimals
,
scaledDecimals
,
4
,
" week"
);
}
else
{
return
kbn
.
toFixedScaled
(
size
/
5.25948e5
,
decimals
,
scaledDecimals
,
5
,
" year"
);
}
};
kbn
.
valueFormats
.
h
=
function
(
size
,
decimals
,
scaledDecimals
)
{
if
(
size
===
null
)
{
return
""
;
}
if
(
Math
.
abs
(
size
)
<
24
)
{
return
kbn
.
toFixed
(
size
,
decimals
)
+
" hour"
;
}
else
if
(
Math
.
abs
(
size
)
<
168
)
{
return
kbn
.
toFixedScaled
(
size
/
24
,
decimals
,
scaledDecimals
,
2
,
" day"
);
}
else
if
(
Math
.
abs
(
size
)
<
8760
)
{
return
kbn
.
toFixedScaled
(
size
/
168
,
decimals
,
scaledDecimals
,
3
,
" week"
);
}
else
{
return
kbn
.
toFixedScaled
(
size
/
8760
,
decimals
,
scaledDecimals
,
4
,
" year"
);
}
};
kbn
.
valueFormats
.
d
=
function
(
size
,
decimals
,
scaledDecimals
)
{
if
(
size
===
null
)
{
return
""
;
}
if
(
Math
.
abs
(
size
)
<
7
)
{
return
kbn
.
toFixed
(
size
,
decimals
)
+
" day"
;
}
else
if
(
Math
.
abs
(
size
)
<
365
)
{
return
kbn
.
toFixedScaled
(
size
/
7
,
decimals
,
scaledDecimals
,
2
,
" week"
);
}
else
{
return
kbn
.
toFixedScaled
(
size
/
365
,
decimals
,
scaledDecimals
,
3
,
" year"
);
}
};
///// FORMAT MENU /////
kbn
.
getUnitFormats
=
function
()
{
...
...
public/test/core/utils/kbn_specs.js
View file @
7f9c8a19
...
...
@@ -68,6 +68,27 @@ define([
describeValueFormat
(
'wps'
,
789000000
,
1000000
,
-
1
,
'789M wps'
);
describeValueFormat
(
'iops'
,
11000000000
,
1000000000
,
-
1
,
'11B iops'
);
describeValueFormat
(
's'
,
24
,
1
,
0
,
'24 s'
);
describeValueFormat
(
's'
,
246
,
1
,
0
,
'4.1 min'
);
describeValueFormat
(
's'
,
24567
,
100
,
0
,
'6.82 hour'
);
describeValueFormat
(
's'
,
24567890
,
10000
,
0
,
'40.62 week'
);
describeValueFormat
(
's'
,
24567890000
,
1000000
,
0
,
'778.53 year'
);
describeValueFormat
(
'm'
,
24
,
1
,
0
,
'24 min'
);
describeValueFormat
(
'm'
,
246
,
10
,
0
,
'4.1 hour'
);
describeValueFormat
(
'm'
,
6545
,
10
,
0
,
'4.55 day'
);
describeValueFormat
(
'm'
,
24567
,
100
,
0
,
'2.44 week'
);
describeValueFormat
(
'm'
,
24567892
,
10000
,
0
,
'46.7 year'
);
describeValueFormat
(
'h'
,
21
,
1
,
0
,
'21 hour'
);
describeValueFormat
(
'h'
,
145
,
1
,
0
,
'6.04 day'
);
describeValueFormat
(
'h'
,
1234
,
100
,
0
,
'7.3 week'
);
describeValueFormat
(
'h'
,
9458
,
1000
,
0
,
'1.08 year'
);
describeValueFormat
(
'd'
,
3
,
1
,
0
,
'3 day'
);
describeValueFormat
(
'd'
,
245
,
100
,
0
,
'35 week'
);
describeValueFormat
(
'd'
,
2456
,
10
,
0
,
'6.73 year'
);
describe
(
'kbn.toFixed and negative decimals'
,
function
()
{
it
(
'should treat as zero decimals'
,
function
()
{
var
str
=
kbn
.
toFixed
(
186.123
,
-
2
);
...
...
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