Mini Shell

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

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