Schließanlagen können gelöscht werden
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user