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
5ffd5769
Commit
5ffd5769
authored
May 03, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(table): added support for column units overriding style units for table
parent
6dc24ab2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
public/app/plugins/panel/table/renderer.ts
+3
-3
public/app/plugins/panel/table/specs/renderer_specs.ts
+13
-1
No files found.
public/app/plugins/panel/table/renderer.ts
View file @
5ffd5769
...
...
@@ -36,7 +36,7 @@ export class TableRenderer {
return
v
;
}
createColumnFormater
(
style
)
{
createColumnFormater
(
style
,
column
)
{
if
(
!
style
)
{
return
this
.
defaultCellFormater
;
}
...
...
@@ -53,7 +53,7 @@ export class TableRenderer {
}
if
(
style
.
type
===
'number'
)
{
let
valueFormater
=
kbn
.
valueFormats
[
style
.
unit
];
let
valueFormater
=
kbn
.
valueFormats
[
column
.
unit
||
style
.
unit
];
return
v
=>
{
if
(
v
===
null
||
v
===
void
0
)
{
...
...
@@ -85,7 +85,7 @@ export class TableRenderer {
let
column
=
this
.
table
.
columns
[
colIndex
];
var
regex
=
kbn
.
stringToJsRegex
(
style
.
pattern
);
if
(
column
.
text
.
match
(
regex
))
{
this
.
formaters
[
colIndex
]
=
this
.
createColumnFormater
(
style
);
this
.
formaters
[
colIndex
]
=
this
.
createColumnFormater
(
style
,
column
);
return
this
.
formaters
[
colIndex
](
value
);
}
}
...
...
public/app/plugins/panel/table/specs/renderer_specs.ts
View file @
5ffd5769
...
...
@@ -11,7 +11,8 @@ describe('when rendering table', () => {
{
text
:
'Value'
},
{
text
:
'Colored'
},
{
text
:
'Undefined'
},
{
text
:
'String'
}
{
text
:
'String'
},
{
text
:
'United'
,
unit
:
'bps'
},
];
var
panel
=
{
...
...
@@ -40,6 +41,12 @@ describe('when rendering table', () => {
{
pattern
:
'String'
,
type
:
'string'
,
},
{
pattern
:
'United'
,
type
:
'number'
,
unit
:
'ms'
,
decimals
:
2
,
}
]
};
...
...
@@ -51,6 +58,11 @@ describe('when rendering table', () => {
expect
(
html
).
to
.
be
(
'<td>2014-01-01T06:06:06+00:00</td>'
);
});
it
(
'number column with unit specified should ignore style unit'
,
()
=>
{
var
html
=
renderer
.
renderCell
(
5
,
1230
);
expect
(
html
).
to
.
be
(
'<td>1.23 kbps</td>'
);
});
it
(
'number column should be formated'
,
()
=>
{
var
html
=
renderer
.
renderCell
(
1
,
1230
);
expect
(
html
).
to
.
be
(
'<td>1.230 s</td>'
);
...
...
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