[Library | Trunk]: 1. New view for search results. 2. Add highlight component but currently is not enabled. 3. Change access mode value from classid to classname
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58064 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
efa6527a18
commit
8b6b61f9c3
|
@ -100,20 +100,20 @@
|
|||
|
||||
<span
|
||||
*ngIf="projectInfo.openAccessMandatePublications != undefined && projectInfo.openAccessMandatePublications && projectInfo.openAccessMandateDatasets != undefined && projectInfo.openAccessMandateDatasets"
|
||||
class="uk-label custom-label label-openaccessmandate "
|
||||
class="uk-label custom-label label-open "
|
||||
title="Open Access mandate for Publications and Research Data">
|
||||
<span class="uk-visible@m">Open Access mandate for Publications and Research Data</span> <span
|
||||
class="uk-hidden@m">Open Access mandate for ...</span>
|
||||
</span>{{" "}}
|
||||
<span
|
||||
*ngIf="projectInfo.openAccessMandatePublications != undefined && projectInfo.openAccessMandatePublications && (projectInfo.openAccessMandateDatasets == undefined || !projectInfo.openAccessMandateDatasets)"
|
||||
class="uk-label custom-label label-openaccessmandate "
|
||||
class="uk-label custom-label label-open "
|
||||
title="Open Access mandate for Publications">Open Access mandate for Publications</span>{{" "}}
|
||||
<span *ngIf="projectInfo.specialClause39" class="uk-label custom-label label-sc39 "
|
||||
title="Special Clause 39">Special Clause 39</span>{{" "}}
|
||||
<span
|
||||
*ngIf="projectInfo.openAccessMandateDatasets != undefined && projectInfo.openAccessMandateDatasets && (projectInfo.openAccessMandatePublications == undefined || !projectInfo.openAccessMandatePublications)"
|
||||
class="uk-label custom-label label-openaccessmandate "
|
||||
class="uk-label custom-label label-open "
|
||||
title="Open Access mandate for Research Data">Open Access mandate for Research Data</span>{{" "}}
|
||||
</div>
|
||||
<ul class="uk-list">
|
||||
|
|
|
@ -57,8 +57,8 @@ export class DeletedByInferenceService {
|
|||
result.description = result.description.substring(0, this.sizeOfDescription) + "...";
|
||||
}
|
||||
|
||||
if(data['bestaccessright'] && data['bestaccessright'].hasOwnProperty("classid")) {
|
||||
result.accessMode = data['bestaccessright'].classid;
|
||||
if(data['bestaccessright'] && data['bestaccessright'].hasOwnProperty("classname")) {
|
||||
result.accessMode = data['bestaccessright'].classname;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
title="Country">{{resultLandingInfo.countries.join(", ")}}</span>{{" "}}
|
||||
<!-- <span *ngIf="resultLandingInfo.title && resultLandingInfo.title.accessMode" [class]="'uk-label custom-label label-'+ resultLandingInfo.title.accessMode ">{{resultLandingInfo.title.accessMode}}</span> -->
|
||||
<span *ngIf="resultLandingInfo.accessMode"
|
||||
[class]="'uk-label custom-label label-'+ resultLandingInfo.accessMode "
|
||||
[class]="'uk-label custom-label label-'+ accessClass(resultLandingInfo.accessMode) "
|
||||
title="Access Mode">{{resultLandingInfo.accessMode}}</span>{{" "}}
|
||||
|
||||
<span *ngIf="resultLandingInfo.underCurationMessage" class="uk-label custom-label label-underCuration">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {Component, ElementRef, Inject, Input, PLATFORM_ID, ViewChild} from '@angular/core';
|
||||
import {Component, ElementRef, Input, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {Meta, Title} from '@angular/platform-browser';
|
||||
|
||||
|
@ -12,7 +12,6 @@ import {SEOService} from '../../sharedComponents/SEO/SEO.service';
|
|||
import {HelperFunctions} from '../../utils/HelperFunctions.class';
|
||||
import {HelperService} from '../../utils/helper/helper.service';
|
||||
import {Location} from "@angular/common";
|
||||
import {LoginErrorCodes} from "../../login/utils/guardHelper.class";
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -367,6 +366,16 @@ export class ResultLandingComponent {
|
|||
public updateOpenCitationsPage($event) {
|
||||
this.openCitationsPage = $event.value;
|
||||
}
|
||||
|
||||
public accessClass(accessMode: string): string {
|
||||
if(accessMode.toLowerCase().indexOf('open') !== -1) {
|
||||
return 'open';
|
||||
} else if(accessMode.toLowerCase() === 'not available') {
|
||||
return 'unknown';
|
||||
} else {
|
||||
return 'closed';
|
||||
}
|
||||
}
|
||||
|
||||
public keysToArray(bioentities: Map<string, string>): string[] {
|
||||
let keys: string[] = [];
|
||||
|
|
|
@ -96,10 +96,9 @@ export class ResultLandingService {
|
|||
this.resultLandingInfo.embargoEndDate = data[0].embargoenddate;
|
||||
}
|
||||
|
||||
if(data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classid")) {
|
||||
this.resultLandingInfo.accessMode = data[0]['bestaccessright'].classid;
|
||||
if(data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classname")) {
|
||||
this.resultLandingInfo.accessMode = data[0]['bestaccessright'].classname;
|
||||
}
|
||||
|
||||
// res['result']['metadata']['oaf:entity']['oaf:result']['title']
|
||||
if(data[1] != null) {
|
||||
if(Array.isArray(data[1])) {
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
import {Component, Input, OnInit} from "@angular/core";
|
||||
import {StringUtils} from "../../../utils/string-utils.class";
|
||||
import {Organization, Project} from "../../../utils/entities/searchResult";
|
||||
|
||||
export interface Keyword {
|
||||
field: string,
|
||||
value: string,
|
||||
tokenized: boolean
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'highlight',
|
||||
template: `
|
||||
<ng-template [ngIf]="html" [ngIfElse]="highlightText">
|
||||
<ng-container *ngFor="let token of split()">
|
||||
<span [class.uk-text-bold]="isHighlighted(token)" [innerHTML]="token"></span>
|
||||
</ng-container>
|
||||
</ng-template>
|
||||
<ng-template #highlightText>
|
||||
<ng-container *ngFor="let token of split()">
|
||||
<span *ngIf="isHighlighted(token) else noHighlight" class="uk-text-bold">{{token}}</span>
|
||||
<ng-template #noHighlight>{{token}}</ng-template>
|
||||
</ng-container>
|
||||
</ng-template>`
|
||||
})
|
||||
export class HighlightComponent implements OnInit{
|
||||
@Input() keywords: Keyword[];
|
||||
@Input() field: string;
|
||||
@Input() element: string | Project[] | Organization[];
|
||||
@Input() html = false;
|
||||
public text: string;
|
||||
public separators: string[] = [' ', '-', ',', '.'];
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
if(typeof this.element === "string") {
|
||||
this.text = this.element;
|
||||
} else {
|
||||
/*if(this.element instanceof Project) {
|
||||
this.text = this.element.
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public split(): string[] {
|
||||
return StringUtils.split(this.text, this.separators);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the word given is matched with any keyword
|
||||
*
|
||||
* @param word
|
||||
*/
|
||||
isHighlighted(word: string) {
|
||||
if (this.keywords) {
|
||||
for (let keyword of this.keywords) {
|
||||
if (!keyword.field || keyword.field === this.field) {
|
||||
if (keyword.tokenized && keyword.value.toLowerCase() === word.toLowerCase()) {
|
||||
return true;
|
||||
} else if (!keyword.tokenized && word.toLowerCase().includes(keyword.value.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import {NgModule} from "@angular/core";
|
||||
import {HighlightComponent} from "./highlight.component";
|
||||
import {CommonModule} from "@angular/common";
|
||||
|
||||
@NgModule({
|
||||
declarations: [HighlightComponent],
|
||||
imports: [CommonModule],
|
||||
exports: [HighlightComponent]
|
||||
})
|
||||
export class HighlightModule {}
|
|
@ -1,109 +1,200 @@
|
|||
<ul [class]="'uk-list uk-list-divider uk-margin '+custom_class">
|
||||
<ul [class]="'uk-list uk-margin '+custom_class">
|
||||
<errorMessages [status]="[status]" [type]="'results'"></errorMessages>
|
||||
|
||||
<li *ngFor="let result of results" class="uk-animation-fade">
|
||||
<!-- <h4 class = "{{result.title.accessMode}} {{result.title.sc39}}" [title] = result.title.accessMode > -->
|
||||
<div [title] = result.title.accessMode class="uk-h5">
|
||||
<a [queryParams]="routerHelper.createQueryParam(urlParam,result.id)" routerLinkActive="router-link-active" routerLink="/search/{{type}}">
|
||||
<p *ngIf="result['title'].name || result.acronym"><span *ngIf="result.acronym">{{result.acronym}}</span><span *ngIf="result.acronym && result['title'].name">-</span><span *ngIf="result['title'].name" [innerHTML]="result['title'].name"></span><span *ngIf="result.code"> ({{result.code}})</span></p>
|
||||
<p *ngIf="!result['title'].name && !result.acronym">[no title available]<span *ngIf="result.code"> ({{result.code}})</span></p>
|
||||
<li *ngFor="let result of results" class="uk-animation-fade">
|
||||
<div class="uk-card uk-card-default uk-padding uk-card-hover">
|
||||
<!-- Before title -->
|
||||
<div class="uk-text-small">
|
||||
<span class="uk-text-capitalize">
|
||||
{{(result.entityType) ? getTypeName(result.entityType) : getTypeName(type)}}
|
||||
</span>
|
||||
<span *ngIf="result.type" class="uk-text-capitalize"> . {{result.type}}</span>
|
||||
<span *ngIf="properties.environment !== 'production' && result.types &&
|
||||
removeDuplicates(result.types, (result.entityType) ? getTypeName(result.entityType) : getTypeName(type)).length > 0">
|
||||
{{' . '}}<highlight [field]="'type'" [keywords]="keywords" [element]="(removeDuplicates(result.types, (result.entityType) ?
|
||||
getTypeName(result.entityType) : getTypeName(type)).join(' . '))"></highlight>
|
||||
</span>
|
||||
<span *ngIf="properties.environment === 'production' && result.types &&
|
||||
removeUnknown(result.types, (result.entityType) ? getTypeName(result.entityType) : getTypeName(type)).length > 0">
|
||||
{{' . '}}<highlight [field]="'type'" [keywords]="keywords"
|
||||
[element]="(removeUnknown(result.types, (result.entityType) ?
|
||||
getTypeName(result.entityType) : getTypeName(type)).join(' . '))"></highlight>
|
||||
</span>
|
||||
<span *ngIf="result.year">{{' . ' + result.year.toString()}}</span>
|
||||
<span *ngIf="result.startYear && result.endYear"> . {{result.startYear}} - {{result.endYear}}</span>
|
||||
<span *ngIf="result.embargoEndDate && result.embargoEndDate != ''">
|
||||
. Embargo End Date: {{result.embargoEndDate | date: 'dd MMM yyyy'}}
|
||||
</span>
|
||||
</div>
|
||||
<!-- Title -->
|
||||
<div class="uk-h5 uk-margin-remove">
|
||||
<a [queryParams]="routerHelper.createQueryParam((result.entityType)?queryParamName(result.entityType):urlParam,result.id)"
|
||||
routerLink="/search/{{(result.entityType)?result.entityType:type}}" class="portal-link">
|
||||
<div *ngIf="(result.title && result.title.name) || result.acronym">
|
||||
<span *ngIf="result.acronym">
|
||||
<highlight [field]="'acronym'" [keywords]="keywords" [element]="result.acronym"></highlight>
|
||||
</span>
|
||||
<span *ngIf="result.acronym && (result.title && result.title.name)"> (</span>
|
||||
<span *ngIf="(result.title && result.title.name)">
|
||||
<highlight [field]="'title'" [keywords]="keywords" [element]="result.title.name" [html]="true"></highlight>
|
||||
</span>
|
||||
<span *ngIf="result.acronym && (result.title && result.title.name)">)</span>
|
||||
</div>
|
||||
<div *ngIf="!(result.title && result.title.name) && !result.acronym">
|
||||
[no title available]
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- Authors -->
|
||||
<div *ngIf="result.authors" class="uk-margin-small-bottom">
|
||||
<showAuthors [keywords]="keywords" [authors]="result.authors" [authorsLimit]=10 [showAll]=false></showAuthors>
|
||||
</div>
|
||||
<!-- Funder -->
|
||||
<div *ngIf="result.funderShortname || result.code" class="uk-margin-small-bottom uk-text-small">
|
||||
<span *ngIf="result.funderShortname">
|
||||
<span class="uk-text-muted">Funder: </span>
|
||||
<highlight [field]="'funder'" [keywords]="keywords" [element]="result.funderShortname"></highlight>
|
||||
</span>
|
||||
<span *ngIf="result.code" [class.uk-margin-left]="result.funderShortname">
|
||||
<span class="uk-text-muted">Project Code: </span>
|
||||
<highlight [field]="'code'" [keywords]="keywords" [element]="result.code.toString()"></highlight>
|
||||
</span>
|
||||
</div>
|
||||
<!-- Labels -->
|
||||
<div class="uk-margin-small-bottom">
|
||||
<span *ngIf="properties.environment !== 'production' && result.title && result.title.accessMode"
|
||||
class="uk-label custom-label" [ngClass]="'label-' + accessClass(result.title.accessMode)"
|
||||
title="Access Mode">
|
||||
{{result.title.accessMode}}
|
||||
</span>{{' '}}
|
||||
<span *ngIf="properties.environment === 'production' && result.title &&
|
||||
result.title.accessMode && result.title.accessMode.toLowerCase() !== 'not available'"
|
||||
class="uk-label custom-label" [ngClass]="'label-' + accessClass(result.title.accessMode)"
|
||||
title="Access Mode">
|
||||
{{result.title.accessMode}}
|
||||
</span>{{' '}}
|
||||
<span *ngIf="result.openAccessMandatePublications && (!result.openAccessMandateDatasets)"
|
||||
class="uk-label custom-label label-open"
|
||||
title="Open Access mandate for Publications">
|
||||
Open Access mandate for Publications
|
||||
</span>{{' '}}
|
||||
<span
|
||||
*ngIf="result.openAccessMandateDatasets != undefined && result.openAccessMandateDatasets && (result.openAccessMandatePublications == undefined || !result.openAccessMandatePublications)"
|
||||
class="uk-label custom-label label-open " title="Open Access mandate for Research Data">
|
||||
Open Access mandate for Research Data
|
||||
</span>{{' '}}
|
||||
<span
|
||||
*ngIf="result.openAccessMandatePublications != undefined && result.openAccessMandatePublications && result.openAccessMandateDatasets != undefined && result.openAccessMandateDatasets"
|
||||
class="uk-label custom-label label-open "
|
||||
title="Open Access mandate for Publications and Research Data">
|
||||
Open Access mandate for Publications and Research Data
|
||||
</span>{{' '}}
|
||||
<span *ngIf="properties.environment !== 'production' && result.languages && result.languages.length > 0">
|
||||
<span *ngFor="let language of result.languages" class="uk-label custom-label label-language "
|
||||
title="Language">
|
||||
<highlight [field]="'language'" [keywords]="keywords" [element]="language"></highlight>
|
||||
</span>{{' '}}
|
||||
</span>
|
||||
<span
|
||||
*ngIf="properties.environment === 'production' && result.languages && removeUnknown(result.languages).length > 0">
|
||||
<span *ngFor="let language of removeUnknown(result.languages)" class="uk-label custom-label label-language "
|
||||
title="Language">
|
||||
<highlight [field]="'language'" [keywords]="keywords" [element]="language"></highlight>
|
||||
</span>{{' '}}
|
||||
</span>
|
||||
<span *ngIf="result.title && result.title.sc39" class="uk-label custom-label label-sc39 "
|
||||
title="Special Clause 39">Special Clause 39
|
||||
</span>{{' '}}
|
||||
<span *ngIf="result.compatibility && result.compatibility != ''"
|
||||
class="uk-label custom-label label-compatibility"
|
||||
title="Compatibility">
|
||||
{{result.compatibility}}
|
||||
</span>{{' '}}
|
||||
</div>
|
||||
<!-- Publisher -->
|
||||
<div *ngIf="result.publisher && result.publisher != ''" class="uk-text-small uk-margin-small-bottom">
|
||||
<span class="uk-text-muted">Publisher: </span>
|
||||
<highlight [field]="'publisher'" [keywords]="keywords" [element]="result.publisher"></highlight>
|
||||
</div>
|
||||
<!-- Country -->
|
||||
<div *ngIf="result.countriesForResults && result.countriesForResults.length > 0"
|
||||
class="uk-text-small uk-margin-small-bottom">
|
||||
<span class="uk-text-muted">Country: </span>
|
||||
<highlight [field]="'country'" [keywords]="keywords" [element]="result.countriesForResults.join(', ')"></highlight>
|
||||
</div>
|
||||
<div *ngIf="result.country && result.country != ''" class="uk-text-small uk-margin-small-bottom">
|
||||
<span class="uk-text-muted">Country: </span>
|
||||
<highlight [field]="'country'" [keywords]="keywords" [element]="result.country"></highlight>
|
||||
</div>
|
||||
<div *ngIf="result.countries && result.countries.length > 0" class="uk-text-small uk-margin-small-bottom">
|
||||
<span class="uk-text-muted">Country: </span><span
|
||||
*ngFor="let country of result['countries'].slice(0,10) let i = index">
|
||||
{{country}}{{(i < (result['countries'].slice(0, 10).length - 1)) ? ", " : ""}}
|
||||
{{(i == result['countries'].slice(0, 10).length - 1 && result['countries'].length > 10) ? "..." : ""}}</span>
|
||||
</div>
|
||||
<!-- Programming Languages -->
|
||||
<div *ngIf="result.programmingLanguages && result.programmingLanguages.length > 0"
|
||||
class="uk-text-small uk-margin-small-bottom">
|
||||
<span class="uk-text-muted">Programming language: </span>{{result.programmingLanguages.join(", ")}}
|
||||
</div>
|
||||
<!-- Projects -->
|
||||
<div *ngIf="result.projects && result.projects.length > 0" class="uk-text-small uk-margin-small-bottom">
|
||||
<span class="uk-text-muted"> Project: </span>
|
||||
<span *ngFor="let project of result['projects'].slice(0,10) let i=index">
|
||||
<span>
|
||||
{{project['funderShortname'] ? project['funderShortname'] : project['funderName']}}
|
||||
</span>
|
||||
<span *ngIf="project.acronym || project.title">
|
||||
| {{ project['acronym'] ? project['acronym'] : (project['title'].length > 25 ?
|
||||
project['title'].substring(0, 25) + '...' : project['title'])}}
|
||||
</span>
|
||||
<span *ngIf="project.code"> ({{project.code}})</span>
|
||||
<span *ngIf="i < result['projects'].length-1">,</span>
|
||||
</span>
|
||||
<span *ngIf="result['projects'].length > 10">...</span>
|
||||
</div>
|
||||
<!-- Organizations -->
|
||||
<div *ngIf="showOrganizations && result['organizations'] && result['organizations'].length > 0"
|
||||
class="uk-text-small uk-margin-small-bottom">
|
||||
<span class="uk-text-muted">Organization: </span>
|
||||
<span *ngFor="let organization of result['organizations'].slice(0,10) let i=index">
|
||||
<span>{{organization.name}}</span>
|
||||
<span *ngIf="(i < result['organizations'].length-1) && (i < 9)">,</span>
|
||||
</span>
|
||||
<span *ngIf="result['organizations'].length > 10">...</span>
|
||||
</div>
|
||||
<!-- Website URL -->
|
||||
<div *ngIf="result.websiteURL && result.websiteURL != ''" class="uk-text-small uk-margin-small-bottom">
|
||||
<span class="uk-text-muted">Website URL: </span>
|
||||
<span>
|
||||
<a href="{{result.websiteURL}}" target="_blank" class="custom-external custom-icon">
|
||||
{{result.websiteURL}}
|
||||
</a>
|
||||
</div>
|
||||
<span *ngIf="result.types && result.types.length > 0"
|
||||
[class]="'uk-label custom-label label-blue label-'+result.entityType"
|
||||
title="Type">{{result.types.join(", ")}}</span>{{' '}}
|
||||
<span *ngIf="result.programmingLanguages && result.programmingLanguages.length > 0" class="uk-label custom-label label-progrLanguage " title="Programming Language">{{result.programmingLanguages.join(", ")}}</span>{{' '}}
|
||||
<span *ngIf="result.languages && result.languages.length > 0" class="uk-label custom-label label-language " title="Language">{{result.languages.join(", ")}}</span>{{' '}}
|
||||
<span *ngIf="result.countriesForResults && result.countriesForResults.length > 0" class="uk-label custom-label label-country " title="Country">{{result.countriesForResults.join(", ")}}</span>{{' '}}
|
||||
<span *ngIf="result.title && result.title.accessMode" [class]="'uk-label custom-label label-'+ result.title.accessMode " title="Access Mode">{{result.title.accessMode}}</span>{{' '}}
|
||||
<span *ngIf="result['funderShortname']" class="uk-label custom-label label-funder " title="Funder">{{result['funderShortname']}}</span>{{' '}}
|
||||
<span *ngIf="result.openAccessMandatePublications != undefined && result.openAccessMandatePublications && (result.openAccessMandateDatasets == undefined || !result.openAccessMandateDatasets)"
|
||||
class="uk-label custom-label label-openaccessmandate " title="Open Access mandate for Publications">Open Access mandate for Publications</span>{{' '}}
|
||||
<span *ngIf="result.openAccessMandateDatasets != undefined && result.openAccessMandateDatasets && (result.openAccessMandatePublications == undefined || !result.openAccessMandatePublications)"
|
||||
class="uk-label custom-label label-openaccessmandate " title="Open Access mandate for Research Data">Open Access mandate for Research Data</span>{{' '}}
|
||||
<span *ngIf="result.openAccessMandatePublications != undefined && result.openAccessMandatePublications && result.openAccessMandateDatasets != undefined && result.openAccessMandateDatasets"
|
||||
class="uk-label custom-label label-openaccessmandate " title="Open Access mandate for Publications and Research Data">Open Access mandate for Publications and Research Data</span>{{' '}}
|
||||
|
||||
<span *ngIf="result.title && result.title.sc39" class="uk-label custom-label label-sc39 " title="Special Clause 39">Special Clause 39</span>{{' '}}
|
||||
<div class="uk-margin-small">
|
||||
<!-- <span *ngIf="result['authors'] != undefined" class="resultsAuthors uk-margin-small-top" style="font-style: italic;">-->
|
||||
<!-- <span *ngFor="let author of result['authors'].slice(0,15)">-->
|
||||
<!-- {{author}};-->
|
||||
<!-- </span>-->
|
||||
<!-- <span *ngIf="result['authors'].length > 15">...</span>-->
|
||||
<!-- </span>-->
|
||||
<showAuthors [authors]="result['authors']" [authorsLimit]=15 [showAll]=false></showAuthors>
|
||||
<span *ngIf="result.year != undefined && result.year != ''">
|
||||
({{result.year}})
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div *ngIf="result.publisher != undefined && result.publisher != ''"><span class="uk-text-bold">Publisher:</span> {{result.publisher}}</div>
|
||||
<span *ngIf="result['type'] != undefined && result['type'] != ''" class="uk-label custom-label label-blue label-dataprovider" title="Type"> {{result['type']}}</span>{{' '}}
|
||||
<span *ngIf="result['compatibility'] != undefined && result['compatibility'] != ''" class="uk-label custom-label label-compatibility" title="Compatibility">{{result.compatibility}}</span>{{' '}}
|
||||
<span *ngIf="result.country != undefined && result.country != ''" class="uk-label custom-label label-country" title="Country"> {{result.country}}</span>{{' '}}
|
||||
<div *ngIf="result['projects'] != undefined">
|
||||
<span> Project: </span>
|
||||
<span *ngFor="let project of result['projects'].slice(0,15) let i=index">
|
||||
<a *ngIf="project.id" [queryParams]="{projectId: project.id}" routerLinkActive="router-link-active" routerLink="/search/project">
|
||||
{{project['funderShortname']?project['funderShortname']:project['funderName']}}
|
||||
| {{ project['acronym']?project['acronym']:(project['title'].length>25?project['title'].substring(0,25)+'...':project['title'])}} ({{project.code}})</a><span
|
||||
|
||||
*ngIf="!project.id">{{project['funderShortname']?project['funderShortname']:project['funderName']}}<span
|
||||
*ngIf="project['acronym'] || project['title']"> | {{ project['acronym']?project['acronym']:(project['title'].length>25?project['title'].substring(0,25)+'...':project['title'])}}</span><span
|
||||
*ngIf="project.code">({{project.code}})</span></span><span
|
||||
|
||||
*ngIf="i < result['projects'].length-1">,</span>
|
||||
</span>
|
||||
<span *ngIf="result['projects'].length > 15">...</span>
|
||||
</div>
|
||||
|
||||
<div *ngIf="result.description">
|
||||
<div class="text-justify descriptionText">
|
||||
{{result.description}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<mark *ngIf="result.embargoEndDate != undefined && result.embargoEndDate != ''">Embargo End Date: {{result.embargoEndDate}}</mark>
|
||||
<div *ngIf="result.startYear && result.endYear"> Start year: {{result.startYear}} - End year: {{result.endYear}}</div>
|
||||
<div *ngIf="showOrganizations && result['organizations'] != undefined && result['organizations'].length > 0">
|
||||
<span> Organization: </span>
|
||||
<span *ngFor="let organization of result['organizations'].slice(0,10) let i=index">
|
||||
<a *ngIf="organization.id" [queryParams]="{organizationId: organization.id}" routerLinkActive="router-link-active" routerLink="/search/organization">
|
||||
{{organization.name}}</a><span
|
||||
|
||||
*ngIf="!organization.id">
|
||||
{{organization.name}}</span><span
|
||||
|
||||
*ngIf="(i < result['organizations'].length-1) && (i < 9)">,</span>
|
||||
</span>
|
||||
<span *ngIf="result['organizations'].length > 10">...</span>
|
||||
</div>
|
||||
|
||||
<div *ngIf="result['countries'] && result['countries'].length > 0">
|
||||
Country: <span *ngFor="let country of result['countries'].slice(0,10) let i = index">{{country}}{{(i < ( result['countries'].slice(0,10).length-1))?", ":""}}{{(i == result['countries'].slice(0,10).length-1 && result['countries'].length > 10)?"...":""}}</span>
|
||||
</div>
|
||||
<div *ngIf="result['websiteURL'] != undefined && result['websiteURL'] != ''">
|
||||
<span>Website URL: </span>
|
||||
<span>
|
||||
<a href="{{result['websiteURL']}}" target="_blank" class="custom-external custom-icon">
|
||||
{{result['websiteURL']}}
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<div *ngIf="result['OAIPMHURL'] != undefined && result['OAIPMHURL'] != ''">
|
||||
<span>OAI-PMH URL: </span>
|
||||
<span>
|
||||
<a href="{{result['OAIPMHURL']}}" target="_blank" class="custom-external custom-icon">
|
||||
{{result['OAIPMHURL']}}
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div *ngIf="showSubjects && result['subjects'] && result['subjects'].length > 0">
|
||||
Subject: <span *ngFor="let subject of result['subjects'].slice(0,10) let i = index">{{subject}}{{(i < ( result['subjects'].slice(0,10).length-1))?", ":""}}{{(i == result['subjects'].slice(0,10).length-1 && result['subjects'].length > 10)?"...":""}}</span>
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
</span>
|
||||
</div>
|
||||
<!-- OAI-PMH URL-->
|
||||
<div *ngIf="result.OAIPMHURL && result.OAIPMHURL != ''" class="uk-text-small uk-margin-small-bottom">
|
||||
<span class="uk-text-muted">OAI-PMH URL: </span>
|
||||
<span>
|
||||
<a href="{{result.OAIPMHURL}}" target="_blank" class="custom-external custom-icon">
|
||||
{{result.OAIPMHURL}}
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<!-- Subjects -->
|
||||
<div *ngIf="showSubjects && result.subjects && result.subjects.length > 0"
|
||||
class="uk-text-small uk-margin-small-bottom">
|
||||
<span class="uk-text-muted">Subject: </span>
|
||||
<span *ngFor="let subject of result.subjects.slice(0,10) let i = index">{{subject}}
|
||||
{{(i < (result.subjects.slice(0, 10).length - 1)) ? ", " : ""}}
|
||||
{{(i == result.subjects.slice(0, 10).length - 1 && result.subjects.length > 10) ? "..." : ""}}
|
||||
</span>
|
||||
</div>
|
||||
<!-- Description -->
|
||||
<div *ngIf="result.description" class="uk-margin-small-bottom multi-line-ellipsis lines-3">
|
||||
<p class="uk-text-small">
|
||||
<highlight [field]="'description'" [keywords]="keywords" [element]="result.description"></highlight>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -1,60 +1,95 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {SearchResult} from '../../utils/entities/searchResult';
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {SearchResult} from '../../utils/entities/searchResult';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {RouterHelper} from '../../utils/routerHelper.class';
|
||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {Keyword} from "./highlight/highlight.component";
|
||||
|
||||
@Component({
|
||||
selector: 'search-result',
|
||||
templateUrl:'searchResult.component.html'
|
||||
selector: 'search-result',
|
||||
templateUrl: 'searchResult.component.html'
|
||||
})
|
||||
|
||||
export class SearchResultComponent {
|
||||
@Input() results: SearchResult[];
|
||||
@Input() status: number;
|
||||
@Input() type: string;
|
||||
@Input() showLoading: boolean = false;
|
||||
@Input() showSubjects: boolean = false;
|
||||
@Input() showOrganizations: boolean = true;
|
||||
@Input() custom_class: string = "search-results";
|
||||
@Input() properties:EnvProperties;
|
||||
|
||||
|
||||
public urlParam: string;
|
||||
public linkToAdvancedSearchPage: string;
|
||||
public errorCodes:ErrorCodes = new ErrorCodes();
|
||||
public routerHelper:RouterHelper = new RouterHelper();
|
||||
public errorMessage: string = "No results found";
|
||||
constructor () {}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
if(this.type == "publication") {
|
||||
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedPublications;
|
||||
this.urlParam = "articleId";
|
||||
} else if(this.type == "dataset") {
|
||||
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDatasets;
|
||||
this.urlParam = "datasetId";
|
||||
} else if(this.type == "software") {
|
||||
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedSoftware;
|
||||
this.urlParam = "softwareId";
|
||||
} else if(this.type == "other") {
|
||||
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrps;
|
||||
this.urlParam = "orpId";
|
||||
} else if(this.type == "project") {
|
||||
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedProjects;
|
||||
this.urlParam = "projectId";
|
||||
} else if(this.type == "organization") {
|
||||
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrganizations;
|
||||
this.urlParam = "organizationId";
|
||||
} else if(this.type == "dataprovider") {
|
||||
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDataProviders;
|
||||
this.urlParam = "datasourceId";
|
||||
}
|
||||
|
||||
|
||||
export class SearchResultComponent implements OnInit {
|
||||
@Input() keywords: Keyword[];
|
||||
@Input() results: SearchResult[];
|
||||
@Input() status: number;
|
||||
@Input() type: string;
|
||||
@Input() showLoading: boolean = false;
|
||||
@Input() showSubjects: boolean = false;
|
||||
@Input() showOrganizations: boolean = true;
|
||||
@Input() custom_class: string = "search-results";
|
||||
@Input() properties: EnvProperties;
|
||||
public urlParam: string;
|
||||
public errorCodes: ErrorCodes = new ErrorCodes();
|
||||
public routerHelper: RouterHelper = new RouterHelper();
|
||||
public errorMessage: string = "No results found";
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.type == "project") {
|
||||
this.urlParam = "projectId";
|
||||
} else if (this.type == "organization") {
|
||||
this.urlParam = "organizationId";
|
||||
} else if (this.type == "dataprovider") {
|
||||
this.urlParam = "datasourceId";
|
||||
}
|
||||
|
||||
public quote(params: string):string {
|
||||
return '"'+params+'"';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns query param name base on result's entity type
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public queryParamName(type: string): string {
|
||||
if (type === "publication") {
|
||||
return "articleId";
|
||||
} else if (type === "dataset") {
|
||||
return "datasetId";
|
||||
} else if (type === "software") {
|
||||
return "softwareId";
|
||||
} else if (type === "other") {
|
||||
return "orpId";
|
||||
}
|
||||
}
|
||||
|
||||
public getTypeName(type: string): string {
|
||||
if (type === "dataset") {
|
||||
return "research data";
|
||||
} else if (type === "other") {
|
||||
return "other research outcome";
|
||||
} else if (type === "dataprovider") {
|
||||
return "content provider";
|
||||
} else {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
public removeUnknown(array: string[], type: string = null): string[] {
|
||||
if (type) {
|
||||
return this.removeDuplicates(array, type).filter(value => value.toLowerCase() !== 'unknown');
|
||||
} else {
|
||||
return array.filter(value => value.toLowerCase() !== 'unknown');
|
||||
}
|
||||
}
|
||||
|
||||
public removeDuplicates(array: string[], type: string): string[] {
|
||||
type = this.getTypeName(type);
|
||||
return array.filter(value => value.toLowerCase() !== type);
|
||||
}
|
||||
|
||||
public quote(params: string): string {
|
||||
return '"' + params + '"';
|
||||
}
|
||||
|
||||
public accessClass(accessMode: string): string {
|
||||
if(accessMode.toLowerCase().indexOf('open') !== -1) {
|
||||
return 'open';
|
||||
} else if(accessMode.toLowerCase() === 'not available') {
|
||||
return 'unknown';
|
||||
} else {
|
||||
return 'closed';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,14 @@ import {ErrorMessagesModule} from '../../utils/errorMessages.module';
|
|||
import {SearchResultComponent} from './searchResult.component';
|
||||
import {ApprovedByCommunityModule} from '../../connect/approvedByCommunity/approved.module';
|
||||
import {ShowAuthorsModule} from "../../utils/authors/showAuthors.module";
|
||||
import {HighlightModule} from "./highlight/highlight.module";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
RouterModule, ErrorMessagesModule,
|
||||
ApprovedByCommunityModule,
|
||||
ShowAuthorsModule
|
||||
ShowAuthorsModule, HighlightModule
|
||||
],
|
||||
declarations: [
|
||||
SearchResultComponent
|
||||
|
|
|
@ -35,11 +35,11 @@
|
|||
<span *ngIf="result.title && result.title.accessMode" [class]="'uk-label custom-label label-'+ result.title.accessMode " title="Access Mode">{{result.title.accessMode}}</span>
|
||||
<span *ngIf="result['funderShortname']" class="uk-label custom-label label-funder " title="Funder">{{result['funderShortname']}}</span>
|
||||
<span *ngIf="result.openAccessMandatePublications != undefined && result.openAccessMandatePublications && (result.openAccessMandateDatasets == undefined || !result.openAccessMandateDatasets)"
|
||||
class="uk-label custom-label label-openaccessmandate " title="Open Access mandate for Publications">Open Access mandate for Publications</span>
|
||||
class="uk-label custom-label label-open " title="Open Access mandate for Publications">Open Access mandate for Publications</span>
|
||||
<span *ngIf="result.openAccessMandateDatasets != undefined && result.openAccessMandateDatasets && (result.openAccessMandatePublications == undefined || !result.openAccessMandatePublications)"
|
||||
class="uk-label custom-label label-openaccessmandate " title="Open Access mandate for Research Data">Open Access mandate for Research Data</span>
|
||||
class="uk-label custom-label label-open " title="Open Access mandate for Research Data">Open Access mandate for Research Data</span>
|
||||
<span *ngIf="result.openAccessMandatePublications != undefined && result.openAccessMandatePublications && result.openAccessMandateDatasets != undefined && result.openAccessMandateDatasets"
|
||||
class="uk-label custom-label label-openaccessmandate " title="Open Access mandate for Publications and Research Data">Open Access mandate for Publications and Research Data</span>
|
||||
class="uk-label custom-label label-open " title="Open Access mandate for Publications and Research Data">Open Access mandate for Publications and Research Data</span>
|
||||
<div *ngIf="result.publisher != undefined && result.publisher != ''"><span class="uk-text-bold">Publisher:</span> {{result.publisher}}</div>
|
||||
<span *ngIf="result['type'] != undefined && result['type'] != ''" class="uk-label custom-label label-blue label-dataprovider" title="Type"> {{result['type']}}</span>
|
||||
<span *ngIf="result['compatibility'] != undefined && result['compatibility'] != ''" class="uk-label custom-label label-compatibility" title="Compatibility">{{result.compatibility}}</span>
|
||||
|
|
|
@ -201,10 +201,9 @@ export class SearchResearchResultsService {
|
|||
}
|
||||
|
||||
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
if(resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classid")) {
|
||||
result['title'].accessMode = resData['bestaccessright'].classid;
|
||||
if(resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classname")) {
|
||||
result['title'].accessMode = resData['bestaccessright'].classname;
|
||||
}
|
||||
|
||||
if(resData['rels'].hasOwnProperty("rel")) {
|
||||
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
||||
|
||||
|
@ -251,8 +250,9 @@ export class SearchResearchResultsService {
|
|||
result.description = result.description.substring(0, this.sizeOfDescription) + "...";
|
||||
}
|
||||
|
||||
|
||||
result.embargoEndDate = resData.embargoenddate;
|
||||
if(resData.embargoenddate && resData.embargoenddate != '') {
|
||||
result.embargoEndDate = new Date(resData.embargoenddate);
|
||||
}
|
||||
|
||||
if(!Array.isArray(resData.publisher)) {
|
||||
result.publisher = resData.publisher;
|
||||
|
|
|
@ -4,25 +4,28 @@ import {HelperFunctions} from '../HelperFunctions.class';
|
|||
import {RouterHelper} from "../routerHelper.class";
|
||||
import {EnvProperties} from '../properties/env-properties';
|
||||
import {isPlatformBrowser} from "@angular/common";
|
||||
import {Author} from "../entities/searchResult";
|
||||
import {Keyword} from "../../searchPages/searchUtils/highlight/highlight.component";
|
||||
|
||||
@Component({
|
||||
selector: 'showAuthors',
|
||||
template: `
|
||||
<div *ngIf="authors != undefined" class="uk-height-max-small uk-overflow-auto">
|
||||
<!--div *ngIf="showAll && numberOfAuthors > authorsLimit">
|
||||
<a (click)="numberOfAuthors = authorsLimit;">View less authors</a>
|
||||
</div-->
|
||||
|
||||
<span *ngFor="let author of authors.slice(0,numberOfAuthors) let i=index">
|
||||
<i *ngIf="!author.orcid || (properties.environment == 'production') || !testBrowser">{{author.fullName}}</i
|
||||
><a *ngIf="author.orcid && (properties.environment != 'production') && testBrowser"
|
||||
class="cursor-default"> <img src="assets/common-assets/common/ORCIDiD_icon16x16.png" alt="">{{" "}}
|
||||
<i>{{author.fullName}}</i></a
|
||||
><div *ngIf="author.orcid && (properties.environment != 'production')"
|
||||
class=" default-dropdown uk-margin-remove-top uk-padding-medium"
|
||||
uk-dropdown="pos: bottom-left; mode:click" style="min-width: 70px !important;">
|
||||
<span *ngIf="!author.orcid || (properties.environment == 'production') || !testBrowser"
|
||||
class="uk-text-small">
|
||||
<highlight [element]="author.fullName" [keywords]="keywords" [field]="'author'"></highlight>
|
||||
</span>
|
||||
<a *ngIf="author.orcid && (properties.environment != 'production') && testBrowser"
|
||||
class="cursor-default"> <img src="assets/common-assets/common/ORCIDiD_icon16x16.png" alt="">{{" "}}
|
||||
<span class="uk-text-small">
|
||||
<highlight [element]="author.fullName" [keywords]="keywords" [field]="'author'"></highlight>
|
||||
</span>
|
||||
</a>
|
||||
<div *ngIf="author.orcid && (properties.environment != 'production')"
|
||||
class="default-dropdown uk-margin-remove-top uk-padding-medium"
|
||||
uk-dropdown="pos: bottom-left; mode:click" style="min-width: 70px !important;">
|
||||
<b class="uk-margin-top">{{author.fullName}}</b>
|
||||
|
||||
<div>
|
||||
<div class="uk-text-muted uk-margin-small-bottom uk-margin-small-top">ORCID</div>
|
||||
<span><input #element class="uk-padding-small uk-disabled" name="code"
|
||||
|
@ -82,33 +85,30 @@ import {isPlatformBrowser} from "@angular/common";
|
|||
view all {{authors.length | number}} authors
|
||||
</a>
|
||||
</span>
|
||||
<!--span *ngIf="showAll && numberOfAuthors > authorsLimit">
|
||||
<a (click)="numberOfAuthors = authorsLimit; scroll()">View less authors</a>
|
||||
</span-->
|
||||
</div>
|
||||
<div *ngIf="authors != undefined && showAll && numberOfAuthors > authorsLimit" class="uk-width-1-1 uk-text-right">
|
||||
<!--scroll()-->
|
||||
<a (click)="numberOfAuthors = authorsLimit;">View less authors</a>
|
||||
</div>
|
||||
`
|
||||
|
||||
|
||||
})
|
||||
|
||||
export class ShowAuthorsComponent {
|
||||
@Input() authors: {"fullName": string, "orcid": string}[];
|
||||
@Input() authors: Author[];
|
||||
@Input() authorsLimit: number = 30;
|
||||
@Input() showAll: boolean = true;
|
||||
|
||||
@Input() keywords: Keyword[];
|
||||
|
||||
public numberOfAuthors: number;
|
||||
public properties:EnvProperties;
|
||||
public routerHelper:RouterHelper = new RouterHelper();
|
||||
|
||||
public properties: EnvProperties;
|
||||
public routerHelper: RouterHelper = new RouterHelper();
|
||||
|
||||
testBrowser: boolean;
|
||||
|
||||
constructor (private route: ActivatedRoute, @Inject(PLATFORM_ID) private platformId: string) {
|
||||
|
||||
constructor(private route: ActivatedRoute, @Inject(PLATFORM_ID) private platformId: string) {
|
||||
this.testBrowser = isPlatformBrowser(platformId);
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties = data.envSpecific;
|
||||
|
@ -116,17 +116,17 @@ export class ShowAuthorsComponent {
|
|||
this.numberOfAuthors = this.authorsLimit;
|
||||
}
|
||||
|
||||
copyToClipboard(element: HTMLInputElement){
|
||||
copyToClipboard(element: HTMLInputElement) {
|
||||
element.select();
|
||||
if(typeof document !== 'undefined') {
|
||||
if (typeof document !== 'undefined') {
|
||||
document.execCommand('copy');
|
||||
}
|
||||
}
|
||||
|
||||
public quote(params: string):string {
|
||||
return '"'+params+'"';
|
||||
|
||||
public quote(params: string): string {
|
||||
return '"' + params + '"';
|
||||
}
|
||||
|
||||
|
||||
public scroll() {
|
||||
HelperFunctions.scroll();
|
||||
}
|
||||
|
|
|
@ -4,10 +4,11 @@ import { FormsModule } from '@angular/forms';
|
|||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import {ShowAuthorsComponent} from './showAuthors.component';
|
||||
import {HighlightModule} from "../../searchPages/searchUtils/highlight/highlight.module";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule, RouterModule
|
||||
CommonModule, FormsModule, RouterModule, HighlightModule
|
||||
],
|
||||
declarations: [
|
||||
ShowAuthorsComponent
|
||||
|
|
|
@ -1,56 +1,79 @@
|
|||
import {CommunityInfo} from "../../connect/community/communityInfo";
|
||||
export class Project {
|
||||
funderShortname: string;
|
||||
funderName: string;
|
||||
acronym: string;
|
||||
title: string;
|
||||
code: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export class Author {
|
||||
fullName: string;
|
||||
orcid: string;
|
||||
}
|
||||
|
||||
export class ResultTitle {
|
||||
name: string;
|
||||
accessMode: string;
|
||||
sc39: string;
|
||||
}
|
||||
|
||||
export class Organization {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export class SearchResult {
|
||||
title: { "name": string, "accessMode": string, "sc39": string};
|
||||
id:string;
|
||||
DOI:string;
|
||||
|
||||
//publications & datasets & orp & software & organizations:
|
||||
projects: {"funderShortname": string, "funderName": string, "acronym": string, "title": string, "code": string, "id": string}[];
|
||||
|
||||
//datasets & orp & publications & software
|
||||
description: string;
|
||||
year: string;
|
||||
embargoEndDate: string;
|
||||
authors: {"fullName": string, "orcid": string}[];
|
||||
countriesForResults: string[];
|
||||
languages: string[];
|
||||
|
||||
//datasets & orp & software:
|
||||
publisher: string;
|
||||
|
||||
//software
|
||||
programmingLanguages: string[];
|
||||
|
||||
//dataproviders & projects:
|
||||
organizations: { "name": string, "id": string}[];
|
||||
|
||||
//projects:
|
||||
acronym: string;
|
||||
code: string;
|
||||
//funders: {"funderShortname": string, "funderName": string}[]; // not used
|
||||
funderShortname: string;
|
||||
startYear:number;
|
||||
endYear:number;
|
||||
openAccessMandatePublications: boolean;
|
||||
openAccessMandateDatasets: boolean;
|
||||
|
||||
//organizations:
|
||||
country: string;
|
||||
|
||||
//dataproviders:
|
||||
englishname: string;
|
||||
type: string;
|
||||
websiteURL: string;
|
||||
OAIPMHURL: string;
|
||||
compatibility: string;
|
||||
compatibilityUNKNOWN: boolean;
|
||||
countries: string[];
|
||||
subjects: string[];
|
||||
|
||||
entityType: string;
|
||||
types: string[];
|
||||
|
||||
constructor(){}
|
||||
|
||||
title: ResultTitle;
|
||||
id: string;
|
||||
DOI: string;
|
||||
|
||||
//publications & datasets & orp & software & organizations:
|
||||
projects: Project[];
|
||||
|
||||
//datasets & orp & publications & software
|
||||
description: string;
|
||||
year: string;
|
||||
embargoEndDate: Date | string;
|
||||
authors: Author[];
|
||||
countriesForResults: string[];
|
||||
languages: string[];
|
||||
|
||||
//datasets & orp & software:
|
||||
publisher: string;
|
||||
|
||||
//software
|
||||
programmingLanguages: string[];
|
||||
|
||||
//dataproviders & projects:
|
||||
organizations: Organization[];
|
||||
|
||||
//projects:
|
||||
acronym: string;
|
||||
code: string;
|
||||
funderShortname: string;
|
||||
startYear: number;
|
||||
endYear: number;
|
||||
openAccessMandatePublications: boolean;
|
||||
openAccessMandateDatasets: boolean;
|
||||
|
||||
//organizations:
|
||||
country: string;
|
||||
|
||||
//dataproviders:
|
||||
englishname: string;
|
||||
type: string;
|
||||
websiteURL: string;
|
||||
OAIPMHURL: string;
|
||||
compatibility: string;
|
||||
compatibilityUNKNOWN: boolean;
|
||||
countries: string[];
|
||||
subjects: string[];
|
||||
|
||||
entityType: string;
|
||||
types: string[];
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,111 +1,100 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Http, Response} from '@angular/http';
|
||||
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
|
||||
import {Observable, throwError, of } from 'rxjs';
|
||||
import {Observable, throwError, of} from 'rxjs';
|
||||
import {AutoCompleteValue} from '../../searchPages/searchUtils/searchHelperClasses.class';
|
||||
|
||||
import{EnvProperties} from '../properties/env-properties';
|
||||
import {EnvProperties} from '../properties/env-properties';
|
||||
import {catchError, map} from "rxjs/operators";
|
||||
|
||||
@Injectable()
|
||||
export class ISVocabulariesService {
|
||||
constructor(private http: HttpClient ) {}
|
||||
|
||||
getVocabularyByType(field:string,entity:string, properties:EnvProperties):any{
|
||||
//console.log("getVocabulary field: "+ field + " for entity: "+ entity);
|
||||
var file = "";
|
||||
var vocabulary = "";
|
||||
if( field == "lang"){
|
||||
// file="languages.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:languages.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
}else if ( field == "type" && (entity == "publication")){
|
||||
// file = "publicationTypes.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:publication_resource.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
|
||||
}else if ( field == "type" && (entity == "dataset")){
|
||||
// file = "dnet:dataCite_resource.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:dataCite_resource.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
|
||||
}else if ( field == "type" && (entity == "software" || entity == "other")){
|
||||
return of([]);
|
||||
|
||||
}else if( field == "access" && (entity == "publication" || entity == "dataset" || entity == "software" || entity == "other")){
|
||||
// file= "accessMode.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:access_modes.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
|
||||
} else if( (field == "type") && (entity == "dataprovider")){
|
||||
// file = "dataProviderType.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:datasource_typologies.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
|
||||
} else if( field == "compatibility" && (entity == "dataprovider")){
|
||||
// file = "dataProviderCompatibility.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:datasourceCompatibilityLevel.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
|
||||
} else if( field == "country" ){
|
||||
// file = "countries.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:countries.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
}
|
||||
|
||||
getVocabularyByType(field: string, entity: string, properties: EnvProperties): any {
|
||||
//console.log("getVocabulary field: "+ field + " for entity: "+ entity);
|
||||
var file = "";
|
||||
var vocabulary = "";
|
||||
if (field == "lang") {
|
||||
// file="languages.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:languages.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
} else if (field == "type" && (entity == "publication")) {
|
||||
// file = "publicationTypes.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:publication_resource.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
|
||||
} else if (field == "type" && (entity == "dataset")) {
|
||||
// file = "dnet:dataCite_resource.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:dataCite_resource.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
|
||||
} else if (field == "type" && (entity == "software" || entity == "other")) {
|
||||
return of([]);
|
||||
|
||||
} else if (field == "access" && (entity == "publication" || entity == "dataset" || entity == "software" || entity == "other")) {
|
||||
// file= "accessMode.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:access_modes.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
|
||||
} else if ((field == "type") && (entity == "dataprovider")) {
|
||||
// file = "dataProviderType.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:datasource_typologies.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
|
||||
} else if (field == "compatibility" && (entity == "dataprovider")) {
|
||||
// file = "dataProviderCompatibility.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:datasourceCompatibilityLevel.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
|
||||
} else if (field == "country") {
|
||||
// file = "countries.json";
|
||||
// return this.getVocabularyFromFile(file);
|
||||
vocabulary = "dnet:countries.json";
|
||||
return this.getVocabularyFromService(vocabulary, properties);
|
||||
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
getVocabularyFromService(vocabularyName: string, properties: EnvProperties): any {
|
||||
let url = properties.vocabulariesAPI + vocabularyName;
|
||||
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => res['terms']))
|
||||
.pipe(map(res => this.parse(res, vocabularyName)))
|
||||
.pipe(catchError(this.handleError));
|
||||
|
||||
}
|
||||
|
||||
parse(data: any, vocabularyName: string): AutoCompleteValue[] {
|
||||
var array: AutoCompleteValue[] = []
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var value: AutoCompleteValue = new AutoCompleteValue();
|
||||
value.id = data[i].englishName;//data[i].code;
|
||||
if (vocabularyName == 'dnet:countries.json') { //use Country code instead of country name
|
||||
value.id = data[i].code;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
// getVocabularyFromFile (file:string):AutoCompleteValue[] {
|
||||
// var lang = JSON.parse(JSON.stringify(require('../utils/vocabularies/'+file)));
|
||||
// return this.parse(lang["terms"]);
|
||||
// }
|
||||
getVocabularyFromService (vocabularyName:string, properties:EnvProperties):any {
|
||||
let url = properties.vocabulariesAPI + vocabularyName;
|
||||
//console.log(url);
|
||||
|
||||
// return this.http.get(url).toPromise()
|
||||
// .then(request =>
|
||||
// {
|
||||
// request = request.json()['terms'];
|
||||
// var results:AutoCompleteValue[] = this.parse(request);
|
||||
// console.log("Get vocabulary : "+ vocabularyName+ " - get " +results.length+ "results");
|
||||
// return results;
|
||||
// });
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => res['terms']))
|
||||
.pipe(map(res => this.parse(res, vocabularyName)))
|
||||
.pipe(catchError(this.handleError));
|
||||
|
||||
}
|
||||
|
||||
parse (data: any, vocabularyName: string):AutoCompleteValue[] {
|
||||
var array:AutoCompleteValue[] =[]
|
||||
for(var i = 0; i < data.length; i++){
|
||||
var value:AutoCompleteValue = new AutoCompleteValue();
|
||||
value.id = data[i].englishName;//data[i].code;
|
||||
if(vocabularyName == 'dnet:countries.json'){ //use Country code instead of country name
|
||||
value.id = data[i].code;
|
||||
}
|
||||
value.label = data[i].englishName;
|
||||
array.push(value);
|
||||
}
|
||||
|
||||
return array;
|
||||
|
||||
}
|
||||
private handleError (error: HttpErrorResponse) {
|
||||
// in a real world app, we may send the error to some remote logging infrastructure
|
||||
// instead of just logging it to the console
|
||||
console.log(error);
|
||||
return throwError(error || 'Server error');
|
||||
value.label = data[i].englishName;
|
||||
array.push(value);
|
||||
}
|
||||
|
||||
return array;
|
||||
|
||||
}
|
||||
|
||||
private handleError(error: HttpErrorResponse) {
|
||||
// in a real world app, we may send the error to some remote logging infrastructure
|
||||
// instead of just logging it to the console
|
||||
console.log(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ export class StaticAutoCompleteComponent implements OnChanges{
|
|||
|
||||
}
|
||||
ngOnDestroy(){
|
||||
if(this.sub && this.sub != undefined){
|
||||
if(this.sub){
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,6 +137,35 @@ export class StringUtils{
|
|||
return sliced + (String(mystr).length > size ? '...' : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits a text to words base on a list of separators. Returns the words of the text including the separators.
|
||||
* DO NOT TOUCH, IT WORKS
|
||||
*
|
||||
* @param text
|
||||
* @param separators
|
||||
*/
|
||||
public static split(text: string, separators: string[]): string[] {
|
||||
let words: (string | string[])[] = [text];
|
||||
separators.forEach(separator => {
|
||||
words.forEach((word, index) => {
|
||||
if(typeof word === "string" && separators.indexOf(word) === -1) {
|
||||
let tokens: string[] = word.split(separator).filter(value => value !== '');
|
||||
if(tokens.length > 1) {
|
||||
words[index] = [];
|
||||
tokens.forEach((token, i) => {
|
||||
(<string[]>(words[index])).push(token);
|
||||
if(i !== (tokens.length - 1)) {
|
||||
(<string[]>(words[index])).push(separator);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
words = [].concat.apply([], words);
|
||||
});
|
||||
return <string []>words;
|
||||
}
|
||||
|
||||
public static capitalize(value: string): string {
|
||||
return value.charAt(0).toUpperCase() + value.slice(1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue