add eosc services links on landing pages

This commit is contained in:
Alex Martzios 2022-05-12 14:05:54 +03:00
parent ac2c67d0ca
commit 1046218717
5 changed files with 63 additions and 62 deletions

View File

@ -8,6 +8,14 @@ import {StringUtils} from "../../utils/string-utils.class";
providedIn: 'root'
})
export class ParsingFunctions {
public eoscSubjects = [
{label: 'EOSC::Jupyter Notebook', link: 'https://marketplace.eosc-portal.eu/services/egi-notebooks?q=Jupyter+Notebook', value: 'Jupyter Notebook'},
{label: 'EOSC::RO-crate', link: 'https://marketplace.eosc-portal.eu/services/rohub?q=RO-crate', value: 'RO-crate'},
{label: 'EOSC::Galaxy Workflow', link: 'https://marketplace.eosc-portal.eu/services/european-galaxy-server?q=Galaxy+Workflow', value: 'Galaxy Workflow'},
{label: 'EOSC::Twitter Data', link: 'https://marketplace.eosc-portal.eu/services/verbal-aggression-analyser-va-analyser?q=Twitter+Data', value: 'Twitter Data'}
]
public eoscSubjectsFound = [];
public notebookInSubjects: boolean = false;
private notebookKeyword: string = "eosc jupyter notebook";
private notebook_label: string = "EOSC";
@ -563,7 +571,7 @@ export class ParsingFunctions {
}
// publication & dataset landing : for subjects and otherSubjects and classifiedSubjects
parseAllSubjects(_subjects: any): [string[], Map<string, string[]>, Map<string, string[]>, string[], string[]] {
parseAllSubjects(_subjects: any): [string[], Map<string, string[]>, Map<string, string[]>, string[], string[], any[]] {
let subjects: string[];
let otherSubjects: Map<string, string[]>;
let classifiedSubjects: Map<string, string[]>;
@ -575,6 +583,7 @@ export class ParsingFunctions {
for (let i = 0; i < length; i++) {
subject = Array.isArray(_subjects) ? _subjects[i] : _subjects;
console.log(subject);
if (subject.classid != "") {
if (subject.inferred && subject.inferred == true) {
if(subject.classid === "SDG") {
@ -591,75 +600,50 @@ export class ParsingFunctions {
if (classifiedSubjects == undefined) {
classifiedSubjects = new Map<string, string[]>();
}
// TODO: remove this when data are ok!
if(subject.classname == 'eosc') {
subject.classname = 'EOSC';
}
if (!classifiedSubjects.has(subject.classname)) {
classifiedSubjects.set(subject.classname, new Array<string>());
}
classifiedSubjects.get(subject.classname).push(subject.content+"");
let content: string = subject.content+"";
let found: boolean = false;
// looping through our declared array
this.eoscSubjects.forEach(item => {
if(content && content == item.label) {
found = true;
this.eoscSubjectsFound.push(item);
classifiedSubjects.get(subject.classname).push(item.value);
}
});
if(!found) {
classifiedSubjects.get(subject.classname).push(content);
}
}
} else {
if (subject.classid == "keyword") {
let content: string = subject.content+"";
// console.log("keyword subject: "+content);
if(content && content.toLowerCase().includes(this.notebookKeyword)) {
// console.log("included in keyword subject: "+content);
// console.log("included");
this.notebookInSubjects = true;
if (classifiedSubjects == undefined) {
classifiedSubjects = new Map<string, string[]>();
}
if (!classifiedSubjects.has(subject.classname)) {
classifiedSubjects.set(this.notebook_label, new Array<string>());
}
classifiedSubjects.get(this.notebook_label).push(this.notebook_value);
} else {
if (subjects == undefined) {
subjects = new Array<string>();
}
subjects.push(content);
}
if (subjects == undefined) {
subjects = new Array<string>();
}
subjects.push(content);
} else {
let content: string = subject.content+"";
let classname: string = subject.classname + "";
// console.log("other subject: "+classname + ": " +content);
if( (content && content.toLowerCase().includes(this.notebookKeyword) ||
(classname && classname.toLowerCase().includes(this.notebookKeyword)))) {
// console.log("included in other subject: "+classname + ": "+content);
// console.log("included");
this.notebookInSubjects = true;
if (classifiedSubjects == undefined) {
classifiedSubjects = new Map<string, string[]>();
}
if (!classifiedSubjects.has(subject.classname)) {
classifiedSubjects.set(this.notebook_label, new Array<string>());
}
classifiedSubjects.get(this.notebook_label).push(this.notebook_value);
} else {
// if (otherSubjects == undefined) {
// otherSubjects = new Map<string, string[]>();
// }
//
// if (!otherSubjects.has(subject.classname)) {
// otherSubjects.set(subject.classname, new Array<string>());
// }
// otherSubjects.get(classname).push(content);
if (subjects == undefined) {
subjects = new Array<string>();
}
subjects.push(content);
}
if (subjects == undefined) {
subjects = new Array<string>();
}
subjects.push(content);
}
}
}
}
return [subjects, otherSubjects, classifiedSubjects, fos, sdg];
console.log(this.eoscSubjectsFound);
return [subjects, otherSubjects, classifiedSubjects, fos, sdg, this.eoscSubjectsFound];
}
parseContexts(_contexts: any): Context[] {

View File

@ -367,15 +367,32 @@
<ng-template #right_column>
<div class="uk-margin-medium-top uk-list uk-list-large uk-padding uk-padding-remove-vertical" [class.uk-list-divider]="!viewAll">
<!-- EGI Notebook-->
<div *ngIf="resultLandingInfo.showEgiNotebookButton && properties.adminToolsPortalType == 'explore'
<!-- EOSC Services-->
<!-- 1 link -->
<div *ngIf="resultLandingInfo.eoscSubjects?.length == 1 && properties.adminToolsPortalType == 'explore'
&& (properties.environment == 'beta' || properties.environment == 'development') && (!viewAll || viewAll=='egiNotebook')">
<a class="uk-link-text uk-text-bold custom-external"
target="_blank" [href]="properties.egiNotebookLink">
target="_blank" [href]="resultLandingInfo.eoscSubjects[0].link">
<img src="assets/common-assets/eosc-logo.png"
loading="lazy" alt="eosc_logo" style="width:27px; height:27px">
<span class="uk-margin-small-left uk-text-uppercase"><u>EOSC SERVICE: EGI NOTEBOOK</u></span>
<span class="uk-margin-small-left uk-text-uppercase"><u>Check compatible EOSC services</u></span>
</a>
</div>
<!-- more than 1 links -->
<div *ngIf="resultLandingInfo.eoscSubjects?.length > 1 && properties.adminToolsPortalType == 'explore'
&& (properties.environment == 'beta' || properties.environment == 'development') && (!viewAll || viewAll=='egiNotebook')">
<a class="uk-link-text uk-text-bold">
<img src="assets/common-assets/eosc-logo.png"
loading="lazy" alt="eosc_logo" style="width:27px; height:27px">
<span class="uk-margin-small-left uk-text-uppercase"><u>Check compatible EOSC services</u></span>
</a>
<div class="uk-dropdown" uk-dropdown="pos: bottom-right; offset: 10; delay-hide: 0; mode:click">
<ul class="uk-nav uk-dropdown-nav">
<li *ngFor="let item of resultLandingInfo.eoscSubjects">
<a [href]="item.link" target="_blank" class="custom-external">{{item.value}}</a>
</li>
</ul>
</div>
</div>
<div *ngIf="resultLandingInfo.sdg && resultLandingInfo.sdg.length > 0 && (!viewAll || viewAll=='sdg')">
<sdg [subjects]="resultLandingInfo.sdg" (viewAllClicked)="viewAll=$event"></sdg>

View File

@ -548,7 +548,7 @@ export class ResultLandingComponent {
}
public get hasRightSidebarInfo(): boolean {
return (this.resultLandingInfo.showEgiNotebookButton && properties.adminToolsPortalType == 'explore'
return (this.resultLandingInfo.eoscSubjects && this.resultLandingInfo.eoscSubjects.length && properties.adminToolsPortalType == 'explore'
&& (properties.environment == 'beta' || properties.environment == 'development'))
||
(this.resultLandingInfo.sdg && this.resultLandingInfo.sdg.length > 0)

View File

@ -331,7 +331,7 @@ export class ResultLandingService {
// res['result']['metadata']['oaf:entity']['oaf:result']['subject']
if(data[7] != null) {
let subjectResults: [string[], Map<string, string[]>, Map<string, string[]>, string[], string[]] = this.parsingFunctions.parseAllSubjects(data[7]);
let subjectResults: [string[], Map<string, string[]>, Map<string, string[]>, string[], string[], any[]] = this.parsingFunctions.parseAllSubjects(data[7]);
this.resultLandingInfo.subjects = subjectResults[0];
this.resultLandingInfo.otherSubjects = subjectResults[1];
this.resultLandingInfo.classifiedSubjects = subjectResults[2];
@ -346,7 +346,7 @@ export class ResultLandingService {
})
}
this.resultLandingInfo.showEgiNotebookButton = this.parsingFunctions.notebookInSubjects;
this.resultLandingInfo.eoscSubjects = subjectResults[5];
}
this.resultLandingInfo.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(

View File

@ -62,7 +62,7 @@ export class ResultLandingInfo {
classifiedSubjects: Map<string, string[]>; //<class of subject, subjects>
fos: string[];
sdg: string[];
showEgiNotebookButton: boolean = false;
eoscSubjects: any[];
// // percentage is for trust
// relatedResearchResults: RelationResult[];