diff --git a/smp-angular/package.json b/smp-angular/package.json index 88eecc80d4938396055217235e07a5ee68b62afe..1f1d0c948e49b6cb5b231cb493770f80210828cb 100644 --- a/smp-angular/package.json +++ b/smp-angular/package.json @@ -6,6 +6,7 @@ "scripts": { "ng": "ng", "start": "ng serve --proxy-config proxy-config.json", + "start:docker": "ng serve --proxy-config proxy-config-docker.json", "start:dev": "ng serve -c dev --proxy-config proxy-config.json", "build": "ng build --dev --base-href /smp/", "prod": "ng build --configuration production --output-path=./src/main/resources/META-INF/resources/ui/", diff --git a/smp-angular/proxy-config-docker.json b/smp-angular/proxy-config-docker.json new file mode 100644 index 0000000000000000000000000000000000000000..c90b50bf86a713eabb33d43a6e891769bd5facb2 --- /dev/null +++ b/smp-angular/proxy-config-docker.json @@ -0,0 +1,54 @@ +{ + "/rest/**": { + "target" : "http://eulogin.protected.smp.local:8982/", + "secure" : "false", + "pathRewrite": { + "^/rest": "/smp/ui/rest" + }, + "logLevel": "debug", + "changeOrigin": true, + "cookiePathRewrite": { + "/smp": "/" + }, + "cookieDomainRewrite": "eulogin.protected.smp.local" + }, + "/public/**": { + "target" : "http://eulogin.protected.smp.local:8982/", + "secure" : "false", + "pathRewrite": { + "^/public": "/smp/ui/public" + }, + "logLevel": "debug", + "changeOrigin": true, + "cookiePathRewrite": { + "/smp": "/" + }, + "cookieDomainRewrite": "eulogin.protected.smp.local" + }, + "/edit/**": { + "target" : "http://eulogin.protected.smp.local:8982/", + "secure" : "false", + "pathRewrite": { + "^/edit": "/smp/ui/edit" + }, + "logLevel": "debug", + "changeOrigin": true, + "cookiePathRewrite": { + "/smp": "/" + }, + "cookieDomainRewrite": "eulogin.protected.smp.local" + }, + "/internal/**": { + "target" : "http://eulogin.protected.smp.local:8982/", + "secure" : "false", + "pathRewrite": { + "^/internal": "/smp/ui/internal" + }, + "logLevel": "debug", + "changeOrigin": true, + "cookiePathRewrite": { + "/smp": "/" + }, + "cookieDomainRewrite": "eulogin.protected.smp.local" + } +} diff --git a/smp-angular/src/app/common/dialogs/session-expiration-dialog/session-expiration-dialog.component.html b/smp-angular/src/app/common/dialogs/session-expiration-dialog/session-expiration-dialog.component.html index 4b377b5428e85f183b9c75e102642bdf23962d54..593b9c2c81022ae3357d9875baeef579572a6601 100644 --- a/smp-angular/src/app/common/dialogs/session-expiration-dialog/session-expiration-dialog.component.html +++ b/smp-angular/src/app/common/dialogs/session-expiration-dialog/session-expiration-dialog.component.html @@ -1,5 +1,7 @@ <h2 mat-dialog-title>{{ "session.expiration.dialog.title" | translate }}</h2> -<mat-dialog-content>{{ "session.expiration.dialog.label.session.about.to.expire" | translate:{timeLeft: data.timeLeft, timeout: data.timeout} }} </mat-dialog-content> +<mat-dialog-content> + <div innerHTML='{{"session.expiration.dialog.label.session.about.to.expire" | translate:{timeLeft: data.timeLeft, timeout: data.timeout} }}'></div> +</mat-dialog-content> <mat-dialog-actions> <button mat-raised-button mat-dialog-close (click)="onLogoutClicked()" tabindex="-1"> <mat-icon>power_settings_new</mat-icon> diff --git a/smp-angular/src/app/common/global-lookups.ts b/smp-angular/src/app/common/global-lookups.ts index fc8f8e5e81ad93d1e73fa15c8a1e955d3ac95cde..8d9792f4d7c6d2d9be2c8d9c44c71f0f579cdf0d 100644 --- a/smp-angular/src/app/common/global-lookups.ts +++ b/smp-angular/src/app/common/global-lookups.ts @@ -71,15 +71,6 @@ export class GlobalLookups { this.refreshDomainLookup(domainUrl); } - public refreshDomainLookupForLoggedUser() { - let domainUrl = SmpConstants.REST_PUBLIC_DOMAIN; - // for authenticated admin use internal url which returns more data! - if (this.securityService.isCurrentUserSystemAdmin()) { - domainUrl = SmpConstants.REST_INTERNAL_DOMAIN_MANAGE_DEPRECATED; - } - this.refreshDomainLookup(domainUrl); - } - public refreshDomainLookup(domainUrl: string) { let params: HttpParams = new HttpParams() .set('page', '-1') @@ -100,12 +91,13 @@ export class GlobalLookups { public refreshApplicationInfo() { this.http.get<SmpInfo>(SmpConstants.REST_PUBLIC_APPLICATION_INFO) - .subscribe((res: SmpInfo) => { + .subscribe({ + next: (res: SmpInfo) => { this.cachedApplicationInfo = res; - }, error => { + }, error: (error: any) => { console.log("getSmpInfo:" + error); } - ); + }); } @@ -116,10 +108,13 @@ export class GlobalLookups { console.log("Refresh application configuration is authenticated " + isAuthenticated) if (isAuthenticated) { this.http.get<SmpConfig>(SmpConstants.REST_PUBLIC_APPLICATION_CONFIG) - .subscribe((res: SmpConfig) => { - this.cachedApplicationConfig = res; - }, error => { - console.log("getSmpConfig:" + error); + .subscribe({ + next: (res: SmpConfig) => { + this.cachedApplicationConfig = res; + } + , error: (error: any) => { + console.log("getSmpConfig:" + error); + } } ); } diff --git a/smp-angular/src/app/security/security.service.ts b/smp-angular/src/app/security/security.service.ts index 1346af7a6d5e068e0df28df52b17ac11f01e3368..ea25f79bd6cb271619d31cbb846dbfaebccddc43 100644 --- a/smp-angular/src/app/security/security.service.ts +++ b/smp-angular/src/app/security/security.service.ts @@ -5,8 +5,12 @@ import {SecurityEventService} from './security-event.service'; import {HttpClient, HttpErrorResponse, HttpHeaders} from '@angular/common/http'; import {SmpConstants} from "../smp.constants"; import {Authority} from "./authority.model"; -import {AlertMessageService} from "../common/alert-message/alert-message.service"; -import {PasswordChangeDialogComponent} from "../common/dialogs/password-change-dialog/password-change-dialog.component"; +import { + AlertMessageService +} from "../common/alert-message/alert-message.service"; +import { + PasswordChangeDialogComponent +} from "../common/dialogs/password-change-dialog/password-change-dialog.component"; import {MatDialog} from "@angular/material/dialog"; import {Router} from "@angular/router"; import {TranslateService} from "@ngx-translate/core"; @@ -24,7 +28,10 @@ export class SecurityService { private router: Router, private translateService: TranslateService ) { - this.securityEventService.onLogoutSuccessEvent().subscribe(() => { this.dialog.closeAll(); this.router.navigateByUrl('/'); }); + this.securityEventService.onLogoutSuccessEvent().subscribe(() => { + this.dialog.closeAll(); + this.router.navigateByUrl('/'); + }); this.securityEventService.onLogoutErrorEvent().subscribe((error) => this.alertService.error(error)); } @@ -57,8 +64,11 @@ export class SecurityService { }), {headers}) .subscribe({ - complete: () => { }, // completeHandler - error: (error: any) => {this.alertService.error(error) }, // errorHandler + complete: () => { + }, // completeHandler + error: (error: any) => { + this.alertService.error(error) + }, // errorHandler next: async () => { this.alertService.success(await lastValueFrom(this.translateService.get("login.success.confirmation.email.sent", {userId: userid})), true, -1); @@ -78,8 +88,13 @@ export class SecurityService { }), {headers}) .subscribe({ - complete: () => { this.router.navigate(['/login']); }, // completeHandler - error: (error: any) => {this.alertService.error(error);this.router.navigate(['/login']); }, // errorHandler + complete: () => { + this.router.navigate(['/login']); + }, // completeHandler + error: (error: any) => { + this.alertService.error(error); + this.router.navigate(['/login']); + }, // errorHandler next: async () => { this.alertService.success(await lastValueFrom(this.translateService.get("reset.credentials.success.password.reset")), true, -1); } @@ -107,15 +122,17 @@ export class SecurityService { } logout() { - this.http.delete(SmpConstants.REST_PUBLIC_SECURITY_AUTHENTICATION).subscribe((res: Response) => { - this.finalizeLogout(res); - }, - (err) => { - if (err instanceof HttpErrorResponse && err.status === 401) { - this.finalizeLogout(err); - } - else { - this.securityEventService.notifyLogoutErrorEvent(err); + this.http.delete(SmpConstants.REST_PUBLIC_SECURITY_AUTHENTICATION) + .subscribe({ + next: (res: Response) => { + this.finalizeLogout(res); + }, + error: (err: any) => { + if (err instanceof HttpErrorResponse && err.status === 401) { + this.finalizeLogout(err); + } else { + this.securityEventService.notifyLogoutErrorEvent(err); + } } }); } @@ -133,10 +150,12 @@ export class SecurityService { private getCurrentUsernameFromServer(): Observable<User> { let subject = new ReplaySubject<User>(); this.http.get<User>(SmpConstants.REST_PUBLIC_SECURITY_USER) - .subscribe((res: User) => { - subject.next(res); - }, (error: any) => { - subject.next(null); + .subscribe({ + next: (res: User) => { + subject.next(res); + }, error: (error: any) => { + subject.next(null); + } }); return subject.asObservable(); } diff --git a/smp-angular/src/app/window/sidenav/navigation-model.service.ts b/smp-angular/src/app/window/sidenav/navigation-model.service.ts index f59445e5304bbce55c63f534d91e774105d5f8f0..fbb961e41672fc9c4bd820c28d9b11311fa736bf 100644 --- a/smp-angular/src/app/window/sidenav/navigation-model.service.ts +++ b/smp-angular/src/app/window/sidenav/navigation-model.service.ts @@ -186,7 +186,7 @@ export class NavigationService extends MatTreeNestedDataSource<NavigationNode> { return this.findSiblings(targetNode).length == 0; } - protected findSiblings(node:NavigationNode): NavigationNode[] { + protected findSiblings(node: NavigationNode): NavigationNode[] { if (!node || !node.children || node.children.length == 0) { return []; } @@ -251,21 +251,20 @@ export class NavigationService extends MatTreeNestedDataSource<NavigationNode> { */ public refreshNavigationTree() { this.securityService.isAuthenticated(false).subscribe((isAuthenticated: boolean) => { - console.log("Refresh application configuration is authenticated " + isAuthenticated) - if (!isAuthenticated) { - this.reset(); - } else { - + console.log("Refresh navigation tree [is authenticated: " + isAuthenticated + "]") + if (isAuthenticated) { const currentUser: User = this.securityService.getCurrentUser(); // get navigation for user let navigationObserver = this.http.get<NavigationNode>(SmpConstants.REST_PUBLIC_USER_NAVIGATION_TREE.replace(SmpConstants.PATH_PARAM_ENC_USER_ID, currentUser.userId)); - navigationObserver.subscribe((userRootNode: NavigationNode) => { - this.setNavigationTree(userRootNode) - }, (error: any) => { - // check if unauthorized - // just console try latter - console.log("Error occurred while retrieving the navigation model for the user[" + error + "]"); + navigationObserver.subscribe({ + next: (userRootNode: NavigationNode) => { + this.setNavigationTree(userRootNode) + }, error: (error: any) => { + // check if unauthorized + // just console try latter + console.log("Error occurred while retrieving the navigation model for the user[" + error + "]"); + } }); } }); @@ -312,7 +311,12 @@ export class NavigationService extends MatTreeNestedDataSource<NavigationNode> { /** Remove node from tree */ public remove(node: NavigationNode) { - const newTreeData: NavigationNode = {code: "home", i18n: "navigation.label.home", icon: "home", children: this.data}; + const newTreeData: NavigationNode = { + code: "home", + i18n: "navigation.label.home", + icon: "home", + children: this.data + }; this._remove(node, newTreeData); this.data = newTreeData.children; } @@ -377,7 +381,7 @@ export class NavigationService extends MatTreeNestedDataSource<NavigationNode> { public navigateToLogin(): void { this.securityService.clearLocalStorage() this.reset(); - let node: NavigationNode = this.createNew(); + let node: NavigationNode = this.createLoginNode(); this.rootNode.children.push(node); this.select(node); } @@ -397,7 +401,7 @@ export class NavigationService extends MatTreeNestedDataSource<NavigationNode> { this.setNavigationTreeByPath(['user-settings', 'user-profile'], this.rootNode) } - public createNew(): NavigationNode { + public createLoginNode(): NavigationNode { return { code: "login", icon: "login", diff --git a/smp-angular/src/assets/i18n/en.json b/smp-angular/src/assets/i18n/en.json index 7bfe7457df00ca6b7d8069686c391095489fb21e..66def9da4034dd7ab364a456b7a42095c93e7b73 100644 --- a/smp-angular/src/assets/i18n/en.json +++ b/smp-angular/src/assets/i18n/en.json @@ -102,7 +102,7 @@ "session.expiration.dialog.button.expire": "Extend", "session.expiration.dialog.button.logout": "Logout", "session.expiration.dialog.title": "Extend session", - "session.expiration.dialog.label.session.about.to.expire": "Your session is about to expire in <b>{{data.timeLeft}}</b> seconds!<br />Would you like to logout now or extend it for another <b>{{data.timeout}}</b> seconds?", + "session.expiration.dialog.label.session.about.to.expire": "Your session is about to expire in <b>{{timeLeft}}</b> seconds!<br />Would you like to logout now or extend it for another <b>{{timeout}}</b> seconds?", "alert.panel.title": "Alerts", "alert.panel.user.title": "{{value}} (Email: '{{mailTo}}')", diff --git a/smp-angular/src/assets/i18n/ro.json b/smp-angular/src/assets/i18n/ro.json index 4a13325cd221ad51b80f83e611b3f6123abd1288..c9d1c25a4d552bad004e04af2d3b3f7bee47d218 100644 --- a/smp-angular/src/assets/i18n/ro.json +++ b/smp-angular/src/assets/i18n/ro.json @@ -102,7 +102,7 @@ "session.expiration.dialog.button.expire": "Extinde", "session.expiration.dialog.button.logout": "Deconectare", "session.expiration.dialog.title": "Extindeti sesiunea", - "session.expiration.dialog.label.session.about.to.expire": "Sesiunea dvs. este pe cale sa expire in <b>{{data.timeLeft}}</b> secunde!<br />Doriti sa va deconectati acum sau sa o prelungiti pentru inca <b>{{data.timeout}}</b> secunde?", + "session.expiration.dialog.label.session.about.to.expire": "Sesiunea dvs. este pe cale sa expire in <b>{{timeLeft}}</b> secunde!<br />Doriti sa va deconectati acum sau sa o prelungiti pentru inca <b>{{timeout}}</b> secunde?", "alert.panel.title": "Alerte", "alert.panel.user.title": "{{value}} (E-mail: '{{mailTo}}')",