Aw-5739 Add data download service
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Peter Bastiani 2024-01-11 13:37:25 +01:00
parent 5714cdce72
commit ce2f06091b
2 changed files with 31 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import { EventService } from './services/event.service';
import { TypeaheadService } from './services/typeahead.service';
import { UserService } from './services/user.service';
import { ImageService } from './services/image.service';
import { DownloadService } from './services/download.service';
import { GeolocatorService } from './services/geolocator.service';
import { WeatherService} from './services/weather.service';
import { AppConfig } from './shared/app.config';
@ -48,6 +49,7 @@ export {
TypeaheadService,
UserService,
ImageService,
DownloadService,
GeolocatorService,
WeatherService,
AppConfig,

View 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({});
}
}