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

36 lines
1.1 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 {
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'
}
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());
}
}