delete dashboards
This commit is contained in:
@@ -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()
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user