From 2db67f0dd13321eac51334c8509d2255369e39a4 Mon Sep 17 00:00:00 2001 From: Alexandr Velikiy <39257464+VargBurz@users.noreply.github.com> Date: Tue, 10 Sep 2019 17:57:07 +0300 Subject: [PATCH] "No connection" message on timeout #370 (#381) * check status * move check * rename --- .../graph_panel/services/analytic_service.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/panel/graph_panel/services/analytic_service.ts b/src/panel/graph_panel/services/analytic_service.ts index 44026dc..c6effda 100644 --- a/src/panel/graph_panel/services/analytic_service.ts +++ b/src/panel/graph_panel/services/analytic_service.ts @@ -280,7 +280,11 @@ export class AnalyticService { // xhrStatus may be one of: ('complete', 'error', 'timeout' or 'abort') // See: https://github.com/angular/angular.js/blob/55075b840c9194b8524627a293d6166528b9a1c2/src/ng/http.js#L919-L920 if(error.xhrStatus !== 'complete' || error.status > 500) { - this.displayConnectionErrorAlert(); + if(error.status === 504) { + this.displayConnectionTimeoutAlert(); + } else { + this.displayNoConnectionAlert(); + } this._isUp = false; throw new Error(`Fetching error: ${error.status}: ${error.statusText}`); } else { @@ -323,7 +327,15 @@ export class AnalyticService { return this._analyticRequest('DELETE', url, data); } - private displayConnectionErrorAlert() { + private displayNoConnectionAlert() { + const message = [ + 'No connection to Hastic Server', + `Hastic Datasource URL: "${this._hasticDatasourceURL}"`, + ] + this._displayConnectionAlert(HasticDatasourceStatus.NOT_AVAILABLE, message); + } + + private displayConnectionTimeoutAlert() { const message = [ 'Timeout when connecting to Hastic Server', `Hastic Datasource URL: "${this._hasticDatasourceURL}"`,