FarmMapsLib/projects/common/src/fm/services/codelistitem.service.ts

26 lines
911 B
TypeScript
Raw Normal View History

2020-01-21 13:52:36 +00:00
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[]> {
2020-01-21 13:52:36 +00:00
var params = new HttpParams();
2020-01-22 12:57:56 +00:00
params = params.append("cl", codelist);
2020-01-21 13:52:36 +00:00
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 });
2020-01-21 13:52:36 +00:00
}
}