Browse Source

Send metric configuration after labeling #121 hotfix

master
rozetko 6 years ago
parent
commit
d980e7c21e
  1. 4
      src/controllers/analytic_controller.ts
  2. 8
      src/module.ts
  3. 11
      src/services/analytic_service.ts

4
src/controllers/analytic_controller.ts

@ -89,10 +89,10 @@ export class AnalyticController {
}
}
async saveNew(panelUrl: string) {
async saveNew(metric: MetricExpanded, datasource: DatasourceRequest, panelUrl: string) {
this._savingNewAnalyticUnit = true;
this._newAnalyticUnit.id = await this._analyticService.postNewItem(
this._newAnalyticUnit, panelUrl
this._newAnalyticUnit, metric, datasource, panelUrl
);
if(this._newAnalyticUnit.detectorType === 'threshold') {
await this.saveThreshold(this._newAnalyticUnit.id);

8
src/module.ts

@ -509,7 +509,13 @@ class GraphCtrl extends MetricsPanelCtrl {
const panelId = this.panel.id;
const panelUrl = window.location.origin + window.location.pathname + `?panelId=${panelId}`;
await this.analyticsController.saveNew(panelUrl);
const datasource = await this._getDatasourceRequest();
await this.analyticsController.saveNew(
new MetricExpanded(this.panel.datasource, this.panel.targets),
datasource,
panelUrl
);
} catch(e) {
this.alertSrv.set(
'Error while saving analytic unit',

11
src/services/analytic_service.ts

@ -34,11 +34,18 @@ export class AnalyticService {
return await this.patch('/threshold', threshold);
}
async postNewItem(newItem: AnalyticUnit, panelUrl: string): Promise<AnalyticUnitId> {
async postNewItem(
newItem: AnalyticUnit,
metric: MetricExpanded,
datasource: DatasourceRequest,
panelUrl: string
): Promise<AnalyticUnitId> {
const response = await this.post('/analyticUnits', {
panelUrl,
type: newItem.type,
name: newItem.name
name: newItem.name,
metric: metric.toJSON(),
datasource
});
return response.id as AnalyticUnitId;

Loading…
Cancel
Save