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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
public/app/plugins/panel/table/renderer.ts
+3
-3
public/app/plugins/panel/table/specs/renderer_specs.ts
+15
-3
No files found.
public/app/plugins/panel/table/renderer.ts
View file @
5ffd5769
...
@@ -36,7 +36,7 @@ export class TableRenderer {
...
@@ -36,7 +36,7 @@ export class TableRenderer {
return
v
;
return
v
;
}
}
createColumnFormater
(
style
)
{
createColumnFormater
(
style
,
column
)
{
if
(
!
style
)
{
if
(
!
style
)
{
return
this
.
defaultCellFormater
;
return
this
.
defaultCellFormater
;
}
}
...
@@ -53,7 +53,7 @@ export class TableRenderer {
...
@@ -53,7 +53,7 @@ export class TableRenderer {
}
}
if
(
style
.
type
===
'number'
)
{
if
(
style
.
type
===
'number'
)
{
let
valueFormater
=
kbn
.
valueFormats
[
style
.
unit
];
let
valueFormater
=
kbn
.
valueFormats
[
column
.
unit
||
style
.
unit
];
return
v
=>
{
return
v
=>
{
if
(
v
===
null
||
v
===
void
0
)
{
if
(
v
===
null
||
v
===
void
0
)
{
...
@@ -85,7 +85,7 @@ export class TableRenderer {
...
@@ -85,7 +85,7 @@ export class TableRenderer {
let
column
=
this
.
table
.
columns
[
colIndex
];
let
column
=
this
.
table
.
columns
[
colIndex
];
var
regex
=
kbn
.
stringToJsRegex
(
style
.
pattern
);
var
regex
=
kbn
.
stringToJsRegex
(
style
.
pattern
);
if
(
column
.
text
.
match
(
regex
))
{
if
(
column
.
text
.
match
(
regex
))
{
this
.
formaters
[
colIndex
]
=
this
.
createColumnFormater
(
style
);
this
.
formaters
[
colIndex
]
=
this
.
createColumnFormater
(
style
,
column
);
return
this
.
formaters
[
colIndex
](
value
);
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', () => {
...
@@ -11,7 +11,8 @@ describe('when rendering table', () => {
{
text
:
'Value'
},
{
text
:
'Value'
},
{
text
:
'Colored'
},
{
text
:
'Colored'
},
{
text
:
'Undefined'
},
{
text
:
'Undefined'
},
{
text
:
'String'
}
{
text
:
'String'
},
{
text
:
'United'
,
unit
:
'bps'
},
];
];
var
panel
=
{
var
panel
=
{
...
@@ -40,6 +41,12 @@ describe('when rendering table', () => {
...
@@ -40,6 +41,12 @@ describe('when rendering table', () => {
{
{
pattern
:
'String'
,
pattern
:
'String'
,
type
:
'string'
,
type
:
'string'
,
},
{
pattern
:
'United'
,
type
:
'number'
,
unit
:
'ms'
,
decimals
:
2
,
}
}
]
]
};
};
...
@@ -51,6 +58,11 @@ describe('when rendering table', () => {
...
@@ -51,6 +58,11 @@ describe('when rendering table', () => {
expect
(
html
).
to
.
be
(
'<td>2014-01-01T06:06:06+00:00</td>'
);
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'
,
()
=>
{
it
(
'number column should be formated'
,
()
=>
{
var
html
=
renderer
.
renderCell
(
1
,
1230
);
var
html
=
renderer
.
renderCell
(
1
,
1230
);
expect
(
html
).
to
.
be
(
'<td>1.230 s</td>'
);
expect
(
html
).
to
.
be
(
'<td>1.230 s</td>'
);
...
@@ -62,8 +74,8 @@ describe('when rendering table', () => {
...
@@ -62,8 +74,8 @@ describe('when rendering table', () => {
});
});
it
(
'colored cell should have style'
,
()
=>
{
it
(
'colored cell should have style'
,
()
=>
{
var
html
=
renderer
.
renderCell
(
2
,
40
);
var
html
=
renderer
.
renderCell
(
2
,
40
);
expect
(
html
).
to
.
be
(
'<td style="color:green">40.0</td>'
);
expect
(
html
).
to
.
be
(
'<td style="color:green">40.0</td>'
);
});
});
it
(
'colored cell should have style'
,
()
=>
{
it
(
'colored cell should have style'
,
()
=>
{
...
...
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