Revision 60221
Added by Konstantina Galouni over 3 years ago
resultLanding.component.ts | ||
---|---|---|
16 | 16 |
import {RelationResult, ResultPreview} from "../../utils/result-preview/result-preview"; |
17 | 17 |
import {IndexInfoService} from "../../utils/indexInfo.service"; |
18 | 18 |
import {FormBuilder} from "@angular/forms"; |
19 |
import {StringUtils} from "../../utils/string-utils.class"; |
|
19 |
import {Identifier, StringUtils} from "../../utils/string-utils.class";
|
|
20 | 20 |
import {properties} from "../../../../environments/environment"; |
21 | 21 |
import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabularies.service"; |
22 | 22 |
import {Subscriber} from "rxjs"; |
23 |
import {Session} from "../../login/utils/helper.class"; |
|
23 | 24 |
import {AnnotationComponent} from "../annotation/annotation.component"; |
24 | 25 |
import {User} from "../../login/utils/helper.class"; |
25 | 26 |
|
... | ... | |
100 | 101 |
'Title', 'Authors', 'Access rights', |
101 | 102 |
'Publisher information', 'Funding Information', |
102 | 103 |
'Persistent identifiers', 'Other']; |
104 |
public loggedIn: boolean = false; |
|
105 |
public pidsArrayString: string = ""; |
|
106 |
public identifier: Identifier; |
|
107 |
|
|
103 | 108 |
public user: User; |
104 | 109 |
public pid: string; |
105 | 110 |
@ViewChild("annotation") annotation: AnnotationComponent; |
106 |
|
|
107 |
constructor(private _resultLaningService: ResultLandingService, |
|
111 |
|
|
112 |
constructor(private _resultLandingService: ResultLandingService,
|
|
108 | 113 |
private _vocabulariesService: ISVocabulariesService, |
109 | 114 |
private _piwikService: PiwikService, |
110 | 115 |
private route: ActivatedRoute, |
... | ... | |
131 | 136 |
//this.getDivContents(); |
132 | 137 |
this.getPageContents(); |
133 | 138 |
this.updateUrl(this.properties.domain +this.properties.baseLink + this._router.url); |
134 |
this.subscriptions.push(this.route.queryParams.subscribe(data => { |
|
139 |
this.subscriptions.push(this.route.queryParams.subscribe(async data => { |
|
140 |
if (Session.isLoggedIn()) { |
|
141 |
this.loggedIn = true; |
|
142 |
} |
|
135 | 143 |
this.resultLandingInfo = null; |
136 | 144 |
if (data['articleId']) { |
137 |
this.type = "publication"; |
|
138 |
this.updateTitle("Publication"); |
|
139 |
this.linkToLandingPage = this.properties.searchLinkToPublication; |
|
140 |
this.linkToSearchPage = this.properties.searchLinkToPublications; |
|
141 | 145 |
this.id = data['articleId']; |
142 |
this.title = "Publication";
|
|
146 |
this.initMetaAndLinks("publication");
|
|
143 | 147 |
} else if (data['datasetId']) { |
144 |
this.updateTitle("Dataset"); |
|
145 |
this.type = "dataset"; |
|
146 |
this.linkToLandingPage = this.properties.searchLinkToDataset; |
|
147 |
this.linkToSearchPage = this.properties.searchLinkToDatasets; |
|
148 | 148 |
this.id = data['datasetId']; |
149 |
this.title = "Research Data";
|
|
149 |
this.initMetaAndLinks("dataset");
|
|
150 | 150 |
} else if (data['softwareId']) { |
151 |
this.updateTitle("Software"); |
|
152 |
this.type = "software"; |
|
153 |
this.linkToLandingPage = this.properties.searchLinkToSoftwareLanding; |
|
154 |
this.linkToSearchPage = this.properties.searchLinkToSoftware; |
|
155 | 151 |
this.id = data['softwareId']; |
156 |
this.title = "Software";
|
|
152 |
this.initMetaAndLinks("software");
|
|
157 | 153 |
} else if (data['orpId']) { |
158 |
this.type = "orp"; |
|
159 |
this.updateTitle("Other Research Product"); |
|
160 |
this.linkToLandingPage = this.properties.searchLinkToOrp; |
|
161 |
this.linkToSearchPage = this.properties.searchLinkToOrps; |
|
162 | 154 |
this.id = data['orpId']; |
163 |
this.title = "Other Research Product"; |
|
164 |
} else if (data["id"]){ |
|
165 |
this.type = "result"; |
|
155 |
this.initMetaAndLinks("orp"); |
|
156 |
} else if (data["id"]) { |
|
166 | 157 |
this.id = data["id"]; |
167 |
this.updateTitle("Research Result"); |
|
168 |
this.linkToLandingPage = this.properties.searchLinkToResult; |
|
169 |
this.linkToSearchPage = this.properties.searchLinkToResults; |
|
170 |
this.title = "Research Result"; |
|
158 |
this.initMetaAndLinks("result"); |
|
159 |
} else if (data["pid"]) { |
|
160 |
this.identifier = Identifier.getIdentifierFromString(data["pid"]); |
|
161 |
console.debug(this.identifier); |
|
162 |
|
|
163 |
if(!this.type) { |
|
164 |
this.type = "result"; |
|
165 |
} |
|
166 |
this.initMetaAndLinks(this.type); |
|
171 | 167 |
} |
172 | 168 |
this.updateDescription(""); |
173 |
|
|
169 |
|
|
174 | 170 |
this.metricsClicked = false; |
175 | 171 |
|
176 |
if (this.id && StringUtils.isOpenAIREID(this.id)) {
|
|
172 |
if ((this.id && StringUtils.isOpenAIREID(this.id)) || (this.identifier)) {
|
|
177 | 173 |
this.getProvenanceVocabularyAndResultLandingInfo(); |
178 | 174 |
} else { |
179 | 175 |
this.showLoading = false; |
180 |
|
|
176 |
|
|
181 | 177 |
this._router.navigate(['/error'], { |
182 | 178 |
queryParams: { |
183 | 179 |
"page": this._location.path(true), |
... | ... | |
185 | 181 |
} |
186 | 182 |
}); |
187 | 183 |
} |
188 |
|
|
189 |
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'; |
|
190 |
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'; |
|
191 |
|
|
184 |
|
|
185 |
if(this.id) { |
|
186 |
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'; |
|
187 |
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'; |
|
188 |
} |
|
189 |
|
|
192 | 190 |
this.scroll(); |
193 | 191 |
})); |
194 | 192 |
} |
195 |
|
|
193 |
|
|
194 |
private initMetaAndLinks(type: string) { |
|
195 |
if (type == "publication") { |
|
196 |
this.type = "publication"; |
|
197 |
this.updateTitle("Publication"); |
|
198 |
this.linkToLandingPage = this.properties.searchLinkToPublication; |
|
199 |
this.linkToSearchPage = this.properties.searchLinkToPublications; |
|
200 |
this.title = "Publication"; |
|
201 |
} else if (type == "dataset") { |
|
202 |
this.updateTitle("Dataset"); |
|
203 |
this.type = "dataset"; |
|
204 |
this.linkToLandingPage = this.properties.searchLinkToDataset; |
|
205 |
this.linkToSearchPage = this.properties.searchLinkToDatasets; |
|
206 |
this.title = "Research Data"; |
|
207 |
} else if (type == "software") { |
|
208 |
this.updateTitle("Software"); |
|
209 |
this.type = "software"; |
|
210 |
this.linkToLandingPage = this.properties.searchLinkToSoftwareLanding; |
|
211 |
this.linkToSearchPage = this.properties.searchLinkToSoftware; |
|
212 |
this.title = "Software"; |
|
213 |
} else if (type == "orp") { |
|
214 |
this.type = "orp"; |
|
215 |
this.updateTitle("Other Research Product"); |
|
216 |
this.linkToLandingPage = this.properties.searchLinkToOrp; |
|
217 |
this.linkToSearchPage = this.properties.searchLinkToOrps; |
|
218 |
this.title = "Other Research Product"; |
|
219 |
} else if (type == "result") { |
|
220 |
this.type = "result"; |
|
221 |
this.updateTitle("Research Result"); |
|
222 |
this.linkToLandingPage = this.properties.searchLinkToResult; |
|
223 |
this.linkToSearchPage = this.properties.searchLinkToResults; |
|
224 |
this.title = "Research Result"; |
|
225 |
} |
|
226 |
} |
|
227 |
|
|
196 | 228 |
private getPageContents() { |
197 | 229 |
if (this.communityId) { |
198 | 230 |
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { |
... | ... | |
253 | 285 |
} |
254 | 286 |
|
255 | 287 |
private getOpenCitations() { |
256 |
this.subscriptions.push(this._resultLaningService.getOpenCitations(this.id, this.properties).subscribe( |
|
288 |
this.subscriptions.push(this._resultLandingService.getOpenCitations(this.id, this.properties).subscribe(
|
|
257 | 289 |
data => { |
258 | 290 |
this.resultLandingInfo.openCitations = data[1]; |
259 | 291 |
}, |
... | ... | |
276 | 308 |
this.getResultLandingInfo(provenanceActionVocabulary); |
277 | 309 |
}, err => { |
278 | 310 |
this.getResultLandingInfo(null); |
279 |
this.handleError("Error getting provenance action vocabulary for " + this.type + " with id: " + this.id, err);
|
|
311 |
this.handleError("Error getting provenance action vocabulary for " + this.type, err); |
|
280 | 312 |
} |
281 | 313 |
)); |
282 | 314 |
} else { |
... | ... | |
324 | 356 |
// } |
325 | 357 |
|
326 | 358 |
private getResultLandingInfo(provenanceActionVocabulary: any) { |
327 |
this.subscriptions.push(this._resultLaningService.getResultLandingInfo(this.id, this.type, provenanceActionVocabulary, this.properties).subscribe(
|
|
359 |
this.subscriptions.push(this._resultLandingService.getResultLandingInfo(this.id, this.identifier, this.type, provenanceActionVocabulary, this.properties).subscribe(
|
|
328 | 360 |
data => { |
329 | 361 |
this.resultLandingInfo = data; |
362 |
if(!this.id) { |
|
363 |
this.id = this.resultLandingInfo.relcanId; |
|
364 |
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'; |
|
365 |
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'; |
|
366 |
} |
|
330 | 367 |
if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType |
331 | 368 |
this.updateUrlWithType(); |
332 | 369 |
} |
... | ... | |
351 | 388 |
} |
352 | 389 |
this.bioentitiesNum = bioentitiesNum; |
353 | 390 |
if (typeof document !== 'undefined') { |
354 |
if (this.resultLandingInfo.identifiers != undefined && this.resultLandingInfo.identifiers.has('doi')) { |
|
355 |
this.doi = this.resultLandingInfo.identifiers.get('doi')[0]; |
|
356 |
this.subscriptions.push(this.metricsService.hasAltMetrics(this.properties.altMetricsAPIURL, this.doi).subscribe(hasAltMetrics => { |
|
357 |
this.hasAltMetrics = hasAltMetrics; |
|
358 |
}, error => { |
|
359 |
this.hasAltMetrics = false; |
|
360 |
})); |
|
391 |
if(this.resultLandingInfo.identifiers) { |
|
392 |
let pidsArray: string[] = []; |
|
393 |
for(let key of Array.from(this.resultLandingInfo.identifiers.keys())) { |
|
394 |
pidsArray = pidsArray.concat(this.resultLandingInfo.identifiers.get(key)); |
|
395 |
this.pidsArrayString = pidsArray.join(); |
|
396 |
} |
|
397 |
if (this.resultLandingInfo.identifiers.has('doi')) { |
|
398 |
this.doi = this.resultLandingInfo.identifiers.get('doi')[0]; |
|
399 |
this.subscriptions.push(this.metricsService.hasAltMetrics(this.properties.altMetricsAPIURL, this.doi).subscribe(hasAltMetrics => { |
|
400 |
this.hasAltMetrics = hasAltMetrics; |
|
401 |
}, error => { |
|
402 |
this.hasAltMetrics = false; |
|
403 |
})); |
|
404 |
} |
|
361 | 405 |
} |
362 | 406 |
} |
363 | 407 |
this.showLoading = false; |
364 | 408 |
this.setActiveTab(); |
365 | 409 |
}, |
366 | 410 |
err => { |
367 |
this.handleError("Error getting " + this.type + " for id: " + this.id, err); |
|
368 |
|
|
411 |
this.handleError("Error getting " + this.type + " for " + (this.id ? ("id: " + this.id) : ("pid: " + this.identifier.id + " ("+this.identifier.class+")")), err); |
|
369 | 412 |
if (err.status == 404) { |
370 | 413 |
this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": this.type}}); |
371 | 414 |
} |
... | ... | |
526 | 569 |
|
527 | 570 |
updateUrlWithType() { |
528 | 571 |
this.type = this.resultLandingInfo.resultType; |
572 |
|
|
529 | 573 |
if (this.type == "publication") { |
530 | 574 |
this.linkToLandingPage = this.properties.searchLinkToPublication; |
531 | 575 |
this.linkToSearchPage = this.properties.searchLinkToPublications; |
... | ... | |
540 | 584 |
this.linkToLandingPage = this.properties.searchLinkToOrp; |
541 | 585 |
this.linkToSearchPage = this.properties.searchLinkToOrps; |
542 | 586 |
} |
543 |
this._location.go(this.linkToLandingPage + this.id); |
|
587 |
if(!this.identifier) { |
|
588 |
this._location.go(this.linkToLandingPage + this.id); |
|
589 |
} |
|
590 |
// else { |
|
591 |
// this._location.go(this.linkToLandingPage.split("?")[0] + "?pid=" + this.identifier.id); |
|
592 |
// } |
|
544 | 593 |
} |
545 | 594 |
|
546 | 595 |
public getReferenceUrl(id: Id): string { |
Also available in: Unified diff
[Trunk | Library]:
1. string-utils.class: Create method 'getIdentifierFromString()' to return a single Identifier.
2. resultLanding.component:
a. Add 'pid' as possible parameter in page url for persistent identifiers.
b. In method 'getResultLandingInfo()' add Identifier parameter to build the appropriate query.
c. Do not re-build url (location.go) if url parameter was "pid".
d. [For orcid - coming soon] Join all identifiers of result into a string: pidsArrayString.
3. resultLanding.service:
a. In method 'getResultLandingInfo()' add Identifier parameter to build tthe appropriate query.
b. Add method 'buildResultLandingInfoUrl()' called by 'getResultLandingInfo()'.
c. Im method 'getResultLandingInfo()', if given identifier and not id parameter, the response is search-like with array of results:
if there are no results, throw HttpErrorResponse with status 404 (like landing response, which returns 404 when no results), otherwise return first result (results['result'][0]).