openaire-library/connect/projects/searchProjects.service.ts

22 lines
922 B
TypeScript

import {Injectable} from '@angular/core';
import {HttpClient} from "@angular/common/http";
import{EnvProperties} from '../../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable()
export class SearchCommunityProjectsService {
constructor(private http: HttpClient ) {}
searchProjects (properties:EnvProperties, pid: string, page=0, size=500):any {
let url = properties.communityAPI+pid+"/projects/"+ page + "/" + size;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
//.map(res => <any> res.json())
}
countTotalProjects(properties:EnvProperties,pid:string) {
let url = properties.communityAPI+pid+"/projects/0/1";
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => res['totalElements']));
}
}