Aw-5739 Add data download service
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
29
projects/common/src/fm/services/download.service.ts
Normal file
29
projects/common/src/fm/services/download.service.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { IItem } from '../models/item';
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { AppConfig } from "../shared/app.config";
|
||||
import {ItemTypeService} from './itemtype.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class DownloadService {
|
||||
constructor(public httpClient: HttpClient, public appConfig: AppConfig,private itemTypeService:ItemTypeService) {
|
||||
}
|
||||
|
||||
ApiEndpoint() {
|
||||
return this.appConfig.getConfig("apiEndPoint");
|
||||
}
|
||||
|
||||
getData(itemCode: string): Observable<any> {
|
||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${itemCode}/data`);
|
||||
}
|
||||
|
||||
getData2(item: IItem): Observable<any> {
|
||||
if (item.size > 0) {
|
||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${item.code}/data`)
|
||||
}
|
||||
return of({});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user