diff --git a/dist/module.js b/dist/module.js index 1c220cb..8cd848b 100644 --- a/dist/module.js +++ b/dist/module.js @@ -5924,7 +5924,7 @@ var AnalyticController = /** @class */ (function () { return [2 /*return*/]; } this._statusRunners.add(anomalyType.id); - statusGenerator = this._analyticService.getAnomalyTypeStatusGenerator(anomalyType.id, 1000); + statusGenerator = this._analyticService.getStatusGenerator(anomalyType.id, 1000); _b.label = 1; case 1: _b.trys.push([1, 7, 8, 13]); @@ -9023,8 +9023,8 @@ var AnalyticService = /** @class */ (function () { }); }); }; - AnalyticService.prototype.getAnomalyTypeStatusGenerator = function (id, duration) { - return __asyncGenerator(this, arguments, function getAnomalyTypeStatusGenerator_1() { + AnalyticService.prototype.getStatusGenerator = function (id, duration) { + return __asyncGenerator(this, arguments, function getStatusGenerator_1() { var _this = this; var statusCheck, timeout; return __generator(this, function (_a) { @@ -9077,7 +9077,10 @@ var AnalyticService = /** @class */ (function () { return [4 /*yield*/, this._backendSrv.get(this._backendURL + '/alerts', { id: id })]; case 1: data = _a.sent(); - return [2 /*return*/, data.enable]; + if (data.enabled === undefined) { + throw new Error('Server didn`t return "enabled"'); + } + return [2 /*return*/, data.enabled]; } }); }); diff --git a/src/controllers/analytic_controller.ts b/src/controllers/analytic_controller.ts index 26583c1..0e2ae45 100644 --- a/src/controllers/analytic_controller.ts +++ b/src/controllers/analytic_controller.ts @@ -298,7 +298,7 @@ export class AnalyticController { this._statusRunners.add(anomalyType.id); - var statusGenerator = this._analyticService.getAnomalyTypeStatusGenerator( + var statusGenerator = this._analyticService.getStatusGenerator( anomalyType.id, 1000 ); diff --git a/src/services/analytic_service.ts b/src/services/analytic_service.ts index fdc5636..02de195 100644 --- a/src/services/analytic_service.ts +++ b/src/services/analytic_service.ts @@ -79,7 +79,7 @@ export class AnalyticService { return segments.map(s => new AnalyticSegment(s.labeled, s.id, s.start, s.finish)); } - async * getAnomalyTypeStatusGenerator(id: AnalyticUnitId, duration: number) { + async * getStatusGenerator(id: AnalyticUnitId, duration: number) { if(id === undefined) { throw new Error('id is undefined'); } @@ -108,7 +108,10 @@ export class AnalyticService { var data = await this._backendSrv.get( this._backendURL + '/alerts', { id } ); - return data.enable as boolean; + if(data.enabled === undefined) { + throw new Error('Server didn`t return "enabled"'); + } + return data.enabled as boolean; }