[Library|Trunk]

Enermaps integration:
- parse enermaps id
- show in results and in landing (to be revised)
- add enermaps url property
- add function to query all results for community id/ context




git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60783 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2021-04-02 09:17:00 +00:00
parent 43cc10d32b
commit 3ef2e0168d
14 changed files with 52 additions and 14 deletions

View File

@ -4,7 +4,7 @@ import {properties} from "../../../environments/environment";
export class ConnectHelper {
public static getCommunityFromDomain(domain: string): string{
domain = "beta.egi.openaire.eu"; //for testing
domain = "beta.enermaps.openaire.eu"; //for testing
domain = domain.indexOf("//") != -1? domain.split("//")[1]:domain; //remove https:// prefix
if (domain.indexOf('openaire.eu') === -1) {
return null;

View File

@ -614,7 +614,10 @@ export class ParsingFunctions {
}
return contexts;
}
public static getEnermapsConceptId(contexts: any): string{
let enermapsconcepts = contexts.filter(c=> {return c.idCategory == "enermaps::selection" && c.idConcept});
return enermapsconcepts && enermapsconcepts.length > 0?enermapsconcepts[0].idConcept.split("enermaps::selection::")[1]:null;
}
parseTypes(types: string[], uniqueTypes: Set<string>, instance: any) {
if (instance && instance.hasOwnProperty("instancetype") && instance['instancetype'].classname) {
if (!uniqueTypes.has(instance['instancetype'].classname)) {

View File

@ -210,6 +210,11 @@
<a (click)="showAll = !showAll;">View less</a>
</div>
</div>
<div *ngIf="enermapsId && properties.enermapsURL" class="uk-width-expand uk-flex uk-flex-center">
<a [href]="properties.enermapsURL" target="_blank" ><img class="uk-width-auto"
[src]="properties.enermapsURL +'/images/' + enermapsId + '.png'" alt="Enermaps tool preview">
</a>
</div>
</div>
<div *ngIf="hasSecondaryInfo" class="uk-width-1-3@m uk-width-1-1 right-column uk-padding-remove">
<div *ngIf="resultLandingInfo.fundedByProjects && resultLandingInfo.fundedByProjects.length > 0 ||

View File

@ -21,6 +21,7 @@ import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabulari
import {Subscriber} from "rxjs";
import {Session} from "../../login/utils/helper.class";
import {AnnotationComponent} from "../annotation/annotation.component";
import {ParsingFunctions} from "../landing-utils/parsingFunctions.class";
@Component({
@ -31,6 +32,7 @@ export class ResultLandingComponent {
@Input() type: string = "publication";
@Input() piwikSiteId = properties.piwikSiteId;
@Input() communityId = null;
enermapsId;
@ViewChild('linkModal') linkModal;
@ViewChild('citeModal') citeModal;
@ViewChild('AlertModalDeletedByInference') alertModalDeletedByInference;
@ -389,6 +391,9 @@ export class ResultLandingComponent {
}
}
}
if(this.communityId && this.communityId == "enermaps" && properties.enermapsURL){
this.enermapsId = ParsingFunctions.getEnermapsConceptId(this.resultLandingInfo.contexts);
}
this.showLoading = false;
this.setActiveTab();
},
@ -418,7 +423,7 @@ export class ResultLandingComponent {
}
public get hasPrimaryInfo(): boolean {
return !!this.resultLandingInfo && (!!this.resultLandingInfo.description || !!this.resultLandingInfo.identifiers || !!this.resultLandingInfo.subjects);
return !!this.resultLandingInfo && (!!this.resultLandingInfo.description || !!this.resultLandingInfo.identifiers || !!this.resultLandingInfo.subjects || !!this.enermapsId);
}
public get hasSecondaryInfo(): boolean {

View File

@ -3,7 +3,7 @@
<li *ngFor="let result of previewResults" class="uk-animation-fade">
<div class="uk-card uk-card-default uk-card-hover">
<result-preview [properties]="properties" [showOrganizations]="showOrganizations"
[showSubjects]="showSubjects" [result]="result" [showImage]="showImage">
[showSubjects]="showSubjects" [result]="result" [showEnermaps]="showEnermaps">
</result-preview>
</div>
</li>

View File

@ -22,7 +22,7 @@ export class SearchResultComponent implements OnInit, OnChanges {
@Input() custom_class: string = "search-results";
@Input() properties: EnvProperties;
@Input() showImpactFactors: boolean = false;
@Input() showImage: boolean;
@Input() showEnermaps: boolean;
constructor( private http: HttpClient/*ATHENA CODE*/
, private orcidService: OrcidService) {

View File

@ -366,7 +366,9 @@ export class SearchResearchResultsService {
}
}
}
if(resData['context'] != null) {
result.enermapsId = ParsingFunctions.getEnermapsConceptId(this.parsingFunctions.parseContexts(resData['context']));
}
results.push(result);
}

View File

@ -57,7 +57,7 @@ export class SearchResult {
entityType: string;
types: string[];
enermapsId:string;
constructor() {
}

View File

@ -83,7 +83,25 @@ export class FetchResearchResults {
}
));
}
public getAllResultsForCommunity(resultType:string, communityId: string, page: number, size: number, properties:EnvProperties, contextId = null) {
this.searchUtils.status = this.errorCodes.LOADING;
this.subscriptions.push(this._searchResearchResultsService.advancedSearchResults(resultType, "", page, size, "resultdateofacceptance,descending", properties, "&type=results&fq=communityid=" + communityId +(contextId?'&fq=categoryid=' + encodeURIComponent(contextId):'')).subscribe(
data => {
this.searchUtils.totalResults = data[0];
this.results = data[1];
this.searchUtils.status = this.errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
this.handleError("Error getting "+this.getEntityName(resultType,true)+" for community: "+communityId, err);
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
}
));
}
public getResultsByKeyword(resultType:string, keyword:string, page: number, size: number, properties:EnvProperties, customFilter:SearchCustomFilter=null){
var parameters = "";
if(keyword.length > 0){

View File

@ -23,6 +23,7 @@ export interface EnvProperties {
disableFrameLoad?:boolean
statisticsAPIURL?: string;
impactFactorsAPIURL?: string;
enermapsURL?: string;
claimsAPIURL?: string;
searchAPIURLLAst?: string;
searchResourcesAPIURL?: string;

View File

@ -282,9 +282,10 @@
</div>
</div>
</div>
<div class="uk-width-auto">
<img *ngIf="showImage && getPID()" class="uk-width-medium"
[src]="'http://enermaps.idiap.ch/'+getPID().id+'.png'" alt="tool preview">
<div *ngIf="properties.enermapsURL && showEnermaps" class="uk-width-auto">
<a [href]="properties.enermapsURL" target="_blank" ><img *ngIf="result.enermapsId"
class="uk-width-medium" [src]="properties.enermapsURL + '/images/' + result.enermapsId + '.png'" alt="Enermaps tool preview">
</a>
</div>
</div>
<!--&& loggedIn -->

View File

@ -27,7 +27,7 @@ export class ResultPreviewComponent implements OnInit, OnChanges {
public beforeTitle: string[] = [];
public dataProviderUrl = properties.searchLinkToDataProvider.split('?')[0];
@Input() showOrcid: boolean = true;
@Input() showImage: boolean = false;
@Input() showEnermaps: boolean = false;
ngOnInit(): void {
if(this.hasLink) {

View File

@ -136,7 +136,9 @@ export class ResultPreview {
relation: string;
percentage: number;
provenanceAction: string;
//enermaps id - image
enermapsId:string;
public static searchResultConvert(result: SearchResult, type: string): ResultPreview {
let resultPreview: ResultPreview = new ResultPreview();
resultPreview.id = result.id;
@ -189,6 +191,7 @@ export class ResultPreview {
// resultPreview.identifiers.set("doi", result.DOIs);
// }
resultPreview.identifiers = result.identifiers;
resultPreview.enermapsId = result.enermapsId;
return resultPreview;
}

View File

@ -26,7 +26,7 @@ import {ErrorCodes} from "../../properties/errorCodes";
<search-result [properties]="properties"
[results]="fetch.results"
[status]="fetch.searchUtils.status"
[type]="resultType" [showImpactFactors]="showImpactFactors" [showImage]="showImage">
[type]="resultType" [showImpactFactors]="showImpactFactors" [showEnermaps]="showEnermaps">
</search-result>
<div *ngIf="searchLinkToAdvancedPage" class="uk-text-right">
@ -49,7 +49,7 @@ export class SearchTabComponent {
@Input() properties: EnvProperties;
@Input() showImpactFactors;
@Input() customTitle;
@Input() showImage: boolean;
@Input() showEnermaps: boolean;
public errorCodes: ErrorCodes = new ErrorCodes();