delete dashboards
This commit is contained in:
@@ -55,6 +55,15 @@
|
||||
<th mat-header-cell *matHeaderCellDef>Description</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.description}}</td>
|
||||
</ng-container>
|
||||
<!-- Delete Column -->
|
||||
<ng-container matColumnDef="delete">
|
||||
<th mat-header-cell *matHeaderCellDef></th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<button mat-icon-button (click)="delete(element)">
|
||||
<img src="assets/img/recycle-bin.svg" class="icon-small" title="delete" />
|
||||
</button>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
|
||||
@@ -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()
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,5 +18,5 @@
|
||||
|
||||
<div mat-dialog-actions align="end">
|
||||
<button mat-button mat-dialog-close>Cancel</button>
|
||||
<button mat-button mat-dialog-close (click)="onSaveClick()" cdkFocusInitial>Save</button>
|
||||
<button mat-button mat-dialog-close (click)="onSaveClick()">Save</button>
|
||||
</div>
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<div mat-dialog-content>
|
||||
<mat-form-field appearance="fill">
|
||||
<mat-label>Text</mat-label>
|
||||
<textarea matInput [(ngModel)]="text" #textElement></textarea>
|
||||
<textarea matInput [(ngModel)]="text" #textElement focus></textarea>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div mat-dialog-actions align="end">
|
||||
<button mat-button mat-dialog-close>Cancel</button>
|
||||
<button mat-button mat-dialog-close (click)="onSaveClick()" cdkFocusInitial>Save</button>
|
||||
<button mat-button mat-dialog-close (click)="onSaveClick()">Save</button>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { Component, ElementRef, ViewChild } from '@angular/core';
|
||||
import { MatDialogRef } from '@angular/material/dialog';
|
||||
|
||||
@Component({
|
||||
@@ -6,7 +6,7 @@ import { MatDialogRef } from '@angular/material/dialog';
|
||||
templateUrl: './add-text-dialog.component.html',
|
||||
styleUrls: ['./add-text-dialog.component.scss']
|
||||
})
|
||||
export class AddTextDialogComponent implements OnInit {
|
||||
export class AddTextDialogComponent {
|
||||
text = "";
|
||||
|
||||
@ViewChild('textElement') textElement!: ElementRef;
|
||||
@@ -14,9 +14,6 @@ export class AddTextDialogComponent implements OnInit {
|
||||
constructor(public dialogRef: MatDialogRef<string>){
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
window.setTimeout(() => this.textElement.nativeElement.focus(), 0);
|
||||
}
|
||||
|
||||
onSaveClick(): void {
|
||||
this.dialogRef.close(this.text);
|
||||
|
||||
Reference in New Issue
Block a user