schlüssel neuen zylindern zuordnen geht

This commit is contained in:
Bastian Wagner
2026-02-22 17:08:50 +01:00
parent 6797b73eb1
commit e5c590165c
13 changed files with 163 additions and 1338 deletions

View File

@@ -76,8 +76,20 @@ export class ApiService {
return this.http.get<IKey[]>('api/key/lost')
}
updateKey(key: IKey): Observable<IKey> {
return this.http.put<IKey>('api/key', key);
updateKey(key: IKey): Promise<IKey | null> {
return new Promise<IKey | null>(resolve => {
this.http.put<IKey>('api/key', key).pipe(
this.toast.observe({
loading: `Speichere Schlüssel ${key.name}....`,
success: `Schlüssel ${key.name} gespeichert.`,
error: `Es ist ein Fehler aufgetreten!`
})
).subscribe({
next: (key: IKey) => resolve(key),
error: () => resolve(null),
complete: () => { this.refreshKeys(); }
})
})
}
updateCylinder(cylinder: ICylinder): Promise<boolean> {
@@ -275,8 +287,8 @@ export class ApiService {
* cylinders
* @returns Promise wenn geladen
*/
refreshCylinders(): Promise<void> {
return new Promise<void>(resolve => {
refreshCylinders(): Promise<ICylinder[]> {
return new Promise<ICylinder[]>(resolve => {
this.getCylinders().subscribe({
next: data => {
this.cylinders.next(data);
@@ -284,7 +296,7 @@ export class ApiService {
error: () => {
this.toast.error('Fehler beim Laden der Zylinder')
},
complete: () => resolve()
complete: () => resolve(this.cylinders.value)
})
})
}