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
382ebd63
Commit
382ebd63
authored
May 28, 2019
by
Ryan McKinley
Committed by
Torkel Ödegaard
May 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Frontend/SeriesData: Fix for convert SeriesData to Table format (#17314)
parent
4b0ad174
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
9 deletions
+28
-9
packages/grafana-ui/src/utils/processSeriesData.test.ts
+22
-1
packages/grafana-ui/src/utils/processSeriesData.ts
+6
-8
No files found.
packages/grafana-ui/src/utils/processSeriesData.test.ts
View file @
382ebd63
...
...
@@ -6,7 +6,7 @@ import {
guessFieldTypes
,
guessFieldTypeFromValue
,
}
from
'./processSeriesData'
;
import
{
FieldType
,
TimeSeries
}
from
'../types/data'
;
import
{
FieldType
,
TimeSeries
,
SeriesData
,
TableData
}
from
'../types/data'
;
import
{
dateTime
}
from
'./moment_wrapper'
;
describe
(
'toSeriesData'
,
()
=>
{
...
...
@@ -99,4 +99,25 @@ describe('SerisData backwards compatibility', () => {
expect
(
isTableData
(
roundtrip
)).
toBeTruthy
();
expect
(
roundtrip
).
toMatchObject
(
table
);
});
it
(
'converts SeriesData to TableData to series and back again'
,
()
=>
{
const
series
:
SeriesData
=
{
refId
:
'Z'
,
meta
:
{
somethign
:
8
,
},
fields
:
[
{
name
:
'T'
,
type
:
FieldType
.
time
},
// first
{
name
:
'N'
,
type
:
FieldType
.
number
,
filterable
:
true
},
{
name
:
'S'
,
type
:
FieldType
.
string
,
filterable
:
true
},
],
rows
:
[[
1
,
100
,
'1'
],
[
2
,
200
,
'2'
],
[
3
,
300
,
'3'
]],
};
const
table
=
toLegacyResponseData
(
series
)
as
TableData
;
expect
(
table
.
meta
).
toBe
(
series
.
meta
);
expect
(
table
.
refId
).
toBe
(
series
.
refId
);
const
names
=
table
.
columns
.
map
(
c
=>
c
.
text
);
expect
(
names
).
toEqual
([
'T'
,
'N'
,
'S'
]);
});
});
packages/grafana-ui/src/utils/processSeriesData.ts
View file @
382ebd63
...
...
@@ -4,7 +4,7 @@ import isString from 'lodash/isString';
import
isBoolean
from
'lodash/isBoolean'
;
// Types
import
{
SeriesData
,
Field
,
TimeSeries
,
FieldType
,
TableData
}
from
'../types/index'
;
import
{
SeriesData
,
Field
,
TimeSeries
,
FieldType
,
TableData
,
Column
}
from
'../types/index'
;
import
{
isDateTime
}
from
'./moment_wrapper'
;
function
convertTableToSeriesData
(
table
:
TableData
):
SeriesData
{
...
...
@@ -171,14 +171,12 @@ export const toLegacyResponseData = (series: SeriesData): TimeSeries | TableData
return
{
columns
:
fields
.
map
(
f
=>
{
return
{
text
:
f
.
name
,
filterable
:
f
.
filterable
,
unit
:
f
.
unit
,
refId
:
series
.
refId
,
meta
:
series
.
meta
,
};
const
{
name
,
...
column
}
=
f
;
(
column
as
Column
).
text
=
name
;
return
column
as
Column
;
}),
refId
:
series
.
refId
,
meta
:
series
.
meta
,
rows
,
};
};
...
...
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