2017-12-19 13:53:46 +01:00
|
|
|
import {Injectable} from '@angular/core';
|
|
|
|
import {Http, Response} from '@angular/http';
|
2019-06-03 15:20:36 +02:00
|
|
|
import {HttpClient} from "@angular/common/http";
|
|
|
|
import {Observable} from 'rxjs';
|
|
|
|
|
|
|
|
import {map} from "rxjs/operators";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class HtmlProjectReportService {
|
|
|
|
|
2019-06-03 15:20:36 +02:00
|
|
|
constructor(private http: HttpClient ) {}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
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
|
|
|
|
|
|
|
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-07-26 18:38:59 +02:00
|
|
|
} else if(type == 'other research products') {
|
|
|
|
resultTypeId = 'other';
|
|
|
|
requestType = 'other';
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2018-02-05 14:14:59 +01:00
|
|
|
let url = csvAPIURL;
|
2019-04-02 17:33:01 +02:00
|
|
|
url += '?format=html&type='+requestType+'&fq=(((oaftype exact result) and (resulttypeid exact "'+resultTypeId+'")) and (relprojectid exact "'+id+'"))';
|
2018-02-05 14:14:59 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
let key = url;
|
|
|
|
|
|
|
|
return this.http.get(url)
|
2019-06-03 15:20:36 +02:00
|
|
|
.pipe(map(res => {
|
|
|
|
let resText:any = res;
|
|
|
|
return resText.text();
|
|
|
|
}));
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
}
|