2018-03-29 16:15:47 +02:00
|
|
|
import {Injectable} from '@angular/core';
|
2019-06-03 15:20:36 +02:00
|
|
|
import {HttpClient} from "@angular/common/http";
|
2018-03-29 16:15:47 +02:00
|
|
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
2019-06-05 15:33:18 +02:00
|
|
|
import {map} from "rxjs/operators";
|
2018-03-29 16:15:47 +02:00
|
|
|
|
|
|
|
@Injectable()
|
2018-04-04 14:35:31 +02:00
|
|
|
export class SearchCommunityProjectsService {
|
2019-06-03 15:20:36 +02:00
|
|
|
constructor(private http: HttpClient ) {}
|
2018-03-29 16:15:47 +02:00
|
|
|
|
2023-09-19 14:59:37 +02:00
|
|
|
searchProjects (properties:EnvProperties, pid: string, page=1, size=500):any {
|
|
|
|
this.searchProjectsWithPaging(properties,pid,page, size, null, null);
|
|
|
|
}
|
|
|
|
searchProjectsWithPaging (properties:EnvProperties, pid: string, page=1, size=500, searchFilter, funder):any {
|
|
|
|
let params = funder ? ["funder="+ funder] :[];
|
|
|
|
if (searchFilter) {
|
|
|
|
params.push("searchFilter="+ searchFilter)
|
|
|
|
}
|
|
|
|
let url = properties.communityAPI+pid+"/projects/"+ (page-1) + "/" + size + (params.length > 0?"?" + params.join("&"):"");
|
2019-06-03 15:20:36 +02:00
|
|
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
|
2018-03-29 16:15:47 +02:00
|
|
|
}
|
2020-04-08 13:25:41 +02:00
|
|
|
countTotalProjects(properties:EnvProperties,pid:string) {
|
2023-07-14 12:55:47 +02:00
|
|
|
let url = properties.communityAPI+pid+"/projects/0/1";
|
2019-06-05 15:33:18 +02:00
|
|
|
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
2023-07-14 10:40:38 +02:00
|
|
|
.pipe(map(res => res['totalElements']));
|
2019-06-05 15:33:18 +02:00
|
|
|
}
|
2018-03-29 16:15:47 +02:00
|
|
|
}
|