Browse Source

Confusing Save / Detect buttons #321 (#333)

master
rozetko 6 years ago committed by GitHub
parent
commit
934308c32f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      src/panel/graph_panel/controllers/analytic_controller.ts
  2. 10
      src/panel/graph_panel/graph_ctrl.ts
  3. 1
      src/panel/graph_panel/graph_renderer.ts
  4. 22
      src/panel/graph_panel/partials/analytic_units_5.x.html
  5. 22
      src/panel/graph_panel/partials/analytic_units_6.x.html

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

@ -166,9 +166,7 @@ export class AnalyticController {
this.labelingUnit.saving = false; this.labelingUnit.saving = false;
let unit = this.labelingUnit;
this.dropLabeling(); this.dropLabeling();
this._runStatusWaiter(unit);
} }
undoLabeling() { undoLabeling() {
@ -185,6 +183,8 @@ export class AnalyticController {
this._labelingDataAddedSegments.clear(); this._labelingDataAddedSegments.clear();
this._labelingDataRemovedSegments.clear(); this._labelingDataRemovedSegments.clear();
this.labelingUnit.selected = false; this.labelingUnit.selected = false;
// TODO: it could be changed before labeling
this.labelingUnit.changed = false;
this._selectedAnalyticUnitId = null; this._selectedAnalyticUnitId = null;
this._tempIdCounted = -1; this._tempIdCounted = -1;
} }
@ -206,6 +206,7 @@ export class AnalyticController {
addSegment(segment: Segment, deleted = false) { addSegment(segment: Segment, deleted = false) {
const addedSegment = this.labelingUnit.addSegment(segment, deleted); const addedSegment = this.labelingUnit.addSegment(segment, deleted);
this.labelingUnit.changed = true;
this._labelingDataAddedSegments.addSegment(addedSegment); this._labelingDataAddedSegments.addSegment(addedSegment);
} }
@ -311,9 +312,6 @@ export class AnalyticController {
const newIds = await this._analyticService.updateSegments( const newIds = await this._analyticService.updateSegments(
unit.id, this._labelingDataAddedSegments, this._labelingDataRemovedSegments unit.id, this._labelingDataAddedSegments, this._labelingDataRemovedSegments
); );
if(unit.labelingMode !== LabelingMode.UNLABELING) {
await this._analyticService.runDetect(unit.id);
}
return newIds; return newIds;
} }
@ -454,7 +452,14 @@ export class AnalyticController {
this._labelingDataRemovedSegments.addSegment(s); this._labelingDataRemovedSegments.addSegment(s);
} }
}); });
this._labelingDataAddedSegments.removeInRange(from, to); const removed = this._labelingDataAddedSegments.removeInRange(from, to);
if(!_.isEmpty(removed)) {
this.labelingUnit.changed = true;
}
if(this._labelingDataAddedSegments.length === 0 &&
this._labelingDataRemovedSegments.length === 0) {
this.labelingUnit.changed = false;
}
} }
toggleLabelingMode(labelingMode: LabelingMode): void { toggleLabelingMode(labelingMode: LabelingMode): void {

10
src/panel/graph_panel/graph_ctrl.ts

@ -604,11 +604,14 @@ class GraphCtrl extends MetricsPanelCtrl {
this.analyticsController.redetectAll(from, to); this.analyticsController.redetectAll(from, to);
} }
async runDetectInCurrentRange(analyticUnitId: AnalyticUnitId) { async runDetectInCurrentRange(analyticUnit: AnalyticUnit) {
const { from, to } = this.rangeTimestamp; const { from, to } = this.rangeTimestamp;
if(analyticUnit.changed) {
await this.onAnalyticUnitSave(analyticUnit);
}
this.analyticsController.runDetect( this.analyticsController.runDetect(
analyticUnitId, analyticUnit.id,
from, to from, to
); );
} }
@ -642,6 +645,9 @@ class GraphCtrl extends MetricsPanelCtrl {
} }
async onAnalyticUnitSave(analyticUnit: AnalyticUnit) { async onAnalyticUnitSave(analyticUnit: AnalyticUnit) {
if(this.analyticsController.labelingUnit.id === analyticUnit.id) {
await this.onToggleLabelingMode(analyticUnit.id)
}
await this.analyticsController.saveAnalyticUnit(analyticUnit); await this.analyticsController.saveAnalyticUnit(analyticUnit);
this.refresh(); this.refresh();
} }

1
src/panel/graph_panel/graph_renderer.ts

@ -164,6 +164,7 @@ export class GraphRenderer {
); );
} }
this.scope.$apply();
this.renderPanel(); this.renderPanel();
return; return;
} }

22
src/panel/graph_panel/partials/analytic_units_5.x.html

@ -128,27 +128,9 @@
</a> </a>
</label> </label>
<!-- TODO: Leave one Detect button instead of 2 -->
<label class="gf-form-label" <label class="gf-form-label"
ng-if=" ng-click="ctrl.runDetectInCurrentRange(analyticUnit)"
analyticUnit.detectorType === 'pattern' || ng-disabled="analyticUnit.status === 'LEARNING' || analyticUnit.saving"
(analyticUnit.detectorType === 'anomaly' && analyticUnit.hasSeasonality)
"
ng-click="ctrl.onToggleLabelingMode(analyticUnit.id)"
ng-disabled="analyticUnit.status === 'LEARNING' || analyticUnit.saving || analyticUnit.changed || !analyticUnit.selected"
>
<a class="pointer">
Detect
</a>
</label>
<label class="gf-form-label"
ng-if="
analyticUnit.detectorType === 'threshold' ||
(analyticUnit.detectorType === 'anomaly' && !analyticUnit.hasSeasonality)
"
ng-click="ctrl.runDetectInCurrentRange(analyticUnit.id)"
ng-disabled="analyticUnit.status === 'LEARNING' || analyticUnit.saving || analyticUnit.changed"
> >
<a class="pointer"> <a class="pointer">
Detect Detect

22
src/panel/graph_panel/partials/analytic_units_6.x.html

@ -117,27 +117,9 @@
</a> </a>
</button> </button>
<!-- TODO: Leave one Detect button instead of 2 -->
<button class="query-editor-row__action" <button class="query-editor-row__action"
ng-if=" ng-click="ctrl.runDetectInCurrentRange(analyticUnit)"
analyticUnit.detectorType === 'pattern' || ng-disabled="analyticUnit.status === 'LEARNING' || analyticUnit.saving"
(analyticUnit.detectorType === 'anomaly' && analyticUnit.hasSeasonality)
"
ng-click="ctrl.onToggleLabelingMode(analyticUnit.id)"
ng-disabled="analyticUnit.status === 'LEARNING' || analyticUnit.saving || analyticUnit.changed || !analyticUnit.selected"
>
<a class="pointer">
Detect
</a>
</button>
<button class="query-editor-row__action"
ng-if="
analyticUnit.detectorType === 'threshold' ||
(analyticUnit.detectorType === 'anomaly' && !analyticUnit.hasSeasonality)
"
ng-click="ctrl.runDetectInCurrentRange(analyticUnit.id)"
ng-disabled="analyticUnit.status === 'LEARNING' || analyticUnit.saving || analyticUnit.changed"
> >
<a class="pointer"> <a class="pointer">
Detect Detect

Loading…
Cancel
Save