65 lines
1.6 KiB
TypeScript
65 lines
1.6 KiB
TypeScript
import { Injectable, signal } from '@angular/core';
|
|
import { take } from 'rxjs/operators';
|
|
import { ConfigService } from '../../core/config/config.service';
|
|
import { environment } from '../../../environments/environment';
|
|
|
|
interface UiRuntimeState {
|
|
brandName: string;
|
|
brandFullName: string;
|
|
logoUrl: string;
|
|
contactEmail: string;
|
|
themeId: string;
|
|
}
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
export class UiRuntimeFacade {
|
|
private readonly state = signal<UiRuntimeState>({
|
|
brandName: environment.brandName,
|
|
brandFullName: environment.brandFullName,
|
|
logoUrl: environment.logo,
|
|
contactEmail: environment.contactEmail,
|
|
themeId: environment.theme
|
|
});
|
|
|
|
constructor(private readonly configService: ConfigService) {
|
|
this.configService.loadBootstrap().pipe(take(1)).subscribe({
|
|
next: (bootstrap) => {
|
|
this.state.set({
|
|
brandName: bootstrap.branding.brandName,
|
|
brandFullName: bootstrap.branding.brandName,
|
|
logoUrl: bootstrap.branding.logoUrl,
|
|
contactEmail: bootstrap.branding.supportEmail ?? environment.contactEmail,
|
|
themeId: bootstrap.theme.themeId
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
brandName(): string {
|
|
return this.state().brandName;
|
|
}
|
|
|
|
brandFullName(): string {
|
|
return this.state().brandFullName;
|
|
}
|
|
|
|
logoUrl(): string {
|
|
return this.state().logoUrl;
|
|
}
|
|
|
|
contactEmail(): string {
|
|
return this.state().contactEmail;
|
|
}
|
|
|
|
themeId(): string {
|
|
return this.state().themeId;
|
|
}
|
|
|
|
isNovo(): boolean {
|
|
return this.themeId().includes('novo');
|
|
}
|
|
|
|
isLavero(): boolean {
|
|
return this.themeId().includes('lavero');
|
|
}
|
|
} |