monitor-dashboard/src/app/develop/develop.component.ts

171 lines
7.4 KiB
TypeScript

import {Component, OnDestroy, OnInit} from "@angular/core";
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
import {Stakeholder} from "../openaireLibrary/monitor/entities/stakeholder";
import {Subscription} from "rxjs";
import {Meta, Title} from "@angular/platform-browser";
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
import {properties} from "../../environments/environment";
import {Router} from "@angular/router";
import {StakeholderUtils} from "../utils/indicator-utils";
@Component({
selector: 'develop',
template: `
<div class="uk-section">
<div class="uk-container uk-container-large">
<h1>Help developers <br> with OpenAIRE APIs<span class="uk-text-primary">.</span></h1>
</div>
<div class="uk-section uk-container uk-container-large">
<div class="uk-grid uk-grid-large uk-child-width-1-3@m uk-child-width-1-1" uk-grid>
<div class="uk-text-center uk-margin-large-top">
<div class="uk-icon-bg-shadow uk-icon-bg-shadow-large uk-margin-auto uk-text-primary-gradient">
<icon name="description" [flex]="true" ratio="2.5" type="outlined" visuallyHidden="For research outcomes"></icon>
</div>
<h3>For research outcomes</h3>
<div class="uk-margin-bottom">
For research outcomes (publications, datasets, software and other research data) you can use the Selective Access APIs by adding the funder parameter.
</div>
<a class="uk-display-inline-block uk-text-uppercase uk-button-text"
href="https://graph.openaire.eu/develop/api.html" target="_blank">
<span class="uk-flex uk-flex-middle">
<span>Selective Access APIs</span>
</span>
</a>
</div>
<div>
<img src="assets/apis.svg" alt="">
</div>
<div class="uk-text-center uk-margin-large-top">
<div class="uk-icon-bg-shadow uk-icon-bg-shadow-large uk-margin-auto uk-text-primary-gradient">
<icon name="content_paste" [flex]="true" ratio="2.5" type="outlined" visuallyHidden="For projects"></icon>
</div>
<h3>For projects</h3>
<div class="uk-margin-bottom">
For projects you can use the Selective Access APIs and the Bulk Access APIs.
</div>
<div class="uk-flex uk-flex-column uk-flex-center uk-flex-middle">\
<a class="uk-display-inline-block uk-text-uppercase uk-button-text uk-margin-bottom"
href="https://graph.openaire.eu/develop/api.html" target="_blank">
<span class="uk-flex uk-flex-middle">
<span>Selective Access APIs</span>
</span>
</a>
<a class="uk-display-inline-block uk-text-uppercase uk-button-text"
href="https://graph.openaire.eu/develop/bulk-projects.html" target="_blank">
<span class="uk-flex uk-flex-middle">
<span>Bulk Access APIs</span>
</span>
</a>
</div>
</div>
</div>
</div>
<div class="uk-section uk-container uk-container-large">
<div class="uk-grid uk-grid-large uk-child-width-1-2@m uk-child-width-1-1" uk-grid>
<div>
<div>Request examples for research outcomes:</div>
<ul class="uk-list uk-list-large uk-list-disc">
<li>
<span class="uk-text-bold">Access “Publications”</span><br>
<span class="uk-text-bold uk-margin-small-right">GET</span>
<span class="">https://api.openaire.eu/search/publications?funder={{stakeholder.index_shortName}}</span>
</li>
<li>
<span class="uk-text-bold">Access “Open Access Publications”</span><br>
<span class="uk-text-bold uk-margin-small-right">GET</span>
<span class="uk-text-break">http://api.openaire.eu/search/publications?funder={{stakeholder.index_shortName}}&OA=true</span>
</li>
<li>
<span class="uk-text-bold">Access “Datasets”</span><br>
<span class="uk-text-bold uk-margin-small-right">GET</span>
<span class="uk-text-break">https://api.openaire.eu/search/datasets?funder={{stakeholder.index_shortName}}</span>
</li>
<li>
<span class="uk-text-bold">Access “Software”</span><br>
<span class="uk-text-bold uk-margin-small-right">GET</span>
<span class="uk-text-break">https://api.openaire.eu/search/software?funder={{stakeholder.index_shortName}}</span>
</li>
<li>
<span class="uk-text-bold">Access “Other Research”</span><br>
<span class="uk-text-bold uk-margin-small-right">GET</span>
<span class="uk-text-break">https://api.openaire.eu/search/other?funder={{stakeholder.index_shortName}}</span>
</li>
</ul>
</div>
<div>
<div>Request examples for projects:</div>
<ul class="uk-list uk-list-large uk-list-disc">
<li>
<span class="uk-text-bold">For the “Selective Access”</span><br>
<span class="uk-text-break">https://api.openaire.eu/search/projects?funder={{stakeholder.index_shortName}}</span>
</li>
<li>
<span class="uk-text-bold">For the “Bulk Access”</span><br>
<span class="uk-text-bold uk-text-nowrap">DSpace endpoint:</span>
<span class="uk-text-break uk-margin-small-left">https://api.openaire.eu/projects/dspace/{{stakeholder.index_shortName}}/ALL/ ALL</span><br>
<span class="uk-text-bold uk-text-nowrap">ePrints endpoint:</span>
<span class="uk-text-break uk-margin-small-left">https://api.openaire.eu/projects/eprints/{{stakeholder.index_shortName}}/ALL/ ALL</span>
</li>
</ul>
</div>
</div>
</div>
</div>
`,
styleUrls: ['develop.component.css']
})
export class DevelopComponent implements OnInit, OnDestroy {
public stakeholder: Stakeholder;
private subscriptions: any[] = [];
private stakeholderUtils: StakeholderUtils = new StakeholderUtils();
public type: string;
constructor(private stakeholderService: StakeholderService,
private seoService: SEOService,
private _meta: Meta,
private _router: Router,
private _title: Title) {
}
ngOnInit() {
this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
this.stakeholder = stakeholder;
if (this.stakeholder) {
if(stakeholder.type !== "funder") {
this.navigateToError();
}
/* Metadata */
const url = properties.domain + properties.baseLink + this._router.url;
this.seoService.createLinkForCanonicalURL(url, false);
this._meta.updateTag({content: url}, "property='og:url'");
const description = "Develop | " + this.stakeholder.name;
const title = "Develop | " + this.stakeholder.name;
this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'");
this._meta.updateTag({content: title}, "property='og:title'");
this._title.setTitle(title);
/* Initializations */
this.stakeholderUtils.types.forEach(type => {
if (type.value === stakeholder.type) {
this.type = type.label;
}
});
}
}));
}
private navigateToError() {
this._router.navigate(['/error'], {queryParams: {'page': this._router.url}});
}
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscription) {
subscription.unsubscribe();
}
});
}
}