@dsivd/prestations-ng 16.5.4-beta.3 → 16.5.4-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,8 +2,8 @@ import * as i0 from '@angular/core';
2
2
  import { Injectable, Optional, Inject, EventEmitter, Directive, Input, ViewChildren, ViewChild, forwardRef, Output, HostBinding, Pipe, Component, ContentChildren, HostListener, NgModule, TemplateRef, ContentChild, InjectionToken } from '@angular/core';
3
3
  import * as i1$1 from '@angular/router';
4
4
  import { ActivatedRoute, NavigationStart, RouterModule, NavigationEnd, RouterLink } from '@angular/router';
5
- import { of, BehaviorSubject, combineLatest, Subject, throwError, tap as tap$1, concat, toArray, EMPTY, merge, withLatestFrom, debounceTime as debounceTime$1, switchMap as switchMap$1, map as map$1 } from 'rxjs';
6
- import { map, shareReplay, debounceTime, catchError, switchMap, tap, first, filter, throttleTime, mergeMap, share, finalize, distinctUntilChanged } from 'rxjs/operators';
5
+ import { of, Subject, BehaviorSubject, combineLatest, throwError, tap as tap$1, concat, toArray, EMPTY, merge, withLatestFrom, debounceTime as debounceTime$1, switchMap as switchMap$1, map as map$1 } from 'rxjs';
6
+ import { map, shareReplay, filter, tap, debounceTime, catchError, switchMap, first, throttleTime, mergeMap, share, finalize, distinctUntilChanged } from 'rxjs/operators';
7
7
  import * as i1 from '@angular/common/http';
8
8
  import { HttpResponseBase, HttpErrorResponse, HttpParams, HttpEventType, HttpResponse, HTTP_INTERCEPTORS, HttpClientModule, HttpClient } from '@angular/common/http';
9
9
  import * as i3 from '@angular/forms';
@@ -81,18 +81,235 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
81
81
  args: ['neverConnected']
82
82
  }] }]; } });
83
83
 
84
+ // eslint-disable max-classes-per-file
85
+ class ApplicationInfo {
86
+ constructor() {
87
+ this.configuration = new Configuration();
88
+ }
89
+ }
90
+ class EtapeInfo {
91
+ }
92
+ class Configuration {
93
+ constructor() {
94
+ this.portail = new Portail();
95
+ }
96
+ }
97
+ class Session {
98
+ }
99
+ class Document {
100
+ }
101
+ class Captcha {
102
+ }
103
+ class Portail {
104
+ }
105
+
106
+ var ActionStatut;
107
+ (function (ActionStatut) {
108
+ ActionStatut["DRAFT"] = "DRAFT";
109
+ ActionStatut["INITIAL"] = "INITIAL";
110
+ ActionStatut["PENDING_PAYMENT"] = "PENDING_PAYMENT";
111
+ ActionStatut["TRANSFERRED"] = "TRANSFERRED";
112
+ ActionStatut["ABANDONED"] = "ABANDONED";
113
+ ActionStatut["REOPENED"] = "REOPENED";
114
+ })(ActionStatut || (ActionStatut = {}));
115
+ class GesdemStatutUtils {
116
+ static isFinal(actionStatut) {
117
+ if (!actionStatut) {
118
+ return false;
119
+ }
120
+ return (actionStatut === ActionStatut.TRANSFERRED ||
121
+ actionStatut === ActionStatut.ABANDONED);
122
+ }
123
+ }
124
+
125
+ class FoehnPageService {
126
+ constructor() {
127
+ this._foehnPageSubject = new Subject();
128
+ this._saveFormRequestSubject = new Subject();
129
+ this._currentEtapeId = new BehaviorSubject(null);
130
+ this.currentEtapeIdObs = this._currentEtapeId.asObservable();
131
+ }
132
+ foehnPageObservable() {
133
+ return this._foehnPageSubject.asObservable();
134
+ }
135
+ setPageTitle(title) {
136
+ this._foehnPageSubject.next(title);
137
+ }
138
+ requestFormSave() {
139
+ this._saveFormRequestSubject.next();
140
+ }
141
+ saveFormRequest() {
142
+ return this._saveFormRequestSubject.asObservable();
143
+ }
144
+ setCurrentEtapeId(etapeId) {
145
+ this._currentEtapeId.next(etapeId);
146
+ }
147
+ onEtapeIdChange() {
148
+ return this._currentEtapeId
149
+ .asObservable()
150
+ .pipe(filter(etapeInfo => !!etapeInfo));
151
+ }
152
+ isUserCategoryVisible(isFirstPage, isLastPage, isUserCategoryEnabled, isInitialStep, isUserNeverConnected,
153
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
154
+ backendResponse, isCurrentRouteDefined) {
155
+ const isStatusFinal = backendResponse &&
156
+ GesdemStatutUtils.isFinal(ActionStatut[backendResponse.meta.statut]);
157
+ return (isCurrentRouteDefined &&
158
+ !isStatusFinal &&
159
+ !isUserNeverConnected &&
160
+ isUserCategoryEnabled &&
161
+ isInitialStep &&
162
+ (isFirstPage || isLastPage));
163
+ }
164
+ }
165
+ FoehnPageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FoehnPageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
166
+ FoehnPageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FoehnPageService, providedIn: 'root' });
167
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FoehnPageService, decorators: [{
168
+ type: Injectable,
169
+ args: [{
170
+ providedIn: 'root'
171
+ }]
172
+ }], ctorParameters: function () { return []; } });
173
+
174
+ const APP_INFO_API_URL = 'api/applicationInfo';
175
+ const PORTAIL_BASE_URL_INT = 'https://int-prestations.vd.ch/';
176
+ const FORM_SUPPORT_CYBER_TITLE_FALLBACK = "Demander de l'aide pour l'utilisation du portail sécurisé";
177
+ class ApplicationInfoService {
178
+ constructor(http, foehnPageService) {
179
+ this.http = http;
180
+ this.foehnPageService = foehnPageService;
181
+ this.applicationInfo = new ApplicationInfo();
182
+ this.pulling_ = this.http
183
+ .get(APP_INFO_API_URL)
184
+ .pipe(shareReplay(1));
185
+ // In most prestation, we're interested in the first etape info.
186
+ this.firstEtapeInfo_ = this.pulling_.pipe(filter(appInfo => !!appInfo && !!appInfo.etapeInfos), map(({ etapeInfos }) => {
187
+ // Checks whether the server returns a first key, otherwise fails the
188
+ // observable to ensure that client applications don't try to use this value
189
+ // and are able to implement fallback strategies.
190
+ const firstKey = Object.keys(etapeInfos)[0];
191
+ if (!firstKey) {
192
+ throw new Error('There must be at least one key in the etapeInfos');
193
+ }
194
+ return etapeInfos[firstKey];
195
+ }));
196
+ this.currentEtapeInfo_ = combineLatest([
197
+ this.foehnPageService.onEtapeIdChange(),
198
+ this.pulling_
199
+ ]).pipe(map(([etapeId, applicationInfo]) => applicationInfo.etapeInfos[etapeId]), shareReplay(1));
200
+ this.pulling_.subscribe((ai) => this.setApplicationInfo(ai));
201
+ }
202
+ get data() {
203
+ return this.pulling_.pipe(tap(appInfo => {
204
+ if (!!appInfo.configuration.portail.baseVdChUrl?.length) {
205
+ // already set by the backend
206
+ return;
207
+ }
208
+ switch (appInfo.environment?.toUpperCase()) {
209
+ case 'IN':
210
+ appInfo.configuration.portail.baseVdChUrl =
211
+ 'https://int.vd.ch';
212
+ break;
213
+ case 'VA':
214
+ appInfo.configuration.portail.baseVdChUrl =
215
+ 'https://valid.vd.ch';
216
+ break;
217
+ default:
218
+ appInfo.configuration.portail.baseVdChUrl =
219
+ 'https://www.vd.ch';
220
+ }
221
+ }));
222
+ }
223
+ get firstEtapeInfo() {
224
+ return this.firstEtapeInfo_;
225
+ }
226
+ get currentEtapeInfo() {
227
+ return this.currentEtapeInfo_;
228
+ }
229
+ getSafeCyberLoginUrl() {
230
+ return this.data.pipe(map(appInfo => appInfo.configuration?.portail?.cyberLoginUrl ||
231
+ `${this.getPortailBaseUrl(appInfo)}100018/`));
232
+ }
233
+ getSafeSupportFormUrl(reference, errors) {
234
+ return this.data.pipe(map(appInfo => appInfo.configuration?.portail?.supportFormUrl ||
235
+ `${this.getPortailBaseUrl(appInfo)}pub/101098/`), map(link => {
236
+ if (!!reference?.length) {
237
+ link += `?concernedReference=${reference}`;
238
+ }
239
+ if (!!errors?.length) {
240
+ link += !!reference?.length ? '&' : '?';
241
+ // Need following code to avoid browser Sanitizing error when using JSON.stringify
242
+ link += `errors=${errors
243
+ .map(error => Object.entries(error)
244
+ .map(value => `${value.join('=')}`)
245
+ .join(','))
246
+ .join(';')}`;
247
+ }
248
+ return link;
249
+ }));
250
+ }
251
+ getSafeSupportFormTitle() {
252
+ return this.data.pipe(map(appInfo => {
253
+ const title = appInfo.configuration?.portail
254
+ ?.portailTitlesByPrestaCode?.[101098];
255
+ return title && title.length
256
+ ? title
257
+ : FORM_SUPPORT_CYBER_TITLE_FALLBACK;
258
+ }));
259
+ }
260
+ getSafeEspacesSecuriseUrl() {
261
+ return this.data.pipe(map(appInfo => appInfo.configuration?.portail?.espaceSecuriseUrl ||
262
+ `${this.getPortailBaseUrl(appInfo)}100002/`));
263
+ }
264
+ setApplicationInfo(applicationInfo) {
265
+ this.applicationInfo = applicationInfo;
266
+ if (this.applicationInfo) {
267
+ switch (this.applicationInfo.environment) {
268
+ case 'CO': {
269
+ this.applicationInfo.environmentLabel = 'développement';
270
+ break;
271
+ }
272
+ case 'IN': {
273
+ this.applicationInfo.environmentLabel = 'intégration';
274
+ break;
275
+ }
276
+ case 'VA': {
277
+ this.applicationInfo.environmentLabel = 'validation';
278
+ break;
279
+ }
280
+ default: {
281
+ // Nothing to do
282
+ }
283
+ }
284
+ }
285
+ }
286
+ getPortailBaseUrl(appInfo) {
287
+ return appInfo.environment === 'CO'
288
+ ? PORTAIL_BASE_URL_INT
289
+ : `${window.location.origin}/`;
290
+ }
291
+ }
292
+ ApplicationInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ApplicationInfoService, deps: [{ token: i1.HttpClient }, { token: FoehnPageService }], target: i0.ɵɵFactoryTarget.Injectable });
293
+ ApplicationInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ApplicationInfoService, providedIn: 'root' });
294
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ApplicationInfoService, decorators: [{
295
+ type: Injectable,
296
+ args: [{
297
+ providedIn: 'root'
298
+ }]
299
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: FoehnPageService }]; } });
300
+
84
301
  const DEFAULT_VALUES = {
85
302
  espaceSecuriseUrl: '/100002/accueil',
86
303
  allPrestationsUrl: '/100002/prestations',
87
- vdChUrl: 'https://www.vd.ch/',
88
- descriptionPageBaseUrl: 'https://www.vd.ch/go.to?prestation=',
304
+ vdChUrl: null,
305
+ descriptionPageBaseUrl: null,
89
306
  // It's better to not display the breadcrumb item if the prestation doesn't give its code.
90
307
  prestationCode: null
91
308
  };
92
309
  // eslint-disable-next-line jsdoc/require-jsdoc
93
- function getNotConnectedBreadcrumb({ vdChUrl = DEFAULT_VALUES.vdChUrl, descriptionPageBaseUrl = DEFAULT_VALUES.descriptionPageBaseUrl, prestationCode = DEFAULT_VALUES.prestationCode }) {
310
+ function getNotConnectedBreadcrumb({ vdChUrl, descriptionPageBaseUrl, prestationCode = DEFAULT_VALUES.prestationCode }, vdChUrlFromAppInfo) {
94
311
  const rootElement = {
95
- url: vdChUrl,
312
+ url: vdChUrl || vdChUrlFromAppInfo,
96
313
  routerLink: null,
97
314
  label: 'vd.ch'
98
315
  };
@@ -106,7 +323,9 @@ function getNotConnectedBreadcrumb({ vdChUrl = DEFAULT_VALUES.vdChUrl, descripti
106
323
  rootElement,
107
324
  {
108
325
  // e.g. https://www.vd.ch/go.to?prestation=101016
109
- url: `${descriptionPageBaseUrl}${prestationCode}`,
326
+ url: descriptionPageBaseUrl
327
+ ? `${descriptionPageBaseUrl}${prestationCode}`
328
+ : `${vdChUrlFromAppInfo}/go.to?prestation=${prestationCode}`,
110
329
  routerLink: null,
111
330
  label: 'Description de la prestation'
112
331
  }
@@ -133,22 +352,23 @@ function getConnectedBreadcrumb({ espaceSecuriseUrl = DEFAULT_VALUES.espaceSecur
133
352
  * @param sessionInfoData data info on session
134
353
  * @param configuration as breadcrumb config.
135
354
  * @param currentItem as breadcrumb current item
355
+ * @param vdChBaseUrl typo3 base url for current env
136
356
  * @returns Breadcrumb
137
357
  */
138
- function getBreadcrumb(sessionInfoData, configuration, currentItem) {
358
+ function getBreadcrumb(sessionInfoData, configuration, currentItem, vdChBaseUrl) {
139
359
  // Whether the user has a context we consider it as connected.
140
360
  const isConnectedCyber = !!sessionInfoData && !!sessionInfoData.context;
141
361
  const breadcrumb = new Breadcrumb();
142
362
  // Depending on whether the user is connected, the content of the items change.
143
363
  breadcrumb.breadcrumbItems = isConnectedCyber
144
364
  ? getConnectedBreadcrumb(configuration, sessionInfoData)
145
- : getNotConnectedBreadcrumb(configuration);
365
+ : getNotConnectedBreadcrumb(configuration, vdChBaseUrl);
146
366
  // Optionally set the current item.
147
367
  breadcrumb.current = currentItem;
148
368
  return breadcrumb;
149
369
  }
150
370
  // eslint-disable-next-line jsdoc/require-jsdoc
151
- function mapBreadcrumb([override, configuration, currentItem, sessionInfoData]) {
371
+ function mapBreadcrumb([override, configuration, currentItem, sessionInfoData, applicationInfo]) {
152
372
  // Take the override if it exists
153
373
  if (override) {
154
374
  // Although there's an override, we do want to assign the current item
@@ -161,14 +381,15 @@ function mapBreadcrumb([override, configuration, currentItem, sessionInfoData])
161
381
  }
162
382
  // Otherwise get a breadcrumb based on the configuration
163
383
  if (configuration) {
164
- return getBreadcrumb(sessionInfoData, configuration, currentItem);
384
+ return getBreadcrumb(sessionInfoData, configuration, currentItem, applicationInfo.configuration.portail.baseVdChUrl);
165
385
  }
166
386
  // Only output a breadcrumb of there's a configuration or an override
167
387
  return null;
168
388
  }
169
389
  class BreadcrumbEventService {
170
- constructor(sessionInfo) {
390
+ constructor(sessionInfo, applicationInfoService) {
171
391
  this.sessionInfo = sessionInfo;
392
+ this.applicationInfoService = applicationInfoService;
172
393
  this._breadcrumbOverride = new BehaviorSubject(null);
173
394
  this._breadcrumbConfiguration = new BehaviorSubject(null);
174
395
  this._currentBreadcrumbItem = new BehaviorSubject(null);
@@ -178,7 +399,8 @@ class BreadcrumbEventService {
178
399
  this._breadcrumbOverride,
179
400
  this._breadcrumbConfiguration,
180
401
  this._currentBreadcrumbItem,
181
- this.sessionInfo.data
402
+ this.sessionInfo.data,
403
+ this.applicationInfoService.data
182
404
  ]).pipe(
183
405
  // Put together the breadcrumb, or just take the override if it exists.
184
406
  map(mapBreadcrumb));
@@ -187,7 +409,8 @@ class BreadcrumbEventService {
187
409
  this._breadcrumbOverride,
188
410
  this._breadcrumbConfiguration,
189
411
  this._currentBreadcrumbItem,
190
- of(null)
412
+ of(null),
413
+ this.applicationInfoService.data
191
414
  ]).pipe(
192
415
  // Put together the breadcrumb, or just take the override if it exists.
193
416
  map(mapBreadcrumb));
@@ -242,14 +465,14 @@ class BreadcrumbEventService {
242
465
  this._breadcrumbConfiguration.next(configuration);
243
466
  }
244
467
  }
245
- BreadcrumbEventService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BreadcrumbEventService, deps: [{ token: SessionInfo }], target: i0.ɵɵFactoryTarget.Injectable });
468
+ BreadcrumbEventService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BreadcrumbEventService, deps: [{ token: SessionInfo }, { token: ApplicationInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
246
469
  BreadcrumbEventService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BreadcrumbEventService, providedIn: 'root' });
247
470
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BreadcrumbEventService, decorators: [{
248
471
  type: Injectable,
249
472
  args: [{
250
473
  providedIn: 'root'
251
474
  }]
252
- }], ctorParameters: function () { return [{ type: SessionInfo }]; } });
475
+ }], ctorParameters: function () { return [{ type: SessionInfo }, { type: ApplicationInfoService }]; } });
253
476
 
254
477
  class RegisterNgModelService {
255
478
  constructor() {
@@ -2184,74 +2407,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
2184
2407
  }]
2185
2408
  }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: GesdemHandlerService }, { type: GesdemActionRecoveryService }, { type: i1$1.ActivatedRoute }, { type: i2.Location }, { type: DemandeTransmitInterceptor }, { type: SdkEventsLoggerService }]; } });
2186
2409
 
2187
- var ActionStatut;
2188
- (function (ActionStatut) {
2189
- ActionStatut["DRAFT"] = "DRAFT";
2190
- ActionStatut["INITIAL"] = "INITIAL";
2191
- ActionStatut["PENDING_PAYMENT"] = "PENDING_PAYMENT";
2192
- ActionStatut["TRANSFERRED"] = "TRANSFERRED";
2193
- ActionStatut["ABANDONED"] = "ABANDONED";
2194
- ActionStatut["REOPENED"] = "REOPENED";
2195
- })(ActionStatut || (ActionStatut = {}));
2196
- class GesdemStatutUtils {
2197
- static isFinal(actionStatut) {
2198
- if (!actionStatut) {
2199
- return false;
2200
- }
2201
- return (actionStatut === ActionStatut.TRANSFERRED ||
2202
- actionStatut === ActionStatut.ABANDONED);
2203
- }
2204
- }
2205
-
2206
- class FoehnPageService {
2207
- constructor() {
2208
- this._foehnPageSubject = new Subject();
2209
- this._saveFormRequestSubject = new Subject();
2210
- this._currentEtapeId = new BehaviorSubject(null);
2211
- this.currentEtapeIdObs = this._currentEtapeId.asObservable();
2212
- }
2213
- foehnPageObservable() {
2214
- return this._foehnPageSubject.asObservable();
2215
- }
2216
- setPageTitle(title) {
2217
- this._foehnPageSubject.next(title);
2218
- }
2219
- requestFormSave() {
2220
- this._saveFormRequestSubject.next();
2221
- }
2222
- saveFormRequest() {
2223
- return this._saveFormRequestSubject.asObservable();
2224
- }
2225
- setCurrentEtapeId(etapeId) {
2226
- this._currentEtapeId.next(etapeId);
2227
- }
2228
- onEtapeIdChange() {
2229
- return this._currentEtapeId
2230
- .asObservable()
2231
- .pipe(filter(etapeInfo => !!etapeInfo));
2232
- }
2233
- isUserCategoryVisible(isFirstPage, isLastPage, isUserCategoryEnabled, isInitialStep, isUserNeverConnected,
2234
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2235
- backendResponse, isCurrentRouteDefined) {
2236
- const isStatusFinal = backendResponse &&
2237
- GesdemStatutUtils.isFinal(ActionStatut[backendResponse.meta.statut]);
2238
- return (isCurrentRouteDefined &&
2239
- !isStatusFinal &&
2240
- !isUserNeverConnected &&
2241
- isUserCategoryEnabled &&
2242
- isInitialStep &&
2243
- (isFirstPage || isLastPage));
2244
- }
2245
- }
2246
- FoehnPageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FoehnPageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2247
- FoehnPageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FoehnPageService, providedIn: 'root' });
2248
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FoehnPageService, decorators: [{
2249
- type: Injectable,
2250
- args: [{
2251
- providedIn: 'root'
2252
- }]
2253
- }], ctorParameters: function () { return []; } });
2254
-
2255
2410
  class PendingFiles {
2256
2411
  }
2257
2412
 
@@ -2593,131 +2748,6 @@ class UploaderHelper {
2593
2748
  }
2594
2749
  }
2595
2750
 
2596
- // eslint-disable max-classes-per-file
2597
- class ApplicationInfo {
2598
- }
2599
- class EtapeInfo {
2600
- }
2601
- class Configuration {
2602
- }
2603
- class Session {
2604
- }
2605
- class Document {
2606
- }
2607
- class Captcha {
2608
- }
2609
- class Portail {
2610
- }
2611
-
2612
- const APP_INFO_API_URL = 'api/applicationInfo';
2613
- const PORTAIL_BASE_URL_INT = 'https://int-prestations.vd.ch/';
2614
- const FORM_SUPPORT_CYBER_TITLE_FALLBACK = "Demander de l'aide pour l'utilisation du portail sécurisé";
2615
- class ApplicationInfoService {
2616
- constructor(http, foehnPageService) {
2617
- this.http = http;
2618
- this.foehnPageService = foehnPageService;
2619
- this.applicationInfo = new ApplicationInfo();
2620
- this.pulling_ = this.http
2621
- .get(APP_INFO_API_URL)
2622
- .pipe(shareReplay(1));
2623
- // In most prestation, we're interested in the first etape info.
2624
- this.firstEtapeInfo_ = this.pulling_.pipe(filter(appInfo => !!appInfo && !!appInfo.etapeInfos), map(({ etapeInfos }) => {
2625
- // Checks whether the server returns a first key, otherwise fails the
2626
- // observable to ensure that client applications don't try to use this value
2627
- // and are able to implement fallback strategies.
2628
- const firstKey = Object.keys(etapeInfos)[0];
2629
- if (!firstKey) {
2630
- throw new Error('There must be at least one key in the etapeInfos');
2631
- }
2632
- return etapeInfos[firstKey];
2633
- }));
2634
- this.currentEtapeInfo_ = combineLatest([
2635
- this.foehnPageService.onEtapeIdChange(),
2636
- this.pulling_
2637
- ]).pipe(map(([etapeId, applicationInfo]) => applicationInfo.etapeInfos[etapeId]), shareReplay(1));
2638
- this.pulling_.subscribe((ai) => this.setApplicationInfo(ai));
2639
- }
2640
- get data() {
2641
- return this.pulling_;
2642
- }
2643
- get firstEtapeInfo() {
2644
- return this.firstEtapeInfo_;
2645
- }
2646
- get currentEtapeInfo() {
2647
- return this.currentEtapeInfo_;
2648
- }
2649
- getSafeCyberLoginUrl() {
2650
- return this.data.pipe(map(appInfo => appInfo.configuration?.portail?.cyberLoginUrl ||
2651
- `${this.getPortailBaseUrl(appInfo)}100018/`));
2652
- }
2653
- getSafeSupportFormUrl(reference, errors) {
2654
- return this.data.pipe(map(appInfo => appInfo.configuration?.portail?.supportFormUrl ||
2655
- `${this.getPortailBaseUrl(appInfo)}pub/101098/`), map(link => {
2656
- if (!!reference?.length) {
2657
- link += `?concernedReference=${reference}`;
2658
- }
2659
- if (!!errors?.length) {
2660
- link += !!reference?.length ? '&' : '?';
2661
- // Need following code to avoid browser Sanitizing error when using JSON.stringify
2662
- link += `errors=${errors
2663
- .map(error => Object.entries(error)
2664
- .map(value => `${value.join('=')}`)
2665
- .join(','))
2666
- .join(';')}`;
2667
- }
2668
- return link;
2669
- }));
2670
- }
2671
- getSafeSupportFormTitle() {
2672
- return this.data.pipe(map(appInfo => {
2673
- const title = appInfo.configuration?.portail
2674
- ?.portailTitlesByPrestaCode?.[101098];
2675
- return title && title.length
2676
- ? title
2677
- : FORM_SUPPORT_CYBER_TITLE_FALLBACK;
2678
- }));
2679
- }
2680
- getSafeEspacesSecuriseUrl() {
2681
- return this.data.pipe(map(appInfo => appInfo.configuration?.portail?.espaceSecuriseUrl ||
2682
- `${this.getPortailBaseUrl(appInfo)}100002/`));
2683
- }
2684
- setApplicationInfo(applicationInfo) {
2685
- this.applicationInfo = applicationInfo;
2686
- if (this.applicationInfo) {
2687
- switch (this.applicationInfo.environment) {
2688
- case 'CO': {
2689
- this.applicationInfo.environmentLabel = 'développement';
2690
- break;
2691
- }
2692
- case 'IN': {
2693
- this.applicationInfo.environmentLabel = 'intégration';
2694
- break;
2695
- }
2696
- case 'VA': {
2697
- this.applicationInfo.environmentLabel = 'validation';
2698
- break;
2699
- }
2700
- default: {
2701
- // Nothing to do
2702
- }
2703
- }
2704
- }
2705
- }
2706
- getPortailBaseUrl(appInfo) {
2707
- return appInfo.environment === 'CO'
2708
- ? PORTAIL_BASE_URL_INT
2709
- : `${window.location.origin}/`;
2710
- }
2711
- }
2712
- ApplicationInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ApplicationInfoService, deps: [{ token: i1.HttpClient }, { token: FoehnPageService }], target: i0.ɵɵFactoryTarget.Injectable });
2713
- ApplicationInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ApplicationInfoService, providedIn: 'root' });
2714
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ApplicationInfoService, decorators: [{
2715
- type: Injectable,
2716
- args: [{
2717
- providedIn: 'root'
2718
- }]
2719
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: FoehnPageService }]; } });
2720
-
2721
2751
  class UploadProgressService {
2722
2752
  constructor() {
2723
2753
  this._uploadProgressSubject = new BehaviorSubject(null);
@@ -3639,6 +3669,7 @@ class GesdemConfirmationComponent {
3639
3669
  this._sessionInfo = ServiceLocator.injector.get(SessionInfo);
3640
3670
  this._navigation = ServiceLocator.injector.get(FoehnNavigationService);
3641
3671
  this._eventsLoggerService = ServiceLocator.injector.get(SdkEventsLoggerService);
3672
+ this._applicationInfoService = ServiceLocator.injector.get(ApplicationInfoService);
3642
3673
  const route = FoehnNavigationService.getRootRouteRecursive(activatedRoute.snapshot);
3643
3674
  this._navigation.initRoute(route);
3644
3675
  // Override from the routing.
@@ -3682,18 +3713,20 @@ class GesdemConfirmationComponent {
3682
3713
  this.closeButtonConnectedText ||
3683
3714
  'gesdem-confirmation.exit-button-connected';
3684
3715
  // default closeLink if not by @Input and not by route data
3685
- this.foehnPageService
3686
- .onEtapeIdChange()
3687
- .pipe(first())
3688
- // eslint-disable-next-line rxjs/no-nested-subscribe,rxjs-angular/prefer-async-pipe
3689
- .subscribe(etapeId => {
3716
+ combineLatest([
3717
+ this.foehnPageService.onEtapeIdChange().pipe(first()),
3718
+ this._applicationInfoService.data.pipe(first())
3719
+ ])
3720
+ .pipe(first(), tap(([etapeId, appInfo]) => {
3690
3721
  if (!this.closeLinkNotConnected.getValue()) {
3691
- this.closeLinkNotConnected.next(`https://www.vd.ch/go.to?prestation=${etapeId}`);
3722
+ this.closeLinkNotConnected.next(`${appInfo.configuration.portail.baseVdChUrl}/go.to?prestation=${etapeId}`);
3692
3723
  }
3693
3724
  if (!this.closeLinkConnected.getValue()) {
3694
3725
  this.closeLinkConnected.next('/100018/logout');
3695
3726
  }
3696
- });
3727
+ }))
3728
+ // eslint-disable-next-line rxjs/no-nested-subscribe,rxjs-angular/prefer-async-pipe,rxjs/no-nested-subscribe
3729
+ .subscribe();
3697
3730
  });
3698
3731
  }
3699
3732
  get isTransferred() {