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
0ebd5e0c
Commit
0ebd5e0c
authored
Dec 15, 2018
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
table: fixes #14484. Renders epoch string if date column style
parent
217596b4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
public/app/plugins/panel/table/renderer.ts
+7
-0
public/app/plugins/panel/table/specs/renderer.test.ts
+15
-0
No files found.
public/app/plugins/panel/table/renderer.ts
View file @
0ebd5e0c
...
@@ -91,7 +91,14 @@ export class TableRenderer {
...
@@ -91,7 +91,14 @@ export class TableRenderer {
if
(
_
.
isArray
(
v
))
{
if
(
_
.
isArray
(
v
))
{
v
=
v
[
0
];
v
=
v
[
0
];
}
}
// if is an epoch (numeric string and len > 12)
if
(
_
.
isString
(
v
)
&&
!
isNaN
(
v
)
&&
v
.
length
>
12
)
{
v
=
parseInt
(
v
,
10
);
}
let
date
=
moment
(
v
);
let
date
=
moment
(
v
);
if
(
this
.
isUtc
)
{
if
(
this
.
isUtc
)
{
date
=
date
.
utc
();
date
=
date
.
utc
();
}
}
...
...
public/app/plugins/panel/table/specs/renderer.test.ts
View file @
0ebd5e0c
...
@@ -186,6 +186,21 @@ describe('when rendering table', () => {
...
@@ -186,6 +186,21 @@ describe('when rendering table', () => {
expect
(
html
).
toBe
(
'<td>2014-01-01T06:06:06Z</td>'
);
expect
(
html
).
toBe
(
'<td>2014-01-01T06:06:06Z</td>'
);
});
});
it
(
'time column with epoch as string should be formatted'
,
()
=>
{
const
html
=
renderer
.
renderCell
(
0
,
0
,
'1388556366666'
);
expect
(
html
).
toBe
(
'<td>2014-01-01T06:06:06Z</td>'
);
});
it
(
'time column with RFC2822 date as string should be formatted'
,
()
=>
{
const
html
=
renderer
.
renderCell
(
0
,
0
,
'Sat, 01 Dec 2018 01:00:00 GMT'
);
expect
(
html
).
toBe
(
'<td>2018-12-01T01:00:00Z</td>'
);
});
it
(
'time column with ISO date as string should be formatted'
,
()
=>
{
const
html
=
renderer
.
renderCell
(
0
,
0
,
'2018-12-01T01:00:00Z'
);
expect
(
html
).
toBe
(
'<td>2018-12-01T01:00:00Z</td>'
);
});
it
(
'undefined time column should be rendered as -'
,
()
=>
{
it
(
'undefined time column should be rendered as -'
,
()
=>
{
const
html
=
renderer
.
renderCell
(
0
,
0
,
undefined
);
const
html
=
renderer
.
renderCell
(
0
,
0
,
undefined
);
expect
(
html
).
toBe
(
'<td>-</td>'
);
expect
(
html
).
toBe
(
'<td>-</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