Merge remote-tracking branch 'origin/develop' into angular-16

This commit is contained in:
Konstantinos Triantafyllou 2023-08-21 11:13:57 +03:00
commit f34a501046
4 changed files with 123 additions and 155 deletions

View File

@ -104,8 +104,8 @@ export class MyOrcidLinksComponent {
private errorCodes: ErrorCodes; private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent; private errorMessages: ErrorMessagesComponent;
public results =[]; public results:Map<number,{"work":{},results:ResultPreview[]}[]> = new Map();
public currentResults = []; public currentResults:{"work":{},results:ResultPreview[]}[] = [];
public totalResults:number = 0 ; public totalResults:number = 0 ;
public baseUrl:string; public baseUrl:string;
public searchUtils:SearchUtilsClass = new SearchUtilsClass(); public searchUtils:SearchUtilsClass = new SearchUtilsClass();
@ -163,7 +163,7 @@ export class MyOrcidLinksComponent {
if(typeof document !== 'undefined') { if(typeof document !== 'undefined') {
this.tokenUrl = properties.orcidTokenURL this.tokenUrl = properties.orcidTokenURL
+ "client_id="+properties.orcidClientId + "clientid="+properties.orcidClientId
// + "&response_type=code&scope=/activities/update" // + "&response_type=code&scope=/activities/update"
// + "&response_type=code&scope=/authenticate /activities/update /person/update /read-limited" // + "&response_type=code&scope=/authenticate /activities/update /person/update /read-limited"
+ "&response_type=code&scope=/activities/update /read-limited" + "&response_type=code&scope=/activities/update /read-limited"
@ -253,6 +253,18 @@ export class MyOrcidLinksComponent {
(response: any[]) => { (response: any[]) => {
this.works = response;//['results']; 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.totalOrcidResults = this.works.length;//response['total'];
this.prepareOrcidQuery(); this.prepareOrcidQuery();
@ -266,7 +278,7 @@ export class MyOrcidLinksComponent {
public prepareOrcidQuery() { public prepareOrcidQuery() {
if(this.results.length >= this.currentPage) { if(Array.from(this.results.keys()).length >= this.currentPage) {
this.currentResults = this.results[this.currentPage-1]; this.currentResults = this.results[this.currentPage-1];
return; return;
} }
@ -302,11 +314,7 @@ export class MyOrcidLinksComponent {
this.disableForms = true; this.disableForms = true;
this.currentResults = []; this.currentResults = [];
this.searchUtils.totalResults = 0; 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.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( .subscribe(
data => { data => {
let totalResults = data[0]; let totalResults = data[0];
@ -330,28 +338,29 @@ export class MyOrcidLinksComponent {
let resultsFound: Map<string[], number> = new Map<string[], number>(); let resultsFound: Map<string[], number> = new Map<string[], number>();
for(let work of works) { for(let work of works) {
let relatedResults = [];
this.currentResults.push({"work": work, "results" : relatedResults})
results.forEach(result => { results.forEach(result => {
let identifierValues: string[] = [].concat(...Array.from(result.identifiers.values())); let identifierValues: string[] = [].concat(...Array.from(result.identifiers.values()));
if(work['pids'].some(pid => identifierValues.includes(pid))) { if(work['pids'].some(pid => identifierValues.includes(pid))) {
let index: number = resultsFound.get(identifierValues); let index: number = resultsFound.get(identifierValues);
if(!index) { if(!index) {
this.currentResults.push(this.getResultPreview(result)); relatedResults.push(this.getResultPreview(result));
index = this.currentResults.length - 1; index = relatedResults.length - 1;
relatedResults[index].orcidPutCodes = [];
this.currentResults[index].orcidPutCodes = []; relatedResults[index].orcidCreationDates = [];
this.currentResults[index].orcidCreationDates = []; relatedResults[index].orcidUpdateDates = [];
this.currentResults[index].orcidUpdateDates = [];
} }
if (work['putCode']) { if (work['putCode']) {
this.currentResults[index].orcidPutCodes.push(work['putCode']); relatedResults[index].orcidPutCodes.push(work['putCode']);
} }
if (work['creationDate']) { if (work['creationDate']) {
this.currentResults[index].orcidCreationDates.push(work['creationDate']); relatedResults[index].orcidCreationDates.push(work['creationDate']);
} }
if (work['updateDate']) { 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; 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 { public getResultPreview(result: SearchResult): ResultPreview {
return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.resultType); return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.resultType);
} }

View File

@ -1,5 +1,5 @@
<div class="uk-margin-medium-top uk-margin"> <div class="uk-margin-medium-top uk-margin">
<no-load-paging *ngIf="totalResults > 0 && previewResults && previewResults.length > 0" [type]="openaireEntities.RESULTS" <no-load-paging *ngIf="totalResults > 0 && previewResults && previewResults.length > 0" type="Orcid links"
(pageChange)="pageChanged($event)" (pageChange)="pageChanged($event)"
[page]="currentPage" [pageSize]="resultsPerPage" [page]="currentPage" [pageSize]="resultsPerPage"
[totalResults]="totalResults"> [totalResults]="totalResults">
@ -7,23 +7,57 @@
<ul class="uk-list search-results uk-margin-medium-top"> <ul class="uk-list search-results uk-margin-medium-top">
<errorMessages [status]="[status]" [type]="'results'"></errorMessages> <errorMessages [status]="[status]" [type]="'results'"></errorMessages>
<li *ngFor="let result of previewResults"> <li *ngFor="let resultGroup of previewResults">
<div class="uk-card uk-card-default uk-padding"> <div class="uk-card uk-card-default uk-padding">
<div class="uk-grid uk-grid-divider"> <div class="uk-grid uk-grid-divider">
<div class="uk-width-expand@m uk-width-1-1 uk-first-column"> <div class="uk-width-expand@m uk-width-1-1 uk-first-column">
<div *ngIf="resultGroup['results'].length > 1" class="uk-alert uk-alert-warning uk-text-small">{{resultGroup['results'].length}} results found in OpenAIRE
for PIDs "{{resultGroup['work']['pids'].join("\", \"")}}"
<div>You can update your ORCID work with the most preferred result.</div>
</div>
<div *ngIf="resultGroup['results'].length == 0" class="uk-alert uk-alert-warning uk-text-small"> No results found in OpenAIRE
for PIDs "{{resultGroup['work']['pids'].join("\", \"")}}"
<div>You can remove the entry from your ORCID profile as well.</div>
</div>
<div *ngFor="let result of resultGroup['results']">
<div class = "uk-position-relative">
<div class = "uk-width-1-1">
<result-preview [properties]="properties" [showOrcid]="false" [showOrganizations]="true" <result-preview [properties]="properties" [showOrcid]="false" [showOrganizations]="true"
[showSubjects]="true" [result]="result" [promoteWebsiteURL]="true" [showSubjects]="true" [result]="result" [promoteWebsiteURL]="true"
[isCard]="false"> [isCard]="false">
</result-preview> </result-preview>
</div> </div>
<div class = "uk-position-right uk-margin-large-top">
<div class="uk-width-auto@m uk-width-1-1"> <orcid-work *ngIf="resultGroup['results'].length > 1" [resultId]="result.relcanId"
<div class="uk-height-1-1 uk-padding-small uk-flex uk-flex-center uk-flex-column uk-flex-middle"> [resultTitle]="result.title"
<orcid-work [resultId]="result.relcanId" [resultTitle]="result.title"
[type]="result.resultType" [pageType]="'my_search'" [type]="result.resultType" [pageType]="'my_search'"
[putCodes]="result.orcidPutCodes" [givenPutCode]="true" [putCodes]="result.orcidPutCodes" [givenPutCode]="true"
[identifiers]="result.identifiers" [identifiers]="result.identifiers"
[creationDates]="result.orcidCreationDates" [updateDates]="result.orcidUpdateDates"> [creationDates]="result.orcidCreationDates" [updateDates]="result.orcidUpdateDates"
[showOnlyUpdateButton]="true"
>
</orcid-work>
</div>
</div>
</div>
</div>
<div class="uk-width-auto@m uk-width-1-1">
<div class="uk-height-1-1 uk-padding-small uk-flex uk-flex-center uk-flex-column uk-flex-middle">
<orcid-work *ngIf="resultGroup['results'][0]" [resultId]="resultGroup['results'][0].relcanId" [resultTitle]="resultGroup['results'][0].title"
[type]="resultGroup['results'][0].resultType" [pageType]="'my_search'"
[putCodes]="resultGroup['results'][0].orcidPutCodes" [givenPutCode]="true"
[identifiers]="resultGroup['results'][0].identifiers"
[creationDates]="resultGroup['results'][0].orcidCreationDates" [updateDates]="resultGroup['results'][0].orcidUpdateDates"
[showUpdateButton]="resultGroup['results'].length == 1"
>
</orcid-work>
<orcid-work *ngIf="resultGroup['results'].length ==0" [pageType]="'my_search'"
[putCodes]="[resultGroup.work['putCode']]" [givenPutCode]="true"
[identifiers]="resultGroup.work['pids']"
[creationDates]="[resultGroup.work['creationDate']]" [updateDates]="resultGroup.work['updateDates']"
[showUpdateButton]="false"
>
</orcid-work> </orcid-work>
</div> </div>
</div> </div>

View File

@ -24,7 +24,7 @@ export class searcMyOrcidResultsComponent {
@Input() properties:EnvProperties; @Input() properties:EnvProperties;
public openaireEntities = OpenaireEntities; public openaireEntities = OpenaireEntities;
@Input() previewResults:ResultPreview[]; @Input() previewResults:{"work":{},results:ResultPreview[]}[];
public urlParam: string; public urlParam: string;
public linkToAdvancedSearchPage: 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 { public quote(params: string):string {
return '"'+params+'"'; return '"'+params+'"';
@ -75,45 +70,6 @@ export class searcMyOrcidResultsComponent {
return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.type); 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) { public pageChanged($event) {
this.pageChange.emit($event); this.pageChange.emit($event);
HelperFunctions.scroll(); HelperFunctions.scroll();

View File

@ -114,6 +114,7 @@ declare var UIkit: any;
<ng-container *ngIf="pageType == 'my_search'"> <ng-container *ngIf="pageType == 'my_search'">
<ng-container *ngIf="!showOnlyUpdateButton">
<span class="uk-margin-bottom uk-flex uk-flex-middle uk-flex-center"> <span class="uk-margin-bottom uk-flex uk-flex-middle uk-flex-center">
<span>ORCID&#160;</span> <span>ORCID&#160;</span>
<img src="assets/common-assets/common/ORCIDiD_icon16x16.png" alt="" loading="lazy"> <img src="assets/common-assets/common/ORCIDiD_icon16x16.png" alt="" loading="lazy">
@ -132,7 +133,8 @@ declare var UIkit: any;
<span class="uk-margin-small-left">View ORCID work</span> <span class="uk-margin-small-left">View ORCID work</span>
</a> </a>
</span> </span>
</ng-container>
<ng-container *ngIf="showUpdateButton">
<span [attr.uk-tooltip]="(!putCodes || putCodes.length == 0) <span [attr.uk-tooltip]="(!putCodes || putCodes.length == 0)
? 'This work is currently deleted.' ? 'This work is currently deleted.'
: ('Update this work to your ORCID record' + ((properties.environment == 'beta') ? '. The action will affect your real ORCID iD.' : '') : ('Update this work to your ORCID record' + ((properties.environment == 'beta') ? '. The action will affect your real ORCID iD.' : '')
@ -145,7 +147,8 @@ declare var UIkit: any;
<span class="uk-margin-small-left">Update ORCID work</span> <span class="uk-margin-small-left">Update ORCID work</span>
</a> </a>
</span> </span>
</ng-container>
<ng-container *ngIf="!showOnlyUpdateButton">
<span *ngIf="!putCodes || putCodes.length == 0" <span *ngIf="!putCodes || putCodes.length == 0"
[attr.uk-tooltip]="tooltipAdd"> [attr.uk-tooltip]="tooltipAdd">
<a (click)="currentAction='add'; saveWorkPreparation();" <a (click)="currentAction='add'; saveWorkPreparation();"
@ -168,6 +171,7 @@ declare var UIkit: any;
</a> </a>
</span> </span>
</ng-container> </ng-container>
</ng-container>
<modal-alert #workModal large="true"> <modal-alert #workModal large="true">
<div *ngIf="orcidWorks"> <div *ngIf="orcidWorks">
@ -337,6 +341,9 @@ export class OrcidWorkComponent {
@Input() givenPutCode: boolean = false; @Input() givenPutCode: boolean = false;
@Input() pageType: string = "search"; @Input() pageType: string = "search";
//for myorcid links page
@Input() showOnlyUpdateButton: boolean = false;
@Input() showUpdateButton: boolean = true;
public subscriptions: Subscription[] = []; public subscriptions: Subscription[] = [];
@ViewChild('workModal') workModal; @ViewChild('workModal') workModal;
// @ViewChild('saveWorkModal') saveWorkModal; // @ViewChild('saveWorkModal') saveWorkModal;