diff --git a/smp-angular/src/app/system-settings/admin-keystore/admin-keystore.component.ts b/smp-angular/src/app/system-settings/admin-keystore/admin-keystore.component.ts index 0ddc6b7c1be8bb40790a8225163827c198c2bae9..c388fb6d852f2b21bb60232c6875b61509622405 100644 --- a/smp-angular/src/app/system-settings/admin-keystore/admin-keystore.component.ts +++ b/smp-angular/src/app/system-settings/admin-keystore/admin-keystore.component.ts @@ -1,4 +1,4 @@ -import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core'; +import {AfterViewInit, Component, OnDestroy, OnInit, ViewChild} from '@angular/core'; import {MatTableDataSource} from "@angular/material/table"; import {MatPaginator} from "@angular/material/paginator"; import {MatSort} from "@angular/material/sort"; @@ -10,6 +10,7 @@ import {MatDialog, MatDialogRef} from "@angular/material/dialog"; import {EntityStatus} from "../../common/enums/entity-status.enum"; import {KeystoreImportDialogComponent} from "./keystore-import-dialog/keystore-import-dialog.component"; import {BeforeLeaveGuard} from "../../window/sidenav/navigation-on-leave-guard"; +import {Subscription} from "rxjs"; @Component({ @@ -17,12 +18,15 @@ import {BeforeLeaveGuard} from "../../window/sidenav/navigation-on-leave-guard"; templateUrl: './admin-keystore.component.html', styleUrls: ['./admin-keystore.component.css'] }) -export class AdminKeystoreComponent implements OnInit, AfterViewInit, BeforeLeaveGuard { +export class AdminKeystoreComponent implements OnInit, OnDestroy, AfterViewInit, BeforeLeaveGuard { displayedColumns: string[] = ['alias']; dataSource: MatTableDataSource<CertificateRo> = new MatTableDataSource(); keystoreCertificates: CertificateRo[]; selected?: CertificateRo; + private updateKeystoreCertificatesSub: Subscription = Subscription.EMPTY; + private updateKeystoreEntriesSub: Subscription = Subscription.EMPTY; + @ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; @@ -30,12 +34,12 @@ export class AdminKeystoreComponent implements OnInit, AfterViewInit, BeforeLeav private alertService: AlertMessageService, private dialog: MatDialog) { - keystoreService.onKeystoreUpdatedEvent().subscribe(keystoreCertificates => { + this.updateKeystoreCertificatesSub = keystoreService.onKeystoreUpdatedEvent().subscribe(keystoreCertificates => { this.updateKeystoreCertificates(keystoreCertificates); } ); - keystoreService.onKeystoreEntryUpdatedEvent().subscribe(updatedCertificate => { + this.updateKeystoreEntriesSub = keystoreService.onKeystoreEntryUpdatedEvent().subscribe(updatedCertificate => { this.updateKeystoreEntries(updatedCertificate); } ); @@ -49,6 +53,10 @@ export class AdminKeystoreComponent implements OnInit, AfterViewInit, BeforeLeav return !filter || -1 != data.alias.toLowerCase().indexOf(filter.trim().toLowerCase()) }; } + ngOnDestroy(): void { + this.updateKeystoreCertificatesSub.unsubscribe(); + this.updateKeystoreEntriesSub.unsubscribe(); + } ngAfterViewInit() { this.dataSource.paginator = this.paginator; diff --git a/smp-angular/src/app/system-settings/admin-truststore/admin-truststore.component.ts b/smp-angular/src/app/system-settings/admin-truststore/admin-truststore.component.ts index 76ed48daddaf050a036463befde8146d50a2bc8e..ec6a7c9382c6360436435d228f3e30d91b136d4a 100644 --- a/smp-angular/src/app/system-settings/admin-truststore/admin-truststore.component.ts +++ b/smp-angular/src/app/system-settings/admin-truststore/admin-truststore.component.ts @@ -1,4 +1,4 @@ -import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core'; +import {AfterViewInit, Component, OnDestroy, OnInit, ViewChild} from '@angular/core'; import {MatTableDataSource} from "@angular/material/table"; import {MatPaginator} from "@angular/material/paginator"; import {MatSort} from "@angular/material/sort"; @@ -9,6 +9,7 @@ import {ConfirmationDialogComponent} from "../../common/dialogs/confirmation-dia import {MatDialog} from "@angular/material/dialog"; import {EntityStatus} from "../../common/enums/entity-status.enum"; import {BeforeLeaveGuard} from "../../window/sidenav/navigation-on-leave-guard"; +import {Subscription} from "rxjs"; @Component({ @@ -16,12 +17,14 @@ import {BeforeLeaveGuard} from "../../window/sidenav/navigation-on-leave-guard"; templateUrl: './admin-truststore.component.html', styleUrls: ['./admin-truststore.component.css'] }) -export class AdminTruststoreComponent implements OnInit, AfterViewInit, BeforeLeaveGuard { +export class AdminTruststoreComponent implements OnInit, OnDestroy, AfterViewInit, BeforeLeaveGuard { displayedColumns: string[] = ['alias']; dataSource: MatTableDataSource<CertificateRo> = new MatTableDataSource(); selected?: CertificateRo; trustedCertificateList: CertificateRo[]; + private updateTruststoreCertificatesSub: Subscription = Subscription.EMPTY; + private updateTruststoreCertificateSub: Subscription = Subscription.EMPTY; @ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; @@ -30,12 +33,12 @@ export class AdminTruststoreComponent implements OnInit, AfterViewInit, BeforeLe private alertService: AlertMessageService, private dialog: MatDialog) { - truststoreService.onTruststoreUpdatedEvent().subscribe(updatedTruststore => { + this.updateTruststoreCertificatesSub = truststoreService.onTruststoreUpdatedEvent().subscribe(updatedTruststore => { this.updateTruststoreCertificates(updatedTruststore); } ); - truststoreService.onTruststoreEntryUpdatedEvent().subscribe(updatedCertificate => { + this.updateTruststoreCertificateSub = truststoreService.onTruststoreEntryUpdatedEvent().subscribe(updatedCertificate => { this.updateTruststoreCertificate(updatedCertificate); } ); @@ -53,6 +56,12 @@ export class AdminTruststoreComponent implements OnInit, AfterViewInit, BeforeLe this.dataSource.sort = this.sort; } + ngOnDestroy(): void { + this.updateTruststoreCertificatesSub.unsubscribe(); + this.updateTruststoreCertificateSub.unsubscribe(); + } + + updateTruststoreCertificates(truststoreCertificates: CertificateRo[]) { this.trustedCertificateList = truststoreCertificates this.dataSource.data = this.trustedCertificateList; diff --git a/smp-angular/src/app/window/toolbar/toolbar.component.html b/smp-angular/src/app/window/toolbar/toolbar.component.html index e21a663c4f66a4810c55b8e3ed7ab06582266bd3..7c46c453d287fcc7a86673182ca19406dea2d3f9 100644 --- a/smp-angular/src/app/window/toolbar/toolbar.component.html +++ b/smp-angular/src/app/window/toolbar/toolbar.component.html @@ -4,10 +4,6 @@ <div id="topLogo" class="mat-mdc-card"> <img src="assets/images/DomiSMP_logo.svg" [attr.height]="fullMenu ? '140px' : '30px'" [attr.width]="fullMenu ? '180px' : '50px'"/> - <!-- div id="topLogoText" *ngIf="fullMenu"> - <div style="font-weight: bold;font-size: 15px">eDelivery SMP <span style="font-weight: normal;font-size: 14px">Administration <br>Console</span> - </div> - </div--> </div> <span class="window-toolbar-spacer"></span> <a id="login_id" class="window-toolbar-item" *ngIf="!currentUser" [routerLink]="['/login']" (click)="clearWarning()"> Login </a> @@ -31,10 +27,6 @@ (click)="openCurrentCasUserData()"> <span>Open CAS user data</span> </button> - <button id="getAccessToken_id" *ngIf="isWebServiceUserTokenAuthPasswdEnabled" mat-menu-item - (click)="regenerateCurrentUserAccessToken()"> - <span>Generated access token</span> - </button> <hr/> <button id="logout_id" mat-menu-item (click)="logout($event)"> <mat-icon>power_settings_new</mat-icon> diff --git a/smp-angular/src/app/window/toolbar/toolbar.component.ts b/smp-angular/src/app/window/toolbar/toolbar.component.ts index 0cffdc2d8464f9d0d25ade066394d40285b054b5..9a7b4225b8ed460afc9afa808818841f13490343 100644 --- a/smp-angular/src/app/window/toolbar/toolbar.component.ts +++ b/smp-angular/src/app/window/toolbar/toolbar.component.ts @@ -24,7 +24,7 @@ import {GlobalLookups} from "../../common/global-lookups"; styleUrls: ['./toolbar.component.scss'] }) -export class ToolbarComponent implements OnInit { +export class ToolbarComponent { fullMenu: boolean = true; userController: UserController; @@ -39,10 +39,6 @@ export class ToolbarComponent implements OnInit { this.userController = new UserController(this.http, this.lookups, this.dialog); } - ngOnInit(): void { - - } - clearWarning() { this.alertService.clearAlert(); } @@ -67,15 +63,17 @@ export class ToolbarComponent implements OnInit { } get currentUser(): string { - let user = this.securityService.getCurrentUser(); - let userDesc = user ? ( - user.fullName? user.fullName +" ["+user.username+"]":user.username) - :""; - + let userDesc = this.userTitle; return (userDesc.length>25)?userDesc.slice(0,25) + "...":userDesc } - + get userTitle(){ + let user = this.securityService.getCurrentUser(); + if (!user) { + return "" + } + return !!user.fullName? user.fullName +" ["+user.username+"]":user.username; + } editCurrentUser() { const formRef: MatDialogRef<any> = this.userController.newDialog({ @@ -113,27 +111,11 @@ export class ToolbarComponent implements OnInit { } changeCurrentUserPassword() { - const formRef: MatDialogRef<any> = this.userController.changePasswordDialog({ + this.userController.changePasswordDialog({ data: {user: this.securityService.getCurrentUser(), adminUser: false} }); } - regenerateCurrentUserAccessToken() { - const formRef: MatDialogRef<any> = this.userController.generateAccessTokenDialog({ - data: {user: this.securityService.getCurrentUser(), adminUser: false} - }); - formRef.afterClosed().subscribe(result => { - if (result) { - let user = {...formRef.componentInstance.getCurrent()}; - let currUser = this.securityService.getCurrentUser(); - currUser.accessTokenId = user.accessTokenId; - currUser.accessTokenExpireOn = user.accessTokenExpireOn; - this.securityService.updateUserDetails(currUser); - } - }); - } - - showExpanded(expand: boolean) { this.fullMenu = expand; }