1
|
import {Injectable} from '@angular/core';
|
2
|
import {Http, Response} from '@angular/http';
|
3
|
import {Observable} from 'rxjs/Observable';
|
4
|
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
|
5
|
import 'rxjs/add/operator/do';
|
6
|
|
7
|
@Injectable()
|
8
|
export class HtmlProjectReportService {
|
9
|
|
10
|
constructor(private http: Http ) {}
|
11
|
|
12
|
getHTML(id: string, size: number, type:string):any {
|
13
|
console.info("getHTML in service");
|
14
|
|
15
|
let resultTypeId: string;
|
16
|
let requestType: string;
|
17
|
if(type == "publication") {
|
18
|
resultTypeId = 'publication';
|
19
|
requestType = 'publications';
|
20
|
} else if(type == "research data") {
|
21
|
resultTypeId = 'dataset';
|
22
|
requestType = 'datasets';
|
23
|
} else if(type == "software") {
|
24
|
resultTypeId = 'software';
|
25
|
requestType = 'software'
|
26
|
}
|
27
|
|
28
|
//let url = OpenaireProperties. getSearchAPIURLLast() + 'publications/' +id+"?format=json";
|
29
|
let url = OpenaireProperties.getCsvAPIURL();
|
30
|
url += 'resources?format=html&page=0&size='+size+'&type='+requestType+'&query=(((oaftype exact result) and (resulttypeid exact '+resultTypeId+')) and (relprojectid exact "'+id+'"))';
|
31
|
let key = url;
|
32
|
|
33
|
return this.http.get(url)
|
34
|
.map(res => <any> res.text());
|
35
|
}
|
36
|
}
|