FarmMapsLib/projects/common/src/fm/services/codelistitem.service.ts
Peter Bastiani 587e484cf8
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
AW-835 Remove validFrom/To filter from interface.
2020-01-21 18:15:50 +01:00

26 lines
919 B
TypeScript

import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { HttpClient, HttpParams } from "@angular/common/http";
import { AppConfig } from "../shared/app.config";
import { ICodeListItem } from '../models/code.list.item';
@Injectable({
providedIn: 'root',
})
export class CodeListItemService {
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
}
ApiEndpoint() {
return this.appConfig.getConfig("apiEndPoint");
}
getCodeListItems(codelist: string[], codegroup?: string, dataFilter?: any): Observable<ICodeListItem[]> {
var params = new HttpParams();
params = params.append("cl", codelist.join(","));
if (codegroup) params = params.append("g", codegroup);
if (dataFilter) params = params.append("df", dataFilter);
return this.httpClient.get<ICodeListItem>(`${this.ApiEndpoint()}/api/v1/codelistitems/`, { params: params });
}
}