Commit 47f81452 by Torkel Ödegaard

Merge branch 'master' of github.com:grafana/grafana

parents 71c22fdb 632a5e9b
......@@ -114,7 +114,7 @@ func getEngine() (*xorm.Engine, error) {
protocol = "unix"
}
cnnstr = fmt.Sprintf("%s:%s@%s(%s)/%s?charset=utf8mb4",
cnnstr = fmt.Sprintf("%s:%s@%s(%s)/%s?charset=utf8mb4&allowNativePasswords=true",
DbCfg.User, DbCfg.Pwd, protocol, DbCfg.Host, DbCfg.Name)
if DbCfg.SslMode == "true" || DbCfg.SslMode == "skip-verify" {
......
......@@ -7,8 +7,8 @@ declare var window: any;
const DEFAULT_DATETIME_FORMAT: String = 'YYYY-MM-DDTHH:mm:ssZ';
export function exportSeriesListToCsv(seriesList, dateTimeFormat = DEFAULT_DATETIME_FORMAT) {
var text = 'Series;Time;Value\n';
export function exportSeriesListToCsv(seriesList, dateTimeFormat = DEFAULT_DATETIME_FORMAT, excel = false) {
var text = excel ? 'sep=;\n' : '' + 'Series;Time;Value\n';
_.each(seriesList, function(series) {
_.each(series.datapoints, function(dp) {
text += series.alias + ';' + moment(dp[1]).format(dateTimeFormat) + ';' + dp[0] + '\n';
......@@ -17,8 +17,8 @@ export function exportSeriesListToCsv(seriesList, dateTimeFormat = DEFAULT_DATET
saveSaveBlob(text, 'grafana_data_export.csv');
}
export function exportSeriesListToCsvColumns(seriesList, dateTimeFormat = DEFAULT_DATETIME_FORMAT) {
var text = 'Time;';
export function exportSeriesListToCsvColumns(seriesList, dateTimeFormat = DEFAULT_DATETIME_FORMAT, excel = false) {
var text = excel ? 'sep=;\n' : '' + 'Time;';
// add header
_.each(seriesList, function(series) {
text += series.alias + ';';
......@@ -52,8 +52,8 @@ export function exportSeriesListToCsvColumns(seriesList, dateTimeFormat = DEFAUL
saveSaveBlob(text, 'grafana_data_export.csv');
}
export function exportTableDataToCsv(table) {
var text = '';
export function exportTableDataToCsv(table, excel = false) {
var text = excel ? 'sep=;\n' : '';
// add header
_.each(table.columns, function(column) {
text += (column.title || column.text) + ';';
......
......@@ -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
......
......@@ -150,7 +150,14 @@ class TablePanelCtrl extends MetricsPanelCtrl {
}
exportCsv() {
FileExport.exportTableDataToCsv(this.renderer.render_values());
var scope = this.$scope.$new(true);
scope.tableData = this.renderer.render_values();
scope.panel = 'table';
this.publishAppEvent('show-modal', {
templateHtml: '<export-data-modal panel="panel" data="tableData"></export-data-modal>',
scope,
modalClass: 'modal--narrow'
});
}
link(scope, elem, attrs, ctrl) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment