Browse Source

HSR in Inspect mode #279 (#291)

* Remove HSR

* Show HSR for inspected analytic unit

* fix toggleInspect

* Update checkbox style
master
rozetko 5 years ago committed by GitHub
parent
commit
4ddba127f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 37
      src/panel/graph_panel/controllers/analytic_controller.ts
  2. 5
      src/panel/graph_panel/graph_ctrl.ts
  3. 4
      src/panel/graph_panel/models/analytic_units/analytic_unit.ts
  4. 20
      src/panel/graph_panel/partials/tab_analytics.html

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

@ -504,13 +504,13 @@ export class AnalyticController {
}
async getHSR(from: number, to: number): Promise<HSRTimeSeries | null> {
// 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) {

5
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) {

4
src/panel/graph_panel/models/analytic_units/analytic_unit.ts

@ -55,7 +55,6 @@ export class AnalyticUnit {
private _segmentSet = new SegmentArray<AnalyticSegment>();
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
}

20
src/panel/graph_panel/partials/tab_analytics.html

@ -106,24 +106,16 @@
ng-blur="ctrl.onAnalyticUnitChange(analyticUnit)"
/>
<label class="gf-form-label" ng-if="analyticUnit.status === 'READY' && analyticUnit.visible">
Inspect
</label>
<gf-form-switch ng-if="analyticUnit.status === 'READY' && analyticUnit.visible"
<!-- TODO: Remove hack with "margin-bottom: 0" -->
<gf-form-switch ng-if="analyticUnit.visible"
class="gf-form"
style="margin-bottom: 0"
label="Inspect"
label-class="width-5"
on-change="ctrl.onToggleInspect(analyticUnit.id)"
checked="analyticUnit.inspect"
/>
<label class="gf-form-label" ng-if="analyticUnit.visible">
HSR
</label>
<gf-form-switch ng-if="analyticUnit.visible"
on-change="ctrl.onToggleHSR(analyticUnit.id)"
checked="analyticUnit.showHSR"
/>
<label class="gf-form-label" ng-hide="analyticUnit.selected">
<a
ng-if="analyticUnit.visible"

Loading…
Cancel
Save