2024-03-01 09:32:38 +01:00
|
|
|
import {Component, SimpleChanges} from '@angular/core';
|
2024-02-28 12:07:31 +01:00
|
|
|
import {PluginBaseComponent, PluginBaseInfo} from "../../utils/base-plugin.component";
|
2024-01-19 09:53:17 +01:00
|
|
|
import {HttpClient} from "@angular/common/http";
|
|
|
|
|
2024-02-22 10:09:20 +01:00
|
|
|
export class PluginOpenAIREProducts extends PluginBaseInfo{
|
2024-01-19 09:53:17 +01:00
|
|
|
title:string ="OpenAIRE services for your community";
|
2024-03-01 09:32:38 +01:00
|
|
|
serviceIdsArray = ["argos","zenodo","amnesia"];
|
2024-02-28 12:07:31 +01:00
|
|
|
compare(oldObject): any {
|
|
|
|
return super.compare(oldObject);
|
|
|
|
}
|
2024-01-19 09:53:17 +01:00
|
|
|
}
|
|
|
|
@Component({
|
|
|
|
selector: 'plugin-openaire-products',
|
|
|
|
template: `
|
2024-04-09 09:48:23 +02:00
|
|
|
<div *ngIf="pluginObject " class="uk-container uk-section">
|
2024-02-28 12:07:31 +01:00
|
|
|
<h3>{{pluginObject.title}} </h3>
|
2024-03-01 09:32:38 +01:00
|
|
|
|
2024-04-09 09:48:23 +02:00
|
|
|
<div *ngIf="services && servicesToShow" uk-slider class="uk-slider">
|
2024-03-01 09:32:38 +01:00
|
|
|
<ul *ngIf="slides" class="uk-slider-items" uk-height-match="target: .uk-card; row: false">
|
|
|
|
<li *ngFor="let slide of [].constructor(slides); let i=index" class="uk-width-1-1 uk-padding">
|
|
|
|
<div class="uk-grid uk-child-width-1-3@m uk-child-width-1-1" uk-grid uk-scrollspy="target: [uk-scrollspy-class]; cls: uk-animation-fade; repeat: true">
|
|
|
|
<div *ngFor="let service of servicesToShow.slice((i)*slideItems,(i+1)*slideItems)" uk-scrollspy-class>
|
2024-01-19 09:53:17 +01:00
|
|
|
<div class="uk-card uk-card-default ">
|
|
|
|
<div class="uk-card-media-top">
|
|
|
|
<img [src]="service.logo" width="100%" height="" alt="" class="uk-height-max-small">
|
|
|
|
</div>
|
|
|
|
<div class=" uk-height-max-large uk-padding-small">
|
|
|
|
<div class="uk-text-primary">{{service.name}}</div>
|
|
|
|
<div class="uk-h5 uk-margin-remove-vertical">{{service.tagline}}</div>
|
|
|
|
<div [innerHTML]="service.description" class="uk-text-truncate uk-text-small uk-text-meta"></div>
|
|
|
|
<a class="uk-link-text" [href]="service.webpage" target="_blank">Read more</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-03-01 09:32:38 +01:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<ul class="uk-slider-nav uk-dotnav uk-flex-center uk-margin-medium-top"></ul>
|
|
|
|
</div>
|
2024-03-28 11:37:00 +01:00
|
|
|
<div *ngIf="showErrorMessage" class="uk-text-muted uk-text-center">
|
|
|
|
No products info available
|
|
|
|
|
|
|
|
</div>
|
2024-01-19 09:53:17 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
`,
|
|
|
|
|
|
|
|
|
|
|
|
})
|
2024-02-22 10:09:20 +01:00
|
|
|
export class PluginOpenaireProductsComponent extends PluginBaseComponent<PluginOpenAIREProducts>{
|
2024-03-01 09:32:38 +01:00
|
|
|
services = null;
|
2024-01-19 09:53:17 +01:00
|
|
|
excludedServiceIds = ["openaire_login","research_community_dashboard"]
|
2024-04-09 09:48:23 +02:00
|
|
|
servicesToShow = null;
|
2024-03-01 09:32:38 +01:00
|
|
|
slides = 1;
|
|
|
|
slideItems = 3;
|
2024-03-28 11:37:00 +01:00
|
|
|
api= "https://catalogue.openaire.eu/api/catalogue-resources?from=0&quantity=100&order=asc&orderField=name";
|
|
|
|
showErrorMessage = false;
|
2024-03-01 09:32:38 +01:00
|
|
|
constructor(private http:HttpClient) {
|
2024-01-19 09:53:17 +01:00
|
|
|
super()
|
2024-03-01 09:32:38 +01:00
|
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
|
|
super.ngOnInit();
|
|
|
|
if(!this.services) {
|
2024-03-28 11:37:00 +01:00
|
|
|
this.subscriptions.push(this.http.get( this.properties.cacheUrl + encodeURIComponent(this.api)).subscribe(res =>{
|
2024-03-01 09:32:38 +01:00
|
|
|
this.services = res["results"].map( x=> {
|
2024-04-09 09:48:23 +02:00
|
|
|
if(x.id.indexOf("openaire.")!=-1){
|
|
|
|
x.id = x.id.split("openaire.")[1]
|
|
|
|
}
|
2024-03-01 09:32:38 +01:00
|
|
|
return x;
|
|
|
|
});
|
|
|
|
this.services = this.services.filter(x=> this.excludedServiceIds.indexOf(x.id) ==-1);
|
|
|
|
this.calculatePages();
|
2024-03-28 11:37:00 +01:00
|
|
|
}, error => {
|
|
|
|
this.showErrorMessage = true;
|
2024-03-01 09:32:38 +01:00
|
|
|
}))
|
|
|
|
}else{
|
|
|
|
this.calculatePages();
|
|
|
|
}
|
|
|
|
}
|
2024-01-19 09:53:17 +01:00
|
|
|
|
2024-03-01 09:32:38 +01:00
|
|
|
ngOnChanges(changes: SimpleChanges) {
|
|
|
|
if(this.services) {
|
|
|
|
this.calculatePages();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
calculatePages(){
|
2024-03-06 14:26:14 +01:00
|
|
|
this.slides = 1;
|
2024-03-01 09:32:38 +01:00
|
|
|
this.servicesToShow = this.services.filter(x => this.pluginObject.serviceIdsArray.indexOf(x.id) != -1);
|
|
|
|
if (this.servicesToShow.length > this.slideItems) {
|
|
|
|
this.slides = parseInt('' + (this.servicesToShow.length / this.slideItems));
|
|
|
|
if(this.slides< (this.servicesToShow.length / this.slideItems)){
|
|
|
|
this.slides++;
|
|
|
|
}
|
|
|
|
}
|
2024-01-19 09:53:17 +01:00
|
|
|
}
|
|
|
|
}
|