1. added delay dialog when merging an account

2. added configuration: footer-items
This commit is contained in:
Sofia Papacharalampous 2024-07-03 12:58:16 +03:00
parent fe97a14274
commit 0d569528e8
18 changed files with 182 additions and 16 deletions

View File

@ -166,6 +166,11 @@ export class ConfigurationService extends BaseComponent {
get sidebar(): Sidebar {
return this._sidebar;
}
private _mergeAccountDelayInSeconds: number;
get mergeAccountDelayInSeconds(): number {
return this._mergeAccountDelayInSeconds;
}
private _researcherId: any;
get researcherId(): boolean {
@ -266,6 +271,7 @@ export class ConfigurationService extends BaseComponent {
this._authProviders = AuthProviders.parseValue(config.authProviders);
this._analyticsProviders = AnalyticsProviders.parseValue(config.analytics);
this._sidebar = Sidebar.parseValue(config.sidebar);
this._mergeAccountDelayInSeconds = config.mergeAccountDelayInSeconds;
this._researcherId = config.referenceTypes.researcherId;
this._grantId = config.referenceTypes.grantId;
this._organizationId = config.referenceTypes.organizationId;

View File

@ -7,6 +7,7 @@ import { CommonUiModule } from '@common/ui/common-ui.module';
import { MergeEmailConfirmation } from './merge-email-confirmation/merge-email-confirmation.component';
import { UnlinkEmailConfirmation } from './unlink-email-confirmation/unlink-email-confirmation.component';
import { UserInviteConfirmation } from './user-invite-confirmation/user-invite-confirmation.component';
import { MergeEmailLoaderDialogComponent } from './merge-email-confirmation/merge-email-loader-dialog/merge-email-loader-dialog.component';
@NgModule({
imports: [
@ -18,7 +19,8 @@ import { UserInviteConfirmation } from './user-invite-confirmation/user-invite-c
LoginComponent,
MergeEmailConfirmation,
UnlinkEmailConfirmation,
UserInviteConfirmation
UserInviteConfirmation,
MergeEmailLoaderDialogComponent,
],
exports: [
LoginComponent

View File

@ -1,7 +1,8 @@
import { HttpErrorResponse } from "@angular/common/http";
import { Component, OnInit } from "@angular/core";
import { MatDialog } from "@angular/material/dialog";
import { ActivatedRoute, Router } from "@angular/router";
import { SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { RouterUtilsService } from "@app/core/services/router/router-utils.service";
import { UserService } from "@app/core/services/user/user.service";
import { BaseComponent } from '@common/base/base.component';
@ -9,6 +10,7 @@ import { HttpError, HttpErrorHandlingService } from "@common/modules/errors/erro
import { Guid } from "@common/types/guid";
import { TranslateService } from '@ngx-translate/core';
import { takeUntil } from "rxjs/operators";
import { MergeEmailLoaderDialogComponent } from "./merge-email-loader-dialog/merge-email-loader-dialog.component";
@Component({
selector: 'app-email-confirmation-component',
@ -31,7 +33,9 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit {
private router: Router,
private language: TranslateService,
private httpErrorHandlingService: HttpErrorHandlingService,
private routerUtils: RouterUtilsService
private routerUtils: RouterUtilsService,
private dialog: MatDialog,
private uiNotificationService: UiNotificationService,
) { super(); }
ngOnInit() {
@ -55,13 +59,24 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit {
onConfirm(): void {
if (this.showForm === false) return;
this.userService.confirmMergeAccount(this.token)
.subscribe(result => {
if (result) {
this.onCallbackEmailConfirmationSuccess();
}
},
error => this.onCallbackError(error));
let confirmMergeAccountObservable = this.userService.confirmMergeAccount(this.token);
const dialogRef = this.dialog.open(MergeEmailLoaderDialogComponent, {
maxWidth: '600px',
disableClose: true,
data: {
confirmMergeAccountObservable: confirmMergeAccountObservable,
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result.result) {
this.onCallbackEmailConfirmationSuccess();
} else {
if (result.error) this.onCallbackError(result.error);
else this.onCallbackError();
}
});
}
onCallbackEmailConfirmationSuccess() {
@ -73,10 +88,17 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit {
});
}
onCallbackError(errorResponse: HttpErrorResponse) {
onCallbackError(errorResponse?: HttpErrorResponse) {
if (!errorResponse) {
this.uiNotificationService.snackBarNotification('GENERAL.SNACK-BAR.GENERIC-ERROR', SnackBarNotificationLevel.Error);
return;
}
const errorOverrides = new Map<number, string>();
errorOverrides.set(302, this.language.instant('EMAIL-CONFIRMATION.EMAIL-FOUND'));
errorOverrides.set(403, this.language.instant('EMAIL-CONFIRMATION.EXPIRED-EMAIL'));
this.httpErrorHandlingService.handleBackedRequestError(errorResponse, errorOverrides, SnackBarNotificationLevel.Error)
const error: HttpError = this.httpErrorHandlingService.getError(errorResponse);

View File

@ -0,0 +1,20 @@
<div mat-dialog-title>
<div class="row align-items-center mb-2">
<div class="col-auto pr-0">
<mat-spinner [diameter]="20"></mat-spinner>
</div>
<div class="col-auto">
<span>{{ 'MERGE-ACCOUNT.MERGE-DIALOG.TITLE' | translate }}</span>
</div>
</div>
</div>
<mat-dialog-content>
<div class="row mt-4">
<div class="col-12">
<p class="message ml-2">
{{ 'MERGE-ACCOUNT.MERGE-DIALOG.MESSAGE' | translate: { s: mergeAccountDelayInSeconds } }}
</p>
</div>
</div>
</mat-dialog-content>

View File

@ -0,0 +1,5 @@
.message {
font-weight: lighter;
font-size: 1.25rem;
line-height: 1.9rem;
}

View File

@ -0,0 +1,47 @@
import { Component, Inject, OnDestroy, OnInit } from "@angular/core";
import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog";
import { ConfigurationService } from "@app/core/services/configuration/configuration.service";
import { Subscription, takeUntil } from "rxjs";
@Component({
selector: 'merge-email-loader',
templateUrl: './merge-email-loader-dialog.component.html',
styleUrls: ['./merge-email-loader-dialog.component.scss'],
})
export class MergeEmailLoaderDialogComponent implements OnInit, OnDestroy {
confirmMergeAccountSubscription: Subscription;
mergeAccountDelay: number = 60000;
get mergeAccountDelayInSeconds(): number {
return this.mergeAccountDelay/1000;
}
constructor(
private dialogRef: MatDialogRef<MergeEmailLoaderDialogComponent>,
private configurationService: ConfigurationService,
@Inject(MAT_DIALOG_DATA) public data: any,
) {}
ngOnInit(): void {
if (this.configurationService.mergeAccountDelayInSeconds) this.mergeAccountDelay = this.configurationService.mergeAccountDelayInSeconds*1000;
if (this.data.confirmMergeAccountObservable) {
this.confirmMergeAccountSubscription = this.data.confirmMergeAccountObservable.subscribe(result => {
if (result) {
setTimeout( _ => this.onClose(true), this.mergeAccountDelay)
}
},
error => this.onClose(false, error));
}
}
onClose(success: boolean, error: any = null) {
this.dialogRef.close({ result: success, error: error});
}
ngOnDestroy(): void {
this.confirmMergeAccountSubscription?.unsubscribe();
}
}

View File

@ -109,12 +109,32 @@
],
"footerItems": [
{
"routerPath": "/feedback",
"title": "SIDE-BAR.FEEDBACK",
"routerPath": "/about",
"title": "FOOTER.ABOUT",
"icon": "feedback",
"externalUrl": "https://docs.google.com/forms/d/12RSCrUjdSDp2LZLpjDKOi44cN1fLDD2q1-F66SqZIis/viewform?edit_requested=true",
"accessLevel": true
"accessLevel": "public"
},
{
"routerPath": "/terms-and-conditions",
"title": "FOOTER.TERMS-OF-SERVICE",
"accessLevel": "public"
},
{
"routerPath": "/glossary",
"title": "FOOTER.GLOSSARY",
"accessLevel": "public"
},
{
"routerPath": "/user-guide",
"title": "FOOTER.GUIDE",
"accessLevel": "public"
},
{
"routerPath": "/contact-support",
"title": "FOOTER.CONTACT-SUPPORT",
"accessLevel": "authenticated"
}
]
}
},
"mergeAccountDelayInSeconds": 30
}

View File

@ -2274,6 +2274,10 @@
},
"ACTIONS": {
"CONFIRM": "Confirm"
},
"MERGE-DIALOG": {
"TITLE": "Please wait while we are merging your account.",
"MESSAGE": "Please keep this tab open and allow {{ s }} seconds while we are setting things up for you. Be sure to close any other opened tab."
}
},
"UNLINK-ACCOUNT": {

View File

@ -2274,6 +2274,10 @@
},
"ACTIONS": {
"CONFIRM": "Confirm"
},
"MERGE-DIALOG": {
"TITLE": "Please wait while we are merging your account.",
"MESSAGE": "Please keep this tab open and allow {{ s }} seconds while we are setting things up for you. Be sure to close any other opened tab."
}
},
"UNLINK-ACCOUNT": {

View File

@ -2274,6 +2274,10 @@
},
"ACTIONS": {
"CONFIRM": "Confirm"
},
"MERGE-DIALOG": {
"TITLE": "Please wait while we are merging your account.",
"MESSAGE": "Please keep this tab open and allow {{ s }} seconds while we are setting things up for you. Be sure to close any other opened tab."
}
},
"UNLINK-ACCOUNT": {

View File

@ -2274,6 +2274,10 @@
},
"ACTIONS": {
"CONFIRM": "Confirm"
},
"MERGE-DIALOG": {
"TITLE": "Please wait while we are merging your account.",
"MESSAGE": "Please keep this tab open and allow {{ s }} seconds while we are setting things up for you. Be sure to close any other opened tab."
}
},
"UNLINK-ACCOUNT": {

View File

@ -2274,6 +2274,10 @@
},
"ACTIONS": {
"CONFIRM": "Confirm"
},
"MERGE-DIALOG": {
"TITLE": "Please wait while we are merging your account.",
"MESSAGE": "Please keep this tab open and allow {{ s }} seconds while we are setting things up for you. Be sure to close any other opened tab."
}
},
"UNLINK-ACCOUNT": {

View File

@ -2274,6 +2274,10 @@
},
"ACTIONS": {
"CONFIRM": "Confirm"
},
"MERGE-DIALOG": {
"TITLE": "Please wait while we are merging your account.",
"MESSAGE": "Please keep this tab open and allow {{ s }} seconds while we are setting things up for you. Be sure to close any other opened tab."
}
},
"UNLINK-ACCOUNT": {

View File

@ -2274,6 +2274,10 @@
},
"ACTIONS": {
"CONFIRM": "Confirm"
},
"MERGE-DIALOG": {
"TITLE": "Please wait while we are merging your account.",
"MESSAGE": "Please keep this tab open and allow {{ s }} seconds while we are setting things up for you. Be sure to close any other opened tab."
}
},
"UNLINK-ACCOUNT": {

View File

@ -2274,6 +2274,10 @@
},
"ACTIONS": {
"CONFIRM": "Confirm"
},
"MERGE-DIALOG": {
"TITLE": "Please wait while we are merging your account.",
"MESSAGE": "Please keep this tab open and allow {{ s }} seconds while we are setting things up for you. Be sure to close any other opened tab."
}
},
"UNLINK-ACCOUNT": {

View File

@ -2274,6 +2274,10 @@
},
"ACTIONS": {
"CONFIRM": "Confirm"
},
"MERGE-DIALOG": {
"TITLE": "Please wait while we are merging your account.",
"MESSAGE": "Please keep this tab open and allow {{ s }} seconds while we are setting things up for you. Be sure to close any other opened tab."
}
},
"UNLINK-ACCOUNT": {

View File

@ -2274,6 +2274,10 @@
},
"ACTIONS": {
"CONFIRM": "Confirm"
},
"MERGE-DIALOG": {
"TITLE": "Please wait while we are merging your account.",
"MESSAGE": "Please keep this tab open and allow {{ s }} seconds while we are setting things up for you. Be sure to close any other opened tab."
}
},
"UNLINK-ACCOUNT": {

View File

@ -2274,6 +2274,10 @@
},
"ACTIONS": {
"CONFIRM": "Confirm"
},
"MERGE-DIALOG": {
"TITLE": "Please wait while we are merging your account.",
"MESSAGE": "Please keep this tab open and allow {{ s }} seconds while we are setting things up for you. Be sure to close any other opened tab."
}
},
"UNLINK-ACCOUNT": {