2017-12-19 13:53:46 +01:00
|
|
|
import {Injectable} from '@angular/core';
|
|
|
|
import {Http, Response} from '@angular/http';
|
|
|
|
import {Observable} from 'rxjs/Observable';
|
|
|
|
import 'rxjs/add/operator/do';
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class HtmlProjectReportService {
|
|
|
|
|
|
|
|
constructor(private http: Http ) {}
|
|
|
|
|
2018-02-05 14:14:59 +01:00
|
|
|
getHTML(id: string, size: number, type:string, csvAPIURL: string ):any {
|
2017-12-19 13:53:46 +01:00
|
|
|
console.info("getHTML in service");
|
|
|
|
|
|
|
|
let resultTypeId: string;
|
|
|
|
let requestType: string;
|
|
|
|
if(type == "publication") {
|
|
|
|
resultTypeId = 'publication';
|
|
|
|
requestType = 'publications';
|
|
|
|
} else if(type == "research data") {
|
|
|
|
resultTypeId = 'dataset';
|
|
|
|
requestType = 'datasets';
|
|
|
|
} else if(type == "software") {
|
|
|
|
resultTypeId = 'software';
|
|
|
|
requestType = 'software'
|
|
|
|
}
|
|
|
|
|
2018-02-05 14:14:59 +01:00
|
|
|
let url = csvAPIURL;
|
|
|
|
url += '?format=html&type='+requestType+'&fq=(((oaftype exact result) and (resulttypeid exact '+resultTypeId+')) and (relprojectid exact "'+id+'"))';
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
let key = url;
|
|
|
|
|
|
|
|
return this.http.get(url)
|
|
|
|
.map(res => <any> res.text());
|
|
|
|
}
|
|
|
|
}
|