bunqueue-dashboard 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent/index.ts +8 -3
- package/agent/manager.ts +4 -2
- package/agent/server.ts +66 -2
- package/dist/.vite/manifest.json +63 -63
- package/dist/assets/{AddJob-CMIT6e17.js → AddJob-vk3jh1Zk.js} +2 -2
- package/dist/assets/Benchmark-CpViF2ZC.js +1 -0
- package/dist/assets/{CopilotPanel-BDZzDmVy.js → CopilotPanel-C9ojQ_8d.js} +3 -3
- package/dist/assets/{CopyButton-XT7ykzf5.js → CopyButton-BC6QECSJ.js} +1 -1
- package/dist/assets/{Cron-9hndZ-Z5.js → Cron-Bbf7mRaK.js} +1 -1
- package/dist/assets/{CronManager-BQupx6wZ.js → CronManager-CeNUeoOc.js} +1 -1
- package/dist/assets/Database--bK9pYZF.js +3 -0
- package/dist/assets/{Diagnostics-BzVDq9CH.js → Diagnostics-CGJPsWZQ.js} +1 -1
- package/dist/assets/Dlq-Bs1pupY2.js +1 -0
- package/dist/assets/{DlqControl-Cu2i1oq5.js → DlqControl-BLKVzYQC.js} +1 -1
- package/dist/assets/{DlqPro-HBrCftLD.js → DlqPro-D8SmIQUs.js} +1 -1
- package/dist/assets/{Flows-D3Bvkmd6.js → Flows-BOogljnP.js} +1 -1
- package/dist/assets/{JobInspector-B7zEuFhM.js → JobInspector-Cp4ZuQGI.js} +2 -2
- package/dist/assets/Jobs-C2HYkZXi.js +1 -0
- package/dist/assets/JobsPro-D0uclU0B.js +1 -0
- package/dist/assets/Logs-yn92V_T8.js +1 -0
- package/dist/assets/{LogsPro-P73LCkap.js → LogsPro-DSiV8Ajj.js} +1 -1
- package/dist/assets/{McpServer-CUK20-uN.js → McpServer-CNt7kssG.js} +2 -2
- package/dist/assets/{Metrics-BodjiKpf.js → Metrics-CbscCpvx.js} +1 -1
- package/dist/assets/MetricsPro-CBiFDVne.js +1 -0
- package/dist/assets/Overview-BOuOPWsb.js +1 -0
- package/dist/assets/{Pagination-Cd6lHj2E.js → Pagination-Bj1z6OlD.js} +1 -1
- package/dist/assets/QueueControl-Bl4l9dT6.js +1 -0
- package/dist/assets/QueueDetail-BSUH0Nl6.js +1 -0
- package/dist/assets/{Queues-LrodynCj.js → Queues-BEQlaWVc.js} +1 -1
- package/dist/assets/{QueuesOverview-DrYjyped.js → QueuesOverview-BBjcyzz2.js} +1 -1
- package/dist/assets/{S3Backup-et1PcCC0.js → S3Backup-BmRt-Z8V.js} +1 -1
- package/dist/assets/S3BackupPro-Dsq0erDm.js +1 -0
- package/dist/assets/ServerControl-Bhr9FEXF.js +3 -0
- package/dist/assets/Settings-46jsrfhd.js +1 -0
- package/dist/assets/{Usage-CHCg6VNy.js → Usage-BFLZC7pV.js} +1 -1
- package/dist/assets/{UsagePro-Cto9k5OI.js → UsagePro-D0k-82eG.js} +1 -1
- package/dist/assets/{Webhooks-Cm3vZEp7.js → Webhooks-DChTcBSv.js} +1 -1
- package/dist/assets/Workers-DBXrLvfS.js +1 -0
- package/dist/assets/{WorkersPro-BidtV_Bp.js → WorkersPro-B6I9Ilbq.js} +1 -1
- package/dist/assets/{connectionStore-DI-LYcct.js → connectionStore-CCopJeU7.js} +1 -1
- package/dist/assets/index-BFjeS9FG.js +8 -0
- package/dist/assets/{install-BvB40Zk0.js → install-C019EM5j.js} +2 -2
- package/dist/index.html +2 -2
- package/package.json +12 -10
- package/scripts/embedded.gen.ts +95 -94
- package/scripts/serve.ts +34 -2
- package/dist/assets/Benchmark-Dq1-vJ2k.js +0 -1
- package/dist/assets/Database-Difs7xYV.js +0 -3
- package/dist/assets/Dlq-BCUVh_NO.js +0 -1
- package/dist/assets/Jobs-ovYRwmwi.js +0 -1
- package/dist/assets/JobsPro-DNZivuzq.js +0 -1
- package/dist/assets/Logs-CjM7MNYN.js +0 -1
- package/dist/assets/MetricsPro-CqcH6gJp.js +0 -1
- package/dist/assets/Overview-AwCA3XI2.js +0 -1
- package/dist/assets/QueueControl-D7J1JObu.js +0 -1
- package/dist/assets/QueueDetail-BtiN0s3b.js +0 -1
- package/dist/assets/S3BackupPro-BEo_EVAO.js +0 -1
- package/dist/assets/ServerControl-BRLFRj7k.js +0 -3
- package/dist/assets/Settings-CeRZgZU6.js +0 -1
- package/dist/assets/Workers-CVfx3TK-.js +0 -1
- package/dist/assets/index-C9fPU4bV.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{I as r,O as i,T as a,U as o,Z as s,b as c,c as l,h as u,m as d,u as f,w as p,x as m,y as h}from"./index-BFjeS9FG.js";import{a as g}from"./form-PtDLk33Z.js";import{t as _}from"./Pagination-Bj1z6OlD.js";var v=e(t(),1),y=n(),b=25;function x(){let[e,t]=(0,v.useState)(``),[n,x]=(0,v.useState)(0),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(null),{data:E}=i(()=>s.queues(),[],{intervalMs:3e4});(0,v.useEffect)(()=>{e||!E?.queues?.length||t((E.queues.find(e=>e.dlq>0)??E.queues[0]).name)},[E,e]);let{data:D,error:O,loading:k,refetch:A}=i((0,v.useCallback)(async()=>{if(!e)return{queue:e,page:n,entries:[],total:0};let t=await s.dlq(e,b,n*b);return{queue:e,page:n,entries:t.entries??[],total:t.total??0}},[e,n]),[e,n]),j=D&&D.queue===e&&D.page===n?D:null;(0,v.useEffect)(()=>{if(!j)return;let e=Math.max(0,Math.ceil((j.total??0)/b)-1);n>e&&x(e)},[j,n]);let M=async(e,t,n)=>{if(!(n&&!window.confirm(n))){C(!0),T(null);try{let n=(await t())?.count??0;T({ok:!0,text:`${e} ${l(n)} ${n===1?`entry`:`entries`}`}),A()}catch(e){T({ok:!1,text:e.message})}finally{C(!1)}}},N=j?.entries??[];return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(u,{title:`Dead Letter Queue`,description:`Inspect and replay jobs that exhausted their retries.`,live:!0,actions:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(p,{size:`sm`,disabled:!e||S,onClick:()=>M(`Retried`,()=>s.retryDlq(e),`Retry all ${j?.total??0} DLQ entries for "${e}"?`),children:[(0,y.jsx)(o,{className:`size-3.5`}),` Retry all`]}),(0,y.jsx)(p,{variant:`danger`,size:`sm`,disabled:!e||S,onClick:()=>M(`Purged`,()=>s.purgeDlq(e),`Purge all ${j?.total??0} DLQ entries for "${e}"?`),children:`Purge`})]})}),O&&(0,y.jsx)(m,{onRetry:A}),(0,y.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-56`,children:(0,y.jsx)(g,{value:e,"aria-label":`Queue`,onChange:e=>{t(e.target.value),x(0)},children:(E?.queues??[]).map(e=>(0,y.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,y.jsx)(`div`,{className:`w-40`,children:(0,y.jsx)(d,{label:`Entries`,value:l(j?.total),tone:j?.total?`red`:`default`,compact:!0})}),w&&(0,y.jsx)(`span`,{className:w.ok?`text-sm text-success`:`text-sm text-danger`,children:w.text})]}),k&&!j&&!O?(0,y.jsx)(c,{label:`Loading DLQ…`}):N.length===0?(0,y.jsx)(h,{icon:(0,y.jsx)(r,{}),title:`Dead letter queue is empty`,hint:`Failed jobs that exhaust their retries land here.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Error`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,y.jsx)(`th`,{className:`w-20 px-5 py-3`})]})}),(0,y.jsx)(`tbody`,{children:N.map(t=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:t.job.id}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:t.reason})}),(0,y.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:t.error||`—`}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:t.job.attempts??t.attempts?.length??`—`}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:f(t.enteredAt)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,y.jsx)(a,{"aria-label":`Retry job`,disabled:S,onClick:()=>M(`Retried`,()=>s.retryDlq(e,t.job.id)),children:(0,y.jsx)(o,{className:`size-3.5`})})})]},`${t.job.id}-${t.enteredAt}`))})]})}),j&&(0,y.jsx)(_,{page:n,pageSize:b,total:j.total,onPageChange:x,label:`entries`})]})}export{x as DlqControl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{m as n,r,t as i}from"./react-vendor-CHIHtdAC.js";import{
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{m as n,r,t as i}from"./react-vendor-CHIHtdAC.js";import{I as a,O as o,S as s,T as c,U as l,Z as u,b as d,c as f,h as p,u as m,w as h,x as g,y as _}from"./index-BFjeS9FG.js";import{a as v}from"./form-PtDLk33Z.js";import{t as y}from"./Pagination-Bj1z6OlD.js";var b=e(n(),1),x=i(),S=25;function C(){let[e,n]=(0,b.useState)(``),[i,C]=(0,b.useState)(`all`),[w,T]=(0,b.useState)(`newest`),[E,D]=(0,b.useState)(``),[O,k]=(0,b.useState)(0),[A,j]=(0,b.useState)(!1),[M,N]=(0,b.useState)(null),{data:P,refetch:F}=o(()=>u.queues(),[],{intervalMs:1e4}),I=P?.queues??[],L=I.reduce((e,t)=>e+t.dlq,0),{data:R,error:z,loading:B,refetch:V}=o((0,b.useCallback)(async()=>{if(!e)return{queue:e,page:O,entries:[],entriesTotal:0,stats:null};let[t,n]=await Promise.all([u.dlq(e,S,O*S),u.dlqStats(e).catch(()=>null)]);return{queue:e,page:O,entries:t.entries??[],entriesTotal:t.total??0,stats:n?.stats??null}},[e,O]),[e,O]),H=R&&R.queue===e&&R.page===O?R:null;(0,b.useEffect)(()=>{if(!H)return;let e=H.entriesTotal??0;O>0&&O*S>=e&&k(Math.max(0,Math.ceil(e/S)-1))},[H,O]);let U=async(e,t,n)=>{if(window.confirm(e)){j(!0),N(null);try{let e=(await n())?.count??0;N({ok:!0,text:`${t} ${f(e)} ${e===1?`entry`:`entries`}`}),V(),F()}catch(e){N({ok:!1,text:e.message})}finally{j(!1)}}},W=e=>{Y.current=!0,n(e),k(0),C(`all`)},G=H?.stats?.byReason??{},K=Object.keys(G).filter(e=>G[e]>0),q=[...K].sort((e,t)=>(G[t]??0)-(G[e]??0))[0],J=(0,b.useMemo)(()=>I.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[I]),Y=(0,b.useRef)(!1);(0,b.useEffect)(()=>{Y.current||e||J.length===0||(Y.current=!0,n(J[0].name),k(0),C(`all`))},[e,J]);let X=(0,b.useMemo)(()=>{let e=H?.entries??[];i!==`all`&&(e=e.filter(e=>e.reason===i));let t=E.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>w===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[H,i,E,w]),Z=L===0,Q=i!==`all`||E.trim()!==``,$=(H?.entriesTotal??0)>S;return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(p,{title:`Dead Letter Queue`,description:`Jobs that failed after exhausting all retries. Monitor, retry, or purge.`,live:!0}),z&&(0,x.jsx)(g,{onRetry:V}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,x.jsxs)(s,{children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,x.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,Z?`bg-emerald-500/10 text-success`:`bg-red-500/10 text-danger`),children:Z?`Healthy`:`Attention`})]}),(0,x.jsx)(`div`,{className:t(`mt-2 text-3xl font-bold tnum`,Z?`text-success`:`text-danger`),children:f(L)})]}),(0,x.jsxs)(s,{children:[(0,x.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,x.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:e?q??`No failures`:`Select a queue`})]}),(0,x.jsxs)(s,{children:[(0,x.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,x.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:H?.stats?f(H.stats.pendingRetry??0):`—`}),(0,x.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:e?`in this queue`:`awaiting retry`})]}),(0,x.jsxs)(s,{children:[(0,x.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,x.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:H?.stats?f(K.length):`—`}),(0,x.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]}),J.length>0&&(0,x.jsxs)(s,{className:`mb-6`,children:[(0,x.jsx)(`div`,{className:`mb-3 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,x.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:J.map(n=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>W(n.name),className:t(`rounded-lg border p-3 text-left transition-colors`,e===n.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,x.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:n.name}),(0,x.jsx)(`div`,{className:`mt-1 text-xl font-bold tnum text-danger`,children:n.dlq})]},n.name))})]}),(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-48`,children:(0,x.jsxs)(v,{value:e,onChange:e=>W(e.target.value),children:[(0,x.jsx)(`option`,{value:``,children:`Select a queue…`}),I.map(e=>(0,x.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,x.jsx)(`div`,{className:`w-40`,children:(0,x.jsxs)(v,{value:i,onChange:e=>C(e.target.value),"aria-label":`Filter by reason`,children:[(0,x.jsx)(`option`,{value:`all`,children:`All Reasons`}),K.map(e=>(0,x.jsx)(`option`,{value:e,children:e},e))]})}),(0,x.jsx)(`div`,{className:`w-36`,children:(0,x.jsxs)(v,{value:w,onChange:e=>T(e.target.value),"aria-label":$?`Sort this page`:`Sort`,children:[(0,x.jsxs)(`option`,{value:`newest`,children:[`Newest First`,$?` (this page)`:``]}),(0,x.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,$?` (this page)`:``]})]})}),(0,x.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),placeholder:`Filter this page by job ID…`,"aria-label":`Filter this page by job ID`,className:`h-9 min-w-40 flex-1 rounded-lg border border-line bg-surface px-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),(0,x.jsxs)(h,{size:`sm`,disabled:!e||A,onClick:()=>U(`Retry all for "${e}"?`,`Retried`,()=>u.retryDlq(e)),children:[(0,x.jsx)(l,{className:`size-3.5`}),` Retry All`]}),(0,x.jsx)(h,{variant:`danger`,size:`sm`,disabled:!e||A,onClick:()=>U(`Purge all for "${e}"?`,`Purged`,()=>u.purgeDlq(e)),children:`Purge All`})]}),M&&(0,x.jsx)(`div`,{className:t(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),B&&!H&&!z?(0,x.jsx)(d,{label:`Loading DLQ…`}):e?X.length===0?(0,x.jsx)(_,{icon:(0,x.jsx)(a,{}),title:Q?`No matches on this page`:`No dead letter entries`,hint:Q?`No entries on this page match your filter — the filter is page-scoped. Use the pager below to check other pages.`:`This queue has no dead letter entries.`}):(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Error`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,x.jsx)(`th`,{className:`w-16 px-5 py-3`})]})}),(0,x.jsx)(`tbody`,{children:X.map(t=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(r,{to:`/job?id=${encodeURIComponent(t.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:t.job.id})}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:t.reason})}),(0,x.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:t.error||`—`}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:m(t.enteredAt)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,x.jsx)(c,{"aria-label":`Retry`,disabled:A,onClick:()=>U(`Retry job ${t.job.id.slice(0,8)}… from "${e}"?`,`Retried`,()=>u.retryDlq(e,t.job.id)),children:(0,x.jsx)(l,{className:`size-3.5`})})})]},`${t.job.id}-${t.enteredAt}`))})]})}):(0,x.jsx)(_,{icon:(0,x.jsx)(a,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),e&&H&&(0,x.jsx)(y,{page:O,pageSize:S,total:H.entriesTotal,onPageChange:k,label:`entries`})]})}export{C as DlqPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{d as n,m as r,r as i,t as a}from"./react-vendor-CHIHtdAC.js";import{
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{d as n,m as r,r as i,t as a}from"./react-vendor-CHIHtdAC.js";import{S as o,Z as s,b as c,h as l,v as u,x as d}from"./index-BFjeS9FG.js";var f=e(r(),1),p={nodeWidth:168,nodeHeight:60,colGap:72,rowGap:20,padding:24};function m(e,t){let n=new Map,r=new Map,i=new Map;for(let t of e)n.set(t,0),r.set(t,0),i.set(t,[]);for(let e of t)!n.has(e.from)||!n.has(e.to)||e.from===e.to||(i.get(e.from)?.push(e.to),r.set(e.to,(r.get(e.to)??0)+1));let a=e.filter(e=>(r.get(e)??0)===0),o=0;for(;a.length;){let s=a.shift();o+=1;for(let e of i.get(s)??[]){n.set(e,Math.max(n.get(e)??0,(n.get(s)??0)+1));let t=(r.get(e)??0)-1;r.set(e,t),t===0&&a.push(e)}if(o>e.length+t.length)break}return n}function h(e,t,n={}){let r={...p,...n},i=m(e,t),a=new Map,o=0;for(let t of e){let e=i.get(t)??0;o=Math.max(o,e);let n=a.get(e);n?n.push(t):a.set(e,[t])}let s=0;for(let e of a.values())s=Math.max(s,e.length);let c=s*r.nodeHeight+Math.max(0,s-1)*r.rowGap,l=[];for(let e=0;e<=o;e++){let t=a.get(e)??[],n=t.length*r.nodeHeight+Math.max(0,t.length-1)*r.rowGap,i=r.padding+(c-n)/2;t.forEach((t,n)=>{l.push({id:t,layer:e,x:r.padding+e*(r.nodeWidth+r.colGap),y:i+n*(r.nodeHeight+r.rowGap)})})}return{nodes:l,width:r.padding*2+(o+1)*r.nodeWidth+o*r.colGap,height:r.padding*2+c}}var g=a(),_=168,v=60,y={nodeWidth:_,nodeHeight:v},b=60,x=6,S=`flow-order-9a3f`,C={completed:`border-success/50 bg-success/10 text-success`,failed:`border-danger/50 bg-danger/10 text-danger`,active:`border-blue-400/60 bg-blue-400/10 text-blue-400`,delayed:`border-accent/50 bg-accent/10 text-accent`,waiting:`border-warning/50 bg-warning/10 text-warning`,prioritized:`border-warning/50 bg-warning/10 text-warning`},w=e=>e&&C[e]||`border-line bg-surface-2 text-muted`,T=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,E=`bq-dash-recent-flows`,D=8;function O(){try{let e=JSON.parse(localStorage.getItem(E)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e?.root==`string`&&typeof e?.nodes==`number`&&typeof e?.at==`number`):[]}catch{return[]}}function k(e,t){let n=[t,...e.filter(e=>e.root!==t.root)].slice(0,D);try{localStorage.setItem(E,JSON.stringify(n))}catch{}return n}async function A(e){let t=e,n=new Set([e]);for(let e=0;e<12;e++){try{let{job:e}=await s.job(t),r=e?.parentId;if(r&&!n.has(r)){n.add(r),t=r;continue}}catch{}break}return t}async function j(e){let t=new Map,n=[],r=new Set,i=[{id:e,depth:0}];for(;i.length&&t.size<b;){let{id:e,depth:a}=i.shift();if(t.has(e))continue;let o=null;try{o=(await s.job(e)).job??null}catch{}if(t.set(e,o??{id:e,state:`unknown`}),!o||a>=x)continue;let c=(e,t,o,s)=>{let c=`${e}->${t}:${o}`;r.has(c)||(r.add(c),n.push({from:e,to:t,kind:o})),i.push({id:s,depth:a+1})};for(let t of o.childrenIds??[])c(e,t,`child`,t);for(let t of o.dependsOn??[])c(t,e,`depends`,t)}return{jobs:t,edges:n}}function M(e,t,n,r){let i=(e+n)/2;return`M${e},${t} C${i},${t} ${i},${r} ${n},${r}`}function N(){let[e,r]=n(),a=e.get(`root`)??(u()?S:``),[s,p]=(0,f.useState)(a),[m,x]=(0,f.useState)(null),[C,E]=(0,f.useState)(null),[D,N]=(0,f.useState)(!1),[F,I]=(0,f.useState)(null),[L,R]=(0,f.useState)(O),z=(0,f.useRef)(0),B=(0,f.useCallback)(async e=>{let t=e.trim();if(!t){x(null);return}let n=++z.current;N(!0),I(null);try{let e=await A(t),r=await j(e);if(n!==z.current)return;x(r),E(e),r.jobs.size>1&&R(t=>k(t,{root:e,nodes:r.jobs.size,at:Date.now()}))}catch(e){if(n!==z.current)return;I(e.message||`Failed to load flow`),x(null)}finally{n===z.current&&N(!1)}},[]);(0,f.useEffect)(()=>{a&&B(a)},[a,B]);let V=e=>{e.preventDefault();let t=s.trim();t&&r(t?{root:t}:{},{replace:!0})},H=m?h([...m.jobs.keys()],m.edges,y):null,U=new Map(H?.nodes.map(e=>[e.id,e])??[]),W=C?m?.jobs.get(C):void 0;return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(l,{title:`Flows`,description:`Visualize a job flow: parent, children, and dependency edges as an interactive graph.`,actions:m&&(0,g.jsx)(`button`,{type:`button`,onClick:()=>B(s||a),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Refresh`})}),(0,g.jsxs)(o,{className:`mb-6`,children:[(0,g.jsxs)(`form`,{onSubmit:V,className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(`input`,{value:s,onChange:e=>p(e.target.value),placeholder:`Job ID (any node in the flow)`,"aria-label":`Root job ID`,className:`min-w-0 flex-1 rounded-lg border border-line bg-surface-2 px-3 py-2 font-mono text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/50`}),(0,g.jsx)(`button`,{type:`submit`,disabled:!s.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-50`,children:`Load flow`})]}),(0,g.jsxs)(`p`,{className:`mt-2 text-xs text-faint`,children:[`Paste any job ID from the Job Inspector. The graph climbs to the flow root, then walks children and dependencies (up to `,b,` nodes).`]})]}),F&&(0,g.jsx)(d,{onRetry:()=>B(s||a)}),D&&!m&&(0,g.jsx)(c,{label:`Loading flow…`}),!D&&!m&&!F&&(0,g.jsx)(o,{children:(0,g.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,g.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow loaded.`}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Enter a job ID above, or open a job that is part of a flow and choose “View flow”.`}),L.length>0&&(0,g.jsxs)(`div`,{className:`mt-6`,children:[(0,g.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Recently viewed`}),(0,g.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:L.map(e=>(0,g.jsxs)(`button`,{type:`button`,onClick:()=>{p(e.root),r({root:e.root},{replace:!0})},className:`rounded-lg border border-line bg-surface-2 px-3 py-1.5 font-mono text-xs text-muted transition-colors hover:border-line-strong hover:text-fg`,children:[T(e.root),(0,g.jsxs)(`span`,{className:`ml-2 text-faint`,children:[e.nodes,` nodes`]})]},e.root))})]})]})}),m&&H&&(0,g.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1fr_260px]`,children:[(0,g.jsx)(o,{padded:!1,className:`overflow-auto p-4`,children:(0,g.jsxs)(`div`,{className:`relative`,style:{width:H.width,height:H.height},children:[(0,g.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 text-line`,width:H.width,height:H.height,children:[(0,g.jsx)(`title`,{children:`Flow edges`}),m.edges.map(e=>{let t=U.get(e.from),n=U.get(e.to);return!t||!n?null:(0,g.jsx)(`path`,{d:M(t.x+_,t.y+v/2,n.x,n.y+v/2),fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeDasharray:e.kind===`depends`?`4 4`:void 0,opacity:.5},`${e.from}-${e.to}-${e.kind}`)})]}),H.nodes.map(e=>{let n=m.jobs.get(e.id);return(0,g.jsxs)(`button`,{type:`button`,onClick:()=>E(e.id),style:{left:e.x,top:e.y,width:_,height:v},className:t(`absolute flex flex-col justify-center gap-0.5 rounded-lg border px-3 text-left transition-shadow`,w(n?.state),C===e.id&&`ring-2 ring-accent`),children:[(0,g.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:T(e.id)}),(0,g.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,g.jsx)(`span`,{className:`truncate`,children:n?.queue??`—`}),(0,g.jsx)(`span`,{className:`font-medium`,children:n?.state??`unknown`})]})]},e.id)})]})}),(0,g.jsxs)(o,{children:[W?(0,g.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-xs text-faint`,children:`Job`}),(0,g.jsx)(`div`,{className:`break-all font-mono text-xs text-fg`,children:W.id})]}),(0,g.jsx)(P,{label:`Queue`,value:W.queue??`—`}),(0,g.jsx)(P,{label:`State`,value:W.state??`unknown`}),(0,g.jsx)(P,{label:`Priority`,value:String(W.priority??0)}),(0,g.jsx)(P,{label:`Children`,value:String(W.childrenIds?.length??0)}),(0,g.jsx)(P,{label:`Depends on`,value:String(W.dependsOn?.length??0)}),(0,g.jsx)(i,{to:`/job?id=${encodeURIComponent(W.id)}`,className:`inline-block rounded-lg border border-line px-3 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg`,children:`Open in Job Inspector`})]}):(0,g.jsx)(`p`,{className:`text-sm text-muted`,children:`Click a node to inspect it.`}),(0,g.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-xs text-faint`,children:[(0,g.jsxs)(`div`,{className:`mb-1`,children:[m.jobs.size,` node`,m.jobs.size===1?``:`s`,` · `,m.edges.length,` edge`,m.edges.length===1?``:`s`]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,g.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,g.jsx)(`span`,{className:`inline-block h-px w-4 bg-current`}),` child`]}),(0,g.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,g.jsx)(`span`,{className:`inline-block h-px w-4 border-t border-dashed border-current`}),` `,`depends`]})]})]})]})]})]})}function P({label:e,value:t}){return(0,g.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,g.jsx)(`span`,{className:`text-xs text-faint`,children:e}),(0,g.jsx)(`span`,{className:`text-fg`,children:t})]})}export{N as Flows};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{d as t,m as n,r,t as i}from"./react-vendor-CHIHtdAC.js";import{C as a,D as o,E as s,J as c,S as l,T as u,a as d,g as f,m as p,o as m,v as h,y as g}from"./index-C9fPU4bV.js";import{a as _,n as v}from"./form-PtDLk33Z.js";import{t as y}from"./CopyButton-XT7ykzf5.js";import{t as b}from"./jobActions-CuOdMglt.js";var x=e(n(),1),S=i();function C({job:e,busy:t,act:n}){let r=b(e.state),i=r.cancel||r.discard||r.promote||r.retryActive||r.retryDlq||r.requeueCompleted||r.setPriority||r.setDelay||r.fail||r.moveToDelayed;return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Actions`}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>f.promoteJob(e.id)),children:`Promote (run now)`}),r.retryActive&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>f.retryJob(e.id)),children:`Retry (move to waiting)`}),r.retryDlq&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>f.retryDlq(e.queue??``,e.id)),children:`Retry from DLQ`}),r.requeueCompleted&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Requeue`,()=>f.retryCompleted(e.queue??``,e.id)),children:`Requeue`}),r.moveToDelayed&&(0,S.jsx)(w,{label:`Move to delayed (ms)`,cta:`To delayed`,disabled:t,onSubmit:t=>n(`Move to delayed`,()=>f.moveToDelayed(e.id,t))}),r.discard&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Discard`,()=>f.discardJob(e.id)),children:`Discard (to DLQ)`}),r.setPriority&&(0,S.jsx)(w,{label:`Set priority`,cta:`Set`,disabled:t,onSubmit:t=>n(`Priority`,()=>f.changePriority(e.id,t))}),r.setDelay&&(0,S.jsx)(w,{label:`Set delay (ms)`,cta:`Delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>f.changeDelay(e.id,t))}),r.fail&&(0,S.jsx)(T,{label:`Fail reason (optional)`,cta:`Fail`,variant:`warning`,disabled:t,onSubmit:t=>n(`Fail`,()=>f.failJob(e.id,t||void 0),`Force-fail this active job?`)}),r.cancel&&(0,S.jsx)(o,{variant:`danger`,size:`sm`,disabled:t,onClick:()=>n(`Cancel`,()=>f.cancelJob(e.id),`Cancel and remove this job?`),children:`Cancel (delete)`}),!i&&(0,S.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function w({label:e,cta:t,disabled:n,onSubmit:r}){let[i,a]=(0,x.useState)(``);return(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(v,{type:`number`,value:i,onChange:e=>a(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,S.jsx)(o,{size:`sm`,disabled:n||i.trim()===``,onClick:()=>r(Number(i)),children:t})]})}function T({label:e,cta:t,disabled:n,variant:r=`default`,onSubmit:i}){let[a,s]=(0,x.useState)(``);return(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(v,{value:a,onChange:e=>s(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,S.jsx)(o,{size:`sm`,variant:r,disabled:n,onClick:()=>{i(a),s(``)},children:t})]})}var E=36e5,D=10;function O(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??E,a=r?.delay??e.backoff??1e3,o=[];for(let e=n;e<t&&o.length<D;e++){let t=r?.type===`fixed`?a:a*2**e;o.push({attempt:e+1,delayMs:Math.min(t,i)})}return o}function k({job:e}){let t=e.maxAttempts??0,n=e.attempts??0;if(t<=1)return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Backoff`}),(0,S.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Backoff schedule`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Max attempts reached — no further retries will be scheduled.`})]});let r=e.backoffConfig,i=r?r.type:`exponential (default)`,a=t-n,o=O(e);return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Backoff schedule`,action:(0,S.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${m(r.maxDelay)}`:``]})}),(0,S.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map(e=>(0,S.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,S.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,S.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,m(e.delayMs)]})]},e.attempt))}),a>D&&(0,S.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,D,` of `,a,` remaining attempts.`]}),(0,S.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Approximate — the server applies ±`,r?.type===`fixed`?`20`:`50`,`% jitter at retry time, capped at `,m(r?.maxDelay??E),`.`]})]})}function A({jobId:e}){let[t,n]=(0,x.useState)(!1),[r,i]=(0,x.useState)(!1),[a,c]=(0,x.useState)(!1),[l,d]=(0,x.useState)(void 0),[p,m]=(0,x.useState)(null),h=async()=>{c(!0),m(null);try{d((await f.jobChildren(e)).data?.values),i(!0)}catch(e){m(e.message)}finally{c(!1)}},g=()=>{let e=!t;n(e),e&&!r&&!a&&h()},_=l&&typeof l==`object`?Array.isArray(l)?l.length:Object.keys(l).length:0;return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Child values`,action:(0,S.jsx)(o,{size:`sm`,variant:`ghost`,onClick:g,children:t?`Hide`:`Show`})}),t?a?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):p?(0,S.jsx)(`p`,{className:`text-xs text-danger`,children:p}):_===0?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,S.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(l,null,2)}):(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Resolved return values from this flow job's children.`})]})}function j({data:e,busy:t,onSave:n}){let[r,i]=(0,x.useState)(()=>JSON.stringify(e??null,null,2)),[a,c]=(0,x.useState)(null),l=(0,x.useRef)(r);return(0,x.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,i(t),c(null))},[e]),(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Edit data`,action:(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>{let e;try{e=JSON.parse(r)}catch(e){c(`Invalid JSON: ${e.message}`);return}c(null),n(e)},children:`Save data`})}),(0,S.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),spellCheck:!1,rows:8,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),a&&(0,S.jsx)(`p`,{className:`mt-2 text-xs text-danger`,children:a})]})}function M({jobId:e}){let[t,n]=(0,x.useState)([]),[r,i]=(0,x.useState)(0),[a,c]=(0,x.useState)(!1),[l,d]=(0,x.useState)(null),[p,m]=(0,x.useState)(``),[h,g]=(0,x.useState)(`info`),[y,b]=(0,x.useState)(!1),C=(0,x.useCallback)(async()=>{c(!0),d(null);try{let t=await f.jobLogs(e);n(t.data?.logs??[]),i(t.data?.count??0)}catch(e){d(e.message)}finally{c(!1)}},[e]);(0,x.useEffect)(()=>{C()},[C]);let w=async()=>{if(y)return;let t=p.trim();if(t){b(!0),d(null);try{await f.addJobLog(e,t,h),m(``),await C()}catch(e){d(e.message)}finally{b(!1)}}};return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Logs`,action:(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:r}),(0,S.jsx)(o,{size:`sm`,variant:`ghost`,disabled:a||y,onClick:C,children:`Refresh`}),(0,S.jsx)(o,{size:`sm`,variant:`danger`,disabled:y||t.length===0,onClick:async()=>{if(window.confirm(`Clear all logs for this job?`)){b(!0),d(null);try{await f.clearJobLogs(e),await C()}catch(e){d(e.message)}finally{b(!1)}}},children:`Clear logs`})]})}),l&&(0,S.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:l}),t.length===0?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,S.jsx)(`ol`,{className:`flex max-h-64 flex-col gap-1 overflow-auto rounded-lg bg-surface-2 p-3`,children:t.map((e,t)=>(0,S.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,S.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,S.jsx)(v,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>e.key===`Enter`&&w(),placeholder:`Add a log line…`,className:`h-8 flex-1 text-xs`}),(0,S.jsxs)(_,{value:h,onChange:e=>g(e.target.value),className:`h-8 w-24 text-xs`,children:[(0,S.jsx)(`option`,{value:`info`,children:`info`}),(0,S.jsx)(`option`,{value:`warn`,children:`warn`}),(0,S.jsx)(`option`,{value:`error`,children:`error`})]}),(0,S.jsx)(o,{size:`sm`,disabled:y||p.trim()===``,onClick:w,children:`Add`})]})]})}function N({timeline:e}){let t=e??[];return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Timeline`}),t.length===0?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,S.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,S.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(g,{status:e.state}),e.attempt!=null&&(0,S.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,S.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:d(e.timestamp)})]}),(e.worker||e.error)&&(0,S.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,S.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,S.jsx)(`div`,{className:`mt-0.5 text-xs text-danger/90`,children:e.error})]})]},t))})]})}function P(e){let t=e.timeline??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.state===`failed`&&n.error)return{message:n.error,attempt:n.attempt,timestamp:n.timestamp}}return null}function F(){let[e,n]=t(),[i,v]=(0,x.useState)(e.get(`id`)??``),[b,w]=(0,x.useState)(`id`),[T,E]=(0,x.useState)(null),[D,O]=(0,x.useState)({fetched:!1,value:void 0}),[F,R]=(0,x.useState)(!1),[z,B]=(0,x.useState)(!1),[V,H]=(0,x.useState)(null),[U,W]=(0,x.useState)(!1),G=(0,x.useRef)(0),K=async(e,t=b,r=!1)=>{let i=e.trim();if(!i)return;let a=++G.current;R(!0),B(!1),r||H(null);try{let e=(await(t===`custom`?f.jobByCustomId(i):f.job(i))).job;if(!e){if(a!==G.current)return;E(null),O({fetched:!1,value:void 0}),B(!0),n({},{replace:!0});return}let r=e.state===`completed`?await f.jobResult(e.id).catch(()=>null):null;if(a!==G.current)return;E(e),v(t===`custom`?e.id:i),n({id:e.id},{replace:!0}),O(r?{fetched:!0,value:r.result}:{fetched:!1,value:void 0})}catch(e){if(a!==G.current)return;e instanceof p&&(e.status===404||/not found/i.test(e.message))?(E(null),O({fetched:!1,value:void 0}),B(!0),n({},{replace:!0})):H({ok:!1,text:e.message})}finally{a===G.current&&R(!1)}},q=e.get(`id`);(0,x.useEffect)(()=>{q&&q!==T?.id&&K(q,`id`)},[q,T?.id]);let J=async(e,t,r)=>{if(!(r&&!window.confirm(r))&&T){W(!0),H(null);try{await t(),H({ok:!0,text:`${e} ✓`}),e===`Cancel`?(E(null),O({fetched:!1,value:void 0}),n({},{replace:!0})):await K(T.id,`id`,!0)}catch(e){H({ok:!1,text:e.message})}finally{W(!1)}}},Y=T?.state,X=T?P(T):null,Z=(T?.stacktrace?.length??0)>0,Q=(T?.childrenIds?.length??0)>0;return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(h,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:T&&(Q||T.parentId)?(0,S.jsx)(r,{to:`/flows?root=${encodeURIComponent(T.id)}`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`View flow`}):void 0}),(0,S.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,S.jsxs)(_,{value:b,onChange:e=>w(e.target.value),className:`w-40`,children:[(0,S.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,S.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,S.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,S.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,S.jsx)(`input`,{value:i,onChange:e=>v(e.target.value),onKeyDown:e=>e.key===`Enter`&&K(i),placeholder:b===`custom`?`custom / idempotency id — Enter to look up`:`job id (UUID) — Enter to look up`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 font-mono text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,S.jsx)(o,{variant:`accent`,disabled:F,onClick:()=>K(i),children:`Look up`})]}),V&&(0,S.jsx)(`div`,{className:V.ok?`mb-4 text-sm text-success`:`mb-4 text-sm text-danger`,children:V.text}),F&&!T?(0,S.jsx)(a,{label:`Loading job…`}):z?(0,S.jsx)(l,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`}):T?(0,S.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,S.jsxs)(u,{children:[(0,S.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:T.id}),(0,S.jsx)(y,{value:T.id})]}),(0,S.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:T.queue})]}),(0,S.jsx)(g,{status:Y??`waiting`})]}),(0,S.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,S.jsx)(I,{k:`Priority`,v:String(T.priority??0)}),(0,S.jsx)(I,{k:`Attempts`,v:`${T.attempts??0} / ${T.maxAttempts??`?`}`}),(0,S.jsx)(I,{k:`Progress`,v:`${T.progress??0}%`}),(0,S.jsx)(I,{k:`Created`,v:d(T.createdAt)}),(0,S.jsx)(I,{k:`Started`,v:d(T.startedAt??void 0)}),(0,S.jsx)(I,{k:`Completed`,v:d(T.completedAt??void 0)}),(0,S.jsx)(I,{k:`Duration`,v:m(T.startedAt&&T.completedAt?T.completedAt-T.startedAt:void 0)}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,S.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,S.jsx)(`span`,{className:`truncate font-mono`,children:T.customId??`—`}),T.customId&&(0,S.jsx)(y,{value:T.customId})]})]})]})]}),(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Data`}),(0,S.jsx)(L,{value:T.data})]}),(0,S.jsx)(j,{data:T.data,busy:U,onSave:e=>J(`Data`,()=>f.updateJobData(T.id,e))}),Y===`completed`&&(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Result`}),D.fetched&&D.value!==void 0&&D.value!==null?(0,S.jsx)(L,{value:D.value}):(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]}),(X||Z)&&(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Error`}),X&&(0,S.jsxs)(`div`,{className:`mb-3`,children:[(0,S.jsx)(`p`,{className:`text-sm text-danger`,children:X.message}),(0,S.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[X.attempt==null?``:`Attempt ${X.attempt} · `,d(X.timestamp)]})]}),Z&&(0,S.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-surface-2 p-3 font-mono text-xs text-danger/90`,children:T.stacktrace?.join(`
|
|
2
|
-
`)})]}),(0,S.jsx)(M,{jobId:T.id},`logs-${T.id}`),Q&&(0,S.jsx)(A,{jobId:T.id},`children-${T.id}`),(0,S.jsx)(N,{timeline:T.timeline}),(0,S.jsx)(k,{job:T})]}),(0,S.jsx)(C,{job:T,busy:U,act:J})]}):(0,S.jsx)(
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{d as t,m as n,r,t as i}from"./react-vendor-CHIHtdAC.js";import{C as a,G as o,S as s,Y as c,Z as l,a as u,b as d,g as f,h as p,o as m,w as h,y as g}from"./index-BFjeS9FG.js";import{a as _,n as v}from"./form-PtDLk33Z.js";import{t as y}from"./CopyButton-BC6QECSJ.js";import{t as b}from"./jobActions-CuOdMglt.js";var x=e(n(),1),S=i();function C({job:e,busy:t,act:n}){let r=b(e.state),i=r.cancel||r.discard||r.promote||r.retryActive||r.retryDlq||r.requeueCompleted||r.setPriority||r.setDelay||r.fail||r.moveToDelayed;return(0,S.jsxs)(s,{children:[(0,S.jsx)(a,{title:`Actions`}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,S.jsx)(h,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>l.promoteJob(e.id)),children:`Promote (run now)`}),r.retryActive&&(0,S.jsx)(h,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>l.retryJob(e.id)),children:`Retry (move to waiting)`}),r.retryDlq&&(0,S.jsx)(h,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>l.retryDlq(e.queue??``,e.id)),children:`Retry from DLQ`}),r.requeueCompleted&&(0,S.jsx)(h,{size:`sm`,disabled:t,onClick:()=>n(`Requeue`,()=>l.retryCompleted(e.queue??``,e.id)),children:`Requeue`}),r.moveToDelayed&&(0,S.jsx)(w,{label:`Move to delayed (ms)`,cta:`To delayed`,disabled:t,onSubmit:t=>n(`Move to delayed`,()=>l.moveToDelayed(e.id,t))}),r.discard&&(0,S.jsx)(h,{size:`sm`,disabled:t,onClick:()=>n(`Discard`,()=>l.discardJob(e.id)),children:`Discard (to DLQ)`}),r.setPriority&&(0,S.jsx)(w,{label:`Set priority`,cta:`Set`,disabled:t,onSubmit:t=>n(`Priority`,()=>l.changePriority(e.id,t))}),r.setDelay&&(0,S.jsx)(w,{label:`Set delay (ms)`,cta:`Delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>l.changeDelay(e.id,t))}),r.fail&&(0,S.jsx)(T,{label:`Fail reason (optional)`,cta:`Fail`,variant:`warning`,disabled:t,onSubmit:t=>n(`Fail`,()=>l.failJob(e.id,t||void 0),`Force-fail this active job?`)}),r.cancel&&(0,S.jsx)(h,{variant:`danger`,size:`sm`,disabled:t,onClick:()=>n(`Cancel`,()=>l.cancelJob(e.id),`Cancel and remove this job?`),children:`Cancel (delete)`}),!i&&(0,S.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function w({label:e,cta:t,disabled:n,onSubmit:r}){let[i,a]=(0,x.useState)(``);return(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(v,{type:`number`,value:i,onChange:e=>a(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,S.jsx)(h,{size:`sm`,disabled:n||i.trim()===``,onClick:()=>r(Number(i)),children:t})]})}function T({label:e,cta:t,disabled:n,variant:r=`default`,onSubmit:i}){let[a,o]=(0,x.useState)(``);return(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(v,{value:a,onChange:e=>o(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,S.jsx)(h,{size:`sm`,variant:r,disabled:n,onClick:()=>{i(a),o(``)},children:t})]})}var E=36e5,D=10;function O(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??E,a=r?.delay??e.backoff??1e3,o=[];for(let e=n;e<t&&o.length<D;e++){let t=r?.type===`fixed`?a:a*2**e;o.push({attempt:e+1,delayMs:Math.min(t,i)})}return o}function k({job:e}){let t=e.maxAttempts??0,n=e.attempts??0;if(t<=1)return(0,S.jsxs)(s,{children:[(0,S.jsx)(a,{title:`Backoff`}),(0,S.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,S.jsxs)(s,{children:[(0,S.jsx)(a,{title:`Backoff schedule`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Max attempts reached — no further retries will be scheduled.`})]});let r=e.backoffConfig,i=r?r.type:`exponential (default)`,o=t-n,c=O(e);return(0,S.jsxs)(s,{children:[(0,S.jsx)(a,{title:`Backoff schedule`,action:(0,S.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${m(r.maxDelay)}`:``]})}),(0,S.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:c.map(e=>(0,S.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,S.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,S.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,m(e.delayMs)]})]},e.attempt))}),o>D&&(0,S.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,D,` of `,o,` remaining attempts.`]}),(0,S.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Approximate — the server applies ±`,r?.type===`fixed`?`20`:`50`,`% jitter at retry time, capped at `,m(r?.maxDelay??E),`.`]})]})}function A({jobId:e}){let[t,n]=(0,x.useState)(!1),[r,i]=(0,x.useState)(!1),[o,c]=(0,x.useState)(!1),[u,d]=(0,x.useState)(void 0),[f,p]=(0,x.useState)(null),m=async()=>{c(!0),p(null);try{d((await l.jobChildren(e)).data?.values),i(!0)}catch(e){p(e.message)}finally{c(!1)}},g=()=>{let e=!t;n(e),e&&!r&&!o&&m()},_=u&&typeof u==`object`?Array.isArray(u)?u.length:Object.keys(u).length:0;return(0,S.jsxs)(s,{children:[(0,S.jsx)(a,{title:`Child values`,action:(0,S.jsx)(h,{size:`sm`,variant:`ghost`,onClick:g,children:t?`Hide`:`Show`})}),t?o?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):f?(0,S.jsx)(`p`,{className:`text-xs text-danger`,children:f}):_===0?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,S.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(u,null,2)}):(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Resolved return values from this flow job's children.`})]})}function j({data:e,busy:t,onSave:n}){let[r,i]=(0,x.useState)(()=>JSON.stringify(e??null,null,2)),[o,c]=(0,x.useState)(null),l=(0,x.useRef)(r);return(0,x.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,i(t),c(null))},[e]),(0,S.jsxs)(s,{children:[(0,S.jsx)(a,{title:`Edit data`,action:(0,S.jsx)(h,{size:`sm`,disabled:t,onClick:()=>{let e;try{e=JSON.parse(r)}catch(e){c(`Invalid JSON: ${e.message}`);return}c(null),n(e)},children:`Save data`})}),(0,S.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),spellCheck:!1,rows:8,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),o&&(0,S.jsx)(`p`,{className:`mt-2 text-xs text-danger`,children:o})]})}function M({jobId:e}){let[t,n]=(0,x.useState)([]),[r,i]=(0,x.useState)(0),[o,c]=(0,x.useState)(!1),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(``),[m,g]=(0,x.useState)(`info`),[y,b]=(0,x.useState)(!1),C=(0,x.useCallback)(async()=>{c(!0),d(null);try{let t=await l.jobLogs(e);n(t.data?.logs??[]),i(t.data?.count??0)}catch(e){d(e.message)}finally{c(!1)}},[e]);(0,x.useEffect)(()=>{C()},[C]);let w=async()=>{if(y)return;let t=f.trim();if(t){b(!0),d(null);try{await l.addJobLog(e,t,m),p(``),await C()}catch(e){d(e.message)}finally{b(!1)}}};return(0,S.jsxs)(s,{children:[(0,S.jsx)(a,{title:`Logs`,action:(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:r}),(0,S.jsx)(h,{size:`sm`,variant:`ghost`,disabled:o||y,onClick:C,children:`Refresh`}),(0,S.jsx)(h,{size:`sm`,variant:`danger`,disabled:y||t.length===0,onClick:async()=>{if(window.confirm(`Clear all logs for this job?`)){b(!0),d(null);try{await l.clearJobLogs(e),await C()}catch(e){d(e.message)}finally{b(!1)}}},children:`Clear logs`})]})}),u&&(0,S.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:u}),t.length===0?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,S.jsx)(`ol`,{className:`flex max-h-64 flex-col gap-1 overflow-auto rounded-lg bg-surface-2 p-3`,children:t.map((e,t)=>(0,S.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,S.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,S.jsx)(v,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>e.key===`Enter`&&w(),placeholder:`Add a log line…`,className:`h-8 flex-1 text-xs`}),(0,S.jsxs)(_,{value:m,onChange:e=>g(e.target.value),className:`h-8 w-24 text-xs`,children:[(0,S.jsx)(`option`,{value:`info`,children:`info`}),(0,S.jsx)(`option`,{value:`warn`,children:`warn`}),(0,S.jsx)(`option`,{value:`error`,children:`error`})]}),(0,S.jsx)(h,{size:`sm`,disabled:y||f.trim()===``,onClick:w,children:`Add`})]})]})}function N({timeline:e}){let t=e??[];return(0,S.jsxs)(s,{children:[(0,S.jsx)(a,{title:`Timeline`}),t.length===0?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,S.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,S.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(f,{status:e.state}),e.attempt!=null&&(0,S.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,S.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:u(e.timestamp)})]}),(e.worker||e.error)&&(0,S.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,S.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,S.jsx)(`div`,{className:`mt-0.5 text-xs text-danger/90`,children:e.error})]})]},t))})]})}function P(e){let t=e.timeline??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.state===`failed`&&n.error)return{message:n.error,attempt:n.attempt,timestamp:n.timestamp}}return null}function F(){let[e,n]=t(),[i,v]=(0,x.useState)(e.get(`id`)??``),[b,w]=(0,x.useState)(`id`),[T,E]=(0,x.useState)(null),[D,O]=(0,x.useState)({fetched:!1,value:void 0}),[F,R]=(0,x.useState)(!1),[z,B]=(0,x.useState)(!1),[V,H]=(0,x.useState)(null),[U,W]=(0,x.useState)(!1),G=(0,x.useRef)(0),K=async(e,t=b,r=!1)=>{let i=e.trim();if(!i)return;let a=++G.current;R(!0),B(!1),r||H(null);try{let e=(await(t===`custom`?l.jobByCustomId(i):l.job(i))).job;if(!e){if(a!==G.current)return;E(null),O({fetched:!1,value:void 0}),B(!0),n({},{replace:!0});return}let r=e.state===`completed`?await l.jobResult(e.id).catch(()=>null):null;if(a!==G.current)return;E(e),v(t===`custom`?e.id:i),n({id:e.id},{replace:!0}),O(r?{fetched:!0,value:r.result}:{fetched:!1,value:void 0})}catch(e){if(a!==G.current)return;e instanceof c&&(e.status===404||/not found/i.test(e.message))?(E(null),O({fetched:!1,value:void 0}),B(!0),n({},{replace:!0})):H({ok:!1,text:e.message})}finally{a===G.current&&R(!1)}},q=e.get(`id`);(0,x.useEffect)(()=>{q&&q!==T?.id&&K(q,`id`)},[q,T?.id]);let J=async(e,t,r)=>{if(!(r&&!window.confirm(r))&&T){W(!0),H(null);try{await t(),H({ok:!0,text:`${e} ✓`}),e===`Cancel`?(E(null),O({fetched:!1,value:void 0}),n({},{replace:!0})):await K(T.id,`id`,!0)}catch(e){H({ok:!1,text:e.message})}finally{W(!1)}}},Y=T?.state,X=T?P(T):null,Z=(T?.stacktrace?.length??0)>0,Q=(T?.childrenIds?.length??0)>0;return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(p,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:T&&(Q||T.parentId)?(0,S.jsx)(r,{to:`/flows?root=${encodeURIComponent(T.id)}`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`View flow`}):void 0}),(0,S.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,S.jsxs)(_,{value:b,onChange:e=>w(e.target.value),className:`w-40`,children:[(0,S.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,S.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,S.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,S.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,S.jsx)(`input`,{value:i,onChange:e=>v(e.target.value),onKeyDown:e=>e.key===`Enter`&&K(i),placeholder:b===`custom`?`custom / idempotency id — Enter to look up`:`job id (UUID) — Enter to look up`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 font-mono text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,S.jsx)(h,{variant:`accent`,disabled:F,onClick:()=>K(i),children:`Look up`})]}),V&&(0,S.jsx)(`div`,{className:V.ok?`mb-4 text-sm text-success`:`mb-4 text-sm text-danger`,children:V.text}),F&&!T?(0,S.jsx)(d,{label:`Loading job…`}):z?(0,S.jsx)(g,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`}):T?(0,S.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,S.jsxs)(s,{children:[(0,S.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:T.id}),(0,S.jsx)(y,{value:T.id})]}),(0,S.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:T.queue})]}),(0,S.jsx)(f,{status:Y??`waiting`})]}),(0,S.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,S.jsx)(I,{k:`Priority`,v:String(T.priority??0)}),(0,S.jsx)(I,{k:`Attempts`,v:`${T.attempts??0} / ${T.maxAttempts??`?`}`}),(0,S.jsx)(I,{k:`Progress`,v:`${T.progress??0}%`}),(0,S.jsx)(I,{k:`Created`,v:u(T.createdAt)}),(0,S.jsx)(I,{k:`Started`,v:u(T.startedAt??void 0)}),(0,S.jsx)(I,{k:`Completed`,v:u(T.completedAt??void 0)}),(0,S.jsx)(I,{k:`Duration`,v:m(T.startedAt&&T.completedAt?T.completedAt-T.startedAt:void 0)}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,S.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,S.jsx)(`span`,{className:`truncate font-mono`,children:T.customId??`—`}),T.customId&&(0,S.jsx)(y,{value:T.customId})]})]})]})]}),(0,S.jsxs)(s,{children:[(0,S.jsx)(a,{title:`Data`}),(0,S.jsx)(L,{value:T.data})]}),(0,S.jsx)(j,{data:T.data,busy:U,onSave:e=>J(`Data`,()=>l.updateJobData(T.id,e))}),Y===`completed`&&(0,S.jsxs)(s,{children:[(0,S.jsx)(a,{title:`Result`}),D.fetched&&D.value!==void 0&&D.value!==null?(0,S.jsx)(L,{value:D.value}):(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]}),(X||Z)&&(0,S.jsxs)(s,{children:[(0,S.jsx)(a,{title:`Error`}),X&&(0,S.jsxs)(`div`,{className:`mb-3`,children:[(0,S.jsx)(`p`,{className:`text-sm text-danger`,children:X.message}),(0,S.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[X.attempt==null?``:`Attempt ${X.attempt} · `,u(X.timestamp)]})]}),Z&&(0,S.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-surface-2 p-3 font-mono text-xs text-danger/90`,children:T.stacktrace?.join(`
|
|
2
|
+
`)})]}),(0,S.jsx)(M,{jobId:T.id},`logs-${T.id}`),Q&&(0,S.jsx)(A,{jobId:T.id},`children-${T.id}`),(0,S.jsx)(N,{timeline:T.timeline}),(0,S.jsx)(k,{job:T})]}),(0,S.jsx)(C,{job:T,busy:U,act:J})]}):(0,S.jsx)(g,{title:`No job loaded`,hint:`Enter a job ID above to inspect it.`})]})}function I({k:e,v:t}){return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,S.jsx)(`dd`,{className:`text-fg`,children:t})]})}function L({value:e}){return(0,S.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(e??null,null,2)})}export{F as JobInspector};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{d as t,m as n,t as r}from"./react-vendor-CHIHtdAC.js";import{G as i,K as a,O as o,T as s,b as c,c as l,f as u,g as d,h as f,k as p,l as m,m as h,n as g,o as _,u as v,x as y}from"./index-BFjeS9FG.js";import{a as b,i as x}from"./form-PtDLk33Z.js";var S=e(n(),1),C=r(),w=`__all__`,T=[`all`,`waiting`,`active`,`completed`,`failed`];function E(){let[e]=t(),[n,r]=(0,S.useState)(e.get(`queue`)??w),[E,D]=(0,S.useState)(`all`),[O,k]=(0,S.useState)(``),{data:A}=o(()=>p.queues(500),[]),{data:j}=o(()=>p.overview(),[]),{data:M,error:N,loading:P,refetch:F}=o((0,S.useCallback)(async()=>{let e=n===w?(A?.queues??[]).map(e=>e.name).slice(0,25):[n],t=E===`all`?void 0:[E];return(await Promise.all(e.map(e=>p.jobsList(e,{states:t,limit:40}).then(t=>(t.jobs??[]).map(t=>({...t,queue:t.queue??e}))).catch(()=>[])))).flat().sort((e,t)=>(t.createdAt??0)-(e.createdAt??0))},[n,E,A]),[n,E]),I=(0,S.useMemo)(()=>{let e=M??[],t=O.trim().toLowerCase();return(t?e.filter(e=>e.id.toLowerCase().includes(t)||(e.name??``).toLowerCase().includes(t)):e).slice(0,100)},[M,O]),L=j?.stats,R=L?g(L.totalCompleted,L.totalFailed)??0:0,z=async e=>{if(window.confirm(`Cancel job ${e}?`))try{await p.cancelJob(e),F()}catch{}};return(0,C.jsxs)(`div`,{children:[N&&(0,C.jsx)(y,{onRetry:F}),(0,C.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!0}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,C.jsx)(h,{label:`Total`,value:l((L?.totalCompleted??0)+(L?.totalFailed??0)+(L?.waiting??0)+(L?.active??0)),compact:!0}),(0,C.jsx)(h,{label:`Waiting`,value:l(L?.waiting),tone:`amber`,compact:!0}),(0,C.jsx)(h,{label:`Active`,value:l(L?.active),tone:`blue`,compact:!0}),(0,C.jsx)(h,{label:`Completed`,value:l(L?.totalCompleted),tone:`green`,compact:!0}),(0,C.jsx)(h,{label:`Failed`,value:l(L?.totalFailed),tone:L?.totalFailed?`red`:`default`,compact:!0}),(0,C.jsx)(h,{label:`Error Rate`,value:m(R),tone:R>.05?`red`:`green`,compact:!0})]}),(0,C.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,C.jsx)(`div`,{className:`w-48`,children:(0,C.jsxs)(b,{value:n,onChange:e=>r(e.target.value),children:[(0,C.jsx)(`option`,{value:w,children:`All Queues`}),(A?.queues??[]).map(e=>(0,C.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,C.jsx)(x,{options:T,value:E,onChange:D}),(0,C.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,C.jsx)(i,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,C.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),placeholder:`Search by ID or name…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),P&&!M&&!N?(0,C.jsx)(c,{label:`Loading jobs…`}):(0,C.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,C.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,C.jsx)(`tbody`,{children:I.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:`No jobs found.`})}):I.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:e.id}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name||`unknown`}),(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(d,{status:String(e.state??e.status??`waiting`)})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:v(e.createdAt)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:_(u(e.processedOn,e.finishedOn))}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,C.jsx)(s,{"aria-label":`Cancel job`,onClick:()=>z(e.id),children:(0,C.jsx)(a,{className:`size-3.5`})})})]},`${e.queue}:${e.id}`))})]})})]})}export{E as Jobs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{d as n,m as r,r as i,t as a}from"./react-vendor-CHIHtdAC.js";import{G as o,K as ee,L as s,N as c,O as l,T as u,U as d,V as te,Z as f,a as ne,b as re,c as ie,g as ae,h as p,l as m,m as h,n as oe,o as g,w as _,x as se}from"./index-BFjeS9FG.js";import{a as ce,i as le}from"./form-PtDLk33Z.js";import{t as ue}from"./Pagination-Bj1z6OlD.js";import{t as v}from"./jobActions-CuOdMglt.js";var y=e(r(),1),b=a(),de=[`all`,`waiting`,`active`,`completed`,`failed`],x=25;function S(e=0){return e>=10?{t:`HIGH`,c:`text-warning`}:e>=1?{t:`MEDIUM`,c:`text-blue-400`}:{t:`LOW`,c:`text-faint`}}function C(e){let t=v(e.state);return t.retryActive?f.retryJob(e.id):t.retryDlq?f.retryDlq(e.queue??``,e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not retryable`))}function w(){let[e]=n(),[r,a]=(0,y.useState)(e.get(`queue`)??``),[w,fe]=(0,y.useState)(`all`),[T,pe]=(0,y.useState)(``),[E,D]=(0,y.useState)(0),[O,k]=(0,y.useState)(new Set),[me,A]=(0,y.useState)(new Set),[j,M]=(0,y.useState)(!1),[N,P]=(0,y.useState)(null),{data:F}=l(()=>f.queuesSummary(),[],{intervalMs:3e4}),{data:I}=l(()=>f.overview(),[],{intervalMs:1e4});(0,y.useEffect)(()=>{!r&&F?.length&&a(F[0].name)},[F,r]);let L=`${r}|${w}|${E}`,{data:R,error:z,loading:B,refetch:V}=l((0,y.useCallback)(async()=>{if(!r)return{view:L,jobs:[]};let e=w===`all`?void 0:[w];return{view:L,jobs:((await f.jobsList(r,e,x,E*x)).jobs??[]).map(e=>({...e,queue:e.queue??r}))}},[r,w,E,L]),[r,w,E]),H=R&&R.view===L?R.jobs:null,he=(H?.length??0)===x,U=(0,y.useMemo)(()=>{let e=T.trim().toLowerCase();return e?(H??[]).filter(t=>t.id.toLowerCase().includes(e)):H??[]},[H,T]),W=I?.stats,G=(0,y.useMemo)(()=>(F??[]).reduce((e,t)=>e+(t.counts?.failed??0),0),[F]),K=W?oe(W.completed,G):null,q=e=>W?ie(e):`—`,J=()=>D(0);(0,y.useEffect)(()=>{k(new Set)},[r,w,E]);let ge=e=>k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Y=U.length>0&&U.every(e=>O.has(e.id)),_e=()=>k(()=>Y?new Set:new Set(U.map(e=>e.id))),X=async(e,t,n,r)=>{if(!(r&&!window.confirm(r))){A(t=>new Set(t).add(e.id)),P(null);try{await n(),P({ok:!0,text:`${t} ✓`})}catch(e){P({ok:!1,text:`${t} failed: ${e.message}`})}finally{A(t=>{let n=new Set(t);return n.delete(e.id),n}),V()}}},Z=async(e,t,n)=>{let r=U.filter(e=>O.has(e.id));if(r.length===0||n&&!window.confirm(n(r.length)))return;M(!0),P(null);let i=await Promise.allSettled(r.map(t)),a=i.filter(e=>e.status===`fulfilled`).length,o=i.length-a;P({ok:o===0,text:`${e}: ${a} succeeded${o?`, ${o} not eligible / failed`:``}`}),k(new Set),M(!1),V()},Q=U.filter(e=>O.has(e.id)),$={retry:Q.some(e=>{let t=v(e.state);return t.retryActive||t.retryDlq}),promote:Q.some(e=>v(e.state).promote),requeue:Q.some(e=>v(e.state).requeueCompleted),fail:Q.some(e=>v(e.state).fail),cancel:Q.some(e=>v(e.state).cancel)};return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(p,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!0}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,b.jsx)(h,{label:`Total`,value:q((W?.completed??0)+G+(W?.waiting??0)+(W?.active??0)+(W?.delayed??0)),hint:`all queues`,compact:!0}),(0,b.jsx)(h,{label:`Waiting`,value:q(W?.waiting),tone:`amber`,compact:!0}),(0,b.jsx)(h,{label:`Active`,value:q(W?.active),tone:`blue`,compact:!0}),(0,b.jsx)(h,{label:`Completed`,value:q(W?.completed),tone:`green`,compact:!0}),(0,b.jsx)(h,{label:`Failed`,value:q(G),tone:G?`red`:`default`,compact:!0}),(0,b.jsx)(h,{label:`Error Rate`,value:K==null?`—`:m(K),tone:K==null?`default`:K>.05?`red`:`green`,compact:!0})]}),(0,b.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,b.jsx)(`div`,{className:`w-48`,children:(0,b.jsx)(ce,{value:r,"aria-label":`Queue`,onChange:e=>{a(e.target.value),J()},children:(F??[]).map(e=>(0,b.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,b.jsx)(le,{options:de,value:w,onChange:e=>{fe(e),J()}}),(0,b.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,b.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,b.jsx)(`input`,{value:T,onChange:e=>pe(e.target.value),placeholder:`Filter this page by ID…`,"aria-label":`Filter by job ID`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),O.size>0&&(0,b.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,b.jsxs)(`span`,{className:`mr-1 text-muted`,children:[O.size,` selected`]}),$.retry&&(0,b.jsx)(_,{size:`sm`,disabled:j,onClick:()=>Z(`Retry`,C),children:`Retry selected`}),$.promote&&(0,b.jsx)(_,{size:`sm`,disabled:j,onClick:()=>Z(`Promote`,e=>v(e.state).promote?f.promoteJob(e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not delayed`))),children:`Promote selected`}),$.requeue&&(0,b.jsx)(_,{size:`sm`,disabled:j,onClick:()=>Z(`Requeue`,e=>v(e.state).requeueCompleted?f.retryCompleted(e.queue??``,e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not completed`))),children:`Requeue selected`}),$.fail&&(0,b.jsx)(_,{variant:`warning`,size:`sm`,disabled:j,onClick:()=>Z(`Fail`,e=>v(e.state).fail?f.failJob(e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not active`)),e=>`Force-fail ${e} job(s)?`),children:`Fail selected`}),$.cancel&&(0,b.jsx)(_,{variant:`danger`,size:`sm`,disabled:j,onClick:()=>Z(`Cancel`,e=>v(e.state).cancel?f.cancelJob(e.id):Promise.reject(Error(`"${e.state??`unknown`}" cannot be cancelled`)),e=>`Cancel ${e} job(s)? This cannot be undone.`),children:`Cancel selected`}),!$.retry&&!$.promote&&!$.requeue&&!$.fail&&!$.cancel&&(0,b.jsx)(`span`,{className:`text-xs text-faint`,children:`No actions apply to the selected job states.`})]}),N&&(0,b.jsx)(`div`,{className:t(`mb-3 text-sm`,N.ok?`text-success`:`text-danger`),children:N.text}),z&&(0,b.jsx)(se,{onRetry:V}),B&&!H&&!z?(0,b.jsx)(re,{label:`Loading jobs…`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,b.jsx)(`th`,{className:`w-10 px-5 py-3`,children:(0,b.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:_e,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Priority`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,b.jsx)(`th`,{className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,b.jsx)(`tbody`,{children:U.length===0?(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:T.trim()?`No jobs on this page match your ID filter.`:r?`No jobs found.`:`Select a queue.`})}):U.map(e=>{let n=S(e.priority),r=v(e.state),a=me.has(e.id);return(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`input`,{type:`checkbox`,checked:O.has(e.id),onChange:()=>ge(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,b.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,b.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(ae,{status:String(e.state??`waiting`)})}),(0,b.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.c),children:n.t}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:ne(e.createdAt)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:g(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,b.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,children:(0,b.jsx)(u,{"aria-label":`Inspect job`,children:(0,b.jsx)(s,{className:`size-3.5`})})}),r.promote&&(0,b.jsx)(u,{"aria-label":`Promote job`,disabled:a,onClick:()=>X(e,`Promote`,()=>f.promoteJob(e.id)),children:(0,b.jsx)(te,{className:`size-3.5`})}),(r.retryActive||r.retryDlq)&&(0,b.jsx)(u,{"aria-label":`Retry job`,disabled:a,onClick:()=>X(e,`Retry`,()=>C(e)),children:(0,b.jsx)(d,{className:`size-3.5`})}),r.requeueCompleted&&(0,b.jsx)(u,{"aria-label":`Requeue job`,disabled:a,onClick:()=>X(e,`Requeue`,()=>f.retryCompleted(e.queue??``,e.id)),children:(0,b.jsx)(d,{className:`size-3.5`})}),r.fail&&(0,b.jsx)(u,{"aria-label":`Fail job`,disabled:a,onClick:()=>X(e,`Fail`,()=>f.failJob(e.id),`Force-fail this active job?`),children:(0,b.jsx)(c,{className:`size-3.5`})}),r.cancel&&(0,b.jsx)(u,{"aria-label":`Cancel job`,disabled:a,onClick:()=>X(e,`Cancel`,()=>f.cancelJob(e.id),`Cancel this job?`),children:(0,b.jsx)(ee,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,b.jsx)(ue,{page:E,pageSize:x,hasNext:he,onPageChange:D,label:`jobs`})]})]})}export{w as JobsPro};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{G as r,O as i,c as a,g as o,h as s,k as c,m as l,t as u,u as d,x as f,y as p,z as m}from"./index-BFjeS9FG.js";import{a as h,i as g}from"./form-PtDLk33Z.js";import{t as _}from"./Pagination-Bj1z6OlD.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;function C(){let[e,t]=(0,v.useState)(b),[n,C]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O}=i(()=>c.queues(500),[],{intervalMs:3e4}),{events:k,counters:A,throughput:j,connected:M}=u(e===b?void 0:e),N=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return k.filter(t=>n!==`all`&&t.status!==n?!1:e?(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e):!0)},[k,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let P=Math.max(1,Math.ceil(N.length/S)),F=Math.min(E,P-1);return(0,y.jsxs)(`div`,{children:[!M&&k.length===0&&(0,y.jsx)(f,{}),(0,y.jsx)(s,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:M}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(l,{label:`Total Events`,value:a(A.total),compact:!0}),(0,y.jsx)(l,{label:`Completed`,value:a(A.completed),tone:`green`,compact:!0}),(0,y.jsx)(l,{label:`Failed`,value:a(A.failed),tone:A.failed?`red`:`default`,compact:!0}),(0,y.jsx)(l,{label:`Waiting`,value:a(A.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(l,{label:`Active`,value:a(A.active),tone:`blue`,compact:!0}),(0,y.jsx)(l,{label:`Throughput`,value:`${j.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(h,{value:e,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(g,{options:x,value:n,onChange:C}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),N.length===0?(0,y.jsx)(p,{icon:(0,y.jsx)(m,{}),title:M?`Waiting for activity…`:`Connecting to the event stream…`,hint:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job Name`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:N.slice(F*S,F*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(o,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name||`unknown`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:d(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(_,{page:F,pageSize:S,total:N.length,onPageChange:D,label:`events`})]})}export{C as Logs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{G as r,O as i,Z as a,c as o,g as s,h as c,m as l,t as u,u as d,x as f}from"./index-BFjeS9FG.js";import{a as p,i as m}from"./form-PtDLk33Z.js";import{t as h}from"./Pagination-Bj1z6OlD.js";var g=e(t(),1),_=n(),v=`__all__`,y=[`all`,`waiting`,`active`,`completed`,`failed`],b=10;function x(){let[e,t]=(0,g.useState)(v),[n,x]=(0,g.useState)(`all`),[S,C]=(0,g.useState)(``),[w,T]=(0,g.useState)(0),{data:E,error:D,refetch:O}=i(()=>a.queues(),[],{intervalMs:3e4}),{events:k,counters:A,throughput:j,connected:M}=u(e===v?void 0:e),N=(0,g.useMemo)(()=>{let e=S.trim().toLowerCase();return k.filter(t=>n!==`all`&&t.status!==n?!1:e?(t.jobId??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e):!0)},[k,n,S]);(0,g.useEffect)(()=>T(0),[e,n,S]);let P=w*b,F=N.slice(P,P+b);return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(c,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:M}),D&&(0,_.jsx)(f,{onRetry:O}),(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(l,{label:`Total Events`,value:o(A.total),compact:!0}),(0,_.jsx)(l,{label:`Completed`,value:o(A.completed),tone:`green`,compact:!0}),(0,_.jsx)(l,{label:`Failed`,value:o(A.failed),tone:A.failed?`red`:`default`,compact:!0}),(0,_.jsx)(l,{label:`Waiting`,value:o(A.waiting),tone:`amber`,compact:!0}),(0,_.jsx)(l,{label:`Active`,value:o(A.active),tone:`blue`,compact:!0}),(0,_.jsx)(l,{label:`Throughput`,value:`${j.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,_.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,_.jsx)(`div`,{className:`w-48`,children:(0,_.jsxs)(p,{"aria-label":`Filter by queue`,value:e,onChange:e=>t(e.target.value),children:[(0,_.jsx)(`option`,{value:v,children:`All Queues`}),(E?.queues??[]).map(e=>(0,_.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,_.jsx)(m,{options:y,value:n,onChange:x}),(0,_.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,_.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,_.jsx)(`input`,{"aria-label":`Search by job ID or queue`,value:S,onChange:e=>C(e.target.value),placeholder:`Search by job ID or queue…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,_.jsx)(`tbody`,{children:F.length===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:M?k.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):F.map(e=>(0,_.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsx)(s,{status:e.status})}),(0,_.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:e.event}),(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:d(e.timestamp)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,_.jsx)(h,{page:w,pageSize:b,total:N.length,onPageChange:T,label:`events`})]})}export{x as LogsPro};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-CHIHtdAC.js";import{
|
|
1
|
+
import{t as e}from"./react-vendor-CHIHtdAC.js";import{C as t,S as n,h as r,m as i}from"./index-BFjeS9FG.js";import{t as a}from"./CopyButton-BC6QECSJ.js";var o=e(),s=`{
|
|
2
2
|
"mcpServers": {
|
|
3
3
|
"bunqueue": {
|
|
4
4
|
"command": "bunx",
|
|
@@ -19,4 +19,4 @@ import{t as e}from"./react-vendor-CHIHtdAC.js";import{E as t,T as n,_ as r,v as
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
}`,l=`claude mcp add bunqueue -- bunx --package=bunqueue bunqueue-mcp`,u=[{name:`Jobs`,count:11,examples:[`add_job`,`get_job`,`get_jobs`,`get_job_result`,`wait_for_job`]},{name:`Job management`,count:6,examples:[`cancel_job`,`change_job_priority`,`promote_job`,`update_job_data`]},{name:`Consumption`,count:8,examples:[`pull_job`,`pull_job_batch`,`ack_job`,`fail_job`,`job_heartbeat`]},{name:`Queues`,count:11,examples:[`list_queues`,`pause_queue`,`resume_queue`,`drain_queue`,`obliterate_queue`]},{name:`Dead letter queue`,count:4,examples:[`get_dlq`,`retry_dlq`,`purge_dlq`]},{name:`Cron`,count:4,examples:[`add_cron`,`list_crons`,`get_cron`,`delete_cron`]},{name:`Flows`,count:4,examples:[`add_flow`,`add_flow_chain`,`get_flow`,`get_children_values`]},{name:`Rate limits`,count:4,examples:[`set_rate_limit`,`set_concurrency`,`clear_rate_limit`]},{name:`Webhooks`,count:4,examples:[`add_webhook`,`list_webhooks`,`remove_webhook`,`set_webhook_enabled`]},{name:`Workers`,count:3,examples:[`register_worker`,`list_workers`,`worker_heartbeat`]},{name:`Handlers`,count:3,examples:[`register_handler`,`list_handlers`,`unregister_handler`]},{name:`Monitoring`,count:11,examples:[`get_stats`,`get_queue_stats`,`get_memory_stats`,`get_prometheus_metrics`]}],d=[`bunqueue://queues`,`bunqueue://stats`,`bunqueue://workers`,`bunqueue://crons`,`bunqueue://webhooks`],f=[`bunqueue_debug_queue`,`bunqueue_health_report`,`bunqueue_incident_response`];function p({code:e}){return(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(`div`,{className:`absolute right-2 top-2`,children:(0,o.jsx)(a,{value:e})}),(0,o.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-line bg-surface-2 p-4 pr-12 font-mono text-xs leading-relaxed text-fg`,children:e})]})}function m({children:e}){return(0,o.jsx)(`span`,{className:`rounded-md border border-line bg-surface-2 px-1.5 py-0.5 font-mono text-[11px] text-muted`,children:e})}function h(){return(0,o.jsxs)(`div`,{children:[(0,o.jsx)(
|
|
22
|
+
}`,l=`claude mcp add bunqueue -- bunx --package=bunqueue bunqueue-mcp`,u=[{name:`Jobs`,count:11,examples:[`add_job`,`get_job`,`get_jobs`,`get_job_result`,`wait_for_job`]},{name:`Job management`,count:6,examples:[`cancel_job`,`change_job_priority`,`promote_job`,`update_job_data`]},{name:`Consumption`,count:8,examples:[`pull_job`,`pull_job_batch`,`ack_job`,`fail_job`,`job_heartbeat`]},{name:`Queues`,count:11,examples:[`list_queues`,`pause_queue`,`resume_queue`,`drain_queue`,`obliterate_queue`]},{name:`Dead letter queue`,count:4,examples:[`get_dlq`,`retry_dlq`,`purge_dlq`]},{name:`Cron`,count:4,examples:[`add_cron`,`list_crons`,`get_cron`,`delete_cron`]},{name:`Flows`,count:4,examples:[`add_flow`,`add_flow_chain`,`get_flow`,`get_children_values`]},{name:`Rate limits`,count:4,examples:[`set_rate_limit`,`set_concurrency`,`clear_rate_limit`]},{name:`Webhooks`,count:4,examples:[`add_webhook`,`list_webhooks`,`remove_webhook`,`set_webhook_enabled`]},{name:`Workers`,count:3,examples:[`register_worker`,`list_workers`,`worker_heartbeat`]},{name:`Handlers`,count:3,examples:[`register_handler`,`list_handlers`,`unregister_handler`]},{name:`Monitoring`,count:11,examples:[`get_stats`,`get_queue_stats`,`get_memory_stats`,`get_prometheus_metrics`]}],d=[`bunqueue://queues`,`bunqueue://stats`,`bunqueue://workers`,`bunqueue://crons`,`bunqueue://webhooks`],f=[`bunqueue_debug_queue`,`bunqueue_health_report`,`bunqueue_incident_response`];function p({code:e}){return(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(`div`,{className:`absolute right-2 top-2`,children:(0,o.jsx)(a,{value:e})}),(0,o.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-line bg-surface-2 p-4 pr-12 font-mono text-xs leading-relaxed text-fg`,children:e})]})}function m({children:e}){return(0,o.jsx)(`span`,{className:`rounded-md border border-line bg-surface-2 px-1.5 py-0.5 font-mono text-[11px] text-muted`,children:e})}function h(){return(0,o.jsxs)(`div`,{children:[(0,o.jsx)(r,{title:`MCP Server`,description:`Connect bunqueue to AI agents (Claude Desktop, Claude Code) over the Model Context Protocol.`,actions:(0,o.jsx)(`a`,{href:`https://egeominotti.github.io/bunqueue-dashboard/docs/guide/mcp`,target:`_blank`,rel:`noopener noreferrer`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Docs`})}),(0,o.jsx)(n,{className:`mb-6`,children:(0,o.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted`,children:[`bunqueue ships a Model Context Protocol server,`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`bunqueue-mcp`}),`, that lets an AI agent drive the queue with tools, resources, and prompts. It is a separate`,` `,(0,o.jsx)(`span`,{className:`text-fg`,children:`stdio`}),` process, launched by the MCP client (not by this dashboard, and not part of the HTTP API), so this page is a setup and reference guide rather than a live monitor. It needs the optional peer dependency`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`@modelcontextprotocol/sdk`}),`.`]})}),(0,o.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,o.jsx)(i,{label:`Tools`,value:`73`}),(0,o.jsx)(i,{label:`Categories`,value:`12`}),(0,o.jsx)(i,{label:`Resources`,value:`5`}),(0,o.jsx)(i,{label:`Prompts`,value:`3`})]}),(0,o.jsxs)(`div`,{className:`mb-6 grid gap-4 lg:grid-cols-2`,children:[(0,o.jsxs)(n,{children:[(0,o.jsx)(t,{title:`Embedded mode (default)`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Direct SQLite access, no running server. Point `,(0,o.jsx)(m,{children:`DATA_PATH`}),` at the bunqueue database file. Best for a local agent on the same machine.`]}),(0,o.jsx)(p,{code:s})]}),(0,o.jsxs)(n,{children:[(0,o.jsx)(t,{title:`TCP mode (remote server)`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Connect to a running bunqueue server over its TCP protocol port (`,(0,o.jsx)(m,{children:`6789`}),`, distinct from the HTTP admin API on 6790). Use a `,(0,o.jsx)(m,{children:`BUNQUEUE_TOKEN`}),` if the server has one.`]}),(0,o.jsx)(p,{code:c})]})]}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsx)(t,{title:`Where to put it`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Add the JSON above to your MCP client config (for Claude Desktop, its`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`claude_desktop_config.json`}),`). For Claude Code, register it from the CLI:`]}),(0,o.jsx)(p,{code:l})]}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsx)(t,{title:`Tools`,action:(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:`73 total`})}),(0,o.jsx)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 lg:grid-cols-3`,children:u.map(e=>(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,o.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:e.count})]}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.examples.map(e=>(0,o.jsx)(m,{children:e},e))})]},e.name))}),(0,o.jsxs)(`p`,{className:`mt-4 text-xs text-faint`,children:[`Every tool name is prefixed `,(0,o.jsx)(`span`,{className:`font-mono`,children:`bunqueue_`}),` (examples above drop it). Counts total 73.`]})]}),(0,o.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,o.jsxs)(n,{children:[(0,o.jsx)(t,{title:`Resources`,action:(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:`5`})}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:d.map(e=>(0,o.jsx)(m,{children:e},e))})]}),(0,o.jsxs)(n,{children:[(0,o.jsx)(t,{title:`Prompts`,action:(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:`3`})}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.map(e=>(0,o.jsx)(m,{children:e},e))})]})]})]})}export{h as McpServer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-CHIHtdAC.js";import{C as t,
|
|
1
|
+
import{t as e}from"./react-vendor-CHIHtdAC.js";import{C as t,O as n,S as r,b as i,c as a,h as o,k as s,m as c,r as l,x as u}from"./index-BFjeS9FG.js";var d=e(),f={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function p(){let{data:e,error:p,loading:g,refetch:_}=n(()=>s.overview(),[]);if(g&&!e&&!p)return(0,d.jsx)(i,{label:`Loading metrics…`});let{stats:v,throughput:y,latency:b,memory:x,collections:S}=e??f,C={};for(let[e,t]of Object.entries(b.percentiles??{}))t&&typeof t==`object`&&(C[`${e} p50`]=t.p50,C[`${e} p95`]=t.p95,C[`${e} p99`]=t.p99);return(0,d.jsxs)(`div`,{children:[p&&(0,d.jsx)(u,{onRetry:_}),(0,d.jsx)(o,{title:`Metrics`,description:`Throughput, latency, and resource internals.`,live:!0}),(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,d.jsx)(c,{label:`Pushed /s`,value:y.pushPerSec.toFixed(1),compact:!0}),(0,d.jsx)(c,{label:`Pulled /s`,value:y.pullPerSec.toFixed(1),tone:`blue`,compact:!0}),(0,d.jsx)(c,{label:`Completed /s`,value:y.completePerSec.toFixed(1),tone:`green`,compact:!0}),(0,d.jsx)(c,{label:`Failed /s`,value:y.failPerSec.toFixed(1),tone:`red`,compact:!0})]}),(0,d.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,d.jsxs)(r,{children:[(0,d.jsx)(t,{title:`Totals`}),(0,d.jsx)(m,{rows:[[`Pushed`,a(v.totalPushed)],[`Pulled`,a(v.totalPulled)],[`Completed`,a(v.totalCompleted)],[`Failed`,a(v.totalFailed)]]})]}),(0,d.jsxs)(r,{children:[(0,d.jsx)(t,{title:`Memory`}),(0,d.jsx)(m,{rows:[[`Heap Used`,l(x.heapUsed*1024*1024)],[`Heap Total`,l(x.heapTotal*1024*1024)],[`RSS`,l(x.rss*1024*1024)]]})]}),(0,d.jsxs)(r,{children:[(0,d.jsx)(t,{title:`Latency — percentiles (ms)`}),(0,d.jsx)(h,{record:C,suffix:`ms`})]}),(0,d.jsxs)(r,{children:[(0,d.jsx)(t,{title:`Latency — averages (ms)`}),(0,d.jsx)(h,{record:b.averages,suffix:`ms`})]})]}),(0,d.jsx)(`div`,{className:`mt-6`,children:(0,d.jsxs)(r,{children:[(0,d.jsx)(t,{title:`In-memory collections`}),(0,d.jsx)(h,{record:S})]})})]})}function m({rows:e}){return(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:e.map(([e,t])=>(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,d.jsx)(`div`,{className:`mt-1 text-xl font-semibold tnum text-fg`,children:t})]},e))})}function h({record:e,suffix:t}){let n=Object.entries(e??{});return n.length===0?(0,d.jsx)(`p`,{className:`py-4 text-sm text-faint`,children:`No data.`}):(0,d.jsx)(`dl`,{className:`divide-y divide-line`,children:n.map(([e,n])=>(0,d.jsxs)(`div`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,d.jsx)(`dt`,{className:`font-mono text-xs text-muted`,children:e}),(0,d.jsxs)(`dd`,{className:`tnum font-medium text-fg`,children:[typeof n==`number`?a(Math.round(n*100)/100):String(n),t&&(0,d.jsx)(`span`,{className:`ml-1 text-xs text-faint`,children:t})]})]},e))})}export{p as Metrics};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{m as n,t as r}from"./react-vendor-CHIHtdAC.js";import{C as i,D as a,O as o,S as s,Z as c,b as l,c as u,d,h as f,i as p,l as m,m as h,n as g,x as _}from"./index-BFjeS9FG.js";import{t as v}from"./Pagination-Bj1z6OlD.js";import{t as y}from"./AreaChart-DzUXW8u3.js";var b=e(n(),1);function x(e=60){let[t,n]=(0,b.useState)({push:[],complete:[],fail:[],depth:[]}),[r,i]=(0,b.useState)(null),o=(0,b.useRef)(!0),s=(0,b.useRef)(!1);return(0,b.useEffect)(()=>{o.current=!0;let t=a(()=>typeof document<`u`&&document.hidden),r=async()=>{if(!s.current&&t()){s.current=!0;try{let t=await c.overview();if(!o.current)return;i(t);let r=(t.stats.waiting??0)+(t.stats.active??0)+(t.stats.delayed??0);n(n=>({push:[...n.push,t.throughput.pushPerSec].slice(-e),complete:[...n.complete,t.throughput.completePerSec].slice(-e),fail:[...n.fail,t.throughput.failPerSec].slice(-e),depth:[...n.depth,r].slice(-e)}))}catch{}finally{s.current=!1}}};r();let l=setInterval(r,1e3);return()=>{o.current=!1,clearInterval(l)}},[e]),{...t,latest:r}}function S(e){if(e.length<2)return{slope:0,label:`steady`,draining:!1};let t=e.length,n=(t-1)/2,r=e.reduce((e,t)=>e+t,0)/t,i=0,a=0;for(let o=0;o<t;o++)i+=(o-n)*(e[o]-r),a+=(o-n)**2;let o=a===0?0:i/a,s=o<-.05;return{slope:o,label:s?`draining`:o>.05?`accumulating`:`steady`,draining:s}}var C=r(),w=[`-60s`,`-45s`,`-30s`,`-15s`,`now`],T=15,E=[`push`,`pull`,`ack`],D={stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}}};function O(){let e=x(60),[n,r]=(0,b.useState)(0),{data:a,error:O,loading:M,refetch:N}=o(async()=>({details:await c.queuesSummary()}),[]),P=a?.details??[],F=Math.max(1,Math.ceil(P.length/T)),I=Math.min(n,F-1),L=(0,b.useMemo)(()=>P.slice(I*T,I*T+T),[P,I]),R=(0,b.useMemo)(()=>P.reduce((e,t)=>e+(t.counts?.failed??0),0),[P]);if(M&&!a&&!O)return(0,C.jsx)(l,{label:`Loading metrics…`});let{stats:z,throughput:B,latency:V}=e.latest??D,H=g(z.completed,R),U=S(e.depth),W=e.depth.length?e.depth[e.depth.length-1]:0;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(f,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:!O}),O&&(0,C.jsx)(_,{onRetry:N}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(h,{label:`Total Completed`,value:p(z.completed),tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(h,{label:`Total Failed`,value:u(R),tone:R?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(h,{label:`Push/sec`,value:B.pushPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(h,{label:`Pull/sec`,value:B.pullPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(A,{color:`#ec4899`,label:`Pushed`,value:B.pushPerSec}),(0,C.jsx)(A,{color:`#34d399`,label:`Completed`,value:B.completePerSec}),(0,C.jsx)(A,{color:`#f87171`,label:`Failed`,value:B.failPerSec})]})]}),(0,C.jsx)(y,{xLabels:w,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]})]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Backlog over time (waiting + active + delayed). The trend says whether you're draining or falling behind — more useful than any single gauge.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:u(W)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,U.label===`draining`?`text-success`:U.label===`accumulating`?`text-danger`:`text-faint`),children:U.label===`steady`?`steady`:`${U.slope>0?`+`:``}${U.slope.toFixed(1)}/s · ${U.label}`})]})]}),(0,C.jsx)(y,{xLabels:w,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:U.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]})]}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(i,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,H!=null&&H>.05?`text-danger`:`text-fg`),children:H==null?`—`:m(H)}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:`error rate`})]}),(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,H==null?`text-fg`:`text-success`),children:H==null?`—`:m(1-H)}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:`success rate`})]})]}),H==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-H)*100}%`}})}),(0,C.jsxs)(`div`,{className:`mt-2 flex justify-between font-mono text-[11px] text-faint`,children:[(0,C.jsxs)(`span`,{children:[p(z.completed),` completed`]}),(0,C.jsxs)(`span`,{children:[u(R),` failed`]})]})]}),(0,C.jsxs)(s,{children:[(0,C.jsx)(i,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(j,{color:`bg-blue-400`,label:`Queued`,value:u(z.waiting)}),(0,C.jsx)(j,{color:`bg-accent`,label:`Processing`,value:u(z.active)}),(0,C.jsx)(j,{color:`bg-amber-400`,label:`Delayed`,value:u(z.delayed)}),(0,C.jsx)(j,{color:`bg-red-400`,label:`Dead Letter`,value:u(z.dlq)}),(0,C.jsx)(j,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:p(z.totalPushed)}),(0,C.jsx)(j,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:p(z.totalPulled)}),(0,C.jsx)(j,{color:`bg-emerald-400`,label:`Uptime`,value:d(z.uptime/1e3)})]})]})]}),(0,C.jsxs)(s,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:E.map(e=>{let t=V?.percentiles?.[e],n=V?.averages?.[`${e}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:e}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(t?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(t?.p95)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:k(t?.p99)})]},e)})})]})})]}),(0,C.jsxs)(s,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:L.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:6,className:`px-5 py-12 text-center text-sm text-faint`,children:`No queues yet.`})}):L.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:u(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:u(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:u(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:u(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:I,pageSize:T,total:P.length,onPageChange:r,label:`queues`})})]})]})}function k(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}function A({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}function j({color:e,label:n,value:r}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}export{O as MetricsPro};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./react-vendor-CHIHtdAC.js";import{C as t,F as n,O as r,S as i,b as a,c as o,d as s,h as c,k as l,l as u,m as d,n as f,q as p,r as m,x as h}from"./index-BFjeS9FG.js";var g=e(),_={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function v(){let{data:e,error:v,loading:x,refetch:S}=r(()=>l.overview(),[]);if(x&&!e&&!v)return(0,g.jsx)(a,{label:`Loading overview…`});let{stats:C,throughput:w,memory:T,workers:E,crons:D,storage:O}=e??_,k=f(C.totalCompleted,C.totalFailed)??0;return(0,g.jsxs)(`div`,{children:[v&&(0,g.jsx)(h,{onRetry:S}),(0,g.jsx)(c,{title:`Overview`,description:`Live health and throughput across all queues.`,live:!0}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,g.jsx)(d,{label:`Waiting`,value:o(C.waiting),tone:`amber`}),(0,g.jsx)(d,{label:`Active`,value:o(C.active),tone:`blue`}),(0,g.jsx)(d,{label:`Completed`,value:o(C.totalCompleted),tone:`green`}),(0,g.jsx)(d,{label:`Failed`,value:o(C.totalFailed),tone:`red`}),(0,g.jsx)(d,{label:`DLQ`,value:o(C.dlq),tone:C.dlq>0?`red`:`default`}),(0,g.jsx)(d,{label:`Error Rate`,value:u(k),tone:k>.05?`red`:`green`})]}),(0,g.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsxs)(i,{children:[(0,g.jsx)(t,{title:`Throughput`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,g.jsx)(y,{label:`Pushed`,value:w.pushPerSec,tone:`text-fg`}),(0,g.jsx)(y,{label:`Pulled`,value:w.pullPerSec,tone:`text-blue-400`}),(0,g.jsx)(y,{label:`Completed`,value:w.completePerSec,tone:`text-emerald-400`}),(0,g.jsx)(y,{label:`Failed`,value:w.failPerSec,tone:`text-red-400`})]})]}),(0,g.jsxs)(i,{children:[(0,g.jsx)(t,{title:`Resources`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,g.jsx)(b,{label:`Uptime`,value:s(C.uptime)}),(0,g.jsx)(b,{label:`Heap`,value:m(T.heapUsed*1024*1024)}),(0,g.jsx)(b,{label:`RSS`,value:m(T.rss*1024*1024)}),(0,g.jsx)(b,{label:`Storage`,value:O.diskFull?`Disk full`:`Healthy`,tone:O.diskFull?`text-red-400`:`text-emerald-400`})]})]})]}),(0,g.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsxs)(i,{children:[(0,g.jsx)(t,{title:`Workers`,icon:(0,g.jsx)(p,{className:`size-4 text-faint`}),action:(0,g.jsxs)(`span`,{className:`text-sm text-muted`,children:[(0,g.jsx)(`span`,{className:`font-semibold text-emerald-400`,children:E.active}),` /`,` `,E.total,` active`]})}),E.list.length===0?(0,g.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No workers registered.`}):(0,g.jsx)(`ul`,{className:`divide-y divide-line`,children:E.list.slice(0,6).map(e=>(0,g.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,g.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name||e.id}),(0,g.jsxs)(`span`,{className:`text-xs text-faint`,children:[e.queues.join(`, `)||`—`,` · `,o(e.processedJobs),` done`]})]},e.id))})]}),(0,g.jsxs)(i,{children:[(0,g.jsx)(t,{title:`Cron Jobs`,icon:(0,g.jsx)(n,{className:`size-4 text-faint`}),action:(0,g.jsxs)(`span`,{className:`text-sm text-muted`,children:[D.total,` scheduled`]})}),D.list.length===0?(0,g.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No cron jobs.`}):(0,g.jsx)(`ul`,{className:`divide-y divide-line`,children:D.list.slice(0,6).map(e=>(0,g.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,g.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),(0,g.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)})]},e.name))})]})]})]})}function y({label:e,value:t,tone:n}){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,g.jsxs)(`div`,{className:`mt-1 text-2xl font-semibold tnum ${n}`,children:[t.toFixed(1),(0,g.jsx)(`span`,{className:`ml-0.5 text-sm font-normal text-faint`,children:`/s`})]})]})}function b({label:e,value:t,tone:n=`text-fg`}){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,g.jsx)(`div`,{className:`mt-1 text-base font-semibold ${n}`,children:t})]})}export{v as Overview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{c as r}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{c as r}from"./index-BFjeS9FG.js";var i=e(t(),1),a=n();function o({page:e,pageSize:t,total:n,hasNext:o,onPageChange:s,label:c=`items`,className:l}){let u=n!=null,d=u?Math.max(1,Math.ceil(n/t)):void 0;(0,i.useEffect)(()=>{u&&e>d-1&&s(d-1)},[u,e,d,s]);let f=u?Math.min(e,d-1):e,p=f*t,m=f>0,h=u?f<d-1:!!o;if(u&&n<=t&&f===0)return null;let g=u?n===0?`No ${c}`:`${r(p+1)}–${r(Math.min(p+t,n))} of ${r(n)} ${c}`:`Page ${f+1}`;return(0,a.jsxs)(`div`,{className:`mt-4 flex items-center justify-between text-sm text-faint ${l??``}`,children:[(0,a.jsx)(`span`,{children:g}),(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsx)(`button`,{type:`button`,disabled:!m,onClick:()=>s(f-1),className:`rounded-md px-3 py-1 text-xs hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 disabled:hover:text-faint`,children:`Previous`}),(0,a.jsx)(`span`,{className:`rounded-md bg-accent/15 px-2.5 py-1 text-xs font-medium text-accent tnum`,children:u?`${f+1} / ${d}`:f+1}),(0,a.jsx)(`button`,{type:`button`,disabled:!h,onClick:()=>s(f+1),className:`rounded-md px-3 py-1 text-xs hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 disabled:hover:text-faint`,children:`Next`})]})]})}export{o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{C as r,O as i,S as a,Z as o,_ as s,b as c,c as l,h as u,m as d,w as f,x as p}from"./index-BFjeS9FG.js";import{a as m,n as h,o as g,t as _}from"./form-PtDLk33Z.js";var v=e(t(),1),y=n();function b(e){let[t,n]=(0,v.useState)(e),r=(0,v.useRef)(JSON.stringify(e));return(0,v.useEffect)(()=>{let t=JSON.stringify(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n]}function x(e){let t=String(e).trim();if(t===``)return null;let n=Number(t);return Number.isFinite(n)?n:null}function S({queue:e,config:t,onSaved:n}){let[i,s]=b(t),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1);return(0,y.jsxs)(a,{children:[(0,y.jsx)(r,{title:`Stall detection`}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,y.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,y.jsx)(g,{checked:i.enabled,onChange:e=>s({...i,enabled:e}),label:`enabled`}),(0,y.jsx)(`span`,{className:`text-sm text-muted`,children:`enabled`})]}),(0,y.jsx)(_,{label:`Stall interval (ms)`,children:(0,y.jsx)(h,{type:`number`,value:i.stallInterval,onChange:e=>s({...i,stallInterval:e.target.value})})}),(0,y.jsx)(_,{label:`Max stalls`,children:(0,y.jsx)(h,{type:`number`,value:i.maxStalls,onChange:e=>s({...i,maxStalls:e.target.value})})}),(0,y.jsx)(_,{label:`Grace period (ms)`,children:(0,y.jsx)(h,{type:`number`,value:i.gracePeriod,onChange:e=>s({...i,gracePeriod:e.target.value})})})]}),(0,y.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,y.jsx)(f,{variant:`accent`,size:`sm`,disabled:u,onClick:async()=>{let t=x(i.stallInterval),r=x(i.maxStalls),a=x(i.gracePeriod);if(t==null||r==null||a==null){l(`All numeric fields must be filled in`);return}d(!0),m(!1);try{l(null),await o.setStallConfig(e,{...i,stallInterval:t,maxStalls:r,gracePeriod:a}),n(),m(!0),window.setTimeout(()=>m(!1),2e3)}catch(e){l(e.message)}finally{d(!1)}},children:`Save`}),p&&(0,y.jsx)(`span`,{className:`text-xs text-success`,children:`Saved ✓`}),c&&(0,y.jsx)(`span`,{className:`text-xs text-danger`,children:c})]})]})}function C({queue:e,config:t,onSaved:n}){let[i,s]=b(t),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1);return(0,y.jsxs)(a,{children:[(0,y.jsx)(r,{title:`DLQ policy`}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,y.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,y.jsx)(g,{checked:i.autoRetry,onChange:e=>s({...i,autoRetry:e}),label:`auto-retry`}),(0,y.jsx)(`span`,{className:`text-sm text-muted`,children:`auto-retry`})]}),(0,y.jsx)(_,{label:`Retry interval (ms)`,children:(0,y.jsx)(h,{type:`number`,value:i.autoRetryInterval,onChange:e=>s({...i,autoRetryInterval:e.target.value})})}),(0,y.jsx)(_,{label:`Max auto-retries`,children:(0,y.jsx)(h,{type:`number`,value:i.maxAutoRetries,onChange:e=>s({...i,maxAutoRetries:e.target.value})})}),(0,y.jsx)(_,{label:`Max age (ms)`,children:(0,y.jsx)(h,{type:`number`,value:i.maxAge??``,onChange:e=>s({...i,maxAge:e.target.value})})}),(0,y.jsx)(_,{label:`Max entries`,children:(0,y.jsx)(h,{type:`number`,value:i.maxEntries,onChange:e=>s({...i,maxEntries:e.target.value})})})]}),(0,y.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,y.jsx)(f,{variant:`accent`,size:`sm`,disabled:u,onClick:async()=>{let t=x(i.autoRetryInterval),r=x(i.maxAutoRetries),a=x(i.maxEntries),s=i.maxAge==null?null:x(i.maxAge);if(t==null||r==null||a==null){l(`All numeric fields must be filled in`);return}d(!0),m(!1);try{l(null),await o.setDlqConfig(e,{...i,autoRetryInterval:t,maxAutoRetries:r,maxAge:s,maxEntries:a}),n(),m(!0),window.setTimeout(()=>m(!1),2e3)}catch(e){l(e.message)}finally{d(!1)}},children:`Save`}),p&&(0,y.jsx)(`span`,{className:`text-xs text-success`,children:`Saved ✓`}),c&&(0,y.jsx)(`span`,{className:`text-xs text-danger`,children:c})]})]})}function w({queue:e,paused:t,busy:n,run:i}){let[s,c]=(0,v.useState)(`0`),[l,u]=(0,v.useState)(`1000`),[d,p]=(0,v.useState)(``);return(0,y.jsxs)(a,{className:`mb-6`,children:[(0,y.jsx)(r,{title:`Lifecycle`}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,y.jsx)(f,{variant:`success`,size:`sm`,disabled:n,onClick:()=>i(`Resumed`,()=>o.resume(e)),children:`Resume`}):(0,y.jsx)(f,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>i(`Paused`,()=>o.pause(e)),children:`Pause`}),(0,y.jsx)(f,{size:`sm`,disabled:n,onClick:()=>i(`Drained`,()=>o.drain(e),`Drain waiting jobs from "${e}"?`),children:`Drain`}),(0,y.jsx)(f,{size:`sm`,disabled:n,onClick:()=>i(`Retried completed`,()=>o.retryCompleted(e)),children:`Retry completed`}),(0,y.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,y.jsx)(`div`,{className:`w-24`,children:(0,y.jsx)(_,{label:`Promote N`,children:(0,y.jsx)(h,{type:`number`,value:d,onChange:e=>p(e.target.value),placeholder:`all`})})}),(0,y.jsx)(f,{size:`sm`,disabled:n,onClick:()=>i(`Promoted`,()=>o.promoteJobs(e,d?Number(d):void 0)),children:`Promote delayed`})]}),(0,y.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,y.jsx)(`div`,{className:`w-24`,children:(0,y.jsx)(_,{label:`Grace (ms)`,children:(0,y.jsx)(h,{type:`number`,value:s,onChange:e=>c(e.target.value)})})}),(0,y.jsx)(`div`,{className:`w-24`,children:(0,y.jsx)(_,{label:`Limit`,children:(0,y.jsx)(h,{type:`number`,value:l,onChange:e=>u(e.target.value)})})}),(0,y.jsx)(f,{variant:`danger`,size:`sm`,disabled:n,onClick:()=>i(`Cleaned`,()=>o.clean(e,{grace:Number(s),limit:Number(l)}),`Permanently delete up to ${l} completed/failed jobs older than ${s}ms from "${e}"?`),children:`Clean`})]})]})]})}function T({queue:e,busy:t,run:n}){let[i,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``);return(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,y.jsxs)(a,{children:[(0,y.jsx)(r,{title:`Rate limit`}),(0,y.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,y.jsx)(`div`,{className:`flex-1`,children:(0,y.jsx)(_,{label:`Limit`,children:(0,y.jsx)(h,{type:`number`,value:i,onChange:e=>s(e.target.value),placeholder:`max per window`})})}),(0,y.jsx)(f,{variant:`accent`,size:`sm`,disabled:t||!i,onClick:()=>n(`Rate limit set`,()=>o.setRateLimit(e,Number(i))),children:`Set`}),(0,y.jsx)(f,{size:`sm`,disabled:t,onClick:()=>n(`Rate limit cleared`,()=>o.clearRateLimit(e)),children:`Clear`})]})]}),(0,y.jsxs)(a,{children:[(0,y.jsx)(r,{title:`Concurrency`}),(0,y.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,y.jsx)(`div`,{className:`flex-1`,children:(0,y.jsx)(_,{label:`Concurrency`,children:(0,y.jsx)(h,{type:`number`,value:c,onChange:e=>l(e.target.value),placeholder:`max in-flight`})})}),(0,y.jsx)(f,{variant:`accent`,size:`sm`,disabled:t||!c,onClick:()=>n(`Concurrency set`,()=>o.setConcurrency(e,Number(c))),children:`Set`}),(0,y.jsx)(f,{size:`sm`,disabled:t,onClick:()=>n(`Concurrency cleared`,()=>o.clearConcurrency(e)),children:`Clear`})]})]})]})}var E=[`waiting`,`active`,`completed`,`failed`,`delayed`,`paused`];function D(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(!1),[a,f]=(0,v.useState)(null),{data:h}=i(()=>o.queues(),[],{intervalMs:3e4});(0,v.useEffect)(()=>{!e&&h?.queues?.length&&t(h.queues[0].name)},[h,e]);let{data:g,error:_,loading:b,refetch:x}=i((0,v.useCallback)(async()=>{if(!e)return null;let[t,n,r]=await Promise.all([o.queueDetail(e,!1),o.getStallConfig(e).catch(()=>null),o.getDlqConfig(e).catch(()=>null)]);return{queue:e,detail:t,stall:n?.config??null,dlq:r?.config??null}},[e]),[e]),D=g&&g.queue===e?g:null,O=(e,t,n)=>{n&&!window.confirm(n)||(r(!0),f(null),t().then(t=>{let n=t?.count;f({ok:!0,text:`${e}${n==null?` ✓`:`: ${n}`}`}),x()}).catch(e=>f({ok:!1,text:e.message})).finally(()=>r(!1)))};return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(u,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!0}),(0,y.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-56`,children:(0,y.jsx)(m,{value:e,onChange:e=>t(e.target.value),children:(h?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),D?.detail&&(0,y.jsx)(s,{label:D.detail.paused?`Paused`:`Active`,tone:D.detail.paused?`amber`:`green`}),a&&(0,y.jsx)(`span`,{className:a.ok?`text-xs text-success`:`text-xs text-danger`,children:a.text})]}),_&&(0,y.jsx)(p,{onRetry:x}),b&&!D&&!_?(0,y.jsx)(c,{}):D?.detail?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`mb-6 grid grid-cols-3 gap-3 md:grid-cols-6`,children:E.map(e=>(0,y.jsx)(d,{label:e,value:l(D.detail.counts[e]),compact:!0},e))}),(0,y.jsx)(w,{queue:e,paused:D.detail.paused,busy:n,run:O}),(0,y.jsx)(T,{queue:e,busy:n,run:O}),(0,y.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[D.stall&&(0,y.jsx)(S,{queue:e,config:D.stall,onSaved:()=>f({ok:!0,text:`Stall config saved ✓`})},e),D.dlq&&(0,y.jsx)(C,{queue:e,config:D.dlq,onSaved:()=>f({ok:!0,text:`DLQ config saved ✓`})},e)]})]}):!_&&(0,y.jsx)(`p`,{className:`text-sm text-faint`,children:`Select a queue.`})]})}export{D as QueueControl};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{l as t,m as n,r,t as i,u as a}from"./react-vendor-CHIHtdAC.js";import{A as o,B as s,M as c,O as l,R as u,S as d,T as f,V as p,_ as m,b as h,c as g,f as _,g as v,k as y,l as b,m as x,n as S,o as C,q as w,u as T,w as E,x as D}from"./index-BFjeS9FG.js";import{n as O,t as k}from"./form-PtDLk33Z.js";var A=e(n(),1),j=i();function M({queue:e}){return(0,j.jsxs)(`div`,{className:`mt-8`,children:[(0,j.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,j.jsx)(P,{queue:e}),(0,j.jsx)(F,{queue:e})]})]})}function N(){let[e,t]=(0,A.useState)(!1),[n,r]=(0,A.useState)(null),[i,a]=(0,A.useState)(!1);return{busy:e,error:n,done:i,run:async e=>{t(!0),r(null),a(!1);try{await e(),a(!0),setTimeout(()=>a(!1),2e3)}catch(e){r(e.message)}finally{t(!1)}}}}function P({queue:e}){let[t,n]=(0,A.useState)(``),{busy:r,error:i,done:a,run:o}=N();return(0,j.jsxs)(d,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,j.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate Limit`}),(0,j.jsx)(u,{className:`size-4 text-faint`})]}),(0,j.jsx)(k,{label:`Max jobs / second`,children:(0,j.jsx)(O,{type:`number`,inputMode:`numeric`,placeholder:`100`,value:t,onChange:e=>n(e.target.value)})}),(0,j.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,j.jsx)(E,{variant:`accent`,size:`sm`,disabled:r||!t,onClick:()=>o(()=>y.setRateLimit(e,Number(t))),children:`Set`}),(0,j.jsx)(E,{size:`sm`,disabled:r,onClick:()=>o(()=>y.clearRateLimit(e)),children:`Clear`}),a&&(0,j.jsx)(`span`,{className:`text-xs text-emerald-400`,children:`Saved`}),i&&(0,j.jsx)(`span`,{className:`text-xs text-red-400`,children:i})]})]})}function F({queue:e}){let[t,n]=(0,A.useState)(``),{busy:r,error:i,done:a,run:o}=N();return(0,j.jsxs)(d,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,j.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency`}),(0,j.jsx)(w,{className:`size-4 text-faint`})]}),(0,j.jsx)(k,{label:`Concurrency`,children:(0,j.jsx)(O,{type:`number`,inputMode:`numeric`,placeholder:`5`,value:t,onChange:e=>n(e.target.value)})}),(0,j.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,j.jsx)(E,{variant:`accent`,size:`sm`,disabled:r||!t,onClick:()=>o(()=>y.setConcurrency(e,Number(t))),children:`Set`}),(0,j.jsx)(E,{size:`sm`,disabled:r,onClick:()=>o(()=>y.clearConcurrency(e)),children:`Clear`}),a&&(0,j.jsx)(`span`,{className:`text-xs text-emerald-400`,children:`Saved`}),i&&(0,j.jsx)(`span`,{className:`text-xs text-red-400`,children:i})]})]})}var I=[`active`,`waiting`,`completed`,`failed`,`delayed`,`paused`],L={detail:{ok:!1,name:``,counts:{waiting:0,active:0,completed:0,failed:0,delayed:0,prioritized:0,paused:0},paused:!1,priorityCounts:{},dlqPreview:[],timestamp:0},jobs:[]};function R(){let{name:e=``}=a(),n=t(),[i,u]=(0,A.useState)(null),[d,w]=(0,A.useState)(null),{data:O,error:k,loading:N,refetch:P}=l((0,A.useCallback)(async()=>{let[t,n]=await Promise.all([y.queueDetail(e,!1),y.jobsList(e,{states:I,limit:12})]);return{detail:t,jobs:n.jobs??[]}},[e]),[e]),F=async(e,t,r)=>{if(!(r&&!window.confirm(r))){u(e),w(null);try{if(await t(),e===`obliterate`){n(`/queues`);return}await P()}catch(e){w(e.message)}finally{u(null)}}};if(N&&!O&&!k)return(0,j.jsx)(h,{label:`Loading ${e}…`});let R=O??L,{detail:z}=R,B=z.counts,V=S(B.completed??0,B.failed??0)??0,H=[...R.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,j.jsxs)(`div`,{children:[k&&(0,j.jsx)(D,{onRetry:P}),(0,j.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,j.jsx)(f,{"aria-label":`Back to queues`,onClick:()=>n(`/queues`),children:(0,j.jsx)(c,{className:`size-4`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,j.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,j.jsx)(m,{label:z.paused?`Paused`:`Active`,tone:z.paused?`amber`:`green`}),(0,j.jsx)(m,{label:`Live`,tone:`green`})]})]})]}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[z.paused?(0,j.jsxs)(E,{variant:`success`,size:`sm`,disabled:i!=null,onClick:()=>F(`resume`,()=>y.resume(e)),children:[(0,j.jsx)(p,{className:`size-3.5`}),` Resume`]}):(0,j.jsxs)(E,{variant:`warning`,size:`sm`,disabled:i!=null,onClick:()=>F(`pause`,()=>y.pause(e)),children:[(0,j.jsx)(s,{className:`size-3.5`}),` Pause`]}),(0,j.jsx)(E,{size:`sm`,disabled:i!=null,onClick:()=>F(`drain`,()=>y.drain(e),`Drain all waiting jobs from "${e}"?`),children:`Drain`}),(0,j.jsx)(E,{variant:`danger`,size:`sm`,disabled:i!=null,onClick:()=>F(`obliterate`,()=>y.obliterate(e),`Obliterate "${e}"? This removes the queue and all its jobs.`),children:`Obliterate`})]})]}),d&&(0,j.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-red-400`,children:d}),(0,j.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,j.jsx)(x,{label:`Waiting`,value:g(B.waiting),tone:`amber`}),(0,j.jsx)(x,{label:`Active`,value:g(B.active),tone:`blue`}),(0,j.jsx)(x,{label:`Completed`,value:g(B.completed),tone:`green`}),(0,j.jsx)(x,{label:`Failed`,value:g(B.failed),tone:B.failed?`red`:`default`}),(0,j.jsx)(x,{label:`Delayed`,value:g(B.delayed),tone:`default`}),(0,j.jsx)(x,{label:`Error Rate`,value:b(V),tone:V>.05?`red`:`green`})]}),(0,j.jsxs)(`div`,{className:`mt-8`,children:[(0,j.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,j.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,j.jsxs)(r,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all jobs `,(0,j.jsx)(o,{className:`size-3.5`})]})]}),(0,j.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-line bg-surface`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,j.jsx)(`tbody`,{children:H.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):H.map(e=>(0,j.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.id}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unknown`}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(v,{status:String(e.state??e.status??`waiting`)})}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:C(_(e.startedAt,e.completedAt))}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:T(e.createdAt)})]},e.id))})]})})]}),(0,j.jsx)(M,{queue:e})]})}export{R as QueueDetail};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{l as n,m as r,t as i}from"./react-vendor-CHIHtdAC.js";import{
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{l as n,m as r,t as i}from"./react-vendor-CHIHtdAC.js";import{A as a,G as o,H as s,O as c,b as l,c as u,h as d,k as f,m as p,x as m}from"./index-BFjeS9FG.js";import{t as h}from"./Pagination-Bj1z6OlD.js";var g=e(r(),1),_=i(),v=20,y={ok:!1,queues:[],total:0,limit:v,offset:0,timestamp:0};function b(){let e=n(),[r,i]=(0,g.useState)(``),[b,x]=(0,g.useState)(0),{data:S,error:C,loading:w,refetch:T}=c(()=>f.queues(v,b*v),[b]),E=S??y,D=(0,g.useMemo)(()=>{let e=E.queues,t=r.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)):e},[E,r]);if(w&&!S&&!C)return(0,_.jsx)(l,{label:`Loading queues…`});let O=E.queues.reduce((e,t)=>(e.waiting+=t.waiting,e.active+=t.active,e.delayed+=t.delayed,e.dlq+=t.dlq,e),{waiting:0,active:0,delayed:0,dlq:0});return(0,_.jsxs)(`div`,{children:[C&&(0,_.jsx)(m,{onRetry:T}),(0,_.jsx)(d,{title:`Queues`,description:`${E.total} queues`,live:!0}),(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,_.jsx)(p,{label:`Waiting`,value:u(O.waiting),tone:`amber`,compact:!0}),(0,_.jsx)(p,{label:`Active`,value:u(O.active),tone:`blue`,compact:!0}),(0,_.jsx)(p,{label:`Delayed`,value:u(O.delayed),tone:`default`,compact:!0}),(0,_.jsx)(p,{label:`DLQ`,value:u(O.dlq),tone:O.dlq?`red`:`default`,compact:!0})]}),(0,_.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,_.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,_.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Search queues…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,_.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Delayed`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`DLQ`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,_.jsx)(`th`,{className:`w-10 px-5 py-3`})]})}),(0,_.jsx)(`tbody`,{children:D.length===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:r?`No queues match on this page.`:`No queues yet.`})}):D.map(n=>(0,_.jsxs)(`tr`,{onClick:()=>e(`/queues/${encodeURIComponent(n.name)}`),className:`group cursor-pointer border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(`span`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,_.jsx)(s,{className:`size-4 text-faint`}),n.name]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:u(n.waiting)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:u(n.active)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:u(n.delayed)}),(0,_.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,n.dlq?`text-red-400`:`text-muted`),children:u(n.dlq)}),(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,n.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-emerald-400`),children:[(0,_.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),n.paused?`Paused`:`Active`]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-faint`,children:(0,_.jsx)(a,{className:`size-4 opacity-0 transition-opacity group-hover:opacity-100`})})]},n.name))})]})}),(0,_.jsx)(h,{page:b,pageSize:v,total:E.total,onPageChange:x,label:`queues`})]})}export{b as Queues};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{l as n,m as r,r as i,t as a}from"./react-vendor-CHIHtdAC.js";import{
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{l as n,m as r,r as i,t as a}from"./react-vendor-CHIHtdAC.js";import{A as o,B as s,G as c,H as l,O as u,T as d,V as f,Z as p,b as m,c as h,h as g,m as _,x as v}from"./index-BFjeS9FG.js";import{t as y}from"./Pagination-Bj1z6OlD.js";var b=e(r(),1),x=a(),S=15;function C(){let e=n(),[r,a]=(0,b.useState)(``),[C,w]=(0,b.useState)(0),[T,E]=(0,b.useState)(new Set),[D,O]=(0,b.useState)(null),{data:k,error:A,loading:j,refetch:M}=u(()=>p.queuesSummary(),[]),N=k??[],P=(0,b.useMemo)(()=>{let e=r.trim().toLowerCase();return[...e?N.filter(t=>t.name.toLowerCase().includes(e)):N].sort((e,t)=>e.name.localeCompare(t.name))},[N,r]),F=(0,b.useMemo)(()=>N.reduce((e,t)=>(e.waiting+=t.counts.waiting,e.active+=t.counts.active,e.failed+=t.counts.failed,e.paused+=+!!t.paused,e),{waiting:0,active:0,failed:0,paused:0}),[N]),I=Math.max(1,Math.ceil(P.length/S)),L=Math.min(C,I-1),R=P.slice(L*S,L*S+S),z=async e=>{E(t=>new Set(t).add(e.name)),O(null);try{await(e.paused?p.resume(e.name):p.pause(e.name)),O({ok:!0,text:`${e.name} ${e.paused?`resumed`:`paused`} ✓`})}catch(e){O({ok:!1,text:e.message})}finally{E(t=>{let n=new Set(t);return n.delete(e.name),n}),M()}};return j&&!k&&!A?(0,x.jsx)(m,{label:`Loading queues…`}):(0,x.jsxs)(`div`,{children:[(0,x.jsx)(g,{title:`Queues`,description:`${N.length} queues`,live:!0}),A&&(0,x.jsx)(v,{onRetry:M}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,x.jsx)(_,{label:`Waiting`,value:h(F.waiting),tone:`amber`,compact:!0}),(0,x.jsx)(_,{label:`Active`,value:h(F.active),tone:`blue`,compact:!0}),(0,x.jsx)(_,{label:`Failed`,value:h(F.failed),tone:F.failed?`red`:`default`,compact:!0}),(0,x.jsx)(_,{label:`Paused`,value:h(F.paused),tone:F.paused?`amber`:`default`,compact:!0})]}),(0,x.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,x.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,x.jsx)(`input`,{value:r,onChange:e=>{a(e.target.value),w(0)},placeholder:`Search queues…`,"aria-label":`Filter queues`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),D&&(0,x.jsx)(`div`,{className:t(`mb-3 text-sm`,D.ok?`text-success`:`text-danger`),children:D.text}),(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Delayed`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,x.jsx)(`th`,{className:`w-24 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,x.jsx)(`tbody`,{children:R.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:r?`No queues match your search.`:`No queues yet.`})}):R.map(n=>{let r=T.has(n.name);return(0,x.jsxs)(`tr`,{onClick:()=>e(`/queues/${encodeURIComponent(n.name)}`),className:`group cursor-pointer border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsxs)(i,{to:`/queues/${encodeURIComponent(n.name)}`,onClick:e=>e.stopPropagation(),className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,x.jsx)(l,{className:`size-4 text-faint`}),n.name]})}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:h(n.counts.waiting)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:h(n.counts.active)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:h(n.counts.completed)}),(0,x.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,n.counts.failed?`text-danger`:`text-muted`),children:h(n.counts.failed)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:h(n.counts.delayed)}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,n.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:[(0,x.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),n.paused?`Paused`:`Active`]})}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,x.jsx)(d,{"aria-label":n.paused?`Resume queue`:`Pause queue`,disabled:r,onClick:e=>{e.stopPropagation(),z(n)},children:n.paused?(0,x.jsx)(f,{className:`size-3.5 text-success`}):(0,x.jsx)(s,{className:`size-3.5 text-warning`})}),(0,x.jsx)(o,{className:`size-4 text-faint opacity-0 transition-opacity group-hover:opacity-100`})]})})]},n.name)})})]})}),(0,x.jsx)(y,{page:L,pageSize:S,total:P.length,onPageChange:w,label:`queues`})]})}export{C as QueuesOverview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-CHIHtdAC.js";import{C as t,
|
|
1
|
+
import{t as e}from"./react-vendor-CHIHtdAC.js";import{C as t,O as n,S as r,b as i,h as a,k as o,x as s}from"./index-BFjeS9FG.js";var c=e(),l=[[`S3_BACKUP_ENABLED`,`Set to 1 to enable periodic backups`],[`S3_BUCKET`,`Target bucket name`],[`S3_REGION`,`Bucket region (default us-east-1)`],[`S3_ENDPOINT`,`Custom endpoint (for S3-compatible stores)`],[`S3_ACCESS_KEY_ID`,`Access key`],[`S3_SECRET_ACCESS_KEY`,`Secret key`],[`S3_BACKUP_INTERVAL`,`Interval in ms (default 21600000 = 6h)`],[`S3_BACKUP_RETENTION`,`Backups to keep (default 7)`]];function u(){let{data:e,error:u,loading:d,refetch:f}=n(()=>o.storage(),[]);return(0,c.jsxs)(`div`,{children:[u&&(0,c.jsx)(s,{onRetry:f}),(0,c.jsx)(a,{title:`S3 Backup`,description:`SQLite snapshot backups to object storage.`,live:!0}),(0,c.jsx)(`div`,{className:`mb-6 rounded-lg border border-line bg-surface/60 px-4 py-3 text-sm text-muted`,children:`S3 backup runs on the server and is configured via environment variables — it cannot be toggled from the dashboard. The status below reflects the connected server's storage.`}),(0,c.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,c.jsxs)(r,{children:[(0,c.jsx)(t,{title:`Storage status`}),d&&!e&&!u?(0,c.jsx)(i,{}):(0,c.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,c.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,c.jsx)(`dt`,{className:`text-muted`,children:`Disk`}),(0,c.jsx)(`dd`,{className:e?.status?.diskFull?`font-medium text-red-400`:`font-medium text-emerald-400`,children:e?.status?.diskFull?`Full`:`Healthy`})]}),(0,c.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,c.jsx)(`dt`,{className:`text-muted`,children:`Path`}),(0,c.jsx)(`dd`,{className:`font-mono text-xs text-fg`,children:String(e?.status?.path??`—`)})]})]})]}),(0,c.jsxs)(r,{children:[(0,c.jsx)(t,{title:`Configuration (server env)`}),(0,c.jsx)(`dl`,{className:`divide-y divide-line text-sm`,children:l.map(([e,t])=>(0,c.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-2.5`,children:[(0,c.jsx)(`dt`,{className:`font-mono text-xs text-accent/90`,children:e}),(0,c.jsx)(`dd`,{className:`text-right text-xs text-faint`,children:t})]},e))})]})]})]})}export{u as S3Backup};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{a as r,o as i}from"./connectionStore-CCopJeU7.js";import{S as a,W as o,Z as s,h as c,w as l,y as u}from"./index-BFjeS9FG.js";import{a as d,n as f,r as p,t as m}from"./form-PtDLk33Z.js";var h=e(t(),1);function g(e){return{endpoint:e.endpoint,region:e.region,bucket:e.bucket,schedule:e.schedule,pathPrefix:e.pathPrefix}}var _=i()(r(e=>({endpoint:``,region:`us-east-1`,bucket:``,accessKeyId:``,secretAccessKey:``,schedule:`disabled`,pathPrefix:``,set:t=>e(t)}),{name:`bq-dash-s3`,partialize:g})),v=n();function y(){let e=_(),[t,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(!1),g=e.bucket.trim()!==``;return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(c,{title:`S3 Backup`,description:`Automatic backups to S3-compatible storage.`}),(0,v.jsxs)(`div`,{className:`mb-6 flex items-center justify-between rounded-xl border border-line bg-surface px-5 py-4`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,v.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-surface-2 text-faint`,children:(0,v.jsx)(o,{className:`size-5`})}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`font-semibold text-fg`,children:g?`Backup configured`:`No backup configured`}),(0,v.jsx)(`div`,{className:`text-xs text-faint`,children:g?`Target: ${e.bucket}`:`Set up S3 to protect your queue data`})]})]}),(0,v.jsx)(`span`,{className:g?`rounded-full bg-emerald-500/10 px-3 py-1 text-xs font-medium text-success`:`rounded-full bg-amber-500/10 px-3 py-1 text-xs font-medium text-warning`,children:g?`Ready`:`Configure`})]}),(0,v.jsx)(`div`,{className:`mb-6 rounded-lg border border-line bg-surface/60 px-4 py-2.5 text-xs text-faint`,children:`bunqueue reads S3 backup settings from server environment variables (S3_BUCKET, S3_REGION, …). This form helps you assemble that configuration; it is stored locally in your browser.`}),(0,v.jsxs)(a,{className:`mb-6`,children:[(0,v.jsx)(`h3`,{className:`mb-1 text-base font-semibold text-fg`,children:`Connection Settings`}),(0,v.jsx)(`p`,{className:`mb-4 text-xs text-faint`,children:`Works with AWS S3, Cloudflare R2, MinIO, DigitalOcean Spaces, and any S3-compatible provider.`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,v.jsx)(m,{label:`Endpoint`,children:(0,v.jsx)(f,{value:e.endpoint,onChange:t=>e.set({endpoint:t.target.value}),placeholder:`https://s3.amazonaws.com`})}),(0,v.jsx)(m,{label:`Region`,children:(0,v.jsx)(f,{value:e.region,onChange:t=>e.set({region:t.target.value}),placeholder:`us-east-1`})}),(0,v.jsx)(`div`,{className:`md:col-span-2`,children:(0,v.jsx)(m,{label:`Bucket name`,children:(0,v.jsx)(f,{value:e.bucket,onChange:t=>e.set({bucket:t.target.value}),placeholder:`my-bunqueue-backups`})})}),(0,v.jsx)(m,{label:`Access key ID`,children:(0,v.jsx)(f,{value:e.accessKeyId,onChange:t=>e.set({accessKeyId:t.target.value}),placeholder:`AKIA…`})}),(0,v.jsx)(m,{label:`Secret access key`,children:(0,v.jsx)(f,{type:`password`,value:e.secretAccessKey,onChange:t=>e.set({secretAccessKey:t.target.value}),placeholder:`••••••••••••••••`})}),(0,v.jsx)(`p`,{className:`-mt-2 text-xs text-faint md:col-span-2`,children:`Keys are kept in memory only and cleared on reload.`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(p,{children:`Backup schedule`}),(0,v.jsxs)(d,{value:e.schedule,onChange:t=>e.set({schedule:t.target.value}),className:`mt-1.5`,children:[(0,v.jsx)(`option`,{value:`disabled`,children:`Disabled`}),(0,v.jsx)(`option`,{value:`6h`,children:`Every 6 hours`}),(0,v.jsx)(`option`,{value:`12h`,children:`Every 12 hours`}),(0,v.jsx)(`option`,{value:`24h`,children:`Every 24 hours`})]})]}),(0,v.jsx)(m,{label:`Path prefix (optional)`,children:(0,v.jsx)(f,{value:e.pathPrefix,onChange:t=>e.set({pathPrefix:t.target.value}),placeholder:`backups/production/`})})]}),(0,v.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(l,{variant:`accent`,onClick:()=>{i(!0),setTimeout(()=>i(!1),2e3)},children:`Save Configuration`}),(0,v.jsx)(l,{onClick:async()=>{n(null);try{let e=await s.storage();n({ok:!e.data?.diskFull,msg:e.data?.diskFull?`Server disk is full`:`Server storage reachable`})}catch(e){n({ok:!1,msg:e.message})}},children:`Test Connection`}),(0,v.jsx)(l,{disabled:!0,title:`Trigger a manual backup — requires server-side S3 config`,children:`Backup Now`}),r&&(0,v.jsx)(`span`,{className:`text-xs text-success`,children:`Saved locally (keys excluded)`}),t&&(0,v.jsx)(`span`,{className:t.ok?`text-xs text-success`:`text-xs text-danger`,children:t.msg})]})]}),(0,v.jsxs)(a,{children:[(0,v.jsx)(`h3`,{className:`mb-4 text-base font-semibold text-fg`,children:`Backup History`}),(0,v.jsx)(u,{icon:(0,v.jsx)(o,{}),title:`No backups yet`,hint:`Configure your S3 connection and run a backup to get started.`})]})]})}export{y as S3BackupPro};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{m as n,t as r}from"./react-vendor-CHIHtdAC.js";import{B as i,C as a,G as o,O as s,S as c,U as l,V as u,Z as d,a as f,d as p,h as m,p as h,r as g,u as _,w as v,x as y}from"./index-BFjeS9FG.js";import{i as b,n as x,t as S}from"./form-PtDLk33Z.js";import{t as C}from"./CopyButton-BC6QECSJ.js";var w=e(n(),1),T=r();function E({children:e}){return(0,T.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs text-fg`,children:e})}function D({agentBase:e}){return(0,T.jsx)(c,{children:(0,T.jsxs)(`details`,{className:`group`,children:[(0,T.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2`,children:[(0,T.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:`How server control works`}),(0,T.jsx)(`span`,{className:`text-xs text-muted transition-transform group-open:rotate-90`,children:`▶`})]}),(0,T.jsxs)(`div`,{className:`mt-4 space-y-4 text-sm leading-relaxed text-muted`,children:[(0,T.jsxs)(`p`,{children:[`A browser can't start or stop an OS process, so the dashboard talks to a small local`,` `,(0,T.jsx)(`span`,{className:`font-medium text-fg`,children:`control agent`}),` (`,(0,T.jsx)(E,{children:e}),`) that supervises the bunqueue server process — start, stop and restart — and streams its logs back here.`]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Launch & environment`}),(0,T.jsxs)(`p`,{children:[`The agent runs your `,(0,T.jsx)(`span`,{className:`text-fg`,children:`Command`}),` and injects`,` `,(0,T.jsx)(E,{children:`HTTP_PORT`}),`, `,(0,T.jsx)(E,{children:`TCP_PORT`}),` and `,(0,T.jsx)(E,{children:`BUNQUEUE_DATA_PATH`}),` — plus any `,(0,T.jsx)(`span`,{className:`text-fg`,children:`Environment variables`}),` you add — into its environment. The default `,(0,T.jsx)(E,{children:`bunqueue start`}),` needs a globally-installed binary; pointing the command at a local entry (e.g.`,` `,(0,T.jsx)(E,{children:`bun run /path/to/bunqueue/src/main.ts`}),`) works without one.`]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`When changes apply`}),(0,T.jsxs)(`p`,{children:[`Config is editable any time, but `,(0,T.jsx)(`span`,{className:`text-fg`,children:`Command`}),`, ports and data path only take effect on the `,(0,T.jsx)(`span`,{className:`text-fg`,children:`next start/restart`}),` `,`— the running process keeps the config it launched with until then.`]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Data path`}),(0,T.jsxs)(`p`,{children:[`Relative paths resolve against the `,(0,T.jsx)(`span`,{className:`text-fg`,children:`agent's`}),` working directory. SQLite creates the database `,(0,T.jsx)(`span`,{className:`text-fg`,children:`file`}),` but not its parent `,(0,T.jsx)(`span`,{className:`text-fg`,children:`folder`}),` — if start fails with`,` `,(0,T.jsx)(E,{children:`SQLITE_CANTOPEN`}),`, create the directory first or use a path whose folder already exists.`]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Security`}),(0,T.jsxs)(`p`,{children:[`The agent can spawn processes, so it binds `,(0,T.jsx)(E,{children:`127.0.0.1`}),` only, locks CORS to an allowlist (never `,(0,T.jsx)(E,{children:`*`}),`), rejects any disallowed `,(0,T.jsx)(E,{children:`Origin`}),` or`,` `,(0,T.jsx)(E,{children:`Host`}),` with a `,(0,T.jsx)(E,{children:`403`}),` (the latter blocks DNS-rebinding reads), and honours an optional `,(0,T.jsx)(E,{children:`AGENT_TOKEN`}),` on state-changing requests. Keep its port on loopback.`]}),(0,T.jsxs)(`p`,{children:[`If you started the agent with `,(0,T.jsx)(E,{children:`AGENT_TOKEN`}),`, enter that token under`,` `,(0,T.jsx)(`span`,{className:`text-fg`,children:`Settings → Agent token`}),` (or when the lock screen prompts) so start / stop / restart and config changes are authorized.`]})]})]})]})})}var O=0,k=e=>Object.entries(e).map(([e,t])=>({id:O++,key:e,value:t})),A=e=>{let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return t},j=[`AUTH_TOKENS`,`LOG_LEVEL`,`S3_BACKUP_ENABLED`,`S3_BUCKET`,`METRICS_ENABLED`];function M({value:e,onChange:t,disabled:n}){let[r,i]=(0,w.useState)(()=>k(e)),a=e=>{i(e),t(A(e))},o=(e,t)=>a(r.map(n=>n.id===e?{...n,...t}:n)),s=(e=``)=>a([...r,{id:O++,key:e,value:``}]),c=e=>a(r.filter(t=>t.id!==e)),l=new Set(r.map(e=>e.key.trim()).filter(Boolean)),u=r.map(e=>e.key.trim()).filter((e,t,n)=>e&&n.indexOf(e)!==t);return(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.length===0&&(0,T.jsxs)(`p`,{className:`text-xs leading-relaxed text-faint`,children:[`No custom variables. The agent already injects`,` `,(0,T.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`HTTP_PORT`}),`,`,` `,(0,T.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`TCP_PORT`}),` and`,` `,(0,T.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`BUNQUEUE_DATA_PATH`}),`.`]}),r.map(e=>(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`w-2/5 shrink-0`,children:(0,T.jsx)(x,{className:`font-mono`,placeholder:`KEY`,value:e.key,disabled:n,onChange:t=>o(e.id,{key:t.target.value})})}),(0,T.jsx)(`span`,{className:`text-faint`,children:`=`}),(0,T.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,T.jsx)(x,{className:`font-mono`,placeholder:`value`,value:e.value,disabled:n,onChange:t=>o(e.id,{value:t.target.value})})}),(0,T.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.key||`variable`}`,disabled:n,onClick:()=>c(e.id),className:`shrink-0 rounded-md px-2 py-1 text-xs text-faint transition-colors hover:text-danger disabled:opacity-40`,children:`✕`})]},e.id)),u.length>0&&(0,T.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Duplicate key`,u.length>1?`s`:``,` — the last value wins: `,u.join(`, `)]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,T.jsx)(v,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>s(),children:`+ Add variable`}),j.filter(e=>!l.has(e)).map(e=>(0,T.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>s(e),className:`rounded-md border border-line bg-surface-2 px-2 py-1 font-mono text-[11px] text-muted transition-colors hover:border-line-strong hover:text-fg disabled:opacity-40`,children:[`+ `,e]},e))]})]})}var N=[`all`,`stdout`,`stderr`,`sys`],P=e=>`${new Date(e).toLocaleTimeString([],{hour12:!1})}.${String(e%1e3).padStart(3,`0`)}`,F=e=>e===`stderr`?`text-danger/90`:e===`sys`?`text-accent/80`:`text-muted`;function I(){let{data:e}=R(),n=(0,w.useMemo)(()=>e?.lines??[],[e]),[r,i]=(0,w.useState)(`all`),[a,s]=(0,w.useState)(``),[l,u]=(0,w.useState)(!0),[d,f]=(0,w.useState)(!1),p=(0,w.useRef)(null),m=(0,w.useMemo)(()=>{let e=a.trim().toLowerCase();return n.map(e=>e.line.includes(`\x1B`)?{...e,line:h(e.line)}:e).filter(t=>(r===`all`||t.stream===r)&&(!e||t.line.toLowerCase().includes(e)))},[n,r,a]);(0,w.useEffect)(()=>{if(!l)return;let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[m.length,l]);let g=(0,w.useMemo)(()=>m.map(e=>d?`${P(e.ts)} [${e.stream}] ${e.line}`:e.line).join(`
|
|
2
|
+
`),[m,d]);return(0,T.jsxs)(c,{padded:!1,className:`overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-4 py-3`,children:[(0,T.jsx)(`h3`,{className:`mr-1 text-base font-semibold text-fg`,children:`Process logs`}),(0,T.jsx)(b,{options:N,value:r,onChange:i}),(0,T.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,T.jsx)(o,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,T.jsx)(`input`,{value:a,onChange:e=>s(e.target.value),"aria-label":`Filter log lines`,placeholder:`Filter…`,className:`h-8 w-full rounded-lg border border-line bg-surface-2 pl-8 pr-2 text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,T.jsx)(L,{on:l,onClick:()=>u(e=>!e),label:`Follow`}),(0,T.jsx)(L,{on:d,onClick:()=>f(e=>!e),label:`Times`}),(0,T.jsx)(C,{value:g}),(0,T.jsx)(`button`,{type:`button`,onClick:()=>{let e=new Blob([g],{type:`text/plain`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`bunqueue-logs-${Date.now()}.log`,n.click(),URL.revokeObjectURL(t)},disabled:m.length===0,className:`rounded-md border border-line bg-surface-2 px-2 py-1 text-xs text-muted transition-colors hover:text-fg disabled:opacity-40`,children:`Download`})]}),(0,T.jsx)(`div`,{ref:p,className:`max-h-80 min-h-40 overflow-y-auto p-4 font-mono text-xs leading-relaxed`,children:m.length===0?(0,T.jsx)(`p`,{className:`text-faint`,children:n.length===0?`No output yet.`:`No lines match the current filter.`}):m.map(e=>(0,T.jsxs)(`div`,{className:t(`whitespace-pre-wrap`,F(e.stream)),children:[d&&(0,T.jsx)(`span`,{className:`mr-2 text-faint`,children:P(e.ts)}),e.line]},e.seq))}),(0,T.jsxs)(`div`,{className:`flex items-center justify-between border-t border-line px-4 py-2 text-[11px] text-faint`,children:[(0,T.jsx)(`span`,{children:m.length===n.length?`${n.length} lines`:`${m.length} of ${n.length} lines`}),(0,T.jsx)(`span`,{children:l?`following tail`:`paused`})]})]})}function L({on:e,onClick:n,label:r}){return(0,T.jsx)(`button`,{type:`button`,onClick:n,"aria-pressed":e,className:t(`rounded-md border px-2 py-1 text-xs transition-colors`,e?`border-accent/40 bg-accent/10 text-accent`:`border-line bg-surface-2 text-muted hover:text-fg`),children:r})}function R(){return s(()=>d.control.logs(),[])}var z={running:{label:`Running`,tone:`text-success`,dot:`bg-emerald-400`},starting:{label:`Starting`,tone:`text-warning`,dot:`bg-amber-400`},stopping:{label:`Stopping`,tone:`text-warning`,dot:`bg-amber-400`},stopped:{label:`Stopped`,tone:`text-danger`,dot:`bg-red-400`}};function B({startedAt:e}){let[,t]=(0,w.useState)(0);return(0,w.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,T.jsx)(T.Fragment,{children:p((Date.now()-e)/1e3)})}function V({label:e,children:t,title:n}){return(0,T.jsxs)(`div`,{className:`min-w-0`,title:n,children:[(0,T.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:e}),(0,T.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,children:t})]})}function H({status:e,agentBase:n,transitioning:r,stale:a=!1,vitals:o=null,busy:s,onStart:c,onStop:d,onRestart:p}){let m=e?.status??`stopped`,h=m===`running`,g=z[m]??z.stopped,_=!!e?.healthy&&!a,y=!h&&e?.exitCode!=null&&e.exitCode!==0,b=e?.runningConfig??e?.config??null,x=`http://localhost:${b?.httpPort??6790}`;return(0,T.jsxs)(`section`,{className:`mb-6 overflow-hidden rounded-xl border border-line bg-surface`,children:[(0,T.jsx)(`div`,{className:t(`h-0.5 bg-gradient-to-r to-transparent`,h&&_?`from-emerald-400/80 via-emerald-400/25`:h||r?`from-amber-400/80 via-amber-400/25`:`from-red-400/70 via-red-400/20`)}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-5 p-5 lg:flex-row lg:items-center lg:justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,T.jsxs)(`span`,{className:`relative flex size-3.5 shrink-0`,children:[h&&_&&(0,T.jsx)(`span`,{className:`absolute inline-flex size-full rounded-full bg-emerald-400 opacity-50 motion-safe:animate-ping`}),(0,T.jsx)(`span`,{className:t(`relative inline-flex size-3.5 rounded-full`,g.dot)})]}),(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,T.jsx)(`span`,{className:t(`text-2xl font-bold tracking-tight`,g.tone),children:r&&s?`${s}…`:g.label}),e?.version&&(0,T.jsxs)(`span`,{className:`font-mono text-xs text-muted`,children:[`bunqueue v`,e.version]}),y&&(0,T.jsxs)(`span`,{className:`rounded-full bg-red-500/15 px-2 py-0.5 font-mono text-[11px] font-medium text-danger`,children:[`crashed · exit `,e?.exitCode]})]}),(0,T.jsx)(`div`,{className:`mt-1 font-mono text-xs text-muted`,children:a?(0,T.jsxs)(`span`,{className:`text-warning`,children:[`last known: pid `,e?.pid??`—`,` — agent unreachable, state may have changed`]}):h?(0,T.jsxs)(T.Fragment,{children:[_?`healthy`:`waiting for health…`,` · pid `,e?.pid??`—`,` · up`,` `,e?.startedAt?(0,T.jsx)(B,{startedAt:e.startedAt}):`—`]}):`process not running — start it below or point the dashboard at an external server`})]})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,T.jsxs)(v,{variant:`success`,disabled:h||r||a,onClick:c,children:[(0,T.jsx)(u,{className:`size-4`}),` Start`]}),(0,T.jsxs)(v,{variant:`warning`,disabled:!h||r||a,onClick:d,children:[(0,T.jsx)(i,{className:`size-4`}),` Stop`]}),(0,T.jsxs)(v,{disabled:r||a,onClick:p,children:[(0,T.jsx)(l,{className:`size-4`}),` Restart`]})]})]}),(0,T.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 border-t border-line bg-surface-2/30 px-5 py-4 md:grid-cols-3 xl:grid-cols-7`,children:[(0,T.jsx)(V,{label:`Memory`,children:o?.memory?.rss==null?(0,T.jsx)(`span`,{className:`text-faint`,children:`—`}):(0,T.jsxs)(`span`,{title:`heap ${o.memory.heapUsed??`?`} / ${o.memory.heapTotal??`?`} MB`,children:[o.memory.rss,` MB rss`]})}),(0,T.jsx)(V,{label:`Connections`,children:o?.connections?`${o.connections.tcp??0} tcp · ${o.connections.ws??0} ws · ${o.connections.sse??0} sse`:(0,T.jsx)(`span`,{className:`text-faint`,children:`—`})}),(0,T.jsx)(V,{label:`API endpoint`,title:x,children:h?(0,T.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,T.jsx)(`a`,{href:`${x}/health`,target:`_blank`,rel:`noreferrer`,className:`truncate text-accent hover:underline`,children:x}),(0,T.jsx)(C,{value:x})]}):(0,T.jsx)(`span`,{className:`text-faint`,children:x})}),(0,T.jsx)(V,{label:`Ports`,children:b?`${b.httpPort} http · ${b.tcpPort} tcp`:`—`}),(0,T.jsx)(V,{label:`Started`,children:h&&e?.startedAt?f(e.startedAt):`—`}),(0,T.jsx)(V,{label:`Control agent`,title:n,children:n.replace(/^https?:\/\//,``)}),(0,T.jsx)(V,{label:`Launch command`,title:b?.command,children:b?.command??`—`})]})]})}var U=[{key:`size`,label:`Database`,color:`bg-accent`},{key:`walSize`,label:`WAL`,color:`bg-amber-400`},{key:`shmSize`,label:`SHM`,color:`bg-zinc-500`}];function W({db:e}){let n=e.totalSize||0;return(0,T.jsxs)(c,{children:[(0,T.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,T.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Storage`}),(0,T.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:e.exists?`${g(n)} on disk`:`not created yet`})]}),(0,T.jsxs)(`p`,{className:`mb-4 flex items-center gap-1.5 truncate font-mono text-xs text-faint`,title:e.path,children:[(0,T.jsx)(`span`,{className:`truncate`,children:e.path}),(0,T.jsx)(C,{value:e.path})]}),e.exists&&n>0?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`flex h-2.5 overflow-hidden rounded-full bg-surface-2`,children:U.map(r=>{let i=e[r.key];return i?(0,T.jsx)(`div`,{className:t(`h-full`,r.color),style:{width:`${i/n*100}%`},title:`${r.label}: ${g(i)}`},r.key):null})}),(0,T.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 font-mono text-[11px] text-faint`,children:[U.map(n=>(0,T.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,T.jsx)(`span`,{className:t(`size-2 rounded-full`,n.color)}),n.label,` `,(0,T.jsx)(`span`,{className:`text-fg`,children:g(e[n.key])})]},n.key)),e.mtimeMs?(0,T.jsxs)(`span`,{className:`ml-auto`,children:[`written `,_(e.mtimeMs)]}):null]})]}):(0,T.jsx)(`p`,{className:`rounded-lg border border-dashed border-line px-4 py-6 text-center text-sm text-faint`,children:`The database appears here after the first start — SQLite creates the file at the configured data path.`})]})}function G(){let{data:e,error:t,refetch:n}=s(()=>d.control.status(),[]),[r,i]=(0,w.useState)(null),[o,l]=(0,w.useState)(null),u=e?.status===`running`,{data:f}=s(()=>u?d.health():Promise.resolve(null),[u]),p=u?f??null:null,h=async(e,t,r)=>{if(!(r&&!window.confirm(r))){i(e),l(null);try{await t(),await n()}catch(e){l(e.message)}finally{i(null)}}};if(t&&!e)return(0,T.jsxs)(`div`,{children:[(0,T.jsx)(m,{title:`Server`,description:`Start, stop and restart the bunqueue server.`}),(0,T.jsx)(y,{message:`Control agent unreachable — server lifecycle controls are unavailable.`,onRetry:n}),(0,T.jsxs)(c,{children:[(0,T.jsx)(a,{title:`Control agent not running`}),(0,T.jsxs)(`p`,{className:`text-sm text-muted`,children:[`The local control agent is unreachable at`,` `,(0,T.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:d.agentBase}),`. It manages the bunqueue server process (start / stop / restart). Start it with:`]}),(0,T.jsxs)(`pre`,{className:`mt-3 overflow-x-auto rounded-lg border border-line bg-surface-2 px-3 py-2 text-xs`,children:[`bun start`,` `,`# agent + dashboard together (recommended)`,`
|
|
3
|
+
`,`bun run agent`,` `,`# agent only, if the dashboard is already running`]}),(0,T.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`This page reconnects automatically once the agent is up — no reload needed.`})]})]});let g=e?.status??`stopped`,_=g===`running`,v=g===`starting`||g===`stopping`||r!=null,b=t!=null&&e!=null;return(0,T.jsxs)(`div`,{children:[(0,T.jsx)(m,{title:`Server`,description:`Supervise the bunqueue server process — lifecycle, configuration, storage and logs.`}),o&&(0,T.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-danger`,children:o}),b&&(0,T.jsx)(`div`,{className:`mb-4 rounded-lg border border-amber-500/20 bg-amber-500/5 px-4 py-2 text-sm text-warning`,children:`Control agent unreachable — showing last known state. Lifecycle actions are disabled until it responds again.`}),(0,T.jsx)(H,{status:e,agentBase:d.agentBase,stale:b,vitals:p,transitioning:v,busy:r,onStart:()=>h(`starting`,()=>d.control.start()),onStop:()=>h(`stopping`,()=>d.control.stop(),`Stop the bunqueue server?`),onRestart:()=>h(`restarting`,()=>d.control.restart(),`Restart the bunqueue server?`)}),(0,T.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,T.jsx)(K,{status:e,onSaved:n,running:_,transitioning:v}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[e?.db&&(0,T.jsx)(W,{db:e.db}),(0,T.jsx)(I,{})]})]}),(0,T.jsx)(`div`,{className:`mt-6`,children:(0,T.jsx)(D,{agentBase:d.agentBase})})]})}function K({status:e,onSaved:t,running:n,transitioning:r}){let[i,o]=(0,w.useState)(null),[s,u]=(0,w.useState)(!1),[f,p]=(0,w.useState)(!1),[m,h]=(0,w.useState)(null);(0,w.useEffect)(()=>{e?.config&&!i&&o(e.config)},[e,i]);let g=i??e?.config??null;if(!g)return(0,T.jsx)(c,{children:`Loading…`});let _=e=>o({...g,...e}),y=e?.runningConfig??null,b=(e={})=>JSON.stringify(Object.keys(e).sort().map(t=>[t,e[t]])),C=n&&y!=null&&(y.command!==g.command||y.httpPort!==g.httpPort||y.tcpPort!==g.tcpPort||y.dataPath!==g.dataPath||b(y.extraEnv)!==b(g.extraEnv)),E=r||f,D=()=>{u(!0),setTimeout(()=>u(!1),2e3)},O=()=>{let e=e=>Number.isInteger(e)&&e>=1&&e<=65535;return e(g.httpPort)?e(g.tcpPort)?g.httpPort===g.tcpPort?`HTTP and TCP ports must differ`:null:`TCP port must be an integer between 1 and 65535`:`HTTP port must be an integer between 1 and 65535`};return(0,T.jsxs)(c,{children:[(0,T.jsx)(a,{title:`Configuration`}),(0,T.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:n?`Ports and data path apply on the next restart — edit freely, then restart.`:`Edit and save; the config is used the next time the server starts.`}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,T.jsx)(S,{label:`Command`,hint:`The exact command the agent runs to launch bunqueue. It receives HTTP_PORT, TCP_PORT and BUNQUEUE_DATA_PATH in its environment. The default needs a global 'bunqueue' binary — or point it at a local entry, e.g. bun run /path/to/bunqueue/src/main.ts.`,children:(0,T.jsx)(x,{value:g.command,disabled:E,onChange:e=>_({command:e.target.value}),placeholder:`bunqueue start`})}),(0,T.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,T.jsx)(S,{label:`HTTP port`,hint:`Dashboard API + SSE.`,children:(0,T.jsx)(x,{type:`number`,min:1,max:65535,value:g.httpPort,disabled:E,onChange:e=>_({httpPort:Number(e.target.value)})})}),(0,T.jsx)(S,{label:`TCP port`,hint:`Binary protocol. Must differ from HTTP.`,children:(0,T.jsx)(x,{type:`number`,min:1,max:65535,value:g.tcpPort,disabled:E,onChange:e=>_({tcpPort:Number(e.target.value)})})})]}),(0,T.jsx)(S,{label:`Data path`,hint:`SQLite database file, relative to the agent's working directory. The parent folder must already exist — SQLite creates the file, not the directory.`,children:(0,T.jsx)(x,{value:g.dataPath,disabled:E,onChange:e=>_({dataPath:e.target.value})})}),(0,T.jsx)(S,{label:`Environment variables`,hint:`Injected into the server process on start, on top of the ports + data path. Applies on the next restart.`,children:(0,T.jsx)(M,{value:g.extraEnv??{},onChange:e=>_({extraEnv:e}),disabled:E})}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,T.jsx)(v,{variant:`accent`,size:`sm`,disabled:E,onClick:async()=>{let e=O();if(e){h(e);return}h(null);try{await d.control.setConfig(g),D(),t()}catch(e){h(e.message)}},children:`Save config`}),n&&(0,T.jsxs)(v,{variant:`warning`,size:`sm`,disabled:E,onClick:async()=>{let e=O();if(e){h(e);return}if(window.confirm(`Save configuration and restart the server to apply it?`)){h(null),p(!0);try{await d.control.setConfig(g),await d.control.restart(),D(),t()}catch(e){h(e.message)}finally{p(!1)}}},children:[(0,T.jsx)(l,{className:`size-3.5`}),` Save & restart`]}),C&&!s&&(0,T.jsx)(`span`,{className:`text-xs text-warning`,children:`Restart to apply changes`}),s&&(0,T.jsx)(`span`,{className:`text-xs text-success`,children:`Saved`}),m&&(0,T.jsx)(`span`,{className:`text-xs text-danger`,children:m})]})]})]})}export{G as ServerControl};
|