update config service, remove app bootstrapped & config module

This commit is contained in:
Dan Percic 2021-09-20 14:23:22 +03:00
parent 6557bafd2f
commit 8634361a5e
24 changed files with 138 additions and 193 deletions

View File

@ -30,13 +30,14 @@ import { MONACO_PATH, MonacoEditorModule } from '@materia-ui/ngx-monaco-editor';
import { GlobalErrorHandler } from '@utils/global-error-handler.service';
import { REDMissingTranslationHandler } from '@utils/missing-translations-handler';
import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler';
import { configurationInitializer } from '@app-config/configuration.initializer';
import { AppConfigService } from '@app-config/app-config.service';
import { configurationInitializer } from '@utils/configuration.initializer';
import { ConfigService } from '@services/config.service';
import { SpotlightSearchComponent } from '@components/spotlight-search/spotlight-search.component';
import { PruningTranslationLoader } from '@utils/pruning-translation-loader';
import { DatePipe } from '@shared/pipes/date.pipe';
import * as links from '../assets/help-mode/links.json';
import { HELP_DOCS, IqserHelpModeModule, MAX_RETRIES_ON_SERVER_ERROR, ServerErrorInterceptor } from '@iqser/common-ui';
import { KeycloakService } from 'keycloak-angular';
export function httpLoaderFactory(httpClient: HttpClient): PruningTranslationLoader {
return new PruningTranslationLoader(httpClient, '/assets/i18n/', '.json');
@ -130,7 +131,7 @@ const components = [
provide: APP_INITIALIZER,
multi: true,
useFactory: configurationInitializer,
deps: [Title, AppConfigService, GeneralSettingsControllerService]
deps: [KeycloakService, Title, ConfigService, GeneralSettingsControllerService]
},
{
provide: MONACO_PATH,
@ -146,8 +147,8 @@ const components = [
},
{
provide: MAX_RETRIES_ON_SERVER_ERROR,
useFactory: (appConfigService: AppConfigService) => appConfigService.config.MAX_RETRIES_ON_SERVER_ERROR,
deps: [AppConfigService]
useFactory: (configService: ConfigService) => configService.values.MAX_RETRIES_ON_SERVER_ERROR,
deps: [ConfigService]
},
DatePipe
],

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { UserService } from '@services/user.service';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
@Component({
selector: 'redaction-auth-error',
@ -8,8 +8,8 @@ import { AppConfigService } from '@app-config/app-config.service';
styleUrls: ['./auth-error.component.scss']
})
export class AuthErrorComponent {
adminName = this._appConfigService.config.ADMIN_CONTACT_NAME;
adminUrl = this._appConfigService.config.ADMIN_CONTACT_URL;
adminName = this._configService.values.ADMIN_CONTACT_NAME;
adminUrl = this._configService.values.ADMIN_CONTACT_URL;
constructor(readonly userService: UserService, private readonly _appConfigService: AppConfigService) {}
constructor(readonly userService: UserService, private readonly _configService: ConfigService) {}
}

View File

@ -5,7 +5,7 @@ import { PermissionsService } from '@services/permissions.service';
import { LanguageService } from '@i18n/language.service';
import { TranslateService } from '@ngx-translate/core';
import { UserControllerService } from '@redaction/red-ui-http';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import { DomSanitizer } from '@angular/platform-browser';
import { languagesTranslations } from '../../translations/languages-translations';
import { LoadingService } from '@iqser/common-ui';
@ -26,7 +26,7 @@ export class UserProfileScreenComponent implements OnInit {
readonly permissionsService: PermissionsService,
private readonly _formBuilder: FormBuilder,
private readonly _userService: UserService,
private readonly _appConfigService: AppConfigService,
private readonly _configService: ConfigService,
private readonly _userControllerService: UserControllerService,
private readonly _languageService: LanguageService,
private readonly _domSanitizer: DomSanitizer,
@ -42,7 +42,7 @@ export class UserProfileScreenComponent implements OnInit {
});
this.changePasswordUrl = this._domSanitizer.bypassSecurityTrustResourceUrl(
this._appConfigService.config.OAUTH_URL + '/account/password'
this._configService.values.OAUTH_URL + '/account/password'
);
}

View File

@ -7,7 +7,7 @@ import {
SmtpConfigurationControllerService,
SMTPConfigurationModel
} from '@redaction/red-ui-http';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import { AutoUnsubscribe, IconButtonTypes, LoadingService, Toaster } from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { UserService } from '@services/user.service';
@ -33,7 +33,7 @@ export class GeneralConfigScreenComponent extends AutoUnsubscribe implements OnI
private readonly _formBuilder: FormBuilder,
private readonly _loadingService: LoadingService,
private readonly _dialogService: AdminDialogService,
private readonly _appConfigService: AppConfigService,
private readonly _configService: ConfigService,
private readonly _smtpConfigService: SmtpConfigurationControllerService,
private readonly _generalSettingsControllerService: GeneralSettingsControllerService
) {
@ -112,7 +112,7 @@ export class GeneralConfigScreenComponent extends AutoUnsubscribe implements OnI
await this._generalSettingsControllerService.updateGeneralConfigurations(configFormValues).toPromise();
this._initialGeneralConfiguration = await this._generalSettingsControllerService.getGeneralConfigurations().toPromise();
this._appConfigService.updateDisplayName(this._initialGeneralConfiguration.displayName);
this._configService.updateDisplayName(this._initialGeneralConfiguration.displayName);
this._loadingService.stop();
}

View File

@ -16,17 +16,17 @@
<div class="grid-container">
<div class="row">
<div translate="license-info-screen.backend-version"></div>
<div>{{ appConfigService.config.BACKEND_APP_VERSION || '-' }}</div>
<div>{{ configService.values.BACKEND_APP_VERSION || '-' }}</div>
</div>
<div class="row">
<div translate="license-info-screen.frontend-version"></div>
<div>{{ appConfigService.config.FRONTEND_APP_VERSION || '-' }}</div>
<div>{{ configService.values.FRONTEND_APP_VERSION || '-' }}</div>
</div>
<div class="row">
<div translate="license-info-screen.custom-app-title"></div>
<div>{{ appConfigService.config.APP_NAME || '-' }}</div>
<div>{{ configService.values.APP_NAME || '-' }}</div>
</div>
<div class="row">
@ -45,14 +45,14 @@
<div class="row">
<div translate="license-info-screen.licensed-to"></div>
<div>{{ appConfigService.config.LICENSE_CUSTOMER || '-' }}</div>
<div>{{ configService.values.LICENSE_CUSTOMER || '-' }}</div>
</div>
<div class="row">
<div translate="license-info-screen.licensing-period"></div>
<div>
{{ appConfigService.config.LICENSE_START || '-' }} /
{{ appConfigService.config.LICENSE_END || '-' }}
{{ configService.values.LICENSE_START || '-' }} /
{{ configService.values.LICENSE_END || '-' }}
</div>
</div>

View File

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { LicenseReport, LicenseReportControllerService } from '@redaction/red-ui-http';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import * as moment from 'moment';
import { TranslateService } from '@ngx-translate/core';
import { IconButtonTypes, LoadingService } from '@iqser/common-ui';
@ -45,8 +45,8 @@ export class LicenseInformationScreenComponent implements OnInit {
};
constructor(
readonly configService: ConfigService,
private readonly _userService: UserService,
readonly appConfigService: AppConfigService,
private readonly _loadingService: LoadingService,
readonly routerHistoryService: RouterHistoryService,
private readonly _translateService: TranslateService,
@ -60,9 +60,9 @@ export class LicenseInformationScreenComponent implements OnInit {
}
async ngOnInit() {
this.totalLicensedNumberOfPages = this.appConfigService.config.LICENSE_PAGE_COUNT || 0;
const startDate = moment(this.appConfigService.config.LICENSE_START, 'DD-MM-YYYY');
const endDate = moment(this.appConfigService.config.LICENSE_END, 'DD-MM-YYYY');
this.totalLicensedNumberOfPages = this.configService.values.LICENSE_PAGE_COUNT || 0;
const startDate = moment(this.configService.values.LICENSE_START, 'DD-MM-YYYY');
const endDate = moment(this.configService.values.LICENSE_END, 'DD-MM-YYYY');
await this._setMonthlyStats(startDate, endDate);
@ -93,7 +93,7 @@ export class LicenseInformationScreenComponent implements OnInit {
}
sendMail(): void {
const licenseCustomer = this.appConfigService.config.LICENSE_CUSTOMER;
const licenseCustomer = this.configService.values.LICENSE_CUSTOMER;
const subject = this._translateService.instant('license-info-screen.email.title', {
licenseCustomer
});
@ -106,7 +106,7 @@ export class LicenseInformationScreenComponent implements OnInit {
pages: this.totalLicensedNumberOfPages
})
].join(lineBreak);
window.location.href = `mailto:${this.appConfigService.config.LICENSE_EMAIL}?subject=${subject}&body=${body}`;
window.location.href = `mailto:${this.configService.values.LICENSE_EMAIL}?subject=${subject}&body=${body}`;
}
private async _setMonthlyStats(startDate: moment.Moment, endDate: moment.Moment) {

View File

@ -9,7 +9,7 @@ import {
SortingOrders,
TableColumnConfig
} from '@iqser/common-ui';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import * as moment from 'moment';
import { DossiersService } from '../../../dossier/services/dossiers.service';
import { AdminDialogService } from '../../services/admin-dialog.service';
@ -45,14 +45,14 @@ export class TrashScreenComponent extends ListingComponent<DossierListItem> impl
@ViewChild('deletedTimeTemplate', { static: true }) deletedTimeTemplate: TemplateRef<never>;
@ViewChild('restoreDateTemplate', { static: true }) restoreDateTemplate: TemplateRef<never>;
protected readonly _primaryKey = 'dossierName';
private readonly _deleteRetentionHours = this._appConfigService.config.DELETE_RETENTION_HOURS;
private readonly _deleteRetentionHours = this._configService.values.DELETE_RETENTION_HOURS;
constructor(
protected readonly _injector: Injector,
private readonly _loadingService: LoadingService,
private readonly _dossiersService: DossiersService,
readonly routerHistoryService: RouterHistoryService,
private readonly _appConfigService: AppConfigService,
private readonly _configService: ConfigService,
private readonly _adminDialogService: AdminDialogService
) {
super(_injector);

View File

@ -1,11 +0,0 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { AppConfigService } from './app-config.service';
@NgModule({
declarations: [],
imports: [CommonModule, HttpClientModule],
providers: [AppConfigService]
})
export class AppConfigModule {}

View File

@ -1,73 +0,0 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Title } from '@angular/platform-browser';
import packageInfo from '../../../../../../package.json';
import config from '../../../assets/config/config.json';
import { CacheApiService, wipeCaches } from '@redaction/red-cache';
const version = packageInfo.version;
export const enum AppConfigKey {
OAUTH_URL = 'OAUTH_URL',
OAUTH_CLIENT_ID = 'OAUTH_CLIENT_ID',
OAUTH_IDP_HINT = 'OAUTH_IDP_HINT',
API_URL = 'API_URL',
ADMIN_CONTACT_NAME = 'ADMIN_CONTACT_NAME',
ADMIN_CONTACT_URL = 'ADMIN_CONTACT_URL',
AUTO_READ_TIME = 'AUTO_READ_TIME',
SELECTION_MODE = 'SELECTION_MODE',
MAX_FILE_SIZE_MB = 'MAX_FILE_SIZE_MB',
RECENT_PERIOD_IN_HOURS = 'RECENT_PERIOD_IN_HOURS',
DELETE_RETENTION_HOURS = 'DELETE_RETENTION_HOURS',
APP_NAME = 'APP_NAME',
MAX_RETRIES_ON_SERVER_ERROR = 'MAX_RETRIES_ON_SERVER_ERROR',
// TODO
BACKEND_APP_VERSION = 'BACKEND_APP_VERSION',
FRONTEND_APP_VERSION = 'FRONTEND_APP_VERSION',
EULA_URL = 'EULA_URL',
LICENSE_CUSTOMER = 'LICENSE_CUSTOMER',
LICENSE_EMAIL = 'LICENSE_EMAIL',
LICENSE_START = 'LICENSE_START',
LICENSE_END = 'LICENSE_END',
LICENSE_PAGE_COUNT = 'LICENSE_PAGE_COUNT'
}
@Injectable({
providedIn: 'root'
})
export class AppConfigService {
private _config = { ...config, [AppConfigKey.FRONTEND_APP_VERSION]: version } as const;
constructor(
private readonly _httpClient: HttpClient,
private readonly _cacheApiService: CacheApiService,
private readonly _titleService: Title
) {
this._checkFrontendVersion();
}
private _checkFrontendVersion(): void {
this._cacheApiService.getCachedValue(AppConfigKey.FRONTEND_APP_VERSION).then(async lastVersion => {
console.log('[REDACTION] Last app version: ', lastVersion, ' current version ', version);
if (lastVersion !== version) {
console.warn('[REDACTION] Version-mismatch - wiping caches!');
await wipeCaches();
}
await this._cacheApiService.cacheValue(AppConfigKey.FRONTEND_APP_VERSION, version);
});
}
get config() {
return this._config;
}
updateDisplayName(name: string): void {
this._config = { ...this._config, [AppConfigKey.APP_NAME]: name } as const;
this._titleService.setTitle(this._config.APP_NAME || 'RedactManager');
}
getConfig(key: AppConfigKey, defaultValue?: string): string | number {
return this._config[key] ?? defaultValue;
}
}

View File

@ -1,28 +0,0 @@
import { GeneralSettingsControllerService } from '@redaction/red-ui-http';
import { catchError, mergeMap, take, tap } from 'rxjs/operators';
import { AppConfigService } from './app-config.service';
import { Title } from '@angular/platform-browser';
import { APP_BOOTSTRAPPED } from '../bootstrap/app-bootstrap';
import { of } from 'rxjs';
export function configurationInitializer(
title: Title,
appConfigService: AppConfigService,
generalSettingsControllerService: GeneralSettingsControllerService
) {
return () =>
APP_BOOTSTRAPPED.pipe(
mergeMap(() =>
generalSettingsControllerService.getGeneralConfigurations().pipe(
tap(configuration => {
appConfigService.updateDisplayName(configuration.displayName);
})
)
),
catchError(() => {
title.setTitle('RedactManager');
return of({});
}),
take(1)
).toPromise();
}

View File

@ -2,7 +2,7 @@ import { Inject, Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
import { KeycloakAuthGuard, KeycloakService } from 'keycloak-angular';
import { UserService } from '@services/user.service';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import { BASE_HREF } from '../../tokens';
@Injectable({
@ -13,7 +13,7 @@ export class AuthGuard extends KeycloakAuthGuard {
@Inject(BASE_HREF) private readonly _baseHref: string,
protected readonly _router: Router,
protected readonly _keycloak: KeycloakService,
private readonly _appConfigService: AppConfigService,
private readonly _configService: ConfigService,
private readonly _userService: UserService
) {
super(_router, _keycloak);
@ -22,7 +22,7 @@ export class AuthGuard extends KeycloakAuthGuard {
async isAccessAllowed(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
if (!this.authenticated) {
await this._keycloak.login({
idpHint: this._appConfigService.config.OAUTH_IDP_HINT,
idpHint: this._configService.values.OAUTH_IDP_HINT,
redirectUri: window.location.origin + this._baseHref + state.url
});
return false;

View File

@ -1,19 +1,13 @@
import { APP_INITIALIZER, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { AppConfigModule } from '@app-config/app-config.module';
import { KeycloakAngularModule, KeycloakOptions, KeycloakService } from 'keycloak-angular';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import { BASE_HREF } from '../../tokens';
import { APP_BOOTSTRAPPED } from '../bootstrap/app-bootstrap';
export function keycloakInitializer(
keycloakService: KeycloakService,
appConfigService: AppConfigService,
baseUrl: string
): () => Promise<void> {
let url = appConfigService.config.OAUTH_URL;
export function keycloakInitializer(keycloakService: KeycloakService, configService: ConfigService, baseUrl: string): () => Promise<void> {
let url = configService.values.OAUTH_URL;
url = url.replace(/\/$/, ''); // remove trailing slash
const realm = url.substring(url.lastIndexOf('/') + 1, url.length);
url = url.substr(0, url.lastIndexOf('/realms'));
@ -21,7 +15,7 @@ export function keycloakInitializer(
config: {
url: url,
realm: realm,
clientId: appConfigService.config.OAUTH_CLIENT_ID
clientId: configService.values.OAUTH_CLIENT_ID
},
initOptions: {
checkLoginIframe: false,
@ -31,11 +25,7 @@ export function keycloakInitializer(
},
enableBearerInterceptor: true
};
return () =>
keycloakService
.init(options)
.then(() => configureAutomaticRedirectToLoginScreen(keycloakService))
.then(() => APP_BOOTSTRAPPED.next(true));
return () => keycloakService.init(options).then(() => configureAutomaticRedirectToLoginScreen(keycloakService));
}
function configureAutomaticRedirectToLoginScreen(keyCloakService: KeycloakService) {
@ -45,13 +35,13 @@ function configureAutomaticRedirectToLoginScreen(keyCloakService: KeycloakServic
}
@NgModule({
imports: [CommonModule, HttpClientModule, KeycloakAngularModule, AppConfigModule],
imports: [CommonModule, HttpClientModule, KeycloakAngularModule],
providers: [
{
provide: APP_INITIALIZER,
useFactory: keycloakInitializer,
multi: true,
deps: [KeycloakService, AppConfigService, BASE_HREF]
deps: [KeycloakService, ConfigService, BASE_HREF]
}
]
})

View File

@ -1,3 +0,0 @@
import { ReplaySubject } from 'rxjs';
export const APP_BOOTSTRAPPED = new ReplaySubject<boolean>();

View File

@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, S
import { ViewedPages, ViewedPagesControllerService } from '@redaction/red-ui-http';
import { AppStateService } from '@state/app-state.service';
import { PermissionsService } from '@services/permissions.service';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import { Subscription } from 'rxjs';
@Component({
@ -25,7 +25,7 @@ export class PageIndicatorComponent implements OnChanges, OnInit, OnDestroy {
constructor(
private readonly _viewedPagesControllerService: ViewedPagesControllerService,
private readonly _appStateService: AppStateService,
private readonly _appConfigService: AppConfigService,
private readonly _configService: ConfigService,
private readonly _permissionService: PermissionsService
) {}
@ -71,7 +71,7 @@ export class PageIndicatorComponent implements OnChanges, OnInit, OnDestroy {
if (this.active && !this.read) {
this._markPageRead();
}
}, this._appConfigService.config.AUTO_READ_TIME * 1000);
}, this._configService.values.AUTO_READ_TIME * 1000);
}
}
}

View File

@ -23,7 +23,7 @@ import { AnnotationDrawService } from '../../services/annotation-draw.service';
import { AnnotationActionsService } from '../../services/annotation-actions.service';
import { UserPreferenceService } from '@services/user-preference.service';
import { BASE_HREF } from '../../../../tokens';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import { LoadingService } from '@iqser/common-ui';
import { DossiersDialogService } from '../../services/dossiers-dialog.service';
import { ConfirmationDialogInput } from '@shared/dialogs/confirmation-dialog/confirmation-dialog.component';
@ -73,7 +73,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
private readonly _userPreferenceService: UserPreferenceService,
private readonly _annotationDrawService: AnnotationDrawService,
private readonly _annotationActionsService: AnnotationActionsService,
private readonly _appConfigService: AppConfigService,
private readonly _configService: ConfigService,
private readonly _loadingService: LoadingService
) {}
@ -298,7 +298,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
private _setSelectionMode(): void {
const textTool = (<unknown>this.instance.Core.Tools.TextTool) as TextTool;
textTool.SELECTION_MODE = this._appConfigService.config.SELECTION_MODE;
textTool.SELECTION_MODE = this._configService.values.SELECTION_MODE;
}
private _toggleRectangleAnnotationAction(readonly: boolean) {

View File

@ -13,7 +13,7 @@ import {
import { FileManagementControllerService, FileStatus, StatusControllerService } from '@redaction/red-ui-http';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import * as moment from 'moment';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import { getLeftDateTime } from '@utils/functions';
import { Observable } from 'rxjs';
import { distinctUntilChanged, map } from 'rxjs/operators';
@ -44,7 +44,7 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent<FileL
tableColumnConfigs: TableColumnConfig<FileListItem>[];
readonly tableHeaderLabel = _('edit-dossier-dialog.deleted-documents.table-header.label');
readonly circleButtonTypes = CircleButtonTypes;
readonly deleteRetentionHours = this._appConfigService.config.DELETE_RETENTION_HOURS;
readonly deleteRetentionHours = this._configService.values.DELETE_RETENTION_HOURS;
@ViewChild('filenameTemplate', { static: true }) filenameTemplate: TemplateRef<never>;
@ViewChild('pagesTemplate', { static: true }) pagesTemplate: TemplateRef<never>;
@ViewChild('deletedDateTemplate', { static: true }) deletedDateTemplate: TemplateRef<never>;
@ -57,7 +57,7 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent<FileL
private readonly _fileManagementController: FileManagementControllerService,
private readonly _appStateService: AppStateService,
private readonly _loadingService: LoadingService,
private readonly _appConfigService: AppConfigService,
private readonly _configService: ConfigService,
private readonly _dialogService: DossiersDialogService
) {
super(_injector);

View File

@ -27,7 +27,7 @@ import { StatusSorter } from '@utils/sorters/status-sorter';
import { convertFiles, handleFileDrop } from '@utils/file-drop-utils';
import { DossiersDialogService } from '../../services/dossiers-dialog.service';
import { OnAttach, OnDetach } from '@utils/custom-route-reuse.strategy';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import { ActionConfig } from '@shared/components/page-header/models/action-config.model';
import {
CircleButtonTypes,
@ -50,7 +50,7 @@ import { annotationFilterChecker } from '@utils/filter-utils';
import { PermissionsService } from '@services/permissions.service';
import { RouterHistoryService } from '@services/router-history.service';
import { FileAttributeConfig } from '@redaction/red-ui-http';
import { DossierWrapper } from '../../../../state/model/dossier.wrapper';
import { DossierWrapper } from '@state/model/dossier.wrapper';
@Component({
templateUrl: './dossier-overview-screen.component.html',
@ -98,7 +98,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<FileStatusW
private readonly _loadingService: LoadingService,
private readonly _appStateService: AppStateService,
readonly routerHistoryService: RouterHistoryService,
private readonly _appConfigService: AppConfigService,
private readonly _configService: ConfigService,
private readonly _translateService: TranslateService,
private readonly _dialogService: DossiersDialogService,
private readonly _changeDetectorRef: ChangeDetectorRef,
@ -256,7 +256,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<FileStatusW
}
recentlyModifiedChecker = (file: FileStatusWrapper) =>
moment(file.lastUpdated).add(this._appConfigService.config.RECENT_PERIOD_IN_HOURS, 'hours').isAfter(moment());
moment(file.lastUpdated).add(this._configService.values.RECENT_PERIOD_IN_HOURS, 'hours').isAfter(moment());
private _configureTableColumns() {
const dynamicColumns: TableColumnConfig<FileStatusWrapper>[] = [];
@ -472,7 +472,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<FileStatusW
private _createQuickFilters() {
let quickFilters = [];
if (this.entitiesService.all.filter(this.recentlyModifiedChecker).length > 0) {
const recentPeriod = this._appConfigService.config.RECENT_PERIOD_IN_HOURS;
const recentPeriod = this._configService.values.RECENT_PERIOD_IN_HOURS;
quickFilters = [
{
key: 'recent',

View File

@ -10,7 +10,7 @@ import { ManualAnnotationService } from './manual-annotation.service';
import { ManualAnnotationDialogComponent } from '../dialogs/manual-redaction-dialog/manual-annotation-dialog.component';
import { EditDossierDialogComponent } from '../dialogs/edit-dossier-dialog/edit-dossier-dialog.component';
import { AssignReviewerApproverDialogComponent } from '../dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import { ChangeLegalBasisDialogComponent } from '../dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component';
import { RecategorizeImageDialogComponent } from '../dialogs/recategorize-image-dialog/recategorize-image-dialog.component';
import { DialogService, largeDialogConfig } from '@shared/services/dialog.service';
@ -78,7 +78,7 @@ export class DossiersDialogService extends DialogService<DialogType> {
protected readonly _dialog: MatDialog,
private readonly _appStateService: AppStateService,
private readonly _manualAnnotationService: ManualAnnotationService,
private readonly _appConfigService: AppConfigService
private readonly _configService: ConfigService
) {
super(_dialog);
}

View File

@ -1,7 +1,7 @@
import { ApplicationRef, Injectable } from '@angular/core';
import { DownloadControllerService, FileManagementControllerService } from '@redaction/red-ui-http';
import { interval, Observable } from 'rxjs';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import { TranslateService } from '@ngx-translate/core';
import { DossierWrapper } from '@state/model/dossier.wrapper';
import { FileStatusWrapper } from '@models/file/file-status.wrapper';
@ -23,7 +23,7 @@ export class FileDownloadService {
private readonly _keycloakService: KeycloakService,
private readonly _appStateService: AppStateService,
private readonly _translateService: TranslateService,
private readonly _appConfigService: AppConfigService,
private readonly _configService: ConfigService,
private readonly _downloadControllerService: DownloadControllerService,
private readonly _fileManagementControllerService: FileManagementControllerService
) {
@ -56,7 +56,7 @@ export class FileDownloadService {
const token = await this._keycloakService.getToken();
const anchor = document.createElement('a');
anchor.href =
this._appConfigService.config.API_URL +
this._configService.values.API_URL +
'/async/download?access_token=' +
encodeURIComponent(token) +
'&storageId=' +

View File

@ -3,7 +3,7 @@ import { FileUploadModel } from '../model/file-upload.model';
import { AppStateService } from '@state/app-state.service';
import { HttpErrorResponse, HttpEventType } from '@angular/common/http';
import { interval, Subscription } from 'rxjs';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import { TranslateService } from '@ngx-translate/core';
import { UploadDownloadDialogService } from './upload-download-dialog.service';
import { toNumber } from '@utils/functions';
@ -30,7 +30,7 @@ export class FileUploadService {
private readonly _appStateService: AppStateService,
private readonly _applicationRef: ApplicationRef,
private readonly _translateService: TranslateService,
private readonly _appConfigService: AppConfigService,
private readonly _configService: ConfigService,
private readonly _uploadControllerService: UploadControllerService,
private readonly _dialogService: UploadDownloadDialogService,
private readonly _errorMessageService: ErrorMessageService
@ -55,10 +55,10 @@ export class FileUploadService {
}
async uploadFiles(files: FileUploadModel[]): Promise<number> {
const maxSizeMB = this._appConfigService.config.MAX_FILE_SIZE_MB;
const maxSizeMB = this._configService.values.MAX_FILE_SIZE_MB;
const maxSizeBytes = toNumber(maxSizeMB) * 1024 * 1024;
const dossierFiles = this._appStateService.activeDossier.files;
let option: 'overwrite' | 'skip' | undefined;
let option: 'overwrite' | 'skip';
for (let idx = 0; idx < files.length; ++idx) {
const file = files[idx];
let currentOption = option;

View File

@ -0,0 +1,43 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Title } from '@angular/platform-browser';
import packageInfo from '../../../../../package.json';
import config from '../../assets/config/config.json';
import { CacheApiService, wipeCaches } from '@redaction/red-cache';
const version = packageInfo.version;
@Injectable({
providedIn: 'root'
})
export class ConfigService {
private _values = { ...config, FRONTEND_APP_VERSION: version } as const;
constructor(
private readonly _httpClient: HttpClient,
private readonly _cacheApiService: CacheApiService,
private readonly _titleService: Title
) {
this._checkFrontendVersion();
}
private _checkFrontendVersion(): void {
this._cacheApiService.getCachedValue('FRONTEND_APP_VERSION').then(async lastVersion => {
console.log('[REDACTION] Last app version: ', lastVersion, ' current version ', version);
if (lastVersion !== version) {
console.warn('[REDACTION] Version-mismatch - wiping caches!');
await wipeCaches();
}
await this._cacheApiService.cacheValue('FRONTEND_APP_VERSION', version);
});
}
get values() {
return this._values;
}
updateDisplayName(name: string): void {
this._values = { ...this._values, APP_NAME: name } as const;
this._titleService.setTitle(this._values.APP_NAME || 'RedactManager');
}
}

View File

@ -1,17 +1,17 @@
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Inject, Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { AppConfigService } from '@app-config/app-config.service';
import { ConfigService } from '@services/config.service';
import { BASE_HREF } from '../tokens';
@Injectable()
export class ApiPathInterceptor implements HttpInterceptor {
constructor(@Inject(BASE_HREF) private readonly _baseHref: string, private readonly _appConfigService: AppConfigService) {}
constructor(@Inject(BASE_HREF) private readonly _baseHref: string, private readonly _configService: ConfigService) {}
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
if (!req.url.startsWith('/assets')) {
const updatedRequest = req.clone({
url: this._appConfigService.config.API_URL + req.url
url: this._configService.values.API_URL + req.url
});
return next.handle(updatedRequest);
} else {

View File

@ -0,0 +1,27 @@
import { GeneralSettingsControllerService } from '@redaction/red-ui-http';
import { catchError, filter, mergeMap, take, tap } from 'rxjs/operators';
import { ConfigService } from '@services/config.service';
import { Title } from '@angular/platform-browser';
import { of } from 'rxjs';
import { KeycloakEventType, KeycloakService } from 'keycloak-angular';
export function configurationInitializer(
keycloakService: KeycloakService,
title: Title,
configService: ConfigService,
generalSettingsControllerService: GeneralSettingsControllerService
) {
return () =>
keycloakService.keycloakEvents$
.pipe(
filter(event => event.type === KeycloakEventType.OnReady),
mergeMap(() => generalSettingsControllerService.getGeneralConfigurations()),
tap(configuration => configService.updateDisplayName(configuration.displayName)),
catchError(() => {
title.setTitle('RedactManager');
return of({});
}),
take(1)
)
.toPromise();
}

View File

@ -17,7 +17,6 @@
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
"@app-config/*": ["apps/red-ui/src/app/modules/app-config/*"],
"@components/*": ["apps/red-ui/src/app/components/*"],
"@environments/*": ["apps/red-ui/src/environments/*"],
"@guards/*": ["apps/red-ui/src/app/guards/*"],