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

43 lines
1.3 KiB
TypeScript

import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {HttpClient} from "@angular/common/http";
import {Observable} from 'rxjs';
import {map} from "rxjs/operators";
@Injectable()
export class HtmlProjectReportService {
constructor(private http: HttpClient ) {}
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)
.pipe(map(res => {
let resText:any = res;
return resText.text();
}));
}
}