{"version":3,"sources":["webpack:///./node_modules/@abaco/assets-module/src/modules/assets-module/api/BuildingApi.ts"],"names":["BuildingApi","http","rootPath","this","cancelTokenSource","pk_cuaa","paging","filter","onlyTractors","onlyImplements","filterArr","push","toUpperCase","get","params","offset","count","length","undefined","res","data","fk_external_id","records","pkCuaa","machineId","pkid","detailOut","put","post","delete","onlyActive","long","lat","councilId","get_mbr","mbr","councilCode","measure_family_name","id"],"mappings":"uMAkBqBA,G,+BAKjB,WAAYC,EAAkBC,GAAgB,uBAC1CC,KAAKF,KAAOA,EACZE,KAAKD,SAAWA,EAChBC,KAAKC,kBAAoB,K,4GAGtB,WACHC,EACAC,EACAC,EACAC,EACAC,GALG,gGAWGC,EAAY,GACdH,GACAG,EAAUC,KAAV,4BAAoCJ,EAAOK,gBAb5C,SAeeT,KAAKF,KAAKY,IAAV,UAAiBV,KAAKD,SAAtB,kCAAwDG,EAAxD,cAA6E,CAC3FS,OAAQ,CACJC,OAAQT,EAAOS,OACfC,MAAOV,EAAOU,MACdT,OAAQG,EAAUO,OAAS,EAAIP,OAAYQ,KAnBhD,cAeGC,EAfH,yBAsBIA,EAAIC,MAtBR,gD,oKAyBA,WAAkCf,EAAiBgB,GAAnD,uGACelB,KAAKF,KAAKY,IAAV,UAAiBV,KAAKD,SAAtB,kCAAwDG,EAAxD,cAA6E,CAC3FS,OAAQ,CACJP,OAAQ,kBAAF,OAAoBc,MAH/B,cACGF,EADH,yBAMIA,EAAIC,KAAKE,QAAQ,IANrB,gD,wJASA,WAA4BjB,GAA5B,uGACeF,KAAKF,KAAKY,IAAV,UAAiBV,KAAKD,SAAtB,kCAAwDG,EAAxD,eADf,cACGc,EADH,yBAEIA,EAAIC,MAFR,gD,4IAKA,WAAkBG,EAAgBC,GAAlC,uGACerB,KAAKF,KAAKY,IAAV,UAAiBV,KAAKD,SAAtB,kCAAwDqB,EAAxD,sBAA4EC,IAD3F,cACGL,EADH,yBAEIA,EAAIC,MAFR,gD,sJAIA,WAA0BG,EA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AAKE,SARb,gD,qJA6BA,WACHC,EACAe,EACAZ,GAHG,uGAKevB,KAAKF,KAAK0B,IAAV,UAAiBxB,KAAKD,SAAtB,kCAAwDqB,EAAxD,kBAAwEe,GAAMZ,GAL7F,cAKGP,EALH,yBAMIA,EAAIC,MANR,gD,yJAQA,WAA2BG,EAAgBG,GAA3C,uGACevB,KAAKF,KAAK2B,KAAV,UAAkBzB,KAAKD,SAAvB,kCAAyDqB,EAAzD,UAAyEG,GADxF,cACGP,EADH,yBAEIA,EAAIC,MAFR,gD,uJAIA,WAA2BG,EAAgBe,GAA3C,uGACenC,KAAKF,KAAK4B,OAAV,UAAoB1B,KAAKD,SAAzB,kCAA2DqB,EAA3D,kBAA2Ee,IAD1F,cACGnB,EADH,yBAEIA,EAAIC,MAFR,gD,8IAKA,WAAkBf,EAAiBE,GAAnC,gGAKGG,EAAY,GACdH,GACAG,EAAUC,KAAV,4BAAoCJ,EAAOK,gBAE/CF,EAAUC,KAAV,wBATG,SAUeR,KAAKF,KAAKY,IAAV,UAAiBV,KAAKD,SAAtB,mCAAyDG,EAAzD,eAA+E,CAC7FS,OAAQ,CACJC,OAAQ,EACRC,MAAO,IACPT,OAAQG,EAAUO,OAAS,EAAIP,OAAYQ,KAdhD,cAUGC,EAVH,yBAiBIA,EAAIC,KAAKE,SAjBb,gD","file":"js/chunk-2d2304d0.b83463c5.js","sourcesContent":["import { HTTPClient } from \"@abaco/web-common/src/HTTP\";\nimport axios, { CancelTokenSource } from \"axios\";\nimport { PagedResults, PagingParams } from \"@abaco/web-common/src/Paging\";\nimport {\n Building,\n BuildingOut,\n BuildingFilter,\n BuildingType,\n ProductionAreaOut,\n ProductionAreaUpdateOut,\n BuildingGeometry,\n Council,\n ProductionArea,\n CouncilSector\n} from \"../models/Building\";\nimport { UnitOfMeasure } from \"../models/UnitsOfMeasure\";\nimport { Equipment, Implant } from \"../models/Equipment\";\n\nexport default class BuildingApi {\n private http: HTTPClient;\n private rootPath: string;\n private cancelTokenSource: CancelTokenSource | null;\n\n constructor(http: HTTPClient, rootPath: string) {\n this.http = http;\n this.rootPath = rootPath;\n this.cancelTokenSource = null;\n }\n\n public async getBuildings(\n pk_cuaa: number,\n paging: PagingParams,\n filter: string | null,\n onlyTractors?: boolean,\n onlyImplements?: boolean\n ): Promise> {\n // if (this.cancelTokenSource) {\n // this.cancelTokenSource.cancel();\n // }\n //this.cancelTokenSource = axios.CancelToken.source();\n const filterArr = [];\n if (filter) {\n filterArr.push(`^description like ${filter.toUpperCase()}`);\n }\n const res = await this.http.get(`${this.rootPath}/v1/buildings/subjects/${pk_cuaa}/buildings`, {\n params: {\n offset: paging.offset,\n count: paging.count,\n filter: filterArr.length > 0 ? filterArr : undefined\n }\n });\n return res.data;\n }\n\n public async getBuildingInfoByExternalId(pk_cuaa: number, fk_external_id: number): Promise {\n const res = await this.http.get(`${this.rootPath}/v1/buildings/subjects/${pk_cuaa}/buildings`, {\n params: {\n filter: `building_id eq ${fk_external_id}`\n }\n });\n return res.data.records[0];\n }\n\n public async getWarehouseBuildings(pk_cuaa: number): Promise {\n const res = await this.http.get(`${this.rootPath}/v1/buildings/subjects/${pk_cuaa}/buildings`);\n return res.data;\n }\n\n public async getBuilding(pkCuaa: number, machineId: number): Promise {\n const res = await this.http.get(`${this.rootPath}/v1/buildings/subjects/${pkCuaa}/buildings/${machineId}`);\n return res.data;\n }\n public async getBuildingGeometry(pkCuaa: number, machineId: number): Promise {\n const res = await this.http.get(\n `${this.rootPath}/v1/buildings/subjects/${pkCuaa}/buildings/${machineId}/wkt_geometry`\n );\n return res.data;\n }\n public async editBuilding(pkCuaa: number, pkid: number, detailOut: BuildingOut): Promise {\n const res = await this.http.put(\n `${this.rootPath}/v1/buildings/subjects/${pkCuaa}/buildings/${pkid}`,\n detailOut\n );\n return res.data;\n }\n public async insertBuilding(pkCuaa: number, detailOut: BuildingOut): Promise {\n const res = await this.http.post(`${this.rootPath}/v1/buildings/subjects/${pkCuaa}/buildings`, detailOut);\n return res.data;\n }\n public async deleteBuilding(pkCuaa: number, pkid: number): Promise {\n const res = await this.http.delete(`${this.rootPath}/v1/buildings/subjects/${pkCuaa}/buildings/${pkid}`);\n return res.data;\n }\n\n public async getOwnershipTypes(): Promise {\n const res = await this.http.get(`${this.rootPath}/v1/buildings/dictionary_buildings/ownership_types`, {\n params: {\n offset: 0,\n count: 300\n }\n });\n return res.data.records;\n }\n\n public async getBuildingTypes(): Promise {\n const res = await this.http.get(`${this.rootPath}/v1/buildings/dictionary_buildings/types`, {\n params: {\n offset: 0,\n count: 300\n }\n });\n return res.data.records;\n }\n\n public async getCouncils(\n paging: PagingParams,\n filter: string | null,\n onlyActive: boolean,\n long: number | null,\n lat: number | null\n ): Promise> {\n const filterArr = [];\n if (onlyActive) {\n filterArr.push(\"fg_active eq 1\");\n }\n if (filter) {\n filterArr.push(`^council_label like ${filter.toUpperCase()}`);\n }\n const res = await this.http.get(\"/sitiagri-rest-api/api_basic/v1/plots/dictionary_councils\", {\n params: {\n lat: lat && long ? lat : undefined,\n long: lat && long ? long : undefined,\n offset: paging.offset,\n count: paging.count,\n filter: filterArr.length ? filterArr : undefined\n }\n });\n return res.data;\n }\n\n public async getCouncilSector(\n paging: PagingParams,\n filter: string | null,\n onlyActive: boolean,\n councilId: number | null,\n ): Promise> {\n const filterArr = [];\n if (onlyActive) {\n filterArr.push(\"fg_active eq 1\");\n }\n if (filter) {\n filterArr.push(`^council_sector_label like ${filter.toUpperCase()}`);\n }\n if (councilId) {\n filterArr.push(`council_id eq ${councilId}`);\n }\n const res = await this.http.get(\"/sitiagri-rest-api/api_basic/v1/plots/dictionary_councils_sectors\", {\n params: {\n offset: paging.offset,\n count: paging.count,\n filter: filterArr.length ? filterArr : undefined\n }\n });\n return res.data;\n }\n\n\n public async getCouncilMbr(councilId: number): Promise {\n const res = await this.http.get(\"/sitiagri-rest-api/api_basic/v1/plots/dictionary_councils\", {\n params: {\n offset: 0,\n count: 1,\n filter: `council_id eq ${councilId}`,\n get_mbr: true\n }\n });\n return res.data.records[0].mbr;\n }\n public async getCouncilMbrByCode(councilCode: string): Promise {\n const res = await this.http.get(\"/sitiagri-rest-api/api_basic/v1/plots/dictionary_councils\", {\n params: {\n offset: 0,\n count: 1,\n filter: `council_sector_code eq ${councilCode}`,\n get_mbr: true\n }\n });\n return res.data.records[0].mbr;\n }\n\n public async getUoms(measure_family_name: string): Promise {\n const res = await this.http.get(\n `${this.rootPath}/v1/services/decodes/transcode/RPRICE/dictionary_units_of_measure/${measure_family_name}?filter=ext_code ne `,\n {\n params: {\n offset: 0,\n count: 300\n }\n }\n );\n return res.data.records;\n }\n\n public async getBuildingProductionAreas(pkCuaa: number, id?: number): Promise {\n const res = await this.http.get(`${this.rootPath}/v1/buildings/subjects/${pkCuaa}/areas?preview=true`, {\n params: {\n offset: 0,\n count: 300,\n filter: `building_id eq ${id}`\n }\n });\n return res.data.records;\n // const imps: ImplantTemp[] = [];\n // for (let index = 1; index < 8; index++) {\n // const imp: ImplantTemp = {\n // description: \"Implant \" + index,\n // id: index,\n // };\n // imps.push(imp);\n // }\n // const els: ProductionAreaTemp[] = [];\n // for (let index = 1; index < 4; index++) {\n // const el: ProductionAreaTemp = {\n // description: \"Area \" + index,\n // id: index,\n // items: imps,\n // };\n // els.push(el);\n // }\n // return els;\n }\n\n public async editProductionArea(\n pkCuaa: number,\n id: number,\n detailOut: ProductionAreaUpdateOut\n ): Promise {\n const res = await this.http.put(`${this.rootPath}/v1/buildings/subjects/${pkCuaa}/areas/${id}`, detailOut);\n return res.data;\n }\n public async insertProductionArea(pkCuaa: number, detailOut: ProductionAreaOut): Promise {\n const res = await this.http.post(`${this.rootPath}/v1/buildings/subjects/${pkCuaa}/areas`, detailOut);\n return res.data;\n }\n public async deleteProductionArea(pkCuaa: number, id: number): Promise {\n const res = await this.http.delete(`${this.rootPath}/v1/buildings/subjects/${pkCuaa}/areas/${id}`);\n return res.data;\n }\n\n public async getImplants(pk_cuaa: number, filter: string | null): Promise {\n // if (this.cancelTokenSource) {\n // this.cancelTokenSource.cancel();\n // }\n //this.cancelTokenSource = axios.CancelToken.source();\n const filterArr = [];\n if (filter) {\n filterArr.push(`^description like ${filter.toUpperCase()}`);\n }\n filterArr.push(`^equipment_type eq I`);\n const res = await this.http.get(`${this.rootPath}/v1/equipments/subjects/${pk_cuaa}/equipments`, {\n params: {\n offset: 0,\n count: 300,\n filter: filterArr.length > 0 ? filterArr : undefined\n }\n });\n return res.data.records;\n }\n}\n"],"sourceRoot":""}