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
d13957cb
Commit
d13957cb
authored
Jan 21, 2016
by
Carl Bergquist
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3803 from xadhoom/table_export_csv
add export to csv in table panel
parents
4a8f82ca
cdcc7a71
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
public/app/core/utils/kbn.js
+23
-2
public/app/plugins/panel/table/controller.ts
+7
-0
No files found.
public/app/core/utils/kbn.js
View file @
d13957cb
...
...
@@ -186,8 +186,29 @@ function($, _) {
text
+=
series
.
alias
+
';'
+
new
Date
(
dp
[
1
]).
toISOString
()
+
';'
+
dp
[
0
]
+
'
\
n'
;
});
});
var
blob
=
new
Blob
([
text
],
{
type
:
"text/csv;charset=utf-8"
});
window
.
saveAs
(
blob
,
'grafana_data_export.csv'
);
kbn
.
saveSaveBlob
(
text
,
'grafana_data_export.csv'
);
};
kbn
.
exportTableDataToCsv
=
function
(
table
)
{
var
text
=
''
;
// add header
_
.
each
(
table
.
columns
,
function
(
column
)
{
text
+=
column
.
text
+
';'
;
});
text
+=
'
\
n'
;
// process data
_
.
each
(
table
.
rows
,
function
(
row
)
{
_
.
each
(
row
,
function
(
value
)
{
text
+=
value
+
';'
;
});
text
+=
'
\
n'
;
});
kbn
.
saveSaveBlob
(
text
,
'grafana_data_export.csv'
);
};
kbn
.
saveSaveBlob
=
function
(
payload
,
fname
)
{
var
blob
=
new
Blob
([
payload
],
{
type
:
"text/csv;charset=utf-8"
});
window
.
saveAs
(
blob
,
fname
);
};
kbn
.
stringToJsRegex
=
function
(
str
)
{
...
...
public/app/plugins/panel/table/controller.ts
View file @
d13957cb
...
...
@@ -3,6 +3,7 @@
import
angular
from
'angular'
;
import
_
from
'lodash'
;
import
moment
from
'moment'
;
import
kbn
from
'app/core/utils/kbn'
;
import
PanelMeta
from
'app/features/panel/panel_meta2'
;
import
{
transformDataToTable
}
from
'./transformers'
;
...
...
@@ -23,6 +24,8 @@ export class TablePanelCtrl {
$scope
.
panelMeta
.
addEditorTab
(
'Options'
,
'app/plugins/panel/table/options.html'
);
$scope
.
panelMeta
.
addEditorTab
(
'Time range'
,
'app/features/panel/partials/panelTime.html'
);
$scope
.
panelMeta
.
addExtendedMenuItem
(
'Export CSV'
,
''
,
'exportCsv()'
);
var
panelDefaults
=
{
targets
:
[{}],
transform
:
'timeseries_to_columns'
,
...
...
@@ -124,6 +127,10 @@ export class TablePanelCtrl {
panelHelper
.
broadcastRender
(
$scope
,
$scope
.
table
,
$scope
.
dataRaw
);
};
$scope
.
exportCsv
=
function
()
{
kbn
.
exportTableDataToCsv
(
$scope
.
table
);
};
$scope
.
init
();
}
}
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