From 551249af33ed9f7da3eb7e8e5f047b06ae084d0a Mon Sep 17 00:00:00 2001 From: Sofia Papacharalampous Date: Tue, 19 Mar 2024 17:12:36 +0200 Subject: [PATCH] styling changes *user-profile --- dmp-backend/pom.xml | 13 ---- dmp-frontend/src/app/core/model/user/user.ts | 6 ++ .../add-account-dialog.component.html | 2 +- .../user-profile/user-profile.component.html | 66 +++++++++---------- .../ui/user-profile/user-profile.component.ts | 63 +++++++++++------- 5 files changed, 81 insertions(+), 69 deletions(-) diff --git a/dmp-backend/pom.xml b/dmp-backend/pom.xml index 2d0d0bf65..200ef159d 100644 --- a/dmp-backend/pom.xml +++ b/dmp-backend/pom.xml @@ -412,19 +412,6 @@ - - cite-dev - - - cite-maven - CITE Maven Repository - https://crepo.cite.gr/repository/cite-maven/ - - - - true - - \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/user/user.ts b/dmp-frontend/src/app/core/model/user/user.ts index 40d3f965d..3108a1b24 100644 --- a/dmp-frontend/src/app/core/model/user/user.ts +++ b/dmp-frontend/src/app/core/model/user/user.ts @@ -62,6 +62,12 @@ export interface UserCredential { externalId: String; user: User; createdAt: Date; + data: UserCredentialData +} + +export interface UserCredentialData { + externalProviderNames: String[]; + email: String; } export interface DmpAssociatedUser { 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 bd3776d6f..d35cc84ce 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 @@ -3,7 +3,7 @@

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

close - +
diff --git a/dmp-frontend/src/app/ui/user-profile/user-profile.component.html b/dmp-frontend/src/app/ui/user-profile/user-profile.component.html index 644698ab0..0ab832a5f 100644 --- a/dmp-frontend/src/app/ui/user-profile/user-profile.component.html +++ b/dmp-frontend/src/app/ui/user-profile/user-profile.component.html @@ -1,3 +1,5 @@ + +
- +
@@ -68,31 +74,29 @@
- --> +
-
+
{{'USER-PROFILE.SETTINGS.ORGANIZATION' | translate}}
- +
-
- -
-
+ +
{{'USER-PROFILE.SETTINGS.ROLE' | translate}}
- + {{enumUtils.toRoleOrganizationString(roleOrganizationEnum.Faculty)}} {{enumUtils.toRoleOrganizationString(roleOrganizationEnum.Librarian)}} @@ -116,13 +120,13 @@
-
+
{{'USER-PROFILE.SETTINGS.TIMEZONE' | translate}} *
- + @@ -134,16 +138,14 @@
-
-
-
+
{{'USER-PROFILE.SETTINGS.CULTURE' | translate}} *
- + @@ -155,17 +157,15 @@
-
-
-
+
{{'USER-PROFILE.SETTINGS.LANGUAGE' | translate}} *
- + 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 9d58964c7..7645dd153 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 @@ -6,7 +6,7 @@ import { ActivatedRoute, Params, Router } from '@angular/router'; import { RoleOrganizationType } from '@app/core/common/enum/role-organization-type'; import { CultureInfo } from '@app/core/model/culture-info'; import { Reference } from '@app/core/model/reference/reference'; -import { User } from '@app/core/model/user/user'; +import { User, UserCredential } from '@app/core/model/user/user'; import { AuthService } from '@app/core/services/auth/auth.service'; import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; import { CultureService } from '@app/core/services/culture/culture-service'; @@ -39,7 +39,8 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes userProfileEditorModel: UserProfileEditorModel; user: Observable; //TODO: refactor - // userCredentials: UserCredentialModel[]; + userCredentials: Observable; + firstEmail: String; currentUserId: string; cultures: Observable; timezones: Observable; @@ -95,31 +96,42 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes nameof(x => x.additionalInfo.culture), nameof(x => x.additionalInfo.organization), nameof(x => x.additionalInfo.roleOrganization), + `${nameof(x => x.credentials)}.${nameof(x => x.data.email)}`, + `${nameof(x => x.credentials)}.${nameof(x => x.data.externalProviderNames)}`, ] ) .pipe(map(result => { - //result['additionalinfo'] = JSON.parse(result['additionalinfo']); + //tested ui with fake data + // const fakecredentials: UserCredential = { + // "id": Guid.createEmpty(), + // "externalId": "123", + // "user": null, + // "createdAt": new Date(), + // "data": { + // "email": "dmpadmin@dmp.com", + // "externalProviderNames": ["Google", "Facebook"] + // } + // }; + // result.credentials.push(fakecredentials); + // result.credentials[0].data.externalProviderNames = ['Google']; + + this.firstEmail = result.credentials[0].data.email; + this.userCredentials = of(result.credentials); - this.userProfileEditorModel = new UserProfileEditorModel().fromModel(result); - this.formGroup = this.userProfileEditorModel.buildForm(this.languageService.getAvailableLanguagesCodes()); + this.userProfileEditorModel = new UserProfileEditorModel().fromModel(result); + this.formGroup = this.userProfileEditorModel.buildForm(this.languageService.getAvailableLanguagesCodes()); - // this.formGroup = new FormBuilder().group({ - // language: new FormControl(result['language'] ? availableLanguages.filter(x => x.value === result['language']['value']).pop() : '', [Validators.required]), - // timezone: new FormControl(result['timezone'], [Validators.required]), - // culture: new FormControl(result['culture'], [Validators.required]) - // }); - - //this.formGroup.get('language').valueChanges.pipe(takeUntil(this._destroyed)).subscribe(x => { if (x) this.translate.use(x.value) }) - this.formGroup.get('timezone').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { if (x) { this.timezones = this._filterTimezone(x); } }); - this.formGroup.get('culture').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { if (x) { this.cultures = this._filterCulture(x); } }); - // this.initializeDisabledFormGroup(); - this.unlock(); - return result; - })); + //this.formGroup.get('language').valueChanges.pipe(takeUntil(this._destroyed)).subscribe(x => { if (x) this.translate.use(x.value) }) + this.formGroup.get('timezone').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => { if (x) { this.timezones = this._filterTimezone(x); } }); + this.formGroup.get('culture').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => { if (x) { this.cultures = this._filterCulture(x); } }); + // this.initializeDisabledFormGroup(); + this.unlock(); + return result; + })); //TODO: refactor // this.userService.getEmails(userId).pipe(takeUntil(this._destroyed)) @@ -138,6 +150,12 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes ngOnDestroy(): void { } + public hasProvider(userCredential: UserCredential, provider: string): boolean { + const result = userCredential.data.externalProviderNames?.find(x => x == provider); + + return result != null; + } + private filterOrganisations(value: string): Observable { //TODO: refactor // return this.externalSourcesService.searchDMPOrganizations(value); @@ -259,6 +277,7 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes .subscribe(confirm => { if (confirm) { //TODO: refactor + console.log('removed!'); // const unlinkAccountModel: UnlinkAccountRequestModel = { // userId: this.currentUserId, // email: userCredential.email,