Browse Source

HSR is not updated when anomaly analytic unit options are changed #292 (#294)

master
rozetko 6 years ago committed by GitHub
parent
commit
6a8d1b6f7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/panel/graph_panel/controllers/analytic_controller.ts
  2. 19
      src/panel/graph_panel/graph_ctrl.ts
  3. 5
      src/panel/graph_panel/services/analytic_service.ts

6
src/panel/graph_panel/controllers/analytic_controller.ts

@ -505,12 +505,16 @@ export class AnalyticController {
async getHSR(from: number, to: number): Promise<HSRTimeSeries | null> {
// Returns HSR (Hastic Signal Representation) for analytic unit in "Inspect" mode
// Returns null when there is no analytic units in "Inspect" mode
// Returns null when there are no analytic units in "Inspect" mode
// or if there is no response from server
if(this.inspectedAnalyticUnit === null) {
return null;
}
const hsr = await this._analyticService.getHSR(this.inspectedAnalyticUnit.id, from, to);
if(hsr === null) {
return null;
}
const datapoints = hsr.values.map(value => value.reverse() as [number, number]);
return { target: 'HSR', datapoints };
}

19
src/panel/graph_panel/graph_ctrl.ts

@ -398,6 +398,13 @@ class GraphCtrl extends MetricsPanelCtrl {
};
break;
}
const from = _.find(series.datapoints, datapoint => datapoint[0] !== null);
const to = _.findLast(series.datapoints, datapoint => datapoint[0] !== null);
this._dataTimerange = {};
if(from !== undefined && to !== undefined) {
this._dataTimerange = { from: from[1], to: to[1] };
}
}
}
@ -410,11 +417,11 @@ class GraphCtrl extends MetricsPanelCtrl {
await Promise.all(loadTasks);
// this.annotations = results[0].annotations;
this.render(this.seriesList);
this.analyticsController.fetchAnalyticUnitsDetections(
await this.analyticsController.fetchAnalyticUnitsDetections(
this._dataTimerange.from,
this._dataTimerange.to
);
this.render(this.seriesList);
}
this.loading = false;
@ -426,14 +433,6 @@ class GraphCtrl extends MetricsPanelCtrl {
}
for(let series of this.seriesList) {
const from = _.find(series.datapoints, datapoint => datapoint[0] !== null);
const to = _.findLast(series.datapoints, datapoint => datapoint[0] !== null);
this._dataTimerange = {};
if(from !== undefined && to !== undefined) {
this._dataTimerange = { from: from[1], to: to[1] };
}
if (series.unit) {
this.panel.yaxes[series.yaxis - 1].format = series.unit;
}

5
src/panel/graph_panel/services/analytic_service.ts

@ -203,8 +203,11 @@ export class AnalyticService {
async getHSR(analyticUnitId: AnalyticUnitId, from: number, to: number): Promise<{
values: [number, number][];
columns: string[];
}> {
} | null> {
const data = await this.get('/query', { analyticUnitId, from, to });
if(data === undefined) {
return null;
}
return data.results;
}

Loading…
Cancel
Save