Schließanlagen können gelöscht werden

This commit is contained in:
Bastian Wagner
2026-02-20 16:44:59 +01:00
parent 955faa5cd5
commit 6797b73eb1
17 changed files with 302 additions and 14 deletions

View File

@@ -6,6 +6,7 @@ import { IKey } from '../model/interface/key.interface';
import { ICylinder } from '../model/interface/cylinder.interface';
import { HotToastService } from '@ngxpert/hot-toast';
import { ICustomer } from '../model/interface/customer.interface';
import { ISystem } from '../model/interface/keysystem.interface';
@Injectable({
providedIn: 'root'
@@ -198,7 +199,7 @@ export class ApiService {
*/
deleteSystem(system: any): Promise<boolean> {
return new Promise<boolean>(resolve => {
this.http.delete(`api/system${system.id}`).pipe(
this.http.delete(`api/system/${system.id}`).pipe(
this.toast.observe({
loading: `Lösche Schließanlage ${system.name}...`,
success: `Schließanlage ${system.name} wurde gelöscht.`,
@@ -222,6 +223,21 @@ export class ApiService {
return this.http.put(`api/key/${id}/restore`, null);
}
restoreSystem(system: ISystem): Promise<boolean> {
return new Promise(resolve => {
this.http.put(`api/system/${system.id}/restore`, null).subscribe({
next: () => {
this.refreshSystems();
resolve(true);
},
error: () => {
this.toast.error('Schließanlage konnte nicht wiederhergestellt werden');
resolve(false)
}
})
})
}
private getCylinders(): Observable<ICylinder[]> {
return this.http.get<ICylinder[]>('api/cylinder');
}
@@ -240,6 +256,20 @@ export class ApiService {
})
}
getSystemArchive(): Promise<any[]> {
return new Promise<any[]>(resolve => {
this.http.get<any[]>('api/system/archive').subscribe({
next: val => {
return resolve(val);
},
error: () => {
this.toast.error('Gelöschte Schließanlagen konnten nicht geladen werden');
return resolve([])
}
})
})
}
/**
* Aktualisiert die Zylinder im Behaviour Subject
* cylinders