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
a9cc8a89
Commit
a9cc8a89
authored
Mar 20, 2019
by
ryan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update table data model
parent
30f0c350
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
8 deletions
+25
-8
packages/grafana-ui/src/types/data.ts
+18
-3
packages/grafana-ui/src/utils/processTableData.ts
+3
-2
public/app/plugins/datasource/influxdb/influx_series.ts
+2
-1
public/app/plugins/datasource/prometheus/result_transformer.ts
+2
-2
No files found.
packages/grafana-ui/src/types/data.ts
View file @
a9cc8a89
...
@@ -50,14 +50,29 @@ export enum NullValueMode {
...
@@ -50,14 +50,29 @@ export enum NullValueMode {
/** View model projection of many time series */
/** View model projection of many time series */
export
type
TimeSeriesVMs
=
TimeSeriesVM
[];
export
type
TimeSeriesVMs
=
TimeSeriesVM
[];
export
enum
ColumnType
{
time
=
'time'
,
// or date
number
=
'number'
,
string
=
'string'
,
boolean
=
'boolean'
,
other
=
'other'
,
// Object, Array, etc
}
export
interface
Column
{
export
interface
Column
{
text
:
string
;
// The column name
text
:
string
;
// The column name
type
?:
'time'
|
'number'
|
'string'
|
'object'
;
// not used anywhere? can we remove?
type
?:
ColumnType
;
filterable
?:
boolean
;
// currently only set by elasticsearch, and used in the table panel
filterable
?:
boolean
;
unit
?:
string
;
unit
?:
string
;
dateFormat
?:
string
;
// Source data format
}
export
interface
Tags
{
[
key
:
string
]:
string
;
}
}
export
interface
TableData
{
export
interface
TableData
{
name
?:
string
;
columns
:
Column
[];
columns
:
Column
[];
rows
:
any
[];
rows
:
any
[][];
tags
?:
Tags
;
}
}
packages/grafana-ui/src/utils/processTableData.ts
View file @
a9cc8a89
...
@@ -3,7 +3,7 @@ import isNumber from 'lodash/isNumber';
...
@@ -3,7 +3,7 @@ import isNumber from 'lodash/isNumber';
import
Papa
,
{
ParseError
,
ParseMeta
}
from
'papaparse'
;
import
Papa
,
{
ParseError
,
ParseMeta
}
from
'papaparse'
;
// Types
// Types
import
{
TableData
,
Column
,
TimeSeries
}
from
'../types'
;
import
{
TableData
,
Column
,
TimeSeries
,
ColumnType
}
from
'../types'
;
// Subset of all parse options
// Subset of all parse options
export
interface
TableParseOptions
{
export
interface
TableParseOptions
{
...
@@ -131,6 +131,7 @@ export function parseCSV(text: string, options?: TableParseOptions, details?: Ta
...
@@ -131,6 +131,7 @@ export function parseCSV(text: string, options?: TableParseOptions, details?: Ta
function
convertTimeSeriesToTableData
(
timeSeries
:
TimeSeries
):
TableData
{
function
convertTimeSeriesToTableData
(
timeSeries
:
TimeSeries
):
TableData
{
return
{
return
{
name
:
timeSeries
.
target
,
columns
:
[
columns
:
[
{
{
text
:
timeSeries
.
target
||
'Value'
,
text
:
timeSeries
.
target
||
'Value'
,
...
@@ -138,7 +139,7 @@ function convertTimeSeriesToTableData(timeSeries: TimeSeries): TableData {
...
@@ -138,7 +139,7 @@ function convertTimeSeriesToTableData(timeSeries: TimeSeries): TableData {
},
},
{
{
text
:
'Time'
,
text
:
'Time'
,
type
:
'time'
,
type
:
ColumnType
.
time
,
unit
:
'dateTimeAsIso'
,
unit
:
'dateTimeAsIso'
,
},
},
],
],
...
...
public/app/plugins/datasource/influxdb/influx_series.ts
View file @
a9cc8a89
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
TableModel
from
'app/core/table_model'
;
import
TableModel
from
'app/core/table_model'
;
import
{
ColumnType
}
from
'@grafana/ui'
;
export
default
class
InfluxSeries
{
export
default
class
InfluxSeries
{
series
:
any
;
series
:
any
;
...
@@ -156,7 +157,7 @@ export default class InfluxSeries {
...
@@ -156,7 +157,7 @@ export default class InfluxSeries {
// Check that the first column is indeed 'time'
// Check that the first column is indeed 'time'
if
(
series
.
columns
[
0
]
===
'time'
)
{
if
(
series
.
columns
[
0
]
===
'time'
)
{
// Push this now before the tags and with the right type
// Push this now before the tags and with the right type
table
.
columns
.
push
({
text
:
'Time'
,
type
:
'time'
});
table
.
columns
.
push
({
text
:
'Time'
,
type
:
ColumnType
.
time
});
j
++
;
j
++
;
}
}
_
.
each
(
_
.
keys
(
series
.
tags
),
key
=>
{
_
.
each
(
_
.
keys
(
series
.
tags
),
key
=>
{
...
...
public/app/plugins/datasource/prometheus/result_transformer.ts
View file @
a9cc8a89
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
TableModel
from
'app/core/table_model'
;
import
TableModel
from
'app/core/table_model'
;
import
{
TimeSeries
}
from
'@grafana/ui'
;
import
{
TimeSeries
,
ColumnType
}
from
'@grafana/ui'
;
export
class
ResultTransformer
{
export
class
ResultTransformer
{
constructor
(
private
templateSrv
)
{}
constructor
(
private
templateSrv
)
{}
...
@@ -98,7 +98,7 @@ export class ResultTransformer {
...
@@ -98,7 +98,7 @@ export class ResultTransformer {
// Sort metric labels, create columns for them and record their index
// Sort metric labels, create columns for them and record their index
const
sortedLabels
=
_
.
keys
(
metricLabels
).
sort
();
const
sortedLabels
=
_
.
keys
(
metricLabels
).
sort
();
table
.
columns
.
push
({
text
:
'Time'
,
type
:
'time'
});
table
.
columns
.
push
({
text
:
'Time'
,
type
:
ColumnType
.
time
});
_
.
each
(
sortedLabels
,
(
label
,
labelIndex
)
=>
{
_
.
each
(
sortedLabels
,
(
label
,
labelIndex
)
=>
{
metricLabels
[
label
]
=
labelIndex
+
1
;
metricLabels
[
label
]
=
labelIndex
+
1
;
table
.
columns
.
push
({
text
:
label
,
filterable
:
true
});
table
.
columns
.
push
({
text
:
label
,
filterable
:
true
});
...
...
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