improve error messages

This commit is contained in:
2023-03-02 17:56:23 +01:00
parent b3509e062b
commit a8cd94f47e
3 changed files with 14 additions and 5 deletions

View File

@@ -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 @@
<div *ngIf="loading" class="center">
<mat-spinner></mat-spinner>
</div>
<div *ngIf="error" class="center is-error">
<div *ngIf="error" class="center is-error .center-content">
{{error}}
</div>
<div *ngIf="!loading && !error">
<div class="toolbar">
<button mat-button (click)="createNewDashboard()">New</button>

View File

@@ -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;
}
});

View File

@@ -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";
}
}
});