|
|
|
@ -21,7 +21,7 @@ const TIMESTAMP_COLUMN = 'timestamp';
|
|
|
|
|
export class Exporter { |
|
|
|
|
private exportedRows = 0; |
|
|
|
|
private createdTimestamp: number; |
|
|
|
|
private user: string; |
|
|
|
|
private username: string; |
|
|
|
|
private datasourceRef: DataSourceRef; |
|
|
|
|
|
|
|
|
|
private initCsvStream() { |
|
|
|
@ -44,9 +44,9 @@ export class Exporter {
|
|
|
|
|
let time = moment().valueOf(); |
|
|
|
|
let data = { |
|
|
|
|
time, |
|
|
|
|
user: this.user, |
|
|
|
|
username: this.username, |
|
|
|
|
exportedRows: this.exportedRows, |
|
|
|
|
progress: progress.toLocaleString('en', { style: 'percent' }), |
|
|
|
|
progress: progress, |
|
|
|
|
status, |
|
|
|
|
datasourceRef: this.datasourceRef, |
|
|
|
|
}; |
|
|
|
@ -58,11 +58,11 @@ export class Exporter {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async export(data: Target[], datasourceUrl: string, user: string, from: number, to: number) { |
|
|
|
|
this.user = user; |
|
|
|
|
public async export(data: Target[], datasourceUrl: string, username: string, from: number, to: number) { |
|
|
|
|
this.username = username; |
|
|
|
|
|
|
|
|
|
this.validateTargets(datasourceUrl, data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log('ds', data[0].datasource)
|
|
|
|
|
const targets = data.map(target => { |
|
|
|
|
console.log({ |
|
|
|
@ -72,17 +72,18 @@ export class Exporter {
|
|
|
|
|
return { |
|
|
|
|
...target, |
|
|
|
|
metric: new QueryConfig( |
|
|
|
|
QueryType.GRAFANA,
|
|
|
|
|
QueryType.GRAFANA, |
|
|
|
|
{ |
|
|
|
|
...target.datasource, |
|
|
|
|
url: datasourceUrl |
|
|
|
|
},
|
|
|
|
|
}, |
|
|
|
|
target.panel.targets |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.datasourceRef = data.length === 1 ? data[0].datasource : { uid: 'all', type: 'all' }; |
|
|
|
|
const datasource = data[0].datasource; |
|
|
|
|
this.datasourceRef = data.length === 1 ? { uid: datasource.uid, type: datasource.type } : { uid: 'all', type: 'all' }; |
|
|
|
|
|
|
|
|
|
await this.updateStatus(ExportStatus.EXPORTING, 0); |
|
|
|
|
|
|
|
|
|