From 3b75824a1c7273776c68621826a6658121859e03 Mon Sep 17 00:00:00 2001 From: alecarn <133774929+alecarn@users.noreply.github.com> Date: Tue, 10 Oct 2023 10:44:07 -0400 Subject: [PATCH] feat(*): add types for app environment and config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(App): add types for app environment and config * fix(Environment): remove circular dependencies between packages * feat(Environment): add an environment file by package * fix(Environment): add missing options * fix(Storage): respect the generic type * Get config typed (#1430) * chore(auth): set type for each configService.getConfig usage * chore(common): set type for each configService.getConfig usage * chore(context): set type for each configService.getConfig usage * chore(core): set type for each configService.getConfig usage * chore(geo): set type for each configService.getConfig usage * chore(integration): set type for each configService.getConfig usage * chore(*): normalize EnvironmentOptions syntax * various fix * refactor(catalog): adapt the interface to handle catalo queryformat property * refactor(*): remove todo comments * refactor(*): minor interface changes * refactor(about-tool): adjust version handling based on config. * refactor(core): add a deprecated key (config) * refactor(*): minor adjustements to interfaces * refactor(integration): minor interface changes --------- Co-authored-by: Pierre-Étienne Lord Co-authored-by: Pierre-Étienne Lord <7397743+pelord@users.noreply.github.com> --- demo/src/environments/environment.prod.ts | 23 +++---- demo/src/environments/environment.ts | 35 ++++------- .../lib/environment/environment.interface.ts | 6 ++ packages/auth/src/lib/environment/index.ts | 1 + packages/auth/src/lib/shared/admin.guard.ts | 5 +- .../src/lib/shared/auth-microsoft.provider.ts | 12 ++-- packages/auth/src/lib/shared/auth.guard.ts | 5 +- .../auth/src/lib/shared/auth.interceptor.ts | 18 ++++-- .../auth/src/lib/shared/auth.interface.ts | 7 +-- packages/auth/src/lib/shared/auth.service.ts | 63 ++++++++++--------- packages/auth/src/lib/shared/logged.guard.ts | 5 +- packages/auth/src/lib/shared/profils.guard.ts | 5 +- packages/auth/src/public_api.ts | 1 + .../lib/environment/environment.interface.ts | 15 +++++ packages/common/src/lib/environment/index.ts | 1 + .../interactive-tour.service.ts | 6 +- packages/common/src/public_api.ts | 1 + .../context-list/context-list.component.html | 6 +- .../context-list/context-list.component.ts | 10 ++- .../shared/layer-context.directive.ts | 15 +---- .../lib/environment/environment.interface.ts | 10 +++ packages/context/src/lib/environment/index.ts | 1 + packages/context/src/public_api.ts | 1 + .../core/src/lib/config/config-deprecated.ts | 8 +++ .../core/src/lib/config/config.interface.ts | 8 ++- .../core/src/lib/config/config.service.ts | 12 ++-- packages/core/src/lib/config/version.ts | 6 +- .../lib/environment/environment.interface.ts | 18 ++++++ packages/core/src/lib/environment/index.ts | 1 + packages/core/src/lib/storage/storage.ts | 2 +- packages/core/src/public_api.ts | 1 + .../src/lib/catalog/shared/catalog.enum.ts | 6 ++ .../lib/catalog/shared/catalog.interface.ts | 17 +++-- .../src/lib/catalog/shared/catalog.service.ts | 10 +-- .../directions-source.interface.ts | 21 ++++--- .../osrm-directions-source.ts | 4 +- .../directions/shared/directions.service.ts | 5 +- .../src/lib/draw/shared/draw-icon.service.ts | 2 +- .../lib/environment/environment.interface.ts | 63 +++++++++++++++++++ packages/geo/src/lib/environment/index.ts | 1 + .../ogc-filter-selection.component.ts | 10 ++- .../import-export/import-export.component.ts | 46 +++++++------- .../shared/drop-geo-file.directive.ts | 14 +---- .../import-export/shared/import.interface.ts | 1 + .../home-extent-button.component.ts | 13 ++-- .../home-extent-button.interface.ts | 7 +++ .../src/lib/map/home-extent-button/index.ts | 1 + .../controllers/geolocation.interface.ts | 9 +++ packages/geo/src/lib/map/shared/map.ts | 10 +-- .../lib/map/shared/projection.interfaces.ts | 4 +- .../src/lib/map/shared/projection.service.ts | 5 +- .../lib/offline/shared/geo-network.service.ts | 1 - .../shared/vector/vector-style.interface.ts | 5 ++ .../shared/feature-workspace.service.ts | 8 ++- .../workspace/shared/wfs-workspace.service.ts | 8 ++- .../workspace/shared/wms-workspace.service.ts | 8 ++- packages/geo/src/public_api.ts | 1 + .../about-tool/about-tool.component.html | 2 +- .../about/about-tool/about-tool.component.ts | 31 ++++----- .../lib/environment/environment.interface.ts | 38 +++++++++++ .../integration/src/lib/environment/index.ts | 1 + .../advanced-coordinates.component.ts | 38 +++++++---- .../integration/src/lib/search/query.state.ts | 10 +-- .../src/lib/search/search.state.ts | 12 ++-- .../src/locale/en.integration.json | 2 +- .../src/locale/fr.integration.json | 2 +- packages/integration/src/public_api.ts | 1 + 67 files changed, 471 insertions(+), 254 deletions(-) create mode 100644 packages/auth/src/lib/environment/environment.interface.ts create mode 100644 packages/auth/src/lib/environment/index.ts create mode 100644 packages/common/src/lib/environment/environment.interface.ts create mode 100644 packages/common/src/lib/environment/index.ts create mode 100644 packages/context/src/lib/environment/environment.interface.ts create mode 100644 packages/context/src/lib/environment/index.ts create mode 100644 packages/core/src/lib/environment/environment.interface.ts create mode 100644 packages/core/src/lib/environment/index.ts create mode 100644 packages/geo/src/lib/environment/environment.interface.ts create mode 100644 packages/geo/src/lib/environment/index.ts create mode 100644 packages/geo/src/lib/map/home-extent-button/home-extent-button.interface.ts create mode 100644 packages/integration/src/lib/environment/environment.interface.ts create mode 100644 packages/integration/src/lib/environment/index.ts diff --git a/demo/src/environments/environment.prod.ts b/demo/src/environments/environment.prod.ts index 9aa82ba9a9..7b8491153b 100644 --- a/demo/src/environments/environment.prod.ts +++ b/demo/src/environments/environment.prod.ts @@ -1,9 +1,7 @@ -interface Environment { - production: boolean; - igo: any; -} +import { EnvironmentOptions } from '@igo2/integration'; +import { CatalogQueryFormatTypes, ICatalog, TooltipType } from '@igo2/geo'; -export const environment: Environment = { +export const environment: EnvironmentOptions = { production: true, igo: { projections: [ @@ -15,13 +13,15 @@ export const environment: Environment = { } ], auth: { + tokenKey: 'testIgo2Lib', intern: { enabled: true }, allowAnonymous: true }, interactiveTour: { - tourInMobile: true + tourInMobile: true, + activateInteractiveTour: true }, importExport: { url: 'https://geoegl.msp.gouv.qc.ca/apis/ogre' @@ -42,14 +42,11 @@ export const environment: Environment = { url: 'https://ws.mapserver.transports.gouv.qc.ca/swtq', queryFormat: { html: '*', - 'application/json': [ - 'stations_meteoroutieres', - 'histo_stations_meteoroutieres' - ] - }, + json: ['stations_meteoroutieres', 'histo_stations_meteoroutieres'] + } as CatalogQueryFormatTypes, queryHtmlTarget: 'iframe', count: 30 - }, + } as ICatalog, { id: 'catalogwithregex', title: 'Filtered catalog by regex', @@ -60,7 +57,7 @@ export const environment: Environment = { id: 'catalogwithtooltipcontrol', title: 'Controling tooltip format', url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/igo_gouvouvert.fcgi', - tooltipType: 'abstract' // or title + tooltipType: TooltipType.ABSTRACT } ] }, diff --git a/demo/src/environments/environment.ts b/demo/src/environments/environment.ts index eb5340325a..1b1d122e97 100644 --- a/demo/src/environments/environment.ts +++ b/demo/src/environments/environment.ts @@ -1,15 +1,7 @@ -// This file can be replaced during build by using the `fileReplacements` array. -// `ng build ---configuration production` replaces `environment.ts` with `environment.prod.ts`. -// The list of file replacements can be found in `angular.json`. +import { EnvironmentOptions } from '@igo2/integration'; +import { TooltipType, CatalogQueryFormatTypes, ICatalog } from '@igo2/geo'; -// import { IgoEnvironment } from '@igo2/core'; - -interface Environment { - production: boolean; - igo: any; -} - -export const environment: Environment = { +export const environment: EnvironmentOptions = { production: false, igo: { importWithStyle: true, @@ -54,14 +46,11 @@ export const environment: Environment = { url: 'https://ws.mapserver.transports.gouv.qc.ca/swtq', queryFormat: { html: '*', - 'application/json': [ - 'stations_meteoroutieres', - 'histo_stations_meteoroutieres' - ] - }, + json: ['stations_meteoroutieres', 'histo_stations_meteoroutieres'] + } as CatalogQueryFormatTypes, queryHtmlTarget: 'iframe', count: 30 - }, + } as ICatalog, { id: 'catalogwithregex', title: 'Filtered catalog by regex', @@ -72,7 +61,7 @@ export const environment: Environment = { id: 'catalogwithtooltipcontrol', title: 'Controling tooltip format', url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/igo_gouvouvert.fcgi', - tooltipType: 'abstract' // or title + tooltipType: TooltipType.ABSTRACT }, { id: 'arcgisrestcompletecatalog', @@ -148,7 +137,7 @@ export const environment: Environment = { id: 'wmts_error', url: 'https://servicesmatriciels.mern.gouv.qc.ca/erdas-iws/ogc/wmts/Elevation?SERVICE=WMTS&REQUEST=GetCapabilities', type: 'wmts', - crossOrigin: true, + setCrossOriginAnonymous: true, matrixSet: 'EPSG_3857', version: '1.0.0', forcedProperties: [ @@ -166,7 +155,7 @@ export const environment: Environment = { id: 'wms', url: 'https://cartes.geogratis.gc.ca/wms/canvec_fr', type: 'wms', - crossOrigin: true, + setCrossOriginAnonymous: true, version: '1.3.0', forcedProperties: [ { @@ -223,7 +212,7 @@ export const environment: Environment = { id: 'wms', url: 'https://cartes.geogratis.gc.ca/wms/canvec_fr', type: 'wms', - crossOrigin: true, + setCrossOriginAnonymous: true, version: '1.3.0' }, { @@ -237,7 +226,7 @@ export const environment: Environment = { id: 'rn_wmts_1', url: 'https://servicesmatriciels.mern.gouv.qc.ca/erdas-iws/ogc/wmts/Cartes_Images', type: 'wmts', - crossOrigin: true, + setCrossOriginAnonymous: true, matrixSet: 'EPSG_3857', version: '1.0.0', forcedProperties: [ @@ -293,7 +282,7 @@ export const environment: Environment = { title: 'Feuillets SNRC', searchUrl: '/ws/mffpecofor.fcgi', storedquery_id: 'sq250et20kFeuillet', - fields: { name: 'no_feuillet', defaultValue: '0' }, + fields: [{ name: 'no_feuillet', defaultValue: '0' }], resultTitle: 'feuillet', params: { limit: '8' diff --git a/packages/auth/src/lib/environment/environment.interface.ts b/packages/auth/src/lib/environment/environment.interface.ts new file mode 100644 index 0000000000..fe5bce3498 --- /dev/null +++ b/packages/auth/src/lib/environment/environment.interface.ts @@ -0,0 +1,6 @@ +import { AuthOptions, AuthStorageOptions } from '../shared'; + +export interface EnvironmentOptions { + auth?: AuthOptions; + storage?: AuthStorageOptions; +} diff --git a/packages/auth/src/lib/environment/index.ts b/packages/auth/src/lib/environment/index.ts new file mode 100644 index 0000000000..3af98079bc --- /dev/null +++ b/packages/auth/src/lib/environment/index.ts @@ -0,0 +1 @@ +export * from './environment.interface'; diff --git a/packages/auth/src/lib/shared/admin.guard.ts b/packages/auth/src/lib/shared/admin.guard.ts index 72b01079ba..31145486f2 100644 --- a/packages/auth/src/lib/shared/admin.guard.ts +++ b/packages/auth/src/lib/shared/admin.guard.ts @@ -7,6 +7,7 @@ import { import { ConfigService } from '@igo2/core'; import { AuthService } from './auth.service'; +import { AuthOptions } from './auth.interface'; @Injectable({ providedIn: 'root' @@ -26,8 +27,8 @@ export class AdminGuard { this.authService.redirectUrl = state.url; - const authConfig = this.config.getConfig('auth'); - if (authConfig && authConfig.loginRoute) { + const authConfig = this.config.getConfig('auth') as AuthOptions; + if (authConfig?.loginRoute) { this.router.navigateByUrl(authConfig.loginRoute); } diff --git a/packages/auth/src/lib/shared/auth-microsoft.provider.ts b/packages/auth/src/lib/shared/auth-microsoft.provider.ts index a9e5326be0..0d8acab667 100644 --- a/packages/auth/src/lib/shared/auth-microsoft.provider.ts +++ b/packages/auth/src/lib/shared/auth-microsoft.provider.ts @@ -20,7 +20,7 @@ import { MsalServiceb2c } from './auth-msalServiceb2c.service.'; export function MSALConfigFactory( config: ConfigService ): PublicClientApplication { - const msConf: BrowserAuthOptions | null = config.getConfig('auth.microsoft'); + const msConf = config.getConfig('auth.microsoft') as AuthMicrosoftOptions; msConf.redirectUri = msConf?.redirectUri || window.location.href; msConf.authority = @@ -39,9 +39,9 @@ export function MSALConfigFactory( export function MSALConfigFactoryb2c( config: ConfigService ): PublicClientApplication { - const msConf: BrowserAuthOptions | null = config.getConfig( + const msConf = config.getConfig( 'auth.microsoftb2c.browserAuthOptions' - ); + ) as BrowserAuthOptions; msConf.redirectUri = msConf?.redirectUri || window.location.href; msConf.authority = msConf?.authority || 'https://login.microsoftonline.com/organizations'; @@ -59,7 +59,7 @@ export function MSALConfigFactoryb2c( export function MSALAngularConfigFactory( config: ConfigService ): MSPMsalGuardConfiguration { - const msConf: AuthMicrosoftOptions = config.getConfig('auth.microsoft'); + const msConf = config.getConfig('auth.microsoft') as AuthMicrosoftOptions; return { interactionType: InteractionType.Popup, @@ -74,9 +74,9 @@ export function MSALAngularConfigFactory( export function MSALAngularConfigFactoryb2c( config: ConfigService ): MSPMsalGuardConfiguration { - const msConf: BrowserAuthOptions | null = config.getConfig( + const msConf = config.getConfig( 'auth.microsoftb2c.browserAuthOptions' - ); + ) as BrowserAuthOptions; return { interactionType: InteractionType.Popup, diff --git a/packages/auth/src/lib/shared/auth.guard.ts b/packages/auth/src/lib/shared/auth.guard.ts index cdc0d41ece..727ee37520 100644 --- a/packages/auth/src/lib/shared/auth.guard.ts +++ b/packages/auth/src/lib/shared/auth.guard.ts @@ -7,6 +7,7 @@ import { import { ConfigService } from '@igo2/core'; import { AuthService } from './auth.service'; +import { AuthOptions } from './auth.interface'; @Injectable({ providedIn: 'root' @@ -25,8 +26,8 @@ export class AuthGuard { this.authService.redirectUrl = state.url; - const authConfig = this.config.getConfig('auth'); - if (authConfig && authConfig.loginRoute) { + const authConfig = this.config.getConfig('auth') as AuthOptions; + if (authConfig?.loginRoute) { this.router.navigateByUrl(authConfig.loginRoute); } diff --git a/packages/auth/src/lib/shared/auth.interceptor.ts b/packages/auth/src/lib/shared/auth.interceptor.ts index 802b9f8ed0..ffbba1e50b 100644 --- a/packages/auth/src/lib/shared/auth.interceptor.ts +++ b/packages/auth/src/lib/shared/auth.interceptor.ts @@ -11,12 +11,17 @@ import { Md5 } from 'ts-md5'; import { ConfigService } from '@igo2/core'; import { TokenService } from './token.service'; -import { AuthByKeyOptions, WithCredentialsOptions } from './auth.interface'; +import { + AuthByKeyOptions, + AuthOptions, + WithCredentialsOptions +} from './auth.interface'; @Injectable({ providedIn: 'root' }) export class AuthInterceptor implements HttpInterceptor { + private authOptions: AuthOptions; private refreshInProgress = false; private trustHosts: string[]; private hostsWithCredentials: WithCredentialsOptions[]; @@ -27,12 +32,13 @@ export class AuthInterceptor implements HttpInterceptor { private tokenService: TokenService, private http: HttpClient ) { - this.trustHosts = this.config.getConfig('auth.trustHosts') || []; + this.authOptions = this.config.getConfig('auth') as AuthOptions; + + this.trustHosts = this.authOptions?.trustHosts || []; this.trustHosts.push(window.location.hostname); - this.hostsWithCredentials = - this.config.getConfig('auth.hostsWithCredentials') || []; - this.hostsWithAuthByKey = this.config.getConfig('auth.hostsByKey') || []; + this.hostsWithCredentials = this.authOptions?.hostsWithCredentials || []; + this.hostsWithAuthByKey = this.authOptions?.hostsByKey || []; } intercept( @@ -171,7 +177,7 @@ export class AuthInterceptor implements HttpInterceptor { ) { this.refreshInProgress = true; - const url = this.config.getConfig('auth.url'); + const url = this.authOptions?.url; return this.http.post(`${url}/refresh`, {}).subscribe( (data: any) => { this.tokenService.set(data.token); diff --git a/packages/auth/src/lib/shared/auth.interface.ts b/packages/auth/src/lib/shared/auth.interface.ts index 17ac6490d3..4cad1e1410 100644 --- a/packages/auth/src/lib/shared/auth.interface.ts +++ b/packages/auth/src/lib/shared/auth.interface.ts @@ -16,11 +16,8 @@ export interface AuthGoogleOptions { clientId: string; } -export interface AuthMicrosoftOptions { +export interface AuthMicrosoftOptions extends BrowserAuthOptions { enabled?: boolean; - clientId: string; - redirectUri?: string; - authority?: string; } export interface AuthMicrosoftb2cOptions { @@ -54,7 +51,7 @@ export interface AuthMicrosoftb2cOptionsAuthority { export interface AuthOptions { url?: string; - tokenKey: string; + tokenKey?: string; allowAnonymous?: boolean; loginRoute?: string; logoutRoute?: string; diff --git a/packages/auth/src/lib/shared/auth.service.ts b/packages/auth/src/lib/shared/auth.service.ts index 4d04ba0b66..3a0cbd6a2c 100644 --- a/packages/auth/src/lib/shared/auth.service.ts +++ b/packages/auth/src/lib/shared/auth.service.ts @@ -9,7 +9,7 @@ import { globalCacheBusterNotifier } from 'ts-cacheable'; import { ConfigService, LanguageService, MessageService } from '@igo2/core'; import { Base64 } from '@igo2/utils'; -import { User, IInfosUser } from './auth.interface'; +import { User, IInfosUser, AuthOptions } from './auth.interface'; import { TokenService } from './token.service'; @Injectable({ @@ -21,9 +21,10 @@ export class AuthService { public redirectUrl: string; public languageForce = false; private anonymous = false; + private authOptions: AuthOptions; get hasAuthService() { - return this.config.getConfig('auth.url') !== undefined; + return this.authOptions?.url !== undefined; } constructor( @@ -34,6 +35,7 @@ export class AuthService { private messageService: MessageService, @Optional() private router: Router ) { + this.authOptions = this.config.getConfig('auth'); this.authenticate$.next(this.authenticated); this.authenticate$.subscribe((authenticated) => { this.logged$.next(authenticated); @@ -75,8 +77,7 @@ export class AuthService { } refresh(): Observable { - const url = this.config.getConfig('auth.url'); - return this.http.post(`${url}/refresh`, {}).pipe( + return this.http.post(`${this.authOptions?.url}/refresh`, {}).pipe( tap((data: any) => { this.tokenService.set(data.token); }), @@ -115,9 +116,8 @@ export class AuthService { } const redirectUrl = this.redirectUrl || this.router.url; - const options = this.config.getConfig('auth') || {}; - if (redirectUrl === options.loginRoute) { - const homeRoute = options.homeRoute || '/'; + if (redirectUrl === this.authOptions.loginRoute) { + const homeRoute = this.authOptions.homeRoute || '/'; this.router.navigateByUrl(homeRoute); } else if (redirectUrl) { this.router.navigateByUrl(redirectUrl); @@ -125,18 +125,18 @@ export class AuthService { } getUserInfo(): Observable { - const url = this.config.getConfig('auth.url') + '/info'; + const url = this.authOptions?.url + '/info'; return this.http.get(url); } getProfils(): Observable<{ profils: string[] }> { - const url = this.config.getConfig('auth.url'); - return this.http.get<{ profils: string[] }>(`${url}/profils`); + return this.http.get<{ profils: string[] }>( + `${this.authOptions?.url}/profils` + ); } updateUser(user: User): Observable { - const url = this.config.getConfig('auth.url'); - return this.http.patch(url, user); + return this.http.patch(this.authOptions?.url, user); } private encodePassword(password: string) { @@ -165,25 +165,26 @@ export class AuthService { } private loginCall(body, headers) { - const url = this.config.getConfig('auth.url'); - return this.http.post(`${url}/login`, body, { headers }).pipe( - tap((data: any) => { - this.tokenService.set(data.token); - const tokenDecoded = this.decodeToken(); - if (tokenDecoded && tokenDecoded.user) { - if (tokenDecoded.user.locale && !this.languageForce) { - this.languageService.setLanguage(tokenDecoded.user.locale); + return this.http + .post(`${this.authOptions?.url}/login`, body, { headers }) + .pipe( + tap((data: any) => { + this.tokenService.set(data.token); + const tokenDecoded = this.decodeToken(); + if (tokenDecoded && tokenDecoded.user) { + if (tokenDecoded.user.locale && !this.languageForce) { + this.languageService.setLanguage(tokenDecoded.user.locale); + } + if (tokenDecoded.user.isExpired) { + this.messageService.alert('igo.auth.error.Password expired'); + } } - if (tokenDecoded.user.isExpired) { - this.messageService.alert('igo.auth.error.Password expired'); - } - } - this.authenticate$.next(true); - }), - catchError((err) => { - err.error.caught = true; - throw err; - }) - ); + this.authenticate$.next(true); + }), + catchError((err) => { + err.error.caught = true; + throw err; + }) + ); } } diff --git a/packages/auth/src/lib/shared/logged.guard.ts b/packages/auth/src/lib/shared/logged.guard.ts index a6b67a67bb..7674d5bdfd 100644 --- a/packages/auth/src/lib/shared/logged.guard.ts +++ b/packages/auth/src/lib/shared/logged.guard.ts @@ -7,6 +7,7 @@ import { import { ConfigService } from '@igo2/core'; import { AuthService } from './auth.service'; +import { AuthOptions } from './auth.interface'; @Injectable({ providedIn: 'root' @@ -25,8 +26,8 @@ export class LoggedGuard { this.authService.redirectUrl = state.url; - const authConfig = this.config.getConfig('auth'); - if (authConfig && authConfig.loginRoute) { + const authConfig = this.config.getConfig('auth') as AuthOptions; + if (authConfig?.loginRoute) { this.router.navigateByUrl(authConfig.loginRoute); } diff --git a/packages/auth/src/lib/shared/profils.guard.ts b/packages/auth/src/lib/shared/profils.guard.ts index 31d1d7d55a..7c927855bd 100644 --- a/packages/auth/src/lib/shared/profils.guard.ts +++ b/packages/auth/src/lib/shared/profils.guard.ts @@ -8,6 +8,7 @@ import { map } from 'rxjs/operators'; import { ConfigService } from '@igo2/core'; import { AuthService } from './auth.service'; +import { AuthOptions } from './auth.interface'; @Injectable({ providedIn: 'root' @@ -22,7 +23,7 @@ export class ProfilsGuard { canActivate(_route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { return this.authService.getProfils().pipe( map((profils: { profils: string[] }) => { - const authConfig = this.config.getConfig('auth'); + const authConfig = this.config.getConfig('auth') as AuthOptions; if ( profils && profils.profils && @@ -33,7 +34,7 @@ export class ProfilsGuard { this.authService.redirectUrl = state.url; - if (authConfig && authConfig.loginRoute) { + if (authConfig?.loginRoute) { this.router.navigateByUrl(authConfig.loginRoute); } diff --git a/packages/auth/src/public_api.ts b/packages/auth/src/public_api.ts index 9d3fbd0ae0..a2345ee1e5 100644 --- a/packages/auth/src/public_api.ts +++ b/packages/auth/src/public_api.ts @@ -3,6 +3,7 @@ */ export { AuthFormComponent } from './lib/auth-form'; +export * from './lib/environment'; export * from './lib/shared/auth.service'; export * from './lib/shared/logged.guard'; export * from './lib/shared/auth.guard'; diff --git a/packages/common/src/lib/environment/environment.interface.ts b/packages/common/src/lib/environment/environment.interface.ts new file mode 100644 index 0000000000..035c51c42b --- /dev/null +++ b/packages/common/src/lib/environment/environment.interface.ts @@ -0,0 +1,15 @@ +export interface EnvironmentOptions { + depot?: DepotOptions; + interactiveTour?: InteractiveTourConfigOptions; +} + +export interface DepotOptions { + url: string; + trainingGuides?: string[]; +} + +export interface InteractiveTourConfigOptions { + activateInteractiveTour?: boolean; + tourInMobile?: boolean; + pathToConfigFile?: string; +} diff --git a/packages/common/src/lib/environment/index.ts b/packages/common/src/lib/environment/index.ts new file mode 100644 index 0000000000..3af98079bc --- /dev/null +++ b/packages/common/src/lib/environment/index.ts @@ -0,0 +1 @@ +export * from './environment.interface'; diff --git a/packages/common/src/lib/interactive-tour/interactive-tour.service.ts b/packages/common/src/lib/interactive-tour/interactive-tour.service.ts index ead06d27c1..448c1970fc 100644 --- a/packages/common/src/lib/interactive-tour/interactive-tour.service.ts +++ b/packages/common/src/lib/interactive-tour/interactive-tour.service.ts @@ -73,10 +73,8 @@ export class InteractiveTourService { const showInMobile = this.configService.getConfig( 'interactiveTour.tourInMobile' ); - if (showInMobile === undefined) { - return true; - } - return this.configService.getConfig('interactiveTour.tourInMobile'); + + return showInMobile === undefined ? true : showInMobile; } private getButtons(buttonKind?: 'first' | 'last' | 'noBackButton') { diff --git a/packages/common/src/public_api.ts b/packages/common/src/public_api.ts index 69f6470561..51b9e608e8 100644 --- a/packages/common/src/public_api.ts +++ b/packages/common/src/public_api.ts @@ -16,6 +16,7 @@ export * from './lib/dom/dom.module'; export * from './lib/drag-drop/drag-drop.module'; export * from './lib/dynamic-component/dynamic-component.module'; export * from './lib/dynamic-component/dynamic-outlet/dynamic-outlet.module'; +export * from './lib/environment'; export * from './lib/flexible/flexible.module'; export * from './lib/form/form.module'; export * from './lib/form/form/form.module'; diff --git a/packages/context/src/lib/context-manager/context-list/context-list.component.html b/packages/context/src/lib/context-manager/context-list/context-list.component.html index c931c445a3..49ee0926a2 100644 --- a/packages/context/src/lib/context-manager/context-list/context-list.component.html +++ b/packages/context/src/lib/context-manager/context-list/context-list.component.html @@ -53,7 +53,7 @@