From b07662a07d37f2f51bcd136636db57fd1343bf33 Mon Sep 17 00:00:00 2001 From: rozetko Date: Tue, 5 Jun 2018 20:52:10 +0300 Subject: [PATCH] Show error on 'failed' status (#8) --- src/controllers/anomaly_controller.ts | 7 ++++++- src/model/anomaly.ts | 4 ++++ src/partials/tab_analytics.html | 2 +- src/services/anomaly_service.ts | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/controllers/anomaly_controller.ts b/src/controllers/anomaly_controller.ts index c22de7c..4b35e12 100644 --- a/src/controllers/anomaly_controller.ts +++ b/src/controllers/anomaly_controller.ts @@ -294,9 +294,14 @@ export class AnomalyController { anomalyType.key, 1000 ); - for await (const status of statusGenerator) { + for await (const data of statusGenerator) { + let status = data.status; + let error = data.errorMessage; if(anomalyType.status !== status) { anomalyType.status = status; + if(error !== undefined) { + anomalyType.error = error; + } this._emitter.emit('anomaly-type-status-change', anomalyType); } if(!anomalyType.isActiveStatus) { diff --git a/src/model/anomaly.ts b/src/model/anomaly.ts index 21242da..0faaa0b 100644 --- a/src/model/anomaly.ts +++ b/src/model/anomaly.ts @@ -26,6 +26,7 @@ export class AnomalyType { private _saving: boolean = false; private _segmentSet = new SegmentArray(); private _status: string; + private _error: string; private _metric: Metric; private _alertEnabled?: boolean; @@ -101,6 +102,9 @@ export class AnomalyType { this._status = value; } + get error() { return this._error; } + set error(value) { this._error = value; } + get isActiveStatus() { return this.status !== 'ready' && this.status !== 'failed'; } diff --git a/src/partials/tab_analytics.html b/src/partials/tab_analytics.html index 48f5857..7cba76c 100644 --- a/src/partials/tab_analytics.html +++ b/src/partials/tab_analytics.html @@ -100,7 +100,7 @@ diff --git a/src/services/anomaly_service.ts b/src/services/anomaly_service.ts index b65cfa3..f7ac2c7 100644 --- a/src/services/anomaly_service.ts +++ b/src/services/anomaly_service.ts @@ -81,7 +81,7 @@ export class AnomalyService { var data = await this._backendSrv.get( this._backendURL + '/anomalies/status', { name: key } ); - return data.status as string; + return data; } let timeout = async () => new Promise(