Mini Shell
import{_ as I,g as T,h as y,j as w,a as m,c as n,b as e,t as d,k as h,l as p,d as k,v as b,F as g,r as f,n as _,m as O,q as S,o as i,p as P,f as C}from"./index-eQbzG_il.js";import{r as N,m as R,c as x,e as V}from"./cornerstoneWADOImageLoader.bundle.min-EU_ZCHA5.js";import{D as F}from"./DicomViewer-D7n5Kjib.js";const A={data(){return{img2:T,img1:y,moment:w,radiology:N,microscopy:R,cardiology:x,endoscopy:V,selectedFile:null,scansData:null,showFileTableLoader:!1,userData:null,showDicomViewer:!1,selectedResult:null}},components:{DicomViewer:F},mounted(){this.$root.loadScripts(),this.getFiles(),this.getUserData(),this.getAIScans()},methods:{closeDicomViewer(){this.showDicomViewer=!1},redirectTo(t){this.$router.push(t)},async refreshToken(t){try{const o=await this.$http.post("api/token/refresh",{refresh:this.$store.state.refresh});o.data.access?(this.$store.commit("setAccess",o.data.access),m.defaults.headers.common.Authorization=`Bearer ${o.data.access}`,await t()):this.$router.push("/login")}catch(o){console.error("Failed to refresh token",o),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 o=t.response.status;o===401?await this.refreshToken(this.getUserData):(console.error(`Error ${o}: ${t.response.data.message}`),toast.error(`Error ${o}: ${t.response.data.message}`,{autoClose:3e3,position:toast.POSITION.TOP_RIGHT}))}else t.request?(console.error("No response received:",t.request),toast.error("No response received. Please try again later.",{autoClose:3e3,position:toast.POSITION.TOP_RIGHT})):(console.error("Error",t),toast.error(`Error: ${t.message}`,{autoClose:3e3,position:toast.POSITION.TOP_RIGHT}))}},async useModel(t){if(!this.selectedFile){alert("Please select a file to use the model");return}const o={fileUUID:this.selectedFile.uuid,model_name:t};try{await m.post("api/v1/model",o).then(l=>{console.log("Model used successfully",l.data),toast.info("AI Model request is Processing",{autoClose:3e3,position:toast.POSITION.TOP_RIGHT})})}catch(l){if(this.$root.isLoading=!1,l.response){const r=l.response.status;r===401?await this.refreshToken(this.useModel):(console.error(`Error ${r}: ${l.response.data.message}`),toast.error(`Error ${r}: ${l.response.data.message}`,{autoClose:3e3,position:toast.POSITION.TOP_RIGHT}))}else l.request?(console.error("No response received:",l.request),toast.error("No response received. Please try again later.",{autoClose:3e3,position:toast.POSITION.TOP_RIGHT})):(console.error("Error",l),toast.error(`Error: ${l.message}`,{autoClose:3e3,position:toast.POSITION.TOP_RIGHT}))}},async getFiles(t=null,o=null){this.showFileTableLoader=!0;let l={};try{t&&(l.page=t),o&&(l.search=o),console.log("herte",t),await this.$http.get("api/v1/files",{params:l}).then(r=>{const s=r.data;s.status&&(this.filesData=s,this.showFileTableLoader=!1)})}catch(r){console.error("Error fetching files",r),this.showFileTableLoader=!1}},async getAIScans(t=null,o=null){this.showFileTableLoader=!0;let l={};try{t&&(l.page=t),o&&(l.search=o);const r=await this.$http.get("api/v1/model",{params:l});this.scansData=r.data,this.showFileTableLoader=!1}catch(r){if(this.showFileTableLoader=!1,r.response){const s=r.response.status;s===401?await this.refreshToken(this.getAIScans):(console.error(`Error ${s}: ${r.response.data.message}`),toast.error(`Error ${s}: ${r.response.data.message}`,{autoClose:3e3,position:toast.POSITION.TOP_RIGHT}))}else r.request?(console.error("No response received:",r.request),toast.error("No response received. Please try again later.",{autoClose:3e3,position:toast.POSITION.TOP_RIGHT})):(console.error("Error",r),toast.error(`Error: ${r.message}`,{autoClose:3e3,position:toast.POSITION.TOP_RIGHT}))}}}},c=t=>(P("data-v-4e4d199c"),t=t(),C(),t),E={class:"home"},L={class:"container"},G={key:0},H=c(()=>e("div",{class:"heading flex1"},[e("h3",null,"Results"),e("p",null,"Dashboard / Results")],-1)),U={class:"content flex"},q={class:"content_left"},M={class:"top"},B={class:"wlecome flex1"},$=c(()=>e("div",{class:"text"},[e("h3",null,"Welcome Back !"),e("label",null,"Ukubona Dashboard")],-1)),z={class:"img"},j=["src"],W={key:0,class:"profile flex1"},J={class:"box"},K={class:"image"},Q=["src"],X={class:"text"},Y={key:0,class:"box"},Z=c(()=>e("label",null,"Saved FIles",-1)),ee=c(()=>e("br",null,null,-1)),se=c(()=>e("i",{class:"fas fa-chevron-down"},null,-1)),te={class:"content_right"},oe={class:"right_top grid"},ae={class:"rbox flex1"},le={class:"text"},re=c(()=>e("h4",null,"total AI Results",-1)),ie={key:0},ne={key:1},ce=c(()=>e("div",{class:"icon"},[e("span",{class:"material-icons"}," library_books ")],-1)),de={class:"rbox flex1"},ue={class:"text"},he=c(()=>e("h4",null,"Available AI models",-1)),_e=c(()=>e("div",{class:"icon"},[e("span",{class:"material-icons"}," widgets ")],-1)),pe=c(()=>e("section",{class:"models"},null,-1)),me={class:"table"},ge={class:"container"},fe={class:"top-level"},ve={class:"left"},De=c(()=>e("h3",null,"Search Results",-1)),Ie={class:"search-button"},Te=c(()=>e("div",{class:"right"},null,-1)),ye=c(()=>e("thead",null,[e("tr",null,[e("th",null,"ScanID"),e("th",null,"Model"),e("th",null,"Uploaded"),e("th",null,"Result Summary"),e("th",null,"Status"),e("th")])],-1)),we={key:0},ke=["onClick"],be={key:0,class:"loading-table"},Oe=c(()=>e("div",{class:"spinner"},null,-1)),Se=[Oe],Pe={class:"pagination"},Ce={key:0},Ne=["onClick"],Re={key:1};function xe(t,o,l,r,s,u){const v=S("DicomViewer");return i(),n("main",null,[e("section",E,[e("div",L,[s.userData?(i(),n("h3",G,d(s.userData.hospital.name),1)):h("",!0),H,e("div",U,[e("div",q,[e("div",M,[e("div",B,[$,e("div",z,[e("img",{src:s.img2,alt:""},null,8,j)])]),s.userData?(i(),n("div",W,[e("div",J,[e("div",K,[e("img",{src:s.userData.profile_image_url,alt:""},null,8,Q)]),e("div",X,[e("p",null,d(s.userData.last_name)+" "+d(s.userData.first_name),1),e("label",null,d(s.userData.role),1)])]),s.userData?(i(),n("div",Y,[e("p",null,d(s.userData.saved_files),1),Z,p(),ee,e("button",{onClick:o[0]||(o[0]=a=>u.redirectTo("/profile"))},[p(" View Profile "),se])])):h("",!0)])):h("",!0)])]),e("div",te,[e("div",oe,[e("div",ae,[e("div",le,[re,s.userData?(i(),n("h2",ie,d(s.userData.total_scans),1)):(i(),n("h2",ne,"..."))]),ce]),e("div",de,[e("div",ue,[he,e("h2",null,d(t.$store.state.total_models),1)]),_e])])])])])]),pe,e("section",me,[e("div",ge,[e("div",fe,[e("div",ve,[De,k(e("input",{type:"search",name:"",id:"",placeholder:"search files","onUpdate:modelValue":o[1]||(o[1]=a=>t.searchText=a)},null,512),[[b,t.searchText]]),e("span",Ie,[e("i",{class:"fa-solid fa-magnifying-glass",onClick:o[2]||(o[2]=a=>u.getAIScans(null,t.searchText))})])]),Te]),e("table",null,[ye,s.scansData?(i(),n("tbody",we,[(i(!0),n(g,null,f(s.scansData.data,a=>(i(),n("tr",{key:a},[e("td",null,d(a.scanID),1),e("td",null,d(a.model_name),1),e("td",null,d(s.moment(a.date_added).fromNow()),1),e("td",null,d(a.result_summary||"-"),1),e("td",null,[e("span",{class:_({green:a.status=="success",yellow:a.status=="pending",red:a.status=="failed"})},d(a.status),3)]),e("td",null,[a.result?(i(),n("button",{key:0,onClick:D=>{s.selectedResult=a,s.selectedResult.mode="split",s.showDicomViewer=!0}},"View Result",8,ke)):h("",!0)])]))),128)),s.showFileTableLoader?(i(),n("div",be,Se)):h("",!0)])):h("",!0)]),e("div",Pe,[s.scansData&&s.scansData.data.length>0?(i(),n("ul",Ce,[e("li",null,[e("i",{class:_(["fas fa-chevron-left",{disabled:s.scansData.pagination.current_page<=1}]),onClick:o[3]||(o[3]=a=>u.getAIScans(s.scansData.pagination.current_page-1))},null,2)]),(i(!0),n(g,null,f(s.scansData.pagination.total_pages,(a,D)=>(i(),n("li",{key:a,class:_({active:s.scansData.pagination.current_page==a}),onClick:Ve=>u.getAIScans(a)},[e("span",null,d(a),1)],10,Ne))),128)),e("li",null,[e("i",{class:_(["fas fa-chevron-right",{disabled:s.scansData.pagination.current_page>=s.scansData.pagination.total_pages}]),onClick:o[4]||(o[4]=a=>u.getAIScans(s.scansData.pagination.current_page+1))},null,2)])])):(i(),n("p",Re,[p("No AI Models Used yet. "),e("button",{onClick:o[5]||(o[5]=a=>u.redirectTo("/models"))},"Use a Model")]))])])]),s.showDicomViewer?(i(),O(v,{key:0,onCloseDicomViewer:u.closeDicomViewer,currentSelectedDisplayItem:s.selectedResult},null,8,["onCloseDicomViewer","currentSelectedDisplayItem"])):h("",!0)])}const Le=I(A,[["render",xe],["__scopeId","data-v-4e4d199c"]]);export{Le as default};