Mini Shell

Direktori : /home/ukubnwwt/viewer.ukubona.cloud/assets/
Upload File :
Current File : /home/ukubnwwt/viewer.ukubona.cloud/assets/FilesView-DBc7LzTa.js

import{_ as I,g as w,h as O,j as k,a as g,i as l,c,b as s,t as u,k as p,l as m,d as F,v as y,F as D,r as T,n as _,m as C,q as P,o as n,p as S,f as b}from"./index-eQbzG_il.js";import{r as N,m as U,c as x,e as A}from"./cornerstoneWADOImageLoader.bundle.min-EU_ZCHA5.js";import{D as z}from"./DicomViewer-D7n5Kjib.js";const E={data(){return{img2:w,img1:O,moment:k,radiology:N,microscopy:U,cardiology:x,endoscopy:A,selectedFile:null,filesData:null,showFileTableLoader:!1,file:null,filename:"",fileSize:"",files:[],fileNames:[],fileSizes:[],fileDescriptions:[],fileUploadDescription:"",showFileUploadForm:!1,userData:null,selectedFiles:[],selectAllFiles:!1,isDeleteConfirmed:!1,showDeleteWindow:!1,areImagesPrefetched:!1,showDicomViewer:!1,selectedUploadedFile:null}},components:{DicomViewer:z},mounted(){this.getUserData(),this.getFiles(),this.$root.loadScripts()},methods:{redirectTo(t){this.$router.push(t)},closeDicomViewer(){this.showDicomViewer=!1},isInArray(t){return this.selectedFiles.includes(t)},toggleFileArray(t){this.isInArray(t)?this.selectedFiles=this.selectedFiles.filter(e=>e!==t):this.selectedFiles.push(t),this.selectAllFiles=!1},toggleAddAllFilesToArray(){this.selectedFiles.length>0?(this.selectedFiles=[],this.selectAllFiles=!1):(this.selectedFiles=[...this.filesData.data.map(t=>t.uuid)],this.selectAllFiles=!0)},async refreshToken(t){try{const e=await this.$http.post("api/token/refresh",{refresh:this.$store.state.refresh});e.data.access?(this.$store.commit("setAccess",e.data.access),g.defaults.headers.common.Authorization=`Bearer ${e.data.access}`,await t()):this.$router.push("/login")}catch(e){console.error("Failed to refresh token",e),this.$router.push("/login")}},async getUserData(){this.$root.isLoading=!0;try{const t=await this.$http.get("accounts/userdata");this.userData=t.data,this.$root.profileInfo={name:this.userData.first_name,image:this.userData.profile_image_url},this.$root.isLoading=!1}catch(t){if(this.$root.isLoading=!1,t.response){const e=t.response.status;e===401?await this.refreshToken(this.getUserData):(console.error(`Error ${e}: ${t.response.data.message}`),l.error(`Error ${e}: ${t.response.data.message}`,{autoClose:3e3,position:l.POSITION.TOP_RIGHT}))}else t.request?(console.error("No response received:",t.request),l.error("No response received. Please try again later.",{autoClose:3e3,position:l.POSITION.TOP_RIGHT})):(console.error("Error",t),l.error(`Error: ${t.message}`,{autoClose:3e3,position:l.POSITION.TOP_RIGHT}))}},async prefetchAllImages(){if(!this.areImagesPrefetched){this.areImagesPrefetched=!0;for(let t=0;t<this.filesData.data.length;t++){let e=this.filesData.data[t];this.$root.preloadImage(e.getFileURL)}}},async getFiles(t=null,e=null){this.showFileTableLoader=!0;let r={};try{t&&(r.page=t),e&&(r.search=e),console.log("herte",t),await this.$http.get("api/v1/files",{params:r}).then(h=>{const o=h.data;o.status&&(this.filesData=o,this.showFileTableLoader=!1,this.prefetchAllImages())})}catch(h){if(this.showFileTableLoader=!1,h.response){const o=h.response.status;o===401?await this.refreshToken(this.getFiles):(console.error(`Error ${o}: ${h.response.data.message}`),l.error(`Error ${o}: ${h.response.data.message}`,{autoClose:3e3,position:l.POSITION.TOP_RIGHT}))}else h.request?(console.error("No response received:",h.request),l.error("No response received. Please try again later.",{autoClose:3e3,position:l.POSITION.TOP_RIGHT})):(console.error("Error",h),l.error(`Error: ${h.message}`,{autoClose:3e3,position:l.POSITION.TOP_RIGHT}))}},onFileChange2(t){const e=t.target.files[0];e&&(this.file=e,this.filename=e.name,this.fileSize=this.getReadableFileSizeString(e.size))},onFileChange(){this.files=Array.from(event.target.files),this.fileNames=this.files.map(t=>t.name),this.fileSizes=this.files.map(t=>this.getReadableFileSizeString(t.size))},getReadableFileSizeString(t){const e=["B","KB","MB","GB","TB"];let r=0,h=t;for(;h>=1e3&&r<e.length-1;)h/=1e3,r++;return`${h.toFixed(2)} ${e[r]}`},async uploadFile2(){if(!this.file){alert("Please select a file to upload.");return}this.$root.isLoading=!0;const t=new FormData;t.append("file",this.file),t.append("fileName",this.filename),t.append("fileSize",this.fileSize),t.append("fileDescription",this.fileUploadDescription);try{const e=await g.post("api/v1/file-upload",t,{headers:{"Content-Type":"multipart/form-data"}});this.showFileUploadForm=!1,this.$root.isLoading=!1,this.getFiles(),this.getUserData(),console.log("File uploaded successfully:",e.data),l.success(e.data.message||"File Uploaded Successfully",{autoClose:3e3,position:l.POSITION.TOP_RIGHT})}catch(e){if(this.$root.isLoading=!1,e.response){const r=e.response.status;r===401?await this.refreshToken(this.uploadFile):(console.error(`Error ${r}: ${e.response.data.message}`),l.error(`Error ${r}: ${e.response.data.message}`,{autoClose:3e3,position:l.POSITION.TOP_RIGHT}))}else e.request?(console.error("No response received:",e.request),l.error("No response received. Please try again later.",{autoClose:3e3,position:l.POSITION.TOP_RIGHT})):(console.error("Error",e),l.error(`Error: ${e.message}`,{autoClose:3e3,position:l.POSITION.TOP_RIGHT}))}},async uploadFile(){if(this.files.length==0){alert("Please select a file to upload.");return}this.$root.isLoading=!0,console.log("what?");const t=new FormData;this.files.forEach((e,r)=>{t.append("files",e),t.append("fileNames",this.fileNames[r]),t.append("fileSizes",this.fileSizes[r]),t.append("fileDescription",this.fileUploadDescription)});try{const e=await this.$http.post("api/v1/file-upload",t,{headers:{"Content-Type":"multipart/form-data"}});this.showFileUploadForm=!1,this.fileUploadDescription="",this.files=[],this.fileNames=[],this.fileSizes=[],this.$root.isLoading=!1,this.getFiles(),this.getUserData(),console.log("File uploaded successfully:",e.data),l.success(e.data.message||"File Uploaded Successfully",{autoClose:3e3,position:l.POSITION.TOP_RIGHT})}catch(e){if(this.$root.isLoading=!1,e.response){const r=e.response.status;r===401?await this.refreshToken(this.uploadFile):r===413?(console.error(`Error ${r}: The uploaded file is too large.`),l.error("Error 413: The uploaded file is too large. Please reduce the file size and try again.",{autoClose:3e3,position:l.POSITION.TOP_RIGHT})):(console.error(`Error ${r}: ${e.response.data.message}`),l.error(`Error ${r}: ${e.response.data.message}`,{autoClose:3e3,position:l.POSITION.TOP_RIGHT}))}else e.request?(console.error("No response received:",e.request),l.error("No response received. Please try again later.",{autoClose:3e3,position:l.POSITION.TOP_RIGHT})):(console.error("Error",e),l.error(`Error: ${e.message}`,{autoClose:3e3,position:l.POSITION.TOP_RIGHT}))}},async deleteFile(){const t={file_uuids:this.selectAllFiles?"all":this.selectedFiles};try{const e=await this.$http.post("api/v1/files/delete",t);console.log("File deleted successfully:",e.data),l.success(e.data.message||"File Deleted Successfully",{autoClose:3e3,position:l.POSITION.TOP_RIGHT}),this.showDeleteWindow=!1,this.getFiles(),this.getUserData()}catch(e){if(this.$root.isLoading=!1,e.response){const r=e.response.status;r===401?await this.refreshToken(this.deleteFile):(console.error(`Error ${r}: ${e.response.data.message}`),l.error(`Error ${r}: ${e.response.data.message}`,{autoClose:3e3,position:l.POSITION.TOP_RIGHT}))}else e.request?(console.error("No response received:",e.request),l.error("No response received. Please try again later.",{autoClose:3e3,position:l.POSITION.TOP_RIGHT})):(console.error("Error",e),l.error(`Error: ${e.message}`,{autoClose:3e3,position:l.POSITION.TOP_RIGHT}))}}}},a=t=>(S("data-v-1e3c7a6c"),t=t(),b(),t),R={class:"home"},G={class:"container"},H={key:0},L=a(()=>s("div",{class:"heading flex1"},[s("h3",null,"Files"),s("p",null,"Dashboard / Dashboard")],-1)),V={class:"content flex"},q={class:"content_left"},B={class:"top"},$={class:"wlecome flex1"},W=a(()=>s("div",{class:"text"},[s("h3",null,"Welcome Back !"),s("label",null,"Ukubona Dashboard")],-1)),M={class:"img"},Y=["src"],j={key:0,class:"profile flex1"},K={class:"box"},J={class:"image"},Q=["src"],X={class:"text"},Z={key:0,class:"box"},ee={style:{color:"transparent"}},se=a(()=>s("label",{style:{color:"transparent"}},"Saved FIles",-1)),te=a(()=>s("br",null,null,-1)),oe=a(()=>s("i",{class:"fas fa-chevron-down"},null,-1)),le={class:"content_right"},ie={class:"right_top grid"},re={class:"rbox flex1"},ae={class:"text"},ne=a(()=>s("h4",null,"Total Files",-1)),ce={key:0},de={key:1},he=a(()=>s("div",{class:"icon"},[s("span",{class:"material-icons"}," library_books ")],-1)),ue={class:"rbox flex1"},pe={class:"text"},fe=a(()=>s("h4",null,"Available AI models",-1)),_e=a(()=>s("div",{class:"icon"},[s("span",{class:"material-icons"}," widgets ")],-1)),ge=a(()=>s("section",{class:"models"},null,-1)),me={class:"table"},Fe={class:"container"},ye={key:0,class:"file-upload-form",style:{margin:".5rem 0",padding:"1rem .5rem",display:"flex","flex-direction":"column",background:"rgba(3, 8, 48, 0.15)","border-radius":".5rem"}},De=a(()=>s("h3",null,"Upload File ",-1)),Te=a(()=>s("label",{for:"",style:{"margin-top":"1rem","font-size":"14px","font-weight":"600"}},"Short Description (Optional)",-1)),ve=["disabled"],Ie={class:"top-level"},we={class:"left"},Oe=a(()=>s("h3",null,"Uploaded Files",-1)),ke={class:"search-button"},Ce={class:"right"},Pe=a(()=>s("i",{class:"fa-solid fa-trash"},null,-1)),Se=[Pe],be=a(()=>s("th",null,"File Name",-1)),Ne=a(()=>s("th",null,"File Size",-1)),Ue=a(()=>s("th",null,"Uploaded",-1)),xe=a(()=>s("th",null,"File Description",-1)),Ae=a(()=>s("th",null,null,-1)),ze={key:0,style:{position:"relative"}},Ee=["checked","onChange"],Re=["onClick"],Ge={key:0,style:{"font-size":"14px"}},He={key:1,style:{"font-size":"14px"}},Le=["onClick"],Ve=a(()=>s("i",{class:"fa-solid fa-trash",style:{"font-size":"24px",color:"var(--danger)"}},null,-1)),qe=[Ve],Be=a(()=>s("td",null,null,-1)),$e={key:0,class:"loading-table"},We=a(()=>s("div",{class:"spinner"},null,-1)),Me=[We],Ye={key:1},je={key:1,class:"pagination"},Ke=["onClick"],Je={key:0,class:"modal confirm-delete"},Qe={class:"modal-content"},Xe=a(()=>s("h2",null,"Delete File ",-1)),Ze={key:0},es={key:1},ss={class:"buttons"};function ts(t,e,r,h,o,d){const v=P("DicomViewer");return n(),c("main",null,[s("section",R,[s("div",G,[o.userData?(n(),c("h3",H,u(o.userData.hospital.name),1)):p("",!0),L,s("div",V,[s("div",q,[s("div",B,[s("div",$,[W,s("div",M,[s("img",{src:o.img2,alt:""},null,8,Y)])]),o.userData?(n(),c("div",j,[s("div",K,[s("div",J,[s("img",{src:o.userData.profile_image_url,alt:""},null,8,Q)]),s("div",X,[s("p",null,u(o.userData.last_name)+" "+u(o.userData.first_name),1),s("label",null,u(o.userData.role),1)])]),o.userData?(n(),c("div",Z,[s("p",ee,u(o.userData.saved_files),1),se,m(),te,s("button",{onClick:e[0]||(e[0]=i=>d.redirectTo("/profile"))},[m(" View Profile "),oe])])):p("",!0)])):p("",!0)])]),s("div",le,[s("div",ie,[s("div",re,[s("div",ae,[ne,o.userData?(n(),c("h2",ce,u(o.userData.saved_files),1)):(n(),c("h2",de,"..."))]),he]),s("div",ue,[s("div",pe,[fe,s("h2",null,u(t.$store.state.total_models),1)]),_e])])])])])]),ge,s("section",me,[s("div",Fe,[s("button",{style:{"margin-bottom":"1rem"},onClick:e[1]||(e[1]=i=>o.showFileUploadForm=!o.showFileUploadForm)},"Upload File +"),o.showFileUploadForm?(n(),c("div",ye,[De,s("input",{type:"file",multiple:"",style:{"margin-top":"1rem","font-size":"1rem"},onChange:e[2]||(e[2]=(...i)=>d.onFileChange&&d.onFileChange(...i)),accept:".dcm,.dicom,.jpg,.png,.jpeg"},null,32),Te,F(s("input",{"onUpdate:modelValue":e[3]||(e[3]=i=>o.fileUploadDescription=i),type:"text",placeholder:"Enter file description",style:{"font-size":"16px",padding:".2rem"}},null,512),[[y,o.fileUploadDescription]]),s("button",{onClick:e[4]||(e[4]=(...i)=>d.uploadFile&&d.uploadFile(...i)),disabled:o.files.length==0,style:{"margin-top":"1rem","max-width":"fit-content"}},"Upload File",8,ve)])):p("",!0),s("div",Ie,[s("div",we,[Oe,F(s("input",{type:"search",name:"",id:"",placeholder:"search files","onUpdate:modelValue":e[5]||(e[5]=i=>t.searchText=i)},null,512),[[y,t.searchText]]),s("span",ke,[s("i",{class:"fa-solid fa-magnifying-glass",onClick:e[6]||(e[6]=i=>d.getFiles(null,t.searchText))})])]),s("div",Ce,[o.selectedFiles.length>0||o.selectAllFiles?(n(),c("span",{key:0,class:"delete",onClick:e[7]||(e[7]=i=>{o.showDeleteWindow=!0})},Se)):p("",!0)])]),s("table",null,[s("thead",null,[s("tr",null,[s("th",null,[s("input",{type:"checkbox",onChange:e[8]||(e[8]=(...i)=>d.toggleAddAllFilesToArray&&d.toggleAddAllFilesToArray(...i))},null,32)]),be,Ne,Ue,xe,Ae])]),o.filesData?(n(),c("tbody",ze,[(n(!0),c(D,null,T(o.filesData.data,i=>(n(),c("tr",{key:i},[s("td",null,[s("input",{type:"checkbox",checked:d.isInArray(i.uuid),onChange:f=>d.toggleFileArray(i.uuid)},null,40,Ee)]),s("td",{style:{cursor:"pointer"},class:"filehover",onClick:f=>{o.selectedUploadedFile={mode:"single",filePath:i.getFileURL},o.showDicomViewer=!0}},u(i.fileName),9,Re),s("td",null,u(i.fileSize),1),s("td",null,u(o.moment(`${i.dateUploaded}`).format("DD MMM, YYYY . ")),1),s("td",null,[i.fileDescription.length>25?(n(),c("span",Ge,u(i.fileDescription.slice(0,25))+"...",1)):(n(),c("span",He,u(i.fileDescription),1))]),s("td",null,[s("span",{class:"delete",style:{cursor:"pointer"},onClick:f=>{d.toggleFileArray(i.uuid),o.selectedFiles=[i.uuid],o.showDeleteWindow=!0}},qe,8,Le)]),Be]))),128)),o.showFileTableLoader?(n(),c("div",$e,Me)):p("",!0)])):(n(),c("tbody",Ye))]),o.filesData?(n(),c("div",je,[s("ul",null,[s("li",null,[s("i",{class:_(["fas fa-chevron-left",{disabled:o.filesData.pagination.current_page<=1}]),onClick:e[9]||(e[9]=i=>d.getFiles(o.filesData.pagination.current_page-1))},null,2)]),(n(!0),c(D,null,T(o.filesData.pagination.total_pages,(i,f)=>(n(),c("li",{key:i,class:_({active:o.filesData.pagination.current_page==i}),onClick:os=>d.getFiles(i)},[s("span",null,u(i),1)],10,Ke))),128)),s("li",null,[s("i",{class:_(["fas fa-chevron-right",{disabled:o.filesData.pagination.current_page>=o.filesData.pagination.total_pages}]),onClick:e[10]||(e[10]=i=>d.getFiles(o.filesData.pagination.current_page+1))},null,2)])])])):p("",!0)])]),o.showDeleteWindow?(n(),c("div",Je,[s("div",Qe,[Xe,o.selectedFiles.length==1?(n(),c("p",Ze,"Are you sure you want to delete this file?")):p("",!0),o.selectedFiles.length>1?(n(),c("p",es,"Are you sure you want to delete these "+u(o.selectAllFiles.length)+" files?",1)):p("",!0),s("div",ss,[s("button",{class:"delete",onClick:e[11]||(e[11]=i=>d.deleteFile())},"Delete"),s("button",{onClick:e[12]||(e[12]=i=>o.showDeleteWindow=!1)},"Cancel")])])])):p("",!0),o.showDicomViewer?(n(),C(v,{key:1,onCloseDicomViewer:d.closeDicomViewer,currentSelectedDisplayItem:o.selectedUploadedFile},null,8,["onCloseDicomViewer","currentSelectedDisplayItem"])):p("",!0)])}const as=I(E,[["render",ts],["__scopeId","data-v-1e3c7a6c"]]);export{as as default};