Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 7fe0630c authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

[EDELIVERY-13779] Access token - panel collapse on delete action

parent 1fd41930
No related branches found
No related tags found
No related merge requests found
......@@ -4,10 +4,11 @@ import {SmpConstants} from "../../smp.constants";
import {User} from "../../security/user.model";
import {AlertMessageService} from "../alert-message/alert-message.service";
import {SecurityService} from "../../security/security.service";
import {Observable, Subject} from "rxjs";
import {lastValueFrom, Observable, Subject} from "rxjs";
import {CredentialRo} from "../../security/credential.model";
import {AccessTokenRo} from "../model/access-token-ro.model";
import {HttpErrorHandlerService} from "../error/http-error-handler.service";
import {TranslateService} from "@ngx-translate/core";
/**
* Class handle current user settings such-as profile, credentials, DomiSMP settings... ,
......@@ -31,6 +32,7 @@ export class UserService {
private httpErrorHandlerService: HttpErrorHandlerService,
private securityService: SecurityService,
private alertService: AlertMessageService,
protected translateService: TranslateService
) {
}
......@@ -52,13 +54,15 @@ export class UserService {
}
this.http.get<CredentialRo>(SmpConstants.REST_PUBLIC_USER_CREDENTIAL_STATUS
.replace(SmpConstants.PATH_PARAM_ENC_USER_ID, user.userId))
.subscribe((response: CredentialRo) => {
this.notifyPwdStatusUpdated(response)
}, error => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)){
return;
.subscribe({
next: (response: CredentialRo) => {
this.notifyPwdStatusUpdated(response)
}, error: (error: any) => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)) {
return;
}
this.alertService.error(error.error?.errorDescription)
}
this.alertService.error(error.error?.errorDescription)
});
}
......@@ -69,13 +73,15 @@ export class UserService {
}
this.http.get<CredentialRo[]>(SmpConstants.REST_PUBLIC_USER_ACCESS_TOKEN_CREDENTIALS
.replace(SmpConstants.PATH_PARAM_ENC_USER_ID, user.userId))
.subscribe((response: CredentialRo[]) => {
this.notifyAccessTokensUpdated(response)
}, error => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)){
return;
.subscribe({
next: (response: CredentialRo[]) => {
this.notifyAccessTokensUpdated(response)
}, error: (error: any) => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)) {
return;
}
this.alertService.error(error.error?.errorDescription)
}
this.alertService.error(error.error?.errorDescription)
});
}
......@@ -87,14 +93,16 @@ export class UserService {
this.http.delete<CredentialRo>(SmpConstants.REST_PUBLIC_USER_MANAGE_ACCESS_TOKEN_CREDENTIAL
.replace(SmpConstants.PATH_PARAM_ENC_USER_ID, user.userId)
.replace(SmpConstants.PATH_PARAM_ENC_CREDENTIAL_ID, credential.credentialId))
.subscribe((response: CredentialRo) => {
this.notifyAccessTokenUpdated(response)
this.alertService.success("Access token ["+response.name+"] has been deleted!")
}, error => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)){
return;
.subscribe({
next: async (response: CredentialRo) => {
this.notifyAccessTokenUpdated(response)
this.alertService.success(await lastValueFrom(this.translateService.get("user.access.tokens.success.deleted", {credentialName: response.name})))
}, error: (error: any) => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)) {
return;
}
this.alertService.error(error.error?.errorDescription)
}
this.alertService.error(error.error?.errorDescription)
});
}
......@@ -106,14 +114,16 @@ export class UserService {
this.http.post<CredentialRo>(SmpConstants.REST_PUBLIC_USER_MANAGE_ACCESS_TOKEN_CREDENTIAL
.replace(SmpConstants.PATH_PARAM_ENC_USER_ID, user.userId)
.replace(SmpConstants.PATH_PARAM_ENC_CREDENTIAL_ID, credential.credentialId), credential)
.subscribe((response: CredentialRo) => {
this.notifyAccessTokenUpdated(response)
this.alertService.success("Access token ["+response.name+"] has been updated!")
}, error => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)){
return;
.subscribe({
next: async (response: CredentialRo) => {
this.notifyAccessTokenUpdated(response)
this.alertService.success(await lastValueFrom(this.translateService.get("user.access.tokens.success.updated", {credentialName: response.name})))
}, error: (error: any) => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)) {
return;
}
this.alertService.error(error.error?.errorDescription)
}
this.alertService.error(error.error?.errorDescription)
});
}
......@@ -125,14 +135,16 @@ export class UserService {
this.http.post<CredentialRo>(SmpConstants.REST_PUBLIC_USER_MANAGE_CERTIFICATE_CREDENTIAL
.replace(SmpConstants.PATH_PARAM_ENC_USER_ID, user.userId)
.replace(SmpConstants.PATH_PARAM_ENC_CREDENTIAL_ID, credential.credentialId), credential)
.subscribe((response: CredentialRo) => {
this.notifyCertificateUpdated(response)
this.alertService.success("Certificate ["+response.name+"] has been updated!")
}, error => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)){
return;
.subscribe({
next: async (response: CredentialRo) => {
this.notifyCertificateUpdated(response)
this.alertService.success(await lastValueFrom(this.translateService.get("user.certificate.success.updated", {credentialName: response.name})))
}, error: (error: any) => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)) {
return;
}
this.alertService.error(error.error?.errorDescription)
}
this.alertService.error(error.error?.errorDescription)
});
}
......@@ -144,14 +156,16 @@ export class UserService {
this.http.delete<CredentialRo>(SmpConstants.REST_PUBLIC_USER_MANAGE_CERTIFICATE_CREDENTIAL
.replace(SmpConstants.PATH_PARAM_ENC_USER_ID, user.userId)
.replace(SmpConstants.PATH_PARAM_ENC_CREDENTIAL_ID, credential.credentialId))
.subscribe((response: CredentialRo) => {
this.notifyCertificateUpdated(response)
this.alertService.success("Certificate ["+response.name+"] has been deleted!")
}, error => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)){
return;
.subscribe({
next: async (response: CredentialRo) => {
this.notifyCertificateUpdated(response)
this.alertService.success(await lastValueFrom(this.translateService.get("user.certificate.success.deleted", {credentialName: response.name})))
}, error: (error: any) => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)) {
return;
}
this.alertService.error(error.error?.errorDescription)
}
this.alertService.error(error.error?.errorDescription)
});
}
......@@ -174,15 +188,16 @@ export class UserService {
this.http.put<CredentialRo>(SmpConstants.REST_PUBLIC_USER_MANAGE_CERTIFICATE_CREDENTIAL
.replace(SmpConstants.PATH_PARAM_ENC_USER_ID, user.userId)
.replace(SmpConstants.PATH_PARAM_ENC_CREDENTIAL_ID, credential.credentialId), credential)
.subscribe((response: CredentialRo) => {
this.notifyCertificateUpdated(response)
this.alertService.success("Certificate ["+response.name+"] has been successfully uploaded!")
}, error => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)){
return;
.subscribe({
next: async (response: CredentialRo) => {
this.notifyCertificateUpdated(response)
this.alertService.success(await lastValueFrom(this.translateService.get("user.certificate.success.uploaded", {credentialName: response.name})))
}, error: (error: any) => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)) {
return;
}
this.alertService.error(error.error?.errorDescription)
}
this.alertService.error(error.error?.errorDescription)
});
}
......@@ -199,7 +214,7 @@ export class UserService {
.subscribe((response: CredentialRo[]) => {
this.notifyCertificatesUpdated(response)
}, error => {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)){
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(error)) {
return;
}
this.alertService.error(error.error?.errorDescription)
......
......@@ -13,13 +13,13 @@
maxlength="255" readonly>
<div style="display: inline">
<button id="deleteButton" mat-raised-button
(click)="onDeleteButtonClicked()"
(click)="onDeleteButtonClicked($event)"
color="primary" >
<mat-icon>delete</mat-icon>
<span>{{ "access.token.panel.button.delete" | translate }}</span>
</button>
<button id="saveButton" mat-raised-button
(click)="onSaveButtonClicked()"
(click)="onSaveButtonClicked($event)"
color="primary"
[disabled]="!submitButtonEnabled" >
<mat-icon>save</mat-icon>
......@@ -29,7 +29,7 @@
</div>
</div>
</mat-expansion-panel-header>
<div class="panel smp-data-panel" [formGroup]="credentialForm" (ngSubmit)="onSaveButtonClicked()">
<div class="panel smp-data-panel" [formGroup]="credentialForm">
<mat-form-field style="width: 100%">
<mat-label>{{ "access.token.panel.label.description" | translate }}</mat-label>
<input matInput
......
import {Component, EventEmitter, Input, Output} from '@angular/core';
import {FormBuilder, FormControl, FormGroup} from "@angular/forms";
import {
FormBuilder,
FormControl,
FormGroup
} from "@angular/forms";
import {CredentialRo} from "../../../security/credential.model";
import {BeforeLeaveGuard} from "../../../window/sidenav/navigation-on-leave-guard";
......@@ -11,7 +15,7 @@ import {BeforeLeaveGuard} from "../../../window/sidenav/navigation-on-leave-guar
})
export class AccessTokenPanelComponent implements BeforeLeaveGuard {
@Output() minSelectableDate: Date = new Date();
@Output() minSelectableDate: Date = null;
@Output() onDeleteEvent: EventEmitter<CredentialRo> = new EventEmitter();
@Output() onSaveEvent: EventEmitter<CredentialRo> = new EventEmitter();
......@@ -51,16 +55,17 @@ export class AccessTokenPanelComponent implements BeforeLeaveGuard {
this.credentialForm.markAsPristine();
}
onDeleteButtonClicked() {
onDeleteButtonClicked(event: MouseEvent) {
this.onDeleteEvent.emit(this.credential);
event?.stopPropagation();
}
onSaveButtonClicked() {
onSaveButtonClicked(event: MouseEvent) {
this._credential.active = this.credentialForm.controls['active'].value
this._credential.description = this.credentialForm.controls['description'].value
this._credential.activeFrom = this.credentialForm.controls['activeFrom'].value
this._credential.expireOn = this.credentialForm.controls['expireOn'].value
event?.stopPropagation();
this.onSaveEvent.emit(this._credential);
}
......@@ -84,5 +89,4 @@ export class AccessTokenPanelComponent implements BeforeLeaveGuard {
isDirty(): boolean {
return this.credentialForm.dirty;
}
}
<mat-expansion-panel [expanded]="_expanded" [formGroup]="credentialForm" (ngSubmit)="onSaveButtonClicked()">
<mat-expansion-panel [expanded]="_expanded" [formGroup]="credentialForm" >
<mat-expansion-panel-header style="height: 72px">
<div style="display: flex; flex-direction: column;width: 100%; padding-right: 10px">
<smp-warning-panel *ngIf="_credential.certificate?.invalid;" class="smp-certificate-warning-panel"
......@@ -16,13 +16,13 @@
<div
style="display: flex; flex-direction: row; justify-content: space-between; gap: 3px; padding-left: 5px;">
<button id="deleteButton" mat-raised-button
(click)="onDeleteButtonClicked()"
(click)="onDeleteButtonClicked($event)"
color="primary">
<mat-icon>delete</mat-icon>
<span>{{ "user.certificate.panel.button.delete" | translate }}</span>
</button>
<button id="saveButton" mat-raised-button
(click)="onSaveButtonClicked()"
(click)="onSaveButtonClicked($event)"
color="primary"
[disabled]="!submitButtonEnabled">
<mat-icon>save</mat-icon>
......
......@@ -59,13 +59,14 @@ export class UserCertificatePanelComponent implements BeforeLeaveGuard {
this.credentialForm.markAsPristine();
}
onDeleteButtonClicked() {
onDeleteButtonClicked(event: MouseEvent) {
this.onDeleteEvent.emit(this.credential);
event?.stopPropagation();
}
onSaveButtonClicked() {
onSaveButtonClicked(event: MouseEvent) {
this.onSaveEvent.emit(this.credential);
event?.stopPropagation();
}
onShowCertificateButtonClicked(){
......
......@@ -833,6 +833,9 @@
"user.access.tokens.update.confirmation.dialog.description": "Action will update access token: \"{{credentialName}}\"!<br /><br />Do you wish to continue?",
"user.access.tokens.update.confirmation.dialog.title": "Update Access token",
"user.access.tokens.tooltip.create": "Create new Access token",
"user.access.tokens.success.deleted": "Access token \"{{credentialName}}\" has been deleted!",
"user.access.tokens.success.updated": "Access token \"{{credentialName}}\" has been updated!",
"user.certificate.panel.button.delete": "Delete",
"user.certificate.panel.button.show.details": "Show Details",
......@@ -846,6 +849,9 @@
"user.certificate.panel.label.validity.dates": "Validity period of the certificate",
"user.certificate.panel.placeholder.end.date": "End date",
"user.certificate.panel.placeholder.start.date": "Start date",
"user.certificate.success.deleted": "Certificate \"{{credentialName}}\" has been deleted!",
"user.certificate.success.updated": "Certificate \"{{credentialName}}\" has been updated!",
"user.certificate.success.uploaded": "Certificate \"{{credentialName}}\" has been uploaded!",
"user.certificates.button.import": "Import new certificate",
"user.certificates.label.user.certificate": "User Certificates",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment