Wording und API
This commit is contained in:
@@ -5,7 +5,6 @@ import { IKey } from '../../../../model/interface/key.interface';
|
||||
import { ApiService } from '../../../api.service';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { DeleteKeyComponent } from '../../../../modules/keys/components/delete-key/delete-key.component';
|
||||
import { HotToastService } from '@ngxpert/hot-toast';
|
||||
import { HandoverDialogComponent } from '../../../../modules/keys/components/handover-dialog/handover-dialog.component';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { LostKeyComponent } from '../../../../modules/keys/components/lost-key/lost-key.component';
|
||||
@@ -23,7 +22,6 @@ export class AgKeyActionsComponent implements ICellRendererAngularComp {
|
||||
|
||||
private api: ApiService = inject(ApiService);
|
||||
private dialog: MatDialog = inject(MatDialog);
|
||||
private toast = inject(HotToastService);
|
||||
|
||||
agInit(params: ICellRendererParams<any, any, any>): void {
|
||||
this.params = params;
|
||||
@@ -69,22 +67,10 @@ export class AgKeyActionsComponent implements ICellRendererAngularComp {
|
||||
// ref.componentInstance.editKey(this.key)
|
||||
}
|
||||
|
||||
deleteThisKey() {
|
||||
async deleteThisKey() {
|
||||
this.params.api.setGridOption("loading", true);
|
||||
this.api.deleteKey(this.key.id).pipe(
|
||||
this.toast.observe({
|
||||
loading: 'Lösche Schlüssel ' + this.key.name,
|
||||
success: 'Schlüssel ' + this.key.name + ' gelöscht',
|
||||
error: 'Konnte nicht gelöscht werden'
|
||||
})
|
||||
).subscribe({
|
||||
next: () => {
|
||||
this.api.refreshKeys();
|
||||
},
|
||||
error: () => {
|
||||
this.params.api.setGridOption("loading", false);
|
||||
}
|
||||
})
|
||||
await this.api.deleteKey(this.key);
|
||||
this.params.api.setGridOption("loading", false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -101,12 +101,42 @@ export class ApiService {
|
||||
return this.http.post('api/customer', data);
|
||||
}
|
||||
|
||||
getCustomers(): Observable<any[]> {
|
||||
return this.http.get<any[]>('api/customer')
|
||||
getCustomers(): Promise<any[]> {
|
||||
return new Promise(resolve => {
|
||||
this.http.get<any[]>('api/customer').subscribe({
|
||||
next: (customers) => resolve(customers),
|
||||
error: (err) => {
|
||||
this.toast.error('Fehler beim Laden der Kunden');
|
||||
resolve([]);
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
deleteKey(id: string) {
|
||||
return this.http.delete(`api/key/${id}`);
|
||||
/**
|
||||
* Löscht einen Schlüssel und gibt Meldungen aus.
|
||||
* Aktualisiert die Schlüssel danach
|
||||
* @param key zu löschen
|
||||
* @returns true wenn gelöscht, false wenn nicht
|
||||
*/
|
||||
deleteKey(key: IKey): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
this.http.delete<IKey>(`api/key/${key.id}`).pipe(
|
||||
this.toast.observe({
|
||||
loading: `Lösche Schlüssel ${key.name}...`,
|
||||
success: `Schlüssel ${key.name} wurde gelöscht.`,
|
||||
error: 'Es ist ein Fehler aufgetreten'
|
||||
})).subscribe({
|
||||
next: () => {
|
||||
return resolve(true);
|
||||
},
|
||||
error: () => resolve(false),
|
||||
complete: () => {
|
||||
this.refreshKeys();
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
getKeyArchive(): Observable<IKey[]> {
|
||||
@@ -159,7 +189,7 @@ export class ApiService {
|
||||
this.http.delete(`api/cylinder/${cylinder.id}`).pipe(
|
||||
this.toast.observe({
|
||||
loading: `Lösche Zylinder ${cylinder.name}...`,
|
||||
success: 'Zylinder gelöscht',
|
||||
success: `Zylinder ${cylinder.name} wurde gelöscht.`,
|
||||
error: 'Es ist ein Fehler aufgetreten'
|
||||
})
|
||||
).subscribe({
|
||||
@@ -171,12 +201,12 @@ export class ApiService {
|
||||
})
|
||||
}
|
||||
|
||||
restoreCylinder(id: string): Promise<boolean> {
|
||||
restoreCylinder(cylinder: ICylinder): Promise<boolean> {
|
||||
return new Promise<boolean>(resolve => {
|
||||
this.http.put(`api/cylinder/${id}/restore`, null).pipe(
|
||||
this.http.put(`api/cylinder/${cylinder.id}/restore`, null).pipe(
|
||||
this.toast.observe({
|
||||
loading: 'Stelle wiederher...',
|
||||
success: 'Zylinder wiederhergestellt',
|
||||
loading: `Stelle Zylinder ${cylinder.name} wieder her...`,
|
||||
success: `Zylinder ${cylinder.name} erfolgreich wiederhergestellt`,
|
||||
error: 'Es ist ein Fehler aufgetreten'
|
||||
})).subscribe({
|
||||
next: () => resolve(true),
|
||||
|
||||
Reference in New Issue
Block a user