import{d as I,v as L,z as i,b as c,t as w,c as m,x as e,e as x,V as y,N as n,F as B,L as D,ad as O,J as V,aq as k,O as T,Q as C,W as S,q as N}from"./registerWidgets.88d12ae1.js";import{C as A}from"./gateway.042591ee.js";import{B as U}from"./build.07d07ee7.js";import{a as j}from"./asyncComputed.0bf661db.js";import{L as F}from"./CircularLoading.0c459b72.js";import"./passwordlessManager.a5c71e7e.js";import"./activeRecord.57c6bf02.js";class E{list(t){const d=new URLSearchParams({offset:t.offset.toString(),limit:t.limit.toString(),from:t.from.getTime().toString(),to:t.to.getTime().toString(),search:t.search});return A.get(`projects/${t.projectId}/builds/${t.buildId}/logs?${d}`)}}const R=new E;class _{constructor(t,d,a,l,g,v,b){this.executionId=t,this.runtimeType=d,this.runtimeName=a,this.payload=l,this.event=g,this.buildId=v,this.createdAt=b}static fromDTO(t){return new _(t.executionId,t.runtimeType,t.runtimeName,t.payload,t.event,t.buildId,new Date(t.createdAt))}static async list(t){return(await R.list(t)).logs.map(_.fromDTO)}}const r=u=>(T("data-v-540332ab"),u=u(),C(),u),$={key:1,class:"logs"},P=r(()=>e("h1",null,"Logs",-1)),z={class:"filters"},G={class:"field"},J=r(()=>e("label",null,"Build",-1)),M={class:"field"},Q=r(()=>e("label",null,"From",-1)),W={class:"field"},H=r(()=>e("label",null,"To",-1)),K={class:"field"},X=r(()=>e("label",null,"Search",-1)),Y={key:0,class:"log-list"},Z={class:"search-summary"},q=O('<details class="log" data-v-540332ab><summary class="log-header" data-v-540332ab><div class="log-date log-header-item" data-v-540332ab><span class="log-header-item-name" data-v-540332ab>Date</span></div><div class="log-runtime log-header-item" data-v-540332ab><span class="log-header-item-name" data-v-540332ab>Runtime</span></div><div class="log-execution log-header-item" data-v-540332ab><span class="log-header-item-name" data-v-540332ab>Execution</span></div><div class="log-event log-header-item" data-v-540332ab><span class="log-header-item-name" data-v-540332ab>Event</span></div></summary></details>',1),ee={class:"log-header"},te={class:"log-date log-header-item"},se={class:"log-header-item-value"},ae={class:"log-runtime log-header-item"},oe={class:"log-header-item-value"},le={class:"log-execution log-header-item"},ie={class:"log-header-item-value"},de={class:"log-event log-header-item"},ne={class:"log-header-item-value"},ce={class:"log-payload"},re=["textContent"],ue={key:1,class:"no-logs"},me=r(()=>e("p",null,"No logs found.",-1)),pe=[me],he=I({__name:"Logs",setup(u){const d=V().params.projectId,a=L({selectedBuild:"latest",buildOptions:[{label:"Latest",value:"latest"},{label:"All",value:"all"}],buildsLoading:!1,buildLoaded:!1}),l={from:new Date(Date.now()-1e3*60*60*24*7).toISOString().slice(0,16),to:new Date().toISOString().slice(0,16),search:""},g=async()=>{if(a.buildLoaded)return;a.buildsLoading=!0;const h=await U.list(d);a.buildOptions=[...a.buildOptions,...h.map(o=>({label:o.id.split("-")[0],value:o.id}))],a.buildLoaded=!0,a.buildsLoading=!1},v=h=>{a.selectedBuild=h.value,f()},{loading:b,result:p,refetch:f}=j(()=>_.list({projectId:d,limit:50,offset:0,buildId:a.selectedBuild,from:new Date(l.from),to:new Date(l.to),search:l.search}));return(h,o)=>i(b)||!i(p)?(c(),w(F,{key:0})):(c(),m("div",$,[P,e("div",z,[e("div",G,[J,x(i(k),{modelValue:a.selectedBuild,"onUpdate:modelValue":o[0]||(o[0]=s=>a.selectedBuild=s),options:a.buildOptions,"option-label":"label","option-value":"value",loading:a.buildsLoading,filter:!1,onShow:g,onChange:v},null,8,["modelValue","options","loading"])]),e("div",M,[Q,y(e("input",{"onUpdate:modelValue":o[1]||(o[1]=s=>l.from=s),type:"datetime-local"},null,512),[[S,l.from]])]),e("div",W,[H,y(e("input",{"onUpdate:modelValue":o[2]||(o[2]=s=>l.to=s),type:"datetime-local"},null,512),[[S,l.to]])]),e("div",K,[X,y(e("input",{"onUpdate:modelValue":o[3]||(o[3]=s=>l.search=s),type:"search"},null,512),[[S,l.search]])]),e("button",{onClick:o[4]||(o[4]=(...s)=>i(f)&&i(f)(...s))},"Filter")]),i(p).length>0?(c(),m("div",Y,[e("div",Z,"Showing "+n(i(p).length)+" results",1),q,(c(!0),m(B,null,D(i(p),s=>(c(),m("details",{key:s.createdAt.toString(),class:"log"},[e("summary",ee,[e("div",te,[e("span",se,n(s.createdAt.toISOString()),1)]),e("div",ae,[e("span",oe,n(s.runtimeType)+":"+n(s.runtimeName),1)]),e("div",le,[e("span",ie,n(s.executionId.slice(0,8)),1)]),e("div",de,[e("span",ne,n(s.event),1)])]),e("div",ce,[e("pre",{class:"log-payload-content",textContent:n(s.payload)},null,8,re)])]))),128))])):(c(),m("div",ue,pe))]))}});const Ie=N(he,[["__scopeId","data-v-540332ab"]]);export{Ie as default};
//# sourceMappingURL=Logs.15d7e657.js.map
