mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
csv: add toggle for export to Excel
Adds back feature that adds 'sep=;' text that excel needs in a csv file. Also adds toggle to make this optional if exporting to other spreadsheet programs. Fixes #9083.
This commit is contained in:
@@ -11,17 +11,21 @@
|
||||
|
||||
<div class="modal-content">
|
||||
<div class="p-t-2">
|
||||
<div class="gf-form">
|
||||
<div class="gf-form" ng-hide="ctrl.panel === 'table'">
|
||||
<label class="gf-form-label width-10">Mode</label>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input" ng-model="ctrl.asRows" ng-options="f.value as f.text for f in [{text: 'Series as rows', value: true}, {text: 'Series as columns', value: false}]">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<div class="gf-form" ng-hide="ctrl.panel === 'table'">
|
||||
<label class="gf-form-label width-10">Date Time Format</label>
|
||||
<input type="text" class="gf-form-input" ng-model="ctrl.dateTimeFormat">
|
||||
</div>
|
||||
<gf-form-switch class="gf-form"
|
||||
label="Export To Excel" label-class="width-12" switch-class="max-width-6"
|
||||
checked="ctrl.excel">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-button-row text-center">
|
||||
|
||||
@@ -6,17 +6,24 @@ import appEvents from 'app/core/app_events';
|
||||
|
||||
export class ExportDataModalCtrl {
|
||||
private data: any[];
|
||||
private panel: string;
|
||||
asRows: Boolean = true;
|
||||
dateTimeFormat: String = 'YYYY-MM-DDTHH:mm:ssZ';
|
||||
excel: false;
|
||||
/** @ngInject */
|
||||
constructor(private $scope) { }
|
||||
|
||||
export() {
|
||||
if (this.asRows) {
|
||||
fileExport.exportSeriesListToCsv(this.data, this.dateTimeFormat);
|
||||
if (this.panel === 'table') {
|
||||
fileExport.exportTableDataToCsv(this.data, this.excel);
|
||||
} else {
|
||||
fileExport.exportSeriesListToCsvColumns(this.data, this.dateTimeFormat);
|
||||
if (this.asRows) {
|
||||
fileExport.exportSeriesListToCsv(this.data, this.dateTimeFormat, this.excel);
|
||||
} else {
|
||||
fileExport.exportSeriesListToCsvColumns(this.data, this.dateTimeFormat, this.excel);
|
||||
}
|
||||
}
|
||||
|
||||
this.dismiss();
|
||||
}
|
||||
|
||||
@@ -32,6 +39,7 @@ export function exportDataModal() {
|
||||
controller: ExportDataModalCtrl,
|
||||
controllerAs: 'ctrl',
|
||||
scope: {
|
||||
panel: '<',
|
||||
data: '<' // The difference to '=' is that the bound properties are not watched
|
||||
},
|
||||
bindToController: true
|
||||
|
||||
Reference in New Issue
Block a user