Skip to content

Commit

Permalink
test-upload
Browse files Browse the repository at this point in the history
  • Loading branch information
dysTOS committed Nov 14, 2023
1 parent f8fdba9 commit 7a76c90
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 65 deletions.
4 changes: 2 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AuthStateService } from "./services/authentication/auth-state.service";
import { TokenService } from "./services/authentication/token.service";
import { UserService } from "./services/authentication/user.service";
import { ThemeService } from "./services/theme.service";
import { AppNamingService } from "./services/config.service";
import { AppConfigService } from "./services/app-config.service";

@Component({
selector: "app-root",
Expand All @@ -22,7 +22,7 @@ export class AppComponent {
private router: Router,
private userService: UserService,
private tokenService: TokenService,
private namingService: AppNamingService
private configService: AppConfigService
) {
this.authStatService.userAuthState.subscribe((isAuthenticated) => {
if (!isAuthenticated && this.tokenService.isLoggedIn()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Table } from "primeng/table";
import { Noten, NotenGattungMap } from "src/app/models/Noten";
import { PermissionMap } from "src/app/models/User";
import { NotenApiService } from "src/app/services/api/noten-api.service";
import { AppNamingService } from "src/app/services/config.service";
import { AppConfigService } from "src/app/services/app-config.service";
import { InfoService } from "src/app/services/info.service";
import { MkjToolbarService } from "src/app/utilities/mkj-toolbar/mkj-toolbar.service";

Expand Down Expand Up @@ -33,7 +33,7 @@ export class NotenarchivComponent implements OnInit {
private toolbarService: MkjToolbarService,
private router: Router,
private route: ActivatedRoute,
private namingService: AppNamingService
private namingService: AppConfigService
) {
this.toolbarService.header = this.namingService.appNaming.Noten;
this.toolbarService.backButton = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { PermissionMap } from "src/app/models/User";
import { MkjDatePipe } from "src/app/pipes/mkj-date.pipe";
import { TermineApiService } from "src/app/services/api/termine-api.service";
import { UserService } from "src/app/services/authentication/user.service";
import { AppNamingService } from "src/app/services/config.service";
import { AppConfigService } from "src/app/services/app-config.service";
import { ExportService } from "src/app/services/export.service";
import { InfoService } from "src/app/services/info.service";
import { MkjToolbarService } from "src/app/utilities/mkj-toolbar/mkj-toolbar.service";
Expand Down Expand Up @@ -109,7 +109,7 @@ export class AusrueckungenAktuellComponent implements OnInit, AfterViewInit {
private route: ActivatedRoute,
private exportService: ExportService,
private mkjDatePipe: MkjDatePipe,
private namingService: AppNamingService,
private namingService: AppConfigService,
public toolbarService: MkjToolbarService
) {
this.hasAktionenPermissions = this.userService.hasOneOfPermissions([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
</ng-container>
</div>

<p-button label="Save" (onClick)="saveNaming()"></p-button>
<p-button label="Save" (onClick)="updateNaming()"></p-button>
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
import { Component } from "@angular/core";
import * as _ from "lodash";
import { ConfigApiService } from "src/app/services/api/config-api.service";
import { AppNamingService } from "src/app/services/config.service";
import { InfoService } from "src/app/services/info.service";
import { AppConfigService } from "src/app/services/app-config.service";

@Component({
selector: "app-ui-naming-config",
templateUrl: "./ui-naming-config.component.html",
styleUrls: ["./ui-naming-config.component.scss"],
})
export class UiNamingConfigComponent {
public readonly appNaming = _.cloneDeep(this.namingService.appNaming);
public readonly editNaming = _.cloneDeep(this.namingService.appNaming);
public readonly appNaming = _.cloneDeep(this.configService.appNaming);
public readonly editNaming = _.cloneDeep(this.configService.appNaming);

constructor(
private namingService: AppNamingService,
private configService: ConfigApiService,
private infoService: InfoService
) {}
constructor(private configService: AppConfigService) {}

public saveNaming(): void {
this.configService.setUiNamingConfig(this.editNaming).subscribe({
next: (_) => this.infoService.success("Einstellungen gespeichert."),
error: (err) => this.infoService.error(err),
});
public updateNaming(): void {
this.configService.updateAppNamingConfig(this.editNaming);
}
}
18 changes: 18 additions & 0 deletions src/app/interfaces/UiConfigurations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export interface UiConfigurations {
uiNaming: UiNamingConfig;
terminConfig: UiTerminConfig;
}

export interface UiNamingConfig {
Termine: string;
Noten: string;
}

export interface UiTerminConfig {
terminKategorien: UiDropdownOption[];
}

export interface UiDropdownOption {
label: string;
value: string;
}
4 changes: 0 additions & 4 deletions src/app/interfaces/UiNamingConfig.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/app/providers/mkj-app-initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { APP_INITIALIZER } from "@angular/core";
import { UserService } from "../services/authentication/user.service";
import { ServiceWorkerService } from "../services/service-worker.service";
import { ThemeService } from "../services/theme.service";
import { AppNamingService } from "../services/config.service";
import { AppConfigService } from "../services/app-config.service";
import { switchMap } from "rxjs";

export const mkjAppInitializer = () => {
Expand All @@ -11,7 +11,7 @@ export const mkjAppInitializer = () => {
useFactory: (
themeService: ThemeService,
userService: UserService,
appNamingService: AppNamingService,
appNamingService: AppConfigService,
serviceWorkerService: ServiceWorkerService
) => {
return () =>
Expand All @@ -24,7 +24,7 @@ export const mkjAppInitializer = () => {
deps: [
ThemeService,
UserService,
AppNamingService,
AppConfigService,
ServiceWorkerService,
],
multi: true,
Expand Down
14 changes: 7 additions & 7 deletions src/app/services/api/config-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { environment } from "src/environments/environment";
import { Observable } from "rxjs";
import { UiNamingConfig } from "src/app/interfaces/UiNamingConfig";
import { UiConfigurations } from "src/app/interfaces/UiConfigurations";
import { StandardHttpOptions } from "src/app/interfaces/api-middleware";

@Injectable({
providedIn: "root",
})
export class ConfigApiService {
protected apiUrl: string = environment.apiUrl + "namingconfig";
protected apiUrl: string = environment.apiUrl + "configs";

constructor(private httpClient: HttpClient) {}

public getUiNamingConfig(): Observable<UiNamingConfig> {
return this.httpClient.get<UiNamingConfig>(
public getConfigs(): Observable<UiConfigurations> {
return this.httpClient.get<UiConfigurations>(
this.apiUrl,
StandardHttpOptions
);
}

public setUiNamingConfig(config: UiNamingConfig): Observable<void> {
return this.httpClient.post<void>(
public saveConfigs(config: UiConfigurations): Observable<UiConfigurations> {
return this.httpClient.post<UiConfigurations>(
this.apiUrl,
{ config },
config,
StandardHttpOptions
);
}
Expand Down
62 changes: 62 additions & 0 deletions src/app/services/app-config.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Injectable } from "@angular/core";
import { BehaviorSubject, Observable, map, tap } from "rxjs";
import {
UiConfigurations,
UiNamingConfig,
UiTerminConfig,
} from "../interfaces/UiConfigurations";
import { ConfigApiService } from "./api/config-api.service";
import { InfoService } from "./info.service";

@Injectable({
providedIn: "root",
})
export class AppConfigService {
private _appNaming = new BehaviorSubject<UiNamingConfig>(null);
public get appNaming(): UiNamingConfig {
return this._appNaming.value;
}

private _terminConfig = new BehaviorSubject<UiTerminConfig>(null);
public get terminConfig(): UiTerminConfig {
return this._terminConfig.value;
}

constructor(
private configService: ConfigApiService,
private infoService: InfoService
) {}

public initAppNamingConfig(): Observable<void> {
return this.configService.getConfigs().pipe(
tap((config) => this.setInternalConfigs(config)),
map((config) => null)
);
}

public updateAppNamingConfig(naming: UiNamingConfig) {
const configurations: UiConfigurations = {
uiNaming: naming,
terminConfig: this.terminConfig,
};

this.permitConfigs(configurations).subscribe({
next: (_) => this.infoService.success("Einstellungen gespeichert."),
error: (err) => this.infoService.error(err),
});
}

private permitConfigs(configurations: UiConfigurations): Observable<void> {
return this.configService.saveConfigs(configurations).pipe(
tap((res) => {
this.setInternalConfigs(res);
}),
map((_) => null)
);
}

private setInternalConfigs(config: UiConfigurations): void {
this._appNaming.next(config.uiNaming);
this._terminConfig.next(config.terminConfig);
}
}
27 changes: 0 additions & 27 deletions src/app/services/config.service.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/app/services/menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SubSink } from "subsink";
import { Permission, PermissionMap } from "../models/User";
import { AuthStateService } from "./authentication/auth-state.service";
import { UserService } from "./authentication/user.service";
import { AppNamingService } from "./config.service";
import { AppConfigService } from "./app-config.service";

@Injectable()
export class MenuService implements OnDestroy {
Expand Down Expand Up @@ -196,7 +196,7 @@ export class MenuService implements OnDestroy {
private authStateService: AuthStateService,
private confirmationService: ConfirmationService,
private userService: UserService,
private namingService: AppNamingService
private namingService: AppConfigService
) {
this.subSink.add(
this.userService.getCurrentUserPermissions().subscribe({
Expand Down

0 comments on commit 7a76c90

Please sign in to comment.