From 40154d6ad9859ec993f9064bee02756f575d8e6a Mon Sep 17 00:00:00 2001 From: argirok Date: Thu, 8 Sep 2022 16:30:40 +0300 Subject: [PATCH 1/4] revert previous tests for backet sticky menu --- claims/linking/linkingGeneric.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/claims/linking/linkingGeneric.component.html b/claims/linking/linkingGeneric.component.html index 9a62d971..f3d8f825 100644 --- a/claims/linking/linkingGeneric.component.html +++ b/claims/linking/linkingGeneric.component.html @@ -66,7 +66,7 @@
-
From 1c4551c40869197cc4f5b27edea7919872fedd3f Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Thu, 8 Sep 2022 16:43:59 +0300 Subject: [PATCH 2/4] Remove promise from user management service. Change user component in order to update user-info in case of session expired --- .../connectAdminLoginGuard.guard.ts | 2 +- .../communityGuard/connectSubscriber.guard.ts | 2 +- login/adminLoginGuard.guard.ts | 2 +- login/claimsCuratorGuard.guard.ts | 2 +- login/loginGuard.guard.ts | 2 +- login/user.component.ts | 6 ++-- .../role-verification.component.ts | 2 +- services/user-management.service.ts | 36 +++++-------------- 8 files changed, 18 insertions(+), 36 deletions(-) diff --git a/connect/communityGuard/connectAdminLoginGuard.guard.ts b/connect/communityGuard/connectAdminLoginGuard.guard.ts index e718cd8e..6a1765de 100644 --- a/connect/communityGuard/connectAdminLoginGuard.guard.ts +++ b/connect/communityGuard/connectAdminLoginGuard.guard.ts @@ -22,7 +22,7 @@ export class ConnectAdminLoginGuard implements CanActivate, CanActivateChild { check(community: string, path: string): Observable | boolean { let errorCode = LoginErrorCodes.NOT_LOGIN; - const authorized = this.userManagementService.getUserInfo(false).pipe(take(1), map(user => { + const authorized = this.userManagementService.getUserInfo().pipe(take(1), map(user => { if (user) { if (Session.isPortalAdministrator(user) || Session.isCommunityCurator(user) || Session.isManager('community', community, user)) { return of(true); diff --git a/connect/communityGuard/connectSubscriber.guard.ts b/connect/communityGuard/connectSubscriber.guard.ts index 19eea1f8..aac13b37 100644 --- a/connect/communityGuard/connectSubscriber.guard.ts +++ b/connect/communityGuard/connectSubscriber.guard.ts @@ -30,7 +30,7 @@ export class ConnectSubscriberGuard implements CanActivate, CanActivateChild { } else { community = ConnectHelper.getCommunityFromDomain(properties.domain); } - const authorized = this.userManagementService.getUserInfo(false).pipe(take(1), map(user => { + const authorized = this.userManagementService.getUserInfo().pipe(take(1), map(user => { if (user) { if (Session.isSubscribedTo('community', community, user)) { return of(true); diff --git a/login/adminLoginGuard.guard.ts b/login/adminLoginGuard.guard.ts index 5c5fb990..0548fb3b 100644 --- a/login/adminLoginGuard.guard.ts +++ b/login/adminLoginGuard.guard.ts @@ -22,7 +22,7 @@ export class AdminLoginGuard implements CanActivate, CanActivateChild { check(data: Data, path: string): Observable { let errorCode = LoginErrorCodes.NOT_LOGIN; - return this.userManagementService.getUserInfo(false).pipe(map(user => { + return this.userManagementService.getUserInfo().pipe(map(user => { if (user) { errorCode = LoginErrorCodes.NOT_ADMIN; } diff --git a/login/claimsCuratorGuard.guard.ts b/login/claimsCuratorGuard.guard.ts index 724f0f0a..2bfce277 100644 --- a/login/claimsCuratorGuard.guard.ts +++ b/login/claimsCuratorGuard.guard.ts @@ -15,7 +15,7 @@ export class ClaimsCuratorGuard implements CanActivate { check(path: string): Observable | boolean { let errorCode = LoginErrorCodes.NOT_LOGIN; - return this.userManagementService.getUserInfo(false).pipe(map(user => { + return this.userManagementService.getUserInfo().pipe(map(user => { if (user) { errorCode = LoginErrorCodes.NOT_ADMIN; } diff --git a/login/loginGuard.guard.ts b/login/loginGuard.guard.ts index 99faad2c..59e72592 100644 --- a/login/loginGuard.guard.ts +++ b/login/loginGuard.guard.ts @@ -22,7 +22,7 @@ export class LoginGuard implements CanActivate, CanLoad, CanActivateChild { } check(path: string): Observable | boolean { - return this.userManagementService.getUserInfo(false).pipe(map(user => { + return this.userManagementService.getUserInfo().pipe(map(user => { return user !== null; }),tap(isLoggedIn => { if(!isLoggedIn) { diff --git a/login/user.component.ts b/login/user.component.ts index d364684f..1f6ee1d8 100644 --- a/login/user.component.ts +++ b/login/user.component.ts @@ -43,8 +43,8 @@ export class UserComponent { this.loginUrl = this.properties.loginUrl; if (typeof document !== 'undefined') { this.server = false; - this.subscriptions.push(this.userManagementsService.getUserInfo(false).subscribe(user => { - this.user = user; + this.userManagementsService.updateUserInfo(() => { + this.user = this.userManagementsService.user; this.loggedIn = !!this.user; this.errorMessage = ""; this.loading = true; @@ -58,7 +58,7 @@ export class UserComponent { this.loading = false; } })); - })); + }); } } diff --git a/role-verification/role-verification.component.ts b/role-verification/role-verification.component.ts index 609ecd29..c45184f8 100644 --- a/role-verification/role-verification.component.ts +++ b/role-verification/role-verification.component.ts @@ -103,7 +103,7 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn ngAfterViewInit() { this.subs.push(this.route.queryParams.subscribe(params => { if (params && params['verify']) { - this.subs.push(this.userManagementService.getUserInfo(false).subscribe(user => { + this.subs.push(this.userManagementService.getUserInfo().subscribe(user => { this.user = user; if (this.user) { this.subs.push(this.userRegistryService.getInvitation(params['verify']).subscribe(verification => { diff --git a/services/user-management.service.ts b/services/user-management.service.ts index d6a1ccd5..d7b640eb 100644 --- a/services/user-management.service.ts +++ b/services/user-management.service.ts @@ -16,22 +16,11 @@ export class UserManagementService { private readonly getUserInfoSubject: AdvancedAsyncSubject = new AdvancedAsyncSubject(); public fixRedirectURL: string = null; private redirectUrl: string = null; - private readonly promise: Promise; private subscription; private readonly routerSubscription; - constructor(private http: HttpClient, private router: Router) { - this.promise = new Promise((resolve => { - this.updateUserInfo(resolve); - })); - this.routerSubscription = this.router.events.subscribe(event => { - if (event instanceof NavigationEnd) { - const token = COOKIE.getCookie('AccessToken'); - if (!token && this.getUserInfoSubject.getValue() !== null) { - this.getUserInfoSubject.next(null); - } - } - }); + constructor(private http: HttpClient) { + this.updateUserInfo(); } clearSubscriptions() { @@ -43,12 +32,12 @@ export class UserManagementService { } } - public getUserInfo(subject: boolean = true): Observable { - if (subject) { - return this.getUserInfoSubject.asObservable(); - } else { - return from(this.getUserInfoAsync()); - } + public get user(): User { + return this.getUserInfoSubject.getValue(); + } + + public getUserInfo(): Observable { + return this.getUserInfoSubject.asObservable(); } public updateUserInfo(resolve: Function = null) { @@ -67,14 +56,6 @@ export class UserManagementService { }); } - private async getUserInfoAsync(): Promise { - await this.promise; - if (this.subscription) { - this.subscription.unsubscribe(); - } - return this.getUserInfoSubject.getValue(); - } - private parseUserInfo(info: any) { const user: User = new User(); user.id = (info.sub && info.sub.indexOf('@')) ? info.sub.substring(0, info.sub.indexOf('@')) : info.sub; @@ -144,6 +125,7 @@ export class UserManagementService { public logout() { this.setRedirectUrl(); Session.removeUser(); + this.getUserInfoSubject.next(null); window.location.href = properties.logoutUrl + "?redirect=" + this.redirectUrl; } } From 656a3634e282ba9e5e5f684ea129a0de9bca1491 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Fri, 9 Sep 2022 00:35:11 +0300 Subject: [PATCH 3/4] [Library | new-theme]: Do not show provenance value if no provenance vocabulary or if no label for this provenance value. 1. fundedBy.component.ts: Added local field "provenancesCalculated" to check for each provenance label only once and do not show provenance if no vocabulary or if not label for this value. 2. result-preview.component.ts: Do not show provenance if no vocabulary or if no label for this value. 3. HelperFunctions.class.ts: In method "getVocabularyLabel()" added parameter "returnIfNotFound: boolean = true" to return null if no vocabulary or if no label for this value, when it is false. --- landingPages/landing-utils/fundedBy.component.ts | 13 +++++++++---- utils/HelperFunctions.class.ts | 10 ++++++++-- utils/result-preview/result-preview.component.ts | 5 ++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/landingPages/landing-utils/fundedBy.component.ts b/landingPages/landing-utils/fundedBy.component.ts index 663b163b..634998e1 100644 --- a/landingPages/landing-utils/fundedBy.component.ts +++ b/landingPages/landing-utils/fundedBy.component.ts @@ -58,10 +58,10 @@ import {HelperFunctions} from '../../utils/HelperFunctions.class'; Funding stream: {{item.funding}} -
+
Validated by funder | - {{getVocabularyLabel(item.provenanceAction, provenanceActionVocabulary)}} + {{item.provenanceAction}}
@@ -80,6 +80,7 @@ export class FundedByComponent { public url = properties.searchLinkToProject.split('?')[0]; public title: string = "Funded by"; @Input() provenanceActionVocabulary = null; + public provenancesCalculated: boolean[] = []; public viewAllClick() { if(this.fundedByProjects.length <= this.threshold*2) { @@ -96,7 +97,11 @@ export class FundedByComponent { this.viewAllClicked.emit(""); } - public getVocabularyLabel(value: any, vocabulary: any) { - return HelperFunctions.getVocabularyLabel(value, vocabulary); + public getVocabularyLabel(item: any, vocabulary: any, index: number) { + if(!this.provenancesCalculated[index]) { + this.provenancesCalculated[index] = true; + item.provenanceAction = HelperFunctions.getVocabularyLabel(item.provenanceAction, vocabulary, false); + } + return item.provenanceAction; } } diff --git a/utils/HelperFunctions.class.ts b/utils/HelperFunctions.class.ts index 981fdf21..1b629fb0 100644 --- a/utils/HelperFunctions.class.ts +++ b/utils/HelperFunctions.class.ts @@ -72,11 +72,17 @@ export class HelperFunctions { return Object.keys(value).map(key => value[key]); } - public static getVocabularyLabel(value: any, vocabulary: any) { + public static getVocabularyLabel(value: any, vocabulary: any, returnIfNotFound: boolean = true) { + if(value == undefined || value == null) { + return null; + } if(vocabulary && value in vocabulary) { return vocabulary[value]; } - return value; + if(returnIfNotFound) { + return value; + } + return null; } public static sortSDGs(sgd1: string, sdg2: string): number { diff --git a/utils/result-preview/result-preview.component.ts b/utils/result-preview/result-preview.component.ts index e613dc3b..a53f4506 100644 --- a/utils/result-preview/result-preview.component.ts +++ b/utils/result-preview/result-preview.component.ts @@ -123,7 +123,10 @@ export class ResultPreviewComponent implements OnInit, OnChanges { this.beforeTitle.push(this.result.startYear.toString() + ' - ' + this.result.endYear.toString()); } if(this.result.provenanceAction) { - this.beforeTitle.push(HelperFunctions.getVocabularyLabel(this.result.provenanceAction, this.provenanceActionVocabulary)); + let value = HelperFunctions.getVocabularyLabel(this.result.provenanceAction, this.provenanceActionVocabulary, false); + if(value) { + this.beforeTitle.push(value); + } } if(this.result.relationName) { this.beforeTitle.push(HelperFunctions.getVocabularyLabel(this.result.relationName, this.relationsVocabulary)); From 7ef47ab0efcefa8f28bdc6516f27cad9b12df30c Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Fri, 9 Sep 2022 00:46:44 +0300 Subject: [PATCH 4/4] [Library | new-theme]: Fixes in parsing of "eoscifguidelines" | Added EOSC Subject ("eoscifguidelines") in RESULT ADVANCED FIELDS (not in production for now). 1. resultLanding.service.ts: [Bug fix] Spelling error in parsing of "eoscifguidelines" field. 2. showSubjects.component.ts: [Bug fix] Do not show "EOSC" label in classified subjects, when no "eoscSubjects" parsed. 3. searchFields.ts: In RESULT_ADVANCED_FIELDS added "eoscifguidelines" | Added method "getResultAdvancedFields()", which does not include "eoscifguidelines" in "RESULT_ADVANCED_FIELDS" when environment == "production". 4. searchAll.component.ts & searchResearchResults.component.ts: Get searchFields.RESULT_ADVANCED_FIELDS from "getResultAdvancedFields()". --- .../landing-utils/showSubjects.component.ts | 4 ++-- landingPages/result/resultLanding.service.ts | 2 +- searchPages/find/searchAll.component.ts | 2 +- .../searchResearchResults.component.ts | 2 +- utils/properties/searchFields.ts | 21 ++++++++++++++++++- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/landingPages/landing-utils/showSubjects.component.ts b/landingPages/landing-utils/showSubjects.component.ts index 1b9aa981..2eab7611 100644 --- a/landingPages/landing-utils/showSubjects.component.ts +++ b/landingPages/landing-utils/showSubjects.component.ts @@ -18,7 +18,7 @@ import {properties} from "../../../../environments/environment"; Subjects by Vocabulary
- + @@ -97,7 +97,7 @@ import {properties} from "../../../../environments/environment";
- +
` diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts index 3bb8d720..55b4f30a 100644 --- a/landingPages/result/resultLanding.service.ts +++ b/landingPages/result/resultLanding.service.ts @@ -87,7 +87,7 @@ export class ResultLandingService { res[1]['oaf:result']['pid'], // 4 res[1]['oaf:result']['journal'], // 5 res[1]['oaf:result']['language'], // 6 - res[1]['oaf:result']['eoscifgiudelines'], // 7 + res[1]['oaf:result']['eoscifguidelines'], // 7 res[1]['oaf:result']['subject'], // 8 res[1]['oaf:result']['context'], // 9 res[1]['oaf:result']['creator'], // 10 diff --git a/searchPages/find/searchAll.component.ts b/searchPages/find/searchAll.component.ts index bc8f5a0d..a9ed7ce3 100644 --- a/searchPages/find/searchAll.component.ts +++ b/searchPages/find/searchAll.component.ts @@ -103,7 +103,7 @@ export class SearchAllComponent { resultTypes = {publication: true, dataset: true, software: true, other: true}; //adv Search Form - public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS; + public fieldIds: string[] = this.searchFields.getResultAdvancedFields(); public fieldIdsMap = this.searchFields.RESULT_FIELDS; public selectedFields: AdvancedField[] = []; diff --git a/searchPages/searchResearchResults.component.ts b/searchPages/searchResearchResults.component.ts index e15e3657..37419da8 100644 --- a/searchPages/searchResearchResults.component.ts +++ b/searchPages/searchResearchResults.component.ts @@ -62,7 +62,7 @@ export class SearchResearchResultsComponent { public searchUtils: SearchUtilsClass = new SearchUtilsClass(); public searchFields: SearchFields = new SearchFields(); - public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS; + public fieldIds: string[] = this.searchFields.getResultAdvancedFields(); public fieldIdsMap = this.searchFields.RESULT_FIELDS; public rangeFields: string[][] = this.searchFields.RESULT_RANGE_FIELDS; public selectedFields: AdvancedField[] = []; diff --git a/utils/properties/searchFields.ts b/utils/properties/searchFields.ts index b767570b..ab616156 100644 --- a/utils/properties/searchFields.ts +++ b/utils/properties/searchFields.ts @@ -1,4 +1,5 @@ import {Filter} from "../../searchPages/searchUtils/searchHelperClasses.class"; +import {properties} from "../../../../environments/environment"; export class SearchFields { @@ -17,7 +18,7 @@ export class SearchFields { "relfundinglevel0_id", "relfundinglevel1_id", "relfundinglevel2_id", "relproject", "sdg", "country", "resultlanguagename", "resulthostingdatasource", "community"]; - public RESULT_ADVANCED_FIELDS: string[] = ["q", "resulttitle", "resultauthor", "authorid", "resultdescription", "resultsubject", "resultpublisher", + public RESULT_ADVANCED_FIELDS: string[] = ["q", "resulttitle", "resultauthor", "authorid", "resultdescription", "resultsubject", "eoscifguidelines", "resultpublisher", "resultbestaccessright", "community", "collectedfromdatasourceid", "resulthostingdatasourceid", "resultdateofacceptance", "relfunder", "relfundinglevel0_id", "relfundinglevel1_id", "relfundinglevel2_id", @@ -56,6 +57,14 @@ export class SearchFields { equalityOperator: "=", filterType: null }, + ["eoscifguidelines"]: { + name: "EOSC Subject", + type: "keyword", + param: "eoscSubj", + operator: "es", + equalityOperator: " exact ", + filterType: null + }, ["resultdescription"]: { name: "Abstract", type: "keyword", @@ -690,6 +699,16 @@ export class SearchFields { constructor() { } + + getResultAdvancedFields() { + if(properties.environment == "production") { + this.RESULT_ADVANCED_FIELDS = this.RESULT_ADVANCED_FIELDS.filter((value, index, array) => { + return value != "eoscifguidelines"; + }) + } + return this.RESULT_ADVANCED_FIELDS; + } + getField(fieldId: string, fieldType: string): any { if (fieldType == "publication" || fieldType == "dataset" || fieldType == "software" || fieldType == "other" || fieldType == "result") { return this.RESULT_FIELDS[fieldId];