show error message when loading dashboards failed

This commit is contained in:
2023-03-01 19:15:13 +01:00
parent d9daf561bf
commit 1bfb8a0090
2 changed files with 30 additions and 14 deletions

View File

@@ -13,6 +13,7 @@ export class DashboardPageComponent implements OnInit {
displayedColumns: string[] = ['name', 'description'];
dataSource: Dashboard[] = [];
loading = true;
error = "";
constructor(public dialog: MatDialog, private dashboardService: DashboardService){
@@ -25,9 +26,15 @@ export class DashboardPageComponent implements OnInit {
refreshTable(){
this.loading = true;
this.dashboardService.getDashboards().subscribe((dashboardList: DashboardList) => {
this.dataSource = dashboardList.dashboards;
this.loading = false;
this.dashboardService.getDashboards().subscribe({
'next':(dashboardList: DashboardList) => {
this.dataSource = dashboardList.dashboards;
this.loading = false;
},
'error': () => {
this.error = "Failed to load dashboards.";
this.loading = false;
}
});
}