Skip to content
Snippets Groups Projects
Commit c2b34a1d authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'master' into ozg-6647-network-policy-for-scraper

parents 8e54b2c2 afb777fe
Branches
Tags
No related merge requests found
Showing
with 41 additions and 0 deletions
import { HttpError, StateResource } from '@alfa-client/tech-shared'; import { createEmptyStateResource, StateResource } from '@alfa-client/tech-shared';
import { SnackBarService } from '@alfa-client/ui';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable, startWith, tap } from 'rxjs';
import { SettingName } from '../admin-settings.model'; import { SettingName } from '../admin-settings.model';
import { PostfachResourceService } from './postfach-resource.service'; import { PostfachResourceService } from './postfach-resource.service';
import { Postfach, PostfachResource, PostfachSettingsItem } from './postfach.model'; import { Postfach, PostfachResource, PostfachSettingsItem } from './postfach.model';
@Injectable() @Injectable()
export class PostfachService { export class PostfachService {
constructor(private postfachResourceService: PostfachResourceService) {} constructor(
private postfachResourceService: PostfachResourceService,
private snackbarService: SnackBarService,
) {}
public get(): Observable<StateResource<PostfachResource>> { public get(): Observable<StateResource<PostfachResource>> {
return this.postfachResourceService.get(); return this.postfachResourceService.get();
} }
public save(postfach: Postfach): Observable<StateResource<PostfachResource | HttpError>> { public save(postfach: Postfach): Observable<StateResource<PostfachResource>> {
return this.postfachResourceService.save(this.buildPostfachSettingItem(postfach)); return this.postfachResourceService.save(this.buildPostfachSettingItem(postfach)).pipe(
tap((stateResource: StateResource<PostfachResource>) =>
this.showInfoAfterSave(stateResource),
),
startWith(createEmptyStateResource<PostfachResource>(true)),
);
}
private showInfoAfterSave(stateResource: StateResource<PostfachResource>) {
if (!stateResource.loading) {
this.snackbarService.showInfo('Die Signatur wird erfolgreich gespeichert.');
}
} }
private buildPostfachSettingItem(postfach: Postfach): PostfachSettingsItem { private buildPostfachSettingItem(postfach: Postfach): PostfachSettingsItem {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment