{"version":3,"sources":["webpack:///./node_modules/@abaco/dashboard-module/src/modules/dashboard/api/DashboardApi.ts"],"names":["DashboardApi","http","rootPath","software","this","tags","params","get","res","data","dashboardId","dashboardCode","newDashboard","post","editedDashboard","put","delete","response","status","id","result"],"mappings":"uMAGqBA,G,+BAKjB,WAAYC,EAAkBC,EAAkBC,GAAgB,uBAC5DC,KAAKH,KAAOA,EACZG,KAAKF,SAAWA,EAChBE,KAAKD,SAAWA,E,gHAMb,WAAuBE,GAAvB,gGACGC,EAAS,CACXD,QAFD,SAIeD,KAAKH,KAAKM,IAAV,UAAiBH,KAAKF,SAAtB,uBAA6CE,KAAKD,SAAlD,eAAyE,CAACG,WAJzF,cAIGE,EAJH,yBAKIA,EAAIC,MALR,gD,6IAYA,WAAmBC,GAAnB,uGACeN,KAAKH,KAAKM,IAAV,UAAiBH,KAAKF,SAAtB,uBAA6CQ,IAD5D,cACGF,EADH,yBAEIA,EAAIC,MAFR,gD,qJASE,WAA2BE,GAA3B,uGACaP,KAAKH,KAAKM,IAAV,UAAiBH,KAAKF,SAAtB,uBAA6CE,KAAKD,SAAlD,YAA8DQ,IAD3E,cACCH,EADD,yBAEEA,EAAIC,MAFN,gD,gJASF,WAAsBG,GAAtB,8FACHA,EAAaT,SAAWC,KAAKD,SAD1B,SAEeC,KAAKH,KAAKY,KAAV,UAAkBT,KAAKF,SAAvB,eAA8CU,GAF7D,cAEGJ,EAFH,yBAGIA,EAAIC,MAHR,gD,iJAWA,WAAuBC,EAAqBI,GAA5C,8FACHA,EAAgBX,SAAWC,KAAKD,SAD7B,SAEeC,KAAKH,KAAKc,IAAV,UAAiBX,KAAKF,SAAtB,uBAA6CQ,GAAeI,GAF3E,cAEGN,EAFH,yBAGIA,EAAIC,MAHR,gD,kJAUA,WAAsBC,GAAtB,iGACGN,KAAKH,KAAKe,OAAV,UAAoBZ,KAAKF,SAAzB,uBAAgDQ,IADnD,gD,oJAOA,WAA0BL,GAA1B,gGACGC,EAAS,CACXD,QAFD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EKA,EAAIC,KAAKW,QAFd,gD,6JAKA,WAAoCf,GAApC,gGACGC,EAAS,CAACD,QADb,SAEeD,KAAKH,KAAKM,IAAV,UAAsCH,KAAKF,SAA3C,uBAAkEE,KAAKD,SAAvE,uBAAsG,CAACG,WAFtH,cAEGE,EAFH,yBAGIA,EAAIC,MAHR,gD","file":"js/chunk-2d20901e.290a6398.js","sourcesContent":["import { HTTPClient, } from '@abaco/web-common/src/HTTP';\nimport { Dashboard, DashboardMetadata, DashboardOut, PinnableDashboard } from '../models/Dashboard';\n\nexport default class DashboardApi {\n private http: HTTPClient;\n private rootPath: string;\n private software: string;\n\n constructor(http: HTTPClient, rootPath: string, software: string) {\n this.http = http;\n this.rootPath = rootPath;\n this.software = software;\n }\n\n /**\n * Gets all dashboard visible to the current user\n */\n public async getAllDashboards(tags: string[]): Promise{\n const params = {\n tags\n }\n const res = await this.http.get(`${this.rootPath}/dashboards/${this.software}/dashboards`, {params});\n return res.data;\n }\n\n /**\n * Gets a dashboard based on it's ID\n * @param dashboardId the id\n */\n public async getDashboard(dashboardId: number): Promise{\n const res = await this.http.get(`${this.rootPath}/dashboards/${dashboardId}`);\n return res.data;\n }\n\n /**\n * Gets a dashboard based on it's CODE\n * @param dashboardCode the code\n */\n public async getDashboardWithCode(dashboardCode: string): Promise{\n const res = await this.http.get(`${this.rootPath}/dashboards/${this.software}/${dashboardCode}`);\n return res.data;\n }\n\n /**\n * Creates a new dashboard\n * @param newDashboard the dashboard\n */\n public async createDashboard(newDashboard: DashboardOut): Promise{\n newDashboard.software = this.software;\n const res = await this.http.post(`${this.rootPath}/dashboards`, newDashboard);\n return res.data;\n }\n\n /**\n * Updates a dashboard\n * @param dashboardId the id\n * @param editedDashboard the dashboard data\n */\n public async updatedDashboard(dashboardId: number, editedDashboard: DashboardOut): Promise{\n editedDashboard.software = this.software;\n const res = await this.http.put(`${this.rootPath}/dashboards/${dashboardId}`, editedDashboard);\n return res.data;\n }\n\n /**\n * Deletes a dashboard\n * @param dashboardId the ID\n */\n public async deleteDashboard(dashboardId: number): Promise{\n await this.http.delete(`${this.rootPath}/dashboards/${dashboardId}`);\n }\n\n /**\n * Gets user's pinned dashboards\n */\n public async getPinnedDashboards(tags: string[]): Promise{\n const params = {\n tags\n }\n const res = await this.http.get(`${this.rootPath}/pinned-dashboards/${this.software}/dashboards`, {params});\n return res.data;\n }\n\n /**\n * Pins a dashboard for the current user\n * @param dashboardId the ID\n */\n public async pinDashboard(dashboardId: number): Promise{\n const res = await this.http.put(`${this.rootPath}/pinned-dashboards/${dashboardId}`);\n return res.data;\n }\n\n /**\n * Pins a dashboard for the current user with code\n * @param dashboardCode the code\n */\n public async pinDashboardWithCode(dashboardCode: string): Promise{\n const res = await this.http.put(`${this.rootPath}/pinned-dashboards/${this.software}/${dashboardCode}`);\n return res.data;\n }\n\n /**\n * Unpins a previously pinned dashboard\n * @param dashboardId the ID\n */\n public async unpinDashboard(dashboardId: number): Promise{\n await this.http.delete(`${this.rootPath}/pinned-dashboards/${dashboardId}`);\n }\n\n /**\n * Gets the last dashboard used by a user\n */\n public async getLastUsedDashboard(tags: string[]): Promise {\n try {\n const params = {\n tags\n }\n const res = await this.http.get(`${this.rootPath}/last-used-dashboard/${this.software}/dashboards`, {params});\n return res.data;\n } catch (e) {\n if ((e as any).response?.status === 404) {\n return null;\n }\n throw e;\n }\n }\n\n /**\n * Gets the last dashboard id used by a user\n */\n public async getLastUsedDashboardId(tags: string): Promise {\n try {\n const params = {tags}\n const res = await this.http.get(`${this.rootPath}/last-used-dashboard-id/${this.software}`, {params});\n return res.data;\n } catch (e) {\n if ((e as any).response?.status === 404) {\n return null;\n }\n throw e;\n }\n }\n\n /**\n * Sets the last dashboard used by the current user\n * @param dashboardId the ID\n */\n public async setLastUsedDashboard(dashboardId: number): Promise {\n await this.http.put(`${this.rootPath}/last-used-dashboard`, {id: dashboardId});\n }\n\n public async canCreatePublicDash(){\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/user_registry/module_competencies/DASHBOARD/CREATE_PUBLIC`);\n return res.data.result\n }\n\n public async isReadOnly(){\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/user_registry/module_competencies/DASHBOARD/CREATE`);\n return !res.data.result\n }\n\n public async getAutomaticPinnableDashboard(tags: string[]){\n const params = {tags};\n const res = await this.http.get(`${this.rootPath}/dashboards/${this.software}/automatic-pinnable`, {params});\n return res.data;\n }\n}\n"],"sourceRoot":""}