{"version":3,"sources":["webpack:///./node_modules/@abaco/crop-plan-module/src/modules/crop-plan-module/api/PlantingApi.ts"],"names":["PlantingApi","http","this","plot_id","block_id","get","res","data","params","offset","count","records","editedPlanting","put","delete","env","url","post","wkt","gptoken","unauthHttp","HTTPClient","filter","paging","filters","push","toUpperCase","length","undefined","str","charAt","slice","toLowerCase"],"mappings":"qPAIqBA,E,WAIjB,WAAYC,GAAgB,uBACxBC,KAAKD,KAAOA,E,kHAGhB,WAAyBE,EAAiBC,GAA1C,uGACsBF,KAAKD,KAAKI,IAAV,sDAA6DF,EAA7D,mBAA+EC,EAA/E,uBADtB,cACUE,EADV,yBAGWA,EAAIC,MAHf,gD,qJAMA,oHACsBL,KAAKD,KAAKI,IAAV,mEAAkF,CAChGG,OAAQ,CACJC,OAAQ,EACRC,MAAO,OAJnB,cACUJ,EADV,yBAQWA,EAAIC,KAAKI,SARpB,gD,kJAWA,oHACsBT,KAAKD,KAAKI,IAAV,mEAAkF,CAChGG,OAAQ,CACJC,OAAQ,EACRC,MAAO,OAJnB,cACUJ,EADV,yBAQWA,EAAIC,KAAKI,SARpB,gD,kJAWA,oHACsBT,KAAKD,KAAKI,IAAV,mEAAkF,CAChGG,OAAQ,CACJC,OAAQ,EACRC,MAAO,OAJnB,cACUJ,EADV,yBAQWA,EAAIC,KAAKI,SARpB,gD,4IAWA,WAAmBR,EAAiBC,EAAkBQ,GAAtD,uGACsBV,KAAKD,KAAKY,IAAV,sDAA6DV,EAA7D,mBAA+EC,EAA/E,aAAoGQ,GAD1H,cACUN,EADV,yBAGWA,EAAIC,MAHf,gD,mJAMA,WAAqBJ,EAAiBC,GAAtC,uGACsBF,KAAKD,KAAKa,OAAV,sDAAgEX,EAAhE,mBAAkFC,EAAlF,cADtB,cACUE,EADV,yBAGWA,EAAIC,MAHf,gD,6IAMA,+GACUQ,EAAM,CACR,IAAO,eACP,QAAW,KACX,OAAU,KACV,SAAY,mBAGVC,EAAM,8CARhB,SASsBd,KAAKD,KAAKgB,KAAKD,EAAKD,GAT1C,cASUT,EATV,yBAUWA,EAAIC,MAVf,gD,kJAaA,WAAyBW,EAAaC,GAAtC,oGACUC,EAAa,IAAIC,OAEjBL,EAAM,oDACNR,EAAS,CACXU,MACAC,WANR,SAQsBC,EAAWf,IAAIW,EAAK,CAACR,WAR3C,cAQUF,EARV,yBASWA,EAAIC,MATf,2C,2JAYA,WAA+Be,EAAuBC,GAAtD,gGACUC,EAAU,GACbF,GACCE,EAAQC,KAAR,oCAA0CH,EAAOI,gBAHzD,SAKsBxB,KAAKD,KAAKI,IAAV,oEAAmF,CACjGG,OAAQ,CACJc,OAAQE,EAAQG,OAAS,EAAIH,OAAUI,EACvClB,MAAOa,EAAOb,MACdD,OAAQc,EAAOd,UAT3B,cAKUH,EALV,yBAaWA,EAAIC,MAbf,gD,gJAgBA,oHACsBL,KAAKD,KAAKI,IAAV,kEAAiF,CAC/FG,OAAQ,CACJE,MAAO,IACPD,OAAQ,KAJpB,cACUH,EADV,yBAOWA,EAAIC,KAAKI,SAPpB,gD,4IAUA,oHACsBT,KAAKD,KAAKI,IAAV,8DAA6E,CAC3FG,OAAQ,CACJE,MAAO,IACPD,OAAQ,KAJpB,cACUH,EADV,yBAOWA,EAAIC,KAAKI,SAPpB,gD,mJAUA,oHACsBT,KAAKD,KAAKI,IAAV,mEAAkF,CAChGG,OAAQ,CACJE,MAAO,IACPD,OAAQ,KAJpB,cACUH,EADV,yBAOWA,EAAIC,KAAKI,SAPpB,gD,8EAWQ,SAAQkB,GACZ,OAAGA,GAAOA,EAAIF,OAAS,EACZE,EAAIC,OAAO,GAAGJ,cAAgBG,EAAIE,MAAM,GAAGC,cAE3C,O","file":"js/chunk-2d0cb78f.f5257c42.js","sourcesContent":["import { TrainingSystem, IrrigationType, PlantingOut, Planting, VineyardDenomination, VineyardRootstock, VineyardLayering, VegetativeState, ProtectionType } from './../models/Block';\nimport { HTTPClient } from '@abaco/web-common/src/HTTP';\nimport { NumTreeEstimate, PlotMbr } from '../models/Plot';\nimport { PagedResults, PagingParams } from '@abaco/web-common/src/Paging';\nexport default class PlantingApi {\n\n private http: HTTPClient;\n\n constructor(http: HTTPClient) {\n this.http = http;\n }\n\n async getPlantingDefault(plot_id: number, block_id: number): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/blocks/${block_id}/planting_defaults`)\n\n return res.data;\n }\n\n async getTrainingSystems(): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/dictionary_training_system`, {\n params: {\n offset: 0,\n count: 300\n }\n })\n\n return res.data.records\n }\n\n async getIrrigationTypes(): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/dictionary_irrigation_type`, {\n params: {\n offset: 0,\n count: 300\n }\n })\n\n return res.data.records\n }\n\n async getProtectionTypes(): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/dictionary_protection_type`, {\n params: {\n offset: 0,\n count: 300\n }\n })\n\n return res.data.records\n }\n\n async editPlanting(plot_id: number, block_id: number, editedPlanting: PlantingOut): Promise {\n const res = await this.http.put(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/blocks/${block_id}/planting`, editedPlanting);\n\n return res.data\n }\n\n async deletePlanting(plot_id: number, block_id: number): Promise {\n const res = await this.http.delete(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/blocks/${block_id}/planting`);\n\n return res.data;\n }\n\n async getGpToken(): Promise{\n const env = {\n \"env\": \"PORTALE_PROD\",\n \"context\": null,\n \"userid\": null,\n \"password\": \"aBACFarm3r2020!\"\n };\n // {\"env\":\"PORTALE_PROD\",\"context\":null,\"userid\":null,\"password\":\"aBACFarm3r2020!\"}\n const url = \"https://geoproxy-prod.abacofarmer.com/login\";\n const res = await this.http.post(url, env);\n return res.data;\n }\n\n async getNumTreeEstimate(wkt: string, gptoken: string): Promise{\n const unauthHttp = new HTTPClient();\n // const url = \"http://ec2-18-193-171-42.eu-central-1.compute.amazonaws.com/counting-trees/api/v1.0/countingtreesdemo/countTreesFast\";\n const url = \"/counting-trees/api/v1.0/countingtrees/countTrees\";\n const params = {\n wkt,\n gptoken\n }\n const res = await unauthHttp.get(url, {params});\n return res.data;\n }\n\n async getVineyardDenominations(filter: string | null, paging: PagingParams): Promise> {\n const filters = [];\n if(filter){\n filters.push(`^ds_designation_type like ${filter.toUpperCase()}`)\n }\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/dictionary_designation_type`, {\n params: {\n filter: filters.length > 0 ? filters : undefined,\n count: paging.count,\n offset: paging.offset\n }\n });\n //res.data.records = res.data.records.map((e: VineyardDenomination) => { return {...e, ds_designation_type: this.ucFirst(e.ds_designation_type)} }); removed per #95346\n return res.data;\n }\n\n async getRootstocks(): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/dictionary_rootstock_type`, {\n params: {\n count: 300,\n offset: 0\n }\n });\n return res.data.records;\n }\n\n async getLayerings(): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/dictionary_lying_type`, {\n params: {\n count: 300,\n offset: 0\n }\n });\n return res.data.records;\n }\n\n async getVegetativeStates(): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/dictionary_veg_status_type`, {\n params: {\n count: 300,\n offset: 0\n }\n });\n return res.data.records;\n }\n\n //lowercase string and uppercase first letter\n private ucFirst(str: string | null): string{\n if(str && str.length > 0){\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();\n } else {\n return \"\";\n }\n }\n\n}\n"],"sourceRoot":""}