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
81d1f665
Unverified
Commit
81d1f665
authored
May 25, 2020
by
Ryan McKinley
Committed by
GitHub
May 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Download CSV: format the dates (#24992)
* export formatted dates * remove if(true) * display processor
parent
ad870c07
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
0 deletions
+57
-0
packages/grafana-data/src/vector/FormattedVector.ts
+25
-0
packages/grafana-data/src/vector/index.ts
+1
-0
public/app/features/dashboard/components/Inspector/InspectDataTab.tsx
+31
-0
No files found.
packages/grafana-data/src/vector/FormattedVector.ts
0 → 100644
View file @
81d1f665
import
{
Vector
}
from
'../types/vector'
;
import
{
DisplayProcessor
}
from
'../types'
;
import
{
formattedValueToString
}
from
'../valueFormats'
;
import
{
vectorToArray
}
from
'./vectorToArray'
;
export
class
FormattedVector
<
T
=
any
>
implements
Vector
<
string
>
{
constructor
(
private
source
:
Vector
<
T
>
,
private
formatter
:
DisplayProcessor
)
{}
get
length
()
{
return
this
.
source
.
length
;
}
get
(
index
:
number
):
string
{
const
v
=
this
.
source
.
get
(
index
);
return
formattedValueToString
(
this
.
formatter
(
v
));
}
toArray
():
string
[]
{
return
vectorToArray
(
this
);
}
toJSON
():
string
[]
{
return
this
.
toArray
();
}
}
packages/grafana-data/src/vector/index.ts
View file @
81d1f665
...
...
@@ -4,5 +4,6 @@ export * from './CircularVector';
export
*
from
'./ConstantVector'
;
export
*
from
'./BinaryOperationVector'
;
export
*
from
'./SortedVector'
;
export
*
from
'./FormattedVector'
;
export
{
vectorator
}
from
'./FunctionalVector'
;
public/app/features/dashboard/components/Inspector/InspectDataTab.tsx
View file @
81d1f665
...
...
@@ -8,6 +8,11 @@ import {
SelectableValue
,
toCSV
,
transformDataFrame
,
getTimeField
,
FieldType
,
FormattedVector
,
DisplayProcessor
,
getDisplayProcessor
,
}
from
'@grafana/data'
;
import
{
Button
,
Field
,
Icon
,
LegacyForms
,
Select
,
Table
}
from
'@grafana/ui'
;
import
{
selectors
}
from
'@grafana/e2e-selectors'
;
...
...
@@ -52,6 +57,32 @@ export class InspectDataTab extends PureComponent<Props, State> {
exportCsv
=
(
dataFrame
:
DataFrame
)
=>
{
const
{
panel
}
=
this
.
props
;
const
{
transformId
}
=
this
.
state
;
// Replace the time field with a formatted time
const
{
timeIndex
,
timeField
}
=
getTimeField
(
dataFrame
);
if
(
timeField
)
{
// Use the configurd date or standandard time display
let
processor
:
DisplayProcessor
=
timeField
.
display
;
if
(
!
processor
)
{
processor
=
getDisplayProcessor
({
field
:
timeField
,
});
}
const
formattedDateField
=
{
...
timeField
,
type
:
FieldType
.
string
,
values
:
new
FormattedVector
(
timeField
.
values
,
processor
),
};
const
fields
=
[...
dataFrame
.
fields
];
fields
[
timeIndex
]
=
formattedDateField
;
dataFrame
=
{
...
dataFrame
,
fields
,
};
}
const
dataFrameCsv
=
toCSV
([
dataFrame
]);
const
blob
=
new
Blob
([
dataFrameCsv
],
{
...
...
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