Revision 60394
Added by Konstantina Galouni over 3 years ago
modules/uoa-services-library/trunk/ng-openaire-library/src/app/orcid/my-orcid-links/myOrcidLinks.module.ts | ||
---|---|---|
1 |
import {NgModule} from '@angular/core'; |
|
2 |
import {CommonModule} from '@angular/common'; |
|
3 |
import {FormsModule} from '@angular/forms'; |
|
4 |
import {RouterModule} from '@angular/router'; |
|
5 |
|
|
6 |
import {ResultPreviewModule} from "../../utils/result-preview/result-preview.module"; |
|
7 |
import {ErrorMessagesModule} from "../../utils/errorMessages.module"; |
|
8 |
import {MyOrcidLinksComponent} from "./myOrcidLinks.component"; |
|
9 |
import {SearchResearchResultsServiceModule} from "../../services/searchResearchResultsService.module"; |
|
10 |
import {SearchMyOrcidResultsModule} from "./searchMyOrcidResults.module"; |
|
11 |
import {AlertModalModule} from "../../utils/modal/alertModal.module"; |
|
12 |
|
|
13 |
@NgModule({ |
|
14 |
imports: [ |
|
15 |
CommonModule, FormsModule, |
|
16 |
RouterModule, ErrorMessagesModule, |
|
17 |
ResultPreviewModule, SearchResearchResultsServiceModule, SearchMyOrcidResultsModule, |
|
18 |
AlertModalModule |
|
19 |
], |
|
20 |
declarations: [ |
|
21 |
MyOrcidLinksComponent |
|
22 |
], |
|
23 |
providers:[ |
|
24 |
], |
|
25 |
exports: [ |
|
26 |
MyOrcidLinksComponent |
|
27 |
] |
|
28 |
}) |
|
29 |
export class MyOrcidLinksModule { } |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/orcid/my-orcid-links/searchMyOrcidResults.component.html | ||
---|---|---|
1 |
<!--<div *ngIf="status == errorCodes.NONE" class="uk-text-center uk-margin-large-top uk-width-3-5">--> |
|
2 |
<!-- <p class="uk-text-large uk-text-muted uk-margin">There are no repositories for your preferences</p>--> |
|
3 |
|
|
4 |
<!-- <p class="uk-text-large uk-text-muted">We suggest to deposit your research in</p>--> |
|
5 |
<!-- <!– <a href="{{zenodoInformation.url}}" target="_blank" class="custom-external custom-icon">{{zenodoInformation.name}}</a>–>--> |
|
6 |
<!-- <svg xmlns="http://www.w3.org/2000/svg" width="173" height="56.685" viewBox="0 0 173 56.685"><defs><style>.a{fill:#191919;}</style></defs><path class="a" d="M171.749,22.311a16.158,16.158,0,0,0-3.364-4.953A15.511,15.511,0,0,0,157.4,12.837a15.213,15.213,0,0,0-6.074,1.206,16.4,16.4,0,0,0-2.63,1.424,16.2,16.2,0,0,0-2.325,1.891,14.893,14.893,0,0,0-1.242,1.383,19.241,19.241,0,0,0-1.173,1.7,19.372,19.372,0,0,0-1.482,3.343c.048-1.943.332-4.842,1.482-6.468V3.272a3.081,3.081,0,0,0-.993-2.323,3.251,3.251,0,0,0-5.556,2.323V15.765a17.084,17.084,0,0,0-4.261-2.156,14.8,14.8,0,0,0-4.781-.773,15.314,15.314,0,0,0-6.028,1.206,15.575,15.575,0,0,0-4.959,3.316,16.056,16.056,0,0,0-3.352,4.953c-.063.142-.118.286-.177.43-.056-.144-.111-.288-.173-.43a16.158,16.158,0,0,0-3.364-4.953,15.519,15.519,0,0,0-4.95-3.316,15.795,15.795,0,0,0-12.105,0,16.068,16.068,0,0,0-4.954,3.316,15.182,15.182,0,0,0-3.359,4.953c-.058.136-.109.272-.162.407-.056-.135-.109-.271-.167-.407a16.056,16.056,0,0,0-3.357-4.953,15.532,15.532,0,0,0-4.956-3.316,15.795,15.795,0,0,0-12.105,0,16.084,16.084,0,0,0-4.948,3.316,15.129,15.129,0,0,0-3.366,4.953c-.051.125-.1.253-.148.378-.051-.125-.1-.253-.155-.378a16.165,16.165,0,0,0-3.366-4.953,15.489,15.489,0,0,0-10.979-4.521,15.185,15.185,0,0,0-6.072,1.206,16.01,16.01,0,0,0-4.622,3.017v-.521A3.335,3.335,0,0,0,27.211,13.2H3.837a3.334,3.334,0,0,0,0,6.669h18.37L.658,48.884A3.333,3.333,0,0,0,0,50.872v2.176a3.337,3.337,0,0,0,3.336,3.336H28.214a3.335,3.335,0,0,0,3.324-3.09,15.693,15.693,0,0,0,3.675,2.184,15.189,15.189,0,0,0,6.031,1.207A14.892,14.892,0,0,0,49.857,54.1a15.447,15.447,0,0,0,4.827-5.188v4.5a3.245,3.245,0,0,0,3.277,3.275,3.194,3.194,0,0,0,2.281-.949,3.077,3.077,0,0,0,.991-2.326V41.733h-.012a.087.087,0,0,1,.012-.015h-8.17a3.175,3.175,0,0,0-1.851.558,3.007,3.007,0,0,0-1.161,1.507l-.535,1.1a8.969,8.969,0,0,1-8.271,5.254,9.141,9.141,0,0,1-3.493-.684,8.463,8.463,0,0,1-2.883-1.939,9.963,9.963,0,0,1-1.94-2.888,8.4,8.4,0,0,1-.729-3.447V38.252H61.234V28.34a8.74,8.74,0,0,1,.688-3.442,8.959,8.959,0,0,1,8.355-5.515,9.117,9.117,0,0,1,3.493.687,8.459,8.459,0,0,1,2.883,1.94,10.032,10.032,0,0,1,1.94,2.889,8.36,8.36,0,0,1,.734,3.442V53.409A3.233,3.233,0,0,0,82.6,56.684a3.211,3.211,0,0,0,2.286-.949,3.107,3.107,0,0,0,.986-2.326v-4.5a15.828,15.828,0,0,0,2.482,3.249,15.454,15.454,0,0,0,4.954,3.314,15.671,15.671,0,0,0,12.061,0,16.035,16.035,0,0,0,5-3.314,15.226,15.226,0,0,0,3.359-4.951c.044-.112.087-.225.129-.338.046.113.087.226.134.338a15.068,15.068,0,0,0,3.359,4.951,16.075,16.075,0,0,0,4.951,3.314,15.79,15.79,0,0,0,12.109,0,15.476,15.476,0,0,0,4.946-3.314,16.166,16.166,0,0,0,3.366-4.951c.06-.142.116-.283.173-.426.058.143.111.284.173.426a16.07,16.07,0,0,0,3.359,4.951,15.454,15.454,0,0,0,4.954,3.314,15.671,15.671,0,0,0,12.061,0,16.008,16.008,0,0,0,5-3.314A15.314,15.314,0,0,0,173,41.178V28.341A14.991,14.991,0,0,0,171.749,22.311ZM8.35,49.716,25.794,26.224a16.054,16.054,0,0,0-.143,2.117V41.178A14.759,14.759,0,0,0,26.9,47.211a16.514,16.514,0,0,0,1.366,2.5H8.35ZM50.285,31.7H32.2V28.34a8.738,8.738,0,0,1,.686-3.442,8.951,8.951,0,0,1,8.36-5.515,9.1,9.1,0,0,1,3.486.687,8.423,8.423,0,0,1,2.885,1.94,10.033,10.033,0,0,1,1.94,2.889,8.318,8.318,0,0,1,.729,3.442V31.7Zm58.093,9.48a8.7,8.7,0,0,1-.688,3.447,8.941,8.941,0,0,1-8.352,5.511,9.141,9.141,0,0,1-3.493-.684,8.417,8.417,0,0,1-2.883-1.939,9.917,9.917,0,0,1-1.94-2.888,8.353,8.353,0,0,1-.729-3.447V28.341A8.74,8.74,0,0,1,90.98,24.9a8.935,8.935,0,0,1,1.937-2.889,9.165,9.165,0,0,1,9.9-1.94,8.433,8.433,0,0,1,2.888,1.94,10.129,10.129,0,0,1,1.94,2.889,8.356,8.356,0,0,1,.729,3.442V41.178Zm29.035,0a8.32,8.32,0,0,1-.729,3.447,9.947,9.947,0,0,1-1.94,2.888,8.358,8.358,0,0,1-2.888,1.939,9.337,9.337,0,0,1-7.018,0,9.046,9.046,0,0,1-4.825-4.826,8.735,8.735,0,0,1-.69-3.447V28.341a8.439,8.439,0,0,1,.732-3.442,10.1,10.1,0,0,1,1.94-2.889,8.522,8.522,0,0,1,2.883-1.94,9.152,9.152,0,0,1,3.493-.687,8.985,8.985,0,0,1,8.357,5.515,8.775,8.775,0,0,1,.686,3.442V41.178Zm29.035,0a8.82,8.82,0,0,1-.686,3.447,9.129,9.129,0,0,1-11.85,4.826,8.424,8.424,0,0,1-2.882-1.939,9.946,9.946,0,0,1-1.942-2.888,8.337,8.337,0,0,1-.732-3.447V28.341a8.742,8.742,0,0,1,.69-3.442,8.935,8.935,0,0,1,1.937-2.889,9.169,9.169,0,0,1,9.905-1.94,8.423,8.423,0,0,1,2.885,1.94,10.088,10.088,0,0,1,1.942,2.889,8.356,8.356,0,0,1,.729,3.442V41.178Z"/></svg>--> |
|
7 |
<!-- <p>The OpenAIRE Catch-all repository hosted at CERN cloud infrastructure. Whatever your field of research is, you can deposit any type of research product, select the proper license, ask for a DOI and link it to the funding projects for easy reporting.</p>--> |
|
8 |
<!--</div>--> |
|
9 |
|
|
10 |
<div class="uk-margin-top uk-margin"> |
|
11 |
<div class="uk-clearfix "> |
|
12 |
<paging-no-load [currentPage]="currentPage" [totalResults]="totalResults" [size]="resultsPerPage" |
|
13 |
(pageChange)="pageChanged($event)" class="uk-float-right"></paging-no-load> |
|
14 |
</div> |
|
15 |
|
|
16 |
<ul class="uk-list search-results uk-margin-remove-top"> |
|
17 |
<errorMessages *ngIf="status != errorCodes.NONE" [status]="[status]" [type]="'results'"></errorMessages> |
|
18 |
|
|
19 |
<li *ngFor="let result of previewResults" class="uk-animation-fade"> |
|
20 |
<div class="uk-card uk-card-default uk-padding uk-card-hover"> |
|
21 |
<div class="uk-grid uk-grid-divider"> |
|
22 |
<div class="uk-width-3-4 uk-first-column"> |
|
23 |
<result-preview [properties]="properties" [showOrcid]="false" [showOrganizations]="true" |
|
24 |
[showSubjects]="true" [result]="result" [promoteWebsiteURL]="true"> |
|
25 |
</result-preview> |
|
26 |
</div> |
|
27 |
|
|
28 |
<div class="uk-width-1-4"> |
|
29 |
<div class="uk-height-1-1 uk-padding-small uk-flex uk-flex-center uk-flex-column uk-flex-middle"> |
|
30 |
<orcid-work [resultId]="result.id" [type]="result.resultType" [pageType]="'my_search'" |
|
31 |
[putCodes]="result.orcidPutCodes" [givenPutCode]="true" |
|
32 |
[identifiers]="result.identifiers" |
|
33 |
[creationDates]="result.orcidCreationDates" [updateDates]="result.orcidUpdateDates"> |
|
34 |
</orcid-work> |
|
35 |
</div> |
|
36 |
</div> |
|
37 |
</div> |
|
38 |
</div> |
|
39 |
</li> |
|
40 |
</ul> |
|
41 |
</div> |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/orcid/my-orcid-links/searchMyOrcidResults.component.ts | ||
---|---|---|
1 |
import {Component, EventEmitter, Input, Output, SimpleChanges} from '@angular/core'; |
|
2 |
import {ActivatedRoute} from "@angular/router"; |
|
3 |
import {Subscriber} from "rxjs"; |
|
4 |
import {SearchResult} from "../../utils/entities/searchResult"; |
|
5 |
import {EnvProperties} from "../../utils/properties/env-properties"; |
|
6 |
import {RouterHelper} from "../../utils/routerHelper.class"; |
|
7 |
import {ErrorCodes} from "../../utils/properties/errorCodes"; |
|
8 |
import {ResultPreview} from "../../utils/result-preview/result-preview"; |
|
9 |
import {properties} from "../../../../environments/environment"; |
|
10 |
import {Session} from "../../login/utils/helper.class"; |
|
11 |
import {OrcidService} from "../orcid.service"; |
|
12 |
|
|
13 |
@Component({ |
|
14 |
selector: 'my-orcid-result', |
|
15 |
templateUrl:'searchMyOrcidResults.component.html' |
|
16 |
}) |
|
17 |
|
|
18 |
export class searcMyOrcidResultsComponent { |
|
19 |
@Input() results: SearchResult[]; |
|
20 |
@Input() status: number; |
|
21 |
@Input() type: string; |
|
22 |
@Input() properties:EnvProperties; |
|
23 |
|
|
24 |
@Input() previewResults:ResultPreview[]; |
|
25 |
|
|
26 |
public urlParam: string; |
|
27 |
public linkToAdvancedSearchPage: string; |
|
28 |
public errorCodes:ErrorCodes = new ErrorCodes(); |
|
29 |
public routerHelper:RouterHelper = new RouterHelper(); |
|
30 |
public errorMessage: string = "No results found"; |
|
31 |
@Output() pageChange = new EventEmitter(); |
|
32 |
@Input() currentPage: number = 0; |
|
33 |
@Input() totalResults: number; |
|
34 |
@Input() resultsPerPage: number = 5; |
|
35 |
|
|
36 |
sub; |
|
37 |
constructor (private route: ActivatedRoute, private orcidService: OrcidService) {} |
|
38 |
ngOnDestroy() { |
|
39 |
if (this.sub instanceof Subscriber) { |
|
40 |
this.sub.unsubscribe(); |
|
41 |
} |
|
42 |
} |
|
43 |
ngOnInit() { |
|
44 |
if(this.type == "publication") { |
|
45 |
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedPublications; |
|
46 |
this.urlParam = "articleId"; |
|
47 |
} else if(this.type == "dataset") { |
|
48 |
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDatasets; |
|
49 |
this.urlParam = "datasetId"; |
|
50 |
} else if(this.type == "software") { |
|
51 |
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedSoftware; |
|
52 |
this.urlParam = "softwareId"; |
|
53 |
} else if(this.type == "other") { |
|
54 |
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrps; |
|
55 |
this.urlParam = "orpId"; |
|
56 |
} |
|
57 |
|
|
58 |
this.properties = properties; |
|
59 |
|
|
60 |
} |
|
61 |
|
|
62 |
// ngOnChanges(changes: SimpleChanges): void { |
|
63 |
// if (changes.results) { |
|
64 |
// this.initialize(); |
|
65 |
// } |
|
66 |
// } |
|
67 |
|
|
68 |
public quote(params: string):string { |
|
69 |
return '"'+params+'"'; |
|
70 |
} |
|
71 |
public getResultPreview(result: SearchResult): ResultPreview { |
|
72 |
return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.type); |
|
73 |
} |
|
74 |
|
|
75 |
initialize() { |
|
76 |
this.previewResults = []; |
|
77 |
for (let result of this.results) { |
|
78 |
this.previewResults.push(this.getResultPreview(result)); |
|
79 |
} |
|
80 |
|
|
81 |
if (this.properties.environment == 'development' && Session.isLoggedIn() && this.results && this.results.length > 0) { |
|
82 |
this.orcidService.getLocalWorksByPids(this.previewResults.map( |
|
83 |
previewResult => { |
|
84 |
if (previewResult.identifiers) { |
|
85 |
let pidsArray: string[] = []; |
|
86 |
for (let key of Array.from(previewResult.identifiers.keys())) { |
|
87 |
pidsArray = pidsArray.concat(previewResult.identifiers.get(key)); |
|
88 |
} |
|
89 |
return pidsArray;//.join(); |
|
90 |
} |
|
91 |
})).subscribe( |
|
92 |
works => { |
|
93 |
for (let i = 0; i < this.previewResults.length; i++) { |
|
94 |
if (this.previewResults[i].identifiers) { |
|
95 |
this.previewResults[i].orcidPutCodes = []; |
|
96 |
this.previewResults[i].orcidUpdateDates = []; |
|
97 |
|
|
98 |
works[i].forEach(work => { |
|
99 |
this.previewResults[i].orcidPutCodes.push(work['putCode']); |
|
100 |
this.previewResults[i].orcidUpdateDates.push(work['creationDate']); |
|
101 |
}); |
|
102 |
// this.previewResults[i].orcidPutCodes = works[i].map(work => work['putCode']); |
|
103 |
// this.previewResults[i].orcidUpdateDates = works[i] |
|
104 |
// console.debug(i, this.previewResults[i].orcidPutCodes); |
|
105 |
} |
|
106 |
} |
|
107 |
}, error => { |
|
108 |
|
|
109 |
} |
|
110 |
); |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
public pageChanged($event) { |
|
115 |
this.pageChange.emit($event); |
|
116 |
} |
|
117 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/orcid/my-orcid-links/searchMyOrcidResults.module.ts | ||
---|---|---|
1 |
import {NgModule} from '@angular/core'; |
|
2 |
import {CommonModule} from '@angular/common'; |
|
3 |
import {FormsModule} from '@angular/forms'; |
|
4 |
import {RouterModule} from '@angular/router'; |
|
5 |
|
|
6 |
import {ResultPreviewModule} from "../../utils/result-preview/result-preview.module"; |
|
7 |
import {ErrorMessagesModule} from "../../utils/errorMessages.module"; |
|
8 |
import {searcMyOrcidResultsComponent} from "./searchMyOrcidResults.component"; |
|
9 |
import {OrcidModule} from "../orcid.module"; |
|
10 |
import {PagingModule} from "../../utils/paging.module"; |
|
11 |
|
|
12 |
@NgModule({ |
|
13 |
imports: [ |
|
14 |
CommonModule, FormsModule, |
|
15 |
RouterModule, ErrorMessagesModule, |
|
16 |
ResultPreviewModule, OrcidModule, PagingModule |
|
17 |
], |
|
18 |
declarations: [ |
|
19 |
searcMyOrcidResultsComponent |
|
20 |
], |
|
21 |
providers:[ |
|
22 |
], |
|
23 |
exports: [ |
|
24 |
searcMyOrcidResultsComponent |
|
25 |
] |
|
26 |
}) |
|
27 |
export class SearchMyOrcidResultsModule { } |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/orcid/my-orcid-links/myOrcidLinks.component.ts | ||
---|---|---|
1 |
import {Component, Input, ViewChild} from '@angular/core'; |
|
2 |
import {ActivatedRoute, Router} from '@angular/router'; |
|
3 |
import {Location} from '@angular/common'; |
|
4 |
import {ErrorCodes} from "../../utils/properties/errorCodes"; |
|
5 |
import {ErrorMessagesComponent} from "../../utils/errorMessages.component"; |
|
6 |
import {SearchUtilsClass} from "../../searchPages/searchUtils/searchUtils.class"; |
|
7 |
import {RouterHelper} from "../../utils/routerHelper.class"; |
|
8 |
import {EnvProperties} from "../../utils/properties/env-properties"; |
|
9 |
import {properties} from "../../../../environments/environment"; |
|
10 |
import {OrcidService} from "../orcid.service"; |
|
11 |
import {Identifier, StringUtils} from "../../utils/string-utils.class"; |
|
12 |
import {SearchResearchResultsService} from "../../services/searchResearchResults.service"; |
|
13 |
import {Session} from "../../login/utils/helper.class"; |
|
14 |
import {LoginErrorCodes} from "../../login/utils/guardHelper.class"; |
|
15 |
import {SearchResult} from "../../utils/entities/searchResult"; |
|
16 |
import {ResultPreview} from "../../utils/result-preview/result-preview"; |
|
17 |
import {HttpClient} from "@angular/common/http"; |
|
18 |
|
|
19 |
declare var UIkit: any; |
|
20 |
|
|
21 |
@Component({ |
|
22 |
selector: 'my-orcid-links', |
|
23 |
template: ` |
|
24 |
|
|
25 |
<!-- <div class="uk-section uk-padding-remove-bottom uk-padding-remove-top">--> |
|
26 |
<!-- <div class="explorePanelBackground communityPanelBackground uk-padding-small">--> |
|
27 |
<!-- <div class="uk-container uk-container-large uk-margin-small-top uk-margin-small-bottom">--> |
|
28 |
<!-- <breadcrumbs [light]="!!(this.communityId)" [breadcrumbs]="breadcrumbs"></breadcrumbs>--> |
|
29 |
<!-- </div>--> |
|
30 |
<!-- </div>--> |
|
31 |
<!-- </div>--> |
|
32 |
<div class=""> |
|
33 |
<div class="uk-container uk-container-large uk-margin-top"> |
|
34 |
<div *ngIf="showErrorMessage" class="uk-animation-fade uk-alert uk-alert-warning" role="alert"> |
|
35 |
An Error Occurred |
|
36 |
</div> |
|
37 |
<div *ngIf="!showLoading && !orcidQuery && !requestGrant && !showErrorMessage" |
|
38 |
class="uk-animation-fade uk-alert uk-alert-primary" role="alert"> |
|
39 |
No ORCID links found |
|
40 |
</div> |
|
41 |
<div *ngIf="requestGrant" class=""> |
|
42 |
<div class="uk-text-center uk-padding-small"> |
|
43 |
<div> |
|
44 |
This is a private page, only for users that have connected their ORCID iD with OpenAIRE. |
|
45 |
Please grant OpenAIRE to access and update your ORCID works. |
|
46 |
</div> |
|
47 |
|
|
48 |
<div class="uk-margin-medium-top uk-align-center"> |
|
49 |
<button (click)="openGrantWindow()" type="submit" |
|
50 |
class="uk-button uk-padding-small uk-padding-remove-vertical uk-margin-left uk-button-primary"> |
|
51 |
<span>Grant OpenAIRE</span> |
|
52 |
</button> |
|
53 |
</div> |
|
54 |
</div> |
|
55 |
</div> |
|
56 |
</div> |
|
57 |
|
|
58 |
<!-- <div *ngIf="orcidQuery" class="uk-container uk-container-large uk-margin-top">--> |
|
59 |
|
|
60 |
<!-- <form --> |
|
61 |
<!-- class="uk-margin-top uk-grid uk-margin-small-left ng-untouched ng-pristine ng-valid uk-form-width-large uk-float-right">--> |
|
62 |
<!-- --> |
|
63 |
<!-- <div class=" uk-padding-remove-left uk-margin-small-top uk-inline uk-width-expand">--> |
|
64 |
<!-- <a *ngIf="keyword.length > 0" class="uk-form-icon uk-form-icon-flip"--> |
|
65 |
<!-- (click)="keyword = ''"--> |
|
66 |
<!-- uk-icon="icon: close"></a>--> |
|
67 |
<!-- <input type="text" class="uk-input text-input-box uk-width-expand"--> |
|
68 |
<!-- placeholder="Search by name, description, subject..." aria-describedby="sizing-addon2"--> |
|
69 |
<!-- [(ngModel)]="keyword" name="keyword">--> |
|
70 |
<!-- </div>--> |
|
71 |
<!-- <div class="uk-padding-remove-left"> --> |
|
72 |
<!-- <button (click)="keywordChanged()" type="submit"--> |
|
73 |
<!-- class="portal-button uk-margin-small-left uk-margin-small-top uk-button">Search--> |
|
74 |
<!-- </button>--> |
|
75 |
<!-- </div>--> |
|
76 |
<!-- --> |
|
77 |
<!-- </form>--> |
|
78 |
<!-- </div>--> |
|
79 |
|
|
80 |
|
|
81 |
<!-- <div id="tm-main" class=" tm-middle" [class.uk-margin-top]="stickyForm">--> |
|
82 |
<!-- <div uk-grid>--> |
|
83 |
<!-- <div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first ">--> |
|
84 |
<!-- <div class="uk-container uk-container-large">--> |
|
85 |
<!-- <my-orcid-result [results]="results"--> |
|
86 |
<!-- [status]="searchUtils.status"--> |
|
87 |
<!-- [type]="resultType"--> |
|
88 |
<!-- [properties]=properties>--> |
|
89 |
<!-- </my-orcid-result>--> |
|
90 |
<!-- </div> --> |
|
91 |
<!-- </div>--> |
|
92 |
<!-- </div>--> |
|
93 |
<!-- </div>--> |
|
94 |
</div> |
|
95 |
|
|
96 |
<div *ngIf="orcidQuery" class="tm-middle" id="tm-main"> |
|
97 |
<div uk-grid="" class="uk-grid uk-grid-stack"> |
|
98 |
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first uk-first-column"> |
|
99 |
<div class="uk-container uk-container-large"> |
|
100 |
<my-orcid-result [previewResults]="currentResults" |
|
101 |
[status]="searchUtils.status" |
|
102 |
[type]="resultType" |
|
103 |
[properties]=properties |
|
104 |
[currentPage]="currentPage" |
|
105 |
[totalResults]="totalOrcidResults" |
|
106 |
[resultsPerPage]="resultsPerPage" |
|
107 |
(pageChange)="pageChanged($event)"> |
|
108 |
</my-orcid-result> |
|
109 |
|
|
110 |
<div class="uk-text-center uk-margin-medium-top uk-margin-medium-bottom uk-animation-fade uk-alert" role="alert"> |
|
111 |
Your ORCID links will be visible in the OpenAIRE research results as soon as we synchronize our data with ORCID. |
|
112 |
</div> |
|
113 |
</div> |
|
114 |
</div> |
|
115 |
</div> |
|
116 |
</div> |
|
117 |
` |
|
118 |
}) |
|
119 |
export class MyOrcidLinksComponent { |
|
120 |
public resultType: string = "result"; |
|
121 |
|
|
122 |
private errorCodes: ErrorCodes; |
|
123 |
private errorMessages: ErrorMessagesComponent; |
|
124 |
@Input() piwikSiteId = null; |
|
125 |
public results =[]; |
|
126 |
public currentResults = []; |
|
127 |
public totalResults:number = 0 ; |
|
128 |
public baseUrl:string; |
|
129 |
public searchUtils:SearchUtilsClass = new SearchUtilsClass(); |
|
130 |
public subscriptions: any[] = []; |
|
131 |
public _location:Location; |
|
132 |
|
|
133 |
public disableForms: boolean = false; |
|
134 |
public loadPaging: boolean = true; |
|
135 |
public oldTotalResults: number = 0; |
|
136 |
pagingLimit = 0; |
|
137 |
|
|
138 |
properties:EnvProperties; |
|
139 |
|
|
140 |
@Input() public communityId: string = null; |
|
141 |
|
|
142 |
depositLearnHowPage: string = null; |
|
143 |
public routerHelper:RouterHelper = new RouterHelper(); |
|
144 |
// breadcrumbs:Breadcrumb[] = []; |
|
145 |
parameters = {}; |
|
146 |
keyword = ""; |
|
147 |
|
|
148 |
identifiers: string[] = []; |
|
149 |
works: any[] = []; |
|
150 |
|
|
151 |
orcidQuery: string = ""; |
|
152 |
typeQuery: string = ""; |
|
153 |
|
|
154 |
public showLoading: boolean = true; |
|
155 |
|
|
156 |
currentPage: number = 1; |
|
157 |
totalOrcidResults: number; |
|
158 |
resultsPerPage: number = 5; |
|
159 |
|
|
160 |
public requestGrant: boolean = false; |
|
161 |
public window: any; |
|
162 |
private tokenUrl: string; |
|
163 |
private clientId: string = "APP-A5M3KTX6NCN67L91"; |
|
164 |
|
|
165 |
public showErrorMessage: boolean = false; |
|
166 |
|
|
167 |
constructor (private route: ActivatedRoute, private router: Router, |
|
168 |
private _orcidService: OrcidService, |
|
169 |
private _searchResearchResultsService: SearchResearchResultsService |
|
170 |
// ,private http: HttpClient/*ATHENA CODE*/ |
|
171 |
) { |
|
172 |
this.errorCodes = new ErrorCodes(); |
|
173 |
this.errorMessages = new ErrorMessagesComponent(); |
|
174 |
this.searchUtils.status = this.errorCodes.LOADING; |
|
175 |
this.searchUtils.page =1; |
|
176 |
|
|
177 |
if(typeof document !== 'undefined') { |
|
178 |
this.tokenUrl = "https://sandbox.orcid.org/oauth/authorize?" |
|
179 |
+ "client_id="+this.clientId |
|
180 |
// + "&response_type=code&scope=/activities/update" |
|
181 |
// + "&response_type=code&scope=/authenticate /activities/update /person/update /read-limited" |
|
182 |
+ "&response_type=code&scope=/activities/update /read-limited" |
|
183 |
+ "&redirect_uri="+location.origin+"/orcid?source=openaire"; |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 |
public ngOnInit() { |
|
188 |
this.properties = properties; |
|
189 |
this.depositLearnHowPage = this.properties.depositLearnHowPage; |
|
190 |
this.baseUrl = this.properties.depositSearchPage; |
|
191 |
this.pagingLimit = this.properties.pagingLimit; |
|
192 |
// this.breadcrumbs.push({name: 'home', route: '/'}, { |
|
193 |
// name: "Deposit", |
|
194 |
// route: this.depositLearnHowPage |
|
195 |
// }, {name: "Browse repositories", route: null}); |
|
196 |
|
|
197 |
// this.subscriptions.push(this.route.queryParams.subscribe( |
|
198 |
// params => { |
|
199 |
// this.searchUtils.page = params['page'] ? params['page']-1 : 1; |
|
200 |
// this.searchUtils.size = params['size'] ? params['size'] : 5; |
|
201 |
|
|
202 |
// let page = (params['page'] === undefined) ? 1 : +params['page']; |
|
203 |
// this.searchUtils.page = (page <= 0) ? 1 : page; |
|
204 |
// let size = (params['size'] === undefined) ? 5 : +params['size']; |
|
205 |
// this.searchUtils.size = (size <= 0) ? 1 : size; |
|
206 |
// |
|
207 |
// if (params["type"]) { |
|
208 |
// let types = params["type"]; |
|
209 |
// types = Array.isArray(types) ? types.join(',').split(","):types.split(","); |
|
210 |
// types.map( function (t) { |
|
211 |
// return StringUtils.unquote(StringUtils.URIDecode(t)); |
|
212 |
// } ); |
|
213 |
// |
|
214 |
// if(types.indexOf("publications")!=-1 && types.indexOf("datasets")!=-1 && types.indexOf("software")!=-1 && types.indexOf("other")!=-1 ){ |
|
215 |
// this.typeQuery += "&type=results"; |
|
216 |
// }else{ |
|
217 |
// for (let type of types) { |
|
218 |
// this.typeQuery += "&type=" + StringUtils.unquote(StringUtils.URIDecode(type)); |
|
219 |
// } |
|
220 |
// } |
|
221 |
// }else{ |
|
222 |
// this.typeQuery += "&type=results"; |
|
223 |
// } |
|
224 |
|
|
225 |
this.typeQuery = "&type=results"; |
|
226 |
// this.getLocalWorks(this.currentPage, this.resultsPerPage); |
|
227 |
// })); |
|
228 |
this.typeQuery = "&type=results"; |
|
229 |
this.getLocalWorks(); |
|
230 |
} |
|
231 |
|
|
232 |
public ngOnDestroy() { |
|
233 |
for(let sub of this.subscriptions){ |
|
234 |
sub.unsubscribe(); |
|
235 |
} |
|
236 |
} |
|
237 |
|
|
238 |
openGrantWindow() { |
|
239 |
this.window = window.open(this.tokenUrl, '_blank', |
|
240 |
'location=yes,height=700,width=540,left=500,top=100,scrollbars=yes,status=yes'); |
|
241 |
|
|
242 |
let self = this; |
|
243 |
window.onmessage = function (ev) { |
|
244 |
if (ev.isTrusted && ev.origin !== location.origin && ev.data !== 'success') |
|
245 |
return; |
|
246 |
self.requestGrant = false; |
|
247 |
UIkit.notification({ |
|
248 |
message: 'Thank you for <strong>connecting your ORCID iD</strong> with OpenAIRE!', |
|
249 |
status: 'success', |
|
250 |
timeout: 6000, |
|
251 |
pos: 'bottom-right' |
|
252 |
}); |
|
253 |
self.getLocalWorks(); |
|
254 |
}; |
|
255 |
} |
|
256 |
|
|
257 |
getLocalWorks() { |
|
258 |
this.showErrorMessage = false; |
|
259 |
|
|
260 |
this.showLoading = true; |
|
261 |
this.subscriptions.push(this._orcidService.getLocalWorks().subscribe( |
|
262 |
(response: any[]) => { |
|
263 |
|
|
264 |
this.works = response;//['results']; |
|
265 |
this.totalOrcidResults = this.works.length;//response['total']; |
|
266 |
|
|
267 |
this.prepareOrcidQuery(); |
|
268 |
}, |
|
269 |
error => { |
|
270 |
this.handleError(error, "Could not get locally stored user's ORCID works"); |
|
271 |
this.showLoading = false; |
|
272 |
} |
|
273 |
)); |
|
274 |
} |
|
275 |
|
|
276 |
public prepareOrcidQuery() { |
|
277 |
|
|
278 |
if(this.results.length >= this.currentPage) { |
|
279 |
this.currentResults = this.results[this.currentPage-1]; |
|
280 |
return; |
|
281 |
} |
|
282 |
|
|
283 |
this.showLoading = true; |
|
284 |
|
|
285 |
this.orcidQuery = ""; |
|
286 |
|
|
287 |
let from: number = (this.currentPage-1)*this.resultsPerPage; |
|
288 |
if(from >= this.works.length) { |
|
289 |
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; |
|
290 |
} |
|
291 |
let to: number = this.currentPage*this.resultsPerPage; |
|
292 |
|
|
293 |
if(to > this.works.length) { |
|
294 |
to = this.works.length; |
|
295 |
} |
|
296 |
|
|
297 |
let works = this.works.slice(from, to); |
|
298 |
|
|
299 |
for(let work of works) { |
|
300 |
for(let pid of work['pids']) { |
|
301 |
let identifier: Identifier = Identifier.getIdentifierFromString(pid); |
|
302 |
this.orcidQuery += (this.orcidQuery ? " or " : "") + ('(pidclassid exact "'+identifier.class+'" and pid="'+StringUtils.URIEncode(identifier.id)+'")'); |
|
303 |
//this.orcidQuery = '(pidclassid exact "doi" and pid="10.1007/978-3-030-55814-7_16")'; |
|
304 |
// console.debug(this.orcidQuery); |
|
305 |
} |
|
306 |
} |
|
307 |
this.showLoading = false; |
|
308 |
this._getResults(works); |
|
309 |
} |
|
310 |
|
|
311 |
public _getResults(works: any) { |
|
312 |
this.searchUtils.status = this.errorCodes.LOADING; |
|
313 |
this.disableForms = true; |
|
314 |
this.currentResults = []; |
|
315 |
this.searchUtils.totalResults = 0; |
|
316 |
|
|
317 |
// let params: string = this.orcidQuery + this.typeQuery; |
|
318 |
//this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery) |
|
319 |
this.subscriptions.push(this._searchResearchResultsService.searchForMyOrcidLinks(this.resultType, this.orcidQuery, this.typeQuery, 1, 50) |
|
320 |
//this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, null, this.searchPage.getFields(), refineFieldsFilterQuery) |
|
321 |
.subscribe( |
|
322 |
data => { |
|
323 |
let totalResults = data[0]; |
|
324 |
let results = data[1]; |
|
325 |
|
|
326 |
this.resultsReturned(results, totalResults, works); |
|
327 |
}, |
|
328 |
err => { |
|
329 |
// this.handleError("Error getting " + this.getEntityName(this.resultType, true, true), err); |
|
330 |
console.error("Error getting " + this.getEntityName(this.resultType, true, true)); |
|
331 |
this.showLoading = false; |
|
332 |
this.searchUtils.status = this.errorMessages.getErrorCode(err.status); |
|
333 |
this.disableForms = false; |
|
334 |
} |
|
335 |
) |
|
336 |
); |
|
337 |
} |
|
338 |
|
|
339 |
public resultsReturned(results: any, totalResults, works: any[]) { |
|
340 |
this.searchUtils.totalResults = totalResults; |
|
341 |
|
|
342 |
let resultsFound: Map<string[], number> = new Map<string[], number>(); |
|
343 |
|
|
344 |
for(let work of works) { |
|
345 |
results.forEach(result => { |
|
346 |
let identifierValues: string[] = [].concat(...Array.from(result.identifiers.values())); |
|
347 |
if(work['pids'].some(pid => identifierValues.includes(pid))) { |
|
348 |
|
|
349 |
let index: number = resultsFound.get(identifierValues); |
|
350 |
if(!index) { |
|
351 |
this.currentResults.push(this.getResultPreview(result)); |
|
352 |
index = this.currentResults.length - 1; |
|
353 |
|
|
354 |
this.currentResults[index].orcidPutCodes = []; |
|
355 |
this.currentResults[index].orcidCreationDates = []; |
|
356 |
this.currentResults[index].orcidUpdateDates = []; |
|
357 |
} |
|
358 |
|
|
359 |
if (work['putCode']) { |
|
360 |
this.currentResults[index].orcidPutCodes.push(work['putCode']); |
|
361 |
} |
|
362 |
if (work['creationDate']) { |
|
363 |
this.currentResults[index].orcidCreationDates.push(work['creationDate']); |
|
364 |
} |
|
365 |
if (work['updateDate']) { |
|
366 |
this.currentResults[index].orcidUpdateDates.push(work['updateDate']); |
|
367 |
} |
|
368 |
} |
|
369 |
}) |
|
370 |
} |
|
371 |
|
|
372 |
// /////////////////////// ATHENA CODE /////////////////////// |
|
373 |
// // console.log(data[1]); |
|
374 |
// let dois = encodeURIComponent(results.map((result) => result.DOIs).join(",")); |
|
375 |
// console.log(dois); |
|
376 |
// console.log(this.properties.impactFactorsAPIURL); |
|
377 |
// if(dois.length > 0 && (this.properties.impactFactorsAPIURL && this.properties.impactFactorsAPIURL.length > 0) ) { |
|
378 |
// let url = this.properties.impactFactorsAPIURL + dois; |
|
379 |
// this.http.get((this.properties.useCache?(this.properties.cacheUrl+(encodeURIComponent(url))):url)).subscribe((data_received:any[]) => { |
|
380 |
// let impact =[]; |
|
381 |
// data_received.forEach(function (result) { |
|
382 |
// if(result.doi && result.doi.length > 0 && result.pop_class!=null && result.inf_class!=null) |
|
383 |
// impact[result.doi]=result; |
|
384 |
// }); |
|
385 |
// this.currentResults.forEach(function (result) { |
|
386 |
// if(result.identifiers) { |
|
387 |
// result.identifiers.get("doi").forEach(function (doi) { |
|
388 |
// if (impact[doi]) { |
|
389 |
// result.DOI = doi; |
|
390 |
// } |
|
391 |
// |
|
392 |
// }) |
|
393 |
// } |
|
394 |
// }); |
|
395 |
// for (let i = 0; i < this.currentResults.length; i++) { |
|
396 |
// if (this.currentResults[i].DOI) { |
|
397 |
// this.currentResults[i].pop_inf = new Array<string>(); |
|
398 |
// this.currentResults[i].pop_inf.push(impact[this.currentResults[i].DOI].pop_class, impact[this.currentResults[i].DOI].inf_class); |
|
399 |
// if(this.currentResults[i].pop_inf[0]=="A"){ |
|
400 |
// // this.previewResults[i].pop_inf.push("High"); |
|
401 |
// this.currentResults[i].pop_inf.push("Exceptional"); |
|
402 |
// }else if(this.currentResults[i].pop_inf[0]=="B"){ |
|
403 |
// // this.previewResults[i].pop_inf.push("Average"); |
|
404 |
// this.currentResults[i].pop_inf.push("Substantial"); |
|
405 |
// }else{ |
|
406 |
// // this.previewResults[i].pop_inf.push("low"); |
|
407 |
// this.currentResults[i].pop_inf.push("Average"); |
|
408 |
// } |
|
409 |
// if(this.currentResults[i].pop_inf[1]=="A"){ |
|
410 |
// // this.previewResults[i].pop_inf.push("Strong"); |
|
411 |
// this.currentResults[i].pop_inf.push("Exceptional"); |
|
412 |
// }else if(this.currentResults[i].pop_inf[1]=="B"){ |
|
413 |
// // this.previewResults[i].pop_inf.push("Average"); |
|
414 |
// this.currentResults[i].pop_inf.push("Substantial"); |
|
415 |
// }else{ |
|
416 |
// // this.previewResults[i].pop_inf.push("Weak"); |
|
417 |
// this.currentResults[i].pop_inf.push("Average"); |
|
418 |
// } |
|
419 |
// } |
|
420 |
// } |
|
421 |
// |
|
422 |
// }, error1 => { |
|
423 |
// console.error("Failed to get Impact factors for elixir-gr") |
|
424 |
// }); |
|
425 |
// // console.log(researchResults[1]); |
|
426 |
// |
|
427 |
// } |
|
428 |
// /////////////////////// ATHENA CODE /////////////////////// |
|
429 |
|
|
430 |
|
|
431 |
this.results[this.currentPage-1] = this.currentResults; |
|
432 |
|
|
433 |
this.searchUtils.status = this.errorCodes.DONE; |
|
434 |
if (this.searchUtils.totalResults == 0) { |
|
435 |
this.searchUtils.status = this.errorCodes.NONE; |
|
436 |
} |
|
437 |
|
|
438 |
this.disableForms = false; |
|
439 |
} |
|
440 |
|
|
441 |
public resultsReturned2(results: any, totalResults, works: any[]) { |
|
442 |
this.searchUtils.totalResults = totalResults; |
|
443 |
|
|
444 |
for(let result of results) { |
|
445 |
let identifierValues: string[] = [].concat(...Array.from(result.identifiers.values())); |
|
446 |
|
|
447 |
this.currentResults.push(this.getResultPreview(result)); |
|
448 |
|
|
449 |
let filteredWorks = works.filter(work => { |
|
450 |
return work['pids'].some(pid => identifierValues.includes(pid)); |
|
451 |
}) |
|
452 |
|
|
453 |
this.currentResults[this.currentResults.length - 1].orcidPutCodes = []; |
|
454 |
this.currentResults[this.currentResults.length - 1].orcidCreationDates = []; |
|
455 |
this.currentResults[this.currentResults.length - 1].orcidUpdateDates = []; |
|
456 |
|
|
457 |
filteredWorks.forEach(work => { |
|
458 |
if(work['putCode']) { |
|
459 |
this.currentResults[this.currentResults.length - 1].orcidPutCodes.push(work['putCode']); |
|
460 |
} |
|
461 |
if(work['creationDate']) { |
|
462 |
this.currentResults[this.currentResults.length - 1].orcidCreationDates.push(work['creationDate']); |
|
463 |
} |
|
464 |
if(work['updateDate']) { |
|
465 |
this.currentResults[this.currentResults.length - 1].orcidUpdateDates.push(work['updateDate']); |
|
466 |
} |
|
467 |
|
|
468 |
// this.currentResults[this.currentResults.length - 1].orcidPutCodes.push(work['putCode']); |
|
469 |
// this.currentResults[this.currentResults.length - 1].orcidCreationDates.push(work['creationDate']); |
|
470 |
// this.currentResults[this.currentResults.length - 1].orcidUpdateDates.push(work['creationDate']); |
|
471 |
}); |
|
472 |
} |
|
473 |
|
|
474 |
this.results[this.currentPage-1] = this.currentResults; |
|
475 |
// if(!refine) { |
|
476 |
// this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false); |
|
477 |
// } |
|
478 |
|
|
479 |
this.searchUtils.status = this.errorCodes.DONE; |
|
480 |
if (this.searchUtils.totalResults == 0) { |
|
481 |
this.searchUtils.status = this.errorCodes.NONE; |
|
482 |
} |
|
483 |
|
|
484 |
this.disableForms = false; |
|
485 |
} |
|
486 |
|
|
487 |
public getResultPreview(result: SearchResult): ResultPreview { |
|
488 |
return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.resultType); |
|
489 |
} |
|
490 |
|
|
491 |
// private handleError(message: string, error) { |
|
492 |
// if(error && error.status == "401") { |
|
493 |
// this.requestGrant = true; |
|
494 |
// this.requestGrantMessage = "Please grant OpenAIRE to access and update your ORCID record and works. "; |
|
495 |
// // + "If you have already granted OpenAIRE, you just need to login again to ORCID!"; |
|
496 |
// } else if(error && error.status == "403") { |
|
497 |
// this.requestGrant = true; |
|
498 |
// this.requestGrantMessage = "Please login again to ORCID." |
|
499 |
// } |
|
500 |
// console.error("My ORCID links Page: "+message, error); |
|
501 |
// } |
|
502 |
|
|
503 |
public getEntityName(entityType: string, plural: boolean, full: boolean): string { |
|
504 |
if (entityType == "publication") { |
|
505 |
return "publication" + (plural ? "s" : ""); |
|
506 |
} else if (entityType == "dataset") { |
|
507 |
return (full ? "research data" : ("dataset" + (plural ? "s" : ""))); |
|
508 |
} else if (entityType == "software") { |
|
509 |
return "software"; |
|
510 |
} else if (entityType == "other") { |
|
511 |
return (full ? ("other research product" + (plural ? "s" : "")) : "other"); |
|
512 |
} else if (entityType == "result") { |
|
513 |
return (full ? ("research outcome" + (plural ? "s" : "")) : "result"); |
|
514 |
} |
|
515 |
} |
|
516 |
|
|
517 |
public pageChanged($event) { |
|
518 |
this.currentPage = $event.value; |
|
519 |
this.prepareOrcidQuery(); |
|
520 |
// this.getLocalWorks(this.currentPage, this.resultsPerPage); |
|
521 |
} |
|
522 |
|
|
523 |
handleError(error, errorMsg: string) { |
|
524 |
if(error && (error.status == "401" || error.status == "403")) { |
|
525 |
this.requestGrant = true; |
|
526 |
} else { |
|
527 |
this.showErrorMessage = true; |
|
528 |
|
|
529 |
// UIkit.notification({ |
|
530 |
// message: errorMsg, |
|
531 |
// status: 'warning', |
|
532 |
// timeout: 6000, |
|
533 |
// pos: 'bottom-right' |
|
534 |
// }); |
|
535 |
} |
|
536 |
this.showLoading = false; |
|
537 |
} |
|
538 |
} |
Also available in: Unified diff
[Trunk | Library]: [NEW] Added "my-orcid-links" folder and files.