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} from "../../utils/string-utils.class";
|
12
|
|
13
|
@Component({
|
14
|
selector: 'search-recommended-results-for-orcid',
|
15
|
template: `
|
16
|
|
17
|
<!-- <div class="uk-section uk-padding-remove-bottom uk-padding-remove-top">-->
|
18
|
<!-- <div class="explorePanelBackground communityPanelBackground uk-padding-small">-->
|
19
|
<!-- <div class="uk-container uk-container-large uk-margin-small-top uk-margin-small-bottom">-->
|
20
|
<!-- <breadcrumbs [light]="!!(this.communityId)" [breadcrumbs]="breadcrumbs"></breadcrumbs>-->
|
21
|
<!-- </div>-->
|
22
|
<!-- </div>-->
|
23
|
<!-- </div>-->
|
24
|
<div class="">
|
25
|
<div class="uk-container uk-container-large uk-margin-top">
|
26
|
<div *ngIf="showLoading" class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert">
|
27
|
<span class="loading-gif uk-align-center"></span>
|
28
|
</div>
|
29
|
<div *ngIf="!showLoading && !orcidQuery" class="uk-animation-fade uk-alert uk-alert-warning" role="alert">
|
30
|
An Error Occurred
|
31
|
</div>
|
32
|
</div>
|
33
|
|
34
|
<div *ngIf="orcidQuery" class="uk-container uk-container-large uk-margin-top">
|
35
|
|
36
|
<form
|
37
|
class="uk-margin-top uk-grid uk-margin-small-left ng-untouched ng-pristine ng-valid uk-form-width-large uk-float-right">
|
38
|
|
39
|
<div class=" uk-padding-remove-left uk-margin-small-top uk-inline uk-width-expand">
|
40
|
<a *ngIf="keyword.length > 0" class="uk-form-icon uk-form-icon-flip"
|
41
|
(click)="keyword = ''"
|
42
|
uk-icon="icon: close"></a>
|
43
|
<input type="text" class="uk-input text-input-box uk-width-expand"
|
44
|
placeholder="Search by name, description, subject..." aria-describedby="sizing-addon2"
|
45
|
[(ngModel)]="keyword" name="keyword">
|
46
|
</div>
|
47
|
<div class="uk-padding-remove-left">
|
48
|
<button (click)="keywordChanged()" type="submit"
|
49
|
class="portal-button uk-margin-small-left uk-margin-small-top uk-button">Search
|
50
|
</button>
|
51
|
</div>
|
52
|
|
53
|
</form>
|
54
|
</div>
|
55
|
|
56
|
<!-- <search-research-results [simpleView]="true" type="deposit" simpleSearchLink="/participate/deposit/search" [includeOnlyResultsAndFilter]="true" >-->
|
57
|
<!-- </search-research-results>-->
|
58
|
<search-research-results *ngIf="orcidQuery"
|
59
|
resultType="result" usedBy="orcid" [identifiers]="identifiers"
|
60
|
[includeOnlyResultsAndFilter]="true" [orcidQuery]="orcidQuery">
|
61
|
</search-research-results>
|
62
|
</div>
|
63
|
`
|
64
|
})
|
65
|
export class SearchRecommendedResultsForOrcidComponent {
|
66
|
private errorCodes: ErrorCodes;
|
67
|
private errorMessages: ErrorMessagesComponent;
|
68
|
@Input() piwikSiteId = null;
|
69
|
public results =[];
|
70
|
public totalResults:number = 0 ;
|
71
|
public baseUrl:string;
|
72
|
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
73
|
public subscriptions: any[] = [];
|
74
|
public _location:Location;
|
75
|
|
76
|
public disableForms: boolean = false;
|
77
|
public loadPaging: boolean = true;
|
78
|
public oldTotalResults: number = 0;
|
79
|
pagingLimit = 0;
|
80
|
|
81
|
properties:EnvProperties;
|
82
|
|
83
|
@Input() public communityId: string = null;
|
84
|
|
85
|
depositLearnHowPage: string = null;
|
86
|
public routerHelper:RouterHelper = new RouterHelper();
|
87
|
// breadcrumbs:Breadcrumb[] = [];
|
88
|
parameters = {};
|
89
|
keyword = "";
|
90
|
|
91
|
identifiers: string[] = [];
|
92
|
|
93
|
orcidQuery: string = "";
|
94
|
public showLoading: boolean = true;
|
95
|
|
96
|
constructor (private route: ActivatedRoute, private router: Router, private _orcidService: OrcidService) {
|
97
|
this.errorCodes = new ErrorCodes();
|
98
|
this.errorMessages = new ErrorMessagesComponent();
|
99
|
this.searchUtils.status = this.errorCodes.LOADING;
|
100
|
this.searchUtils.page =1;
|
101
|
}
|
102
|
|
103
|
public ngOnInit() {
|
104
|
this.properties = properties;
|
105
|
this.depositLearnHowPage = this.properties.depositLearnHowPage;
|
106
|
this.baseUrl = this.properties.depositSearchPage;
|
107
|
this.pagingLimit = this.properties.pagingLimit;
|
108
|
// this.breadcrumbs.push({name: 'home', route: '/'}, {
|
109
|
// name: "Deposit",
|
110
|
// route: this.depositLearnHowPage
|
111
|
// }, {name: "Browse repositories", route: null});
|
112
|
|
113
|
// this.subscriptions.push(this._orcidService.getLocalWorks().subscribe(
|
114
|
// works => {
|
115
|
// console.debug(works);
|
116
|
// for(let work of works) {
|
117
|
// for(let pid of work['pids']) {
|
118
|
// let identifier: Identifier = Identifier.getIdentifierFromString(pid);
|
119
|
// this.pidsQuery += (this.pidsQuery ? " or " : "") + '(pidclassid exact "'+identifier.class+'" and pid="'+identifier.id+'")'
|
120
|
// }
|
121
|
// }
|
122
|
// },
|
123
|
// error => {
|
124
|
// this.handleError("Could not get user's ORCID works", error);
|
125
|
// }
|
126
|
// ));
|
127
|
|
128
|
this.subscriptions.push(this._orcidService.getUserOrcid().subscribe(
|
129
|
orcidId => {
|
130
|
orcidId = "0000-0001-7291-3210";//"0000-0002-0458-1004";
|
131
|
// console.debug("mocked orcidIdrcidId: "+orcidId);
|
132
|
this.orcidQuery = 'authorid exact "'+orcidId+'" and (authoridtype exact "orcid_pending")';
|
133
|
this.showLoading = false;
|
134
|
},
|
135
|
error => {
|
136
|
this.handleError("Could not get user's ORCID iD", error);
|
137
|
this.showLoading = false;
|
138
|
}
|
139
|
));
|
140
|
|
141
|
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
142
|
this.parameters = Object.assign({}, params);
|
143
|
this.keyword = params["fv0"]?params["fv0"]:'';
|
144
|
}));
|
145
|
}
|
146
|
|
147
|
public ngOnDestroy() {
|
148
|
for(let sub of this.subscriptions){
|
149
|
sub.unsubscribe();
|
150
|
}
|
151
|
}
|
152
|
keywordChanged() {
|
153
|
|
154
|
if (this.keyword.length > 0) {
|
155
|
this.parameters["fv0"] = this.keyword;
|
156
|
this.parameters["f0"] = "q";
|
157
|
} else {
|
158
|
delete this.parameters['fv0'];
|
159
|
delete this.parameters['f0'];
|
160
|
}
|
161
|
|
162
|
if (this.parameters["page"]) {
|
163
|
//GO to first page
|
164
|
delete this.parameters['page'];
|
165
|
}
|
166
|
|
167
|
this.router.navigate(['/recommended-orcid-links'], {queryParams: this.parameters});
|
168
|
}
|
169
|
|
170
|
private handleError(message: string, error) {
|
171
|
console.error("Search My Results in Orcid Page: "+message, error);
|
172
|
}
|
173
|
}
|