fixes
This commit is contained in:
@@ -15,6 +15,7 @@ export class ApiService {
|
||||
|
||||
public keys: BehaviorSubject<IKey[]> = new BehaviorSubject<IKey[]>([]);
|
||||
public cylinders: BehaviorSubject<ICylinder[]> = new BehaviorSubject<ICylinder[]>([]);
|
||||
public systems: BehaviorSubject<any[]> = new BehaviorSubject<any[]>([]);
|
||||
|
||||
|
||||
public user: BehaviorSubject<IUser> = new BehaviorSubject<IUser>(null!);
|
||||
@@ -73,6 +74,24 @@ export class ApiService {
|
||||
return this.http.put<IKey>('api/key', key);
|
||||
}
|
||||
|
||||
updateCylinder(cylinder: ICylinder): Promise<boolean> {
|
||||
return new Promise<boolean>(resolve => {
|
||||
this.http.put('api/cylinder', cylinder).pipe(
|
||||
this.toast.observe({
|
||||
loading: `Zylinder ${cylinder} wird gespeichert...`,
|
||||
success: `Zylinder ${cylinder.name} gespeichert.`,
|
||||
error: 'Es ist ein Fehler aufgetreten'
|
||||
})
|
||||
).subscribe({
|
||||
next: () => resolve(true),
|
||||
error: () => resolve(false),
|
||||
complete: () => {
|
||||
this.refreshCylinders()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
createKey(key: any) {
|
||||
return this.http.post<IKey>('api/key', key);
|
||||
}
|
||||
@@ -81,7 +100,7 @@ export class ApiService {
|
||||
return this.http.post('api/system', keySystem);
|
||||
}
|
||||
|
||||
getSystems(): Observable<any[]> {
|
||||
private getSystems(): Observable<any[]> {
|
||||
return this.http.get<any[]>('api/system');
|
||||
}
|
||||
|
||||
@@ -139,6 +158,24 @@ export class ApiService {
|
||||
})
|
||||
}
|
||||
|
||||
deleteSystem(system: any): Promise<boolean> {
|
||||
return new Promise<boolean>(resolve => {
|
||||
this.http.delete(`api/system${system.id}`).pipe(
|
||||
this.toast.observe({
|
||||
loading: `Lösche Schließsystem ${system.name}...`,
|
||||
success: `Schließsystem ${system.name} wurde gelöscht.`,
|
||||
error: 'Es ist ein Fehler aufgetreten'
|
||||
})
|
||||
).subscribe({
|
||||
next: () => resolve(true),
|
||||
error: () => resolve(false),
|
||||
complete: () => {
|
||||
this.refreshSystems();
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
getKeyArchive(): Observable<IKey[]> {
|
||||
return this.http.get<IKey[]>('api/key/archive');
|
||||
}
|
||||
@@ -184,6 +221,21 @@ export class ApiService {
|
||||
})
|
||||
}
|
||||
|
||||
refreshSystems(): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
this.getSystems().subscribe({
|
||||
next: data => {
|
||||
this.systems.next(data);
|
||||
resolve()
|
||||
},
|
||||
error: () => {
|
||||
this.toast.error('Fehler beim Laden der Schließsysteme')
|
||||
},
|
||||
complete: () => resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
deleteCylinder(cylinder: ICylinder): Promise<boolean> {
|
||||
return new Promise<boolean>(resolve => {
|
||||
this.http.delete(`api/cylinder/${cylinder.id}`).pipe(
|
||||
|
||||
Reference in New Issue
Block a user