openaire-library/landingPages/htmlProjectReport/htmlProjectReport.service.ts

38 lines
1.2 KiB
TypeScript

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 ) {}
getHTML(id: string, size: number, type:string, csvAPIURL: string ):any {
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'
} else if(type == 'other research products') {
resultTypeId = 'other';
requestType = 'other';
}
let url = csvAPIURL;
url += '?format=html&type='+requestType+'&fq=(((oaftype exact result) and (resulttypeid exact '+resultTypeId+')) and (relprojectid exact "'+id+'"))';
let key = url;
return this.http.get(url)
.map(res => <any> res.text());
}
}