diff --git a/dmp-frontend/src/app/core/model/user/user.ts b/dmp-frontend/src/app/core/model/user/user.ts index 3108a1b24..d920512a0 100644 --- a/dmp-frontend/src/app/core/model/user/user.ts +++ b/dmp-frontend/src/app/core/model/user/user.ts @@ -75,3 +75,7 @@ export interface DmpAssociatedUser { name: string; email: string; } + +export interface UserMergeRequestPersist { + email: string; +} diff --git a/dmp-frontend/src/app/core/services/user/user.service.ts b/dmp-frontend/src/app/core/services/user/user.service.ts index 988bbb8e8..79e5b6049 100644 --- a/dmp-frontend/src/app/core/services/user/user.service.ts +++ b/dmp-frontend/src/app/core/services/user/user.service.ts @@ -1,7 +1,7 @@ import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { IsActive } from '@app/core/common/enum/is-active.enum'; -import { DmpAssociatedUser, User, UserPersist, UserRolePatchPersist } from '@app/core/model/user/user'; +import { DmpAssociatedUser, User, UserMergeRequestPersist, UserPersist, UserRolePatchPersist } from '@app/core/model/user/user'; import { UserLookup } from '@app/core/query/user.lookup'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; @@ -99,6 +99,14 @@ export class UserService { return this.http.post(url, formData, { params: params }); } + mergeAccount(item: UserMergeRequestPersist): Observable { + const url = `${this.apiBase}/mine/merge-account-request`; + + return this.http + .post(url, item).pipe( + catchError((error: any) => throwError(error))); + } + // // Autocomplete Commons // diff --git a/dmp-frontend/src/app/library/notification/popup/popup-notification.component.html b/dmp-frontend/src/app/library/notification/popup/popup-notification.component.html index 3e0877065..4bc153f8d 100644 --- a/dmp-frontend/src/app/library/notification/popup/popup-notification.component.html +++ b/dmp-frontend/src/app/library/notification/popup/popup-notification.component.html @@ -1,5 +1,21 @@ -

{{notification.title}}

-{{notification.message}} - - - +
+
+
+ + {{notification.title}} + +
+
+
+
+ + {{notification.message}} + +
+
+
+
+ +
+
+
diff --git a/dmp-frontend/src/app/library/notification/popup/popup-notification.component.scss b/dmp-frontend/src/app/library/notification/popup/popup-notification.component.scss new file mode 100644 index 000000000..ee04ba4fb --- /dev/null +++ b/dmp-frontend/src/app/library/notification/popup/popup-notification.component.scss @@ -0,0 +1,4 @@ +.dialog-wrapper { + padding: 2.0rem; + width: 40vw; +} diff --git a/dmp-frontend/src/app/library/notification/popup/popup-notification.component.ts b/dmp-frontend/src/app/library/notification/popup/popup-notification.component.ts index 6240d08c5..63d89f4e4 100644 --- a/dmp-frontend/src/app/library/notification/popup/popup-notification.component.ts +++ b/dmp-frontend/src/app/library/notification/popup/popup-notification.component.ts @@ -4,7 +4,8 @@ import { PopupNotification } from '../../../core/services/notification/ui-notifi @Component({ selector: 'app-popup-notification-dialog', - templateUrl: './popup-notification.component.html' + templateUrl: './popup-notification.component.html', + styleUrls: ['popup-notification.component.scss'] }) export class PopupNotificationDialogComponent { diff --git a/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.html b/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.html index d35cc84ce..bd2bc989f 100644 --- a/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.html +++ b/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.html @@ -1,20 +1,27 @@
-
-

{{'USER-PROFILE.ACTIONS.LINK-NEW-ACCOUNT' | translate}}

- close +
+
+ {{'USER-PROFILE.ACTIONS.LINK-NEW-ACCOUNT' | translate}} +
+
+ close +
-
-
- - + +
+
+ +
-
-
- - -
+
+
+
+ +
+
+
diff --git a/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.scss b/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.scss index 2ea0cecfe..e3f5b3312 100644 --- a/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.scss +++ b/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.scss @@ -1,4 +1,8 @@ .template-container { + + width: 40vw; + padding: 2.0rem; + .header { display: flex; width: 100%; diff --git a/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.ts b/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.ts index ad4712467..856300188 100644 --- a/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.ts +++ b/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.ts @@ -1,5 +1,5 @@ import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; +import { FormBuilder, FormGroup, UntypedFormGroup, Validators } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; @Component({ @@ -13,18 +13,22 @@ export class AddAccountDialogComponent implements OnInit { datasetProfileDefinitionModel: any; datasetProfileDefinitionFormGroup: UntypedFormGroup; progressIndication = false; - public hasEmail = true; + form: FormGroup; + // public hasEmail = true; //TODO: refactor - private request: any; + // private request: any; constructor( + private formBuilder: FormBuilder, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any - ) { - - } + ) { } ngOnInit(): void { + this.form = this.formBuilder.group({ + email: [this.data.email, [Validators.required, Validators.email]] + }); + //TODO refactor // this.mergeLoginService.getObservable().subscribe(result => { // if (result !== undefined) { @@ -39,16 +43,14 @@ export class AddAccountDialogComponent implements OnInit { } add(): void { - this.request.email = 'email'; - this.dialogRef.close(this.request); + this.closeDialog(this.form.value); } cancel(): void { - this.dialogRef.close(); + this.closeDialog(); } - closeDialog(): void { - this.dialogRef.close(); + closeDialog(data?: any): void { + this.dialogRef.close(data); } - } diff --git a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts index 6d66c4dca..db079be6e 100644 --- a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts +++ b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts @@ -330,13 +330,30 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes const dialogRef = this.dialog.open(AddAccountDialogComponent, { restoreFocus: false, autoFocus: false, - width: '653px', - maxHeight: '90vh', + // width: '653px', + // maxHeight: '90vh', data: { + email: '' } }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result) { + console.log('email result:'); + console.log(result); + this.userService.mergeAccount({ email: result.email }) + .subscribe(result => { + if (result) { + this.dialog.open(PopupNotificationDialogComponent, { + data: { + title: this.language.instant('USER-PROFILE.MERGING-EMAILS-DIALOG.TITLE'), + message: this.language.instant('USER-PROFILE.MERGING-EMAILS-DIALOG.MESSAGE') + }//, maxWidth: '30em' + }); + } + }, + error => console.error(error)); //TODO how to handle this + + //TODO refactor // this.mergeEmailConfirmation.sendConfirmationEmail(result).pipe(takeUntil(this._destroyed)) // .subscribe(res => {