2020-03-26 17:44:12 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { BaseHttpParams } from '@common/http/base-http-params';
|
|
|
|
import { InterceptorType } from '@common/http/interceptors/interceptor-type';
|
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
|
|
|
import { catchError, takeUntil } from 'rxjs/operators';
|
|
|
|
import { Observable, throwError } from 'rxjs';
|
|
|
|
import { HelpService } from '@app/core/model/configuration-models/help-service.model';
|
|
|
|
import { Logging } from '@app/core/model/configuration-models/logging.model';
|
|
|
|
import { HttpClient } from '@angular/common/http';
|
2023-10-11 16:53:12 +02:00
|
|
|
import { KeycloakConfiguration } from '@app/core/model/configuration-models/keycloak-configuration.model';
|
2023-10-24 17:00:11 +02:00
|
|
|
import { Guid } from '@common/types/guid';
|
2020-03-26 17:44:12 +01:00
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root',
|
2020-12-10 14:29:24 +01:00
|
|
|
})
|
2020-03-26 17:44:12 +01:00
|
|
|
export class ConfigurationService extends BaseComponent {
|
|
|
|
|
|
|
|
constructor(private http: HttpClient) { super(); }
|
|
|
|
|
|
|
|
private _server: string;
|
|
|
|
get server(): string {
|
|
|
|
return this._server;
|
|
|
|
}
|
|
|
|
|
|
|
|
private _app: string;
|
|
|
|
get app(): string {
|
|
|
|
return this._app;
|
|
|
|
}
|
|
|
|
|
|
|
|
private _helpService: HelpService;
|
|
|
|
get helpService(): HelpService {
|
|
|
|
return this._helpService;
|
|
|
|
}
|
|
|
|
|
|
|
|
private _defaultCulture: string;
|
|
|
|
get defaultCulture(): string {
|
|
|
|
return this._defaultCulture;
|
|
|
|
}
|
|
|
|
|
2023-10-24 17:00:11 +02:00
|
|
|
private _defaultBlueprintId: Guid;
|
|
|
|
get defaultBlueprintId(): Guid {
|
|
|
|
return this._defaultBlueprintId;
|
|
|
|
}
|
|
|
|
|
2023-10-20 17:01:09 +02:00
|
|
|
private _defaultTimezone: string;
|
|
|
|
get defaultTimezone(): string {
|
|
|
|
return this._defaultTimezone || 'UTC';
|
|
|
|
}
|
|
|
|
|
2020-03-26 17:44:12 +01:00
|
|
|
private _logging: Logging;
|
|
|
|
get logging(): Logging {
|
|
|
|
return this._logging;
|
|
|
|
}
|
|
|
|
|
|
|
|
private _lockInterval: number;
|
|
|
|
get lockInterval(): number {
|
|
|
|
return this._lockInterval;
|
|
|
|
}
|
|
|
|
|
|
|
|
private _guideAssets: string;
|
2020-12-10 14:29:24 +01:00
|
|
|
get guideAssets(): string {
|
2020-03-26 17:44:12 +01:00
|
|
|
return this._guideAssets;
|
|
|
|
}
|
|
|
|
|
2020-04-23 09:48:14 +02:00
|
|
|
private _allowOrganizationCreator: boolean;
|
2020-12-10 14:29:24 +01:00
|
|
|
get allowOrganizationCreator(): boolean {
|
2020-04-23 09:48:14 +02:00
|
|
|
return this._allowOrganizationCreator;
|
|
|
|
}
|
|
|
|
|
2020-05-27 16:19:38 +02:00
|
|
|
private _useSplash: string;
|
|
|
|
get useSplash(): string {
|
|
|
|
return this._useSplash;
|
|
|
|
}
|
|
|
|
|
2020-07-02 17:29:33 +02:00
|
|
|
private _orcidPath: string;
|
|
|
|
get orcidPath(): string {
|
|
|
|
return this._orcidPath;
|
|
|
|
}
|
2020-03-26 17:44:12 +01:00
|
|
|
|
2020-12-10 14:29:24 +01:00
|
|
|
private _matomoEnabled: boolean;
|
|
|
|
get matomoEnabled(): boolean {
|
|
|
|
return this._matomoEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
private _matomoSiteUrl: string;
|
|
|
|
get matomoSiteUrl(): string {
|
|
|
|
return this._matomoSiteUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
private _matomoSiteId: number;
|
|
|
|
get matomoSiteId(): number {
|
|
|
|
return this._matomoSiteId;
|
|
|
|
}
|
|
|
|
|
2022-03-16 12:00:03 +01:00
|
|
|
private _maxFileSizeInMB: number;
|
|
|
|
get maxFileSizeInMB(): number {
|
|
|
|
return this._maxFileSizeInMB;
|
|
|
|
}
|
|
|
|
|
2023-10-11 16:53:12 +02:00
|
|
|
|
|
|
|
private _keycloak: KeycloakConfiguration;
|
|
|
|
get keycloak(): KeycloakConfiguration {
|
|
|
|
return this._keycloak;
|
|
|
|
}
|
|
|
|
|
2023-10-20 17:01:09 +02:00
|
|
|
private _userSettingsVersion: string;
|
|
|
|
get userSettingsVersion(): string {
|
|
|
|
return this._userSettingsVersion;
|
|
|
|
}
|
|
|
|
|
2023-12-20 17:02:55 +01:00
|
|
|
private _notificationServiceAddress: string;
|
|
|
|
get notificationServiceAddress(): string {
|
|
|
|
return this._notificationServiceAddress || './';
|
|
|
|
}
|
|
|
|
|
|
|
|
private _notificationServiceEnabled: boolean;
|
|
|
|
get notificationServiceEnabled(): boolean {
|
|
|
|
return this._notificationServiceEnabled;
|
|
|
|
}
|
2023-10-11 16:53:12 +02:00
|
|
|
|
2024-02-22 11:16:05 +01:00
|
|
|
private _annotationServiceAddress: string;
|
|
|
|
get annotationServiceAddress(): string {
|
2024-02-27 12:44:50 +01:00
|
|
|
return this._annotationServiceAddress || './';
|
2024-02-22 11:16:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private _annotationServiceEnabled: boolean;
|
|
|
|
get annotationServiceEnabled(): boolean {
|
2024-02-27 12:44:50 +01:00
|
|
|
return this._annotationServiceEnabled;
|
2024-02-22 11:16:05 +01:00
|
|
|
}
|
|
|
|
|
2024-01-09 14:52:07 +01:00
|
|
|
private _inAppNotificationsCountInterval: number;
|
|
|
|
get inAppNotificationsCountInterval(): number {
|
|
|
|
return this._inAppNotificationsCountInterval || 3200;
|
|
|
|
}
|
|
|
|
|
2024-03-20 17:06:05 +01:00
|
|
|
private _newReleaseNotificationLink: number;
|
|
|
|
get newReleaseNotificationLink(): number {
|
|
|
|
return this._newReleaseNotificationLink;
|
|
|
|
}
|
|
|
|
|
|
|
|
private _newReleaseNotificationExpires: number;
|
|
|
|
get newReleaseNotificationExpires(): number {
|
|
|
|
return this._newReleaseNotificationExpires;
|
|
|
|
}
|
|
|
|
|
|
|
|
private _newReleaseNotificationVersionCode: number;
|
|
|
|
get newReleaseNotificationVersionCode(): number {
|
|
|
|
return this._newReleaseNotificationVersionCode;
|
|
|
|
}
|
|
|
|
|
2020-03-26 17:44:12 +01:00
|
|
|
public loadConfiguration(): Promise<any> {
|
|
|
|
return new Promise((r, e) => {
|
|
|
|
// We need to exclude all interceptors here, for the initial configuration request.
|
|
|
|
const params = new BaseHttpParams();
|
|
|
|
params.interceptorContext = {
|
2023-10-11 16:53:12 +02:00
|
|
|
excludedInterceptors: [
|
|
|
|
InterceptorType.AuthToken,
|
|
|
|
InterceptorType.JSONContentType,
|
|
|
|
InterceptorType.Locale,
|
|
|
|
InterceptorType.ProgressIndication,
|
|
|
|
InterceptorType.RequestTiming,
|
|
|
|
InterceptorType.UnauthorizedResponse,
|
|
|
|
],
|
2020-03-26 17:44:12 +01:00
|
|
|
};
|
|
|
|
|
2023-10-11 16:53:12 +02:00
|
|
|
this.http
|
|
|
|
.get("./assets/config/config.json", { params: params })
|
|
|
|
.pipe(
|
|
|
|
catchError((err: any, caught: Observable<any>) =>
|
|
|
|
throwError(err)
|
|
|
|
)
|
|
|
|
)
|
2020-03-26 17:44:12 +01:00
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(
|
|
|
|
(content: ConfigurationService) => {
|
|
|
|
this.parseResponse(content);
|
|
|
|
r(this);
|
|
|
|
},
|
2023-10-11 16:53:12 +02:00
|
|
|
(reason) => e(reason)
|
|
|
|
);
|
2020-03-26 17:44:12 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-10-12 16:13:04 +02:00
|
|
|
|
2023-10-11 16:53:12 +02:00
|
|
|
|
2020-03-26 17:44:12 +01:00
|
|
|
private parseResponse(config: any) {
|
|
|
|
this._server = config.Server;
|
|
|
|
this._app = config.App;
|
|
|
|
this._helpService = HelpService.parseValue(config.HelpService);
|
|
|
|
this._defaultCulture = config.defaultCulture;
|
2023-10-24 17:00:11 +02:00
|
|
|
this._defaultBlueprintId = config.defaultBlueprintId;
|
2023-10-20 17:01:09 +02:00
|
|
|
this._defaultTimezone = config.defaultTimezone;
|
2023-10-11 16:53:12 +02:00
|
|
|
this._keycloak = KeycloakConfiguration.parseValue(config.keycloak);
|
2020-03-26 17:44:12 +01:00
|
|
|
this._logging = Logging.parseValue(config.logging);
|
|
|
|
this._lockInterval = config.lockInterval;
|
|
|
|
this._guideAssets = config.guideAssets;
|
2020-04-23 09:48:14 +02:00
|
|
|
this._allowOrganizationCreator = config.allowOrganizationCreator;
|
2020-05-27 16:19:38 +02:00
|
|
|
this._useSplash = config.useSplash;
|
2020-07-02 17:29:33 +02:00
|
|
|
this._orcidPath = config.orcidPath;
|
2020-12-10 14:29:24 +01:00
|
|
|
if (config.matomo) {
|
|
|
|
this._matomoEnabled = config.matomo.enabled;
|
|
|
|
this._matomoSiteUrl = config.matomo.url;
|
|
|
|
this._matomoSiteId = config.matomo.siteId;
|
|
|
|
}
|
2022-03-16 12:00:03 +01:00
|
|
|
this._maxFileSizeInMB = config.maxFileSizeInMB;
|
2023-10-20 17:01:09 +02:00
|
|
|
this._userSettingsVersion = config.userSettingsVersion;
|
2023-12-20 17:02:55 +01:00
|
|
|
if (config.notification_service) {
|
|
|
|
this._notificationServiceEnabled = config.notification_service.enabled;
|
|
|
|
this._notificationServiceAddress = config.notification_service.address;
|
|
|
|
}
|
2024-02-22 11:16:05 +01:00
|
|
|
if (config.annotation_service) {
|
|
|
|
this._annotationServiceEnabled = config.annotation_service.enabled;
|
|
|
|
this._annotationServiceAddress = config.annotation_service.address;
|
|
|
|
}
|
2024-01-09 14:52:07 +01:00
|
|
|
this._inAppNotificationsCountInterval = config.inAppNotificationsCountInterval;
|
2024-03-20 17:06:05 +01:00
|
|
|
this._newReleaseNotificationExpires = config.newReleaseNotification?.expires;
|
|
|
|
this._newReleaseNotificationLink = config.newReleaseNotification?.link;
|
|
|
|
this._newReleaseNotificationVersionCode = config.newReleaseNotification?.versionCode;
|
2020-03-26 17:44:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|