felicity-lims/felicity/static/assets/SampleDetail-1f1ef13b.js
2023-04-23 16:54:32 +02:00

5 lines
17 KiB
JavaScript

import{d as Y,ad as se,a8 as ae,s as ve,A as ne,q as oe,x as re,B as ke,V as le,o as n,g as i,h as e,j as W,l as A,L as ie,i as g,ai as Z,F as B,z as q,H as z,D as F,y as D,t as C,R as ee,v as we,C as P,E as I,G as V,w as j,ah as te,U as X,_ as K,a2 as Ce,r as G,bn as Re,bo as Se,ak as Ae}from"./index-cd9e6ac8.js";import{F as L}from"./Button-11ddd444.js";import{u as Ee}from"./analysis-efb3ac18.js";import{h as M,o as N,a as O}from"./constants-99d18042.js";import{u as Te}from"./samples-84482611.js";import{t as Ue}from"./AuditLog-efe68260.js";const $e=e("hr",{class:"mt-4 mb-2"},null,-1),Ie=e("h3",{class:"font-bold"},"Analyses/Results",-1),De=e("hr",{class:"mb-4 mt-2"},null,-1),Pe={class:"overflow-x-auto"},Ve={class:"align-middle inline-block min-w-full shadow overflow-hidden bg-white shadow-dashboard px-2 pt-1 rounded-bl-lg rounded-br-lg"},je={key:0,class:"py-4 text-center"},Le={key:1,class:"min-w-full"},Me={class:"px-1 py-1 border-b-2 border-gray-300 text-left leading-4 text-gray-800 tracking-wider"},Ne=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left leading-4 text-gray-800 tracking-wider"},null,-1),Oe=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left leading-4 text-gray-800 tracking-wider"}," Analysis ",-1),Be=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Methods ",-1),Fe=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Instrument ",-1),Je=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Analyst ",-1),qe=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Interim ",-1),He=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Result ",-1),Ge=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Retest ",-1),ze=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Submitted ",-1),Ke=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Due Date ",-1),Qe=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Status ",-1),We=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Reportable ",-1),Xe=e("th",{class:"px-1 py-1 border-b-2 border-gray-300"},null,-1),Ye={class:"bg-white"},Ze=["onUpdate:modelValue","onChange","disabled"],et=e("td",{class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},null,-1),tt={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},st={class:"text-sm leading-5 text-sky-800 font-semibold"},at={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},nt={class:"text-sm leading-5 text-sky-800"},ot={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},rt={class:"text-sm leading-5 text-sky-800"},lt={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},it={class:"text-sm leading-5 text-sky-800"},ct={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},dt={key:0,class:"text-sm leading-5 text-sky-800"},ut={key:1,class:"block col-span-2 mb-2"},pt=["onUpdate:modelValue","onChange"],ht=e("option",{value:""},null,-1),_t=["value"],ft={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},yt={key:0,class:"text-sm leading-5 text-sky-800"},mt={key:1,class:"block"},bt=["onUpdate:modelValue","onKeyup"],gt={key:2,class:"block col-span-2 mb-2"},xt=["onUpdate:modelValue","onChange"],vt=e("option",{value:""},null,-1),kt=["value"],wt={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},Ct={class:"text-sm leading-5 text-sky-800"},Rt={key:0,class:"text-sky-800"},St=e("i",{class:"fa fa-check-circle","aria-hidden":"true"},null,-1),At=[St],Et={key:1,class:"text-orange-600"},Tt=e("i",{class:"fa fa-times-circle","aria-hidden":"true"},null,-1),Ut=[Tt],$t=e("td",{class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},[e("div",{class:"text-sm leading-5 text-sky-800"},"2020-10-10")],-1),It=e("td",{class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},[e("div",{class:"text-sm leading-5 text-sky-800"},"2020-10-10")],-1),Dt={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},Pt={type:"button",class:"bg-sky-800 text-white px-2 py-1 rounded-sm leading-none"},Vt={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},jt={class:"text-sm leading-5 text-sky-800"},Lt={key:0,class:"text-emerald-600"},Mt=e("i",{class:"fa fa-thumbs-up","aria-hidden":"true"},null,-1),Nt=[Mt],Ot={key:1,class:"text-orange-600"},Bt=e("i",{class:"fa fa-thumbs-down","aria-hidden":"true"},null,-1),Ft=[Bt],Jt=e("td",{class:"px-1 py-1 whitespace-no-wrap text-right border-b border-gray-500 text-sm leading-5"},[D(` <button @click.prevent="submitResult(result)"
class="p-1 ml-2 border-white border text-gray-500rounded-smtransition duration-300 hover:border-sky-800 hover:text-sky-800 focus:outline-none">
submit
</button> `)],-1),qt={class:"my-4"},Ht=Y({__name:"Results",setup(J){const R=se(),c=ae(),{sample:k,analysisResults:x,fetchingResults:S}=ve(c),o=ne({can_submit:!1,can_cancel:!1,can_retract:!1,can_approve:!1,can_retest:!1,can_reinstate:!1,allChecked:!1});oe(()=>c.fetchAnalysisResultsForSample(R.params.sampleUid)),re(()=>R.params.sampleUid,(s,d)=>{c.resetSample(),c.fetchAnalysisResultsForSample(R.params.sampleUid)});function T(){let s=[];return x?.value?.forEach(d=>{d.checked&&s.push(d)}),s}function E(){let s=T(),d=[];return s?.forEach($=>d.push({uid:$.uid,result:$.result})),d}function f(){const s=T();let d=[];return s?.forEach($=>d.push($.uid)),d}function t(s){m()?o.allChecked=!0:o.allChecked=!1,b()}function a(s){s.checked=!0,b()}function l(s){s.checked=!1,b()}async function y(){await x?.value?.forEach(s=>o.allChecked?a(s):l(s)),b()}async function h(){await x?.value?.forEach(s=>l(s)),b()}function m(){return x?.value?.every(s=>s.checked===!0)}function u(s){switch(s?.status){case"retracted":return!0;case"approved":return!0;case"cancelled":return k?.value?.status!=="received";default:return!1}}function _(s){s.editable=!0}function v(s){return k?.value?.status!=="received"||s.status!=="pending"?!1:s?.editable||te(s?.result)?(_(s),!0):!1}function U(s){switch(s?.status){case"retracted":return"bg-gray-300";case"aproved":return s?.reportable===!1?"bg-orange-600":"";default:return""}}function b(){o.can_cancel=!1,o.can_submit=!1,o.can_retract=!1,o.can_approve=!1,o.can_retest=!1,o.can_reinstate=!1;const s=T();s.length!==0&&(s.every(d=>d.status==="cancelled")&&(o.can_reinstate=!0),s.every(d=>d.status==="pending")&&(o.can_cancel=!0),s.every(d=>d.status==="pending"&&!te(d.result))&&(o.can_submit=!0),s.every(d=>d.status==="resulted")&&(o.can_retract=!0,o.can_approve=!0,o.can_retest=!0))}const w=async()=>{const s=X(()=>c.getSample);s.value&&c.fetchSampleStatus(s?.value?.uid)};let{submitResults:H,cancelResults:Q,reInstateResults:ce,approveResults:de,retractResults:ue,retestResults:pe}=Ee();const he=()=>H(E(),"sample",k?.value?.uid).then(()=>w()).finally(()=>h()),_e=()=>Q(f()).then(()=>w()).finally(()=>h()),fe=()=>ce(f()).then(()=>w()).finally(()=>h()),ye=()=>de(f(),"sample",k?.value?.uid).then(()=>w()).finally(()=>h()),me=()=>ue(f()).then(()=>w()).finally(()=>h()),be=()=>pe(f()).then(()=>w()).finally(()=>h());return(s,d)=>{const $=ke("font-awesome-icon"),ge=le("motion-slide-right");return n(),i(B,null,[$e,Ie,De,e("div",Pe,[e("div",Ve,[W(S)?(n(),i("div",je,[A(ie,{message:"Fetching analytes ..."})])):(n(),i("table",Le,[e("thead",null,[e("tr",null,[e("th",Me,[g(e("input",{type:"checkbox",class:"",onChange:y,"onUpdate:modelValue":d[0]||(d[0]=r=>o.allChecked=r)},null,544),[[Z,o.allChecked]])]),Ne,Oe,Be,Fe,Je,qe,He,Ge,ze,Ke,Qe,We,Xe])]),e("tbody",Ye,[(n(!0),i(B,null,q(W(x),r=>g((n(),i("tr",{key:r.uid,class:z([U(r)])},[e("td",null,[g(e("input",{type:"checkbox",class:"border-red-500","onUpdate:modelValue":p=>r.checked=p,onChange:p=>t(),disabled:u(r)},null,40,Ze),[[Z,r.checked]]),r.status==="pending"?(n(),F($,{key:0,icon:"fa-question",class:"ml-1 text-xs"})):D("v-if",!0),r.status==="resulted"?(n(),F($,{key:1,icon:"fa-question",class:"ml-1 text-xs text-orange"})):D("v-if",!0)]),et,e("td",tt,[e("div",st,C(r.analysis?.name),1)]),e("td",at,[e("div",nt,C(r.method?.name||"None"),1)]),e("td",ot,[e("div",rt,C(r.instrument?.name||"None"),1)]),e("td",lt,[e("div",it,C(r.analyst?.name||"moyoza"),1)]),e("td",ct,[!v(r)||r?.analysis?.interims?.length===0?(n(),i("div",dt," --- ")):(n(),i("label",ut,[g(e("select",{class:"form-input mt-1 block w-full","onUpdate:modelValue":p=>r.result=p,onChange:p=>a(r)},[ht,(n(!0),i(B,null,q(r?.analysis?.interims,(p,xe)=>(n(),i("option",{key:p.key,value:p.value},C(p.value),9,_t))),128))],40,pt),[[ee,r.result]])]))]),e("td",ft,[v(r)?r?.analysis?.resultOptions?.length===0?(n(),i("label",mt,[g(e("input",{class:"form-input mt-1 block w-full","onUpdate:modelValue":p=>r.result=p,onKeyup:p=>a(r)},null,40,bt),[[we,r.result]])])):(n(),i("label",gt,[g(e("select",{class:"form-input mt-1 block w-full","onUpdate:modelValue":p=>r.result=p,onChange:p=>a(r)},[vt,(n(!0),i(B,null,q(r?.analysis?.resultOptions,(p,xe)=>(n(),i("option",{key:p.optionKey,value:p.value},C(p.value),9,kt))),128))],40,xt),[[ee,r.result]])])):(n(),i("div",yt,C(r?.result),1))]),e("td",wt,[e("div",Ct,[r?.retest?(n(),i("span",Rt,At)):(n(),i("span",Et,Ut))])]),$t,It,e("td",Dt,[e("button",Pt,C(r.status),1)]),e("td",Vt,[e("div",jt,[r?.reportable?(n(),i("span",Lt,Nt)):(n(),i("span",Ot,Ft))])]),Jt],2)),[[ge]])),128))])]))])]),e("section",qt,[g(A(L,{key:"cancel",onClick:j(_e,["prevent"]),color:"sky-800"},{default:I(()=>[V("Cancel")]),_:1},8,["onClick"]),[[P,M(O.UPDATE,N.RESULT)&&o.can_cancel]]),g(A(L,{key:"reinstate",onClick:j(fe,["prevent"]),color:"orange-600"},{default:I(()=>[V("Re-Instate")]),_:1},8,["onClick"]),[[P,M(O.UPDATE,N.RESULT)&&o.can_reinstate]]),g(A(L,{key:"submit",onClick:j(he,["prevent"]),color:"orange-600"},{default:I(()=>[V("Submit")]),_:1},8,["onClick"]),[[P,M(O.UPDATE,N.RESULT)&&o.can_submit]]),g(A(L,{key:"retract",onClick:j(me,["prevent"]),color:"orange-600"},{default:I(()=>[V("Retract")]),_:1},8,["onClick"]),[[P,M(O.UPDATE,N.RESULT)&&o.can_retract]]),g(A(L,{key:"verify",onClick:j(ye,["prevent"]),color:"orange-600"},{default:I(()=>[V("Verify")]),_:1},8,["onClick"]),[[P,M(O.UPDATE,N.RESULT)&&o.can_approve]]),g(A(L,{key:"retest",onClick:j(be,["prevent"]),color:"orange-600"},{default:I(()=>[V("Retest")]),_:1},8,["onClick"]),[[P,M(O.UPDATE,N.RESULT)&&o.can_retest]])])],64)}}}),Gt=K(Ht,[["__file","/home/aurthur/Development/Python/felicity/felicity-lims/webapp/views/sample/_id/Results.vue"]]);const zt=e("div",{id:"jsonPreview"},null,-1),Kt={__name:"JsonPreViewer",props:["data","wrapper"],setup(J){const R=J;re(()=>R.data,(t,a)=>{document.getElementById("jsonPreview").innerHTML="",t.length!==0&&new f({container:document.getElementById("jsonPreview"),data:JSON.stringify(R.data),theme:"light",expand:!1})});const c=Object.prototype.toString;function k(t){return typeof t=="number"}function x(t){return typeof t=="boolean"}function S(t){return typeof t>"u"}function o(t){return c.call(t)==="[object Array]"}function T(t){return c.call(t)==="[object Object]"}function E(t){return c.call(t)==="[object Null]"}function f(t){const a={theme:"light",container:null,data:"{}",expand:!1};if(this.options=Object.assign(a,t),E(t.container))throw new Error("Container: dom element is required");this.render()}return f.prototype.renderRight=function(t,a,l){k(l)?a.setAttribute("class",t+"rightNumber"):x(l)?a.setAttribute("class",t+"rightBoolean"):l==="null"?a.setAttribute("class",t+"rightNull"):a.setAttribute("class",t+"rightString"),a.innerText=l},f.prototype.renderChildren=function(t,a,l,y,h,m){let u=this,_=this.createElement("span"),v=this.options.expand?"rotate90":"",U=this.options.expand?"add-height":"";_.setAttribute("class",t+"folder "+v),_.onclick=function(H){let Q=H.target.parentNode.nextSibling;u.toggleItem(Q,H.target)};let b=0,w=!1;T(l)?(b=Object.keys(l).length,w=!0):b=l.length,m.innerHTML=w?a+"&nbsp;&nbsp{"+b+"}":a+"&nbsp;&nbsp["+b+"]",m.prepend(_),y.setAttribute("class",t+"rightObj "+U),u.parse(l,y,h+0,t)},f.prototype.parse=function(t,a,l,y){const h=this;this.forEach(t,function(m,u){const{left:_,right:v}=h.createItem(l,y,a,u,typeof m!="object");typeof m!="object"?h.renderRight(y,v,m):h.renderChildren(y,u,m,v,l,_)})},f.prototype.createItem=function(t,a,l,y,h){let m=this,u=this.createElement("div"),_=this.createElement("div"),v=this.createElement("div"),U=this.createElement("div");return u.style.marginLeft=t*2+"px",_.innerHTML=`${y}<span class="jv-${a}-symbol">&nbsp;:&nbsp;</span>`,h?(u.appendChild(U),U.appendChild(_),U.appendChild(v),l.appendChild(u),u.setAttribute("class",a+"current"),U.setAttribute("class","jv-wrap"),_.setAttribute("class",a+"left")):(u.appendChild(_),u.appendChild(v),l.appendChild(u),u.setAttribute("class",a+"current"),_.setAttribute("class",a+"left jv-folder"),_.onclick=function(b){let w=b.target.nextSibling;m.toggleItem(w,b.target.querySelector("span"))}),{left:_,right:v,current:u}},f.prototype.render=function(){let t=this.options.data,a="jv-"+this.options.theme+"-",l=0,y=this.options.container,h="object",m;y.setAttribute("class",a+"con");try{m=JSON.parse(t)}catch{throw new Error("It is not a json format")}o(m)&&(h="array");const{left:u,right:_}=this.createItem(l,a,y,h);this.renderChildren(a,h,m,_,l,u)},f.prototype.toggleItem=function(t,a){t.classList.toggle("add-height"),a.classList.toggle("rotate90")},f.prototype.createElement=function(t){return document.createElement(t)},f.prototype.forEach=function(t,a){if(!(S(t)||E(t)))if(typeof t=="object"&&o(t))for(let l=0,y=t.length;l<y;l++)a.call(null,t[l],l,t);else for(let l in t)t.hasOwnProperty(l)&&a.call(null,t[l]??"null",l,t)},(t,a)=>(n(),i("div",{class:z(J.wrapper)},[A(Ce,{name:"bounce"},{default:I(()=>[zt]),_:1})],2))}},Qt=K(Kt,[["__file","/home/aurthur/Development/Python/felicity/felicity-lims/webapp/components/JsonPreViewer.vue"]]),Wt={key:1},Xt={key:0,class:"flex justify-start mt-4 mr-4"},Yt={class:""},Zt=["onClick"],es={class:"flex justify-between items-center space-x-4"},ts={class:"flex-1 min-w-0"},ss={class:"text-sm font-medium text-gray-900 truncat"},as={class:"text-sm text-gray-500 truncat"},ns=["onClick"],os={class:"ml-4 w-full"},rs=e("h5",null,"Json Impress",-1),ls=e("hr",{class:"mb-2"},null,-1),is={key:1,class:"mt-4 text-red-500"},cs=Y({__name:"Impress",setup(J){const{withClientQuery:R}=Ae(),c=se(),k=G(!1),x=G([]),S=G({});oe(()=>{k.value=!0,R(Re,{uids:[c?.params?.sampleUid]},"impressReportsMeta").then(E=>{x.value=E}).finally(()=>{k.value=!1})});const{downloadImpress:o}=Te(),T=async E=>await o(E);return(E,f)=>k.value?(n(),F(ie,{key:0,message:"Loading your reports ..."},null,8,["message"])):(n(),i("section",Wt,[x.value.length>0?(n(),i("div",Xt,[e("ul",Yt,[(n(!0),i(B,null,q(x.value,t=>(n(),i("li",{key:t?.uid,class:z(["mb-2 p-3 rounded-sm border w-96",[{"border-gray-300 bg-white":t?.uid!==S.value?.uid},{"border-3 border-blue-800 bg-green-200":t?.uid===S.value?.uid}]]),onClick:a=>S.value=t},[e("div",es,[e("div",ts,[e("p",ss,C(t.state),1),e("p",as," Generated on "+C(t.dateGenerated),1),D(` <FontAwesomeIcon class="text-red-500 mr-2" icon="fa-message" />
<FontAwesomeIcon class="text-red-500" icon="fa-envelope" /> `)]),e("span",{class:"flex justify-center items-center animate-bounce h-8 w-8 rounded-full bg-white border border-gray-200 drop-shadow-sm",onClick:a=>T(t.uid)},[A(W(Se),{class:"text-blue-500",icon:"fa-download"})],8,ns)])],10,Zt))),128))]),e("div",os,[rs,ls,A(Qt,{data:S.value,wrapper:"max-h-96 overflow-y-scroll"},null,8,["data"])])])):(n(),i("div",is,"This sample has no Impress Reports"))]))}}),ds=K(cs,[["__file","/home/aurthur/Development/Python/felicity/felicity-lims/webapp/views/sample/_id/Impress.vue"]]),us={class:"col-span-12"},ps={class:"bg-white shadow-md mt-2"},hs={class:"-mb-px flex justify-start"},_s=["onClick"],fs=Y({__name:"SampleDetail",setup(J){const R=ae(),c=ne({currentTab:G("analysis-results"),tabs:["analysis-results","logs","impress-reports"],sample:X(()=>R.getSample)});return X(()=>"tab-"+c.currentTab),(k,x)=>{const S=le("motion-slide-left");return n(),i("section",us,[g((n(),i("nav",ps,[e("div",hs,[(n(!0),i(B,null,q(c.tabs,o=>(n(),i("a",{key:o,class:z(["no-underline text-gray-500 uppercase tracking-wide font-bold text-xs py-1 px-4 tab hover:bg-sky-600 hover:text-gray-200",{"tab-active":c.currentTab===o}]),onClick:T=>c.currentTab=o,href:"#"},C(o),11,_s))),128))])])),[[S]]),e("div",null,[c.currentTab==="analysis-results"?(n(),F(Gt,{key:0})):D("v-if",!0),c.currentTab==="logs"?(n(),F(Ue,{key:1,targetType:"sample",targetId:c.sample?.uid},null,8,["targetId"])):D("v-if",!0),c.currentTab==="impress-reports"?(n(),F(ds,{key:2})):D("v-if",!0)])])}}}),ks=K(fs,[["__file","/home/aurthur/Development/Python/felicity/felicity-lims/webapp/views/sample/_id/SampleDetail.vue"]]);export{ks as default};