57 lines
2.3 KiB
TypeScript
57 lines
2.3 KiB
TypeScript
import {Component} from '@angular/core';
|
|
import {PluginBaseComponent, PluginBaseInfo} from "../../utils/base-plugin.component";
|
|
import {HttpClient} from "@angular/common/http";
|
|
|
|
export class PluginOpenAIREProducts extends PluginBaseInfo{
|
|
title:string ="OpenAIRE services for your community";
|
|
serviceIdsArray = ["zenodo","graph","explore"];
|
|
compare(oldObject): any {
|
|
return super.compare(oldObject);
|
|
}
|
|
}
|
|
@Component({
|
|
selector: 'plugin-openaire-products',
|
|
template: `
|
|
<div *ngIf="pluginObject">
|
|
<h3>{{pluginObject.title}} </h3>
|
|
<div class="uk-child-width-1-3 uk-grid">
|
|
<ng-container *ngFor="let service of services">
|
|
<div *ngIf="pluginObject && pluginObject.serviceIdsArray.indexOf(service.id)!=-1" class="uk-padding-xsmall">
|
|
|
|
<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>
|
|
</ng-container>
|
|
</div>
|
|
</div>
|
|
|
|
`,
|
|
|
|
|
|
})
|
|
export class PluginOpenaireProductsComponent extends PluginBaseComponent<PluginOpenAIREProducts>{
|
|
services = [];
|
|
excludedServiceIds = ["openaire_login","research_community_dashboard"]
|
|
default = new PluginOpenAIREProducts();
|
|
constructor(http:HttpClient) {
|
|
super()
|
|
this.subscriptions.push(http.get("https://explore.openaire.eu/cache/get?url="+ encodeURIComponent("https://catalogue.openaire.eu/api/catalogue-resources?from=0&quantity=100&order=asc&orderField=name")).subscribe(res =>{
|
|
this.services = res["results"].map( x=> {
|
|
x.id = x.id.split("openaire.")[1]
|
|
return x;
|
|
});
|
|
this.services = this.services.filter(x=> this.excludedServiceIds.indexOf(x.id) ==-1);
|
|
}))
|
|
|
|
}
|
|
}
|