schlüssel neuen zylindern zuordnen geht
This commit is contained in:
@@ -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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user