From a53c4e90d099d0bf3919df55edceaf7f793427d0 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Fri, 28 Jul 2023 16:04:14 +0300 Subject: [PATCH 01/14] [Library | develop]: resultLanding.component.ts: Added ContextsService and call to get public communities, and then filter out contexts (related to communities) of resultLandingInfo if they are hidden. --- .../result/resultLanding.component.ts | 66 ++++++++++++++----- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/landingPages/result/resultLanding.component.ts b/landingPages/result/resultLanding.component.ts index 0aa95a05..dcd9399c 100644 --- a/landingPages/result/resultLanding.component.ts +++ b/landingPages/result/resultLanding.component.ts @@ -28,6 +28,7 @@ import {NumberUtils} from '../../utils/number-utils.class'; import {FullScreenModalComponent} from "../../utils/modal/full-screen-modal/full-screen-modal.component"; import {SdgFosSuggestComponent} from '../landing-utils/sdg-fos-suggest/sdg-fos-suggest.component'; import {LayoutService} from "../../dashboard/sharedComponents/sidebar/layout.service"; +import {ContextsService} from "../../claims/claim-utils/service/contexts.service"; declare var ResizeObserver; @@ -174,6 +175,8 @@ export class ResultLandingComponent { @ViewChild('fosFsModal') fosFsModal: FullScreenModalComponent; public noCommunities: boolean = false; + private promise: Promise = null; + private publicCommunities: string[] = []; public rightSidebarOffcanvasClicked: boolean = false; public egiTransferModalOpen = false; @@ -192,7 +195,8 @@ export class ResultLandingComponent { private _location: Location, private indexInfoService: IndexInfoService, private userManagementService: UserManagementService, - private layoutService: LayoutService) { + private layoutService: LayoutService, + private _contextService: ContextsService) { } ngOnInit() { @@ -256,6 +260,7 @@ export class ResultLandingComponent { this.type="publication"; } if ((this.id && StringUtils.isOpenAIREID(this.id)) || (this.identifier)) { + this.getPublicCommunities(); this.getVocabulariesAndResultLandingInfo(); } else { this.showLoading = false; @@ -496,29 +501,32 @@ export class ResultLandingComponent { this.resultLandingInfo = null; this.hasAltMetrics = false; this.subscriptions.push(this._resultLandingService.getResultLandingInfo(this.id, this.identifier, this.type, subjectsVocabulary, this.properties).subscribe( - data => { + async data => { + let contexts = data.contexts; + data.contexts = []; + this.resultLandingInfo = data; this.id = this.resultLandingInfo.objIdentifier; //old // this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; // this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; //new - this.viewsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"column","query":{"name":"usagestats.results.views.monthly", "parameters":["' + this.id + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly views"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}'); - this.downloadsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + + this.viewsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"column","query":{"name":"usagestats.results.views.monthly", "parameters":["' + this.id + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly views"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}'); + this.downloadsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly downloads","type":"column","query":{"name":"usagestats.results.downloads.monthly", "parameters":["' + this.id + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly downloads"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}'); - this.bipFrameUrl = this.properties.bipFrameAPIURL + this.id + (properties.environment == "beta" ? "&src=beta" : ""); - let pid:Identifier = Identifier.getPIDFromIdentifiers(this.resultLandingInfo.identifiers); + this.bipFrameUrl = this.properties.bipFrameAPIURL + this.id + (properties.environment == "beta" ? "&src=beta" : ""); + let pid: Identifier = Identifier.getPIDFromIdentifiers(this.resultLandingInfo.identifiers); if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType this.updateUrlWithType(pid); } - this.canonicalUrl = this.properties.domain+ properties.baseLink + ( pid ? (this.linkToLandingPage.split("?")[0] + "?pid=" + encodeURIComponent(pid.id)): + this.canonicalUrl = this.properties.domain + properties.baseLink + (pid ? (this.linkToLandingPage.split("?")[0] + "?pid=" + encodeURIComponent(pid.id)) : (this.linkToLandingPage + this.resultLandingInfo.relcanId)); this.seoService.createLinkForCanonicalURL(this.canonicalUrl); this.updateUrl(this.canonicalUrl); this.addNoIndexFilter(); if (this.resultLandingInfo.title) { this.updateTitle(this.resultLandingInfo.title); - this.updateDescription((this.resultLandingInfo.description ? (this.resultLandingInfo.description.substr(0,157) + (this.resultLandingInfo.description.substr(0,157).length == 157?"...":"")) : (this.resultLandingInfo.title))); + this.updateDescription((this.resultLandingInfo.description ? (this.resultLandingInfo.description.substr(0, 157) + (this.resultLandingInfo.description.substr(0, 157).length == 157 ? "..." : "")) : (this.resultLandingInfo.title))); } this.subscriptions.push(this._piwikService.trackViewForCustomUrl(this.properties, this.resultLandingInfo.title, this.linkToLandingPage.split("?")[1] + this.id).subscribe()); let bioentitiesNum = 0; @@ -529,9 +537,9 @@ export class ResultLandingComponent { } this.bioentitiesNum = bioentitiesNum; if (typeof document !== 'undefined') { - if(this.resultLandingInfo.identifiers) { + if (this.resultLandingInfo.identifiers) { let pidsArray: string[] = []; - for(let key of Array.from(this.resultLandingInfo.identifiers.keys())) { + for (let key of Array.from(this.resultLandingInfo.identifiers.keys())) { pidsArray = pidsArray.concat(this.resultLandingInfo.identifiers.get(key)); this.pidsArrayString = pidsArray.join(); } @@ -545,14 +553,17 @@ export class ResultLandingComponent { } } } - if(this.communityId && this.communityId == "enermaps" && properties.enermapsURL){ + if (this.communityId && this.communityId == "enermaps" && properties.enermapsURL) { this.enermapsId = ParsingFunctions.getEnermapsConceptId(this.resultLandingInfo.contexts); } this.relatedClassFilters = [{"label": "All relations", "value": ""}]; - if(this.resultLandingInfo.relatedClassFilters.size > 1) { + if (this.resultLandingInfo.relatedClassFilters.size > 1) { for (let relClass of this.resultLandingInfo.relatedClassFilters) { - this.relatedClassFilters.push({"label": HelperFunctions.getVocabularyLabel(relClass, this.relationsVocabulary), "value": relClass}); + this.relatedClassFilters.push({ + "label": HelperFunctions.getVocabularyLabel(relClass, this.relationsVocabulary), + "value": relClass + }); } } else { this.relatedClassFilters.pop(); @@ -562,12 +573,12 @@ export class ResultLandingComponent { this.hasViews = false; this.hasDownloads = false; - if(this.resultLandingInfo.measure && this.resultLandingInfo.measure.counts) { + if (this.resultLandingInfo.measure && this.resultLandingInfo.measure.counts) { this.resultLandingInfo.measure.counts.forEach(measure => { - if(measure.name == "views" && measure.value > 0) { + if (measure.name == "views" && measure.value > 0) { this.hasViews = true; } - if(measure.name == "downloads" && measure.value > 0) { + if (measure.name == "downloads" && measure.value > 0) { this.hasDownloads = true; } }) @@ -577,6 +588,14 @@ export class ResultLandingComponent { this.setActiveTab(); this.cdr.detectChanges(); + + if (contexts) { + await this.promise; + if(this.publicCommunities && this.publicCommunities.length > 0) { + this.resultLandingInfo.contexts = contexts.filter(context => this.publicCommunities.includes(context.idContext)); + this.cdr.detectChanges(); + } + } }, err => { this.handleError("Error getting " + this.type + " for " + (this.id ? ("id: " + this.id) : ("pid: " + this.identifier.id + " ("+this.identifier.class+")")), err); @@ -593,6 +612,21 @@ export class ResultLandingComponent { )); } + public getPublicCommunities() { + this.promise = new Promise(resolve => { + this._contextService.getPublicCommunitiesByState().subscribe( + data => { + this.publicCommunities = data.map(value => value.id); + // this.publicCommunities = data; + resolve(); + }, + error => { + this.handleError("Error getting communities status", error); + resolve(); + }); + }); + } + public metricsResults($event) { this.totalViews = $event.totalViews; this.totalDownloads = $event.totalDownloads; From 038adf352a3f5aefcb1efcccebf5731819618925 Mon Sep 17 00:00:00 2001 From: argirok Date: Wed, 9 Aug 2023 11:52:30 +0300 Subject: [PATCH 02/14] change the way my orcid links are shown. Group together multiple results from the index, add update button to each one of them --- .../my-orcid-links/myOrcidLinks.component.ts | 81 +++++----------- .../searchMyOrcidResults.component.html | 56 ++++++++--- .../searchMyOrcidResults.component.ts | 46 +-------- orcid/orcid-work.component.ts | 95 ++++++++++--------- 4 files changed, 123 insertions(+), 155 deletions(-) diff --git a/orcid/my-orcid-links/myOrcidLinks.component.ts b/orcid/my-orcid-links/myOrcidLinks.component.ts index 09402cb8..d846f2e1 100644 --- a/orcid/my-orcid-links/myOrcidLinks.component.ts +++ b/orcid/my-orcid-links/myOrcidLinks.component.ts @@ -104,8 +104,8 @@ export class MyOrcidLinksComponent { private errorCodes: ErrorCodes; private errorMessages: ErrorMessagesComponent; - public results =[]; - public currentResults = []; + public results:Map = new Map(); + public currentResults:{"work":{},results:ResultPreview[]}[] = []; public totalResults:number = 0 ; public baseUrl:string; public searchUtils:SearchUtilsClass = new SearchUtilsClass(); @@ -163,7 +163,7 @@ export class MyOrcidLinksComponent { if(typeof document !== 'undefined') { this.tokenUrl = properties.orcidTokenURL - + "client_id="+properties.orcidClientId + + "clientid="+properties.orcidClientId // + "&response_type=code&scope=/activities/update" // + "&response_type=code&scope=/authenticate /activities/update /person/update /read-limited" + "&response_type=code&scope=/activities/update /read-limited" @@ -253,6 +253,18 @@ export class MyOrcidLinksComponent { (response: any[]) => { this.works = response;//['results']; + this.works=[ + { "id" : "60391ad16c2043536ca44ea4", "pids" : [ "10.5281/zeno(do.4304132", "10.5281/zenodo.3974605" ], "putCode" : "89558576", "orcid" : "0000-0002-3880-0244", "creationDate" : "2021-02-26T15:59:13.098Z", "updateDate" : "2021-02-26T15:59:13.098Z", "dashboard" : "production_explore" }, + { "id" : "60391ceb7a767127ea9a4d06", "pids" : [ "10.5281/zenodo.4095044", "10.5281/zenodo.4095043" ], "putCode" : "89559422", "orcid" : "0000-0002-3880-0244", "creationDate" : "2021-02-26T16:08:11.930Z", "updateDate" : "2021-02-26T16:27:12.835Z", "dashboard" : "production_explore" }, + { "id" : "604244fb7a767127ea9a4d0b", "pids" : [ "10.5281/zenodo.3467103", "10.5281/zenodo.3467104", "10.1007/978-3-030-30760-8_5", "1822/62856" ], "putCode" : "90020579", "orcid" : "0000-0002-3880-0244", "creationDate" : "2021-03-05T14:49:31.972Z", "updateDate" : "2022-06-20T08:28:08.539Z", "dashboard" : "production_explore" }, + { "id" : "60744bb46c20432760765b9f", "pids" : [ "10.5281/zenodo.3701379", "10.5281/zenodo.3701380" ], "putCode" : "92074390", "orcid" : "0000-0002-3880-0244", "creationDate" : "2021-04-12T13:31:32.476Z", "updateDate" : "2021-04-12T13:31:32.476Z", "dashboard" : "production_explore" }, + { "id" : "6077f0047a767112e847f9f8", "pids" : [ "10.5281/zenodo.4559726" ], "putCode" : "92235922", "orcid" : "0000-0002-3880-0244", "creationDate" : "2021-04-15T07:49:24.078Z", "updateDate" : "2021-04-21T09:43:40.147Z", "dashboard" : "production_explore" }, + { "id" : "6079752b7a767112e847fa5b", "pids" : [ "10.5281/zenodo.4304047", "10.5281/zenodo.3980491" ], "putCode" : "92304809", "orcid" : "0000-0002-3880-0244", "creationDate" : "2021-04-16T11:29:47.905Z", "updateDate" : "2021-04-16T11:29:47.905Z", "dashboard" : "production_explore" }, + { "id" : "63186abb7a767129935f495b", "pids" : [ "10.5281/zenodo.1314672", "10.5281/zenodo.1412509", "10.5281/zenodo.1314671" ], "putCode" : "118582128", "orcid" : "0000-0002-3880-0244", "creationDate" : "2022-09-07T09:56:11.556Z", "updateDate" : "2022-09-07T09:56:11.556Z", "dashboard" : "production_explore" }, + { "id" : "63186ade6c204337f56d97ca", "pids" : [ "10.5281/zenodo.6634431", "10.5281/zenodo.6385204", "10.5281/zenodo.4559725" ], "putCode" : "118582151", "orcid" : "0000-0002-3880-0244", "creationDate" : "2022-09-07T09:56:46.231Z", "updateDate" : "2022-09-07T09:56:46.231Z", "dashboard" : "production_explore" }, + { "id" : "63186ae27a767129935f495c", "pids" : [ "10.5281/zenodo.5801283", "10.5281/zenodo.3516917", "10.5281/zenodo.6616871" ], "putCode" : "118582162", "orcid" : "0000-0002-3880-0244", "creationDate" : "2022-09-07T09:56:50.660Z", "updateDate" : "2022-09-07T09:56:50.660Z", "dashboard" : "production_explore" } + ]; + this.totalOrcidResults = this.works.length;//response['total']; this.prepareOrcidQuery(); @@ -266,7 +278,7 @@ export class MyOrcidLinksComponent { public prepareOrcidQuery() { - if(this.results.length >= this.currentPage) { + if(Array.from(this.results.keys()).length >= this.currentPage) { this.currentResults = this.results[this.currentPage-1]; return; } @@ -302,11 +314,7 @@ export class MyOrcidLinksComponent { this.disableForms = true; this.currentResults = []; this.searchUtils.totalResults = 0; - - // let params: string = this.orcidQuery + this.typeQuery; - //this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery) this.subscriptions.push(this._searchResearchResultsService.searchForMyOrcidLinks(this.resultType, this.orcidQuery, this.typeQuery, 1, 50) - //this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, null, this.searchPage.getFields(), refineFieldsFilterQuery) .subscribe( data => { let totalResults = data[0]; @@ -330,28 +338,29 @@ export class MyOrcidLinksComponent { let resultsFound: Map = new Map(); for(let work of works) { + let relatedResults = []; + this.currentResults.push({"work": work, "results" : relatedResults}) results.forEach(result => { let identifierValues: string[] = [].concat(...Array.from(result.identifiers.values())); if(work['pids'].some(pid => identifierValues.includes(pid))) { let index: number = resultsFound.get(identifierValues); if(!index) { - this.currentResults.push(this.getResultPreview(result)); - index = this.currentResults.length - 1; - - this.currentResults[index].orcidPutCodes = []; - this.currentResults[index].orcidCreationDates = []; - this.currentResults[index].orcidUpdateDates = []; + relatedResults.push(this.getResultPreview(result)); + index = relatedResults.length - 1; + relatedResults[index].orcidPutCodes = []; + relatedResults[index].orcidCreationDates = []; + relatedResults[index].orcidUpdateDates = []; } if (work['putCode']) { - this.currentResults[index].orcidPutCodes.push(work['putCode']); + relatedResults[index].orcidPutCodes.push(work['putCode']); } if (work['creationDate']) { - this.currentResults[index].orcidCreationDates.push(work['creationDate']); + relatedResults[index].orcidCreationDates.push(work['creationDate']); } if (work['updateDate']) { - this.currentResults[index].orcidUpdateDates.push(work['updateDate']); + relatedResults[index].orcidUpdateDates.push(work['updateDate']); } } }) @@ -367,44 +376,6 @@ export class MyOrcidLinksComponent { this.disableForms = false; } - public resultsReturned2(results: any, totalResults, works: any[]) { - this.searchUtils.totalResults = totalResults; - - for(let result of results) { - let identifierValues: string[] = [].concat(...Array.from(result.identifiers.values())); - - this.currentResults.push(this.getResultPreview(result)); - - let filteredWorks = works.filter(work => { - return work['pids'].some(pid => identifierValues.includes(pid)); - }) - - this.currentResults[this.currentResults.length - 1].orcidPutCodes = []; - this.currentResults[this.currentResults.length - 1].orcidCreationDates = []; - this.currentResults[this.currentResults.length - 1].orcidUpdateDates = []; - - filteredWorks.forEach(work => { - if(work['putCode']) { - this.currentResults[this.currentResults.length - 1].orcidPutCodes.push(work['putCode']); - } - if(work['creationDate']) { - this.currentResults[this.currentResults.length - 1].orcidCreationDates.push(work['creationDate']); - } - if(work['updateDate']) { - this.currentResults[this.currentResults.length - 1].orcidUpdateDates.push(work['updateDate']); - } - }); - } - - this.results[this.currentPage-1] = this.currentResults; - this.searchUtils.status = this.errorCodes.DONE; - if (this.searchUtils.totalResults == 0) { - this.searchUtils.status = this.errorCodes.NONE; - } - - this.disableForms = false; - } - public getResultPreview(result: SearchResult): ResultPreview { return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.resultType); } diff --git a/orcid/my-orcid-links/searchMyOrcidResults.component.html b/orcid/my-orcid-links/searchMyOrcidResults.component.html index 2eaa8986..4cbd7292 100644 --- a/orcid/my-orcid-links/searchMyOrcidResults.component.html +++ b/orcid/my-orcid-links/searchMyOrcidResults.component.html @@ -1,5 +1,5 @@
- @@ -7,23 +7,57 @@