{"version":3,"sources":["webpack:///./src/views/project-files/ProjectFiles.vue?433e","webpack:///./src/util/file.ts","webpack:///./src/views/project-files/ProjectFilesMachine.ts","webpack:///./src/views/project-files/ProjectFiles.vue?262f","webpack:///./src/views/project-files/ProjectFiles.vue?27c5","webpack:///./src/views/project-files/ProjectFiles.vue"],"names":["render","_vm","this","_h","$createElement","_c","_self","attrs","_v","_s","$t","files","total","state","matches","headers","items","options","currentPage","on","updateOptions","$event","scopedSlots","_u","key","fn","ref","item","preventDefault","handleDownload","fileName","bytesToSize","fileSize","toLocalDateTimeStringShort","uploadDate","staticRenderFns","bytes","sizes","i","Math","min","floor","log","length","concat","pow","toFixed","projectFilesMachine","Machine","id","initial","states","idle","RELOAD","loading","RESOLVE","REJECT","error","type","defineComponent","name","components","setup","_","vm","projectEmployerFilesApi","ProjectEmployerFilesApi","_useMachine","useMachine","ProjectFilesMachine","service","page","itemsPerPage","sortBy","sortDesc","groupBy","groupDesc","multiSort","mustSort","text","i18n","t","toString","value","selectedProject","computed","Store","getters","projectId","_selectedProject$valu","Number","opts","send","getFiles","_x","_getFiles","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","request","_yield$projectEmploye","data","wrap","_context","prev","next","descending","rowsPerPage","projectEmployerFilesGetProjectEmployerFilesTable","sent","t0","stop","downloadFile","_x2","_downloadFile","_callee2","_yield$projectEmploye2","_context2","abrupt","projectEmployerFilesDownloadProjectEmployerFile","responseType","downloadDocument","_x3","_handleDownload","_callee3","_context3","onMounted","subscribe","s","component","VBtn","VCard","VCardText","VCardTitle","VCol","VDataTable","VRow"],"mappings":"yHAAA,IAAIA,EAAS,WAAa,IAAIC,EAAIC,KAASC,EAAGF,EAAIG,eAAmBC,EAAGJ,EAAIK,MAAMD,IAAIF,EAAG,OAAOE,EAAG,QAAQ,CAACA,EAAG,QAAQ,CAACE,MAAM,CAAC,GAAK,OAAO,CAACF,EAAG,SAAS,CAACE,MAAM,CAAC,KAAO,GAAG,KAAO,KAAK,CA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OAAA,wBAAAD,EAAAZ,KAAA,EAKH3C,EAAwByD,gDAChClC,EAAUL,MACVrD,EACA,CACE6F,aAAc,gBAEjB,OAAAJ,EAAAC,EAAAR,KARCR,EAAIe,EAAJf,KACAzF,EAAOwG,EAAPxG,QASF6G,eAAiBpB,EAAMzF,EAASe,GAAU,wBAAA0F,EAAAN,UAAAI,OAC3CD,EAAArB,MAAA,KAAAC,WAAA,SAEcpE,EAAcgG,GAAA,OAAAC,EAAA9B,MAAC,KAADC,WAAA,SAAA6B,IAE5B,OAF4BA,EAAA5B,eAAAC,iBAAAC,MAA7B,SAAA2B,EAA8BjG,GAAmC,OAAAqE,iBAAAM,MAAA,SAAAuB,GAAA,eAAAA,EAAArB,KAAAqB,EAAApB,MAAA,cAAAoB,EAAApB,KAAA,EACzDO,EAAarF,GAAS,wBAAAkG,EAAAd,UAAAa,OAC7BD,EAAA9B,MAAA,KAAAC,WAUD,OARAgC,wBAAU,WACR3D,EAAQ4D,WAAU,SAACC,GACbA,EAAErH,QAAQ,YACZ+E,EAAS5E,SAKR,CACLN,QACAkB,iBACAE,cACAE,kCACAhB,UACAF,UACAG,cACAE,gBACAP,YCrLid,I,yGCOnduH,EAAY,eACd,EACApI,EACAmC,GACA,EACA,KACA,KACA,MAIa,aAAAiG,EAAiB,QAWhC,IAAkBA,EAAW,CAACC,OAAA,KAAKC,QAAA,KAAMC,UAAA,OAAUC,WAAA,OAAWC,OAAA,KAAKC,aAAA,KAAWC,OAAA","file":"js/chunk-2d0b274b.3cdb8e31.js","sourcesContent":["var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('v-row',[_c('v-col',{attrs:{\"md\":\"12\"}},[_c('v-card',{attrs:{\"flat\":\"\",\"tile\":\"\"}},[_c('v-card-title',[_vm._v(\" \"+_vm._s(_vm.$t(\"project-files.header\", [_vm.files.total]))+\" \")]),_c('v-card-text',[_c('v-data-table',{attrs:{\"loading\":_vm.state.matches('loading'),\"disabled\":_vm.state.matches('loading'),\"server-items-length\":_vm.files.total,\"headers\":_vm.headers,\"items\":_vm.files.items,\"options\":_vm.options,\"page\":_vm.currentPage,\"loading-text\":_vm.$t('datatable.loading-text'),\"no-data-text\":_vm.$t('datatable.no-data-text'),\"no-results-text\":_vm.$t('datatable.no-results-text'),\"footer-props\":{\n 'items-per-page-text': _vm.$t('datatable.items-per-page-text'),\n 'items-per-page-options': [25, 50, 100],\n }},on:{\"update:options\":_vm.updateOptions,\"update:page\":function($event){_vm.currentPage=$event}},scopedSlots:_vm._u([{key:\"item.fileName\",fn:function(ref){\n var item = ref.item;\nreturn [_c('v-btn',{attrs:{\"text\":\"\"},on:{\"click\":function($event){$event.preventDefault();return _vm.handleDownload(item.fileName)}}},[_vm._v(_vm._s(item.fileName))])]}},{key:\"item.fileSize\",fn:function(ref){\n var item = ref.item;\nreturn [_vm._v(\" \"+_vm._s(_vm.bytesToSize(item.fileSize))+\" \")]}},{key:\"item.uploadDate\",fn:function(ref){\n var item = ref.item;\nreturn [_vm._v(\" \"+_vm._s(_vm.toLocalDateTimeStringShort(item.uploadDate))+\" \")]}}],null,true)})],1)],1)],1)],1)}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","function bytesToSize(bytes: number): string {\r\n const sizes = [\"Bytes\", \"KB\", \"MB\", \"GB\", \"TB\"];\r\n if (bytes === 0) return \"n/a\";\r\n const i = Math.min(\r\n Math.floor(Math.log(bytes) / Math.log(1024)),\r\n sizes.length - 1\r\n );\r\n if (i === 0) return `${bytes} ${sizes[i]}`;\r\n return `${(bytes / 1024 ** i).toFixed(1)} ${sizes[i]}`;\r\n}\r\n\r\nexport default bytesToSize;\r\n","import { Machine } from \"xstate\";\r\n\r\nconst projectFilesMachine = Machine({\r\n id: \"projectFilesMachine\",\r\n initial: \"idle\",\r\n states: {\r\n idle: {\r\n on: {\r\n RELOAD: \"loading\",\r\n },\r\n },\r\n loading: {\r\n on: {\r\n RESOLVE: \"idle\",\r\n REJECT: \"error\",\r\n },\r\n },\r\n error: {\r\n type: \"final\",\r\n },\r\n },\r\n});\r\n\r\nexport default projectFilesMachine;\r\n","\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\r\nimport {\r\n computed,\r\n defineComponent,\r\n onMounted,\r\n ref,\r\n} from \"@vue/composition-api\";\r\nimport Store from \"@/store\";\r\nimport {\r\n GetProjectEmployerFilesTableRequest,\r\n ProjectDto,\r\n ProjectEmployerFilesApi,\r\n VueTableResponseOfProjectEmployerFilesTableDto,\r\n} from \"@/api\";\r\nimport { downloadDocument } from \"@/util/download\";\r\nimport { toLocalDateTimeStringShort } from \"@/util/date\";\r\nimport bytesToSize from \"@/util/file\";\r\nimport { useMachine } from \"@xstate/vue\";\r\nimport { DataTableHeader, DataOptions } from \"vuetify\";\r\nimport i18n from \"@/i18n\";\r\nimport ProjectFilesMachine from \"./ProjectFilesMachine\";\r\n\r\nexport default defineComponent({\r\n name: \"Files\",\r\n components: {},\r\n setup(_, vm) {\r\n const projectEmployerFilesApi = new ProjectEmployerFilesApi();\r\n\r\n const { state, service } = useMachine(ProjectFilesMachine);\r\n\r\n const files = ref({\r\n items: [],\r\n total: 0,\r\n });\r\n\r\n let options: DataOptions = {\r\n page: 1,\r\n itemsPerPage: 25,\r\n sortBy: [\"uploadDate\"],\r\n sortDesc: [true],\r\n groupBy: [],\r\n groupDesc: [],\r\n multiSort: false,\r\n mustSort: false,\r\n };\r\n\r\n const headers: DataTableHeader[] = [\r\n {\r\n text: i18n.t(\"project-files.fileName\").toString(),\r\n value: \"fileName\",\r\n },\r\n {\r\n text: i18n.t(\"project-files.fileSize\").toString(),\r\n value: \"fileSize\",\r\n },\r\n {\r\n text: i18n.t(\"project-files.uploadDate\").toString(),\r\n value: \"uploadDate\",\r\n },\r\n ];\r\n\r\n const currentPage = ref(0);\r\n\r\n const selectedProject = computed(\r\n () => Store.getters[\"User/getSelectedProject\"]\r\n );\r\n\r\n const projectId = computed(() => Number(selectedProject.value?.projectId));\r\n\r\n function updateOptions(opts: DataOptions) {\r\n options = opts;\r\n service.send(\"RELOAD\");\r\n }\r\n\r\n async function getFiles(opts: DataOptions) {\r\n try {\r\n const request: GetProjectEmployerFilesTableRequest = {\r\n sortBy: opts.sortBy,\r\n descending: opts.sortDesc,\r\n page: opts.page,\r\n rowsPerPage: opts.itemsPerPage,\r\n projectId: projectId.value,\r\n };\r\n\r\n const {\r\n data,\r\n } = await projectEmployerFilesApi.projectEmployerFilesGetProjectEmployerFilesTable(\r\n request\r\n );\r\n\r\n const { total, items } = data;\r\n\r\n files.value.items = items;\r\n files.value.total = total;\r\n service.send(\"RESOLVE\");\r\n } catch {\r\n service.send(\"REJECT\");\r\n }\r\n }\r\n\r\n async function downloadFile(fileName: string | null | undefined) {\r\n if (!fileName) return;\r\n\r\n const {\r\n data,\r\n headers,\r\n } = await projectEmployerFilesApi.projectEmployerFilesDownloadProjectEmployerFile(\r\n projectId.value,\r\n fileName,\r\n {\r\n responseType: \"arraybuffer\",\r\n }\r\n );\r\n\r\n downloadDocument(data, headers, fileName);\r\n }\r\n\r\n async function handleDownload(fileName: string | null | undefined) {\r\n await downloadFile(fileName);\r\n }\r\n\r\n onMounted(() => {\r\n service.subscribe((s) => {\r\n if (s.matches(\"loading\")) {\r\n getFiles(options);\r\n }\r\n });\r\n });\r\n\r\n return {\r\n files,\r\n handleDownload,\r\n bytesToSize,\r\n toLocalDateTimeStringShort,\r\n options,\r\n headers,\r\n currentPage,\r\n updateOptions,\r\n state,\r\n };\r\n },\r\n});\r\n","import mod from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/ts-loader/index.js??ref--13-3!../../../node_modules/vuetify-loader/lib/loader.js??ref--20-0!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ProjectFiles.vue?vue&type=script&lang=ts&\"; export default mod; export * from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/ts-loader/index.js??ref--13-3!../../../node_modules/vuetify-loader/lib/loader.js??ref--20-0!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ProjectFiles.vue?vue&type=script&lang=ts&\"","import { render, staticRenderFns } from \"./ProjectFiles.vue?vue&type=template&id=c392188a&\"\nimport script from \"./ProjectFiles.vue?vue&type=script&lang=ts&\"\nexport * from \"./ProjectFiles.vue?vue&type=script&lang=ts&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n \n)\n\nexport default component.exports\n\n/* vuetify-loader */\nimport installComponents from \"!../../../node_modules/vuetify-loader/lib/runtime/installComponents.js\"\nimport { VBtn } from 'vuetify/lib/components/VBtn';\nimport { VCard } from 'vuetify/lib/components/VCard';\nimport { VCardText } from 'vuetify/lib/components/VCard';\nimport { VCardTitle } from 'vuetify/lib/components/VCard';\nimport { VCol } from 'vuetify/lib/components/VGrid';\nimport { VDataTable } from 'vuetify/lib/components/VDataTable';\nimport { VRow } from 'vuetify/lib/components/VGrid';\ninstallComponents(component, {VBtn,VCard,VCardText,VCardTitle,VCol,VDataTable,VRow})\n"],"sourceRoot":""}