From 1d9b5b4d69623e82e893f5c6ad15406557e955dd Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Fri, 31 Mar 2023 12:31:42 +0300 Subject: [PATCH] RED-6523 - multitenancy --- apps/red-ui/src/app/app-routing.module.ts | 12 ++++++--- apps/red-ui/src/app/app.module.ts | 18 +++++-------- .../base-screen/base-screen.component.html | 4 +++ .../base-screen/base-screen.component.ts | 13 +++++++--- .../src/app/guards/dossier-files-guard.ts | 4 ++- .../guards/dossier-template-exists.guard.ts | 6 +++-- apps/red-ui/src/app/guards/dossiers.guard.ts | 4 ++- .../app/guards/entity-exists-guard.service.ts | 4 ++- .../src/app/guards/watermark-exists.guard.ts | 16 ++++++++++-- .../base-entity-screen.component.ts | 5 ++-- .../watermark-screen.component.ts | 8 +++++- .../dossier-template-actions.component.ts | 12 +++++++-- .../file-preview-screen.component.ts | 4 ++- .../file-actions/file-actions.component.ts | 4 ++- .../edit-dossier-general-info.component.ts | 13 ++++++++-- .../add-dossier-dialog.component.ts | 5 ++-- .../services/file-download.service.ts | 7 +++--- .../dossiers/archived-dossiers.service.ts | 4 ++- .../app/services/router-history.service.ts | 7 ++++-- apps/red-ui/src/app/users/red-role.guard.ts | 15 +++++------ .../app/utils/configuration.initializer.ts | 15 +++++++---- apps/red-ui/src/app/utils/tenant-context.ts | 8 ------ .../src/app/utils/tenant-id-interceptor.ts | 16 ------------ .../utils/tenant-id-response-interceptor.ts | 22 ---------------- apps/red-ui/src/assets/config/config.json | 4 +-- apps/red-ui/src/assets/i18n/redact/de.json | 25 +++++++++++-------- apps/red-ui/src/assets/i18n/redact/en.json | 25 +++++++++++-------- apps/red-ui/src/assets/i18n/scm/de.json | 19 ++++++++++---- apps/red-ui/src/assets/i18n/scm/en.json | 19 ++++++++++---- libs/common-ui | 2 +- 30 files changed, 185 insertions(+), 135 deletions(-) delete mode 100644 apps/red-ui/src/app/utils/tenant-context.ts delete mode 100644 apps/red-ui/src/app/utils/tenant-id-interceptor.ts delete mode 100644 apps/red-ui/src/app/utils/tenant-id-response-interceptor.ts diff --git a/apps/red-ui/src/app/app-routing.module.ts b/apps/red-ui/src/app/app-routing.module.ts index a42c3cb55..b6820fa72 100644 --- a/apps/red-ui/src/app/app-routing.module.ts +++ b/apps/red-ui/src/app/app-routing.module.ts @@ -6,6 +6,7 @@ import { IqserAuthGuard, IqserPermissionsGuard, IqserRoutes, + TenantResolveComponent, } from '@iqser/common-ui'; import { RedRoleGuard } from '@users/red-role.guard'; import { BaseScreenComponent } from '@components/base-screen/base-screen.component'; @@ -96,11 +97,14 @@ const dossierTemplateIdRoutes: IqserRoutes = [ const routes: IqserRoutes = [ { path: '', - redirectTo: 'main', - pathMatch: 'full', + component: TenantResolveComponent, }, { - path: 'main', + path: ':tenant', + component: TenantResolveComponent, + }, + { + path: ':tenant/main', component: BaseScreenComponent, children: [ { @@ -212,7 +216,7 @@ const routes: IqserRoutes = [ ], }, { - path: 'auth-error', + path: ':tenant/auth-error', component: AuthErrorComponent, canActivate: [IqserAuthGuard], }, diff --git a/apps/red-ui/src/app/app.module.ts b/apps/red-ui/src/app/app.module.ts index 4da89584c..65adfd2ba 100644 --- a/apps/red-ui/src/app/app.module.ts +++ b/apps/red-ui/src/app/app.module.ts @@ -12,6 +12,7 @@ import { CommonUiModule, EmptyStateComponent, HiddenActionDirective, + IconButtonComponent, InputWithActionComponent, IqserAllowDirective, IqserDenyDirective, @@ -21,6 +22,7 @@ import { IqserPermissionsService, IqserTranslateModule, IqserUsersModule, + KeycloakStatusService, LanguageService, LogoComponent, MAX_RETRIES_ON_SERVER_ERROR, @@ -29,6 +31,7 @@ import { ServerErrorInterceptor, SkeletonComponent, StopPropagationDirective, + TenantsModule, ToastComponent, } from '@iqser/common-ui'; import { ToastrModule } from 'ngx-toastr'; @@ -66,13 +69,11 @@ import { AppConfig, ILoggerConfig } from '@red/domain'; import { SystemPreferencesService } from '@services/system-preferences.service'; import { PdfViewerModule } from './modules/pdf-viewer/pdf-viewer.module'; import { LicenseService } from '@services/license.service'; -import { TenantIdInterceptor } from '@utils/tenant-id-interceptor'; import { UI_CACHES } from '@utils/constants'; import { RedRoleGuard } from '@users/red-role.guard'; import { SkeletonTopBarComponent } from '@components/skeleton/skeleton-top-bar/skeleton-top-bar.component'; import { DossierSkeletonComponent } from '@components/skeleton/dossier-skeleton/dossier-skeleton.component'; import { SkeletonStatsComponent } from '@components/skeleton/skeleton-stats/skeleton-stats.component'; -import { TenantIdResponseInterceptor } from '@utils/tenant-id-response-interceptor'; const screens = [BaseScreenComponent, DownloadsListScreenComponent]; @@ -119,6 +120,7 @@ export const appModuleFactory = (config: AppConfig) => { preventDuplicates: true, resetTimeoutOnDuplicate: true, }), + TenantsModule.forRoot(), IqserTranslateModule.forRoot({ pathPrefix: config.BASE_TRANSLATIONS_DIRECTORY || '/assets/i18n/redact/' }), IqserLoadingModule.forRoot(), ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }), @@ -170,6 +172,7 @@ export const appModuleFactory = (config: AppConfig) => { IqserAllowDirective, IqserDenyDirective, IqserListingModule, + IconButtonComponent, ], providers: [ { @@ -181,22 +184,13 @@ export const appModuleFactory = (config: AppConfig) => { provide: ErrorHandler, useClass: GlobalErrorHandler, }, - { - provide: HTTP_INTERCEPTORS, - multi: true, - useClass: TenantIdInterceptor, - }, - { - provide: HTTP_INTERCEPTORS, - multi: true, - useClass: TenantIdResponseInterceptor, - }, { provide: APP_INITIALIZER, multi: true, useFactory: configurationInitializer, deps: [ BASE_HREF, + KeycloakStatusService, KeycloakService, ConfigService, SystemPreferencesService, diff --git a/apps/red-ui/src/app/components/base-screen/base-screen.component.html b/apps/red-ui/src/app/components/base-screen/base-screen.component.html index f9f73cfb2..f651a33a1 100644 --- a/apps/red-ui/src/app/components/base-screen/base-screen.component.html +++ b/apps/red-ui/src/app/components/base-screen/base-screen.component.html @@ -43,6 +43,10 @@ + +