Compare commits
1 Commits
master
...
VM/RED-103
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fed8b85208 |
@ -3,7 +3,7 @@ import { Title } from '@angular/platform-browser';
|
|||||||
import { CacheApiService } from '../caching/cache-api.service';
|
import { CacheApiService } from '../caching/cache-api.service';
|
||||||
import { wipeAllCaches } from '../caching/cache-utils';
|
import { wipeAllCaches } from '../caching/cache-utils';
|
||||||
import { IqserAppConfig } from '../utils/iqser-app-config';
|
import { IqserAppConfig } from '../utils/iqser-app-config';
|
||||||
import { LANDING_PAGE_THEMES, MANUAL_BASE_URL, THEME_DIRECTORIES } from '../utils/constants';
|
import { MANUAL_BASE_URL, THEME_DIRECTORIES } from '../utils/constants';
|
||||||
import { IStoredTenantId, TenantsService } from '../tenants';
|
import { IStoredTenantId, TenantsService } from '../tenants';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -14,7 +14,6 @@ export class IqserConfigService<T extends IqserAppConfig = IqserAppConfig> {
|
|||||||
|
|
||||||
constructor(@Inject('Doesnt matter') protected _values: T) {
|
constructor(@Inject('Doesnt matter') protected _values: T) {
|
||||||
this._checkFrontendVersion();
|
this._checkFrontendVersion();
|
||||||
this.#updateAppType();
|
|
||||||
this._titleService.setTitle(this._values.APP_NAME);
|
this._titleService.setTitle(this._values.APP_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,28 +47,6 @@ export class IqserConfigService<T extends IqserAppConfig = IqserAppConfig> {
|
|||||||
await this._cacheApiService.cacheValue('FRONTEND_APP_VERSION', version);
|
await this._cacheApiService.cacheValue('FRONTEND_APP_VERSION', version);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#updateAppType() {
|
|
||||||
const storedTenants = this._tenantsService.getStoredTenants();
|
|
||||||
if (storedTenants.length) {
|
|
||||||
const isRedaction = !!storedTenants.find(t => !t.documine);
|
|
||||||
const isDocumine = !!storedTenants.find(t => t.documine);
|
|
||||||
const landingPageTheme =
|
|
||||||
isRedaction && isDocumine
|
|
||||||
? LANDING_PAGE_THEMES.MIXED
|
|
||||||
: isDocumine
|
|
||||||
? LANDING_PAGE_THEMES.DOCUMINE
|
|
||||||
: LANDING_PAGE_THEMES.REDACT_MANAGER;
|
|
||||||
|
|
||||||
this._values = {
|
|
||||||
...this._values,
|
|
||||||
LANDING_PAGE_THEME: landingPageTheme,
|
|
||||||
APP_NAME: landingPageTheme === LANDING_PAGE_THEMES.MIXED ? 'Knecon Cloud' : isDocumine ? 'DocuMine' : 'RedactManager',
|
|
||||||
IS_DOCUMINE: isDocumine,
|
|
||||||
THEME: !isDocumine ? THEME_DIRECTORIES.REDACT : THEME_DIRECTORIES.SCM,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getConfig<T extends IqserAppConfig = IqserAppConfig>() {
|
export function getConfig<T extends IqserAppConfig = IqserAppConfig>() {
|
||||||
|
|||||||
@ -119,6 +119,11 @@ export class TenantsService extends GenericService<Tenant> {
|
|||||||
this.#logger.info('[TENANTS] Stored tenants at logout: ', storedTenants);
|
this.#logger.info('[TENANTS] Stored tenants at logout: ', storedTenants);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearStoredTenants() {
|
||||||
|
this.#logger.warn('[TENANTS] Delete all stored tenants');
|
||||||
|
localStorage.removeItem(STORED_TENANTS_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
getActiveTenant<TD extends TenantDetails>(): Observable<Tenant<TD>> {
|
getActiveTenant<TD extends TenantDetails>(): Observable<Tenant<TD>> {
|
||||||
return this._getOne([this.activeTenantId]);
|
return this._getOne([this.activeTenantId]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { ChangeDetectionStrategy, Component, inject, Input } from '@angular/core';
|
import { AfterViewInit, ChangeDetectionStrategy, Component, inject, Input, OnInit } from '@angular/core';
|
||||||
import { FormBuilder, Validators } from '@angular/forms';
|
import { FormBuilder, Validators } from '@angular/forms';
|
||||||
import { Title } from '@angular/platform-browser';
|
import { Title } from '@angular/platform-browser';
|
||||||
import { KeycloakService } from 'keycloak-angular';
|
import { KeycloakService } from 'keycloak-angular';
|
||||||
@ -10,6 +10,7 @@ import { UI_ROOT } from '../../utils';
|
|||||||
import { getKeycloakOptions } from '../keycloak-options';
|
import { getKeycloakOptions } from '../keycloak-options';
|
||||||
import { IStoredTenantId, TenantsService } from '../services';
|
import { IStoredTenantId, TenantsService } from '../services';
|
||||||
import { KeycloakStatusService } from '../services/keycloak-status.service';
|
import { KeycloakStatusService } from '../services/keycloak-status.service';
|
||||||
|
import { CacheApiService } from '../../caching';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './tenant-select.component.html',
|
templateUrl: './tenant-select.component.html',
|
||||||
@ -17,8 +18,9 @@ import { KeycloakStatusService } from '../services/keycloak-status.service';
|
|||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
standalone: false,
|
standalone: false,
|
||||||
})
|
})
|
||||||
export class TenantSelectComponent {
|
export class TenantSelectComponent implements OnInit {
|
||||||
readonly #uiRoot = inject(UI_ROOT);
|
readonly #uiRoot = inject(UI_ROOT);
|
||||||
|
readonly #cacheApiService = inject(CacheApiService);
|
||||||
protected readonly logger = inject(NGXLogger);
|
protected readonly logger = inject(NGXLogger);
|
||||||
protected readonly tenantsService = inject(TenantsService);
|
protected readonly tenantsService = inject(TenantsService);
|
||||||
protected storedTenants: IStoredTenantId[] = [];
|
protected storedTenants: IStoredTenantId[] = [];
|
||||||
@ -35,8 +37,8 @@ export class TenantSelectComponent {
|
|||||||
@Input() isLoggedOut = false;
|
@Input() isLoggedOut = false;
|
||||||
@Input() noRoleLogOut = false;
|
@Input() noRoleLogOut = false;
|
||||||
|
|
||||||
constructor() {
|
async ngOnInit() {
|
||||||
this.#loadStoredTenants();
|
await this.#loadStoredTenants();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTenantSelection() {
|
updateTenantSelection() {
|
||||||
@ -66,16 +68,24 @@ export class TenantSelectComponent {
|
|||||||
return this.keycloakService.logout(url);
|
return this.keycloakService.logout(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeStored(tenantId: string) {
|
async removeStored(tenantId: string) {
|
||||||
this.tenantsService.removeStored(tenantId);
|
this.tenantsService.removeStored(tenantId);
|
||||||
this.#loadStoredTenants();
|
await this.#loadStoredTenants();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected tenantIcon(tenant: IStoredTenantId) {
|
protected tenantIcon(tenant: IStoredTenantId) {
|
||||||
return `red:${tenant.documine ? 'documine' : 'redaction'}-logo`;
|
return `red:${tenant.documine ? 'documine' : 'redaction'}-logo`;
|
||||||
}
|
}
|
||||||
|
|
||||||
#loadStoredTenants() {
|
async #loadStoredTenants() {
|
||||||
|
const lastVersionAppVersion = await this.#cacheApiService.getCachedValue('FRONTEND_APP_VERSION');
|
||||||
|
const currentAppVersion = this.config.FRONTEND_APP_VERSION;
|
||||||
|
console.log(lastVersionAppVersion);
|
||||||
|
console.log(currentAppVersion);
|
||||||
|
if (lastVersionAppVersion !== currentAppVersion) {
|
||||||
|
this.tenantsService.clearStoredTenants();
|
||||||
|
}
|
||||||
|
|
||||||
this.storedTenants = this.tenantsService.getStoredTenants().sort((a, b) => a.tenantId.localeCompare(b.tenantId));
|
this.storedTenants = this.tenantsService.getStoredTenants().sort((a, b) => a.tenantId.localeCompare(b.tenantId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user