bunqueue-dashboard 0.0.31 → 0.0.32

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.
Files changed (67) hide show
  1. package/agent/db.ts +163 -22
  2. package/agent/dbQueryWorker.ts +14 -6
  3. package/agent/index.ts +4 -1
  4. package/agent/manager.ts +97 -12
  5. package/agent/server.ts +7 -1
  6. package/dist/.vite/manifest.json +76 -75
  7. package/dist/assets/AddJob-Dvpp--yq.js +3 -0
  8. package/dist/assets/{Alerts-70bxf-PT.js → Alerts-CR9jgCCs.js} +1 -1
  9. package/dist/assets/Benchmark-CkL-Ee-M.js +1 -0
  10. package/dist/assets/BulkAddJobs-wI6cRZnX.js +5 -0
  11. package/dist/assets/{CopilotPanel-DZUGIf1q.js → CopilotPanel-DPZV9opm.js} +3 -3
  12. package/dist/assets/{Cron-ltjSoTjj.js → Cron-gWVkYWad.js} +1 -1
  13. package/dist/assets/CronManager-BvfW219u.js +1 -0
  14. package/dist/assets/Database-D2T_ZIGA.js +3 -0
  15. package/dist/assets/Diagnostics-C2goqq5h.js +1 -0
  16. package/dist/assets/{Dlq-fZAKwQoC.js → Dlq-Q4TmmZrK.js} +1 -1
  17. package/dist/assets/{DlqControl-eTrrQCrn.js → DlqControl-C5BfE7Gq.js} +1 -1
  18. package/dist/assets/{DlqPro-CF79339e.js → DlqPro-ClPNmw-X.js} +1 -1
  19. package/dist/assets/Flows-DbhMbvSG.js +1 -0
  20. package/dist/assets/JobInspector-CO_zKjSX.js +2 -0
  21. package/dist/assets/{Jobs-DEqAc1A5.js → Jobs-D2rDHPM_.js} +1 -1
  22. package/dist/assets/JobsPro-Drdgdj3s.js +1 -0
  23. package/dist/assets/{Logs-DBTukPIX.js → Logs-DjwGuRLi.js} +1 -1
  24. package/dist/assets/{LogsPro-Wl_e6hZM.js → LogsPro-7uTBjPWX.js} +1 -1
  25. package/dist/assets/{McpServer-CnWJsKw7.js → McpServer-DAklQDB5.js} +1 -1
  26. package/dist/assets/{Metrics-DzeIhNL-.js → Metrics-Dup9Zinh.js} +1 -1
  27. package/dist/assets/{MetricsPro-O9eVJSH0.js → MetricsPro-PP3TymeP.js} +1 -1
  28. package/dist/assets/{Overview-Bnu7rWqt.js → Overview-C7RCDE6r.js} +1 -1
  29. package/dist/assets/{Pagination-D4ki-pGz.js → Pagination-B9JDi5MI.js} +1 -1
  30. package/dist/assets/QueueActions-DJTw0h2g.js +1 -0
  31. package/dist/assets/{QueueControl-DKqEXnkM.js → QueueControl-CxKjUjF-.js} +1 -1
  32. package/dist/assets/{QueueDetail-DLRow04B.js → QueueDetail-bf2n-r2h.js} +1 -1
  33. package/dist/assets/{QueueDetailPro-BYmOVd4T.js → QueueDetailPro-C-XLWFBa.js} +1 -1
  34. package/dist/assets/{Queues-CoyjRFN7.js → Queues-CMQW89J9.js} +1 -1
  35. package/dist/assets/{QueuesOverview-BeWdJpKi.js → QueuesOverview-x7-akDzf.js} +1 -1
  36. package/dist/assets/{S3Backup-BaLFgl9d.js → S3Backup-1jAySC9R.js} +1 -1
  37. package/dist/assets/{S3BackupPro-DJB4oWgz.js → S3BackupPro-BG_0OHW7.js} +1 -1
  38. package/dist/assets/{ServerControl-_0lVB33E.js → ServerControl-DohTB--h.js} +3 -3
  39. package/dist/assets/{Settings-zKFJTtnq.js → Settings-CnS5PjNe.js} +1 -1
  40. package/dist/assets/{Usage-CKGkvl0j.js → Usage-C3H0hMSA.js} +1 -1
  41. package/dist/assets/{UsagePro-B-TJ6fp4.js → UsagePro-CdnQkP9o.js} +1 -1
  42. package/dist/assets/Webhooks-CAwVmIEZ.js +1 -0
  43. package/dist/assets/{Workers-jKhhXl3W.js → Workers-lvujKZwF.js} +1 -1
  44. package/dist/assets/{WorkersPro-mvY5VX8I.js → WorkersPro-CIJKl7U1.js} +1 -1
  45. package/dist/assets/{connectionStore-Ci04lJmR.js → connectionStore-DO6xQY7h.js} +1 -1
  46. package/dist/assets/{exportFile-tdUeW5m5.js → exportFile-C7xhE8Yh.js} +1 -1
  47. package/dist/assets/{index-DWV3tgrk.css → index-DcVOpnSj.css} +1 -1
  48. package/dist/assets/index-r1ZMLIZ9.js +8 -0
  49. package/dist/assets/{install-DhTYJCUC.js → install-BIVfix28.js} +1 -1
  50. package/dist/assets/useThroughputSeries-CVKzWzdv.js +1 -0
  51. package/dist/index.html +3 -3
  52. package/package.json +1 -1
  53. package/scripts/embedded.gen.ts +112 -112
  54. package/scripts/serve.ts +299 -98
  55. package/dist/assets/AddJob-CAhdg38n.js +0 -3
  56. package/dist/assets/Benchmark-CFZ3WCvj.js +0 -1
  57. package/dist/assets/BulkAddJobs-BzgzpGg_.js +0 -5
  58. package/dist/assets/CronManager-BcFALDeT.js +0 -1
  59. package/dist/assets/Database-CV2yt5O2.js +0 -3
  60. package/dist/assets/Diagnostics-D-EK4GEi.js +0 -1
  61. package/dist/assets/Flows-Ba8G7mcC.js +0 -1
  62. package/dist/assets/JobInspector--d_8ca9p.js +0 -2
  63. package/dist/assets/JobsPro-BcaokZIf.js +0 -1
  64. package/dist/assets/QueueActions-DHoSkWRz.js +0 -1
  65. package/dist/assets/Webhooks-C3zmvY-_.js +0 -1
  66. package/dist/assets/index-BOcegTHa.js +0 -8
  67. package/dist/assets/useThroughputSeries-Chp5OLx3.js +0 -1
@@ -1 +1 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,r,t as i}from"./react-vendor-BcouBxpZ.js";import{A as a,B as o,F as s,J as c,K as l,O as u,R as d,T as f,a as p,b as m,c as h,h as g,m as _,nt as v,o as y,rt as b,u as x,v as S,w as C,x as w,z as T}from"./index-BOcegTHa.js";import{a as E}from"./form-DGinTEEb.js";import{t as D}from"./Pagination-D4ki-pGz.js";import{t as O}from"./exportFile-tdUeW5m5.js";var k=e(n(),1),A=i(),j=25,M=e=>`${e.job.id}-${e.enteredAt}`;function N(){let[e,t]=(0,k.useState)(``),[n,r]=(0,k.useState)(0),[i,o]=(0,k.useState)(`all`),[s,u]=(0,k.useState)(``),[f,p]=(0,k.useState)(new Set),[y,N]=(0,k.useState)(!1),[F,I]=(0,k.useState)(null),{data:L}=a(()=>v.queues(),[],{intervalMs:3e4});(0,k.useEffect)(()=>{e||!L?.queues?.length||t((L.queues.find(e=>e.dlq>0)??L.queues[0]).name)},[L,e]);let{data:R,error:z,loading:B,refetch:V}=a((0,k.useCallback)(async()=>{if(!e)return{queue:e,page:n,entries:[],total:0,stats:null};let[t,r]=await Promise.all([v.dlq(e,j,n*j),v.dlqStats(e).catch(()=>null)]);return{queue:e,page:n,entries:t.entries??[],total:t.total??0,stats:r?.stats??null}},[e,n]),[e,n]),H=R&&R.queue===e&&R.page===n?R:null;(0,k.useEffect)(()=>{if(!H)return;let e=Math.max(0,Math.ceil((H.total??0)/j)-1);n>e&&r(e)},[H,n]),(0,k.useEffect)(()=>{p(new Set)},[e,n]);let U=async(t,n,r)=>{if(!(r&&!window.confirm(r))){N(!0),I(null);try{let r=(await n())?.count??0,i=`${t} ${h(r)} ${r===1?`entry`:`entries`}`;I({ok:!0,text:i}),b.success(i,e),V()}catch(e){let n=e.message;I({ok:!1,text:n});let r=t===`Purged`?`Purge`:`Retry`;b.error(`${r} failed`,n)}finally{N(!1)}}},W=H?.stats?.byReason??{},G=(0,k.useMemo)(()=>Object.keys(W).filter(e=>W[e]>0),[W]),K=(0,k.useMemo)(()=>[...G].sort((e,t)=>(W[t]??0)-(W[e]??0))[0],[G,W]),q=H?.entries??[],J=(0,k.useMemo)(()=>{let e=q;i!==`all`&&(e=e.filter(e=>e.reason===i));let t=s.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>t.enteredAt-e.enteredAt)},[q,i,s]),Y=i!==`all`||s.trim()!==``,X=(H?.total??0)>j,Z=e=>p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(g,{title:`DLQ Control`,description:`Inspect, triage, and replay one queue's dead-lettered jobs.`,live:!0,actions:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(C,{size:`sm`,disabled:!e||!J.length,onClick:()=>{if(J.length===0){b.info(`Nothing to export`);return}O(`dlq-${e}`,J.map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,attempts:e.job.attempts??e.attempts?.length??``,enteredAt:new Date(e.enteredAt).toISOString()})),[`jobId`,`reason`,`error`,`attempts`,`enteredAt`])},children:[(0,A.jsx)(T,{className:`size-3.5`}),` Export`]}),(0,A.jsxs)(C,{size:`sm`,disabled:!e||y||!H?.total,onClick:()=>U(`Retried`,()=>v.retryDlq(e),`Retry all ${H?.total??0} DLQ entries for "${e}"?`),children:[(0,A.jsx)(l,{className:`size-3.5`}),` Retry all`]}),(0,A.jsx)(C,{variant:`danger`,size:`sm`,disabled:!e||y||!H?.total,onClick:()=>{let t=window.prompt(`Purge all ${H?.total??0} DLQ entries for "${e}"? This cannot be undone.\n\nType the queue name to confirm:`);if(t!=null){if(t.trim()!==e){I({ok:!1,text:`Purge cancelled — queue name did not match.`});return}U(`Purged`,()=>v.purgeDlq(e))}},children:`Purge`})]})}),z&&(0,A.jsx)(w,{onRetry:V}),(0,A.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,A.jsx)(_,{label:`Entries`,value:h(H?.total),tone:H?.total?`red`:`green`,hint:H?.total?K?`top: ${K}`:void 0:`queue is clean`,compact:!0}),(0,A.jsx)(_,{label:`Failure types`,value:H?.stats?h(G.length):`—`,hint:`distinct reasons`,compact:!0}),(0,A.jsx)(_,{label:`Pending retry`,value:H?.stats?h(H.stats.pendingRetry??0):`—`,tone:H?.stats?.pendingRetry?`amber`:`default`,hint:`auto-retry queued`,compact:!0}),(0,A.jsx)(_,{label:`Oldest entry`,value:H?.stats?.oldestEntry?x(H.stats.oldestEntry):`—`,hint:`time in DLQ`,compact:!0})]}),(0,A.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,A.jsx)(`div`,{className:`w-56`,children:(0,A.jsx)(E,{value:e,"aria-label":`Queue`,onChange:e=>{t(e.target.value),r(0),o(`all`),u(``),I(null)},children:(L?.queues??[]).map(e=>(0,A.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,A.jsx)(`div`,{className:`w-44`,children:(0,A.jsxs)(E,{value:i,"aria-label":`Filter by reason`,onChange:e=>o(e.target.value),children:[(0,A.jsx)(`option`,{value:`all`,children:`All reasons`}),G.map(e=>(0,A.jsxs)(`option`,{value:e,children:[e,` (`,W[e],`)`]},e))]})}),(0,A.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,A.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,A.jsx)(`input`,{value:s,onChange:e=>u(e.target.value),placeholder:X?`Filter this page by job ID…`:`Filter by job 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`})]}),F&&(0,A.jsx)(`span`,{role:`status`,className:F.ok?`text-sm text-success`:`text-sm text-danger`,children:F.text})]}),B&&!H&&!z?(0,A.jsx)(m,{label:`Loading DLQ…`}):J.length===0?(0,A.jsx)(S,{icon:(0,A.jsx)(d,{}),title:Y?`No matches`:`Dead letter queue is empty`,hint:Y?X?`No entries on this page match your filter — filters are page-scoped. Try another page or clear them.`:`No entries match your filter. Clear it to see all entries.`:`Failed jobs that exhaust their retries land here.`}):(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,A.jsx)(`th`,{className:`w-8 py-3 pl-4`}),(0,A.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Job ID`}),(0,A.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Reason`}),(0,A.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Error`}),(0,A.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Attempts`}),(0,A.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Entered`}),(0,A.jsx)(`th`,{className:`w-20 px-4 py-3`})]})}),(0,A.jsx)(`tbody`,{children:J.map(t=>{let n=M(t),r=f.has(n),i=t.attempts??[];return(0,A.jsx)(P,{entry:t,isOpen:r,busy:y,onToggle:()=>Z(n),onRetry:()=>U(`Retried`,()=>v.retryDlq(e,t.job.id),`Retry job ${t.job.id.slice(0,8)}… from "${e}"?`),attempts:i},n)})})]})}),H&&(0,A.jsx)(D,{page:n,pageSize:j,total:H.total,onPageChange:r,label:`entries`})]})}function P({entry:e,isOpen:n,busy:i,onToggle:a,onRetry:c,attempts:d}){let m=e;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`tr`,{className:`border-b border-line align-top last:border-0 hover:bg-surface-2/40`,children:[(0,A.jsx)(`td`,{className:`py-3 pl-4`,children:(0,A.jsx)(f,{"aria-label":n?`Collapse details`:`Expand details`,"aria-expanded":n,onClick:a,children:(0,A.jsx)(s,{className:t(`size-3.5 transition-transform`,n&&`rotate-90`)})})}),(0,A.jsx)(`td`,{className:`px-3 py-3`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(r,{to:`/job?id=${encodeURIComponent(m.job.id)}`,className:`max-w-[14rem] truncate font-mono text-xs text-accent hover:underline`,title:m.job.id,children:m.job.id}),(0,A.jsx)(u,{value:m.job.id})]})}),(0,A.jsx)(`td`,{className:`px-3 py-3`,children:(0,A.jsx)(`span`,{className:`inline-block rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:m.reason})}),(0,A.jsx)(`td`,{className:`px-3 py-3`,children:(0,A.jsx)(`span`,{className:`block max-w-md truncate text-xs text-danger/80`,title:m.error??``,children:m.error||`—`})}),(0,A.jsx)(`td`,{className:`px-3 py-3 text-right tnum text-muted`,children:m.job.attempts??d.length}),(0,A.jsx)(`td`,{className:`px-3 py-3 text-right text-faint`,title:p(m.enteredAt),children:x(m.enteredAt)}),(0,A.jsx)(`td`,{className:`px-4 py-3`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,A.jsx)(r,{to:`/job?id=${encodeURIComponent(m.job.id)}`,children:(0,A.jsx)(f,{"aria-label":`Inspect job`,children:(0,A.jsx)(o,{className:`size-3.5`})})}),(0,A.jsx)(f,{"aria-label":`Retry job`,disabled:i,onClick:c,children:(0,A.jsx)(l,{className:`size-3.5`})})]})})]}),n&&(0,A.jsxs)(`tr`,{className:`border-b border-line bg-surface-2/30 last:border-0`,children:[(0,A.jsx)(`td`,{}),(0,A.jsxs)(`td`,{colSpan:6,className:`px-3 pb-4 pt-1`,children:[m.error&&(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Error`}),(0,A.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-lg bg-surface p-3 font-mono text-xs text-danger/90`,children:m.error})]}),(0,A.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Failure history`,typeof m.retryCount==`number`&&m.retryCount>0&&(0,A.jsxs)(`span`,{className:`rounded-full bg-surface px-2 py-0.5 text-[10px] normal-case text-muted`,children:[`retried `,m.retryCount,`×`]})]}),d.length===0?(0,A.jsx)(`p`,{className:`text-xs text-faint`,children:`No per-attempt history recorded.`}):(0,A.jsx)(`ol`,{className:`space-y-1.5`,children:d.map(e=>(0,A.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-0.5 rounded-lg border border-line bg-surface px-3 py-2 text-xs`,children:[(0,A.jsxs)(`span`,{className:`font-medium text-fg`,children:[`Attempt `,e.attempt]}),(0,A.jsx)(`span`,{className:`text-faint`,title:p(e.failedAt),children:x(e.failedAt)}),e.duration!=null&&(0,A.jsx)(`span`,{className:`tnum text-muted`,children:y(e.duration)}),e.reason&&(0,A.jsx)(`span`,{className:`rounded bg-red-500/10 px-1.5 text-danger`,children:e.reason}),e.error&&(0,A.jsx)(`span`,{className:`w-full truncate text-danger/70`,children:e.error})]},`${e.attempt}-${e.failedAt}`))})]})]})]})}export{N as DlqControl};
1
+ import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,r,t as i}from"./react-vendor-BcouBxpZ.js";import{A as a,B as o,F as s,J as c,K as l,O as u,R as d,T as f,a as p,b as m,c as h,h as g,m as _,nt as v,o as y,rt as b,u as x,v as S,w as C,x as w,z as T}from"./index-r1ZMLIZ9.js";import{a as E}from"./form-DGinTEEb.js";import{t as D}from"./Pagination-B9JDi5MI.js";import{t as O}from"./exportFile-C7xhE8Yh.js";var k=e(n(),1),A=i(),j=25,M=e=>`${e.job.id}-${e.enteredAt}`;function N(){let[e,t]=(0,k.useState)(``),[n,r]=(0,k.useState)(0),[i,o]=(0,k.useState)(`all`),[s,u]=(0,k.useState)(``),[f,p]=(0,k.useState)(new Set),[y,N]=(0,k.useState)(!1),[F,I]=(0,k.useState)(null),{data:L}=a(()=>v.queues(),[],{intervalMs:3e4});(0,k.useEffect)(()=>{e||!L?.queues?.length||t((L.queues.find(e=>e.dlq>0)??L.queues[0]).name)},[L,e]);let{data:R,error:z,loading:B,refetch:V}=a((0,k.useCallback)(async()=>{if(!e)return{queue:e,page:n,entries:[],total:0,stats:null};let[t,r]=await Promise.all([v.dlq(e,j,n*j),v.dlqStats(e).catch(()=>null)]);return{queue:e,page:n,entries:t.entries??[],total:t.total??0,stats:r?.stats??null}},[e,n]),[e,n]),H=R&&R.queue===e&&R.page===n?R:null;(0,k.useEffect)(()=>{if(!H)return;let e=Math.max(0,Math.ceil((H.total??0)/j)-1);n>e&&r(e)},[H,n]),(0,k.useEffect)(()=>{p(new Set)},[e,n]);let U=async(t,n,r)=>{if(!(r&&!window.confirm(r))){N(!0),I(null);try{let r=(await n())?.count??0,i=`${t} ${h(r)} ${r===1?`entry`:`entries`}`;I({ok:!0,text:i}),b.success(i,e),V()}catch(e){let n=e.message;I({ok:!1,text:n});let r=t===`Purged`?`Purge`:`Retry`;b.error(`${r} failed`,n)}finally{N(!1)}}},W=H?.stats?.byReason??{},G=(0,k.useMemo)(()=>Object.keys(W).filter(e=>W[e]>0),[W]),K=(0,k.useMemo)(()=>[...G].sort((e,t)=>(W[t]??0)-(W[e]??0))[0],[G,W]),q=H?.entries??[],J=(0,k.useMemo)(()=>{let e=q;i!==`all`&&(e=e.filter(e=>e.reason===i));let t=s.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>t.enteredAt-e.enteredAt)},[q,i,s]),Y=i!==`all`||s.trim()!==``,X=(H?.total??0)>j,Z=e=>p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(g,{title:`DLQ Control`,description:`Inspect, triage, and replay one queue's dead-lettered jobs.`,live:!0,actions:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(C,{size:`sm`,disabled:!e||!J.length,onClick:()=>{if(J.length===0){b.info(`Nothing to export`);return}O(`dlq-${e}`,J.map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,attempts:e.job.attempts??e.attempts?.length??``,enteredAt:new Date(e.enteredAt).toISOString()})),[`jobId`,`reason`,`error`,`attempts`,`enteredAt`])},children:[(0,A.jsx)(T,{className:`size-3.5`}),` Export`]}),(0,A.jsxs)(C,{size:`sm`,disabled:!e||y||!H?.total,onClick:()=>U(`Retried`,()=>v.retryDlq(e),`Retry all ${H?.total??0} DLQ entries for "${e}"?`),children:[(0,A.jsx)(l,{className:`size-3.5`}),` Retry all`]}),(0,A.jsx)(C,{variant:`danger`,size:`sm`,disabled:!e||y||!H?.total,onClick:()=>{let t=window.prompt(`Purge all ${H?.total??0} DLQ entries for "${e}"? This cannot be undone.\n\nType the queue name to confirm:`);if(t!=null){if(t.trim()!==e){I({ok:!1,text:`Purge cancelled — queue name did not match.`});return}U(`Purged`,()=>v.purgeDlq(e))}},children:`Purge`})]})}),z&&(0,A.jsx)(w,{onRetry:V}),(0,A.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,A.jsx)(_,{label:`Entries`,value:h(H?.total),tone:H?.total?`red`:`green`,hint:H?.total?K?`top: ${K}`:void 0:`queue is clean`,compact:!0}),(0,A.jsx)(_,{label:`Failure types`,value:H?.stats?h(G.length):`—`,hint:`distinct reasons`,compact:!0}),(0,A.jsx)(_,{label:`Pending retry`,value:H?.stats?h(H.stats.pendingRetry??0):`—`,tone:H?.stats?.pendingRetry?`amber`:`default`,hint:`auto-retry queued`,compact:!0}),(0,A.jsx)(_,{label:`Oldest entry`,value:H?.stats?.oldestEntry?x(H.stats.oldestEntry):`—`,hint:`time in DLQ`,compact:!0})]}),(0,A.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,A.jsx)(`div`,{className:`w-56`,children:(0,A.jsx)(E,{value:e,"aria-label":`Queue`,onChange:e=>{t(e.target.value),r(0),o(`all`),u(``),I(null)},children:(L?.queues??[]).map(e=>(0,A.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,A.jsx)(`div`,{className:`w-44`,children:(0,A.jsxs)(E,{value:i,"aria-label":`Filter by reason`,onChange:e=>o(e.target.value),children:[(0,A.jsx)(`option`,{value:`all`,children:`All reasons`}),G.map(e=>(0,A.jsxs)(`option`,{value:e,children:[e,` (`,W[e],`)`]},e))]})}),(0,A.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,A.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,A.jsx)(`input`,{value:s,onChange:e=>u(e.target.value),placeholder:X?`Filter this page by job ID…`:`Filter by job 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`})]}),F&&(0,A.jsx)(`span`,{role:`status`,className:F.ok?`text-sm text-success`:`text-sm text-danger`,children:F.text})]}),B&&!H&&!z?(0,A.jsx)(m,{label:`Loading DLQ…`}):J.length===0?(0,A.jsx)(S,{icon:(0,A.jsx)(d,{}),title:Y?`No matches`:`Dead letter queue is empty`,hint:Y?X?`No entries on this page match your filter — filters are page-scoped. Try another page or clear them.`:`No entries match your filter. Clear it to see all entries.`:`Failed jobs that exhaust their retries land here.`}):(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,A.jsx)(`th`,{className:`w-8 py-3 pl-4`}),(0,A.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Job ID`}),(0,A.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Reason`}),(0,A.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Error`}),(0,A.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Attempts`}),(0,A.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Entered`}),(0,A.jsx)(`th`,{className:`w-20 px-4 py-3`})]})}),(0,A.jsx)(`tbody`,{children:J.map(t=>{let n=M(t),r=f.has(n),i=t.attempts??[];return(0,A.jsx)(P,{entry:t,isOpen:r,busy:y,onToggle:()=>Z(n),onRetry:()=>U(`Retried`,()=>v.retryDlq(e,t.job.id),`Retry job ${t.job.id.slice(0,8)}… from "${e}"?`),attempts:i},n)})})]})}),H&&(0,A.jsx)(D,{page:n,pageSize:j,total:H.total,onPageChange:r,label:`entries`})]})}function P({entry:e,isOpen:n,busy:i,onToggle:a,onRetry:c,attempts:d}){let m=e;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`tr`,{className:`border-b border-line align-top last:border-0 hover:bg-surface-2/40`,children:[(0,A.jsx)(`td`,{className:`py-3 pl-4`,children:(0,A.jsx)(f,{"aria-label":n?`Collapse details`:`Expand details`,"aria-expanded":n,onClick:a,children:(0,A.jsx)(s,{className:t(`size-3.5 transition-transform`,n&&`rotate-90`)})})}),(0,A.jsx)(`td`,{className:`px-3 py-3`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(r,{to:`/job?id=${encodeURIComponent(m.job.id)}`,className:`max-w-[14rem] truncate font-mono text-xs text-accent hover:underline`,title:m.job.id,children:m.job.id}),(0,A.jsx)(u,{value:m.job.id})]})}),(0,A.jsx)(`td`,{className:`px-3 py-3`,children:(0,A.jsx)(`span`,{className:`inline-block rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:m.reason})}),(0,A.jsx)(`td`,{className:`px-3 py-3`,children:(0,A.jsx)(`span`,{className:`block max-w-md truncate text-xs text-danger/80`,title:m.error??``,children:m.error||`—`})}),(0,A.jsx)(`td`,{className:`px-3 py-3 text-right tnum text-muted`,children:m.job.attempts??d.length}),(0,A.jsx)(`td`,{className:`px-3 py-3 text-right text-faint`,title:p(m.enteredAt),children:x(m.enteredAt)}),(0,A.jsx)(`td`,{className:`px-4 py-3`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,A.jsx)(r,{to:`/job?id=${encodeURIComponent(m.job.id)}`,children:(0,A.jsx)(f,{"aria-label":`Inspect job`,children:(0,A.jsx)(o,{className:`size-3.5`})})}),(0,A.jsx)(f,{"aria-label":`Retry job`,disabled:i,onClick:c,children:(0,A.jsx)(l,{className:`size-3.5`})})]})})]}),n&&(0,A.jsxs)(`tr`,{className:`border-b border-line bg-surface-2/30 last:border-0`,children:[(0,A.jsx)(`td`,{}),(0,A.jsxs)(`td`,{colSpan:6,className:`px-3 pb-4 pt-1`,children:[m.error&&(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Error`}),(0,A.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-lg bg-surface p-3 font-mono text-xs text-danger/90`,children:m.error})]}),(0,A.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Failure history`,typeof m.retryCount==`number`&&m.retryCount>0&&(0,A.jsxs)(`span`,{className:`rounded-full bg-surface px-2 py-0.5 text-[10px] normal-case text-muted`,children:[`retried `,m.retryCount,`×`]})]}),d.length===0?(0,A.jsx)(`p`,{className:`text-xs text-faint`,children:`No per-attempt history recorded.`}):(0,A.jsx)(`ol`,{className:`space-y-1.5`,children:d.map(e=>(0,A.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-0.5 rounded-lg border border-line bg-surface px-3 py-2 text-xs`,children:[(0,A.jsxs)(`span`,{className:`font-medium text-fg`,children:[`Attempt `,e.attempt]}),(0,A.jsx)(`span`,{className:`text-faint`,title:p(e.failedAt),children:x(e.failedAt)}),e.duration!=null&&(0,A.jsx)(`span`,{className:`tnum text-muted`,children:y(e.duration)}),e.reason&&(0,A.jsx)(`span`,{className:`rounded bg-red-500/10 px-1.5 text-danger`,children:e.reason}),e.error&&(0,A.jsx)(`span`,{className:`w-full truncate text-danger/70`,children:e.error})]},`${e.attempt}-${e.failedAt}`))})]})]})]})}export{N as DlqControl};
@@ -1 +1 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-BcouBxpZ.js";import{A as o,K as s,R as c,S as l,T as u,b as ee,c as d,h as te,nt as f,rt as p,u as ne,v as m,w as h,x as re,z as g}from"./index-BOcegTHa.js";import{a as _}from"./form-DGinTEEb.js";import{t as ie}from"./Pagination-D4ki-pGz.js";import{t as v}from"./exportFile-tdUeW5m5.js";import{t as ae}from"./promisePool-Daxkc1OB.js";var y=e(r(),1),b=a(),oe=6,x=25;function S(){let[e,r]=n(),[a,S]=(0,y.useState)(``),[C,w]=(0,y.useState)(`all`),[T,E]=(0,y.useState)(`newest`),[D,se]=(0,y.useState)(``),[O,k]=(0,y.useState)(0),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(null),[P,ce]=(0,y.useState)(new Set),{data:le,refetch:F}=o(()=>f.queues(),[],{intervalMs:1e4}),I=le?.queues??[],L=I.reduce((e,t)=>e+t.dlq,0),{data:R,error:z,loading:ue,refetch:B}=o((0,y.useCallback)(async()=>{if(!a)return{queue:a,page:O,entries:[],entriesTotal:0,stats:null};let[e,t]=await Promise.all([f.dlq(a,x,O*x),f.dlqStats(a).catch(()=>null)]);return{queue:a,page:O,entries:e.entries??[],entriesTotal:e.total??0,stats:t?.stats??null}},[a,O]),[a,O]),V=R&&R.queue===a&&R.page===O?R:null;(0,y.useEffect)(()=>{if(!V)return;let e=V.entriesTotal??0;O>0&&O*x>=e&&k(Math.max(0,Math.ceil(e/x)-1))},[V,O]);let H=async(e,t,n)=>{if(window.confirm(e)){j(!0),N(null);try{let e=(await n())?.count??0,r=`${t} ${d(e)} ${e===1?`entry`:`entries`}`;N({ok:!0,text:r}),p.success(r),B(),F()}catch(e){N({ok:!1,text:e.message}),p.error(`${t} failed`,e.message)}finally{j(!1)}}},U=async e=>{let t=q.map(e=>e.name);if(t.length===0||!window.confirm(`${e} the dead letter queue across ${t.length} queue(s) (${d(L)} entries)?`))return;j(!0),N(null);let n=await ae(t,oe,t=>e===`Retry`?f.retryDlq(t):f.purgeDlq(t)),r=0,i=0;for(let e of n)e.status===`fulfilled`?r+=e.value?.count??0:i++;let a=`${e===`Retry`?`Retried`:`Purged`} ${d(r)} across ${t.length-i}/${t.length} queues${i?`, ${i} failed`:``}`;N({ok:i===0,text:a}),i===0?p.success(a):p.error(a),B(),F(),j(!1)},de=()=>{let e=(V?.entries??[]).map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,enteredAt:new Date(e.enteredAt).toISOString(),attempts:e.attempts?.length??0}));if(e.length===0){p.info(`Nothing to export on this page`);return}v(`dlq-${a}`,e,[`jobId`,`reason`,`error`,`enteredAt`,`attempts`])},W=e=>{J.current=!0,S(e),k(0),w(`all`),r(e?{queue:e}:{},{replace:!0})},G=V?.stats?.byReason??{},K=Object.keys(G).filter(e=>G[e]>0),fe=[...K].sort((e,t)=>(G[t]??0)-(G[e]??0))[0],q=(0,y.useMemo)(()=>I.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[I]),J=(0,y.useRef)(!1),Y=e.get(`queue`);(0,y.useEffect)(()=>{if(!(J.current||a)){if(Y){if(I.some(e=>e.name===Y)){J.current=!0,S(Y),k(0),w(`all`);return}if(I.length===0)return}q.length!==0&&(J.current=!0,S(q[0].name),k(0),w(`all`))}},[a,I,q,Y]);let X=(0,y.useMemo)(()=>{let e=V?.entries??[];C!==`all`&&(e=e.filter(e=>e.reason===C));let t=D.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>T===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[V,C,D,T]),Z=L===0,Q=C!==`all`||D.trim()!==``,$=(V?.entriesTotal??0)>x;return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(te,{title:`Dead Letter Queue`,description:`Jobs that failed after exhausting all retries. Monitor, retry, or purge.`,live:!0}),z&&(0,b.jsx)(re,{onRetry:B}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,b.jsxs)(l,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,b.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,b.jsx)(`div`,{className:t(`mt-2 text-3xl font-bold tnum`,Z?`text-success`:`text-danger`),children:d(L)})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,b.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:a?fe??`No failures`:`Select a queue`})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,b.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:V?.stats?d(V.stats.pendingRetry??0):`—`}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:a?`in this queue`:`awaiting retry`})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,b.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:V?.stats?d(K.length):`—`}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]}),q.length>0&&(0,b.jsxs)(l,{className:`mb-6`,children:[(0,b.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(h,{size:`sm`,disabled:A,onClick:()=>U(`Retry`),children:[(0,b.jsx)(s,{className:`size-3.5`}),` Retry all (`,q.length,` queues)`]}),(0,b.jsxs)(h,{variant:`danger`,size:`sm`,disabled:A,onClick:()=>U(`Purge`),children:[`Purge all (`,q.length,` queues)`]})]})]}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:q.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>W(e.name),className:t(`rounded-lg border p-3 text-left transition-colors`,a===e.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,b.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:e.name}),(0,b.jsx)(`div`,{className:`mt-1 text-xl font-bold tnum text-danger`,children:e.dlq})]},e.name))})]}),(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.jsxs)(_,{value:a,onChange:e=>W(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`Select a queue…`}),I.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,b.jsx)(`div`,{className:`w-40`,children:(0,b.jsxs)(_,{value:C,onChange:e=>w(e.target.value),"aria-label":`Filter by reason`,children:[(0,b.jsx)(`option`,{value:`all`,children:`All Reasons`}),K.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]})}),(0,b.jsx)(`div`,{className:`w-36`,children:(0,b.jsxs)(_,{value:T,onChange:e=>E(e.target.value),"aria-label":$?`Sort this page`:`Sort`,children:[(0,b.jsxs)(`option`,{value:`newest`,children:[`Newest First`,$?` (this page)`:``]}),(0,b.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,$?` (this page)`:``]})]})}),(0,b.jsx)(`input`,{value:D,onChange:e=>se(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,b.jsxs)(h,{size:`sm`,disabled:!a||A,onClick:()=>H(`Retry all for "${a}"?`,`Retried`,()=>f.retryDlq(a)),children:[(0,b.jsx)(s,{className:`size-3.5`}),` Retry All`]}),(0,b.jsx)(h,{variant:`danger`,size:`sm`,disabled:!a||A,onClick:()=>H(`Purge all for "${a}"?`,`Purged`,()=>f.purgeDlq(a)),children:`Purge All`}),(0,b.jsx)(u,{"aria-label":`Export this page to CSV`,title:`Export this page to CSV`,disabled:!a,onClick:de,children:(0,b.jsx)(g,{className:`size-3.5`})})]}),M&&(0,b.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),ue&&!V&&!z?(0,b.jsx)(ee,{label:`Loading DLQ…`}):a?X.length===0?(0,b.jsx)(m,{icon:(0,b.jsx)(c,{}),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,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`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Reason`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Error`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,b.jsx)(`th`,{scope:`col`,className:`w-16 px-5 py-3`})]})}),(0,b.jsx)(`tbody`,{children:X.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(i,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.job.id})}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,b.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:e.error?(0,b.jsx)(`button`,{type:`button`,title:e.error,onClick:()=>ce(t=>{let n=new Set(t),r=`${e.job.id}-${e.enteredAt}`;return n.has(r)?n.delete(r):n.add(r),n}),className:t(`block w-full break-words text-left`,!P.has(`${e.job.id}-${e.enteredAt}`)&&`line-clamp-2`),children:e.error}):`—`}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:ne(e.enteredAt)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,b.jsx)(u,{"aria-label":`Retry`,disabled:A,onClick:()=>H(`Retry job ${e.job.id.slice(0,8)}… from "${a}"?`,`Retried`,()=>f.retryDlq(a,e.job.id)),children:(0,b.jsx)(s,{className:`size-3.5`})})})]},`${e.job.id}-${e.enteredAt}`))})]})}):(0,b.jsx)(m,{icon:(0,b.jsx)(c,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),a&&V&&(0,b.jsx)(ie,{page:O,pageSize:x,total:V.entriesTotal,onPageChange:k,label:`entries`})]})}export{S as DlqPro};
1
+ import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-BcouBxpZ.js";import{A as o,K as s,R as c,S as l,T as u,b as ee,c as d,h as te,nt as f,rt as p,u as ne,v as m,w as h,x as re,z as g}from"./index-r1ZMLIZ9.js";import{a as _}from"./form-DGinTEEb.js";import{t as ie}from"./Pagination-B9JDi5MI.js";import{t as v}from"./exportFile-C7xhE8Yh.js";import{t as ae}from"./promisePool-Daxkc1OB.js";var y=e(r(),1),b=a(),oe=6,x=25;function S(){let[e,r]=n(),[a,S]=(0,y.useState)(``),[C,w]=(0,y.useState)(`all`),[T,E]=(0,y.useState)(`newest`),[D,se]=(0,y.useState)(``),[O,k]=(0,y.useState)(0),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(null),[P,ce]=(0,y.useState)(new Set),{data:le,refetch:F}=o(()=>f.queues(),[],{intervalMs:1e4}),I=le?.queues??[],L=I.reduce((e,t)=>e+t.dlq,0),{data:R,error:z,loading:ue,refetch:B}=o((0,y.useCallback)(async()=>{if(!a)return{queue:a,page:O,entries:[],entriesTotal:0,stats:null};let[e,t]=await Promise.all([f.dlq(a,x,O*x),f.dlqStats(a).catch(()=>null)]);return{queue:a,page:O,entries:e.entries??[],entriesTotal:e.total??0,stats:t?.stats??null}},[a,O]),[a,O]),V=R&&R.queue===a&&R.page===O?R:null;(0,y.useEffect)(()=>{if(!V)return;let e=V.entriesTotal??0;O>0&&O*x>=e&&k(Math.max(0,Math.ceil(e/x)-1))},[V,O]);let H=async(e,t,n)=>{if(window.confirm(e)){j(!0),N(null);try{let e=(await n())?.count??0,r=`${t} ${d(e)} ${e===1?`entry`:`entries`}`;N({ok:!0,text:r}),p.success(r),B(),F()}catch(e){N({ok:!1,text:e.message}),p.error(`${t} failed`,e.message)}finally{j(!1)}}},U=async e=>{let t=q.map(e=>e.name);if(t.length===0||!window.confirm(`${e} the dead letter queue across ${t.length} queue(s) (${d(L)} entries)?`))return;j(!0),N(null);let n=await ae(t,oe,t=>e===`Retry`?f.retryDlq(t):f.purgeDlq(t)),r=0,i=0;for(let e of n)e.status===`fulfilled`?r+=e.value?.count??0:i++;let a=`${e===`Retry`?`Retried`:`Purged`} ${d(r)} across ${t.length-i}/${t.length} queues${i?`, ${i} failed`:``}`;N({ok:i===0,text:a}),i===0?p.success(a):p.error(a),B(),F(),j(!1)},de=()=>{let e=(V?.entries??[]).map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,enteredAt:new Date(e.enteredAt).toISOString(),attempts:e.attempts?.length??0}));if(e.length===0){p.info(`Nothing to export on this page`);return}v(`dlq-${a}`,e,[`jobId`,`reason`,`error`,`enteredAt`,`attempts`])},W=e=>{J.current=!0,S(e),k(0),w(`all`),r(e?{queue:e}:{},{replace:!0})},G=V?.stats?.byReason??{},K=Object.keys(G).filter(e=>G[e]>0),fe=[...K].sort((e,t)=>(G[t]??0)-(G[e]??0))[0],q=(0,y.useMemo)(()=>I.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[I]),J=(0,y.useRef)(!1),Y=e.get(`queue`);(0,y.useEffect)(()=>{if(!(J.current||a)){if(Y){if(I.some(e=>e.name===Y)){J.current=!0,S(Y),k(0),w(`all`);return}if(I.length===0)return}q.length!==0&&(J.current=!0,S(q[0].name),k(0),w(`all`))}},[a,I,q,Y]);let X=(0,y.useMemo)(()=>{let e=V?.entries??[];C!==`all`&&(e=e.filter(e=>e.reason===C));let t=D.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>T===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[V,C,D,T]),Z=L===0,Q=C!==`all`||D.trim()!==``,$=(V?.entriesTotal??0)>x;return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(te,{title:`Dead Letter Queue`,description:`Jobs that failed after exhausting all retries. Monitor, retry, or purge.`,live:!0}),z&&(0,b.jsx)(re,{onRetry:B}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,b.jsxs)(l,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,b.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,b.jsx)(`div`,{className:t(`mt-2 text-3xl font-bold tnum`,Z?`text-success`:`text-danger`),children:d(L)})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,b.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:a?fe??`No failures`:`Select a queue`})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,b.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:V?.stats?d(V.stats.pendingRetry??0):`—`}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:a?`in this queue`:`awaiting retry`})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,b.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:V?.stats?d(K.length):`—`}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]}),q.length>0&&(0,b.jsxs)(l,{className:`mb-6`,children:[(0,b.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(h,{size:`sm`,disabled:A,onClick:()=>U(`Retry`),children:[(0,b.jsx)(s,{className:`size-3.5`}),` Retry all (`,q.length,` queues)`]}),(0,b.jsxs)(h,{variant:`danger`,size:`sm`,disabled:A,onClick:()=>U(`Purge`),children:[`Purge all (`,q.length,` queues)`]})]})]}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:q.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>W(e.name),className:t(`rounded-lg border p-3 text-left transition-colors`,a===e.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,b.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:e.name}),(0,b.jsx)(`div`,{className:`mt-1 text-xl font-bold tnum text-danger`,children:e.dlq})]},e.name))})]}),(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.jsxs)(_,{value:a,onChange:e=>W(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`Select a queue…`}),I.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,b.jsx)(`div`,{className:`w-40`,children:(0,b.jsxs)(_,{value:C,onChange:e=>w(e.target.value),"aria-label":`Filter by reason`,children:[(0,b.jsx)(`option`,{value:`all`,children:`All Reasons`}),K.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]})}),(0,b.jsx)(`div`,{className:`w-36`,children:(0,b.jsxs)(_,{value:T,onChange:e=>E(e.target.value),"aria-label":$?`Sort this page`:`Sort`,children:[(0,b.jsxs)(`option`,{value:`newest`,children:[`Newest First`,$?` (this page)`:``]}),(0,b.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,$?` (this page)`:``]})]})}),(0,b.jsx)(`input`,{value:D,onChange:e=>se(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,b.jsxs)(h,{size:`sm`,disabled:!a||A,onClick:()=>H(`Retry all for "${a}"?`,`Retried`,()=>f.retryDlq(a)),children:[(0,b.jsx)(s,{className:`size-3.5`}),` Retry All`]}),(0,b.jsx)(h,{variant:`danger`,size:`sm`,disabled:!a||A,onClick:()=>H(`Purge all for "${a}"?`,`Purged`,()=>f.purgeDlq(a)),children:`Purge All`}),(0,b.jsx)(u,{"aria-label":`Export this page to CSV`,title:`Export this page to CSV`,disabled:!a,onClick:de,children:(0,b.jsx)(g,{className:`size-3.5`})})]}),M&&(0,b.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),ue&&!V&&!z?(0,b.jsx)(ee,{label:`Loading DLQ…`}):a?X.length===0?(0,b.jsx)(m,{icon:(0,b.jsx)(c,{}),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,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`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Reason`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Error`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,b.jsx)(`th`,{scope:`col`,className:`w-16 px-5 py-3`})]})}),(0,b.jsx)(`tbody`,{children:X.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(i,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.job.id})}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,b.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:e.error?(0,b.jsx)(`button`,{type:`button`,title:e.error,onClick:()=>ce(t=>{let n=new Set(t),r=`${e.job.id}-${e.enteredAt}`;return n.has(r)?n.delete(r):n.add(r),n}),className:t(`block w-full break-words text-left`,!P.has(`${e.job.id}-${e.enteredAt}`)&&`line-clamp-2`),children:e.error}):`—`}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:ne(e.enteredAt)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,b.jsx)(u,{"aria-label":`Retry`,disabled:A,onClick:()=>H(`Retry job ${e.job.id.slice(0,8)}… from "${a}"?`,`Retried`,()=>f.retryDlq(a,e.job.id)),children:(0,b.jsx)(s,{className:`size-3.5`})})})]},`${e.job.id}-${e.enteredAt}`))})]})}):(0,b.jsx)(m,{icon:(0,b.jsx)(c,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),a&&V&&(0,b.jsx)(ie,{page:O,pageSize:x,total:V.entriesTotal,onPageChange:k,label:`entries`})]})}export{S as DlqPro};
@@ -0,0 +1 @@
1
+ import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-BcouBxpZ.js";import{D as o,S as s,b as c,et as l,h as u,nt as d,x as f,y as p}from"./index-r1ZMLIZ9.js";var m=e(r(),1),h={nodeWidth:168,nodeHeight:60,colGap:72,rowGap:20,padding:24};function g(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=new Set;for(;o.size<n.size;){for(;a.length;){let e=a.shift();if(!o.has(e)){o.add(e);for(let t of i.get(e)??[]){if(o.has(t))continue;n.set(t,Math.max(n.get(t)??0,(n.get(e)??0)+1));let i=(r.get(t)??0)-1;r.set(t,i),i===0&&a.push(t)}}}let t=e.find(e=>!o.has(e));if(t===void 0)break;a.push(t)}return n}function _(e,t,n={}){let r={...h,...n},i=g(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 v=a(),y=168,b=60,x={nodeWidth:y,nodeHeight:b},S=60,C=6,w=`flow-order-9a3f`,T={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`},E=e=>e&&T[e]||`border-line bg-surface-2 text-muted`,D=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,O=`bq-dash-recent-flows`,k=8;function A(){try{let e=JSON.parse(localStorage.getItem(O)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e?.root==`string`&&typeof e?.nodes==`number`&&typeof e?.at==`number`):[]}catch{return[]}}function j(e,t){let n=[t,...e.filter(e=>e.root!==t.root)].slice(0,k);try{localStorage.setItem(O,JSON.stringify(n))}catch{}return n}async function M(e){let t=e,n=new Set([e]);for(let e=0;e<12;e++){try{let{job:e}=await d.job(t),r=e?.parentId;if(r&&!n.has(r)){n.add(r),t=r;continue}}catch(t){if(e===0)throw t}break}return t}async function N(e){let t=new Map,n=[],r=new Set,i=[{id:e,depth:0}],a=!1,o=0;for(;i.length&&t.size<S;){let{id:e,depth:s}=i.shift();if(t.has(e))continue;let c=null;try{c=(await d.job(e)).job??null}catch{o+=1}if(t.set(e,c??{id:e,state:`unknown`}),!c)continue;if(s>=C){(c.childrenIds?.length??0)+(c.dependsOn?.length??0)>0&&(a=!0);continue}let l=(e,t,a,o)=>{let c=`${e}->${t}:${a}`;r.has(c)||(r.add(c),n.push({from:e,to:t,kind:a})),i.push({id:o,depth:s+1})};for(let t of c.childrenIds??[])l(e,t,`child`,t);for(let t of c.dependsOn??[])l(t,e,`depends`,t)}return i.some(e=>!t.has(e.id))&&(a=!0),{jobs:t,edges:n,truncated:a,failed:o}}function P(e,t,n,r){let i=(e+n)/2;return`M${e},${t} C${i},${t} ${i},${r} ${n},${r}`}function F(){let[e,r]=n(),a=e.get(`root`)??(o()?w:``),[d,h]=(0,m.useState)(a),[g,T]=(0,m.useState)(null),[O,k]=(0,m.useState)(null),[F,L]=(0,m.useState)(!1),[R,z]=(0,m.useState)(null),[B,V]=(0,m.useState)(A),H=(0,m.useRef)(0),U=(0,m.useCallback)(async e=>{let t=e.trim();if(!t){T(null);return}let n=++H.current;L(!0),z(null);try{let e=await M(t),r=await N(e);if(n!==H.current)return;T(r),k(e),r.jobs.size>1&&V(t=>j(t,{root:e,nodes:r.jobs.size,at:Date.now()}))}catch(e){if(n!==H.current)return;z(e instanceof Error?e:Error(`Failed to load flow`)),T(null)}finally{n===H.current&&L(!1)}},[]);(0,m.useEffect)(()=>{a&&U(a)},[a,U]);let W=e=>{e.preventDefault();let t=d.trim();t&&r(t?{root:t}:{},{replace:!0})},G=g?_([...g.jobs.keys()],g.edges,x):null,K=new Map(G?.nodes.map(e=>[e.id,e])??[]),q=O?g?.jobs.get(O):void 0;return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(u,{title:`Flows`,description:`Visualize a job flow: parent, children, and dependency edges as an interactive graph.`,actions:g&&(0,v.jsx)(`button`,{type:`button`,disabled:F,onClick:()=>U(d||a),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg disabled:opacity-50`,children:`Refresh`})}),(0,v.jsxs)(s,{className:`mb-6`,children:[(0,v.jsxs)(`form`,{onSubmit:W,className:`flex flex-wrap items-center gap-3`,children:[(0,v.jsx)(`input`,{value:d,onChange:e=>h(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,v.jsx)(`button`,{type:`submit`,disabled:F||!d.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,v.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 `,S,` nodes).`]})]}),R&&(R instanceof l?(0,v.jsx)(p,{error:R,onRetry:()=>U(d||a)}):(0,v.jsx)(f,{onRetry:()=>U(d||a)})),F&&!g&&(0,v.jsx)(c,{label:`Loading flow…`}),!F&&!g&&!R&&(0,v.jsx)(s,{children:(0,v.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,v.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow loaded.`}),(0,v.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”.`}),B.length>0&&(0,v.jsxs)(`div`,{className:`mt-6`,children:[(0,v.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Recently viewed`}),(0,v.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:B.map(e=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{h(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:[D(e.root),(0,v.jsxs)(`span`,{className:`ml-2 text-faint`,children:[e.nodes,` nodes`]})]},e.root))})]})]})}),g&&G&&(0,v.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1fr_260px]`,children:[(0,v.jsx)(s,{padded:!1,className:`overflow-auto p-4`,children:(0,v.jsxs)(`div`,{className:`relative`,style:{width:G.width,height:G.height},children:[(0,v.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 text-line`,width:G.width,height:G.height,children:[(0,v.jsx)(`title`,{children:`Flow edges`}),g.edges.map(e=>{let t=K.get(e.from),n=K.get(e.to);return!t||!n?null:(0,v.jsx)(`path`,{d:P(t.x+y,t.y+b/2,n.x,n.y+b/2),fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeDasharray:e.kind===`depends`?`4 4`:void 0,opacity:.5},`${e.from}-${e.to}-${e.kind}`)})]}),G.nodes.map(e=>{let n=g.jobs.get(e.id);return(0,v.jsxs)(`button`,{type:`button`,onClick:()=>k(e.id),style:{left:e.x,top:e.y,width:y,height:b},className:t(`absolute flex flex-col justify-center gap-0.5 rounded-lg border px-3 text-left transition-shadow`,E(n?.state),O===e.id&&`ring-2 ring-accent`),children:[(0,v.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:D(e.id)}),(0,v.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,v.jsx)(`span`,{className:`truncate`,children:n?.queue??`—`}),(0,v.jsx)(`span`,{className:`font-medium`,children:n?.state??`unknown`})]})]},e.id)})]})}),(0,v.jsxs)(s,{children:[q?(0,v.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs text-faint`,children:`Job`}),(0,v.jsx)(`div`,{className:`break-all font-mono text-xs text-fg`,children:q.id})]}),(0,v.jsx)(I,{label:`Queue`,value:q.queue??`—`}),(0,v.jsx)(I,{label:`State`,value:q.state??`unknown`}),(0,v.jsx)(I,{label:`Priority`,value:String(q.priority??0)}),(0,v.jsx)(I,{label:`Children`,value:String(q.childrenIds?.length??0)}),(0,v.jsx)(I,{label:`Depends on`,value:String(q.dependsOn?.length??0)}),(0,v.jsx)(i,{to:`/job?id=${encodeURIComponent(q.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,v.jsx)(`p`,{className:`text-sm text-muted`,children:`Click a node to inspect it.`}),(0,v.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-xs text-faint`,children:[g.truncated&&(0,v.jsxs)(`div`,{className:`mb-1 text-warning`,children:[`Graph truncated at `,S,` nodes / depth `,C,` — not the whole flow.`]}),g.failed>0&&(0,v.jsxs)(`div`,{className:`mb-1 text-warning`,children:[g.failed,` node`,g.failed===1?``:`s`,` couldn't be loaded — their edges are missing, so this is not the whole flow.`]}),(0,v.jsxs)(`div`,{className:`mb-1`,children:[g.jobs.size,` node`,g.jobs.size===1?``:`s`,` · `,g.edges.length,` edge`,g.edges.length===1?``:`s`]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,v.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`inline-block h-px w-4 bg-current`}),` child`]}),(0,v.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`inline-block h-px w-4 border-t border-dashed border-current`}),` `,`depends`]})]})]})]})]})]})}function I({label:e,value:t}){return(0,v.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,v.jsx)(`span`,{className:`text-xs text-faint`,children:e}),(0,v.jsx)(`span`,{className:`text-fg`,children:t})]})}export{F as Flows};
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./cn-CMFYpumL.js";import{f as t,h as n,r,t as i}from"./react-vendor-BcouBxpZ.js";import{C as a,J as o,O as s,S as c,T as l,a as u,b as d,et as f,g as p,h as m,nt as h,o as g,v as _,w as v,z as y}from"./index-r1ZMLIZ9.js";import{a as b,n as x}from"./form-DGinTEEb.js";import{t as S}from"./jobActions-CuOdMglt.js";import{n as C}from"./exportFile-C7xhE8Yh.js";var w=e(n(),1);function ee(e){let t={};return typeof e.priority==`number`&&(t.priority=e.priority),typeof e.maxAttempts==`number`&&(t.maxAttempts=e.maxAttempts),typeof e.backoff==`number`&&(t.backoff=e.backoff),e.backoffConfig&&typeof e.backoffConfig.delay==`number`&&(t.backoffConfig={type:e.backoffConfig.type,delay:e.backoffConfig.delay},typeof t.backoff!=`number`&&(t.backoff=e.backoffConfig.delay)),typeof e.timeout==`number`&&(t.timeout=e.timeout),typeof e.removeOnComplete==`boolean`&&(t.removeOnComplete=e.removeOnComplete),typeof e.removeOnFail==`boolean`&&(t.removeOnFail=e.removeOnFail),typeof e.ttl==`number`&&(t.ttl=e.ttl),Array.isArray(e.tags)&&e.tags.length&&(t.tags=[...e.tags]),typeof e.groupId==`string`&&e.groupId&&(t.groupId=e.groupId),{clone:{queue:e.queue??``,dataText:JSON.stringify(e.data??{},null,2),options:t}}}var T=i();function te({job:e,busy:t,act:n}){let r=S(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,T.jsxs)(c,{children:[(0,T.jsx)(a,{title:`Actions`}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,T.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>h.promoteJob(e.id)),children:`Promote (run now)`}),r.retryActive&&(0,T.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>h.retryJob(e.id)),children:`Retry (move to waiting)`}),r.retryDlq&&(0,T.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>h.retryDlq(e.queue??``,e.id)),children:`Retry from DLQ`}),r.requeueCompleted&&(0,T.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Requeue`,()=>h.retryCompleted(e.queue??``,e.id)),children:`Requeue`}),r.moveToDelayed&&(0,T.jsx)(E,{label:`Move to delayed (ms)`,cta:`To delayed`,disabled:t,onSubmit:t=>n(`Move to delayed`,()=>h.moveToDelayed(e.id,t))}),e.state===`active`&&(0,T.jsx)(E,{label:`Set progress (0–100)`,cta:`Progress`,disabled:t,onSubmit:t=>n(`Progress`,()=>h.setJobProgress(e.id,Math.max(0,Math.min(100,t))))}),r.discard&&(0,T.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Discard`,()=>h.discardJob(e.id)),children:`Discard (to DLQ)`}),r.setPriority&&(0,T.jsx)(E,{label:`Set priority`,cta:`Set`,disabled:t,onSubmit:t=>n(`Priority`,()=>h.changePriority(e.id,t))}),r.setDelay&&(0,T.jsx)(E,{label:`Set delay (ms)`,cta:`Delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>h.changeDelay(e.id,t))}),r.fail&&(0,T.jsx)(D,{label:`Fail reason (optional)`,cta:`Fail`,variant:`warning`,disabled:t,onSubmit:t=>n(`Fail`,()=>h.failJob(e.id,t||void 0),`Force-fail this active job?`)}),r.cancel&&(0,T.jsx)(v,{variant:`danger`,size:`sm`,disabled:t,onClick:()=>n(`Cancel`,()=>h.cancelJob(e.id),`Cancel and remove job ${e.id}?`),children:`Cancel (delete)`}),!i&&(0,T.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function E({label:e,cta:t,disabled:n,onSubmit:r}){let[i,a]=(0,w.useState)(``);return(0,T.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),!n&&i.trim()!==``&&r(Number(i))},children:[(0,T.jsx)(x,{type:`number`,value:i,onChange:e=>a(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,T.jsx)(v,{type:`submit`,size:`sm`,disabled:n||i.trim()===``,children:t})]})}function D({label:e,cta:t,disabled:n,variant:r=`default`,onSubmit:i}){let[a,o]=(0,w.useState)(``);return(0,T.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),!n&&(i(a),o(``))},children:[(0,T.jsx)(x,{value:a,onChange:e=>o(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,T.jsx)(v,{type:`submit`,size:`sm`,variant:r,disabled:n,children:t})]})}var O=36e5,k=10,A=e=>Math.max(e,1);function j(e){return Math.max(0,(e.maxAttempts??0)-A(e.attempts??0))}function M(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??O,a=r?.delay??e.backoff??1e3,o=[];for(let e=A(n);e<t&&o.length<k;e++){let t=r?.type===`fixed`?a:a*2**e;o.push({attempt:e+1,delayMs:Math.min(t,i)})}return o}function N({job:e}){let t=e.maxAttempts??0,n=e.attempts??0;if(t<=1)return(0,T.jsxs)(c,{children:[(0,T.jsx)(a,{title:`Backoff`}),(0,T.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,T.jsxs)(c,{children:[(0,T.jsx)(a,{title:`Backoff schedule`}),(0,T.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=j(e),s=M(e);return(0,T.jsxs)(c,{children:[(0,T.jsx)(a,{title:`Backoff schedule`,action:(0,T.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${g(r.maxDelay)}`:``]})}),(0,T.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:s.map(e=>(0,T.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,T.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,T.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,g(e.delayMs)]})]},e.attempt))}),o>k&&(0,T.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,k,` of `,o,` remaining attempts.`]}),(0,T.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 `,g(r?.maxDelay??O),`.`]})]})}function P({jobId:e}){let[t,n]=(0,w.useState)(!1),[r,i]=(0,w.useState)(!1),[o,s]=(0,w.useState)(!1),[l,u]=(0,w.useState)(void 0),[d,f]=(0,w.useState)(null),p=async()=>{s(!0),f(null);try{let t=await h.jobChildren(e);u(t.data?.values),i(!0)}catch(e){f(e.message)}finally{s(!1)}},m=()=>{let e=!t;n(e),e&&!r&&!o&&p()},g=l&&typeof l==`object`?Array.isArray(l)?l.length:Object.keys(l).length:0;return(0,T.jsxs)(c,{children:[(0,T.jsx)(a,{title:`Child values`,action:(0,T.jsx)(v,{size:`sm`,variant:`ghost`,onClick:m,children:t?`Hide`:`Show`})}),t?o?(0,T.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):d?(0,T.jsx)(`p`,{className:`text-xs text-danger`,children:d}):g===0?(0,T.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,T.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,T.jsx)(`p`,{className:`text-xs text-faint`,children:`Resolved return values from this flow job's children.`})]})}function F({data:e,busy:t,onSave:n}){let[r,i]=(0,w.useState)(()=>JSON.stringify(e??null,null,2)),[o,s]=(0,w.useState)(null),l=(0,w.useRef)(r);return(0,w.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,i(t),s(null))},[e]),(0,T.jsxs)(c,{children:[(0,T.jsx)(a,{title:`Data`,action:(0,T.jsx)(v,{size:`sm`,disabled:t,onClick:()=>{let e;try{e=JSON.parse(r)}catch(e){s(`Invalid JSON: ${e.message}`);return}s(null),n(e)},children:`Save data`})}),(0,T.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,T.jsx)(`p`,{className:`mt-2 text-xs text-danger`,children:o})]})}function I({jobId:e}){let[t,n]=(0,w.useState)([]),[r,i]=(0,w.useState)(0),[o,s]=(0,w.useState)(!1),[l,u]=(0,w.useState)(null),[d,f]=(0,w.useState)(``),[p,m]=(0,w.useState)(`info`),[g,_]=(0,w.useState)(!1),y=(0,w.useRef)(0),S=(0,w.useCallback)(async()=>{let t=++y.current;s(!0),u(null);try{let r=await h.jobLogs(e);if(t!==y.current)return;n(r.data?.logs??[]),i(r.data?.count??0)}catch(e){t===y.current&&u(e.message)}finally{t===y.current&&s(!1)}},[e]);(0,w.useEffect)(()=>{S()},[S]);let C=async()=>{if(g)return;let t=d.trim();if(t){_(!0),u(null);try{await h.addJobLog(e,t,p),f(``),await S()}catch(e){u(e.message)}finally{_(!1)}}};return(0,T.jsxs)(c,{children:[(0,T.jsx)(a,{title:`Logs`,action:(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:r}),(0,T.jsx)(v,{size:`sm`,variant:`ghost`,disabled:o||g,onClick:S,children:`Refresh`}),(0,T.jsx)(v,{size:`sm`,variant:`danger`,disabled:g||t.length===0,onClick:async()=>{if(window.confirm(`Clear all logs for this job?`)){_(!0),u(null);try{await h.clearJobLogs(e),await S()}catch(e){u(e.message)}finally{_(!1)}}},children:`Clear logs`})]})}),l&&(0,T.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:l}),t.length===0?(0,T.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,T.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,T.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,T.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,T.jsx)(x,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.key===`Enter`&&C(),placeholder:`Add a log line…`,className:`h-8 flex-1 text-xs`}),(0,T.jsxs)(b,{value:p,onChange:e=>m(e.target.value),className:`h-8 w-24 text-xs`,children:[(0,T.jsx)(`option`,{value:`info`,children:`info`}),(0,T.jsx)(`option`,{value:`warn`,children:`warn`}),(0,T.jsx)(`option`,{value:`error`,children:`error`})]}),(0,T.jsx)(v,{size:`sm`,disabled:g||d.trim()===``,onClick:C,children:`Add`})]})]})}function ne({timeline:e}){let t=e??[];return(0,T.jsxs)(c,{children:[(0,T.jsx)(a,{title:`Timeline`}),t.length===0?(0,T.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,T.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,T.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(p,{status:e.state}),e.attempt!=null&&(0,T.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,T.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:u(e.timestamp)})]}),(e.worker||e.error)&&(0,T.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,T.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,T.jsx)(`div`,{className:`mt-0.5 text-xs text-danger/90`,children:e.error})]})]},t))})]})}function re(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 L(){let[e,n]=t(),[i,l]=(0,w.useState)(e.get(`id`)??``),[x,S]=(0,w.useState)(`id`),[E,D]=(0,w.useState)(null),[O,k]=(0,w.useState)({fetched:!1,value:void 0}),[A,j]=(0,w.useState)(null),[M,L]=(0,w.useState)(!1),[oe,z]=(0,w.useState)(!1),[B,V]=(0,w.useState)(null),[H,U]=(0,w.useState)(!1),W=(0,w.useRef)(0),G=async(e,t=x,r=!1)=>{let i=e.trim();if(!i)return;let a=++W.current;L(!0),z(!1),r||V(null);try{let e=(await(t===`custom`?h.jobByCustomId(i):h.job(i))).job;if(!e){if(a!==W.current)return;D(null),k({fetched:!1,value:void 0}),j(null),z(!0),n({},{replace:!0});return}let r=null,o=null;if(e.state===`completed`)try{r=await h.jobResult(e.id)}catch(e){o=e.message}if(a!==W.current)return;D(e),l(t===`custom`?e.id:i),n({id:e.id},{replace:!0}),k(r?{fetched:!0,value:r.result}:{fetched:!1,value:void 0}),j(o)}catch(e){if(a!==W.current)return;e instanceof f&&(e.status===404||/not found/i.test(e.message))?(D(null),k({fetched:!1,value:void 0}),j(null),z(!0),n({},{replace:!0})):V(r?t=>t?{ok:t.ok,text:`${t.text} — couldn't reload: ${e.message}`}:{ok:!1,text:e.message}:{ok:!1,text:e.message})}finally{a===W.current&&L(!1)}},K=e.get(`id`);(0,w.useEffect)(()=>{K&&K!==E?.id&&G(K,`id`)},[K,E?.id]);let q=async(e,t,r)=>{if(!(r&&!window.confirm(r))&&E){U(!0),V(null);try{await t(),V({ok:!0,text:`${e} ✓`}),e===`Cancel`?(D(null),k({fetched:!1,value:void 0}),j(null),n({},{replace:!0})):await G(E.id,`id`,!0)}catch(e){V({ok:!1,text:e.message})}finally{U(!1)}}},J=E?.state,Y=E?re(E):null,X=(E?.stacktrace?.length??0)>0,Z=(E?.childrenIds?.length??0)>0,Q=J===`failed`,$=E&&(Y||X)?(0,T.jsxs)(c,{children:[(0,T.jsx)(a,{title:`Error`}),Y&&(0,T.jsxs)(`div`,{className:`mb-3`,children:[(0,T.jsx)(`p`,{className:`text-sm text-danger`,children:Y.message}),(0,T.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[Y.attempt==null?``:`Attempt ${Y.attempt} · `,u(Y.timestamp)]})]}),X&&(0,T.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:E.stacktrace?.join(`
2
+ `)})]}):null;return(0,T.jsxs)(`div`,{children:[(0,T.jsx)(m,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:E?(0,T.jsxs)(T.Fragment,{children:[(Z||E.parentId)&&(0,T.jsx)(r,{to:`/flows?root=${encodeURIComponent(E.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`}),(0,T.jsx)(r,{to:`/add-job`,state:ee(E),title:`Enqueue a new job pre-filled from this one`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Clone`}),(0,T.jsxs)(v,{size:`sm`,onClick:()=>C(`job-${E.id}`,O.fetched?{...E,result:O.value}:E),children:[(0,T.jsx)(y,{className:`size-3.5`}),` Download JSON`]})]}):void 0}),(0,T.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,T.jsxs)(b,{value:x,"aria-label":`Lookup mode`,onChange:e=>S(e.target.value),className:`w-40`,children:[(0,T.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,T.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,T.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,T.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,T.jsx)(`input`,{value:i,"aria-label":x===`custom`?`Custom job ID`:`Job ID`,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&G(i),placeholder:x===`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,T.jsx)(v,{variant:`accent`,disabled:M,onClick:()=>G(i),children:`Look up`})]}),B&&(0,T.jsx)(`div`,{role:`status`,className:B.ok?`mb-4 text-sm text-success`:`mb-4 text-sm text-danger`,children:B.text}),M&&!E?(0,T.jsx)(d,{label:`Loading job…`}):oe?(0,T.jsx)(_,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`}):E?(0,T.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,T.jsxs)(c,{children:[(0,T.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:E.id}),(0,T.jsx)(s,{value:E.id})]}),(0,T.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:E.queue})]}),(0,T.jsx)(p,{status:J??`waiting`})]}),(0,T.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,T.jsx)(R,{k:`Priority`,v:String(E.priority??0)}),(0,T.jsx)(R,{k:`Attempts`,v:`${E.attempts??0} / ${E.maxAttempts??`?`}`}),(0,T.jsx)(R,{k:`Progress`,v:`${E.progress??0}%`}),(0,T.jsx)(R,{k:`Created`,v:u(E.createdAt)}),(0,T.jsx)(R,{k:`Started`,v:u(E.startedAt??void 0)}),(0,T.jsx)(R,{k:`Completed`,v:u(E.completedAt??void 0)}),(0,T.jsx)(R,{k:`Duration`,v:g(E.startedAt&&E.completedAt?E.completedAt-E.startedAt:void 0)}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,T.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,T.jsx)(`span`,{className:`truncate font-mono`,children:E.customId??`—`}),E.customId&&(0,T.jsx)(s,{value:E.customId})]})]})]})]}),Q&&$,(0,T.jsx)(F,{data:E.data,busy:H,onSave:e=>q(`Data`,()=>h.updateJobData(E.id,e))},`data-${E.id}`),J===`completed`&&(0,T.jsxs)(c,{children:[(0,T.jsx)(a,{title:`Result`,action:O.fetched&&O.value!==void 0&&O.value!==null?(0,T.jsx)(ae,{value:O.value,filename:`job-${E.id}-result`}):void 0}),O.fetched&&O.value!==void 0&&O.value!==null?(0,T.jsx)(ie,{value:O.value}):A?(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,T.jsxs)(`p`,{className:`text-xs text-danger`,children:[`Couldn't load result — `,A]}),(0,T.jsx)(v,{size:`sm`,disabled:M,onClick:()=>G(E.id,`id`),children:`Retry`})]}):(0,T.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]}),!Q&&$,(0,T.jsx)(I,{jobId:E.id},`logs-${E.id}`),Z&&(0,T.jsx)(P,{jobId:E.id},`children-${E.id}`),(0,T.jsx)(ne,{timeline:E.timeline}),(0,T.jsx)(N,{job:E})]}),(0,T.jsx)(`div`,{className:`order-first lg:order-none`,children:(0,T.jsx)(te,{job:E,busy:H,act:q})})]}):(0,T.jsx)(_,{title:`No job loaded`,hint:`Enter a job ID above to inspect it.`})]})}function R({k:e,v:t}){return(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,T.jsx)(`dd`,{className:`text-fg`,children:t})]})}function ie({value:e}){return(0,T.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)})}function ae({value:e,filename:t}){return(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(s,{value:JSON.stringify(e??null,null,2)}),(0,T.jsx)(l,{"aria-label":`Download JSON`,title:`Download JSON`,onClick:()=>C(t,e??null),children:(0,T.jsx)(y,{className:`size-3.5`})})]})}export{L as JobInspector};
@@ -1 +1 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{f as t,h as n,t as r}from"./react-vendor-BcouBxpZ.js";import{A as i,J as a,T as o,Y as s,b as c,c as l,f as u,g as d,h as f,j as p,l as m,m as h,n as g,o as _,u as v,x as y}from"./index-BOcegTHa.js";import{a as b,i as x}from"./form-DGinTEEb.js";import{t as S}from"./jobActions-CuOdMglt.js";var C=e(n(),1),w=r(),T=`__all__`,E=[`all`,`waiting`,`active`,`completed`,`failed`];function D(){let[e]=t(),[n,r]=(0,C.useState)(e.get(`queue`)??T),[D,O]=(0,C.useState)(`all`),[k,A]=(0,C.useState)(``),{data:j}=i(()=>p.queues(500),[],{intervalMs:3e4}),{data:M}=i(()=>p.overview(),[]),{data:N,error:P,loading:F,refetch:I}=i((0,C.useCallback)(async()=>{let e=n===T?(j?.queues??[]).map(e=>e.name).slice(0,25):[n],t=D===`all`?void 0:[D];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,D,j]),[n,D]),L=(0,C.useMemo)(()=>{let e=N??[],t=k.trim().toLowerCase();return(t?e.filter(e=>e.id.toLowerCase().includes(t)||(e.data?.name??``).toLowerCase().includes(t)):e).slice(0,100)},[N,k]),R=M?.stats,z=R?g(R.totalCompleted,R.totalFailed)??0:0,B=async e=>{if(window.confirm(`Cancel job ${e}?`))try{await p.cancelJob(e),I()}catch(e){window.alert(`Cancel failed: ${e.message}`)}};return(0,w.jsxs)(`div`,{children:[P&&(0,w.jsx)(y,{onRetry:I}),(0,w.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!0}),(0,w.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,w.jsx)(h,{label:`Total`,value:l((R?.totalCompleted??0)+(R?.totalFailed??0)+(R?.waiting??0)+(R?.active??0)),compact:!0}),(0,w.jsx)(h,{label:`Waiting`,value:l(R?.waiting),tone:`amber`,compact:!0}),(0,w.jsx)(h,{label:`Active`,value:l(R?.active),tone:`blue`,compact:!0}),(0,w.jsx)(h,{label:`Completed`,value:l(R?.totalCompleted),tone:`green`,compact:!0}),(0,w.jsx)(h,{label:`Failed`,value:l(R?.totalFailed),tone:R?.totalFailed?`red`:`default`,compact:!0}),(0,w.jsx)(h,{label:`Error Rate`,value:m(z),tone:z>.05?`red`:`green`,compact:!0})]}),(0,w.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,w.jsx)(`div`,{className:`w-48`,children:(0,w.jsxs)(b,{value:n,onChange:e=>r(e.target.value),children:[(0,w.jsx)(`option`,{value:T,children:`All Queues`}),(j?.queues??[]).map(e=>(0,w.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,w.jsx)(x,{options:E,value:D,onChange:O}),(0,w.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,w.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,w.jsx)(`input`,{value:k,onChange:e=>A(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`})]})]}),F&&!N&&!P?(0,w.jsx)(c,{label:`Loading jobs…`}):(0,w.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,w.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,w.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,w.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,w.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,w.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,w.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,w.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,w.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,w.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,w.jsx)(`tbody`,{children:L.length===0?(0,w.jsx)(`tr`,{children:(0,w.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:`No jobs found.`})}):L.map(e=>(0,w.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,w.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:e.id}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unnamed`}),(0,w.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,w.jsx)(`td`,{className:`px-5 py-3`,children:(0,w.jsx)(d,{status:String(e.state??e.status??`waiting`)})}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:v(e.createdAt)}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:_(u(e.startedAt??void 0,e.completedAt??void 0))}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,w.jsx)(o,{"aria-label":`Cancel job`,disabled:!S(e.state??e.status).cancel,onClick:()=>B(e.id),children:(0,w.jsx)(s,{className:`size-3.5`})})})]},`${e.queue}:${e.id}`))})]})})]})}export{D as Jobs};
1
+ import{r as e}from"./cn-CMFYpumL.js";import{f as t,h as n,t as r}from"./react-vendor-BcouBxpZ.js";import{A as i,J as a,T as o,Y as s,b as c,c as l,f as u,g as d,h as f,j as p,l as m,m as h,n as g,o as _,u as v,x as y}from"./index-r1ZMLIZ9.js";import{a as b,i as x}from"./form-DGinTEEb.js";import{t as S}from"./jobActions-CuOdMglt.js";var C=e(n(),1),w=r(),T=`__all__`,E=[`all`,`waiting`,`active`,`completed`,`failed`];function D(){let[e]=t(),[n,r]=(0,C.useState)(e.get(`queue`)??T),[D,O]=(0,C.useState)(`all`),[k,A]=(0,C.useState)(``),{data:j}=i(()=>p.queues(500),[],{intervalMs:3e4}),{data:M}=i(()=>p.overview(),[]),{data:N,error:P,loading:F,refetch:I}=i((0,C.useCallback)(async()=>{let e=n===T?(j?.queues??[]).map(e=>e.name).slice(0,25):[n],t=D===`all`?void 0:[D];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,D,j]),[n,D]),L=(0,C.useMemo)(()=>{let e=N??[],t=k.trim().toLowerCase();return(t?e.filter(e=>e.id.toLowerCase().includes(t)||(e.data?.name??``).toLowerCase().includes(t)):e).slice(0,100)},[N,k]),R=M?.stats,z=R?g(R.totalCompleted,R.totalFailed)??0:0,B=async e=>{if(window.confirm(`Cancel job ${e}?`))try{await p.cancelJob(e),I()}catch(e){window.alert(`Cancel failed: ${e.message}`)}};return(0,w.jsxs)(`div`,{children:[P&&(0,w.jsx)(y,{onRetry:I}),(0,w.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!0}),(0,w.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,w.jsx)(h,{label:`Total`,value:l((R?.totalCompleted??0)+(R?.totalFailed??0)+(R?.waiting??0)+(R?.active??0)),compact:!0}),(0,w.jsx)(h,{label:`Waiting`,value:l(R?.waiting),tone:`amber`,compact:!0}),(0,w.jsx)(h,{label:`Active`,value:l(R?.active),tone:`blue`,compact:!0}),(0,w.jsx)(h,{label:`Completed`,value:l(R?.totalCompleted),tone:`green`,compact:!0}),(0,w.jsx)(h,{label:`Failed`,value:l(R?.totalFailed),tone:R?.totalFailed?`red`:`default`,compact:!0}),(0,w.jsx)(h,{label:`Error Rate`,value:m(z),tone:z>.05?`red`:`green`,compact:!0})]}),(0,w.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,w.jsx)(`div`,{className:`w-48`,children:(0,w.jsxs)(b,{value:n,onChange:e=>r(e.target.value),children:[(0,w.jsx)(`option`,{value:T,children:`All Queues`}),(j?.queues??[]).map(e=>(0,w.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,w.jsx)(x,{options:E,value:D,onChange:O}),(0,w.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,w.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,w.jsx)(`input`,{value:k,onChange:e=>A(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`})]})]}),F&&!N&&!P?(0,w.jsx)(c,{label:`Loading jobs…`}):(0,w.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,w.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,w.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,w.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,w.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,w.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,w.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,w.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,w.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,w.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,w.jsx)(`tbody`,{children:L.length===0?(0,w.jsx)(`tr`,{children:(0,w.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:`No jobs found.`})}):L.map(e=>(0,w.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,w.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:e.id}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unnamed`}),(0,w.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,w.jsx)(`td`,{className:`px-5 py-3`,children:(0,w.jsx)(d,{status:String(e.state??e.status??`waiting`)})}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:v(e.createdAt)}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:_(u(e.startedAt??void 0,e.completedAt??void 0))}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,w.jsx)(o,{"aria-label":`Cancel job`,disabled:!S(e.state??e.status).cancel,onClick:()=>B(e.id),children:(0,w.jsx)(s,{className:`size-3.5`})})})]},`${e.queue}:${e.id}`))})]})})]})}export{D as Jobs};
@@ -0,0 +1 @@
1
+ import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-BcouBxpZ.js";import{A as o,B as s,I as c,J as l,K as u,T as d,W as ee,Y as te,a as ne,b as re,c as ie,g as ae,h as oe,l as se,m as f,n as ce,nt as p,o as le,rt as m,w as h,x as ue,z as de}from"./index-r1ZMLIZ9.js";import{a as fe,i as g}from"./form-DGinTEEb.js";import{t as pe}from"./Pagination-B9JDi5MI.js";import{t as _}from"./jobActions-CuOdMglt.js";import{t as me}from"./exportFile-C7xhE8Yh.js";var v=e(r(),1),y=a(),b=[`all`,`waiting`,`active`,`completed`,`failed`],x=25;function he(e,t){return e===t?`${t} selected`:`${e} of ${t} selected match this filter`}function ge(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function _e(e=0){return e>=10?{t:`HIGH`,c:`text-warning`}:e>=1?{t:`MEDIUM`,c:`text-blue-400`}:{t:`LOW`,c:`text-faint`}}function S(e){let t=_(e.state);return t.retryActive?p.retryJob(e.id):t.retryDlq?p.retryDlq(e.queue??``,e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not retryable`))}function C(){let[e,r]=n(),[a,C]=(0,v.useState)(e.get(`queue`)??``),[w,ve]=(0,v.useState)(()=>{let t=e.get(`status`);return t&&b.includes(t)?t:`all`}),[T,ye]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),[O,k]=(0,v.useState)(new Set),[be,A]=(0,v.useState)(new Set),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(null),{data:F}=o(()=>p.queuesSummary(),[],{intervalMs:3e4}),{data:xe}=o(()=>p.overview(),[],{intervalMs:1e4});(0,v.useEffect)(()=>{!a&&F?.length&&C(F[0].name)},[F,a]);let I=`${a}|${w}|${E}`,{data:L,error:R,loading:Se,refetch:z}=o((0,v.useCallback)(async()=>{if(!a)return{view:I,jobs:[]};let e=w===`all`?void 0:[w],t=await p.jobsList(a,e,x,E*x);return{view:I,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??a}))}},[a,w,E,I]),[a,w,E]),B=L&&L.view===I?L.jobs:null,Ce=(B?.length??0)===x,V=(0,v.useMemo)(()=>{let e=T.trim().toLowerCase();return e?(B??[]).filter(t=>t.id.toLowerCase().includes(e)):B??[]},[B,T]),H=xe?.stats,U=(0,v.useMemo)(()=>(F??[]).reduce((e,t)=>e+(t.counts?.failed??0),0),[F]),W=H?ce(H.completed,U):null,G=e=>H?ie(e):`—`,K=()=>D(0),q=(e,t)=>{let n={};e&&(n.queue=e),t!==`all`&&(n.status=t),r(n,{replace:!0})};(0,v.useEffect)(()=>{k(new Set)},[a,w,E]);let we=e=>k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),J=V.length>0&&V.every(e=>O.has(e.id)),Te=()=>k(()=>J?new Set:new Set(V.map(e=>e.id))),Y=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} ✓`}),m.success(`${t} ✓`,e.id)}catch(e){P({ok:!1,text:`${t} failed: ${e.message}`}),m.error(`${t} failed`,e.message)}finally{A(t=>{let n=new Set(t);return n.delete(e.id),n}),z()}}},X=async(e,t,n,r)=>{let i=V.filter(e=>O.has(e.id)&&n(e));if(i.length===0||r&&!window.confirm(r(i.length)))return;M(!0),P(null);let a=await Promise.allSettled(i.map(t)),o=a.filter(e=>e.status===`fulfilled`).length,s=a.length-o,c=`${e}: ${o} succeeded${s?`, ${s} failed`:``}`;P({ok:s===0,text:c}),s===0?m.success(c):m.error(c);let l=i.map(e=>e.id);k(e=>ge(e,l)),M(!1),z()},Z={retry:e=>{let t=_(e.state);return t.retryActive||t.retryDlq},promote:e=>_(e.state).promote,requeue:e=>_(e.state).requeueCompleted,fail:e=>_(e.state).fail,cancel:e=>_(e.state).cancel},Q=V.filter(e=>O.has(e.id)),$={retry:Q.some(Z.retry),promote:Q.some(Z.promote),requeue:Q.some(Z.requeue),fail:Q.some(Z.fail),cancel:Q.some(Z.cancel)};return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(oe,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!0,actions:(0,y.jsxs)(h,{size:`sm`,disabled:!B||V.length===0,onClick:()=>{if(V.length===0){m.info(`No jobs to export on this page`);return}let e=V.map(e=>({id:e.id,queue:e.queue??a,state:e.state??``,priority:e.priority??0,attempts:e.attempts??0,maxAttempts:e.maxAttempts??``,createdAt:e.createdAt?new Date(e.createdAt).toISOString():``,durationMs:e.startedAt&&e.completedAt?e.completedAt-e.startedAt:``}));me(`jobs-${a}-${w}`,e,[`id`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,y.jsx)(de,{className:`size-3.5`}),` Export CSV`]})}),(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)(f,{label:`Total`,value:G((H?.completed??0)+U+(H?.waiting??0)+(H?.active??0)+(H?.delayed??0)),hint:`all queues`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:G(H?.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:G(H?.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:G(H?.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:G(U),tone:U?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Error Rate`,value:W==null?`—`:se(W),tone:W==null?`default`:W>.05?`red`:`green`,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.jsx)(fe,{value:a,"aria-label":`Queue`,onChange:e=>{C(e.target.value),K(),q(e.target.value,w)},children:(F??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,y.jsx)(g,{options:b,value:w,onChange:e=>{ve(e),K(),q(a,e)}}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(l,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{value:T,onChange:e=>ye(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,y.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,y.jsx)(`span`,{className:`mr-1 text-muted`,children:he(Q.length,O.size)}),$.retry&&(0,y.jsx)(h,{size:`sm`,disabled:j,onClick:()=>X(`Retry`,S,Z.retry),children:`Retry selected`}),$.promote&&(0,y.jsx)(h,{size:`sm`,disabled:j,onClick:()=>X(`Promote`,e=>p.promoteJob(e.id),Z.promote),children:`Promote selected`}),$.requeue&&(0,y.jsx)(h,{size:`sm`,disabled:j,onClick:()=>X(`Requeue`,e=>p.retryCompleted(e.queue??``,e.id),Z.requeue),children:`Requeue selected`}),$.fail&&(0,y.jsx)(h,{variant:`warning`,size:`sm`,disabled:j,onClick:()=>X(`Fail`,e=>p.failJob(e.id),Z.fail,e=>`Force-fail ${e} job(s)?`),children:`Fail selected`}),$.cancel&&(0,y.jsx)(h,{variant:`danger`,size:`sm`,disabled:j,onClick:()=>X(`Cancel`,e=>p.cancelJob(e.id),Z.cancel,e=>`Cancel ${e} job(s)? This cannot be undone.`),children:`Cancel selected`}),!$.retry&&!$.promote&&!$.requeue&&!$.fail&&!$.cancel&&(0,y.jsx)(`span`,{className:`text-xs text-faint`,children:Q.length===0?`The selected jobs are hidden by the filter — clear it to act on them.`:`No actions apply to the selected job states.`})]}),N&&(0,y.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,N.ok?`text-success`:`text-danger`),children:N.text}),R&&(0,y.jsx)(ue,{onRetry:z}),Se&&!B&&!R?(0,y.jsx)(re,{label:`Loading jobs…`}):(0,y.jsxs)(y.Fragment,{children:[a&&(0,y.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,y.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:a})]}),(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`,{scope:`col`,className:`w-10 px-5 py-3`,children:(0,y.jsx)(`input`,{type:`checkbox`,checked:J,onChange:Te,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,y.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,y.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Priority`}),(0,y.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,y.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,y.jsx)(`th`,{scope:`col`,className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,y.jsx)(`tbody`,{children:V.length===0?(0,y.jsx)(`tr`,{children:(0,y.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.`:a?`No jobs found.`:`Select a queue.`})}):V.map(e=>{let n=_e(e.priority),r=_(e.state),a=be.has(e.id);return(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)(`input`,{type:`checkbox`,checked:O.has(e.id),onChange:()=>we(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,y.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(ae,{status:String(e.state??`waiting`)})}),(0,y.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.c),children:n.t}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:ne(e.createdAt)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:le(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,y.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,children:(0,y.jsx)(d,{"aria-label":`Inspect job`,children:(0,y.jsx)(s,{className:`size-3.5`})})}),r.promote&&(0,y.jsx)(d,{"aria-label":`Promote job`,disabled:a,onClick:()=>Y(e,`Promote`,()=>p.promoteJob(e.id)),children:(0,y.jsx)(ee,{className:`size-3.5`})}),(r.retryActive||r.retryDlq)&&(0,y.jsx)(d,{"aria-label":`Retry job`,disabled:a,onClick:()=>Y(e,`Retry`,()=>S(e)),children:(0,y.jsx)(u,{className:`size-3.5`})}),r.requeueCompleted&&(0,y.jsx)(d,{"aria-label":`Requeue job`,disabled:a,onClick:()=>Y(e,`Requeue`,()=>p.retryCompleted(e.queue??``,e.id)),children:(0,y.jsx)(u,{className:`size-3.5`})}),r.fail&&(0,y.jsx)(d,{"aria-label":`Fail job`,disabled:a,onClick:()=>Y(e,`Fail`,()=>p.failJob(e.id),`Force-fail this active job?`),children:(0,y.jsx)(c,{className:`size-3.5`})}),r.cancel&&(0,y.jsx)(d,{"aria-label":`Cancel job`,disabled:a,onClick:()=>Y(e,`Cancel`,()=>p.cancelJob(e.id),`Cancel this job?`),children:(0,y.jsx)(te,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,y.jsx)(pe,{page:E,pageSize:x,hasNext:Ce,onPageChange:D,label:`jobs`})]})]})}export{C as JobsPro};
@@ -1 +1 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-BcouBxpZ.js";import{A as r,H as i,J as a,c as o,g as s,h as c,j as l,m as u,t as d,u as f,v as p,x as m}from"./index-BOcegTHa.js";import{a as h,i as g}from"./form-DGinTEEb.js";import{t as _}from"./Pagination-D4ki-pGz.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}=r(()=>l.queues(500),[],{intervalMs:3e4}),{events:k,counters:A,throughput:j,connected:M}=d(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))},[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)(m,{}),(0,y.jsx)(c,{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)(u,{label:`Total Events`,value:o(A.total),compact:!0}),(0,y.jsx)(u,{label:`Completed`,value:o(A.completed),tone:`green`,compact:!0}),(0,y.jsx)(u,{label:`Failed`,value:o(A.failed),tone:A.failed?`red`:`default`,compact:!0}),(0,y.jsx)(u,{label:`Waiting`,value:o(A.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(u,{label:`Active`,value:o(A.active),tone:`blue`,compact:!0}),(0,y.jsx)(u,{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)(a,{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)(i,{}),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:`Event`}),(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)(s,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.event||`job event`}),(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:f(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
+ import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-BcouBxpZ.js";import{A as r,H as i,J as a,c as o,g as s,h as c,j as l,m as u,t as d,u as f,v as p,x as m}from"./index-r1ZMLIZ9.js";import{a as h,i as g}from"./form-DGinTEEb.js";import{t as _}from"./Pagination-B9JDi5MI.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}=r(()=>l.queues(500),[],{intervalMs:3e4}),{events:k,counters:A,throughput:j,connected:M}=d(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))},[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)(m,{}),(0,y.jsx)(c,{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)(u,{label:`Total Events`,value:o(A.total),compact:!0}),(0,y.jsx)(u,{label:`Completed`,value:o(A.completed),tone:`green`,compact:!0}),(0,y.jsx)(u,{label:`Failed`,value:o(A.failed),tone:A.failed?`red`:`default`,compact:!0}),(0,y.jsx)(u,{label:`Waiting`,value:o(A.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(u,{label:`Active`,value:o(A.active),tone:`blue`,compact:!0}),(0,y.jsx)(u,{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)(a,{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)(i,{}),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:`Event`}),(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)(s,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.event||`job event`}),(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:f(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{h as t,r as n,t as r}from"./react-vendor-BcouBxpZ.js";import{A as i,J as a,O as o,c as s,g as c,h as l,m as u,nt as d,t as f,u as p,w as m,x as h}from"./index-BOcegTHa.js";import{a as g,i as _}from"./form-DGinTEEb.js";import{t as v}from"./Pagination-D4ki-pGz.js";var y=e(t(),1),b=r(),x=`__all__`,S=[`all`,`waiting`,`active`,`completed`,`failed`],C=10,w=250;function T(){let[e,t]=(0,y.useState)(x),[r,T]=(0,y.useState)(`all`),[E,D]=(0,y.useState)(``),[O,k]=(0,y.useState)(0),[A,j]=(0,y.useState)(null),M=A!==null,{data:N,error:P,refetch:F}=i(()=>d.queues(),[],{intervalMs:3e4}),{events:I,counters:L,throughput:R,connected:z}=f(e===x?void 0:e),B=(0,y.useMemo)(()=>{let e=A??I,t=E.trim().toLowerCase();return e.filter(e=>r!==`all`&&e.status!==r?!1:!t||(e.jobId??``).toLowerCase().includes(t)||(e.queue??``).toLowerCase().includes(t))},[I,A,r,E]),V=M?Math.max(0,(I[0]?.seq??0)-(A[0]?.seq??0)):0;(0,y.useEffect)(()=>k(0),[e,r,E]),(0,y.useEffect)(()=>j(null),[e]);let H=O*C,U=B.slice(H,H+C);return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(l,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:z&&!M}),P&&(0,b.jsx)(h,{onRetry:F}),(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)(u,{label:`Total Events`,value:s(L.total),compact:!0}),(0,b.jsx)(u,{label:`Completed`,value:s(L.completed),tone:`green`,compact:!0}),(0,b.jsx)(u,{label:`Failed`,value:s(L.failed),tone:L.failed?`red`:`default`,compact:!0}),(0,b.jsx)(u,{label:`Waiting`,value:s(L.waiting),tone:`amber`,compact:!0}),(0,b.jsx)(u,{label:`Active`,value:s(L.active),tone:`blue`,compact:!0}),(0,b.jsx)(u,{label:`Throughput`,value:`${R.toFixed(1)}/s`,tone:`accent`,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.jsxs)(g,{"aria-label":`Filter by queue`,value:e,onChange:e=>t(e.target.value),children:[(0,b.jsx)(`option`,{value:x,children:`All Queues`}),(N?.queues??[]).map(e=>(0,b.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,b.jsx)(_,{options:S,value:r,onChange:T}),(0,b.jsx)(m,{size:`sm`,variant:M?`warning`:`default`,onClick:()=>j(M?null:I),title:M?`Resume applying live events to the list`:`Freeze the visible list while the stream keeps buffering`,children:M?`Resume${V?` — ${s(V)} new`:``}`:`Following · Pause`}),(0,b.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,b.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,b.jsx)(`input`,{"aria-label":`Search by job ID or queue`,value:E,onChange:e=>D(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,b.jsxs)(`p`,{className:`-mt-2 mb-4 text-xs text-faint`,children:[`Search and filters cover the last `,w,` streamed events held in this browser.`]}),(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:`px-5 py-3 font-medium`,children:`Status`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,b.jsx)(`tbody`,{children:U.length===0?(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:z?I.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):U.map(e=>(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)(c,{status:e.status})}),(0,b.jsxs)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:[e.event,e.status===`failed`&&e.error&&(0,b.jsx)(`div`,{className:`mt-0.5 max-w-64 truncate text-[11px] text-danger`,title:e.error,children:e.error})]}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,title:new Date(e.timestamp).toISOString(),children:p(e.timestamp)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId?(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,b.jsx)(n,{to:`/job?id=${encodeURIComponent(e.jobId)}`,className:`text-accent hover:underline`,children:e.jobId}),(0,b.jsx)(o,{value:e.jobId})]}):`—`})]},e.seq))})]})}),(0,b.jsx)(v,{page:O,pageSize:C,total:B.length,onPageChange:k,label:`events`})]})}export{T as LogsPro};
1
+ import{r as e}from"./cn-CMFYpumL.js";import{h as t,r as n,t as r}from"./react-vendor-BcouBxpZ.js";import{A as i,J as a,O as o,c as s,g as c,h as l,m as u,nt as d,t as f,u as p,w as m,x as h}from"./index-r1ZMLIZ9.js";import{a as g,i as _}from"./form-DGinTEEb.js";import{t as v}from"./Pagination-B9JDi5MI.js";var y=e(t(),1),b=r(),x=`__all__`,S=[`all`,`waiting`,`active`,`completed`,`failed`],C=10,w=250;function T(){let[e,t]=(0,y.useState)(x),[r,T]=(0,y.useState)(`all`),[E,D]=(0,y.useState)(``),[O,k]=(0,y.useState)(0),[A,j]=(0,y.useState)(null),M=A!==null,{data:N,error:P,refetch:F}=i(()=>d.queues(),[],{intervalMs:3e4}),{events:I,counters:L,throughput:R,connected:z}=f(e===x?void 0:e),B=(0,y.useMemo)(()=>{let e=A??I,t=E.trim().toLowerCase();return e.filter(e=>r!==`all`&&e.status!==r?!1:!t||(e.jobId??``).toLowerCase().includes(t)||(e.queue??``).toLowerCase().includes(t))},[I,A,r,E]),V=M?Math.max(0,(I[0]?.seq??0)-(A[0]?.seq??0)):0;(0,y.useEffect)(()=>k(0),[e,r,E]),(0,y.useEffect)(()=>j(null),[e]);let H=O*C,U=B.slice(H,H+C);return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(l,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:z&&!M}),P&&(0,b.jsx)(h,{onRetry:F}),(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)(u,{label:`Total Events`,value:s(L.total),compact:!0}),(0,b.jsx)(u,{label:`Completed`,value:s(L.completed),tone:`green`,compact:!0}),(0,b.jsx)(u,{label:`Failed`,value:s(L.failed),tone:L.failed?`red`:`default`,compact:!0}),(0,b.jsx)(u,{label:`Waiting`,value:s(L.waiting),tone:`amber`,compact:!0}),(0,b.jsx)(u,{label:`Active`,value:s(L.active),tone:`blue`,compact:!0}),(0,b.jsx)(u,{label:`Throughput`,value:`${R.toFixed(1)}/s`,tone:`accent`,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.jsxs)(g,{"aria-label":`Filter by queue`,value:e,onChange:e=>t(e.target.value),children:[(0,b.jsx)(`option`,{value:x,children:`All Queues`}),(N?.queues??[]).map(e=>(0,b.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,b.jsx)(_,{options:S,value:r,onChange:T}),(0,b.jsx)(m,{size:`sm`,variant:M?`warning`:`default`,onClick:()=>j(M?null:I),title:M?`Resume applying live events to the list`:`Freeze the visible list while the stream keeps buffering`,children:M?`Resume${V?` — ${s(V)} new`:``}`:`Following · Pause`}),(0,b.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,b.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,b.jsx)(`input`,{"aria-label":`Search by job ID or queue`,value:E,onChange:e=>D(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,b.jsxs)(`p`,{className:`-mt-2 mb-4 text-xs text-faint`,children:[`Search and filters cover the last `,w,` streamed events held in this browser.`]}),(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:`px-5 py-3 font-medium`,children:`Status`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,b.jsx)(`tbody`,{children:U.length===0?(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:z?I.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):U.map(e=>(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)(c,{status:e.status})}),(0,b.jsxs)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:[e.event,e.status===`failed`&&e.error&&(0,b.jsx)(`div`,{className:`mt-0.5 max-w-64 truncate text-[11px] text-danger`,title:e.error,children:e.error})]}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,title:new Date(e.timestamp).toISOString(),children:p(e.timestamp)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId?(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,b.jsx)(n,{to:`/job?id=${encodeURIComponent(e.jobId)}`,className:`text-accent hover:underline`,children:e.jobId}),(0,b.jsx)(o,{value:e.jobId})]}):`—`})]},e.seq))})]})}),(0,b.jsx)(v,{page:O,pageSize:C,total:B.length,onPageChange:k,label:`events`})]})}export{T as LogsPro};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./react-vendor-BcouBxpZ.js";import{C as t,O as n,S as r,h as i,m as a}from"./index-BOcegTHa.js";var o=e(),s=`{
1
+ import{t as e}from"./react-vendor-BcouBxpZ.js";import{C as t,O as n,S as r,h as i,m as a}from"./index-r1ZMLIZ9.js";var o=e(),s=`{
2
2
  "mcpServers": {
3
3
  "bunqueue": {
4
4
  "command": "bunx",
@@ -1 +1 @@
1
- import{t as e}from"./react-vendor-BcouBxpZ.js";import{A as t,C as n,S as r,b as i,c as a,h as o,j as s,m as c,r as l,x as u}from"./index-BOcegTHa.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:_}=t(()=>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)(n,{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)(n,{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)(n,{title:`Latency — percentiles (ms)`}),(0,d.jsx)(h,{record:C,suffix:`ms`})]}),(0,d.jsxs)(r,{children:[(0,d.jsx)(n,{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)(n,{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};
1
+ import{t as e}from"./react-vendor-BcouBxpZ.js";import{A as t,C as n,S as r,b as i,c as a,h as o,j as s,m as c,r as l,x as u}from"./index-r1ZMLIZ9.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:_}=t(()=>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)(n,{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)(n,{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)(n,{title:`Latency — percentiles (ms)`}),(0,d.jsx)(h,{record:C,suffix:`ms`})]}),(0,d.jsxs)(r,{children:[(0,d.jsx)(n,{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)(n,{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};
@@ -1 +1 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r}from"./react-vendor-BcouBxpZ.js";import{A as i,C as a,S as o,b as s,c,d as l,h as u,i as d,l as f,m as p,n as m,nt as h,x as g}from"./index-BOcegTHa.js";import{t as _}from"./Pagination-D4ki-pGz.js";import{t as v}from"./AreaChart-2gM0YoZT.js";import{n as y,t as b}from"./useThroughputSeries-Chp5OLx3.js";var x=e(n(),1),S=r(),C=[`-60s`,`-45s`,`-30s`,`-15s`,`now`],w=15,T=[`push`,`pull`,`ack`],E=100,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=y(60),[n,r]=(0,x.useState)(0),{data:O,error:M,loading:N,refetch:P}=i(async()=>({details:await h.queuesSummary()}),[]),F=O?.details??[],I=Math.max(1,Math.ceil(F.length/w)),L=Math.min(n,I-1),R=(0,x.useMemo)(()=>F.slice(L*w,L*w+w),[F,L]),z=(0,x.useMemo)(()=>F.reduce((e,t)=>e+(t.counts?.failed??0),0),[F]);if(N&&!O&&!M)return(0,S.jsx)(s,{label:`Loading metrics…`});let{stats:B,throughput:V,latency:H}=e.latest??D,U=m(B.completed,z),W=b(e.depth),G=e.depth.length?e.depth[e.depth.length-1]:0;return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(u,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:!M}),M&&(0,S.jsx)(g,{onRetry:P}),(0,S.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,S.jsx)(p,{label:`Total Completed`,value:d(B.completed),tone:`green`,hint:`recorded jobs`}),(0,S.jsx)(p,{label:`Total Failed`,value:c(z),tone:z?`red`:`default`,hint:`recorded jobs`}),(0,S.jsx)(p,{label:`Push/sec`,value:V.pushPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`}),(0,S.jsx)(p,{label:`Pull/sec`,value:V.pullPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`})]}),(0,S.jsxs)(o,{className:`mb-6`,children:[(0,S.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,S.jsx)(A,{color:`#ec4899`,label:`Pushed`,value:V.pushPerSec}),(0,S.jsx)(A,{color:`#34d399`,label:`Completed`,value:V.completePerSec}),(0,S.jsx)(A,{color:`#f87171`,label:`Failed`,value:V.failPerSec})]})]}),(0,S.jsx)(v,{xLabels:C,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,S.jsxs)(o,{className:`mb-6`,children:[(0,S.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,S.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,S.jsxs)(`div`,{className:`text-right`,children:[(0,S.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:c(G)}),(0,S.jsx)(`div`,{className:t(`text-xs font-medium`,W.label===`draining`?`text-success`:W.label===`accumulating`?`text-danger`:`text-faint`),children:W.label===`steady`?`steady`:`${W.slope>0?`+`:``}${W.slope.toFixed(1)}/s · ${W.label}`})]})]}),(0,S.jsx)(v,{xLabels:C,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:W.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]})]}),(0,S.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,S.jsxs)(o,{children:[(0,S.jsx)(a,{title:`Error Rate`}),(0,S.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,U!=null&&U>.05?`text-danger`:`text-fg`),children:U==null?`—`:f(U)}),(0,S.jsx)(`div`,{className:`text-xs text-faint`,children:`error rate`})]}),(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,U==null?`text-fg`:`text-success`),children:U==null?`—`:f(1-U)}),(0,S.jsx)(`div`,{className:`text-xs text-faint`,children:`success rate`})]})]}),U==null?(0,S.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,S.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-U)*100}%`}})})]}),(0,S.jsxs)(o,{children:[(0,S.jsx)(a,{title:`Server Overview`}),(0,S.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,S.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,S.jsx)(j,{color:`bg-blue-400`,label:`Queued`,value:c(B.waiting)}),(0,S.jsx)(j,{color:`bg-accent`,label:`Processing`,value:c(B.active)}),(0,S.jsx)(j,{color:`bg-amber-400`,label:`Delayed`,value:c(B.delayed)}),(0,S.jsx)(j,{color:`bg-red-400`,label:`Dead Letter`,value:c(B.dlq)}),(0,S.jsx)(j,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:d(B.totalPushed)}),(0,S.jsx)(j,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:d(B.totalPulled)}),(0,S.jsx)(j,{color:`bg-emerald-400`,label:`Uptime`,value:l(B.uptime/1e3)})]})]})]}),(0,S.jsxs)(o,{className:`mb-6`,padded:!1,children:[(0,S.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,S.jsx)(`tbody`,{children:T.map(e=>{let n=H?.percentiles?.[e],r=H?.averages?.[`${e}Ms`];return(0,S.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,S.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:e}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(r)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n?.p50)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n?.p95)}),(0,S.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(n?.p99??0)>E?`text-warning`:`text-muted`),children:k(n?.p99)})]},e)})})]})})]}),(0,S.jsxs)(o,{padded:!1,children:[(0,S.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,S.jsx)(`tbody`,{children:R.length===0?(0,S.jsx)(`tr`,{children:(0,S.jsx)(`td`,{colSpan:6,className:`px-5 py-12 text-center text-sm text-faint`,children:`No queues yet.`})}):R.map(e=>(0,S.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,S.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,S.jsx)(`td`,{className:`px-5 py-3`,children:(0,S.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,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:c(e.counts.waiting)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:c(e.counts.active)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:c(e.counts.completed)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:c(e.counts.failed)})]},e.name))})]})}),(0,S.jsx)(`div`,{className:`px-5 pb-4`,children:(0,S.jsx)(_,{page:L,pageSize:w,total:F.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,S.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,S.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,S.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}function j({color:e,label:n,value:r}){return(0,S.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,S.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,S.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,S.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}export{O as MetricsPro};
1
+ import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r}from"./react-vendor-BcouBxpZ.js";import{A as i,C as a,S as o,b as s,c,d as l,h as u,i as d,l as f,m as p,n as m,nt as h,x as g}from"./index-r1ZMLIZ9.js";import{t as _}from"./Pagination-B9JDi5MI.js";import{t as v}from"./AreaChart-2gM0YoZT.js";import{n as y,t as b}from"./useThroughputSeries-CVKzWzdv.js";var x=e(n(),1),S=r(),C=[`-60s`,`-45s`,`-30s`,`-15s`,`now`],w=15,T=[`push`,`pull`,`ack`],E=100,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=y(60),[n,r]=(0,x.useState)(0),{data:O,error:M,loading:N,refetch:P}=i(async()=>({details:await h.queuesSummary()}),[]),F=O?.details??[],I=Math.max(1,Math.ceil(F.length/w)),L=Math.min(n,I-1),R=(0,x.useMemo)(()=>F.slice(L*w,L*w+w),[F,L]),z=(0,x.useMemo)(()=>F.reduce((e,t)=>e+(t.counts?.failed??0),0),[F]);if(N&&!O&&!M)return(0,S.jsx)(s,{label:`Loading metrics…`});let{stats:B,throughput:V,latency:H}=e.latest??D,U=m(B.completed,z),W=b(e.depth),G=e.depth.length?e.depth[e.depth.length-1]:0;return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(u,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:!M}),M&&(0,S.jsx)(g,{onRetry:P}),(0,S.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,S.jsx)(p,{label:`Total Completed`,value:d(B.completed),tone:`green`,hint:`recorded jobs`}),(0,S.jsx)(p,{label:`Total Failed`,value:c(z),tone:z?`red`:`default`,hint:`recorded jobs`}),(0,S.jsx)(p,{label:`Push/sec`,value:V.pushPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`}),(0,S.jsx)(p,{label:`Pull/sec`,value:V.pullPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`})]}),(0,S.jsxs)(o,{className:`mb-6`,children:[(0,S.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,S.jsx)(A,{color:`#ec4899`,label:`Pushed`,value:V.pushPerSec}),(0,S.jsx)(A,{color:`#34d399`,label:`Completed`,value:V.completePerSec}),(0,S.jsx)(A,{color:`#f87171`,label:`Failed`,value:V.failPerSec})]})]}),(0,S.jsx)(v,{xLabels:C,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,S.jsxs)(o,{className:`mb-6`,children:[(0,S.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,S.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,S.jsxs)(`div`,{className:`text-right`,children:[(0,S.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:c(G)}),(0,S.jsx)(`div`,{className:t(`text-xs font-medium`,W.label===`draining`?`text-success`:W.label===`accumulating`?`text-danger`:`text-faint`),children:W.label===`steady`?`steady`:`${W.slope>0?`+`:``}${W.slope.toFixed(1)}/s · ${W.label}`})]})]}),(0,S.jsx)(v,{xLabels:C,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:W.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]})]}),(0,S.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,S.jsxs)(o,{children:[(0,S.jsx)(a,{title:`Error Rate`}),(0,S.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,U!=null&&U>.05?`text-danger`:`text-fg`),children:U==null?`—`:f(U)}),(0,S.jsx)(`div`,{className:`text-xs text-faint`,children:`error rate`})]}),(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,U==null?`text-fg`:`text-success`),children:U==null?`—`:f(1-U)}),(0,S.jsx)(`div`,{className:`text-xs text-faint`,children:`success rate`})]})]}),U==null?(0,S.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,S.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-U)*100}%`}})})]}),(0,S.jsxs)(o,{children:[(0,S.jsx)(a,{title:`Server Overview`}),(0,S.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,S.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,S.jsx)(j,{color:`bg-blue-400`,label:`Queued`,value:c(B.waiting)}),(0,S.jsx)(j,{color:`bg-accent`,label:`Processing`,value:c(B.active)}),(0,S.jsx)(j,{color:`bg-amber-400`,label:`Delayed`,value:c(B.delayed)}),(0,S.jsx)(j,{color:`bg-red-400`,label:`Dead Letter`,value:c(B.dlq)}),(0,S.jsx)(j,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:d(B.totalPushed)}),(0,S.jsx)(j,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:d(B.totalPulled)}),(0,S.jsx)(j,{color:`bg-emerald-400`,label:`Uptime`,value:l(B.uptime/1e3)})]})]})]}),(0,S.jsxs)(o,{className:`mb-6`,padded:!1,children:[(0,S.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,S.jsx)(`tbody`,{children:T.map(e=>{let n=H?.percentiles?.[e],r=H?.averages?.[`${e}Ms`];return(0,S.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,S.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:e}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(r)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n?.p50)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n?.p95)}),(0,S.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(n?.p99??0)>E?`text-warning`:`text-muted`),children:k(n?.p99)})]},e)})})]})})]}),(0,S.jsxs)(o,{padded:!1,children:[(0,S.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,S.jsx)(`tbody`,{children:R.length===0?(0,S.jsx)(`tr`,{children:(0,S.jsx)(`td`,{colSpan:6,className:`px-5 py-12 text-center text-sm text-faint`,children:`No queues yet.`})}):R.map(e=>(0,S.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,S.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,S.jsx)(`td`,{className:`px-5 py-3`,children:(0,S.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,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:c(e.counts.waiting)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:c(e.counts.active)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:c(e.counts.completed)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:c(e.counts.failed)})]},e.name))})]})}),(0,S.jsx)(`div`,{className:`px-5 pb-4`,children:(0,S.jsx)(_,{page:L,pageSize:w,total:F.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,S.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,S.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,S.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}function j({color:e,label:n,value:r}){return(0,S.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,S.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,S.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,S.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}export{O as MetricsPro};
@@ -1 +1 @@
1
- import{t as e}from"./react-vendor-BcouBxpZ.js";import{A as t,C as n,L as r,S as i,X as a,b as o,c as s,d as c,h as l,j as u,l as d,m as f,n as p,r as m,x as h}from"./index-BOcegTHa.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}=t(()=>u.overview(),[]);if(x&&!e&&!v)return(0,g.jsx)(o,{label:`Loading overview…`});let{stats:C,throughput:w,memory:T,workers:E,crons:D,storage:O}=e??_,k=p(C.totalCompleted,C.totalFailed)??0;return(0,g.jsxs)(`div`,{children:[v&&(0,g.jsx)(h,{onRetry:S}),(0,g.jsx)(l,{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)(f,{label:`Waiting`,value:s(C.waiting),tone:`amber`}),(0,g.jsx)(f,{label:`Active`,value:s(C.active),tone:`blue`}),(0,g.jsx)(f,{label:`Completed`,value:s(C.totalCompleted),tone:`green`}),(0,g.jsx)(f,{label:`Failed`,value:s(C.totalFailed),tone:`red`}),(0,g.jsx)(f,{label:`DLQ`,value:s(C.dlq),tone:C.dlq>0?`red`:`default`}),(0,g.jsx)(f,{label:`Error Rate`,value:d(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)(n,{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)(n,{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:c(C.uptime/1e3)}),(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)(n,{title:`Workers`,icon:(0,g.jsx)(a,{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(`, `)||`—`,` · `,s(e.processedJobs),` done`]})]},e.id))})]}),(0,g.jsxs)(i,{children:[(0,g.jsx)(n,{title:`Cron Jobs`,icon:(0,g.jsx)(r,{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
+ import{t as e}from"./react-vendor-BcouBxpZ.js";import{A as t,C as n,L as r,S as i,X as a,b as o,c as s,d as c,h as l,j as u,l as d,m as f,n as p,r as m,x as h}from"./index-r1ZMLIZ9.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}=t(()=>u.overview(),[]);if(x&&!e&&!v)return(0,g.jsx)(o,{label:`Loading overview…`});let{stats:C,throughput:w,memory:T,workers:E,crons:D,storage:O}=e??_,k=p(C.totalCompleted,C.totalFailed)??0;return(0,g.jsxs)(`div`,{children:[v&&(0,g.jsx)(h,{onRetry:S}),(0,g.jsx)(l,{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)(f,{label:`Waiting`,value:s(C.waiting),tone:`amber`}),(0,g.jsx)(f,{label:`Active`,value:s(C.active),tone:`blue`}),(0,g.jsx)(f,{label:`Completed`,value:s(C.totalCompleted),tone:`green`}),(0,g.jsx)(f,{label:`Failed`,value:s(C.totalFailed),tone:`red`}),(0,g.jsx)(f,{label:`DLQ`,value:s(C.dlq),tone:C.dlq>0?`red`:`default`}),(0,g.jsx)(f,{label:`Error Rate`,value:d(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)(n,{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)(n,{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:c(C.uptime/1e3)}),(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)(n,{title:`Workers`,icon:(0,g.jsx)(a,{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(`, `)||`—`,` · `,s(e.processedJobs),` done`]})]},e.id))})]}),(0,g.jsxs)(i,{children:[(0,g.jsx)(n,{title:`Cron Jobs`,icon:(0,g.jsx)(r,{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{h as t,t as n}from"./react-vendor-BcouBxpZ.js";import{c as r}from"./index-BOcegTHa.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};
1
+ import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-BcouBxpZ.js";import{c as r}from"./index-r1ZMLIZ9.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{h as t,t as n}from"./react-vendor-BcouBxpZ.js";import{C as r,S as i,nt as a,w as o}from"./index-r1ZMLIZ9.js";import{n as s,o as c,t as l}from"./form-DGinTEEb.js";var u=e(t(),1),d=n();function f(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return JSON.stringify(Object.keys(t).sort().map(e=>[e,t[e]]))}return JSON.stringify(e)}function p(e){let[t,n]=(0,u.useState)(e),r=(0,u.useRef)(f(e));return(0,u.useEffect)(()=>{let t=f(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n,()=>{let e=r.current;return t=>{r.current===e&&(r.current=f(t))}}]}function m(e){let t=String(e).trim();if(t===``)return null;let n=Number(t);return Number.isFinite(n)?n:null}function h({queue:e,config:t,onSaved:n}){let[f,h,g]=p(t),[_,v]=(0,u.useState)(null),[y,b]=(0,u.useState)(!1),[x,S]=(0,u.useState)(!1);return(0,d.jsxs)(i,{children:[(0,d.jsx)(r,{title:`Stall detection`}),(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,d.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,d.jsx)(c,{checked:f.enabled,onChange:e=>h({...f,enabled:e}),label:`enabled`}),(0,d.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`enabled`})]}),(0,d.jsx)(l,{label:`Stall interval (ms)`,children:(0,d.jsx)(s,{type:`number`,value:f.stallInterval,onChange:e=>h({...f,stallInterval:e.target.value})})}),(0,d.jsx)(l,{label:`Max stalls`,children:(0,d.jsx)(s,{type:`number`,value:f.maxStalls,onChange:e=>h({...f,maxStalls:e.target.value})})}),(0,d.jsx)(l,{label:`Grace period (ms)`,children:(0,d.jsx)(s,{type:`number`,value:f.gracePeriod,onChange:e=>h({...f,gracePeriod:e.target.value})})})]}),(0,d.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,d.jsx)(o,{variant:`accent`,size:`sm`,disabled:y,onClick:async()=>{let t=m(f.stallInterval),r=m(f.maxStalls),i=m(f.gracePeriod);if(t==null||r==null||i==null){v(`All numeric fields must be filled in`);return}b(!0),S(!1);try{v(null);let o={...f,stallInterval:t,maxStalls:r,gracePeriod:i},s=g();await a.setStallConfig(e,o),s(o),n(),S(!0),window.setTimeout(()=>S(!1),2e3)}catch(e){v(e.message)}finally{b(!1)}},children:`Save`}),x&&(0,d.jsx)(`span`,{className:`text-xs text-success`,children:`Saved ✓`}),_&&(0,d.jsx)(`span`,{className:`text-xs text-danger`,children:_})]})]})}function g({queue:e,config:t,onSaved:n}){let[f,h,g]=p(t),[_,v]=(0,u.useState)(null),[y,b]=(0,u.useState)(!1),[x,S]=(0,u.useState)(!1);return(0,d.jsxs)(i,{children:[(0,d.jsx)(r,{title:`DLQ policy`}),(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,d.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,d.jsx)(c,{checked:f.autoRetry,onChange:e=>h({...f,autoRetry:e}),label:`auto-retry`}),(0,d.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`auto-retry`})]}),(0,d.jsx)(l,{label:`Retry interval (ms)`,children:(0,d.jsx)(s,{type:`number`,value:f.autoRetryInterval,onChange:e=>h({...f,autoRetryInterval:e.target.value})})}),(0,d.jsx)(l,{label:`Max auto-retries`,children:(0,d.jsx)(s,{type:`number`,value:f.maxAutoRetries,onChange:e=>h({...f,maxAutoRetries:e.target.value})})}),(0,d.jsx)(l,{label:`Max age (ms)`,children:(0,d.jsx)(s,{type:`number`,value:f.maxAge??``,onChange:e=>h({...f,maxAge:e.target.value})})}),(0,d.jsx)(l,{label:`Max entries`,children:(0,d.jsx)(s,{type:`number`,value:f.maxEntries,onChange:e=>h({...f,maxEntries:e.target.value})})})]}),(0,d.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,d.jsx)(o,{variant:`accent`,size:`sm`,disabled:y,onClick:async()=>{let t=m(f.autoRetryInterval),r=m(f.maxAutoRetries),i=m(f.maxEntries),o=f.maxAge==null?null:m(f.maxAge);if(t==null||r==null||i==null){v(`All numeric fields must be filled in`);return}b(!0),S(!1);try{v(null);let s={...f,autoRetryInterval:t,maxAutoRetries:r,maxAge:o,maxEntries:i},c=g();await a.setDlqConfig(e,s),c(s),n(),S(!0),window.setTimeout(()=>S(!1),2e3)}catch(e){v(e.message)}finally{b(!1)}},children:`Save`}),x&&(0,d.jsx)(`span`,{className:`text-xs text-success`,children:`Saved ✓`}),_&&(0,d.jsx)(`span`,{className:`text-xs text-danger`,children:_})]})]})}function _({title:e,onRetry:t}){return(0,d.jsxs)(i,{children:[(0,d.jsx)(r,{title:e}),(0,d.jsx)(`p`,{className:`mb-3 text-sm text-muted`,children:`Couldn't load this queue's config.`}),(0,d.jsx)(o,{size:`sm`,onClick:t,children:`Retry`})]})}function v(e,t){let n=Number(e),r=Number(t);return{grace:n,limit:r,valid:e.trim()!==``&&t.trim()!==``&&Number.isFinite(n)&&Number.isFinite(r)&&n>=0&&r>0}}function y({queue:e,paused:t,busy:n,run:c}){let[f,p]=(0,u.useState)(`0`),[m,h]=(0,u.useState)(`1000`),[g,_]=(0,u.useState)(``),y=v(f,m);return(0,d.jsxs)(i,{className:`mb-6`,children:[(0,d.jsx)(r,{title:`Lifecycle`}),(0,d.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,d.jsx)(o,{variant:`success`,size:`sm`,disabled:n,onClick:()=>c(`Resumed`,()=>a.resume(e)),children:`Resume`}):(0,d.jsx)(o,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>c(`Paused`,()=>a.pause(e)),children:`Pause`}),(0,d.jsx)(o,{size:`sm`,disabled:n,onClick:()=>c(`Retried completed`,()=>a.retryCompleted(e)),children:`Retry completed`}),(0,d.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,d.jsx)(`div`,{className:`w-24`,children:(0,d.jsx)(l,{label:`Promote N`,children:(0,d.jsx)(s,{type:`number`,value:g,onChange:e=>_(e.target.value),placeholder:`all`})})}),(0,d.jsx)(o,{size:`sm`,disabled:n,onClick:()=>c(`Promoted`,()=>a.promoteJobs(e,g?Number(g):void 0)),children:`Promote delayed`})]})]}),(0,d.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3`,children:[(0,d.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Destructive — these permanently remove jobs`}),(0,d.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,d.jsx)(o,{size:`sm`,disabled:n,onClick:()=>c(`Drained`,()=>a.drain(e),`Drain waiting jobs from "${e}"?`),children:`Drain`}),(0,d.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,d.jsx)(`div`,{className:`w-24`,children:(0,d.jsx)(l,{label:`Grace (ms)`,children:(0,d.jsx)(s,{type:`number`,value:f,onChange:e=>p(e.target.value)})})}),(0,d.jsx)(`div`,{className:`w-24`,children:(0,d.jsx)(l,{label:`Limit`,children:(0,d.jsx)(s,{type:`number`,value:m,onChange:e=>h(e.target.value)})})}),(0,d.jsx)(o,{variant:`danger`,size:`sm`,disabled:n||!y.valid,onClick:()=>c(`Cleaned`,()=>a.clean(e,{grace:y.grace,limit:y.limit}),`Permanently delete up to ${y.limit} completed/failed jobs older than ${y.grace}ms from "${e}"?`),children:`Clean`})]})]})]})]})}function b({queue:e,busy:t,run:n}){let[c,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(``);return(0,d.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,d.jsxs)(i,{children:[(0,d.jsx)(r,{title:`Rate limit`}),(0,d.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,d.jsx)(`div`,{className:`flex-1`,children:(0,d.jsx)(l,{label:`Limit`,children:(0,d.jsx)(s,{type:`number`,value:c,onChange:e=>f(e.target.value),placeholder:`max per window`})})}),(0,d.jsx)(o,{variant:`accent`,size:`sm`,disabled:t||!c,onClick:()=>n(`Rate limit set`,()=>a.setRateLimit(e,Number(c))),children:`Set`}),(0,d.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Rate limit cleared`,()=>a.clearRateLimit(e)),children:`Clear`})]})]}),(0,d.jsxs)(i,{children:[(0,d.jsx)(r,{title:`Concurrency`}),(0,d.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,d.jsx)(`div`,{className:`flex-1`,children:(0,d.jsx)(l,{label:`Concurrency`,children:(0,d.jsx)(s,{type:`number`,value:p,onChange:e=>m(e.target.value),placeholder:`max in-flight`})})}),(0,d.jsx)(o,{variant:`accent`,size:`sm`,disabled:t||!p,onClick:()=>n(`Concurrency set`,()=>a.setConcurrency(e,Number(p))),children:`Set`}),(0,d.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Concurrency cleared`,()=>a.clearConcurrency(e)),children:`Clear`})]})]})]})}export{h as a,g as i,b as n,_ as r,y as t};
@@ -1 +1 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-BcouBxpZ.js";import{A as r,_ as i,b as a,c as o,h as s,m as c,nt as l,x as u}from"./index-BOcegTHa.js";import{a as d}from"./form-DGinTEEb.js";import{a as f,i as p,n as m,r as h,t as g}from"./QueueActions-DHoSkWRz.js";var _=e(t(),1),v=n(),y=[`waiting`,`active`,`completed`,`failed`,`delayed`,`paused`];function b(){let[e,t]=(0,_.useState)(``),[n,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),{data:C}=r(()=>l.queues(),[],{intervalMs:3e4});(0,_.useEffect)(()=>{!e&&C?.queues?.length&&t(C.queues[0].name)},[C,e]);let{data:w,error:T,loading:E,refetch:D}=r((0,_.useCallback)(async()=>{if(!e)return null;let[t,n,r]=await Promise.all([l.queueDetail(e,!1),l.getStallConfig(e).catch(()=>null),l.getDlqConfig(e).catch(()=>null)]);return{queue:e,detail:t,stall:n?.config??null,dlq:r?.config??null}},[e]),[e]),O=w&&w.queue===e?w:null,k=(e,t,n)=>{n&&!window.confirm(n)||(b(!0),S(null),t().then(t=>{let n=t?.count;S({ok:!0,text:`${e}${n==null?` ✓`:`: ${n}`}`}),D()}).catch(e=>S({ok:!1,text:e.message})).finally(()=>b(!1)))};return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(s,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!0}),(0,v.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,v.jsx)(`div`,{className:`w-56`,children:(0,v.jsx)(d,{value:e,"aria-label":`Queue`,onChange:e=>t(e.target.value),children:(C?.queues??[]).map(e=>(0,v.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),O?.detail&&(0,v.jsx)(i,{label:O.detail.paused?`Paused`:`Active`,tone:O.detail.paused?`amber`:`green`}),x&&(0,v.jsx)(`span`,{role:`status`,className:x.ok?`text-xs text-success`:`text-xs text-danger`,children:x.text})]}),T&&(0,v.jsx)(u,{onRetry:D}),E&&!O&&!T?(0,v.jsx)(a,{}):O?.detail?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`mb-6 grid grid-cols-3 gap-3 md:grid-cols-6`,children:y.map(e=>(0,v.jsx)(c,{label:e,value:o(O.detail.counts[e]),compact:!0},e))}),(0,v.jsx)(g,{queue:e,paused:O.detail.paused,busy:n,run:k}),(0,v.jsx)(m,{queue:e,busy:n,run:k}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[O.stall?(0,v.jsx)(f,{queue:e,config:O.stall,onSaved:()=>S({ok:!0,text:`Stall config saved ✓`})},e):(0,v.jsx)(h,{title:`Stall detection`,onRetry:D}),O.dlq?(0,v.jsx)(p,{queue:e,config:O.dlq,onSaved:()=>S({ok:!0,text:`DLQ config saved ✓`})},e):(0,v.jsx)(h,{title:`DLQ policy`,onRetry:D})]})]}):!T&&(0,v.jsx)(`p`,{className:`text-sm text-faint`,children:`Select a queue.`})]})}export{b as QueueControl};
1
+ import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-BcouBxpZ.js";import{A as r,_ as i,b as a,c as o,h as s,m as c,nt as l,x as u}from"./index-r1ZMLIZ9.js";import{a as d}from"./form-DGinTEEb.js";import{a as f,i as p,n as m,r as h,t as g}from"./QueueActions-DJTw0h2g.js";var _=e(t(),1),v=n(),y=[`waiting`,`active`,`completed`,`failed`,`delayed`,`paused`];function b(){let[e,t]=(0,_.useState)(``),[n,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),{data:C}=r(()=>l.queues(),[],{intervalMs:3e4});(0,_.useEffect)(()=>{!e&&C?.queues?.length&&t(C.queues[0].name)},[C,e]);let{data:w,error:T,loading:E,refetch:D}=r((0,_.useCallback)(async()=>{if(!e)return null;let[t,n,r]=await Promise.all([l.queueDetail(e,!1),l.getStallConfig(e).catch(()=>null),l.getDlqConfig(e).catch(()=>null)]);return{queue:e,detail:t,stall:n?.config??null,dlq:r?.config??null}},[e]),[e]),O=w&&w.queue===e?w:null,k=(e,t,n)=>{n&&!window.confirm(n)||(b(!0),S(null),t().then(t=>{let n=t?.count;S({ok:!0,text:`${e}${n==null?` ✓`:`: ${n}`}`}),D()}).catch(e=>S({ok:!1,text:e.message})).finally(()=>b(!1)))};return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(s,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!0}),(0,v.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,v.jsx)(`div`,{className:`w-56`,children:(0,v.jsx)(d,{value:e,"aria-label":`Queue`,onChange:e=>t(e.target.value),children:(C?.queues??[]).map(e=>(0,v.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),O?.detail&&(0,v.jsx)(i,{label:O.detail.paused?`Paused`:`Active`,tone:O.detail.paused?`amber`:`green`}),x&&(0,v.jsx)(`span`,{role:`status`,className:x.ok?`text-xs text-success`:`text-xs text-danger`,children:x.text})]}),T&&(0,v.jsx)(u,{onRetry:D}),E&&!O&&!T?(0,v.jsx)(a,{}):O?.detail?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`mb-6 grid grid-cols-3 gap-3 md:grid-cols-6`,children:y.map(e=>(0,v.jsx)(c,{label:e,value:o(O.detail.counts[e]),compact:!0},e))}),(0,v.jsx)(g,{queue:e,paused:O.detail.paused,busy:n,run:k}),(0,v.jsx)(m,{queue:e,busy:n,run:k}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[O.stall?(0,v.jsx)(f,{queue:e,config:O.stall,onSaved:()=>S({ok:!0,text:`Stall config saved ✓`})},e):(0,v.jsx)(h,{title:`Stall detection`,onRetry:D}),O.dlq?(0,v.jsx)(p,{queue:e,config:O.dlq,onSaved:()=>S({ok:!0,text:`DLQ config saved ✓`})},e):(0,v.jsx)(h,{title:`DLQ policy`,onRetry:D})]})]}):!T&&(0,v.jsx)(`p`,{className:`text-sm text-faint`,children:`Select a queue.`})]})}export{b as QueueControl};
@@ -1 +1 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{d as t,h as n,r,t as i,u as a}from"./react-vendor-BcouBxpZ.js";import{A as o,M as s,P as c,S as l,T as u,U as d,V as f,W as p,X as m,_ as h,b as g,c as _,f as v,g as y,j as b,l as x,m as S,n as C,o as w,u as T,w as E,x as D}from"./index-BOcegTHa.js";import{n as O,t as k}from"./form-DGinTEEb.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)(l,{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)(f,{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(()=>b.setRateLimit(e,Number(t))),children:`Set`}),(0,j.jsx)(E,{size:`sm`,disabled:r,onClick:()=>o(()=>b.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)(l,{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)(m,{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(()=>b.setConcurrency(e,Number(t))),children:`Set`}),(0,j.jsx)(E,{size:`sm`,disabled:r,onClick:()=>o(()=>b.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=``}=t(),n=a(),[i,l]=(0,A.useState)(null),[f,m]=(0,A.useState)(null),{data:O,error:k,loading:N,refetch:P}=o((0,A.useCallback)(async()=>{let[t,n]=await Promise.all([b.queueDetail(e,!1),b.jobsList(e,{states:I,limit:12})]);return{detail:t,jobs:n.jobs??[]}},[e]),[e]),F=async(e,t,r)=>{if(!(r&&!window.confirm(r))){l(e),m(null);try{if(await t(),e===`obliterate`){n(`/queues`);return}await P()}catch(e){m(e.message)}finally{l(null)}}};if(N&&!O&&!k)return(0,j.jsx)(g,{label:`Loading ${e}…`});let R=O??L,{detail:z}=R,B=z.counts,V=C(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)(u,{"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)(h,{label:z.paused?`Paused`:`Active`,tone:z.paused?`amber`:`green`}),(0,j.jsx)(h,{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`,()=>b.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`,()=>b.pause(e)),children:[(0,j.jsx)(d,{className:`size-3.5`}),` Pause`]}),(0,j.jsx)(E,{size:`sm`,disabled:i!=null,onClick:()=>F(`drain`,()=>b.drain(e),`Drain all waiting jobs from "${e}"?`),children:`Drain`}),(0,j.jsx)(E,{variant:`danger`,size:`sm`,disabled:i!=null,onClick:()=>F(`obliterate`,()=>b.obliterate(e),`Obliterate "${e}"? This removes the queue and all its jobs.`),children:`Obliterate`})]})]}),f&&(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:f}),(0,j.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,j.jsx)(S,{label:`Waiting`,value:_(B.waiting),tone:`amber`}),(0,j.jsx)(S,{label:`Active`,value:_(B.active),tone:`blue`}),(0,j.jsx)(S,{label:`Completed`,value:_(B.completed),tone:`green`}),(0,j.jsx)(S,{label:`Failed`,value:_(B.failed),tone:B.failed?`red`:`default`}),(0,j.jsx)(S,{label:`Delayed`,value:_(B.delayed),tone:`default`}),(0,j.jsx)(S,{label:`Error Rate`,value:x(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)(s,{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)(y,{status:String(e.state??e.status??`waiting`)})}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:w(v(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
+ import{r as e}from"./cn-CMFYpumL.js";import{d as t,h as n,r,t as i,u as a}from"./react-vendor-BcouBxpZ.js";import{A as o,M as s,P as c,S as l,T as u,U as d,V as f,W as p,X as m,_ as h,b as g,c as _,f as v,g as y,j as b,l as x,m as S,n as C,o as w,u as T,w as E,x as D}from"./index-r1ZMLIZ9.js";import{n as O,t as k}from"./form-DGinTEEb.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)(l,{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)(f,{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(()=>b.setRateLimit(e,Number(t))),children:`Set`}),(0,j.jsx)(E,{size:`sm`,disabled:r,onClick:()=>o(()=>b.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)(l,{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)(m,{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(()=>b.setConcurrency(e,Number(t))),children:`Set`}),(0,j.jsx)(E,{size:`sm`,disabled:r,onClick:()=>o(()=>b.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=``}=t(),n=a(),[i,l]=(0,A.useState)(null),[f,m]=(0,A.useState)(null),{data:O,error:k,loading:N,refetch:P}=o((0,A.useCallback)(async()=>{let[t,n]=await Promise.all([b.queueDetail(e,!1),b.jobsList(e,{states:I,limit:12})]);return{detail:t,jobs:n.jobs??[]}},[e]),[e]),F=async(e,t,r)=>{if(!(r&&!window.confirm(r))){l(e),m(null);try{if(await t(),e===`obliterate`){n(`/queues`);return}await P()}catch(e){m(e.message)}finally{l(null)}}};if(N&&!O&&!k)return(0,j.jsx)(g,{label:`Loading ${e}…`});let R=O??L,{detail:z}=R,B=z.counts,V=C(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)(u,{"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)(h,{label:z.paused?`Paused`:`Active`,tone:z.paused?`amber`:`green`}),(0,j.jsx)(h,{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`,()=>b.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`,()=>b.pause(e)),children:[(0,j.jsx)(d,{className:`size-3.5`}),` Pause`]}),(0,j.jsx)(E,{size:`sm`,disabled:i!=null,onClick:()=>F(`drain`,()=>b.drain(e),`Drain all waiting jobs from "${e}"?`),children:`Drain`}),(0,j.jsx)(E,{variant:`danger`,size:`sm`,disabled:i!=null,onClick:()=>F(`obliterate`,()=>b.obliterate(e),`Obliterate "${e}"? This removes the queue and all its jobs.`),children:`Obliterate`})]})]}),f&&(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:f}),(0,j.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,j.jsx)(S,{label:`Waiting`,value:_(B.waiting),tone:`amber`}),(0,j.jsx)(S,{label:`Active`,value:_(B.active),tone:`blue`}),(0,j.jsx)(S,{label:`Completed`,value:_(B.completed),tone:`green`}),(0,j.jsx)(S,{label:`Failed`,value:_(B.failed),tone:B.failed?`red`:`default`}),(0,j.jsx)(S,{label:`Delayed`,value:_(B.delayed),tone:`default`}),(0,j.jsx)(S,{label:`Error Rate`,value:x(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)(s,{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)(y,{status:String(e.state??e.status??`waiting`)})}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:w(v(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{d as n,h as r,r as i,t as a,u as o}from"./react-vendor-BcouBxpZ.js";import{A as s,C as c,M as l,P as u,S as d,T as f,_ as p,b as m,c as h,h as g,l as _,m as v,n as ee,nt as y,o as b,rt as x,v as S,w as C,x as w}from"./index-BOcegTHa.js";import{t as T}from"./AreaChart-2gM0YoZT.js";import{t as E}from"./useThroughputSeries-Chp5OLx3.js";import{a as D,i as O,n as te,r as k,t as A}from"./QueueActions-DHoSkWRz.js";var j=e(r(),1),M=a(),N=[`waiting`,`active`,`completed`,`failed`,`delayed`,`paused`],P=[`active`,`waiting`,`completed`,`failed`,`delayed`],F=2e3;function I(){let{name:e=``}=n(),r=o(),[a,I]=(0,j.useState)(!1),[R,z]=(0,j.useState)(null),{data:B,error:V,loading:H,refetch:U}=s((0,j.useCallback)(async()=>{if(!e)return null;let[t,n,r,i]=await Promise.all([y.queueDetail(e,!1),y.getStallConfig(e).catch(()=>null),y.getDlqConfig(e).catch(()=>null),y.jobsList(e,P,12).catch(()=>({ok:!1,jobs:[]}))]);return{queue:e,detail:t,stall:n?.config??null,dlq:r?.config??null,jobs:i.jobs??[]}},[e]),[e]),W=B&&B.queue===e?B:null,[G,K]=(0,j.useState)([]),q=(0,j.useRef)(null);(0,j.useEffect)(()=>{let e=W?.detail?.counts;e&&(q.current=(e.waiting??0)+(e.active??0)+(e.delayed??0))},[W]),(0,j.useEffect)(()=>{q.current=null,K([]);let e=setInterval(()=>{let e=q.current;e!=null&&K(t=>[...t,e].slice(-40))},F);return()=>clearInterval(e)},[e]);let J=(t,n,r)=>{r&&!window.confirm(r)||(I(!0),z(null),n().then(n=>{let r=n?.count,i=`${t}${r==null?` ✓`:`: ${r}`}`;z({ok:!0,text:i}),x.success(i,e),U()}).catch(e=>{let n=e.message;z({ok:!1,text:n}),x.error(`${t} failed`,n)}).finally(()=>I(!1)))},Y=()=>{window.confirm(`Obliterate "${e}"? This removes the queue and all its jobs.`)&&(I(!0),y.obliterate(e).then(()=>{x.success(`Queue obliterated`,e),r(`/queues`)}).catch(e=>{let t=e.message;z({ok:!1,text:t}),x.error(`Obliterate failed`,t),I(!1)}))},X=W?.detail,Z=X?.counts,Q=Z?ee(Z.completed??0,Z.failed??0):null,$=E(G);return(0,M.jsxs)(`div`,{children:[(0,M.jsx)(g,{title:(0,M.jsx)(`span`,{className:`font-mono`,children:e}),description:`Full per-queue operations and live backlog.`,live:!0,back:(0,M.jsx)(f,{"aria-label":`Back to queues`,onClick:()=>r(`/queues`),children:(0,M.jsx)(u,{className:`size-4`})}),actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`Jobs `,(0,M.jsx)(l,{className:`size-3.5`})]}),(0,M.jsxs)(i,{to:`/dlq?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`DLQ `,(0,M.jsx)(l,{className:`size-3.5`})]}),(0,M.jsx)(C,{variant:`danger`,size:`sm`,disabled:a,onClick:Y,children:`Obliterate`})]})}),V&&(0,M.jsx)(w,{onRetry:U}),H&&!W&&!V?(0,M.jsx)(m,{label:`Loading ${e}…`}):!X||!Z?!V&&(0,M.jsx)(S,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,M.jsx)(i,{to:`/queues`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to queues`})}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,M.jsx)(p,{label:X.paused?`Paused`:`Active`,tone:X.paused?`amber`:`green`}),R&&(0,M.jsx)(`span`,{role:`status`,className:R.ok?`text-xs text-success`:`text-xs text-danger`,children:R.text})]}),(0,M.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6`,children:N.map(e=>(0,M.jsx)(v,{label:e,value:h(Z[e]),tone:e===`failed`&&Z.failed?`red`:`default`,compact:!0},e))}),(0,M.jsxs)(d,{padded:!1,className:`mb-6`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,M.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Recent jobs`}),(0,M.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,M.jsx)(l,{className:`size-3.5`})]})]}),(0,M.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,children:(0,M.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,M.jsx)(`thead`,{children:(0,M.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,M.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`ID`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`State`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Duration`})]})}),(0,M.jsx)(`tbody`,{children:W.jobs.length===0?(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{colSpan:4,className:`px-5 py-10 text-center text-sm text-faint`,children:`No recent jobs.`})}):W.jobs.map(e=>(0,M.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,M.jsx)(`td`,{className:`px-5 py-3`,children:(0,M.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.id})}),(0,M.jsx)(`td`,{className:`px-5 py-3 text-muted`,children:e.state??`—`}),(0,M.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[e.attempts??0,` / `,e.maxAttempts??`?`]}),(0,M.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)})]},e.id))})]})})]}),(0,M.jsx)(L,{counts:X.priorityCounts}),(0,M.jsxs)(d,{className:`mb-6`,children:[(0,M.jsx)(c,{title:`Backlog depth`,action:(0,M.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,$.draining?`bg-emerald-500/10 text-success`:$.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:$.label})}),G.length<2?(0,M.jsx)(`p`,{className:`py-6 text-center text-xs text-faint`,children:`Sampling… the backlog trend appears after a few polls.`}):(0,M.jsx)(T,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:G,area:!0}]}),(0,M.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-xs text-faint`,children:[(0,M.jsx)(`span`,{children:`waiting + active + delayed`}),(0,M.jsxs)(`span`,{className:`tnum`,children:[`Error rate `,Q==null?`—`:_(Q)]})]})]}),(0,M.jsx)(A,{queue:e,paused:X.paused,busy:a,run:J}),(0,M.jsx)(te,{queue:e,busy:a,run:J}),(0,M.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[W.stall?(0,M.jsx)(D,{queue:e,config:W.stall,onSaved:()=>{z({ok:!0,text:`Stall config saved ✓`}),x.success(`Stall config saved`,e)}},e):(0,M.jsx)(k,{title:`Stall detection`,onRetry:U}),W.dlq?(0,M.jsx)(O,{queue:e,config:W.dlq,onSaved:()=>{z({ok:!0,text:`DLQ config saved ✓`}),x.success(`DLQ config saved`,e)}},e):(0,M.jsx)(k,{title:`DLQ policy`,onRetry:U})]})]})]})}function L({counts:e}){let t=Object.entries(e??{}).map(([e,t])=>[Number(e),t]).filter(([,e])=>e>0).sort((e,t)=>t[0]-e[0]);if(t.length===0)return null;let n=Math.max(...t.map(([,e])=>e));return(0,M.jsxs)(d,{className:`mb-6`,children:[(0,M.jsx)(c,{title:`Jobs by priority`}),(0,M.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(([e,t])=>(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsxs)(`span`,{className:`w-16 shrink-0 text-right font-mono text-xs text-muted`,children:[`p`,e]}),(0,M.jsx)(`div`,{className:`h-4 flex-1 overflow-hidden rounded bg-surface-2`,children:(0,M.jsx)(`div`,{className:`h-full rounded bg-accent`,style:{width:`${Math.max(2,t/n*100)}%`}})}),(0,M.jsx)(`span`,{className:`w-14 shrink-0 tnum text-xs text-fg`,children:h(t)})]},e))}),(0,M.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:`Higher p = higher priority. Waiting jobs only.`})]})}export{I as QueueDetailPro};
1
+ import{r as e,t}from"./cn-CMFYpumL.js";import{d as n,h as r,r as i,t as a,u as o}from"./react-vendor-BcouBxpZ.js";import{A as s,C as c,M as l,P as u,S as d,T as f,_ as p,b as m,c as h,h as g,l as _,m as v,n as ee,nt as y,o as b,rt as x,v as S,w as C,x as w}from"./index-r1ZMLIZ9.js";import{t as T}from"./AreaChart-2gM0YoZT.js";import{t as E}from"./useThroughputSeries-CVKzWzdv.js";import{a as D,i as O,n as te,r as k,t as A}from"./QueueActions-DJTw0h2g.js";var j=e(r(),1),M=a(),N=[`waiting`,`active`,`completed`,`failed`,`delayed`,`paused`],P=[`active`,`waiting`,`completed`,`failed`,`delayed`],F=2e3;function I(){let{name:e=``}=n(),r=o(),[a,I]=(0,j.useState)(!1),[R,z]=(0,j.useState)(null),{data:B,error:V,loading:H,refetch:U}=s((0,j.useCallback)(async()=>{if(!e)return null;let[t,n,r,i]=await Promise.all([y.queueDetail(e,!1),y.getStallConfig(e).catch(()=>null),y.getDlqConfig(e).catch(()=>null),y.jobsList(e,P,12).catch(()=>({ok:!1,jobs:[]}))]);return{queue:e,detail:t,stall:n?.config??null,dlq:r?.config??null,jobs:i.jobs??[]}},[e]),[e]),W=B&&B.queue===e?B:null,[G,K]=(0,j.useState)([]),q=(0,j.useRef)(null);(0,j.useEffect)(()=>{let e=W?.detail?.counts;e&&(q.current=(e.waiting??0)+(e.active??0)+(e.delayed??0))},[W]),(0,j.useEffect)(()=>{q.current=null,K([]);let e=setInterval(()=>{let e=q.current;e!=null&&K(t=>[...t,e].slice(-40))},F);return()=>clearInterval(e)},[e]);let J=(t,n,r)=>{r&&!window.confirm(r)||(I(!0),z(null),n().then(n=>{let r=n?.count,i=`${t}${r==null?` ✓`:`: ${r}`}`;z({ok:!0,text:i}),x.success(i,e),U()}).catch(e=>{let n=e.message;z({ok:!1,text:n}),x.error(`${t} failed`,n)}).finally(()=>I(!1)))},Y=()=>{window.confirm(`Obliterate "${e}"? This removes the queue and all its jobs.`)&&(I(!0),y.obliterate(e).then(()=>{x.success(`Queue obliterated`,e),r(`/queues`)}).catch(e=>{let t=e.message;z({ok:!1,text:t}),x.error(`Obliterate failed`,t),I(!1)}))},X=W?.detail,Z=X?.counts,Q=Z?ee(Z.completed??0,Z.failed??0):null,$=E(G);return(0,M.jsxs)(`div`,{children:[(0,M.jsx)(g,{title:(0,M.jsx)(`span`,{className:`font-mono`,children:e}),description:`Full per-queue operations and live backlog.`,live:!0,back:(0,M.jsx)(f,{"aria-label":`Back to queues`,onClick:()=>r(`/queues`),children:(0,M.jsx)(u,{className:`size-4`})}),actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`Jobs `,(0,M.jsx)(l,{className:`size-3.5`})]}),(0,M.jsxs)(i,{to:`/dlq?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`DLQ `,(0,M.jsx)(l,{className:`size-3.5`})]}),(0,M.jsx)(C,{variant:`danger`,size:`sm`,disabled:a,onClick:Y,children:`Obliterate`})]})}),V&&(0,M.jsx)(w,{onRetry:U}),H&&!W&&!V?(0,M.jsx)(m,{label:`Loading ${e}…`}):!X||!Z?!V&&(0,M.jsx)(S,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,M.jsx)(i,{to:`/queues`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to queues`})}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,M.jsx)(p,{label:X.paused?`Paused`:`Active`,tone:X.paused?`amber`:`green`}),R&&(0,M.jsx)(`span`,{role:`status`,className:R.ok?`text-xs text-success`:`text-xs text-danger`,children:R.text})]}),(0,M.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6`,children:N.map(e=>(0,M.jsx)(v,{label:e,value:h(Z[e]),tone:e===`failed`&&Z.failed?`red`:`default`,compact:!0},e))}),(0,M.jsxs)(d,{padded:!1,className:`mb-6`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,M.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Recent jobs`}),(0,M.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,M.jsx)(l,{className:`size-3.5`})]})]}),(0,M.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,children:(0,M.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,M.jsx)(`thead`,{children:(0,M.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,M.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`ID`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`State`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Duration`})]})}),(0,M.jsx)(`tbody`,{children:W.jobs.length===0?(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{colSpan:4,className:`px-5 py-10 text-center text-sm text-faint`,children:`No recent jobs.`})}):W.jobs.map(e=>(0,M.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,M.jsx)(`td`,{className:`px-5 py-3`,children:(0,M.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.id})}),(0,M.jsx)(`td`,{className:`px-5 py-3 text-muted`,children:e.state??`—`}),(0,M.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[e.attempts??0,` / `,e.maxAttempts??`?`]}),(0,M.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)})]},e.id))})]})})]}),(0,M.jsx)(L,{counts:X.priorityCounts}),(0,M.jsxs)(d,{className:`mb-6`,children:[(0,M.jsx)(c,{title:`Backlog depth`,action:(0,M.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,$.draining?`bg-emerald-500/10 text-success`:$.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:$.label})}),G.length<2?(0,M.jsx)(`p`,{className:`py-6 text-center text-xs text-faint`,children:`Sampling… the backlog trend appears after a few polls.`}):(0,M.jsx)(T,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:G,area:!0}]}),(0,M.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-xs text-faint`,children:[(0,M.jsx)(`span`,{children:`waiting + active + delayed`}),(0,M.jsxs)(`span`,{className:`tnum`,children:[`Error rate `,Q==null?`—`:_(Q)]})]})]}),(0,M.jsx)(A,{queue:e,paused:X.paused,busy:a,run:J}),(0,M.jsx)(te,{queue:e,busy:a,run:J}),(0,M.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[W.stall?(0,M.jsx)(D,{queue:e,config:W.stall,onSaved:()=>{z({ok:!0,text:`Stall config saved ✓`}),x.success(`Stall config saved`,e)}},e):(0,M.jsx)(k,{title:`Stall detection`,onRetry:U}),W.dlq?(0,M.jsx)(O,{queue:e,config:W.dlq,onSaved:()=>{z({ok:!0,text:`DLQ config saved ✓`}),x.success(`DLQ config saved`,e)}},e):(0,M.jsx)(k,{title:`DLQ policy`,onRetry:U})]})]})]})}function L({counts:e}){let t=Object.entries(e??{}).map(([e,t])=>[Number(e),t]).filter(([,e])=>e>0).sort((e,t)=>t[0]-e[0]);if(t.length===0)return null;let n=Math.max(...t.map(([,e])=>e));return(0,M.jsxs)(d,{className:`mb-6`,children:[(0,M.jsx)(c,{title:`Jobs by priority`}),(0,M.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(([e,t])=>(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsxs)(`span`,{className:`w-16 shrink-0 text-right font-mono text-xs text-muted`,children:[`p`,e]}),(0,M.jsx)(`div`,{className:`h-4 flex-1 overflow-hidden rounded bg-surface-2`,children:(0,M.jsx)(`div`,{className:`h-full rounded bg-accent`,style:{width:`${Math.max(2,t/n*100)}%`}})}),(0,M.jsx)(`span`,{className:`w-14 shrink-0 tnum text-xs text-fg`,children:h(t)})]},e))}),(0,M.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:`Higher p = higher priority. Waiting jobs only.`})]})}export{I as QueueDetailPro};
@@ -1 +1 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r,u as i}from"./react-vendor-BcouBxpZ.js";import{A as a,G as o,J as s,M as c,b as l,c as u,h as d,j as f,m as p,x as m}from"./index-BOcegTHa.js";import{t as h}from"./Pagination-D4ki-pGz.js";var g=e(n(),1),_=r(),v=20,y={ok:!1,queues:[],total:0,limit:v,offset:0,timestamp:0};function b(){let e=i(),[n,r]=(0,g.useState)(``),[b,x]=(0,g.useState)(0),{data:S,error:C,loading:w,refetch:T}=a(()=>f.queues(v,b*v),[b]),{data:E}=a(()=>f.overview(),[]),D=S??y,O=(0,g.useMemo)(()=>{let e=D.queues,t=n.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)):e},[D,n]);if(w&&!S&&!C)return(0,_.jsx)(l,{label:`Loading queues…`});let k=E?.stats;return(0,_.jsxs)(`div`,{children:[C&&(0,_.jsx)(m,{onRetry:T}),(0,_.jsx)(d,{title:`Queues`,description:`${D.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:k?u(k.waiting):`—`,tone:`amber`,compact:!0}),(0,_.jsx)(p,{label:`Active`,value:k?u(k.active):`—`,tone:`blue`,compact:!0}),(0,_.jsx)(p,{label:`Delayed`,value:k?u(k.delayed):`—`,tone:`default`,compact:!0}),(0,_.jsx)(p,{label:`DLQ`,value:k?u(k.dlq):`—`,tone:k?.dlq?`red`:`default`,compact:!0})]}),(0,_.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,_.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,_.jsx)(`input`,{value:n,onChange:e=>r(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:O.length===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:n?`No queues match on this page.`:`No queues yet.`})}):O.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)(o,{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)(c,{className:`size-4 opacity-0 transition-opacity group-hover:opacity-100`})})]},n.name))})]})}),(0,_.jsx)(h,{page:b,pageSize:v,total:D.total,onPageChange:x,label:`queues`})]})}export{b as Queues};
1
+ import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r,u as i}from"./react-vendor-BcouBxpZ.js";import{A as a,G as o,J as s,M as c,b as l,c as u,h as d,j as f,m as p,x as m}from"./index-r1ZMLIZ9.js";import{t as h}from"./Pagination-B9JDi5MI.js";var g=e(n(),1),_=r(),v=20,y={ok:!1,queues:[],total:0,limit:v,offset:0,timestamp:0};function b(){let e=i(),[n,r]=(0,g.useState)(``),[b,x]=(0,g.useState)(0),{data:S,error:C,loading:w,refetch:T}=a(()=>f.queues(v,b*v),[b]),{data:E}=a(()=>f.overview(),[]),D=S??y,O=(0,g.useMemo)(()=>{let e=D.queues,t=n.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)):e},[D,n]);if(w&&!S&&!C)return(0,_.jsx)(l,{label:`Loading queues…`});let k=E?.stats;return(0,_.jsxs)(`div`,{children:[C&&(0,_.jsx)(m,{onRetry:T}),(0,_.jsx)(d,{title:`Queues`,description:`${D.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:k?u(k.waiting):`—`,tone:`amber`,compact:!0}),(0,_.jsx)(p,{label:`Active`,value:k?u(k.active):`—`,tone:`blue`,compact:!0}),(0,_.jsx)(p,{label:`Delayed`,value:k?u(k.delayed):`—`,tone:`default`,compact:!0}),(0,_.jsx)(p,{label:`DLQ`,value:k?u(k.dlq):`—`,tone:k?.dlq?`red`:`default`,compact:!0})]}),(0,_.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,_.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,_.jsx)(`input`,{value:n,onChange:e=>r(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:O.length===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:n?`No queues match on this page.`:`No queues yet.`})}):O.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)(o,{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)(c,{className:`size-4 opacity-0 transition-opacity group-hover:opacity-100`})})]},n.name))})]})}),(0,_.jsx)(h,{page:b,pageSize:v,total:D.total,onPageChange:x,label:`queues`})]})}export{b as Queues};
@@ -1 +1 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,r,t as i,u as a}from"./react-vendor-BcouBxpZ.js";import{A as o,G as s,J as c,M as l,T as u,U as d,W as f,b as p,c as m,h,m as g,nt as _,rt as v,w as y,x as b}from"./index-BOcegTHa.js";import{t as x}from"./Pagination-D4ki-pGz.js";import{t as S}from"./promisePool-Daxkc1OB.js";var C=e(n(),1),w=i(),T=6,E=15,D=[[`waiting`,`Waiting`],[`active`,`Active`],[`completed`,`Completed`],[`failed`,`Failed`],[`delayed`,`Delayed`]];function O(){let e=a(),[n,i]=(0,C.useState)(``),[O,k]=(0,C.useState)(0),[A,j]=(0,C.useState)(new Set),[M,N]=(0,C.useState)(!1),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(null),[R,z]=(0,C.useState)(`desc`),{data:B,error:V,loading:H,refetch:U}=o(()=>_.queuesSummary(),[]),W=B??[],G=e=>{I===e?R===`desc`?z(`asc`):L(null):(L(e),z(`desc`)),k(0)},K=(0,C.useMemo)(()=>{let e=n.trim().toLowerCase(),t=[...e?W.filter(t=>t.name.toLowerCase().includes(e)):W].sort((e,t)=>e.name.localeCompare(t.name));if(I){let e=R===`desc`?-1:1;t.sort((t,n)=>e*(t.counts[I]-n.counts[I]))}return t},[W,n,I,R]),q=(0,C.useMemo)(()=>W.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}),[W]),J=Math.max(1,Math.ceil(K.length/E)),Y=Math.min(O,J-1),X=K.slice(Y*E,Y*E+E),Z=async e=>{j(t=>new Set(t).add(e.name)),F(null);try{await(e.paused?_.resume(e.name):_.pause(e.name)),F({ok:!0,text:`${e.name} ${e.paused?`resumed`:`paused`} ✓`})}catch(t){F({ok:!1,text:t.message}),v.error(`Failed to ${e.paused?`resume`:`pause`} ${e.name}`,t.message)}finally{j(t=>{let n=new Set(t);return n.delete(e.name),n}),U()}},Q=async e=>{let t=W.filter(t=>e===`pause`?!t.paused:t.paused);if(t.length===0){v.info(`No queues to ${e}`);return}if(!window.confirm(`${e===`pause`?`Pause`:`Resume`} ${t.length} queue(s)?`))return;N(!0),F(null);let n=(await S(t,T,t=>e===`pause`?_.pause(t.name):_.resume(t.name))).filter(e=>e.status===`rejected`).length,r=`${e===`pause`?`Paused`:`Resumed`} ${t.length-n}/${t.length} queues${n?`, ${n} failed`:``}`;F({ok:n===0,text:r}),n===0?v.success(r):v.error(r),N(!1),U()};return H&&!B&&!V?(0,w.jsx)(p,{label:`Loading queues…`}):(0,w.jsxs)(`div`,{children:[(0,w.jsx)(h,{title:`Queues`,description:`${W.length} queues`,live:!0,actions:W.length>0?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(y,{variant:`warning`,size:`sm`,disabled:M||q.paused>=W.length,onClick:()=>Q(`pause`),children:[(0,w.jsx)(d,{className:`size-3.5`}),` Pause all`]}),(0,w.jsxs)(y,{variant:`success`,size:`sm`,disabled:M||q.paused===0,onClick:()=>Q(`resume`),children:[(0,w.jsx)(f,{className:`size-3.5`}),` Resume all`]})]}):void 0}),V&&(0,w.jsx)(b,{onRetry:U}),(0,w.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,w.jsx)(g,{label:`Waiting`,value:m(q.waiting),tone:`amber`,compact:!0}),(0,w.jsx)(g,{label:`Active`,value:m(q.active),tone:`blue`,compact:!0}),(0,w.jsx)(g,{label:`Failed`,value:m(q.failed),tone:q.failed?`red`:`default`,compact:!0}),(0,w.jsx)(g,{label:`Paused`,value:m(q.paused),tone:q.paused?`amber`:`default`,compact:!0})]}),(0,w.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,w.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,w.jsx)(`input`,{value:n,onChange:e=>{i(e.target.value),k(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`})]}),P&&(0,w.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,P.ok?`text-success`:`text-danger`),children:P.text}),(0,w.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,w.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,w.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Queue`}),D.map(([e,t])=>(0,w.jsx)(`th`,{scope:`col`,"aria-sort":I===e?R===`desc`?`descending`:`ascending`:void 0,className:`px-5 py-3 text-right font-medium`,children:(0,w.jsxs)(`button`,{type:`button`,onClick:()=>G(e),className:`inline-flex items-center gap-1 rounded uppercase tracking-wider hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[t,I===e&&(0,w.jsx)(`span`,{"aria-hidden":`true`,children:R===`desc`?`↓`:`↑`})]})},e)),(0,w.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Status`}),(0,w.jsx)(`th`,{scope:`col`,className:`w-24 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,w.jsx)(`tbody`,{children:X.length===0?(0,w.jsx)(`tr`,{children:(0,w.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:n?`No queues match your search.`:`No queues yet.`})}):X.map(n=>{let i=A.has(n.name);return(0,w.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,w.jsx)(`td`,{className:`px-5 py-3`,children:(0,w.jsxs)(r,{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,w.jsx)(s,{className:`size-4 text-faint`}),n.name]})}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:m(n.counts.waiting)}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:m(n.counts.active)}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:m(n.counts.completed)}),(0,w.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,n.counts.failed?`text-danger`:`text-muted`),children:m(n.counts.failed)}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:m(n.counts.delayed)}),(0,w.jsx)(`td`,{className:`px-5 py-3`,children:(0,w.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,w.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),n.paused?`Paused`:`Active`]})}),(0,w.jsx)(`td`,{className:`px-5 py-3`,children:(0,w.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,w.jsx)(u,{"aria-label":n.paused?`Resume queue`:`Pause queue`,disabled:i,onClick:e=>{e.stopPropagation(),Z(n)},children:n.paused?(0,w.jsx)(f,{className:`size-3.5 text-success`}):(0,w.jsx)(d,{className:`size-3.5 text-warning`})}),(0,w.jsx)(l,{className:`size-4 text-faint opacity-0 transition-opacity group-hover:opacity-100`})]})})]},n.name)})})]})}),(0,w.jsx)(x,{page:Y,pageSize:E,total:K.length,onPageChange:k,label:`queues`})]})}export{O as QueuesOverview};
1
+ import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,r,t as i,u as a}from"./react-vendor-BcouBxpZ.js";import{A as o,G as s,J as c,M as l,T as u,U as d,W as f,b as p,c as m,h,m as g,nt as _,rt as v,w as y,x as b}from"./index-r1ZMLIZ9.js";import{t as x}from"./Pagination-B9JDi5MI.js";import{t as S}from"./promisePool-Daxkc1OB.js";var C=e(n(),1),w=i(),T=6,E=15,D=[[`waiting`,`Waiting`],[`active`,`Active`],[`completed`,`Completed`],[`failed`,`Failed`],[`delayed`,`Delayed`]];function O(){let e=a(),[n,i]=(0,C.useState)(``),[O,k]=(0,C.useState)(0),[A,j]=(0,C.useState)(new Set),[M,N]=(0,C.useState)(!1),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(null),[R,z]=(0,C.useState)(`desc`),{data:B,error:V,loading:H,refetch:U}=o(()=>_.queuesSummary(),[]),W=B??[],G=e=>{I===e?R===`desc`?z(`asc`):L(null):(L(e),z(`desc`)),k(0)},K=(0,C.useMemo)(()=>{let e=n.trim().toLowerCase(),t=[...e?W.filter(t=>t.name.toLowerCase().includes(e)):W].sort((e,t)=>e.name.localeCompare(t.name));if(I){let e=R===`desc`?-1:1;t.sort((t,n)=>e*(t.counts[I]-n.counts[I]))}return t},[W,n,I,R]),q=(0,C.useMemo)(()=>W.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}),[W]),J=Math.max(1,Math.ceil(K.length/E)),Y=Math.min(O,J-1),X=K.slice(Y*E,Y*E+E),Z=async e=>{j(t=>new Set(t).add(e.name)),F(null);try{await(e.paused?_.resume(e.name):_.pause(e.name)),F({ok:!0,text:`${e.name} ${e.paused?`resumed`:`paused`} ✓`})}catch(t){F({ok:!1,text:t.message}),v.error(`Failed to ${e.paused?`resume`:`pause`} ${e.name}`,t.message)}finally{j(t=>{let n=new Set(t);return n.delete(e.name),n}),U()}},Q=async e=>{let t=W.filter(t=>e===`pause`?!t.paused:t.paused);if(t.length===0){v.info(`No queues to ${e}`);return}if(!window.confirm(`${e===`pause`?`Pause`:`Resume`} ${t.length} queue(s)?`))return;N(!0),F(null);let n=(await S(t,T,t=>e===`pause`?_.pause(t.name):_.resume(t.name))).filter(e=>e.status===`rejected`).length,r=`${e===`pause`?`Paused`:`Resumed`} ${t.length-n}/${t.length} queues${n?`, ${n} failed`:``}`;F({ok:n===0,text:r}),n===0?v.success(r):v.error(r),N(!1),U()};return H&&!B&&!V?(0,w.jsx)(p,{label:`Loading queues…`}):(0,w.jsxs)(`div`,{children:[(0,w.jsx)(h,{title:`Queues`,description:`${W.length} queues`,live:!0,actions:W.length>0?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(y,{variant:`warning`,size:`sm`,disabled:M||q.paused>=W.length,onClick:()=>Q(`pause`),children:[(0,w.jsx)(d,{className:`size-3.5`}),` Pause all`]}),(0,w.jsxs)(y,{variant:`success`,size:`sm`,disabled:M||q.paused===0,onClick:()=>Q(`resume`),children:[(0,w.jsx)(f,{className:`size-3.5`}),` Resume all`]})]}):void 0}),V&&(0,w.jsx)(b,{onRetry:U}),(0,w.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,w.jsx)(g,{label:`Waiting`,value:m(q.waiting),tone:`amber`,compact:!0}),(0,w.jsx)(g,{label:`Active`,value:m(q.active),tone:`blue`,compact:!0}),(0,w.jsx)(g,{label:`Failed`,value:m(q.failed),tone:q.failed?`red`:`default`,compact:!0}),(0,w.jsx)(g,{label:`Paused`,value:m(q.paused),tone:q.paused?`amber`:`default`,compact:!0})]}),(0,w.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,w.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,w.jsx)(`input`,{value:n,onChange:e=>{i(e.target.value),k(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`})]}),P&&(0,w.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,P.ok?`text-success`:`text-danger`),children:P.text}),(0,w.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,w.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,w.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Queue`}),D.map(([e,t])=>(0,w.jsx)(`th`,{scope:`col`,"aria-sort":I===e?R===`desc`?`descending`:`ascending`:void 0,className:`px-5 py-3 text-right font-medium`,children:(0,w.jsxs)(`button`,{type:`button`,onClick:()=>G(e),className:`inline-flex items-center gap-1 rounded uppercase tracking-wider hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[t,I===e&&(0,w.jsx)(`span`,{"aria-hidden":`true`,children:R===`desc`?`↓`:`↑`})]})},e)),(0,w.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Status`}),(0,w.jsx)(`th`,{scope:`col`,className:`w-24 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,w.jsx)(`tbody`,{children:X.length===0?(0,w.jsx)(`tr`,{children:(0,w.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:n?`No queues match your search.`:`No queues yet.`})}):X.map(n=>{let i=A.has(n.name);return(0,w.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,w.jsx)(`td`,{className:`px-5 py-3`,children:(0,w.jsxs)(r,{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,w.jsx)(s,{className:`size-4 text-faint`}),n.name]})}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:m(n.counts.waiting)}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:m(n.counts.active)}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:m(n.counts.completed)}),(0,w.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,n.counts.failed?`text-danger`:`text-muted`),children:m(n.counts.failed)}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:m(n.counts.delayed)}),(0,w.jsx)(`td`,{className:`px-5 py-3`,children:(0,w.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,w.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),n.paused?`Paused`:`Active`]})}),(0,w.jsx)(`td`,{className:`px-5 py-3`,children:(0,w.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,w.jsx)(u,{"aria-label":n.paused?`Resume queue`:`Pause queue`,disabled:i,onClick:e=>{e.stopPropagation(),Z(n)},children:n.paused?(0,w.jsx)(f,{className:`size-3.5 text-success`}):(0,w.jsx)(d,{className:`size-3.5 text-warning`})}),(0,w.jsx)(l,{className:`size-4 text-faint opacity-0 transition-opacity group-hover:opacity-100`})]})})]},n.name)})})]})}),(0,w.jsx)(x,{page:Y,pageSize:E,total:K.length,onPageChange:k,label:`queues`})]})}export{O as QueuesOverview};