delete dashboards

This commit is contained in:
2023-03-05 18:12:31 +01:00
parent 332611accb
commit 62cb88e505
12 changed files with 129 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ConfirmationDialogComponent } from '../confirmation-dialog/confirmation-dialog.component';
import { Dashboard, DashboardCreationData, DashboardList, DashboardService } from '../dashboard.service';
import { NewDashboardComponent } from './new-dashboard/new-dashboard.component';
@@ -10,7 +11,7 @@ import { NewDashboardComponent } from './new-dashboard/new-dashboard.component';
})
export class DashboardPageComponent implements OnInit {
displayedColumns: string[] = [/*'icon',*/ 'name', 'description'];
displayedColumns: string[] = [/*'icon',*/ 'name', 'description','delete'];
dataSource: Dashboard[] = [];
loading = true;
error = "";
@@ -23,8 +24,7 @@ export class DashboardPageComponent implements OnInit {
this.refreshTable();
}
refreshTable(){
refreshTable() {
this.loading = true;
this.dashboardService.getDashboards().subscribe({
'next':(dashboardList: DashboardList) => {
@@ -57,4 +57,28 @@ export class DashboardPageComponent implements OnInit {
});
});
}
delete(dashboard: Dashboard){
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: {title: "", text: "Delete dashboard '"+dashboard.name+"'?", btnOkLabel: "Delete", btnCancelLabel: "Cancel"},
hasBackdrop: true
});
dialogRef.afterClosed().subscribe((result: boolean) => {
if (result === true) {
this.dashboardService.deleteDashboard(dashboard.id).subscribe({
'error': (error) => {
},
'complete': () => this.refreshTable()
});
}
});
}
}