diff --git a/orcid/my-orcid-links/myOrcidLinks.component.ts b/orcid/my-orcid-links/myOrcidLinks.component.ts index 09402cb8..d77e14a4 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 @@
    -
  • +
  • - - +
    {{resultGroup['results'].length}} results found in OpenAIRE + for PIDs "{{resultGroup['work']['pids'].join("\", \"")}}" +
    You can update your ORCID work with the most preferred result.
    +
    +
    No results found in OpenAIRE + for PIDs "{{resultGroup['work']['pids'].join("\", \"")}}" +
    You can remove the entry from your ORCID profile as well.
    +
    +
    +
    +
    + + +
    +
    + + +
    +
    +
    - + + +
    diff --git a/orcid/my-orcid-links/searchMyOrcidResults.component.ts b/orcid/my-orcid-links/searchMyOrcidResults.component.ts index 4034e75a..03847ba3 100644 --- a/orcid/my-orcid-links/searchMyOrcidResults.component.ts +++ b/orcid/my-orcid-links/searchMyOrcidResults.component.ts @@ -24,7 +24,7 @@ export class searcMyOrcidResultsComponent { @Input() properties:EnvProperties; public openaireEntities = OpenaireEntities; - @Input() previewResults:ResultPreview[]; + @Input() previewResults:{"work":{},results:ResultPreview[]}[]; public urlParam: string; public linkToAdvancedSearchPage: string; @@ -62,11 +62,6 @@ export class searcMyOrcidResultsComponent { } - // ngOnChanges(changes: SimpleChanges): void { - // if (changes.results) { - // this.initialize(); - // } - // } public quote(params: string):string { return '"'+params+'"'; @@ -75,45 +70,6 @@ export class searcMyOrcidResultsComponent { return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.type); } - initialize() { - this.previewResults = []; - for (let result of this.results) { - this.previewResults.push(this.getResultPreview(result)); - } - - if (Session.isLoggedIn() && this.results && this.results.length > 0) { - this.orcidService.getLocalWorksByPids(this.previewResults.map( - previewResult => { - if (previewResult.identifiers) { - let pidsArray: string[] = []; - for (let key of Array.from(previewResult.identifiers.keys())) { - pidsArray = pidsArray.concat(previewResult.identifiers.get(key)); - } - return pidsArray;//.join(); - } - })).subscribe( - works => { - for (let i = 0; i < this.previewResults.length; i++) { - if (this.previewResults[i].identifiers) { - this.previewResults[i].orcidPutCodes = []; - this.previewResults[i].orcidUpdateDates = []; - - works[i].forEach(work => { - this.previewResults[i].orcidPutCodes.push(work['putCode']); - this.previewResults[i].orcidUpdateDates.push(work['creationDate']); - }); - // this.previewResults[i].orcidPutCodes = works[i].map(work => work['putCode']); - // this.previewResults[i].orcidUpdateDates = works[i] - // console.debug(i, this.previewResults[i].orcidPutCodes); - } - } - }, error => { - - } - ); - } - } - public pageChanged($event) { this.pageChange.emit($event); HelperFunctions.scroll(); diff --git a/orcid/orcid-work.component.ts b/orcid/orcid-work.component.ts index b0cba866..c7cd5b74 100644 --- a/orcid/orcid-work.component.ts +++ b/orcid/orcid-work.component.ts @@ -114,50 +114,53 @@ declare var UIkit: any; - - ORCID  - -  ACTIONS - + + + ORCID  + +  ACTIONS + + + + + + + + View ORCID work + + + + + + + + + Update ORCID work + + + + + + + + + Claim + + - - - - - - View ORCID work - - - - - - - - Update ORCID work - - - - - - - - Claim - - - - @@ -167,6 +170,7 @@ declare var UIkit: any; Remove + @@ -336,7 +340,10 @@ export class OrcidWorkComponent { @Input() updateDates: string[] = []; @Input() givenPutCode: boolean = false; @Input() pageType: string = "search"; - + + //for myorcid links page + @Input() showOnlyUpdateButton: boolean = false; + @Input() showUpdateButton: boolean = true; public subscriptions: Subscription[] = []; @ViewChild('workModal') workModal; // @ViewChild('saveWorkModal') saveWorkModal;