RED-6713: remove tenants context holder

This commit is contained in:
Dan Percic 2023-05-18 12:24:11 +03:00
parent b1c13289ca
commit 0db227c70f
32 changed files with 210 additions and 258 deletions

View File

@ -8,7 +8,7 @@ import {
IqserAuthGuard, IqserAuthGuard,
IqserPermissionsGuard, IqserPermissionsGuard,
IqserRoutes, IqserRoutes,
TenantResolveComponent, TenantSelectComponent,
} from '@iqser/common-ui'; } from '@iqser/common-ui';
import { RedRoleGuard } from '@users/red-role.guard'; import { RedRoleGuard } from '@users/red-role.guard';
import { BaseScreenComponent } from '@components/base-screen/base-screen.component'; import { BaseScreenComponent } from '@components/base-screen/base-screen.component';
@ -19,7 +19,7 @@ import { DossiersGuard } from '@guards/dossiers.guard';
import { ACTIVE_DOSSIERS_SERVICE, ARCHIVED_DOSSIERS_SERVICE } from './tokens'; import { ACTIVE_DOSSIERS_SERVICE, ARCHIVED_DOSSIERS_SERVICE } from './tokens';
import { FeaturesGuard } from '@guards/features-guard.service'; import { FeaturesGuard } from '@guards/features-guard.service';
import { DossierTemplatesGuard } from '@guards/dossier-templates.guard'; import { DossierTemplatesGuard } from '@guards/dossier-templates.guard';
import { DossierTemplateExistsGuard } from '@guards/dossier-template-exists.guard'; import { templateExistsWhenEnteringDossierList } from '@guards/dossier-template-exists.guard';
import { DashboardGuard } from '@guards/dashboard-guard.service'; import { DashboardGuard } from '@guards/dashboard-guard.service';
import { TrashGuard } from '@guards/trash.guard'; import { TrashGuard } from '@guards/trash.guard';
import { ARCHIVE_ROUTE, BreadcrumbTypes, DOSSIER_ID, DOSSIER_TEMPLATE_ID, DOSSIERS_ARCHIVE, DOSSIERS_ROUTE, FILE_ID } from '@red/domain'; import { ARCHIVE_ROUTE, BreadcrumbTypes, DOSSIER_ID, DOSSIER_TEMPLATE_ID, DOSSIERS_ARCHIVE, DOSSIERS_ROUTE, FILE_ID } from '@red/domain';
@ -180,9 +180,9 @@ const mainRoutes: IqserRoutes = [
{ {
path: `:${DOSSIER_TEMPLATE_ID}`, path: `:${DOSSIER_TEMPLATE_ID}`,
children: dossierTemplateIdRoutes, children: dossierTemplateIdRoutes,
canActivate: [CompositeRouteGuard, IqserPermissionsGuard], canActivate: [CompositeRouteGuard, IqserPermissionsGuard, templateExistsWhenEnteringDossierList()],
data: { data: {
routeGuards: [IqserAuthGuard, RedRoleGuard, DossierTemplatesGuard, DashboardGuard, DossierTemplateExistsGuard], routeGuards: [IqserAuthGuard, RedRoleGuard, DossierTemplatesGuard, DashboardGuard],
permissions: { permissions: {
allow: [ allow: [
ROLES.any, ROLES.any,
@ -211,7 +211,7 @@ const routes: IqserRoutes = [
path: '', path: '',
pathMatch: 'full', pathMatch: 'full',
canActivate: [ifNotLoggedIn], canActivate: [ifNotLoggedIn],
component: TenantResolveComponent, component: TenantSelectComponent,
}, },
{ {
path: ':tenant', path: ':tenant',
@ -240,7 +240,7 @@ const routes: IqserRoutes = [
]; ];
@NgModule({ @NgModule({
imports: [RouterModule.forRoot(routes, { scrollPositionRestoration: 'enabled' })], imports: [RouterModule.forRoot(routes, { scrollPositionRestoration: 'enabled', bindToComponentInputs: true })],
providers: [{ provide: RouteReuseStrategy, useExisting: CustomRouteReuseStrategy }], providers: [{ provide: RouteReuseStrategy, useExisting: CustomRouteReuseStrategy }],
exports: [RouterModule], exports: [RouterModule],
}) })

View File

@ -7,7 +7,7 @@ import { TranslateService } from '@ngx-translate/core';
import { SpotlightSearchAction } from '@components/spotlight-search/spotlight-search-action'; import { SpotlightSearchAction } from '@components/spotlight-search/spotlight-search-action';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { filter, map, startWith } from 'rxjs/operators'; import { filter, map, startWith } from 'rxjs/operators';
import { BASE_HREF, IqserPermissionsService, shareDistinctLast, TenantContextHolder, TenantsService } from '@iqser/common-ui'; import { BASE_HREF, IqserPermissionsService, List, shareDistinctLast, TenantsService } from '@iqser/common-ui';
import { BreadcrumbsService } from '@services/breadcrumbs.service'; import { BreadcrumbsService } from '@services/breadcrumbs.service';
import { FeaturesService } from '@services/features.service'; import { FeaturesService } from '@services/features.service';
import { ARCHIVE_ROUTE, DOSSIERS_ARCHIVE, DOSSIERS_ROUTE } from '@red/domain'; import { ARCHIVE_ROUTE, DOSSIERS_ARCHIVE, DOSSIERS_ROUTE } from '@red/domain';
@ -32,7 +32,6 @@ const isSearchScreen: (url: string) => boolean = url => url.includes('/search');
}) })
export class BaseScreenComponent { export class BaseScreenComponent {
readonly roles = ROLES; readonly roles = ROLES;
readonly tenantContext = inject(TenantsService);
readonly documentViewer = inject(REDDocumentViewer); readonly documentViewer = inject(REDDocumentViewer);
readonly currentUser = this.userService.currentUser; readonly currentUser = this.userService.currentUser;
readonly userMenuItems: readonly MenuItem[] = [ readonly userMenuItems: readonly MenuItem[] = [
@ -64,42 +63,42 @@ export class BaseScreenComponent {
id: 'select-tenant', id: 'select-tenant',
name: _('top-bar.navigation-items.my-account.children.select-tenant'), name: _('top-bar.navigation-items.my-account.children.select-tenant'),
action: () => this.selectTenant(), action: () => this.selectTenant(),
show: this.tenantContext.hasMultipleTenants, show: this._tenantsService.hasMultiple(),
}, },
]; ];
readonly searchActions: readonly SpotlightSearchAction[] = [ readonly searchActions: List<SpotlightSearchAction> = [
{ {
text: this._translateService.instant('search.this-dossier'), text: this._translateService.instant('search.this-dossier'),
icon: 'red:enter', icon: 'red:enter',
hide: (): boolean => this._hideSearchThisDossier, hide: (): boolean => this.#hideSearchThisDossier,
action: (query): void => this._searchThisDossier(query), action: (query): void => this.#searchThisDossier(query),
}, },
{ {
text: this._translateService.instant('search.active-dossiers'), text: this._translateService.instant('search.active-dossiers'),
icon: 'red:enter', icon: 'red:enter',
hide: () => !this._featuresService.isEnabled(DOSSIERS_ARCHIVE), hide: () => !this._featuresService.isEnabled(DOSSIERS_ARCHIVE),
action: (query): void => this._search(query, [], true), action: (query): void => this.#search(query, [], true),
}, },
{ {
text: this._translateService.instant('search.all-dossiers'), text: this._translateService.instant('search.all-dossiers'),
icon: 'red:enter', icon: 'red:enter',
action: (query): void => this._search(query, []), action: (query): void => this.#search(query, []),
}, },
]; ];
private readonly _baseHref = inject(BASE_HREF); readonly #baseHref = inject(BASE_HREF);
private readonly _navigationStart$ = this._router.events.pipe( readonly #navigationStart$ = this._router.events.pipe(
filter(isNavigationStart), filter(isNavigationStart),
map((event: NavigationStart) => event.url), map((event: NavigationStart) => event.url),
startWith(this._router.url), startWith(this._router.url),
shareDistinctLast(), shareDistinctLast(),
); );
readonly isSearchScreen$ = this._navigationStart$.pipe(map(isSearchScreen)); readonly isSearchScreen$ = this.#navigationStart$.pipe(map(isSearchScreen));
constructor( constructor(
private readonly _router: Router, private readonly _router: Router,
private readonly _translateService: TranslateService, private readonly _translateService: TranslateService,
private readonly _featuresService: FeaturesService, private readonly _featuresService: FeaturesService,
private readonly _tenantContextHolder: TenantContextHolder, private readonly _tenantsService: TenantsService,
readonly permissionsService: IqserPermissionsService, readonly permissionsService: IqserPermissionsService,
readonly userService: UserService, readonly userService: UserService,
readonly userPreferenceService: UserPreferenceService, readonly userPreferenceService: UserPreferenceService,
@ -107,7 +106,7 @@ export class BaseScreenComponent {
readonly breadcrumbsService: BreadcrumbsService, readonly breadcrumbsService: BreadcrumbsService,
) {} ) {}
private get _hideSearchThisDossier() { get #hideSearchThisDossier() {
const routerLink = this.breadcrumbsService.breadcrumbs[1]?.options?.routerLink; const routerLink = this.breadcrumbsService.breadcrumbs[1]?.options?.routerLink;
if (!routerLink) { if (!routerLink) {
return true; return true;
@ -122,20 +121,20 @@ export class BaseScreenComponent {
} }
selectTenant() { selectTenant() {
window.open(window.location.origin + this._baseHref, '_blank'); window.open(window.location.origin + this.#baseHref, '_blank');
} }
private _search(query: string, dossierIds: string[], onlyActive = false) { #search(query: string, dossierIds: string[], onlyActive = false) {
const queryParams = { query, dossierIds: dossierIds.join(','), onlyActive }; const queryParams = { query, dossierIds: dossierIds.join(','), onlyActive };
this._router.navigate([`/${this._tenantContextHolder.currentTenant}/main/search`], { queryParams }).then(); this._router.navigate([`/${this._tenantsService.currentTenant}/main/search`], { queryParams }).then();
} }
private _searchThisDossier(query: string) { #searchThisDossier(query: string) {
const routerLink = this.breadcrumbsService.breadcrumbs[1]?.options?.routerLink; const routerLink = this.breadcrumbsService.breadcrumbs[1]?.options?.routerLink;
if (!routerLink) { if (!routerLink) {
return this._search(query, []); return this.#search(query, []);
} }
const dossierId = routerLink[2]; const dossierId = routerLink[2];
return this._search(query, [dossierId]); return this.#search(query, [dossierId]);
} }
} }

View File

@ -7,13 +7,13 @@ import { DOSSIER_ID, DOSSIER_TEMPLATE_ID } from '@red/domain';
import { DossiersService } from '@services/dossiers/dossiers.service'; import { DossiersService } from '@services/dossiers/dossiers.service';
import { DictionaryService } from '@services/entity-services/dictionary.service'; import { DictionaryService } from '@services/entity-services/dictionary.service';
import { DossierDictionariesMapService } from '@services/entity-services/dossier-dictionaries-map.service'; import { DossierDictionariesMapService } from '@services/entity-services/dossier-dictionaries-map.service';
import { TenantContextHolder } from '@iqser/common-ui'; import { TenantsService } from '@iqser/common-ui';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class DossierFilesGuard implements CanActivate { export class DossierFilesGuard implements CanActivate {
constructor( constructor(
private readonly _injector: Injector, private readonly _injector: Injector,
private readonly _tenantContextHolder: TenantContextHolder, private readonly _tenantsService: TenantsService,
private readonly _filesMapService: FilesMapService, private readonly _filesMapService: FilesMapService,
private readonly _filesService: FilesService, private readonly _filesService: FilesService,
private readonly _dictionaryService: DictionaryService, private readonly _dictionaryService: DictionaryService,
@ -34,7 +34,7 @@ export class DossierFilesGuard implements CanActivate {
} }
if (!dossiersService.has(dossierId)) { if (!dossiersService.has(dossierId)) {
await this._router.navigate([`/${this._tenantContextHolder.currentTenant}/main`, dossierTemplateId]); await this._router.navigate([`/${this._tenantsService.currentTenant}/main`, dossierTemplateId]);
return false; return false;
} }
@ -46,8 +46,8 @@ export class DossierFilesGuard implements CanActivate {
const promises = []; const promises = [];
if (!this._dictionaryMapService.has(dossierId)) { if (!this._dictionaryMapService.has(dossierId)) {
const dictionary$ = this._dictionaryService.loadDossierDictionary(dossierTemplateId, dossierId); const dictionaryPromise = this._dictionaryService.loadDossierDictionary(dossierTemplateId, dossierId);
promises.push(firstValueFrom(dictionary$)); promises.push(dictionaryPromise);
} }
if (!this._filesMapService.has(dossierId)) { if (!this._filesMapService.has(dossierId)) {

View File

@ -1,37 +1,31 @@
import { Injectable } from '@angular/core'; import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router'; import { ActivatedRouteSnapshot, CanActivateFn, Router } from '@angular/router';
import { DOSSIER_TEMPLATE_ID } from '@red/domain'; import { DOSSIER_TEMPLATE_ID } from '@red/domain';
import { DashboardStatsService } from '@services/dossier-templates/dashboard-stats.service'; import { DashboardStatsService } from '@services/dossier-templates/dashboard-stats.service';
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service'; import { TenantsService } from '@iqser/common-ui';
import { TenantContextHolder } from '@iqser/common-ui';
@Injectable({ providedIn: 'root' }) export function templateExistsWhenEnteringAdmin(): CanActivateFn {
export class DossierTemplateExistsGuard implements CanActivate { return async function (route: ActivatedRouteSnapshot): Promise<boolean> {
constructor(
private readonly _dashboardStatsService: DashboardStatsService,
private readonly _tenantContextHolder: TenantContextHolder,
private readonly _dossierTemplatesService: DossierTemplatesService,
private readonly _router: Router,
) {}
async canActivate(route: ActivatedRouteSnapshot): Promise<boolean> {
const dossierTemplateId: string = route.paramMap.get(DOSSIER_TEMPLATE_ID); const dossierTemplateId: string = route.paramMap.get(DOSSIER_TEMPLATE_ID);
const dossiersListView = !route.pathFromRoot.find(r => r.routeConfig?.path === 'admin');
if (dossiersListView) { const dossierTemplate = inject(DashboardStatsService).find(dossierTemplateId);
const dossierTemplateStats = this._dashboardStatsService.find(dossierTemplateId); if (!dossierTemplate) {
if (!dossierTemplateStats || dossierTemplateStats.isEmpty) { await inject(Router).navigate([inject(TenantsService).currentTenant, 'main', 'admin', 'dossier-templates']);
await this._router.navigate([`/${this._tenantContextHolder.currentTenant}/main`]); return false;
return false;
}
} else {
const dossierTemplate = this._dossierTemplatesService.find(dossierTemplateId);
if (!dossierTemplate) {
await this._router.navigate([this._tenantContextHolder.currentTenant, 'main', 'admin', 'dossier-templates']);
return false;
}
} }
return true; return true;
} };
}
export function templateExistsWhenEnteringDossierList(): CanActivateFn {
return async function (route: ActivatedRouteSnapshot) {
const dossierTemplateId: string = route.paramMap.get(DOSSIER_TEMPLATE_ID);
const dossierTemplateStats = inject(DashboardStatsService).find(dossierTemplateId);
if (!dossierTemplateStats || dossierTemplateStats.isEmpty) {
await inject(Router).navigate([inject(TenantsService).currentTenant, 'main']);
return false;
}
return true;
};
} }

View File

@ -7,14 +7,14 @@ import { ArchivedDossiersService } from '@services/dossiers/archived-dossiers.se
import { DossiersService } from '@services/dossiers/dossiers.service'; import { DossiersService } from '@services/dossiers/dossiers.service';
import { ARCHIVE_ROUTE, DOSSIER_TEMPLATE_ID } from '@red/domain'; import { ARCHIVE_ROUTE, DOSSIER_TEMPLATE_ID } from '@red/domain';
import { DashboardStatsService } from '@services/dossier-templates/dashboard-stats.service'; import { DashboardStatsService } from '@services/dossier-templates/dashboard-stats.service';
import { TenantContextHolder } from '@iqser/common-ui'; import { TenantsService } from '@iqser/common-ui';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class DossiersGuard implements CanActivate { export class DossiersGuard implements CanActivate {
constructor( constructor(
private readonly _injector: Injector, private readonly _injector: Injector,
private readonly _router: Router, private readonly _router: Router,
private readonly _tenantContextHolder: TenantContextHolder, private readonly _tenantsService: TenantsService,
private readonly _dashboardStatsService: DashboardStatsService, private readonly _dashboardStatsService: DashboardStatsService,
private readonly _activeDossiersService: ActiveDossiersService, private readonly _activeDossiersService: ActiveDossiersService,
private readonly _archivedDossiersService: ArchivedDossiersService, private readonly _archivedDossiersService: ArchivedDossiersService,
@ -35,7 +35,7 @@ export class DossiersGuard implements CanActivate {
const dossierTemplateStats = this._dashboardStatsService.find(dossierTemplateId); const dossierTemplateStats = this._dashboardStatsService.find(dossierTemplateId);
if (isArchive && dossierTemplateStats?.numberOfArchivedDossiers === 0) { if (isArchive && dossierTemplateStats?.numberOfArchivedDossiers === 0) {
await this._router.navigate([this._tenantContextHolder.currentTenant, 'main', dossierTemplateId, 'dossiers']); await this._router.navigate([this._tenantsService.currentTenant, 'main', dossierTemplateId, 'dossiers']);
return false; return false;
} }

View File

@ -1,29 +1,21 @@
import { Injectable } from '@angular/core'; import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router'; import { ActivatedRouteSnapshot, CanActivateFn, Router } from '@angular/router';
import { DOSSIER_TEMPLATE_ID, ENTITY_TYPE } from '@red/domain'; import { DOSSIER_TEMPLATE_ID, ENTITY_TYPE } from '@red/domain';
import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service'; import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service';
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service'; import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
import { TenantContextHolder } from '@iqser/common-ui'; import { TenantsService } from '@iqser/common-ui';
@Injectable({ providedIn: 'root' }) export function entityExistsGuard(): CanActivateFn {
export class EntityExistsGuard implements CanActivate { return async function (route: ActivatedRouteSnapshot): Promise<boolean> {
constructor(
private readonly _dictionariesMapService: DictionariesMapService,
private readonly _router: Router,
private readonly _dossierTemplatesService: DossierTemplatesService,
private readonly _tenantContextHolder: TenantContextHolder,
) {}
async canActivate(route: ActivatedRouteSnapshot): Promise<boolean> {
const dossierTemplateId = route.paramMap.get(DOSSIER_TEMPLATE_ID); const dossierTemplateId = route.paramMap.get(DOSSIER_TEMPLATE_ID);
const type = route.paramMap.get(ENTITY_TYPE); const type = route.paramMap.get(ENTITY_TYPE);
if (!this._dictionariesMapService.get(dossierTemplateId, type)) { if (!inject(DictionariesMapService).get(dossierTemplateId, type)) {
const dossierTemplate = this._dossierTemplatesService.find(dossierTemplateId); const dossierTemplate = inject(DossierTemplatesService).find(dossierTemplateId);
await this._router.navigate([`/${this._tenantContextHolder.currentTenant}/${dossierTemplate.routerLink}/entities`]); await inject(Router).navigate([`/${inject(TenantsService).currentTenant}/${dossierTemplate.routerLink}/entities`]);
return false; return false;
} }
return true; return true;
} };
} }

View File

@ -1,27 +1,20 @@
import { Injectable } from '@angular/core'; import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router'; import { ActivatedRouteSnapshot, CanActivateFn, Router } from '@angular/router';
import { WatermarksMapService } from '@services/entity-services/watermarks-map.service'; import { WatermarksMapService } from '@services/entity-services/watermarks-map.service';
import { DOSSIER_TEMPLATE_ID, WATERMARK_ID } from '@red/domain'; import { DOSSIER_TEMPLATE_ID, WATERMARK_ID } from '@red/domain';
import { TenantContextHolder } from '@iqser/common-ui'; import { TenantsService } from '@iqser/common-ui';
@Injectable({ providedIn: 'root' }) export function watermarkExistsGuard(): CanActivateFn {
export class WatermarkExistsGuard implements CanActivate { return async function (route: ActivatedRouteSnapshot) {
constructor(
private readonly _watermarksMapService: WatermarksMapService,
private readonly _tenantContextHolder: TenantContextHolder,
private readonly _router: Router,
) {}
async canActivate(route: ActivatedRouteSnapshot): Promise<boolean> {
const dossierTemplateId = route.parent.paramMap.get(DOSSIER_TEMPLATE_ID); const dossierTemplateId = route.parent.paramMap.get(DOSSIER_TEMPLATE_ID);
const watermarkId = Number(route.paramMap.get(WATERMARK_ID)); const watermarkId = Number(route.paramMap.get(WATERMARK_ID));
if (this._watermarksMapService.get(dossierTemplateId, watermarkId)) { if (inject(WatermarksMapService).get(dossierTemplateId, watermarkId)) {
return true; return true;
} }
await this._router.navigate([ await inject(Router).navigate([
this._tenantContextHolder.currentTenant, inject(TenantsService).currentTenant,
'main', 'main',
'admin', 'admin',
'dossier-templates', 'dossier-templates',
@ -29,5 +22,5 @@ export class WatermarkExistsGuard implements CanActivate {
'watermarks', 'watermarks',
]); ]);
return false; return false;
} };
} }

View File

@ -13,8 +13,8 @@ import { BaseAdminScreenComponent } from './base-admin-screen/base-admin-screen.
import { BaseDossierTemplateScreenComponent } from './base-dossier-templates-screen/base-dossier-template-screen.component'; import { BaseDossierTemplateScreenComponent } from './base-dossier-templates-screen/base-dossier-template-screen.component';
import { DossierTemplatesGuard } from '@guards/dossier-templates.guard'; import { DossierTemplatesGuard } from '@guards/dossier-templates.guard';
import { DOSSIER_TEMPLATE_ID, ENTITY_TYPE } from '@red/domain'; import { DOSSIER_TEMPLATE_ID, ENTITY_TYPE } from '@red/domain';
import { DossierTemplateExistsGuard } from '@guards/dossier-template-exists.guard'; import { templateExistsWhenEnteringAdmin } from '@guards/dossier-template-exists.guard';
import { EntityExistsGuard } from '@guards/entity-exists-guard.service'; import { entityExistsGuard } from '@guards/entity-exists-guard.service';
import { BaseEntityScreenComponent } from './base-entity-screen/base-entity-screen.component'; import { BaseEntityScreenComponent } from './base-entity-screen/base-entity-screen.component';
import { PermissionsGuard } from '@guards/permissions-guard'; import { PermissionsGuard } from '@guards/permissions-guard';
import { ROLES } from '@users/roles'; import { ROLES } from '@users/roles';
@ -39,10 +39,10 @@ const dossierTemplateIdRoutes: IqserRoutes = [
{ {
path: `:${ENTITY_TYPE}`, path: `:${ENTITY_TYPE}`,
component: BaseEntityScreenComponent, component: BaseEntityScreenComponent,
canActivate: [CompositeRouteGuard], canActivate: [CompositeRouteGuard, entityExistsGuard()],
loadChildren: () => import('./screens/entities/entities.module').then(m => m.EntitiesModule), loadChildren: () => import('./screens/entities/entities.module').then(m => m.EntitiesModule),
data: { data: {
routeGuards: [IqserAuthGuard, RedRoleGuard, EntityExistsGuard], routeGuards: [IqserAuthGuard, RedRoleGuard],
}, },
}, },
], ],
@ -141,8 +141,7 @@ const dossierTemplatesRoutes: IqserRoutes = [
{ {
path: `:${DOSSIER_TEMPLATE_ID}`, path: `:${DOSSIER_TEMPLATE_ID}`,
children: dossierTemplateIdRoutes, children: dossierTemplateIdRoutes,
canActivate: [CompositeRouteGuard], canActivate: [templateExistsWhenEnteringAdmin()],
data: { routeGuards: [DossierTemplateExistsGuard] },
}, },
]; ];

View File

@ -4,7 +4,7 @@ import { Router } from '@angular/router';
import { firstValueFrom, Observable } from 'rxjs'; import { firstValueFrom, Observable } from 'rxjs';
import { AdminDialogService } from '../services/admin-dialog.service'; import { AdminDialogService } from '../services/admin-dialog.service';
import { DictionaryService } from '@services/entity-services/dictionary.service'; import { DictionaryService } from '@services/entity-services/dictionary.service';
import { getParam, LoadingService, TenantContextHolder } from '@iqser/common-ui'; import { getParam, LoadingService, TenantsService } from '@iqser/common-ui';
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service'; import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service'; import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
@ -27,7 +27,7 @@ export class BaseEntityScreenComponent {
private readonly _dialogService: AdminDialogService, private readonly _dialogService: AdminDialogService,
private readonly _dictionaryService: DictionaryService, private readonly _dictionaryService: DictionaryService,
private readonly _permissionsService: PermissionsService, private readonly _permissionsService: PermissionsService,
private readonly _tenantContextHolder: TenantContextHolder, private readonly _tenantsService: TenantsService,
private readonly _dossierTemplatesService: DossierTemplatesService, private readonly _dossierTemplatesService: DossierTemplatesService,
) { ) {
const entity$ = dictionaryMapService.watch$(this.#dossierTemplateId, this.#entityType); const entity$ = dictionaryMapService.watch$(this.#dossierTemplateId, this.#entityType);
@ -42,7 +42,7 @@ export class BaseEntityScreenComponent {
this._loadingService.start(); this._loadingService.start();
const dossierTemplate = this._dossierTemplatesService.find(this.#dossierTemplateId); const dossierTemplate = this._dossierTemplatesService.find(this.#dossierTemplateId);
await firstValueFrom(this._dictionaryService.deleteDictionaries([this.#entityType], this.#dossierTemplateId)); await firstValueFrom(this._dictionaryService.deleteDictionaries([this.#entityType], this.#dossierTemplateId));
await this._router.navigate([`/${this._tenantContextHolder.currentTenant}/${dossierTemplate.routerLink}/entities`]); await this._router.navigate([`/${this._tenantsService.currentTenant}/${dossierTemplate.routerLink}/entities`]);
this._loadingService.stop(); this._loadingService.stop();
}); });
} }

View File

@ -11,7 +11,7 @@ import {
IconButtonTypes, IconButtonTypes,
IqserPermissionsService, IqserPermissionsService,
LoadingService, LoadingService,
TenantContextHolder, TenantsService,
Toaster, Toaster,
} from '@iqser/common-ui'; } from '@iqser/common-ui';
import { DOSSIER_TEMPLATE_ID, type IWatermark, type User, WATERMARK_ID, WatermarkOrientation, WatermarkOrientations } from '@red/domain'; import { DOSSIER_TEMPLATE_ID, type IWatermark, type User, WATERMARK_ID, WatermarkOrientation, WatermarkOrientations } from '@red/domain';
@ -77,7 +77,7 @@ export class WatermarkScreenComponent implements OnInit {
private readonly _formBuilder: FormBuilder, private readonly _formBuilder: FormBuilder,
readonly permissionsService: IqserPermissionsService, readonly permissionsService: IqserPermissionsService,
private readonly _loadingService: LoadingService, private readonly _loadingService: LoadingService,
private readonly _tenantContextHolder: TenantContextHolder, private readonly _tenantsService: TenantsService,
private readonly _licenseService: LicenseService, private readonly _licenseService: LicenseService,
private readonly _watermarkService: WatermarkService, private readonly _watermarkService: WatermarkService,
private readonly _userPreferenceService: UserPreferenceService, private readonly _userPreferenceService: UserPreferenceService,
@ -151,7 +151,7 @@ export class WatermarkScreenComponent implements OnInit {
); );
if (!watermark.id) { if (!watermark.id) {
await this._router.navigate([ await this._router.navigate([
`/${this._tenantContextHolder.currentTenant}/main/admin/dossier-templates/${this.#dossierTemplateId}/watermarks/${ `/${this._tenantsService.currentTenant}/main/admin/dossier-templates/${this.#dossierTemplateId}/watermarks/${
updatedWatermark.id updatedWatermark.id
}`, }`,
]); ]);

View File

@ -18,7 +18,7 @@ import {
} from '@iqser/common-ui'; } from '@iqser/common-ui';
import { RedRoleGuard } from '@users/red-role.guard'; import { RedRoleGuard } from '@users/red-role.guard';
import { WATERMARK_ID } from '@red/domain'; import { WATERMARK_ID } from '@red/domain';
import { WatermarkExistsGuard } from '@guards/watermark-exists.guard'; import { watermarkExistsGuard } from '@guards/watermark-exists.guard';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { PaginatorComponent } from './paginator/paginator.component'; import { PaginatorComponent } from './paginator/paginator.component';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
@ -47,9 +47,9 @@ const routes: IqserRoutes = [
{ {
path: `:${WATERMARK_ID}`, path: `:${WATERMARK_ID}`,
component: WatermarkScreenComponent, component: WatermarkScreenComponent,
canActivate: [CompositeRouteGuard], canActivate: [CompositeRouteGuard, watermarkExistsGuard()],
data: { data: {
routeGuards: [IqserAuthGuard, RedRoleGuard, WatermarkExistsGuard], routeGuards: [IqserAuthGuard, RedRoleGuard],
}, },
}, },
]; ];

View File

@ -5,14 +5,7 @@ import { adminSideNavTranslations } from '@translations/admin-side-nav-translati
import { ActivatedRoute, RouterLink, RouterLinkActive } from '@angular/router'; import { ActivatedRoute, RouterLink, RouterLinkActive } from '@angular/router';
import { AdminSideNavType, AdminSideNavTypes, DOSSIER_TEMPLATE_ID, ENTITY_TYPE, User, WATERMARK_ID } from '@red/domain'; import { AdminSideNavType, AdminSideNavTypes, DOSSIER_TEMPLATE_ID, ENTITY_TYPE, User, WATERMARK_ID } from '@red/domain';
import { ROLES } from '@users/roles'; import { ROLES } from '@users/roles';
import { import { getCurrentUser, IqserHelpModeModule, IqserPermissionsService, SideNavComponent, TenantPipe } from '@iqser/common-ui';
getCurrentUser,
IqserHelpModeModule,
IqserPermissionsService,
SideNavComponent,
TenantContextHolder,
TenantPipe,
} from '@iqser/common-ui';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { NgForOf, NgIf } from '@angular/common'; import { NgForOf, NgIf } from '@angular/common';
@ -173,7 +166,6 @@ export class AdminSideNavComponent implements OnInit {
constructor( constructor(
private readonly _permissionsService: IqserPermissionsService, private readonly _permissionsService: IqserPermissionsService,
private readonly _tenantContextHolder: TenantContextHolder,
private readonly _route: ActivatedRoute, private readonly _route: ActivatedRoute,
readonly userPreferenceService: UserPreferenceService, readonly userPreferenceService: UserPreferenceService,
) {} ) {}

View File

@ -7,7 +7,7 @@ import {
getCurrentUser, getCurrentUser,
IqserHelpModeModule, IqserHelpModeModule,
LoadingService, LoadingService,
TenantContextHolder, TenantsService,
} from '@iqser/common-ui'; } from '@iqser/common-ui';
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service'; import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
import { firstValueFrom } from 'rxjs'; import { firstValueFrom } from 'rxjs';
@ -23,17 +23,17 @@ import { TranslateModule } from '@ngx-translate/core';
imports: [NgIf, IqserHelpModeModule, CircleButtonComponent, TranslateModule], imports: [NgIf, IqserHelpModeModule, CircleButtonComponent, TranslateModule],
}) })
export class DossierTemplateActionsComponent implements OnInit { export class DossierTemplateActionsComponent implements OnInit {
@Input() dossierTemplateId: string;
readonly circleButtonTypes = CircleButtonTypes; readonly circleButtonTypes = CircleButtonTypes;
readonly currentUser = getCurrentUser<User>(); readonly currentUser = getCurrentUser<User>();
@Input() dossierTemplateId: string;
constructor( constructor(
private readonly _router: Router, private readonly _router: Router,
private readonly _route: ActivatedRoute, private readonly _route: ActivatedRoute,
private readonly _loadingService: LoadingService, private readonly _loadingService: LoadingService,
private readonly _dialogService: AdminDialogService, private readonly _dialogService: AdminDialogService,
private readonly _tenantContextHolder: TenantContextHolder, private readonly _tenantsService: TenantsService,
private readonly _dossierTemplatesService: DossierTemplatesService, private readonly _dossierTemplatesService: DossierTemplatesService,
) {} ) {}
@ -51,7 +51,7 @@ export class DossierTemplateActionsComponent implements OnInit {
const success = await firstValueFrom(this._dossierTemplatesService.delete([this.dossierTemplateId])); const success = await firstValueFrom(this._dossierTemplatesService.delete([this.dossierTemplateId]));
if (success) { if (success) {
await this._router.navigate([this._tenantContextHolder.currentTenant, 'main', 'admin']); await this._router.navigate([this._tenantsService.currentTenant, 'main', 'admin']);
} }
this._loadingService.stop(); this._loadingService.stop();

View File

@ -1,5 +1,5 @@
<iqser-page-header <iqser-page-header
(closeAction)="router.navigate([tenantContextHolder.currentTenant + '/' + dossier.dossiersListRouterLink])" (closeAction)="router.navigate([tenantsService.currentTenant + '/' + dossier.dossiersListRouterLink])"
[actionConfigs]="actionConfigs" [actionConfigs]="actionConfigs"
[helpModeKey]="'document'" [helpModeKey]="'document'"
[showCloseButton]="true" [showCloseButton]="true"
@ -7,20 +7,20 @@
> >
<ng-container slot="right"> <ng-container slot="right">
<redaction-file-download-btn <redaction-file-download-btn
[attr.help-mode-key]="'edit_dossier_in_dossier'"
[buttonId]="'download-files-btn'" [buttonId]="'download-files-btn'"
[disabled]="downloadBtnDisabled$ | async" [disabled]="downloadBtnDisabled$ | async"
[dossier]="dossier" [dossier]="dossier"
[files]="entitiesService.all$ | async" [files]="entitiesService.all$ | async"
[attr.help-mode-key]="'edit_dossier_in_dossier'"
></redaction-file-download-btn> ></redaction-file-download-btn>
<iqser-circle-button <iqser-circle-button
(action)="downloadDossierAsCSV()" (action)="downloadDossierAsCSV()"
*ngIf="permissionsService.canDownloadCsvReport(dossier)" *ngIf="permissionsService.canDownloadCsvReport(dossier)"
[attr.help-mode-key]="'edit_dossier_in_dossier'"
[disabled]="listingService.areSomeSelected$ | async" [disabled]="listingService.areSomeSelected$ | async"
[icon]="'iqser:csv'" [icon]="'iqser:csv'"
[tooltip]="'dossier-overview.header-actions.download-csv' | translate" [tooltip]="'dossier-overview.header-actions.download-csv' | translate"
[attr.help-mode-key]="'edit_dossier_in_dossier'"
></iqser-circle-button> ></iqser-circle-button>
<iqser-circle-button <iqser-circle-button
@ -36,11 +36,11 @@
<iqser-circle-button <iqser-circle-button
(action)="upload.emit()" (action)="upload.emit()"
*ngIf="permissionsService.canUploadFiles(dossier)" *ngIf="permissionsService.canUploadFiles(dossier)"
[attr.help-mode-key]="'edit_dossier_in_dossier'"
[buttonId]="'upload-document-btn'" [buttonId]="'upload-document-btn'"
[icon]="'iqser:upload'" [icon]="'iqser:upload'"
[tooltip]="'dossier-overview.header-actions.upload-document' | translate" [tooltip]="'dossier-overview.header-actions.upload-document' | translate"
[type]="circleButtonTypes.primary" [type]="circleButtonTypes.primary"
[attr.help-mode-key]="'edit_dossier_in_dossier'"
class="ml-14" class="ml-14"
></iqser-circle-button> ></iqser-circle-button>
</ng-container> </ng-container>

View File

@ -8,7 +8,7 @@ import {
LoadingService, LoadingService,
some, some,
SortingService, SortingService,
TenantContextHolder, TenantsService,
Toaster, Toaster,
} from '@iqser/common-ui'; } from '@iqser/common-ui';
import { Dossier, File, IFile } from '@red/domain'; import { Dossier, File, IFile } from '@red/domain';
@ -44,7 +44,7 @@ export class DossierOverviewScreenHeaderComponent implements OnInit {
readonly sortingService: SortingService<File>, readonly sortingService: SortingService<File>,
readonly permissionsService: PermissionsService, readonly permissionsService: PermissionsService,
readonly entitiesService: EntitiesService<IFile, File>, readonly entitiesService: EntitiesService<IFile, File>,
readonly tenantContextHolder: TenantContextHolder, readonly tenantsService: TenantsService,
private readonly _reanalysisService: ReanalysisService, private readonly _reanalysisService: ReanalysisService,
private readonly _loadingService: LoadingService, private readonly _loadingService: LoadingService,
private readonly _primaryFileAttributeService: PrimaryFileAttributeService, private readonly _primaryFileAttributeService: PrimaryFileAttributeService,

View File

@ -40,7 +40,7 @@ export class BulkActionsService {
async ocr(files: File[]) { async ocr(files: File[]) {
this._loadingService.start(); this._loadingService.start();
await firstValueFrom(this._reanalysisService.ocrFiles(files, files[0].dossierId)); await this._reanalysisService.ocrFiles(files, files[0].dossierId);
this._loadingService.stop(); this._loadingService.stop();
} }
@ -61,9 +61,7 @@ export class BulkActionsService {
async reanalyse(files: File[]) { async reanalyse(files: File[]) {
this._loadingService.start(); this._loadingService.start();
await firstValueFrom( await this._reanalysisService.reanalyzeFilesForDossier(files, files[0].dossierId, { force: true, triggeredByUser: true });
this._reanalysisService.reanalyzeFilesForDossier(files, files[0].dossierId, { force: true, triggeredByUser: true }),
);
this._loadingService.stop(); this._loadingService.stop();
} }
@ -75,7 +73,7 @@ export class BulkActionsService {
async toggleAnalysis(files: File[], excluded: boolean) { async toggleAnalysis(files: File[], excluded: boolean) {
this._loadingService.start(); this._loadingService.start();
await firstValueFrom(this._reanalysisService.toggleAnalysis(files[0].dossierId, files, excluded)); await this._reanalysisService.toggleAnalysis(files[0].dossierId, files, excluded);
this._loadingService.stop(); this._loadingService.stop();
} }

View File

@ -31,7 +31,7 @@ import {
OnDetach, OnDetach,
processFilters, processFilters,
shareDistinctLast, shareDistinctLast,
TenantContextHolder, TenantsService,
Toaster, Toaster,
} from '@iqser/common-ui'; } from '@iqser/common-ui';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
@ -126,7 +126,7 @@ export class FilePreviewScreenComponent
private readonly _viewModeService: ViewModeService, private readonly _viewModeService: ViewModeService,
private readonly _documentViewer: REDDocumentViewer, private readonly _documentViewer: REDDocumentViewer,
private readonly _changeRef: ChangeDetectorRef, private readonly _changeRef: ChangeDetectorRef,
private readonly _tenantContextHolder: TenantContextHolder, private readonly _tenantsService: TenantsService,
private readonly _dialogService: FilePreviewDialogService, private readonly _dialogService: FilePreviewDialogService,
private readonly _pageRotationService: PageRotationService, private readonly _pageRotationService: PageRotationService,
private readonly _viewerHeaderService: ViewerHeaderService, private readonly _viewerHeaderService: ViewerHeaderService,
@ -310,8 +310,7 @@ export class FilePreviewScreenComponent
this._subscribeToFileUpdates(); this._subscribeToFileUpdates();
if (file?.analysisRequired && !file.excludedFromAutomaticAnalysis) { if (file?.analysisRequired && !file.excludedFromAutomaticAnalysis) {
const reanalyzeFiles = this._reanalysisService.reanalyzeFilesForDossier([file], this.dossierId, { force: true }); await this._reanalysisService.reanalyzeFilesForDossier([file], this.dossierId, { force: true });
await firstValueFrom(reanalyzeFiles);
} }
this.pdfProxyService.configureElements(); this.pdfProxyService.configureElements();
@ -772,7 +771,7 @@ export class FilePreviewScreenComponent
private _navigateToDossier() { private _navigateToDossier() {
this._logger.info('Navigating to ', this.state.dossier.dossierName); this._logger.info('Navigating to ', this.state.dossier.dossierName);
return this._router.navigate([`/${this._tenantContextHolder.currentTenant}${this.state.dossier.routerLink}`]); return this._router.navigate([`/${this._tenantsService.currentTenant}${this.state.dossier.routerLink}`]);
} }
#highlightSelectedAnnotations(newAnnotations: AnnotationWrapper[]) { #highlightSelectedAnnotations(newAnnotations: AnnotationWrapper[]) {

View File

@ -1,4 +1,4 @@
import { ChangeDetectorRef, Component, HostBinding, Injector, Input, OnChanges, Optional, SimpleChanges, ViewChild } from '@angular/core'; import { ChangeDetectorRef, Component, HostBinding, Injector, Input, OnChanges, Optional, ViewChild } from '@angular/core';
import { PermissionsService } from '@services/permissions.service'; import { PermissionsService } from '@services/permissions.service';
import { Action, ActionTypes, Dossier, File, ProcessingFileStatuses, User } from '@red/domain'; import { Action, ActionTypes, Dossier, File, ProcessingFileStatuses, User } from '@red/domain';
import { DossiersDialogService } from '../../services/dossiers-dialog.service'; import { DossiersDialogService } from '../../services/dossiers-dialog.service';
@ -10,8 +10,7 @@ import {
IqserPermissionsService, IqserPermissionsService,
IqserTooltipPositions, IqserTooltipPositions,
LoadingService, LoadingService,
ScrollableParentView, TenantsService,
TenantContextHolder,
Toaster, Toaster,
} from '@iqser/common-ui'; } from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@ -39,15 +38,16 @@ import { FileAttributesService } from '@services/entity-services/file-attributes
styleUrls: ['./file-actions.component.scss'], styleUrls: ['./file-actions.component.scss'],
}) })
export class FileActionsComponent implements OnChanges { export class FileActionsComponent implements OnChanges {
readonly circleButtonTypes = CircleButtonTypes;
readonly currentUser = getCurrentUser<User>();
@Input() file: File; @Input() file: File;
@Input() dossier: Dossier; @Input() dossier: Dossier;
@Input() type: 'file-preview' | 'dossier-overview-list' | 'dossier-overview-workflow'; @Input() type: 'file-preview' | 'dossier-overview-list' | 'dossier-overview-workflow';
@Input() maxWidth: number; @Input() maxWidth: number;
@Input() minWidth: number; @Input() minWidth: number;
@Input() fileActionsHelpModeKey: 'document_features_in_dossier' | 'editor_document_features' = 'document_features_in_dossier'; @Input() fileActionsHelpModeKey: 'document_features_in_dossier' | 'editor_document_features' = 'document_features_in_dossier';
readonly circleButtonTypes = CircleButtonTypes;
readonly currentUser = getCurrentUser<User>();
toggleTooltip?: string; toggleTooltip?: string;
assignTooltip?: string; assignTooltip?: string;
buttonType?: CircleButtonType; buttonType?: CircleButtonType;
@ -78,8 +78,6 @@ export class FileActionsComponent implements OnChanges {
tooltipPosition = IqserTooltipPositions.above; tooltipPosition = IqserTooltipPositions.above;
buttons: Action[]; buttons: Action[];
scrollableParentView: ScrollableParentView;
@ViewChild(ExpandableFileActionsComponent) @ViewChild(ExpandableFileActionsComponent)
private readonly _expandableActionsComponent: ExpandableFileActionsComponent; private readonly _expandableActionsComponent: ExpandableFileActionsComponent;
@ -89,7 +87,7 @@ export class FileActionsComponent implements OnChanges {
private readonly _changeRef: ChangeDetectorRef, private readonly _changeRef: ChangeDetectorRef,
private readonly _loadingService: LoadingService, private readonly _loadingService: LoadingService,
private readonly _dialogService: DossiersDialogService, private readonly _dialogService: DossiersDialogService,
private readonly _tenantContextHolder: TenantContextHolder, private readonly _tenantsService: TenantsService,
private readonly _fileAssignService: FileAssignService, private readonly _fileAssignService: FileAssignService,
private readonly _reanalysisService: ReanalysisService, private readonly _reanalysisService: ReanalysisService,
private readonly _permissionsService: PermissionsService, private readonly _permissionsService: PermissionsService,
@ -120,7 +118,7 @@ export class FileActionsComponent implements OnChanges {
{ {
id: 'delete-file-btn', id: 'delete-file-btn',
type: ActionTypes.circleBtn, type: ActionTypes.circleBtn,
action: () => this._openDeleteFileDialog(), action: () => this.#openDeleteFileDialog(),
tooltip: _('dossier-overview.delete.action'), tooltip: _('dossier-overview.delete.action'),
icon: 'iqser:trash', icon: 'iqser:trash',
show: this.showDelete, show: this.showDelete,
@ -128,7 +126,7 @@ export class FileActionsComponent implements OnChanges {
{ {
id: 'assign-btn', id: 'assign-btn',
type: ActionTypes.circleBtn, type: ActionTypes.circleBtn,
action: () => this._assign(), action: () => this.#assign(),
tooltip: this.assignTooltip, tooltip: this.assignTooltip,
icon: 'red:assign', icon: 'red:assign',
show: this.showAssign, show: this.showAssign,
@ -136,7 +134,7 @@ export class FileActionsComponent implements OnChanges {
{ {
id: 'assign-to-me-btn', id: 'assign-to-me-btn',
type: ActionTypes.circleBtn, type: ActionTypes.circleBtn,
action: () => this._assignToMe(), action: () => this.#assignToMe(),
tooltip: _('dossier-overview.assign-me'), tooltip: _('dossier-overview.assign-me'),
icon: 'red:assign-me', icon: 'red:assign-me',
show: this.showAssignToSelf, show: this.showAssignToSelf,
@ -144,7 +142,7 @@ export class FileActionsComponent implements OnChanges {
{ {
id: 'open-import-redactions-dialog-btn', id: 'open-import-redactions-dialog-btn',
type: ActionTypes.circleBtn, type: ActionTypes.circleBtn,
action: () => this._openImportRedactionsDialog(), action: () => this.#openImportRedactionsDialog(),
tooltip: _('dossier-overview.import-redactions'), tooltip: _('dossier-overview.import-redactions'),
icon: 'red:import_redactions', icon: 'red:import_redactions',
show: this.showImportRedactions && !this._iqserPermissionsService.has(ROLES.getRss), show: this.showImportRedactions && !this._iqserPermissionsService.has(ROLES.getRss),
@ -191,7 +189,7 @@ export class FileActionsComponent implements OnChanges {
{ {
id: 'set-file-under-approval-btn', id: 'set-file-under-approval-btn',
type: ActionTypes.circleBtn, type: ActionTypes.circleBtn,
action: () => this._setFileUnderApproval(), action: () => this.#setFileUnderApproval(),
tooltip: _('dossier-overview.under-approval'), tooltip: _('dossier-overview.under-approval'),
icon: 'red:ready-for-approval', icon: 'red:ready-for-approval',
show: this.showUnderApproval, show: this.showUnderApproval,
@ -199,7 +197,7 @@ export class FileActionsComponent implements OnChanges {
{ {
id: 'set-file-under-review-btn', id: 'set-file-under-review-btn',
type: ActionTypes.circleBtn, type: ActionTypes.circleBtn,
action: () => this._setFileUnderReview(), action: () => this.#setFileUnderReview(),
tooltip: _('dossier-overview.under-review'), tooltip: _('dossier-overview.under-review'),
icon: 'red:undo', icon: 'red:undo',
show: this.showUnderReview, show: this.showUnderReview,
@ -216,7 +214,7 @@ export class FileActionsComponent implements OnChanges {
{ {
id: 'toggle-automatic-analysis-btn', id: 'toggle-automatic-analysis-btn',
type: ActionTypes.circleBtn, type: ActionTypes.circleBtn,
action: () => this._toggleAutomaticAnalysis(), action: () => this.#toggleAutomaticAnalysis(),
tooltip: _('dossier-overview.stop-auto-analysis'), tooltip: _('dossier-overview.stop-auto-analysis'),
icon: 'red:disable-analysis', icon: 'red:disable-analysis',
show: this.canDisableAutoAnalysis, show: this.canDisableAutoAnalysis,
@ -224,7 +222,7 @@ export class FileActionsComponent implements OnChanges {
{ {
id: 'reanalyse-file-preview-btn', id: 'reanalyse-file-preview-btn',
type: ActionTypes.circleBtn, type: ActionTypes.circleBtn,
action: () => this._reanalyseFile(), action: () => this.#reanalyseFile(),
tooltip: _('file-preview.reanalyse-notification'), tooltip: _('file-preview.reanalyse-notification'),
tooltipClass: 'small', tooltipClass: 'small',
icon: 'iqser:refresh', icon: 'iqser:refresh',
@ -234,7 +232,7 @@ export class FileActionsComponent implements OnChanges {
{ {
id: 'toggle-automatic-analysis-btn', id: 'toggle-automatic-analysis-btn',
type: ActionTypes.circleBtn, type: ActionTypes.circleBtn,
action: () => this._toggleAutomaticAnalysis(), action: () => this.#toggleAutomaticAnalysis(),
tooltip: _('dossier-overview.start-auto-analysis'), tooltip: _('dossier-overview.start-auto-analysis'),
buttonType: this.isFilePreview ? CircleButtonTypes.warn : CircleButtonTypes.default, buttonType: this.isFilePreview ? CircleButtonTypes.warn : CircleButtonTypes.default,
icon: 'red:enable-analysis', icon: 'red:enable-analysis',
@ -243,7 +241,7 @@ export class FileActionsComponent implements OnChanges {
{ {
id: 'set-under-approval-btn', id: 'set-under-approval-btn',
type: ActionTypes.circleBtn, type: ActionTypes.circleBtn,
action: () => this._setFileUnderApproval(), action: () => this.#setFileUnderApproval(),
tooltip: _('dossier-overview.under-approval'), tooltip: _('dossier-overview.under-approval'),
icon: 'red:undo', icon: 'red:undo',
show: this.showUndoApproval, show: this.showUndoApproval,
@ -251,7 +249,7 @@ export class FileActionsComponent implements OnChanges {
{ {
id: 'ocr-file-btn', id: 'ocr-file-btn',
type: ActionTypes.circleBtn, type: ActionTypes.circleBtn,
action: () => this._ocrFile(), action: () => this.#ocrFile(),
tooltip: _('dossier-overview.ocr-file'), tooltip: _('dossier-overview.ocr-file'),
icon: 'iqser:ocr', icon: 'iqser:ocr',
show: this.showOCR, show: this.showOCR,
@ -259,7 +257,7 @@ export class FileActionsComponent implements OnChanges {
{ {
id: 'reanalyse-file-btn', id: 'reanalyse-file-btn',
type: ActionTypes.circleBtn, type: ActionTypes.circleBtn,
action: () => this._reanalyseFile(), action: () => this.#reanalyseFile(),
tooltip: _('dossier-overview.reanalyse.action'), tooltip: _('dossier-overview.reanalyse.action'),
icon: 'iqser:refresh', icon: 'iqser:refresh',
show: this.showReanalyseDossierOverview, show: this.showReanalyseDossierOverview,
@ -267,7 +265,7 @@ export class FileActionsComponent implements OnChanges {
{ {
id: 'toggle-analysis-btn', id: 'toggle-analysis-btn',
type: ActionTypes.toggle, type: ActionTypes.toggle,
action: () => this._toggleAnalysis(), action: () => this.#toggleAnalysis(),
disabled: !this.canToggleAnalysis, disabled: !this.canToggleAnalysis,
tooltip: this.toggleTooltip, tooltip: this.toggleTooltip,
class: { 'mr-24': this.isDossierOverviewList }, class: { 'mr-24': this.isDossierOverviewList },
@ -280,7 +278,7 @@ export class FileActionsComponent implements OnChanges {
} }
ngOnChanges() { ngOnChanges() {
this._setup(); this.#setup();
} }
async setFileApproved() { async setFileApproved() {
@ -305,7 +303,7 @@ export class FileActionsComponent implements OnChanges {
forceReanalysisAction($event: LongPressEvent) { forceReanalysisAction($event: LongPressEvent) {
this.analysisForced = !$event.touchEnd && this._userPreferenceService.areDevFeaturesEnabled; this.analysisForced = !$event.touchEnd && this._userPreferenceService.areDevFeaturesEnabled;
this._setup(); this.#setup();
} }
#showOCRConfirmationDialog(): Observable<boolean> { #showOCRConfirmationDialog(): Observable<boolean> {
@ -319,11 +317,11 @@ export class FileActionsComponent implements OnChanges {
return ref.afterClosed(); return ref.afterClosed();
} }
private _openImportRedactionsDialog() { #openImportRedactionsDialog() {
this._dialogService.openDialog('importRedactions', { dossierId: this.file.dossierId, fileId: this.file.fileId }); this._dialogService.openDialog('importRedactions', { dossierId: this.file.dossierId, fileId: this.file.fileId });
} }
private _openDeleteFileDialog() { #openDeleteFileDialog() {
this._dialogService.openDialog( this._dialogService.openDialog(
'confirm', 'confirm',
{ {
@ -335,7 +333,7 @@ export class FileActionsComponent implements OnChanges {
try { try {
const dossier = this._activeDossiersService.find(this.file.dossierId); const dossier = this._activeDossiersService.find(this.file.dossierId);
await firstValueFrom(this._fileManagementService.delete([this.file], this.file.dossierId)); await firstValueFrom(this._fileManagementService.delete([this.file], this.file.dossierId));
await this._injector.get(Router).navigate([`/${this._tenantContextHolder.currentTenant}${dossier.routerLink}`]); await this._injector.get(Router).navigate([`/${this._tenantsService.currentTenant}${dossier.routerLink}`]);
} catch (error) { } catch (error) {
this._injector.get(Toaster).error(_('error.http.generic'), { params: error }); this._injector.get(Toaster).error(_('error.http.generic'), { params: error });
} }
@ -344,7 +342,7 @@ export class FileActionsComponent implements OnChanges {
); );
} }
private _assign() { #assign() {
const files = [this.file]; const files = [this.file];
const targetStatus = this.file.workflowStatus; const targetStatus = this.file.workflowStatus;
const withCurrentUserAsDefault = true; const withCurrentUserAsDefault = true;
@ -352,29 +350,29 @@ export class FileActionsComponent implements OnChanges {
this._dialogService.openDialog('assignFile', { targetStatus, files, withCurrentUserAsDefault, withUnassignedOption }); this._dialogService.openDialog('assignFile', { targetStatus, files, withCurrentUserAsDefault, withUnassignedOption });
} }
private async _assignToMe() { async #assignToMe() {
await this._fileAssignService.assignToMe([this.file]); await this._fileAssignService.assignToMe([this.file]);
} }
private async _reanalyseFile() { async #reanalyseFile() {
const params: ReanalyzeQueryParams = { const params: ReanalyzeQueryParams = {
force: true, force: true,
triggeredByUser: true, triggeredByUser: true,
}; };
await firstValueFrom(this._reanalysisService.reanalyzeFilesForDossier([this.file], this.file.dossierId, params)); await this._reanalysisService.reanalyzeFilesForDossier([this.file], this.file.dossierId, params);
} }
private async _toggleAutomaticAnalysis() { async #toggleAutomaticAnalysis() {
this._loadingService.start(); this._loadingService.start();
await firstValueFrom(this._reanalysisService.toggleAutomaticAnalysis(this.file.dossierId, [this.file])); await firstValueFrom(this._reanalysisService.toggleAutomaticAnalysis(this.file.dossierId, [this.file]));
this._loadingService.stop(); this._loadingService.stop();
} }
private async _setFileUnderApproval() { async #setFileUnderApproval() {
await this._fileAssignService.assignApprover(this.file, true); await this._fileAssignService.assignApprover(this.file, true);
} }
private async _ocrFile() { async #ocrFile() {
if (this.file.lastManualChangeDate) { if (this.file.lastManualChangeDate) {
const confirm = await firstValueFrom(this.#showOCRConfirmationDialog()); const confirm = await firstValueFrom(this.#showOCRConfirmationDialog());
if (!confirm) { if (!confirm) {
@ -388,21 +386,21 @@ export class FileActionsComponent implements OnChanges {
viewerHeaderService.disable(ROTATION_ACTION_BUTTONS); viewerHeaderService.disable(ROTATION_ACTION_BUTTONS);
this._loadingService.start(); this._loadingService.start();
await firstValueFrom(this._reanalysisService.ocrFiles([this.file], this.file.dossierId)); await this._reanalysisService.ocrFiles([this.file], this.file.dossierId);
this._loadingService.stop(); this._loadingService.stop();
} }
private async _setFileUnderReview() { async #setFileUnderReview() {
await this._fileAssignService.assignReviewer(this.file, true); await this._fileAssignService.assignReviewer(this.file, true);
} }
private async _toggleAnalysis() { async #toggleAnalysis() {
this._loadingService.start(); this._loadingService.start();
await firstValueFrom(this._reanalysisService.toggleAnalysis(this.file.dossierId, [this.file], !this.file.excluded)); await this._reanalysisService.toggleAnalysis(this.file.dossierId, [this.file], !this.file.excluded);
this._loadingService.stop(); this._loadingService.stop();
} }
private _setup() { #setup() {
this.isDossierOverviewList = this.type === 'dossier-overview-list'; this.isDossierOverviewList = this.type === 'dossier-overview-list';
this.isDossierOverviewWorkflow = this.type === 'dossier-overview-workflow'; this.isDossierOverviewWorkflow = this.type === 'dossier-overview-workflow';
this.isDossierOverview = this.type.startsWith('dossier-overview'); this.isDossierOverview = this.type.startsWith('dossier-overview');

View File

@ -44,7 +44,7 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
async ngOnInit() { async ngOnInit() {
this._loadingService.start(); this._loadingService.start();
this.canEdit = this._permissionsService.canEditDossierDictionary(this.dossier); this.canEdit = this._permissionsService.canEditDossierDictionary(this.dossier);
await this._updateDossierDictionary(); await this.#updateDossierDictionary();
this._loadingService.stop(); this._loadingService.stop();
} }
@ -61,7 +61,7 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
), ),
); );
await this._updateDossierDictionary(); await this.#updateDossierDictionary();
return { success: true }; return { success: true };
} catch (error) { } catch (error) {
return { success: false }; return { success: false };
@ -75,12 +75,12 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
openEditDetailsDialog(): void { openEditDetailsDialog(): void {
const data = { dictionary: this.dossierDictionary, dossierId: this.dossier.id, readOnly: !this.canEdit }; const data = { dictionary: this.dossierDictionary, dossierId: this.dossier.id, readOnly: !this.canEdit };
this._dialogService.openDialog('editDictionaryDetails', data, async () => { this._dialogService.openDialog('editDictionaryDetails', data, async () => {
await this._updateDossierDictionary(); await this.#updateDossierDictionary();
}); });
} }
private async _updateDossierDictionary() { async #updateDossierDictionary() {
const { dossierId, dossierTemplateId } = this.dossier; const { dossierId, dossierTemplateId } = this.dossier;
this.dossierDictionary = await firstValueFrom(this._dictionaryService.loadDossierDictionary(dossierTemplateId, dossierId)); this.dossierDictionary = await this._dictionaryService.loadDossierDictionary(dossierTemplateId, dossierId);
} }
} }

View File

@ -12,7 +12,7 @@ import {
IconButtonTypes, IconButtonTypes,
IConfirmationDialogData, IConfirmationDialogData,
LoadingService, LoadingService,
TenantContextHolder, TenantsService,
TitleColors, TitleColors,
Toaster, Toaster,
} from '@iqser/common-ui'; } from '@iqser/common-ui';
@ -35,10 +35,10 @@ import { dateWithoutTime } from '@utils/functions';
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSectionInterface { export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSectionInterface {
readonly iconButtonTypes = IconButtonTypes;
@Input() dossier: Dossier; @Input() dossier: Dossier;
readonly iconButtonTypes = IconButtonTypes;
form: UntypedFormGroup; form: UntypedFormGroup;
statusPlaceholder: string; statusPlaceholder: string;
hasDueDate: boolean; hasDueDate: boolean;
@ -55,7 +55,7 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
private readonly _formBuilder: UntypedFormBuilder, private readonly _formBuilder: UntypedFormBuilder,
private readonly _dialogService: DossiersDialogService, private readonly _dialogService: DossiersDialogService,
private readonly _router: Router, private readonly _router: Router,
private readonly _tenantContextHolder: TenantContextHolder, private readonly _tenantsService: TenantsService,
private readonly _editDossierDialogRef: MatDialogRef<EditDossierDialogComponent>, private readonly _editDossierDialogRef: MatDialogRef<EditDossierDialogComponent>,
private readonly _toaster: Toaster, private readonly _toaster: Toaster,
private readonly _loadingService: LoadingService, private readonly _loadingService: LoadingService,
@ -153,7 +153,7 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
this._loadingService.start(); this._loadingService.start();
await firstValueFrom(this._trashService.deleteDossier(this.dossier)); await firstValueFrom(this._trashService.deleteDossier(this.dossier));
this._editDossierDialogRef.close(); this._editDossierDialogRef.close();
await this._router.navigate([`/${this._tenantContextHolder.currentTenant}${this.dossier.dossiersListRouterLink}`]); await this._router.navigate([`/${this._tenantsService.currentTenant}${this.dossier.dossiersListRouterLink}`]);
this._loadingService.stop(); this._loadingService.stop();
this._toaster.success(_('edit-dossier-dialog.delete-successful'), { this._toaster.success(_('edit-dossier-dialog.delete-successful'), {
params: { params: {

View File

@ -2,7 +2,7 @@ import { Component, Input, OnChanges } from '@angular/core';
import { PermissionsService } from '@services/permissions.service'; import { PermissionsService } from '@services/permissions.service';
import { Dossier, File, ProcessingFileStatuses } from '@red/domain'; import { Dossier, File, ProcessingFileStatuses } from '@red/domain';
import { FileDownloadService } from '@upload-download/services/file-download.service'; import { FileDownloadService } from '@upload-download/services/file-download.service';
import { CircleButtonType, CircleButtonTypes, defaultDialogConfig, TenantContextHolder, Toaster } from '@iqser/common-ui'; import { CircleButtonType, CircleButtonTypes, defaultDialogConfig, TenantsService, Toaster } from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { import {
@ -31,7 +31,7 @@ export class FileDownloadBtnComponent implements OnChanges {
constructor( constructor(
private readonly _permissionsService: PermissionsService, private readonly _permissionsService: PermissionsService,
private readonly _tenantContextHolder: TenantContextHolder, private readonly _tenantsService: TenantsService,
private readonly _fileDownloadService: FileDownloadService, private readonly _fileDownloadService: FileDownloadService,
private readonly _dialog: MatDialog, private readonly _dialog: MatDialog,
private readonly _toaster: Toaster, private readonly _toaster: Toaster,
@ -62,7 +62,7 @@ export class FileDownloadBtnComponent implements OnChanges {
await downloadRequest await downloadRequest
.then(() => .then(() =>
this._toaster.info(_('download-status.queued'), { this._toaster.info(_('download-status.queued'), {
params: { downloadHref: `/ui/${this._tenantContextHolder.currentTenant}/main/downloads` }, params: { downloadHref: `/ui/${this._tenantsService.currentTenant}/main/downloads` },
}), }),
) )
.catch(() => this._toaster.error(_('download-status.error'))); .catch(() => this._toaster.error(_('download-status.error')));

View File

@ -1,13 +1,6 @@
import { Component, Input, OnChanges, SimpleChanges, ViewChild } from '@angular/core'; import { Component, Input, OnChanges, SimpleChanges, ViewChild } from '@angular/core';
import { Action, ActionTypes, Dossier, File } from '@red/domain'; import { Action, ActionTypes, Dossier, File } from '@red/domain';
import { import { CircleButtonType, defaultDialogConfig, IqserTooltipPosition, TenantsService, Toaster, trackByFactory } from '@iqser/common-ui';
CircleButtonType,
defaultDialogConfig,
IqserTooltipPosition,
TenantContextHolder,
Toaster,
trackByFactory,
} from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { FileDownloadService } from '@upload-download/services/file-download.service'; import { FileDownloadService } from '@upload-download/services/file-download.service';
import { PermissionsService } from '@services/permissions.service'; import { PermissionsService } from '@services/permissions.service';
@ -41,7 +34,7 @@ export class ExpandableFileActionsComponent implements OnChanges {
constructor( constructor(
private readonly _fileDownloadService: FileDownloadService, private readonly _fileDownloadService: FileDownloadService,
private readonly _tenantContextHolder: TenantContextHolder, private readonly _tenantsService: TenantsService,
private readonly _toaster: Toaster, private readonly _toaster: Toaster,
private readonly _permissionsService: PermissionsService, private readonly _permissionsService: PermissionsService,
private readonly _dialog: MatDialog, private readonly _dialog: MatDialog,
@ -106,7 +99,7 @@ export class ExpandableFileActionsComponent implements OnChanges {
...result, ...result,
}); });
this._toaster.info(_('download-status.queued'), { this._toaster.info(_('download-status.queued'), {
params: { downloadHref: `/ui/${this._tenantContextHolder.currentTenant}/main/downloads` }, params: { downloadHref: `/ui/${this._tenantsService.currentTenant}/main/downloads` },
}); });
} }
} }

View File

@ -3,7 +3,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { DOSSIER_TEMPLATE_ID, DownloadFileType, IDossierRequest, IDossierTemplate, IReportTemplate } from '@red/domain'; import { DOSSIER_TEMPLATE_ID, DownloadFileType, IDossierRequest, IDossierTemplate, IReportTemplate } from '@red/domain';
import { UntypedFormGroup, Validators } from '@angular/forms'; import { UntypedFormGroup, Validators } from '@angular/forms';
import { downloadTypesTranslations } from '@translations/download-types-translations'; import { downloadTypesTranslations } from '@translations/download-types-translations';
import { BaseDialogComponent, IconButtonTypes, IqserPermissionsService, SaveOptions, TenantContextHolder } from '@iqser/common-ui'; import { BaseDialogComponent, IconButtonTypes, IqserPermissionsService, SaveOptions, TenantsService } from '@iqser/common-ui';
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service'; import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
import { ReportTemplateService } from '@services/report-template.service'; import { ReportTemplateService } from '@services/report-template.service';
@ -42,7 +42,7 @@ export class AddDossierDialogComponent extends BaseDialogComponent implements On
constructor( constructor(
readonly permissionsService: IqserPermissionsService, readonly permissionsService: IqserPermissionsService,
private readonly _tenantContextHolder: TenantContextHolder, private readonly _tenantsService: TenantsService,
private readonly _activeDossiersService: ActiveDossiersService, private readonly _activeDossiersService: ActiveDossiersService,
private readonly _dossierTemplatesService: DossierTemplatesService, private readonly _dossierTemplatesService: DossierTemplatesService,
private readonly _reportTemplateController: ReportTemplateService, private readonly _reportTemplateController: ReportTemplateService,
@ -83,7 +83,7 @@ export class AddDossierDialogComponent extends BaseDialogComponent implements On
this._loadingService.start(); this._loadingService.start();
const savedDossier = await firstValueFrom(this._activeDossiersService.createOrUpdate(this._formToObject())); const savedDossier = await firstValueFrom(this._activeDossiersService.createOrUpdate(this._formToObject()));
if (savedDossier) { if (savedDossier) {
await this._router.navigate([`/${this._tenantContextHolder.currentTenant}${savedDossier.routerLink}`]); await this._router.navigate([`/${this._tenantsService.currentTenant}${savedDossier.routerLink}`]);
if (options?.addMembers) { if (options?.addMembers) {
this._dialogService.openDialog('editDossier', { this._dialogService.openDialog('editDossier', {
dossierId: savedDossier.id, dossierId: savedDossier.id,

View File

@ -3,14 +3,14 @@ import { DownloadStatus, IDownloadStatus, IDownloadStatusResponse, IPrepareDownl
import { firstValueFrom, Observable } from 'rxjs'; import { firstValueFrom, Observable } from 'rxjs';
import { ConfigService } from '@services/config.service'; import { ConfigService } from '@services/config.service';
import { map, tap } from 'rxjs/operators'; import { map, tap } from 'rxjs/operators';
import { EntitiesService, mapEach, TenantContextHolder } from '@iqser/common-ui'; import { EntitiesService, mapEach, TenantsService } from '@iqser/common-ui';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
@Injectable() @Injectable()
export class FileDownloadService extends EntitiesService<IDownloadStatus, DownloadStatus> { export class FileDownloadService extends EntitiesService<IDownloadStatus, DownloadStatus> {
protected readonly _defaultModelPath = 'async/download'; protected readonly _defaultModelPath = 'async/download';
protected readonly _entityClass = DownloadStatus; protected readonly _entityClass = DownloadStatus;
protected readonly _tenantContext = inject(TenantContextHolder); protected readonly _tenantsService = inject(TenantsService);
constructor(private readonly _configService: ConfigService, private readonly _logger: NGXLogger) { constructor(private readonly _configService: ConfigService, private readonly _logger: NGXLogger) {
super(); super();
@ -36,7 +36,7 @@ export class FileDownloadService extends EntitiesService<IDownloadStatus, Downlo
const token = await this.generateToken(status.storageId); const token = await this.generateToken(status.storageId);
const anchor = document.createElement('a'); const anchor = document.createElement('a');
anchor.href = `${this._configService.values.API_URL}/async/download/with-ott/${token.value}?tenantId=${encodeURIComponent( anchor.href = `${this._configService.values.API_URL}/async/download/with-ott/${token.value}?tenantId=${encodeURIComponent(
this._tenantContext.currentTenant, this._tenantsService.currentTenant,
)}`; )}`;
anchor.download = status.filename; anchor.download = status.filename;
anchor.target = '_blank'; anchor.target = '_blank';

View File

@ -8,17 +8,17 @@ import { DossiersService } from './dossiers.service';
import { FilesMapService } from '../files/files-map.service'; import { FilesMapService } from '../files/files-map.service';
import { FeaturesService } from '../features.service'; import { FeaturesService } from '../features.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { TenantContextHolder } from '@iqser/common-ui'; import { TenantsService } from '@iqser/common-ui';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class ArchivedDossiersService extends DossiersService { export class ArchivedDossiersService extends DossiersService {
protected readonly _defaultModelPath = 'archived-dossiers';
readonly routerPath = ARCHIVE_ROUTE; readonly routerPath = ARCHIVE_ROUTE;
protected readonly _defaultModelPath = 'archived-dossiers';
readonly #activeDossiersService = inject(ActiveDossiersService); readonly #activeDossiersService = inject(ActiveDossiersService);
readonly #filesMapService = inject(FilesMapService); readonly #filesMapService = inject(FilesMapService);
readonly #featuresService = inject(FeaturesService); readonly #featuresService = inject(FeaturesService);
readonly #tenantContextHolder = inject(TenantContextHolder); readonly #tenantsService = inject(TenantsService);
readonly #router = inject(Router); readonly #router = inject(Router);
archive(dossiers: Dossier[]): Observable<unknown> { archive(dossiers: Dossier[]): Observable<unknown> {
@ -42,7 +42,7 @@ export class ArchivedDossiersService extends DossiersService {
if (!this.#activeDossiersService.all.find(d => d.dossierTemplateId === dossierTemplateId)) { if (!this.#activeDossiersService.all.find(d => d.dossierTemplateId === dossierTemplateId)) {
route = route.replace(DOSSIERS_ROUTE, ARCHIVE_ROUTE); route = route.replace(DOSSIERS_ROUTE, ARCHIVE_ROUTE);
} }
await this.#router.navigate([`/${this.#tenantContextHolder.currentTenant}${route}`]); await this.#router.navigate([`/${this.#tenantsService.currentTenant}${route}`]);
}), }),
catchError(showArchiveFailedToast), catchError(showArchiveFailedToast),
); );

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { forkJoin, Observable, of, throwError, zip } from 'rxjs'; import { firstValueFrom, forkJoin, Observable, throwError, zip } from 'rxjs';
import { EntitiesService, List, QueryParam, Toaster } from '@iqser/common-ui'; import { EntitiesService, List, QueryParam, Toaster } from '@iqser/common-ui';
import { Dictionary, DictionaryEntryType, DictionaryEntryTypes, IDictionary, IUpdateDictionary, SuperTypes } from '@red/domain'; import { Dictionary, DictionaryEntryType, DictionaryEntryTypes, IDictionary, IUpdateDictionary, SuperTypes } from '@red/domain';
import { catchError, map, switchMap, tap } from 'rxjs/operators'; import { catchError, map, switchMap, tap } from 'rxjs/operators';
@ -170,23 +170,20 @@ export class DictionaryService extends EntitiesService<IDictionary, Dictionary>
return possibleDictionaries; return possibleDictionaries;
} }
loadDossierDictionary(dossierTemplateId: string, dossierId: string): Observable<Dictionary> { async loadDossierDictionary(dossierTemplateId: string, dossierId: string): Promise<Dictionary> {
return this.getForType(dossierTemplateId, 'dossier_redaction', dossierId).pipe( const promise = firstValueFrom(this.getForType(dossierTemplateId, 'dossier_redaction', dossierId));
map( const dict = await promise.catch(() => undefined);
dictionary => if (dict) {
new Dictionary({ const dictionary = new Dictionary({
...dictionary, ...dict,
type: 'dossier_redaction', type: 'dossier_redaction',
}), });
), this._dossierDictionariesMapService.set(dossierId, [dictionary]);
tap(dictionary => { return dictionary;
this._dossierDictionariesMapService.set(dossierId, [dictionary]); }
}),
catchError(() => { this._dossierDictionariesMapService.set(dossierId, []);
this._dossierDictionariesMapService.set(dossierId, []); return undefined;
return of(null);
}),
);
} }
loadDictionaryData(dossierTemplatesIds: string[]): Observable<Dictionary[][]> { loadDictionaryData(dossierTemplatesIds: string[]): Observable<Dictionary[][]> {

View File

@ -1,5 +1,5 @@
import { Inject, Injectable, OnDestroy } from '@angular/core'; import { Inject, Injectable, OnDestroy } from '@angular/core';
import { BASE_HREF, EntitiesService, getConfig, List, mapEach, QueryParam, TenantContextHolder } from '@iqser/common-ui'; import { BASE_HREF, EntitiesService, getConfig, List, mapEach, QueryParam, TenantsService } from '@iqser/common-ui';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { EMPTY, firstValueFrom, iif, merge, Observable, of, Subscription, timer } from 'rxjs'; import { EMPTY, firstValueFrom, iif, merge, Observable, of, Subscription, timer } from 'rxjs';
import { AppConfig, Dossier, INotification, Notification, NotificationTypes } from '@red/domain'; import { AppConfig, Dossier, INotification, Notification, NotificationTypes } from '@red/domain';
@ -30,7 +30,7 @@ export class NotificationsService extends EntitiesService<INotification, Notific
constructor( constructor(
@Inject(BASE_HREF) private readonly _baseHref: string, @Inject(BASE_HREF) private readonly _baseHref: string,
private readonly _translateService: TranslateService, private readonly _translateService: TranslateService,
private readonly _tenantContextHolder: TenantContextHolder, private readonly _tenantsService: TenantsService,
private readonly _userService: UserService, private readonly _userService: UserService,
private readonly _dossiersCacheService: DossiersCacheService, private readonly _dossiersCacheService: DossiersCacheService,
) { ) {
@ -78,7 +78,7 @@ export class NotificationsService extends EntitiesService<INotification, Notific
const dossier = this._dossiersCacheService.get(dossierId); const dossier = this._dossiersCacheService.get(dossierId);
const fileName = notification.target.fileName; const fileName = notification.target.fileName;
const dossierName = notification.target?.dossierName ?? dossier?.dossierName; const dossierName = notification.target?.dossierName ?? dossier?.dossierName;
const downloadHref = `/ui/${this._tenantContextHolder.currentTenant}/main/downloads`; const downloadHref = `/ui/${this._tenantsService.currentTenant}/main/downloads`;
return this._translateService.instant(translation, { return this._translateService.instant(translation, {
fileHref: this._getFileHref(dossier, fileId), fileHref: this._getFileHref(dossier, fileId),
@ -95,7 +95,7 @@ export class NotificationsService extends EntitiesService<INotification, Notific
} }
private _getDossierHref(dossier: Dossier): string { private _getDossierHref(dossier: Dossier): string {
return dossier ? `${this._baseHref}/${this._tenantContextHolder.currentTenant}${dossier.routerLink}` : null; return dossier ? `${this._baseHref}/${this._tenantsService.currentTenant}${dossier.routerLink}` : null;
} }
private _getUsername(userId: string | undefined) { private _getUsername(userId: string | undefined) {

View File

@ -34,7 +34,7 @@ export class ReanalysisService extends GenericService<unknown> {
return this._post(body, `include-pages/${dossierId}/${file.id}`).pipe(switchMap(() => this._filesService.reload(dossierId, file))); return this._post(body, `include-pages/${dossierId}/${file.id}`).pipe(switchMap(() => this._filesService.reload(dossierId, file)));
} }
reanalyzeFilesForDossier(files: List<File>, dossierId: string, params?: ReanalyzeQueryParams) { async reanalyzeFilesForDossier(files: List<File>, dossierId: string, params?: ReanalyzeQueryParams) {
const fileIds = files.map(f => f.id); const fileIds = files.map(f => f.id);
const queryParams: QueryParam[] = []; const queryParams: QueryParam[] = [];
if (params?.force) { if (params?.force) {
@ -44,19 +44,19 @@ export class ReanalysisService extends GenericService<unknown> {
queryParams.push({ key: 'triggeredByUser', value: true }); queryParams.push({ key: 'triggeredByUser', value: true });
} }
return this._post(fileIds, `reanalyze/${dossierId}/bulk`, queryParams).pipe(switchMap(() => this._filesService.loadAll(dossierId))); await firstValueFrom(this._post(fileIds, `reanalyze/${dossierId}/bulk`, queryParams));
return firstValueFrom(this._filesService.loadAll(dossierId));
} }
toggleAnalysis(dossierId: string, files: List<File>, excluded?: boolean) { async toggleAnalysis(dossierId: string, files: List<File>, excluded?: boolean) {
const fileIds = files.map(f => f.id); const fileIds = files.map(f => f.id);
const queryParams: QueryParam[] = []; const queryParams: QueryParam[] = [];
if (excluded) { if (excluded) {
queryParams.push({ key: 'excluded', value: excluded }); queryParams.push({ key: 'excluded', value: excluded });
} }
return this._post(fileIds, `toggle-analysis/${dossierId}/bulk`, queryParams).pipe( await firstValueFrom(this._post(fileIds, `toggle-analysis/${dossierId}/bulk`, queryParams));
switchMap(() => this._filesService.loadAll(dossierId)), return firstValueFrom(this._filesService.loadAll(dossierId));
);
} }
toggleAutomaticAnalysis(dossierId: string, files: File[]) { toggleAutomaticAnalysis(dossierId: string, files: File[]) {
@ -77,9 +77,10 @@ export class ReanalysisService extends GenericService<unknown> {
); );
} }
ocrFiles(files: List<File>, dossierId: string) { async ocrFiles(files: List<File>, dossierId: string) {
const fileIds = files.map(f => f.id); const fileIds = files.map(f => f.id);
return this._post(fileIds, `ocr/reanalyze/${dossierId}/bulk`).pipe(switchMap(() => this._filesService.loadAll(dossierId))); await firstValueFrom(this._post(fileIds, `ocr/reanalyze/${dossierId}/bulk`));
return firstValueFrom(this._filesService.loadAll(dossierId));
} }
async reanalyzeDossier(dossier: Dossier, force?: boolean) { async reanalyzeDossier(dossier: Dossier, force?: boolean) {

View File

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router'; import { NavigationEnd, Router } from '@angular/router';
import { filter } from 'rxjs/operators'; import { filter } from 'rxjs/operators';
import { TenantContextHolder } from '@iqser/common-ui'; import { TenantsService } from '@iqser/common-ui';
const LAST_DOSSIERS_SCREEN = 'routerHistory_lastDossiersScreen'; const LAST_DOSSIERS_SCREEN = 'routerHistory_lastDossiersScreen';
@ -11,7 +11,7 @@ const LAST_DOSSIERS_SCREEN = 'routerHistory_lastDossiersScreen';
export class RouterHistoryService { export class RouterHistoryService {
private _lastDossiersScreen = localStorage.getItem(LAST_DOSSIERS_SCREEN); private _lastDossiersScreen = localStorage.getItem(LAST_DOSSIERS_SCREEN);
constructor(private readonly _router: Router, private readonly _tenantContextHolder: TenantContextHolder) { constructor(private readonly _router: Router, private readonly _tenantsService: TenantsService) {
// eslint-disable-next-line rxjs/no-ignored-subscription // eslint-disable-next-line rxjs/no-ignored-subscription
this._router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe((event: NavigationEnd) => { this._router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe((event: NavigationEnd) => {
if (event.url.includes('/dossiers') || event.url.includes('/archive')) { if (event.url.includes('/dossiers') || event.url.includes('/archive')) {
@ -23,7 +23,7 @@ export class RouterHistoryService {
navigateToLastDossiersScreen(): void { navigateToLastDossiersScreen(): void {
if (this._router.url === decodeURI(this._lastDossiersScreen)) { if (this._router.url === decodeURI(this._lastDossiersScreen)) {
this._router.navigate(['/' + this._tenantContextHolder.currentTenant]); this._router.navigate(['/' + this._tenantsService.currentTenant]);
} else { } else {
const url = decodeURI(this._lastDossiersScreen).split('?')[0]; const url = decodeURI(this._lastDossiersScreen).split('?')[0];
// todo links // todo links

View File

@ -1,28 +1,25 @@
import { inject, Injectable } from '@angular/core'; import { inject, Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { UserService } from './user.service'; import { IqserPermissionsService, IqserRoleGuard } from '@iqser/common-ui';
import { IqserPermissionsService, IqserRoleGuard, TenantContextHolder } from '@iqser/common-ui';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class RedRoleGuard extends IqserRoleGuard { export class RedRoleGuard extends IqserRoleGuard {
protected readonly _userService = inject(UserService);
protected readonly _permissionsService = inject(IqserPermissionsService); protected readonly _permissionsService = inject(IqserPermissionsService);
protected readonly _tenantContextHolder = inject(TenantContextHolder);
async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> { async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
const currentUser = this._userService.currentUser; const currentUser = this._userService.currentUser;
if (!currentUser?.hasAnyRole) { if (!currentUser?.hasAnyRole) {
await this._router.navigate([`/${this._tenantContextHolder.currentTenant}/auth-error`]); await this._router.navigate([`/${this._tenantsService.currentTenant}/auth-error`]);
this._loadingService.stop(); this._loadingService.stop();
return false; return false;
} }
// we have at least 1 RED Role -> if it's not user he must be an admin // we have at least 1 RED Role -> if it's not user he must be an admin
if (currentUser.isUserAdmin && !currentUser.isAdmin && state.url.includes('admin') && !state.url.includes('users')) { if (currentUser.isUserAdmin && !currentUser.isAdmin && state.url.includes('admin') && !state.url.includes('users')) {
await this._router.navigate([`/${this._tenantContextHolder.currentTenant}/main/admin/users`]); await this._router.navigate([`/${this._tenantsService.currentTenant}/main/admin/users`]);
return false; return false;
} }
@ -32,7 +29,7 @@ export class RedRoleGuard extends IqserRoleGuard {
!currentUser.isUser && !currentUser.isUser &&
!(state.url.includes('/main/admin/users') || state.url.includes('/main/account')) !(state.url.includes('/main/admin/users') || state.url.includes('/main/account'))
) { ) {
await this._router.navigate([`/${this._tenantContextHolder.currentTenant}/main/admin/users`]); await this._router.navigate([`/${this._tenantsService.currentTenant}/main/admin/users`]);
return false; return false;
} }
@ -41,9 +38,9 @@ export class RedRoleGuard extends IqserRoleGuard {
return true; return true;
} }
if (!currentUser.isUser) { if (!currentUser.isUser) {
await this._router.navigate([`/${this._tenantContextHolder.currentTenant}/main/admin`]); await this._router.navigate([`/${this._tenantsService.currentTenant}/main/admin`]);
} else { } else {
await this._router.navigate([`/${this._tenantContextHolder.currentTenant}`]); await this._router.navigate([`/${this._tenantsService.currentTenant}`]);
} }
return false; return false;
} }

View File

@ -5,7 +5,7 @@ import { UserService } from '@users/user.service';
import { SystemPreferencesService } from '@services/system-preferences.service'; import { SystemPreferencesService } from '@services/system-preferences.service';
import { UserPreferenceService } from '@users/user-preference.service'; import { UserPreferenceService } from '@users/user-preference.service';
import { LicenseService } from '@services/license.service'; import { LicenseService } from '@services/license.service';
import { BASE_HREF, IqserPermissionsService, LoadingService, TenantContextHolder } from '@iqser/common-ui'; import { BASE_HREF, IqserPermissionsService, LoadingService, TenantsService } from '@iqser/common-ui';
import { FeaturesService } from '@services/features.service'; import { FeaturesService } from '@services/features.service';
import { GeneralSettingsService } from '@services/general-settings.service'; import { GeneralSettingsService } from '@services/general-settings.service';
import { tap } from 'rxjs/operators'; import { tap } from 'rxjs/operators';
@ -32,7 +32,7 @@ export const mainResolver: ResolveFn<void> = async () => {
const systemPreferencesService = inject(SystemPreferencesService); const systemPreferencesService = inject(SystemPreferencesService);
const userPreferenceService = inject(UserPreferenceService); const userPreferenceService = inject(UserPreferenceService);
const tenantContextHolder = inject(TenantContextHolder); const tenantsService = inject(TenantsService);
const licenseService = inject(LicenseService); const licenseService = inject(LicenseService);
const loadingService = inject(LoadingService); const loadingService = inject(LoadingService);
const configService = inject(ConfigService); const configService = inject(ConfigService);
@ -53,7 +53,7 @@ export const mainResolver: ResolveFn<void> = async () => {
const lastDossierTemplate = userPreferenceService.getLastDossierTemplate(); const lastDossierTemplate = userPreferenceService.getLastDossierTemplate();
if (lastDossierTemplate) { if (lastDossierTemplate) {
redirectToLastDossierTemplate(baseHref, tenantContextHolder.currentTenant, lastDossierTemplate); redirectToLastDossierTemplate(baseHref, tenantsService.currentTenant, lastDossierTemplate);
} }
loadingService.stop(); loadingService.stop();

@ -1 +1 @@
Subproject commit dbfde290c877d41142bf9ea7430fd4359cf223b2 Subproject commit d0551742ecfce6a473ab1431ce890372b1b1a40f