Browse Source

Proper error on creating analytic unit with multiple metrics

master
rozetko 6 years ago
parent
commit
0c977b75f1
  1. 3
      src/models/metric.ts
  2. 8
      src/module.ts

3
src/models/metric.ts

@ -37,6 +37,9 @@ export class Metric {
export class MetricExpanded {
private _targets: Target[];
constructor(public datasource: string, targets: any[]) {
if(targets.length > 1) {
throw new Error('Multiple metrics are not supported currently');
}
this._targets = targets.map(t => new Target(t));
}

8
src/module.ts

@ -532,11 +532,19 @@ class GraphCtrl extends MetricsPanelCtrl {
async saveNew() {
this.refresh();
try {
await this.analyticsController.saveNew(
new MetricExpanded(this.panel.datasource, this.panel.targets),
this.datasourceRequest,
this.panel.id
);
} catch(e) {
this.alertSrv.set(
'Error while saving analytic unit',
e.message,
'error', 7000
);
}
this.$scope.$digest();
this.render(this.seriesList);
}

Loading…
Cancel
Save