Commit b37444f3 by Torkel Ödegaard Committed by GitHub

InputDataSource: Fixed issue with config editor (#19818)

parent 945b815f
...@@ -271,6 +271,12 @@ export function toCSV(data: DataFrame[], config?: CSVConfig): string { ...@@ -271,6 +271,12 @@ export function toCSV(data: DataFrame[], config?: CSVConfig): string {
for (const series of data) { for (const series of data) {
const { fields } = series; const { fields } = series;
// ignore frames with no fields
if (fields.length === 0) {
continue;
}
if (config.headerStyle === CSVHeaderStyle.full) { if (config.headerStyle === CSVHeaderStyle.full) {
csv = csv =
csv + csv +
...@@ -287,7 +293,9 @@ export function toCSV(data: DataFrame[], config?: CSVConfig): string { ...@@ -287,7 +293,9 @@ export function toCSV(data: DataFrame[], config?: CSVConfig): string {
} }
csv += config.newline; csv += config.newline;
} }
const length = fields[0].values.length; const length = fields[0].values.length;
if (length > 0) { if (length > 0) {
const writers = fields.map(field => makeFieldWriter(field, config!)); const writers = fields.map(field => makeFieldWriter(field, config!));
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
......
...@@ -141,6 +141,10 @@ export class DashboardImportCtrl { ...@@ -141,6 +141,10 @@ export class DashboardImportCtrl {
this.autoGenerateUidValue = 'value set'; this.autoGenerateUidValue = 'value set';
} }
if (!this.dash.uid) {
return;
}
this.backendSrv this.backendSrv
// @ts-ignore // @ts-ignore
.getDashboardByUid(this.dash.uid) .getDashboardByUid(this.dash.uid)
......
...@@ -4,5 +4,5 @@ export function dataFrameToCSV(dto?: DataFrameDTO[]) { ...@@ -4,5 +4,5 @@ export function dataFrameToCSV(dto?: DataFrameDTO[]) {
if (!dto || !dto.length) { if (!dto || !dto.length) {
return ''; return '';
} }
return toCSV(dto.map(v => toDataFrame(dto))); return toCSV(dto.map(v => toDataFrame(v)));
} }
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