From 7d6d63f27796327dd5e43b24642376cabe9e9359 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Tue, 17 Oct 2023 21:25:50 +0300 Subject: [PATCH] RED-3800 some updates --- .../license-screen.component.html | 4 ++-- .../license-screen.component.ts | 24 +++++++++---------- ...navigate-last-dossiers-screen.directive.ts | 2 +- .../app/services/router-history.service.ts | 20 +++++++++------- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/apps/red-ui/src/app/modules/admin/screens/license/license-screen/license-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/license/license-screen/license-screen.component.html index 0c253fc96..cec5d3bbf 100644 --- a/apps/red-ui/src/app/modules/admin/screens/license/license-screen/license-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/license/license-screen/license-screen.component.html @@ -10,12 +10,12 @@
-
{{ configService.values.BACKEND_APP_VERSION || '-' }}
+
{{ config.BACKEND_APP_VERSION || '-' }}
-
{{ configService.values.APP_NAME || '-' }}
+
{{ config.APP_NAME || '-' }}
diff --git a/apps/red-ui/src/app/modules/admin/screens/license/license-screen/license-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/license/license-screen/license-screen.component.ts index e16b8642f..8a3e784ef 100644 --- a/apps/red-ui/src/app/modules/admin/screens/license/license-screen/license-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/license/license-screen/license-screen.component.ts @@ -1,23 +1,24 @@ import { Component } from '@angular/core'; -import { ConfigService } from '@services/config.service'; -import { TranslateService } from '@ngx-translate/core'; -import { ButtonConfig, IconButtonTypes, IqserPermissionsService } from '@iqser/common-ui'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; -import { RouterHistoryService } from '@services/router-history.service'; -import { LicenseService } from '@services/license.service'; -import { Roles } from '@users/roles'; -import type { User } from '@red/domain'; +import { List } from '@common-ui/utils'; +import { ButtonConfig, getConfig, IconButtonTypes, IqserPermissionsService } from '@iqser/common-ui'; import { getCurrentUser } from '@iqser/common-ui/lib/users'; +import { TranslateService } from '@ngx-translate/core'; +import type { AppConfig, User } from '@red/domain'; +import { LicenseService } from '@services/license.service'; +import { RouterHistoryService } from '@services/router-history.service'; +import { Roles } from '@users/roles'; @Component({ templateUrl: './license-screen.component.html', styleUrls: ['./license-screen.component.scss'], }) export class LicenseScreenComponent { - readonly roles = Roles; - readonly currentUser = getCurrentUser(); - readonly currentYear = new Date().getFullYear(); - readonly buttonConfigs: readonly ButtonConfig[] = [ + protected readonly config = getConfig(); + protected readonly roles = Roles; + protected readonly currentUser = getCurrentUser(); + protected readonly currentYear = new Date().getFullYear(); + protected readonly buttonConfigs: List = [ { label: _('license-info-screen.email-report'), action: (): void => this.sendMail(), @@ -28,7 +29,6 @@ export class LicenseScreenComponent { ]; constructor( - readonly configService: ConfigService, readonly licenseService: LicenseService, readonly permissionsService: IqserPermissionsService, readonly routerHistoryService: RouterHistoryService, diff --git a/apps/red-ui/src/app/modules/shared/directives/navigate-last-dossiers-screen.directive.ts b/apps/red-ui/src/app/modules/shared/directives/navigate-last-dossiers-screen.directive.ts index d2c18de3d..7410fa19c 100644 --- a/apps/red-ui/src/app/modules/shared/directives/navigate-last-dossiers-screen.directive.ts +++ b/apps/red-ui/src/app/modules/shared/directives/navigate-last-dossiers-screen.directive.ts @@ -8,6 +8,6 @@ export class NavigateLastDossiersScreenDirective { constructor(private readonly _routerHistoryService: RouterHistoryService) {} @HostListener('click') onClick() { - this._routerHistoryService.navigateToLastDossiersScreen(); + return this._routerHistoryService.navigateToLastDossiersScreen(); } } diff --git a/apps/red-ui/src/app/services/router-history.service.ts b/apps/red-ui/src/app/services/router-history.service.ts index db9fd7123..4d928808c 100644 --- a/apps/red-ui/src/app/services/router-history.service.ts +++ b/apps/red-ui/src/app/services/router-history.service.ts @@ -1,10 +1,10 @@ import { effect, Injectable } from '@angular/core'; import { NavigationEnd, Router } from '@angular/router'; -import { filter } from 'rxjs/operators'; +import { JwtToken } from '@guards/if-logged-in.guard'; import { TenantsService } from '@iqser/common-ui/lib/tenants'; import jwt_decode from 'jwt-decode'; import { KeycloakService } from 'keycloak-angular'; -import { JwtToken } from '@guards/if-logged-in.guard'; +import { filter } from 'rxjs/operators'; const LAST_DOSSIERS_SCREEN = 'routerHistory_lastDossiersScreen'; @@ -28,6 +28,10 @@ export class RouterHistoryService { } }); const ref = effect(async () => { + if (!(await _keycloakService.isLoggedIn())) { + return; + } + const token = await this._keycloakService.getToken(); if (this._tenantsService.activeTenantId.length === 0 || !token) { return; @@ -45,14 +49,14 @@ export class RouterHistoryService { }); } - navigateToLastDossiersScreen(): void { + navigateToLastDossiersScreen() { const lastDossiersScreen = localStorage.getItem(LAST_DOSSIERS_SCREEN); if (this._router.url === decodeURI(lastDossiersScreen) || lastDossiersScreen === null) { - this._router.navigate(['/' + this._tenantsService.activeTenantId]); - } else { - const url = decodeURI(lastDossiersScreen).split('?')[0]; - // todo links - this._router.navigate([url]); + return this._router.navigate(['/' + this._tenantsService.activeTenantId]); } + + const url = decodeURI(lastDossiersScreen).split('?')[0]; + // todo links + return this._router.navigate([url]); } }