Browse Source

enable logging

master
amper43 6 years ago
parent
commit
8ada206927
  1. 18
      src/controllers/analytic_controller.ts
  2. 4
      src/partials/tab_analytics.html
  3. 2
      src/services/analytic_service.ts

18
src/controllers/analytic_controller.ts

@ -49,7 +49,7 @@ export class AnalyticController {
this._labelingDataAddedSegments = new SegmentArray<AnalyticSegment>();
this._labelingDataDeletedSegments = new SegmentArray<AnalyticSegment>();
this._analyticUnitsSet = new AnalyticUnitsSet(this._panelObject.anomalyTypes);
// this.analyticUnits.forEach(a => this.runEnabledWaiter(a));
this.analyticUnits.forEach(a => this.runEnabledWaiter(a));
}
getSegmentsSearcher(): AnalyticSegmentsSearcher {
@ -88,7 +88,7 @@ export class AnalyticController {
this._analyticUnitsSet.addItem(this._newAnalyticUnit);
this._creatingNewAnalyticType = false;
this._savingNewAnalyticUnit = false;
// this.runEnabledWaiter(this._newAnalyticUnit);
this.runEnabledWaiter(this._newAnalyticUnit);
this._runStatusWaiter(this._newAnalyticUnit);
}
@ -358,13 +358,13 @@ export class AnalyticController {
this._statusRunners.delete(analyticUnit.id);
}
// async runEnabledWaiter(analyticUnit: AnalyticUnit) {
// var enabled = await this._analyticService.getAlertEnabled(analyticUnit.id);
// if(analyticUnit.alertEnabled !== enabled) {
// analyticUnit.alertEnabled = enabled;
// this._emitter.emit('anomaly-type-alert-change', analyticUnit);
// }
// }
async runEnabledWaiter(analyticUnit: AnalyticUnit) {
var enabled = await this._analyticService.getAlertEnabled(analyticUnit.id);
if(analyticUnit.alertEnabled !== enabled) {
analyticUnit.alertEnabled = enabled;
this._emitter.emit('anomaly-type-alert-change', analyticUnit);
}
}
async toggleAlertEnabled(analyticUnit: AnalyticUnit) {
var enabled = analyticUnit.alertEnabled;

4
src/partials/tab_analytics.html

@ -49,7 +49,7 @@
</label>
<!-- <label class="gf-form-label"> Alerts: </label>
<label class="gf-form-label"> Alerts: </label>
<label
class="gf-form-label text-center"
style="width: 4rem"
@ -57,7 +57,7 @@
bs-tooltip="'Alarting status isn`t available. Wait please.'"
>
<i class="fa fa-spinner fa-spin"></i>
</label> -->
</label>
<gf-form-switch
ng-if="analyticUnit.alertEnabled !== undefined"

2
src/services/analytic_service.ts

@ -114,6 +114,7 @@ export class AnalyticService {
if(data.enabled === undefined) {
throw new Error('Server didn`t return "enabled"');
}
console.log(`Try to enable alerts, got ${data.enabled as boolean}`);
return data.enabled as boolean;
}
@ -122,6 +123,7 @@ export class AnalyticService {
if(id === undefined) {
throw new Error('id is undefined');
}
console.log(`Enable alert url:${this._backendURL + '/alerts'} id:${id} enabled:${enabled}`);
return this._backendSrv.post(
this._backendURL + '/alerts', { id, enabled }
);

Loading…
Cancel
Save