diff --git a/src/lib/filtering/models/nested-filter.ts b/src/lib/filtering/models/nested-filter.ts index 0087b85..26afa82 100644 --- a/src/lib/filtering/models/nested-filter.ts +++ b/src/lib/filtering/models/nested-filter.ts @@ -8,8 +8,8 @@ export class NestedFilter extends Filter implements INestedFilter, IListable { disabled?: boolean; helpModeKey?: string; readonly children: Filter[]; - readonly skipTranslation?: boolean; - readonly metadata?: Record; + override readonly skipTranslation?: boolean; + override readonly metadata?: Record; constructor(nestedFilter: INestedFilter) { super(nestedFilter); diff --git a/src/lib/inputs/dynamic-input/dynamic-input.component.ts b/src/lib/inputs/dynamic-input/dynamic-input.component.ts index acd0ce8..7d3ba7f 100644 --- a/src/lib/inputs/dynamic-input/dynamic-input.component.ts +++ b/src/lib/inputs/dynamic-input/dynamic-input.component.ts @@ -51,7 +51,7 @@ export class DynamicInputComponent extends FormFieldComponent { readonly isNumber = computed(() => this.type() === InputTypes.NUMBER); readonly isText = computed(() => this.type() === InputTypes.TEXT); - writeValue(input: DynamicInput): void { + override writeValue(input: DynamicInput): void { this.input.set(input); } diff --git a/src/lib/services/iqser-user-preference.service.ts b/src/lib/services/iqser-user-preference.service.ts index 16256a8..961c25c 100644 --- a/src/lib/services/iqser-user-preference.service.ts +++ b/src/lib/services/iqser-user-preference.service.ts @@ -16,7 +16,7 @@ export const KEYS = { export abstract class IqserUserPreferenceService extends GenericService { #userAttributes: UserAttributes = {}; protected abstract readonly _devFeaturesEnabledKey: string; - protected readonly _serviceName: string = 'tenant-user-management'; + protected override readonly _serviceName: string = 'tenant-user-management'; get userAttributes(): UserAttributes { return this.#userAttributes; diff --git a/src/lib/tenants/services/keycloak-status.service.ts b/src/lib/tenants/services/keycloak-status.service.ts index 54ece2a..4ad9b7f 100644 --- a/src/lib/tenants/services/keycloak-status.service.ts +++ b/src/lib/tenants/services/keycloak-status.service.ts @@ -1,7 +1,9 @@ import { inject, Injectable } from '@angular/core'; -import { KeycloakService } from 'keycloak-angular'; +import { KeycloakEventType, KeycloakService } from 'keycloak-angular'; import { NGXLogger } from 'ngx-logger'; +import { filter, switchMap } from 'rxjs/operators'; import { getConfig } from '../../services/iqser-config.service'; +import { log, shareLast } from '../../utils'; import { UI_ROOT } from '../../utils/tokens'; import { getKeycloakOptions } from '../keycloak-options'; import { TenantsService } from './tenants.service'; @@ -13,6 +15,12 @@ export class KeycloakStatusService { readonly #tenantsService = inject(TenantsService); readonly #uiRoot = inject(UI_ROOT); readonly #logger = inject(NGXLogger); + readonly token$ = this.#keycloakService.keycloakEvents$.pipe( + log('[KEYCLOAK] New event:'), + filter(event => event.type === KeycloakEventType.OnAuthSuccess || event.type === KeycloakEventType.OnAuthRefreshSuccess), + switchMap(() => this.#keycloakService.getToken()), + shareLast(), + ); createLoginUrlAndExecute(username?: string | null) { const keycloakInstance = this.#keycloakService?.getKeycloakInstance(); diff --git a/src/lib/tenants/services/tenants.service.ts b/src/lib/tenants/services/tenants.service.ts index bc5908b..a8ee92c 100644 --- a/src/lib/tenants/services/tenants.service.ts +++ b/src/lib/tenants/services/tenants.service.ts @@ -1,10 +1,10 @@ import { inject, Injectable, signal } from '@angular/core'; import dayjs from 'dayjs'; import { NGXLogger } from 'ngx-logger'; -import { List } from '../../utils'; -import { GenericService } from '../../services'; -import { Tenant, TenantDetails } from '../types'; import { Observable } from 'rxjs'; +import { GenericService } from '../../services'; +import { List } from '../../utils'; +import { Tenant, TenantDetails } from '../types'; export interface IStoredTenantId { readonly tenantId: string; @@ -28,7 +28,7 @@ export class TenantsService extends GenericService { }; readonly #activeTenantId = signal(''); protected readonly _defaultModelPath = 'tenants'; - protected readonly _serviceName: string = 'tenant-user-management'; + protected override readonly _serviceName: string = 'tenant-user-management'; get activeTenantId() { return this.#activeTenantId(); diff --git a/src/lib/translations/iqser-translate-parser.service.ts b/src/lib/translations/iqser-translate-parser.service.ts index 973f5de..949fe32 100644 --- a/src/lib/translations/iqser-translate-parser.service.ts +++ b/src/lib/translations/iqser-translate-parser.service.ts @@ -4,7 +4,7 @@ import { escapeHtml } from '../utils'; @Injectable() export class IqserTranslateParser extends TranslateDefaultParser { - interpolate(expr: any, params?: Record) { + override interpolate(expr: any, params?: Record) { const entries = Object.entries(params ?? {}); const escapedParams = entries.reduce((acc, [key, value]) => ({ ...acc, [key]: escapeHtml(value) }), {}); return super.interpolate(expr, escapedParams); diff --git a/src/lib/users/services/iqser-user.service.ts b/src/lib/users/services/iqser-user.service.ts index 254ab98..555abe6 100644 --- a/src/lib/users/services/iqser-user.service.ts +++ b/src/lib/users/services/iqser-user.service.ts @@ -23,11 +23,11 @@ export abstract class IqserUserService< Interface extends IIqserUser = IIqserUser, Class extends IqserUser & Interface = IqserUser & Interface, > extends EntitiesService { - readonly currentUser$: Observable; - protected abstract readonly _defaultModelPath: string; + readonly #uiRoot = inject(UI_ROOT); + protected abstract override readonly _defaultModelPath: string; protected abstract readonly _permissionsFilter: (role: string) => boolean; protected abstract readonly _rolesFilter: (role: string) => boolean; - protected abstract readonly _entityClass: new (entityInterface: Interface | KeycloakProfile, ...args: unknown[]) => Class; + protected abstract override readonly _entityClass: new (entityInterface: Interface | KeycloakProfile, ...args: unknown[]) => Class; protected readonly _currentUser$ = new BehaviorSubject(undefined); protected readonly _toaster = inject(Toaster); protected readonly _keycloakService = inject(KeycloakService); @@ -35,8 +35,8 @@ export abstract class IqserUserService< protected readonly _keycloakStatusService = inject(KeycloakStatusService); protected readonly _permissionsService = inject(IqserPermissionsService, { optional: true }); protected readonly _rolesService = inject(IqserRolesService, { optional: true }); - protected readonly _serviceName: string = 'tenant-user-management'; - readonly #uiRoot = inject(UI_ROOT); + protected override readonly _serviceName: string = 'tenant-user-management'; + readonly currentUser$: Observable; constructor() { super(); @@ -80,7 +80,7 @@ export abstract class IqserUserService< await this._keycloakService.login({ action: 'UPDATE_PASSWORD' }); } - loadAll() { + override loadAll() { return this.getAll().pipe( mapEach(user => new this._entityClass(user, user.roles, user.userId)), tap(users => this.setEntities(users)), @@ -121,7 +121,7 @@ export abstract class IqserUserService< return this.find(userId)?.name; } - getAll(url = this._defaultModelPath): Observable { + override getAll(url = this._defaultModelPath): Observable { return super.getAll(url, [{ key: 'refreshCache', value: true }]); } @@ -157,12 +157,12 @@ export abstract class IqserUserService< return this._post(body); } - delete(userIds: List) { + override delete(userIds: List) { const queryParams = userIds.map(userId => ({ key: 'userId', value: userId })); return super.delete(userIds, this._defaultModelPath, queryParams); } - find(id: string): Class | undefined { + override find(id: string): Class | undefined { if (id?.toLowerCase() === 'system') { return this.newSystemUser(); }