Dashboard
This commit is contained in:
@@ -12,17 +12,20 @@ import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { AuthService } from '../../../../core/auth/auth.service';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { RemoveManagerPopupComponent } from '../remove-manager-popup/remove-manager-popup.component';
|
||||
import { IUser } from '../../../../model/interface/user.interface';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
|
||||
@Component({
|
||||
selector: 'app-system-manager',
|
||||
standalone: true,
|
||||
imports: [AgGridAngular, MatDialogModule, MatButtonModule, MatInputModule, MatFormFieldModule, CommonModule, FormsModule],
|
||||
imports: [AgGridAngular, MatDialogModule, MatButtonModule, MatInputModule, MatFormFieldModule, CommonModule, FormsModule, MatIconModule],
|
||||
templateUrl: './system-manager.component.html',
|
||||
styleUrl: './system-manager.component.scss'
|
||||
})
|
||||
export class SystemManagerComponent {
|
||||
|
||||
gridApi!: GridApi;
|
||||
gridApi!: GridApi;
|
||||
|
||||
gridOptions: GridOptions = HELPER.getGridOptions();
|
||||
readonly dialogRef = inject(MatDialogRef<SystemManagerComponent>);
|
||||
@@ -51,7 +54,7 @@ export class SystemManagerComponent {
|
||||
return;
|
||||
}
|
||||
if (event.colDef.colId == 'delete') {
|
||||
this.removeManagerByEmail(event.data.username);
|
||||
this.removeManager(event.data);
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -95,12 +98,25 @@ export class SystemManagerComponent {
|
||||
});
|
||||
}
|
||||
|
||||
removeManagerByEmail(username: string) {
|
||||
const resume = confirm('Soll der Manager wirklich entfernt werden?');
|
||||
if (!resume) return;
|
||||
openPopup(manager: IUser): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
this.dialog.open(RemoveManagerPopupComponent, {
|
||||
data: manager,
|
||||
disableClose: false,
|
||||
autoFocus: false,
|
||||
}).afterClosed().subscribe({
|
||||
next: (n: boolean) => resolve(n)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async removeManager(manager: IUser) {
|
||||
|
||||
const resume = await this.openPopup(manager);
|
||||
if (!resume) return;
|
||||
|
||||
this.gridApi.setGridOption("loading", true);
|
||||
this.api.removeManager(this.system.id, username)
|
||||
this.api.removeManager(this.system.id, manager.username)
|
||||
.pipe(
|
||||
this.toast.observe({
|
||||
loading: 'Manager entfernen',
|
||||
|
||||
Reference in New Issue
Block a user