{"version":3,"sources":["webpack:///./node_modules/@abaco/fibeo-module/src/modules/fibeo-dashboard-module/models/FibeoModel.ts","webpack:///./node_modules/@abaco/fibeo-module/src/modules/fibeo-dashboard-module/api/FibeoApi.ts"],"names":["fromDashboardVarietyToVarietyBase","e","id","item_id","code","crop_code","description","variety","fromVarietyToVarietyBase","fromVegetativeCycleToVarietyBase","seed_code","seed_name","FibeoApi","http","this","get","res","data","campaign","subject","lotId","params","getProductionCommon","blockId","varietyId","type","productionData","farmOrScs","idoneita","pkCuaa","plotId","search","paging","filter","push","toUpperCase","offset","length","undefined","count","include_geometry","include_planting","base","map","varieties","totalcount","getBlockVarieties","curPage","records","getPlotVarieties","getBlocks"],"mappings":"kPAwGM,SAAUA,EAAkCC,GAC9C,MAAO,CACHC,GAAID,EAAEE,QACNC,KAAMH,EAAEI,UACRC,YAAaL,EAAEM,SAIjB,SAAUC,EAAyBP,GACrC,MAAO,CACHC,GAAID,EAAEE,QACNC,KAAMH,EAAEI,UACRC,YAAaL,EAAEM,SAIjB,SAAUE,EAAiCR,GAC7C,MAAO,CACHC,GAAID,EAAEE,QACNC,KAAMH,EAAES,UACRJ,YAAaL,EAAEU,W,ICvHFC,E,WAGjB,WAAYC,GAAgB,uBACxBC,KAAKD,KAAOA,E,0GAGhB,oHACsBC,KAAKD,KAAKE,IAAV,wCADtB,cACUC,EADV,yBAEWA,EAAIC,MAFf,gD,qJAKA,WAA4BC,EAAkBC,GAA9C,4GAA+DC,EAA/D,+BAAsF,KAC5EC,EAAS,CACXD,SAFR,kBAIWN,KAAKQ,oBAAoBJ,EAAUC,EAAS,QAASE,IAJhE,gD,6JAOA,WAAiCH,EAAkBC,GAAnD,8GAAoEC,EAApE,+BAA2F,KAAMG,EAAjG,+BAA0H,KAChHF,EAAS,CACXD,QACAG,WAHR,kBAKWT,KAAKQ,oBAAoBJ,EAAUC,EAAS,UAAWE,IALlE,gD,uJAQA,WAA2BH,EAAkBC,GAA7C,gHAA8DC,EAA9D,+BAAqF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,KAAKD,KAAKE,IAAV,6DAAoEc,EAApE,mCAA6G,CAC3HR,OAAQ,CACJY,SACAG,OAAQJ,EAAOI,OACfG,MAAOP,EAAOO,SATnB,cAKGvB,EALH,yBAYIA,EAAIC,MAZR,gD,mJAeA,WAAmBY,EAAgBX,EAAkBY,GAArD,6FACCS,EAAQ,EACRvB,EAAkB,GAClB6B,EAAa,EAHd,uBAKuB/B,KAAKoC,UAAUrB,EAAQX,EAAU,CAAEkB,OAAQG,EAAOA,MAAO,KAAOT,GALvF,OAKOiB,EALP,OAMCR,GAASQ,EAAQR,MACjBM,EAAaE,EAAQF,WACrB7B,EAAM,GAAH,sBAAOA,GAAP,eAAe+B,EAAQC,UAR3B,UASMT,EAAQM,EATd,iDAUI7B,GAVJ,iD","file":"js/chunk-74672140.020fcd67.js","sourcesContent":["export interface Uga {\n codComune: string;\n code: string;\n description: string;\n name: string;\n wktGshape: string; \n}\nexport interface Card {\n icon: string;\n label: string;\n value: string;\n unit?: string;\n}\n\nexport interface SummaryProduction {\n estimetedCurrentYearQli: number;\n effectiveCurrentYearQli: number;\n previousYearQli: number;\n averageRecentYearsQli: number;\n estimetedCurrentYearKg: number;\n effectiveCurrentYearKg: number;\n previousYearKg: number;\n averageRecentYearsKg: number;\n}\n\nexport interface Summary {\n numberOfEvaluations: number;\n vineyardMonitored: number;\n avgWeightBunch: number;\n numberOfBunchesForPlant: number;\n productionPerPlant: SummaryProduction;\n productionPerHa: SummaryProduction;\n totalProduction: SummaryProduction;\n}\n\nexport interface ScsSummary {\n numberOfFarms: number;\n area: number;\n numberVarietyUsed: number;\n avgProductionPerPlant: SummaryProduction;\n avgProductionPerHa: SummaryProduction;\n avgProductionPerFarm: SummaryProduction;\n totalProductionForScs: SummaryProduction;\n}\n\nexport interface FibeoItem {\n id: number;\n name: string;\n description: string;\n}\n\nexport interface TodoItem {\n completed: boolean;\n id: number;\n title: string;\n userId: number;\n}\n\nexport interface Variety {\n area_ha: number;\n campaign: number;\n crop_code: string;\n rotation: number;\n scs_subject_id: number;\n seed_variety_id: number | null;\n item_id: number | null;\n subject_id: number;\n subject_name: string;\n variety: string;\n}\n\nexport interface DashboardVariety {\n agm_group_code: string;\n area_ha: number;\n campaign: number;\n crop_code: string;\n rotation: number;\n scs_subject_id: number;\n seed_variety_id: number;\n item_id: number;\n subject_id: number;\n subject_name: string;\n variety: string;\n}\n\nexport interface VarietyBase {\n id: number | null;\n code: string;\n description: string;\n}\n\nexport interface VegetativeCycle {\n cycle_id: number;\n cycle_number: number;\n end_date: number;\n precocity_description: string;\n seed_code: string;\n seed_id: number;\n seed_name: string;\n seed_variety_id: number;\n item_id: number;\n start_date: number;\n}\n\nexport function fromDashboardVarietyToVarietyBase(e: DashboardVariety): VarietyBase {\n return {\n id: e.item_id,\n code: e.crop_code,\n description: e.variety,\n }\n}\n\nexport function fromVarietyToVarietyBase(e: Variety): VarietyBase {\n return {\n id: e.item_id,\n code: e.crop_code,\n description: e.variety,\n }\n}\n\nexport function fromVegetativeCycleToVarietyBase(e: VegetativeCycle): VarietyBase {\n return {\n id: e.item_id,\n code: e.seed_code,\n description: e.seed_name,\n }\n}","import { Block, Planting } from '@abaco/portal-global-state/src/modules/global-state/models/Block';\nimport { HTTPClient } from '@abaco/web-common/src/HTTP';\nimport { PagedResults, PagingParams } from '@abaco/web-common/src/Paging';\nimport { DashboardVariety, fromDashboardVarietyToVarietyBase, fromVarietyToVarietyBase, fromVegetativeCycleToVarietyBase, ScsSummary, Summary, Uga, Variety, VarietyBase, VegetativeCycle } from '../models/FibeoModel';\n\nexport default class FibeoApi {\n private http: HTTPClient;\n\n constructor(http: HTTPClient) {\n this.http = http;\n }\n\n async getUGAList() {\n const res = await this.http.get(`/fibeo-api/api/v1/config/catalog/uga`);\n return res.data;\n }\n\n async getProductionVineyard(campaign: number, subject: number, lotId: number | null = null) {\n const params = {\n lotId\n }\n return this.getProductionCommon(campaign, subject, \"vigna\", params);\n }\n\n async getProductionVineyardBlock(campaign: number, subject: number, lotId: number | null = null, blockId: number | null = null) {\n const params = {\n lotId,\n blockId,\n }\n return this.getProductionCommon(campaign, subject, \"vigneto\", params);\n }\n\n async getProductionVariety(campaign: number, subject: number, lotId: number | null = null, blockId: number | null = null, varietyId: number | null = null) {\n const params = {\n lotId,\n blockId,\n varietyId\n }\n return this.getProductionCommon(campaign, subject, \"vitigno\", params);\n }\n\n async getProductionScs(campaign: number, subject: number, type: \"scs\" | \"uga\" | \"scs_vitigno\", params: { uga: string } | null = null): Promise {\n const res = await this.http.get(`/fibeo-api/api/v1/scs/${subject}/campaign/${campaign}/production/${type}`, { params });\n return res.data.productionData;\n }\n\n async getProductionCommon(campaign: number, subject: number, type: \"vigna\" | \"vigneto\" | \"vitigno\", params: any): Promise {\n const res = await this.http.get(`/fibeo-api/api/v1/farm/${subject}/campaign/${campaign}/production/${type}`, { params });\n return res.data.productionData;\n }\n\n async getProductionSummary(campaign: number, subject: number, farmOrScs = \"farm\", lotId: number | null = null, blockId: number | null = null, varietyId: string | null = null, idoneita: string | null = null): Promise {\n const params = {\n lotId,\n blockId,\n varietyId,\n idoneita,\n }\n const res = await this.http.get(`/fibeo-api/api/v1/${farmOrScs}/${subject}/campaign/${campaign}/production/summary`, { params });\n return res.data;\n }\n\n async getProductionHistory(campaign: number, subject: number, farmOrScs = \"farm\", lotId: number | null = null, blockId: number | null = null, varietyId: string | null = null, idoneita: string | null = null) {\n const params = {\n lotId,\n blockId,\n varietyId,\n idoneita,\n }\n const res = await this.http.get(`/fibeo-api/api/v1/${farmOrScs}/${subject}/campaign/${campaign}/production/historical`, { params });\n return res.data;\n }\n\n public async getBlocksOldOnlyFirstLevel(pkCuaa: number, campaign: number, plotId: number, search: string | null, paging: PagingParams): Promise> {\n const filter = [];\n filter.push(`block_level eq 1`);\n if (search) {\n filter.push(`^block_code like ${search.toUpperCase()}`);\n }\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plotId}/blocks`, {\n params: {\n offset: paging.offset,\n filter: filter.length ? filter : undefined,\n count: paging.count,\n include_geometry: true,\n include_planting: true\n }\n })\n return res.data;\n }\n\n public async getVarieties(pkCuaa: number, campaign: number, filter: string | null): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/dashboard/subjects/${pkCuaa}/campaigns/${campaign}/varieties`, {\n params: {\n filter: filter ? `^variety like ${filter.toUpperCase()}` : undefined,\n }\n });\n const base = res.data.map((e: Variety) => fromVarietyToVarietyBase(e));\n return base;\n }\n\n public async getAllDashboardPlotVarieties(pkCuaa: number, campaign: number, plotId: number, filter: string | null): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/dashboard/subjects/${pkCuaa}/campaigns/${campaign}/varieties_v2?plot_id=${plotId}`, {\n params: {\n filter: filter ? `^seed_name like ${filter.toUpperCase()}` : undefined,\n }\n });\n const base = res.data.varieties.map((e: DashboardVariety) => fromDashboardVarietyToVarietyBase(e));\n return base\n }\n\n public async getBlockVarieties(pkCuaa: number, campaign: number, plotId: number, blockId: number, filter: string | null, paging: PagingParams): Promise> {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plotId}/blocks/${blockId}/vegetative_cycles`, {\n params: {\n filter: filter ? `^seed_name like ${filter.toUpperCase()}` : undefined,\n offset: paging.offset,\n count: paging.count,\n }\n });\n return res.data;\n }\n\n public async getAllBlockVarieties(pkCuaa: number, campaign: number, plotId: number, blockId: number, filter: string | null): Promise {\n let count = 0;\n let res: VegetativeCycle[] = [];\n let totalcount = 0;\n do {\n const curPage = await this.getBlockVarieties(pkCuaa, campaign, plotId, blockId, filter, { offset: count, count: 300 });\n count += curPage.count;\n totalcount = curPage.totalcount;\n res = [...res, ...curPage.records];\n } while (count < totalcount)\n const base = res.map((e: VegetativeCycle) => fromVegetativeCycleToVarietyBase(e));\n return base;\n }\n\n public async getAllPlotVarieties(pkCuaa: number, campaign: number, plotId: number, filter: string | null): Promise {\n let count = 0;\n let res: VegetativeCycle[] = [];\n let totalcount = 0;\n do {\n const curPage = await this.getPlotVarieties(pkCuaa, campaign, plotId, filter, { offset: count, count: 300 });\n count += curPage.count;\n totalcount = curPage.totalcount;\n res = [...res, ...curPage.records];\n } while (count < totalcount)\n const base = res.map((e: VegetativeCycle) => fromVegetativeCycleToVarietyBase(e));\n return base;\n }\n\n public async getPlotVarieties(pkCuaa: number, campaign: number, plotId: number, filter: string | null, paging: PagingParams): Promise> {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plotId}/vegetative_cycles`, {\n params: {\n filter: filter ? `^seed_name like ${filter.toUpperCase()}` : undefined,\n offset: paging.offset,\n count: paging.count,\n }\n });\n return res.data;\n }\n\n public async getBlocks(pkCuaa: number, campaign: number, paging: PagingParams, plotId: number | undefined): Promise> {\n const filter = [];\n filter.push(`campaign eq ${campaign}`);\n if(plotId) filter.push(`plot_id eq ${plotId}`);\n\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/dashboard/subjects/${pkCuaa}/plantings?include_graphic=true`, {\n params: {\n filter,\n offset: paging.offset,\n count: paging.count,\n }\n });\n return res.data;\n }\n\n public async getAllBlocks(pkCuaa: number, campaign: number, plotId: number | undefined): Promise {\n let count = 0;\n let res: Planting[] = [];\n let totalcount = 0;\n do {\n const curPage = await this.getBlocks(pkCuaa, campaign, { offset: count, count: 300 }, plotId);\n count += curPage.count;\n totalcount = curPage.totalcount;\n res = [...res, ...curPage.records];\n } while (count < totalcount)\n return res;\n }\n}\n"],"sourceRoot":""}