From a8cd94f47e933a7c58c474bd433cb1e28efc4038 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Thu, 2 Mar 2023 17:56:23 +0100 Subject: [PATCH] improve error messages --- .../src/app/dashboard-page/dashboard-page.component.html | 6 ++++-- .../src/app/dashboard-page/dashboard-page.component.ts | 9 +++++++-- .../app/dashboard-page/dashboard/dashboard.component.ts | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pdb-js/src/app/dashboard-page/dashboard-page.component.html b/pdb-js/src/app/dashboard-page/dashboard-page.component.html index 6459b20..80def05 100644 --- a/pdb-js/src/app/dashboard-page/dashboard-page.component.html +++ b/pdb-js/src/app/dashboard-page/dashboard-page.component.html @@ -5,6 +5,9 @@ left: 50%; transform: translate(-50%, -50%); } + .center-content { + text-align: center; + } .is-error { font-size: 3rem; color: #333; @@ -14,10 +17,9 @@
-
+
{{error}}
-
diff --git a/pdb-js/src/app/dashboard-page/dashboard-page.component.ts b/pdb-js/src/app/dashboard-page/dashboard-page.component.ts index b6aaaf9..65b0d0b 100644 --- a/pdb-js/src/app/dashboard-page/dashboard-page.component.ts +++ b/pdb-js/src/app/dashboard-page/dashboard-page.component.ts @@ -1,3 +1,4 @@ +import { HttpErrorResponse } from '@angular/common/http'; import { Component, OnInit } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { Dashboard, DashboardCreationData, DashboardList, DashboardService } from '../dashboard.service'; @@ -31,8 +32,12 @@ export class DashboardPageComponent implements OnInit { this.dataSource = dashboardList.dashboards; this.loading = false; }, - 'error': () => { - this.error = "Failed to load dashboards."; + 'error': (error: HttpErrorResponse) => { + if (error.status == 504){ + this.error = "Server Unreachable"; + }else{ + this.error = "Failed to load dashboards"; + } this.loading = false; } }); diff --git a/pdb-js/src/app/dashboard-page/dashboard/dashboard.component.ts b/pdb-js/src/app/dashboard-page/dashboard/dashboard.component.ts index f347268..2f7358e 100644 --- a/pdb-js/src/app/dashboard-page/dashboard/dashboard.component.ts +++ b/pdb-js/src/app/dashboard-page/dashboard/dashboard.component.ts @@ -41,8 +41,10 @@ export class DashboardComponent implements OnInit { 'error': (error: HttpErrorResponse) =>{ if (error.status == 404) { this.error = "Not Found"; + }else if (error.status == 504) { // gateway timeout + this.error = "Server Unreachable"; }else{ - this.error = "Failed to load dashboard."; + this.error = "Failed to load dashboard"; } } });