From 4ddba127f38cee7b7a691ffaf5ff10439aa0b178 Mon Sep 17 00:00:00 2001 From: rozetko Date: Thu, 9 May 2019 20:49:03 +0300 Subject: [PATCH] HSR in Inspect mode #279 (#291) * Remove HSR * Show HSR for inspected analytic unit * fix toggleInspect * Update checkbox style --- .../controllers/analytic_controller.ts | 37 +++++-------------- src/panel/graph_panel/graph_ctrl.ts | 5 --- .../models/analytic_units/analytic_unit.ts | 4 -- .../graph_panel/partials/tab_analytics.html | 20 +++------- 4 files changed, 15 insertions(+), 51 deletions(-) diff --git a/src/panel/graph_panel/controllers/analytic_controller.ts b/src/panel/graph_panel/controllers/analytic_controller.ts index e27ffc4..311fbf9 100644 --- a/src/panel/graph_panel/controllers/analytic_controller.ts +++ b/src/panel/graph_panel/controllers/analytic_controller.ts @@ -504,13 +504,13 @@ export class AnalyticController { } async getHSR(from: number, to: number): Promise { - // Returns HSR (Hastic Signal Representation) for analytic unit with enabled "Show HSR" - // Returns null when there is no analytic units which have "Show HSR" enabled - if(this.hsrAnalyticUnit === null) { + // Returns HSR (Hastic Signal Representation) for analytic unit in "Inspect" mode + // Returns null when there is no analytic units in "Inspect" mode + if(this.inspectedAnalyticUnit === null) { return null; } - const hsr = await this._analyticService.getHSR(this.hsrAnalyticUnit.id, from, to); + const hsr = await this._analyticService.getHSR(this.inspectedAnalyticUnit.id, from, to); const datapoints = hsr.values.map(value => value.reverse() as [number, number]); return { target: 'HSR', datapoints }; } @@ -521,8 +521,8 @@ export class AnalyticController { if(hsr === null) { return []; } - if(this.hsrAnalyticUnit.detectorType === DetectorType.ANOMALY) { - const confidence = (this.hsrAnalyticUnit as AnomalyAnalyticUnit).confidence; + if(this.inspectedAnalyticUnit.detectorType === DetectorType.ANOMALY) { + const confidence = (this.inspectedAnalyticUnit as AnomalyAnalyticUnit).confidence; // TODO: looks bad return [ { @@ -562,16 +562,6 @@ export class AnalyticController { return null; } - get hsrAnalyticUnit(): AnalyticUnit | null { - // TODO: remove inspectedAnalyticUnit duplication - for(let analyticUnit of this.analyticUnits) { - if(analyticUnit.showHSR) { - return analyticUnit; - } - }; - return null; - } - public get conditions() { return _.values(Condition); } @@ -682,18 +672,9 @@ export class AnalyticController { } public toggleInspect(id: AnalyticUnitId) { - const analyticUnit = this._analyticUnitsSet.byId(id); - if(!analyticUnit.inspect) { - this.analyticUnits.forEach(unit => unit.inspect = false); - } - } - - public toggleHSR(id: AnalyticUnitId) { - // TODO: remove toggleInspect duplication - const analyticUnit = this._analyticUnitsSet.byId(id); - if(!analyticUnit.showHSR) { - this.analyticUnits.forEach(unit => unit.showHSR = false); - } + this.analyticUnits + .filter(analyticUnit => analyticUnit.id !== id) + .forEach(unit => unit.inspect = false); } public onAnalyticUnitDetectorChange(analyticUnitTypes: any) { diff --git a/src/panel/graph_panel/graph_ctrl.ts b/src/panel/graph_panel/graph_ctrl.ts index 4c08c41..8ef5d9b 100644 --- a/src/panel/graph_panel/graph_ctrl.ts +++ b/src/panel/graph_panel/graph_ctrl.ts @@ -683,11 +683,6 @@ class GraphCtrl extends MetricsPanelCtrl { this.refresh(); } - onToggleHSR(id: AnalyticUnitId) { - this.analyticsController.toggleHSR(id); - this.refresh(); - } - private async _updatePanelInfo() { let datasource = undefined; if(this.panel.datasource) { diff --git a/src/panel/graph_panel/models/analytic_units/analytic_unit.ts b/src/panel/graph_panel/models/analytic_units/analytic_unit.ts index a395706..b2fddee 100644 --- a/src/panel/graph_panel/models/analytic_units/analytic_unit.ts +++ b/src/panel/graph_panel/models/analytic_units/analytic_unit.ts @@ -55,7 +55,6 @@ export class AnalyticUnit { private _segmentSet = new SegmentArray(); private _detectionSpans: DetectionSpan[]; private _inspect = false; - private _showHSR = false; private _status: string; private _error: string; @@ -116,9 +115,6 @@ export class AnalyticUnit { get inspect(): boolean { return this._inspect; } set inspect(value: boolean) { this._inspect = value; } - get showHSR(): boolean { return this._showHSR; } - set showHSR(value: boolean) { this._showHSR = value; } - get visible(): boolean { return (this._serverObject.visible === undefined) ? true : this._serverObject.visible } diff --git a/src/panel/graph_panel/partials/tab_analytics.html b/src/panel/graph_panel/partials/tab_analytics.html index 3c054ec..5001cd1 100644 --- a/src/panel/graph_panel/partials/tab_analytics.html +++ b/src/panel/graph_panel/partials/tab_analytics.html @@ -106,24 +106,16 @@ ng-blur="ctrl.onAnalyticUnitChange(analyticUnit)" /> - - - + - - - -