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
a8c985de
Commit
a8c985de
authored
Mar 12, 2019
by
ryan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move sort to table processing
parent
90510b5f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
25 deletions
+28
-25
packages/grafana-ui/src/components/Table/Table.tsx
+1
-1
packages/grafana-ui/src/utils/processTableData.ts
+26
-2
packages/grafana-ui/src/utils/processTimeSeries.ts
+1
-22
No files found.
packages/grafana-ui/src/components/Table/Table.tsx
View file @
a8c985de
...
@@ -11,7 +11,7 @@ import {
...
@@ -11,7 +11,7 @@ import {
}
from
'react-virtualized'
;
}
from
'react-virtualized'
;
import
{
Themeable
}
from
'../../types/theme'
;
import
{
Themeable
}
from
'../../types/theme'
;
import
{
sortTableData
}
from
'../../utils/processT
imeSeries
'
;
import
{
sortTableData
}
from
'../../utils/processT
ableData
'
;
import
{
TableData
,
InterpolateFunction
}
from
'@grafana/ui'
;
import
{
TableData
,
InterpolateFunction
}
from
'@grafana/ui'
;
import
{
import
{
...
...
packages/grafana-ui/src/utils/processTableData.ts
View file @
a8c985de
import
{
TableData
,
Column
}
from
'../types/index'
;
// Libraries
import
isNumber
from
'lodash/isNumber'
;
import
Papa
,
{
ParseError
,
ParseMeta
}
from
'papaparse'
;
import
Papa
,
{
ParseError
,
ParseMeta
}
from
'papaparse'
;
// Types
import
{
TableData
,
Column
}
from
'../types'
;
// Subset of all parse options
// Subset of all parse options
export
interface
TableParseOptions
{
export
interface
TableParseOptions
{
headerIsFirstLine
?:
boolean
;
// Not a papa-parse option
headerIsFirstLine
?:
boolean
;
// Not a papa-parse option
...
@@ -131,3 +134,24 @@ export function parseCSV(text: string, options?: TableParseOptions, details?: Ta
...
@@ -131,3 +134,24 @@ export function parseCSV(text: string, options?: TableParseOptions, details?: Ta
columnMap
:
{},
columnMap
:
{},
});
});
}
}
export
function
sortTableData
(
data
:
TableData
,
sortIndex
?:
number
,
reverse
=
false
):
TableData
{
if
(
isNumber
(
sortIndex
))
{
const
copy
=
{
...
data
,
rows
:
[...
data
.
rows
].
sort
((
a
,
b
)
=>
{
a
=
a
[
sortIndex
];
b
=
b
[
sortIndex
];
// Sort null or undefined separately from comparable values
return
+
(
a
==
null
)
-
+
(
b
==
null
)
||
+
(
a
>
b
)
||
-
(
a
<
b
);
}),
};
if
(
reverse
)
{
copy
.
rows
.
reverse
();
}
return
copy
;
}
return
data
;
}
packages/grafana-ui/src/utils/processTimeSeries.ts
View file @
a8c985de
...
@@ -4,7 +4,7 @@ import isNumber from 'lodash/isNumber';
...
@@ -4,7 +4,7 @@ import isNumber from 'lodash/isNumber';
import
{
colors
}
from
'./colors'
;
import
{
colors
}
from
'./colors'
;
// Types
// Types
import
{
TimeSeries
,
T
ableData
,
T
imeSeriesVMs
,
NullValueMode
,
TimeSeriesValue
}
from
'../types'
;
import
{
TimeSeries
,
TimeSeriesVMs
,
NullValueMode
,
TimeSeriesValue
}
from
'../types'
;
interface
Options
{
interface
Options
{
timeSeries
:
TimeSeries
[];
timeSeries
:
TimeSeries
[];
...
@@ -173,24 +173,3 @@ export function processTimeSeries({ timeSeries, nullValueMode }: Options): TimeS
...
@@ -173,24 +173,3 @@ export function processTimeSeries({ timeSeries, nullValueMode }: Options): TimeS
return
vmSeries
;
return
vmSeries
;
}
}
export
function
sortTableData
(
data
:
TableData
,
sortIndex
?:
number
,
reverse
=
false
):
TableData
{
if
(
isNumber
(
sortIndex
))
{
const
copy
=
{
...
data
,
rows
:
[...
data
.
rows
].
sort
((
a
,
b
)
=>
{
a
=
a
[
sortIndex
];
b
=
b
[
sortIndex
];
// Sort null or undefined separately from comparable values
return
+
(
a
==
null
)
-
+
(
b
==
null
)
||
+
(
a
>
b
)
||
-
(
a
<
b
);
}),
};
if
(
reverse
)
{
copy
.
rows
.
reverse
();
}
return
copy
;
}
return
data
;
}
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