Project

General

Profile

1
import {Component, OnDestroy, OnInit} from "@angular/core";
2
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
3
import {Stakeholder} from "../openaireLibrary/monitor/entities/stakeholder";
4
import {Subscription} from "rxjs";
5
import {Meta, Title} from "@angular/platform-browser";
6
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
7
import {properties} from "../../environments/environment";
8
import {Router} from "@angular/router";
9
import {StakeholderUtils} from "../utils/indicator-utils";
10

    
11
@Component({
12
  selector: 'develop',
13
  template: `
14
    <div page-content>
15
      <div inner>
16
        <div *ngIf="stakeholder" class="uk-container uk-container-large uk-section-small">
17
          <h2 class="uk-text-center">
18
            Develop
19
          </h2>
20
          <div class="uk-margin-medium-top uk-card uk-card-body uk-card-default">
21
            <h3 class="uk-text-center">Help developers with <span
22
                class="portal-color uk-text-bold">OpenAIRE APIs</span>
23
            </h3>
24
            <div class="uk-margin-large-top uk-margin-medium-bottom">
25
              Not sure where to start? Let us give you some guides and request examples.
26
            </div>
27
            <div class="uk-grid uk-child-width-1-2@l uk-child-width-1-1" uk-grid>
28
              <div>
29
                <p>
30
                  <span class="uk-text-bold">For research outcomes </span>
31
                  (publications, datasets, software and other research data) you can use the
32
                  <a href="http://api.openaire.eu/api.html" target="_blank">Selective Access APIs</a>
33
                  by adding the <span class="uk-text-lowercase">{{type}}</span> parameter.
34
                </p>
35
                <p>
36
                  Request examples:
37
                </p>
38
                <ul class="portal-circle">
39
                  <li>
40
                    <span class="uk-text-bold">Access “Publications”</span><br>
41
                    <span class="uk-text-bold">GET</span>
42
                    <span class="uk-text-break space">https://api.openaire.eu/search/publications?funder={{stakeholder.index_shortName}}</span>
43
                  </li>
44
                  <li>
45
                    <span class="uk-text-bold">Access “Open Access Publications”</span><br>
46
                    <span class="uk-text-bold">GET</span>
47
                    <span class="uk-text-break space">http://api.openaire.eu/search/publications?funder={{stakeholder.index_shortName}}&OA=true</span>
48
                  </li>
49
                  <li>
50
                    <span class="uk-text-bold">Access “Datasets”</span><br>
51
                    <span class="uk-text-bold">GET</span>
52
                    <span class="uk-text-break space">https://api.openaire.eu/search/datasets?funder={{stakeholder.index_shortName}}</span>
53
                  </li>
54
                  <li>
55
                    <span class="uk-text-bold">Access “Software”</span><br>
56
                    <span class="uk-text-bold">GET</span>
57
                    <span class="uk-text-break space">https://api.openaire.eu/search/software?funder={{stakeholder.index_shortName}}</span>
58
                  </li>
59
                  <li>
60
                    <span class="uk-text-bold">Access “Other Research”</span><br>
61
                    <span class="uk-text-bold">GET</span>
62
                    <span class="uk-text-break space">https://api.openaire.eu/search/other?funder={{stakeholder.index_shortName}}</span>
63
                  </li>
64
                </ul>
65
              </div>
66
              <div>
67
                <p>
68
                  <span class="uk-text-bold">For projects</span> you can use the <a href="http://api.openaire.eu/api.html" target="_blank">Selective Access APIs</a>
69
                  and the <a href="http://api.openaire.eu/bulk-projects.html" target="_blank">Bulk Access APIs</a>.
70
                </p>
71
                <p>
72
                  Request examples:
73
                </p>
74
                <ul class="portal-circle">
75
                  <li>
76
                    <span class="uk-text-bold">For the “Selective Access”</span><br>
77
                    <span class="uk-text-break space">https://api.openaire.eu/search/projects?funder={{stakeholder.index_shortName}}</span>
78
                  </li>
79
                  <li>
80
                    <span class="uk-text-bold">For the “Bulk Access”</span><br>
81
                    <span class="uk-text-bold uk-text-nowrap">DSpace endpoint:</span>
82
                    <span class="uk-text-break space">https://api.openaire.eu/projects/dspace/{{stakeholder.index_shortName}}/ALL/ ALL</span><br>
83
                    <span class="uk-text-bold uk-text-nowrap">ePrints endpoint:</span>
84
                    <span class="uk-text-break space">https://api.openaire.eu/projects/eprints/{{stakeholder.index_shortName}}/ALL/ ALL</span>
85
                  </li>
86
                </ul>
87
                <div class="uk-flex uk-flex-center uk-width-1-1 uk-margin-medium-top">
88
                  <img width="350" src="assets/develop.png">
89
                </div>
90
              </div>
91
            </div>
92
            <div class="uk-margin-large-top uk-flex uk-flex-center uk-padding">
93
              <div class="documentation">
94
                For <span class="uk-text-bold">more information</span> on the full potential of the OpenAIRE APIs please check
95
                the <a href="http://develop.openaire.eu/" target="_blank">OpenAIRE API Documentation</a>.
96
              </div>
97
            </div>
98
          </div>
99
        </div>
100
      </div>
101
    </div>
102
  `,
103
  styleUrls: ['develop.component.css']
104
})
105
export class DevelopComponent implements OnInit, OnDestroy {
106
  
107
  public stakeholder: Stakeholder;
108
  private subscriptions: any[] = [];
109
  private stakeholderUtils: StakeholderUtils = new StakeholderUtils();
110
  public type: string;
111
  
112
  constructor(private stakeholderService: StakeholderService,
113
              private seoService: SEOService,
114
              private _meta: Meta,
115
              private _router: Router,
116
              private _title: Title) {
117
  }
118
  
119
  ngOnInit() {
120
    this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
121
      this.stakeholder = stakeholder;
122
      if (this.stakeholder) {
123
        if(stakeholder.type !== "funder") {
124
          this.navigateToError();
125
        }
126
        /* Metadata */
127
        const url = properties.domain + properties.baseLink + this._router.url;
128
        this.seoService.createLinkForCanonicalURL(url, false);
129
        this._meta.updateTag({content: url}, "property='og:url'");
130
        const description = "Develop | " + this.stakeholder.name;
131
        const title = "Develop | " + this.stakeholder.name;
132
        this._meta.updateTag({content: description}, "name='description'");
133
        this._meta.updateTag({content: description}, "property='og:description'");
134
        this._meta.updateTag({content: title}, "property='og:title'");
135
        this._title.setTitle(title);
136
        
137
        /* Initializations */
138
        this.stakeholderUtils.types.forEach(type => {
139
          if (type.value === stakeholder.type) {
140
            this.type = type.label;
141
          }
142
        });
143
      }
144
    }));
145
  }
146
  
147
  private navigateToError() {
148
    this._router.navigate(['/error'], {queryParams: {'page': this._router.url}});
149
  }
150
  
151
  ngOnDestroy() {
152
    this.subscriptions.forEach(subscription => {
153
      if (subscription instanceof Subscription) {
154
        subscription.unsubscribe();
155
      }
156
    });
157
  }
158
}
(2-2/3)