bunqueue-dashboard 0.0.42 → 0.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/agent/flow/routes.ts +2 -0
- package/agent/flow/service.ts +7 -2
- package/agent/managedConnection.ts +35 -0
- package/agent/manager/config.ts +1 -1
- package/agent/queue/runtime.ts +2 -2
- package/agent/workflow/runtime.ts +2 -6
- package/agent/workflow/runtimeConfig.ts +2 -2
- package/dist/.vite/manifest.json +40 -39
- package/dist/assets/{Alerts-BvWBv-z7.js → Alerts-C961Al5D.js} +1 -1
- package/dist/assets/{Benchmark-BywalSmU.js → Benchmark-DQNZV7dM.js} +1 -1
- package/dist/assets/{CopilotPanel-CH2jbbYA.js → CopilotPanel-Dlm8XwBj.js} +1 -1
- package/dist/assets/{Database-BzEkXws0.js → Database-DGM2BIHy.js} +1 -1
- package/dist/assets/{Diagnostics-CPqhV3er.js → Diagnostics-_Sh3UyaT.js} +1 -1
- package/dist/assets/{Dlq-CbLN0zQ5.js → Dlq-mtInIoTh.js} +1 -1
- package/dist/assets/{DlqControl-C5Bgzmk0.js → DlqControl-Lq9ISb9b.js} +1 -1
- package/dist/assets/{DlqPro-Cgaxtuwh.js → DlqPro-0_75vrd1.js} +1 -1
- package/dist/assets/Flows-CE7KzaFN.js +2 -0
- package/dist/assets/{JobInspector-DsOt4mLJ.js → JobInspector-DyWZk1eW.js} +1 -1
- package/dist/assets/{Jobs-BTMpbAHD.js → Jobs-ELSH1Wbd.js} +1 -1
- package/dist/assets/JobsPro-BlWwDeFN.js +1 -0
- package/dist/assets/{Logs-uuzU5ohI.js → Logs-DMukqmHy.js} +1 -1
- package/dist/assets/{LogsPro-DHWbhWyq.js → LogsPro-BfYbmZHi.js} +1 -1
- package/dist/assets/{McpServer-BqmbhrKh.js → McpServer-DNrOEp9j.js} +1 -1
- package/dist/assets/{Metrics-DKyBZoFa.js → Metrics-Cm5ZvfTo.js} +1 -1
- package/dist/assets/{MetricsPro-BR2ULqIc.js → MetricsPro-C9g1sp-u.js} +1 -1
- package/dist/assets/{Overview-ClsyxH2e.js → Overview-CKAA3h9f.js} +1 -1
- package/dist/assets/{QueueControl-BW0XXd0B.js → QueueControl-Bvm8GUQa.js} +1 -1
- package/dist/assets/{QueueDetail-C1dXXN70.js → QueueDetail-BRDATlp0.js} +1 -1
- package/dist/assets/{QueueDetailPro-DDGxs2J2.js → QueueDetailPro-Dkz4-1wn.js} +1 -1
- package/dist/assets/{Queues-DkPuIy1C.js → Queues-BV99vr68.js} +1 -1
- package/dist/assets/{QueuesOverview-COo-V8D_.js → QueuesOverview-CT6JBaim.js} +1 -1
- package/dist/assets/{S3BackupPro-DxNVFvY1.js → S3BackupPro-CjR0y18n.js} +1 -1
- package/dist/assets/{ServerControl-B0Po974t.js → ServerControl-BH6Doax0.js} +1 -1
- package/dist/assets/{Settings-z9k4EVa_.js → Settings-CL7odwoU.js} +1 -1
- package/dist/assets/{Usage-cdWDQUaq.js → Usage-BWZkz7Se.js} +1 -1
- package/dist/assets/{UsagePro-DLuwnM8n.js → UsagePro-CoBbI-Cl.js} +1 -1
- package/dist/assets/{Workers-CVo9rJ_V.js → Workers-CBEDvXm_.js} +1 -1
- package/dist/assets/{WorkersPro-BYaredE9.js → WorkersPro-Dk4NfplT.js} +1 -1
- package/dist/assets/flowOperationPolicy-B2Etcb3f.js +1 -0
- package/dist/assets/{index-mID5W7vq.js → index-BFW2_47n.js} +3 -3
- package/dist/assets/{install-D4uRZ7XA.js → install-oydLpc1T.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +8 -5
- package/scripts/embedded.gen.ts +164 -164
- package/shared/flowOperationPolicy.ts +66 -0
- package/dist/assets/Flows-BtUGOaif.js +0 -2
- package/dist/assets/JobsPro-BfXTm9gH.js +0 -1
- package/dist/assets/jobActions-LQD4KfCc.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{d as n,g as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{t as o}from"./bq-F5BbTG1T.js";import{t as s}from"./toastStore-IZn6OPLZ.js";import{i as c,n as l}from"./icons-BVzwsfbG.js";import{n as u}from"./usePolledData-0CVelkl2.js";import{t as d}from"./Button-Ch1W94fJ.js";import{n as f,t as p}from"./Card-CWxrC8OY.js";import{i as m,n as h,r as g,t as _}from"./feedback-QDN1AsYt.js";import{n as v}from"./StatusBadge-BoOVTnKu.js";import{t as y}from"./PageHeader-CvIyaFOO.js";import{a as b,c as x,s as S,t as C}from"./format-Cg7VCIZW.js";import{n as w}from"./index-mID5W7vq.js";import{r as T,t as E}from"./useServerActionGuard-uGePilQQ.js";import{r as D}from"./flowMutationSafety-YKTHxqKv.js";import{n as O}from"./controlConnectionEpoch-CZsS0wAb.js";import{t as k}from"./AreaChart-DEAalJ6P.js";import{a as A,i as j,n as M,r as N,t as P}from"./QueueActions-BWnmNEqV.js";import{t as F}from"./useThroughputSeries-DgO8uicf.js";var I=e(r(),1),L=[`waiting`,`prioritized`,`active`,`waiting-children`,`delayed`,`completed`,`failed`,`paused`],R=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`],z=2e3,B=a();function V({name:e,jobs:t,error:n}){return(0,B.jsxs)(p,{padded:!1,className:`mb-6`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,B.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Recent jobs`}),(0,B.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,B.jsx)(l,{className:`size-3.5`})]})]}),(0,B.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,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:`ID`}),(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`State`}),(0,B.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,B.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`})]})}),(0,B.jsx)(`tbody`,{children:n?(0,B.jsx)(`tr`,{children:(0,B.jsxs)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,n,`. Retry the page.`]})}):t.length===0?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-faint`,children:`No recent jobs.`})}):t.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)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.id})}),(0,B.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,B.jsx)(`td`,{className:`px-5 py-3 text-muted`,children:e.state??`—`}),(0,B.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[e.attempts??0,` / `,e.maxAttempts??`?`]}),(0,B.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))})]})})]})}function H({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,B.jsxs)(p,{className:`mb-6`,children:[(0,B.jsx)(f,{title:`Jobs by priority`}),(0,B.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(([e,t])=>(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsxs)(`span`,{className:`w-16 shrink-0 text-right font-mono text-xs text-muted`,children:[`p`,e]}),(0,B.jsx)(`div`,{className:`h-4 flex-1 overflow-hidden rounded bg-surface-2`,children:(0,B.jsx)(`div`,{className:`h-full rounded bg-accent`,style:{width:`${Math.max(2,t/n*100)}%`}})}),(0,B.jsx)(`span`,{className:`w-14 shrink-0 tnum text-xs text-fg`,children:S(t)})]},e))}),(0,B.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:`Higher p = higher priority. Waiting jobs only.`})]})}function U({name:e,depth:n,trend:r,rate:i}){return(0,B.jsxs)(p,{className:`mb-6`,children:[(0,B.jsx)(f,{title:`Backlog depth`,action:(0,B.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,r.draining?`bg-emerald-500/10 text-success`:r.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:r.label})}),n.length<2?(0,B.jsx)(`p`,{className:`py-6 text-center text-xs text-faint`,children:`Sampling… the backlog trend appears after a few polls.`}):(0,B.jsx)(k,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:n,area:!0}]}),(0,B.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-xs text-faint`,children:[(0,B.jsx)(`span`,{children:`waiting + prioritized + active + delayed + waiting-children`}),(0,B.jsxs)(`span`,{className:`tnum`,children:[`Error rate `,i==null?`—`:x(i)]})]})]})}function W(e,t){let n=`${O()}\u0000${e}`,[r,i]=(0,I.useState)(()=>({scope:n,values:[]})),a=(0,I.useRef)(null);(0,I.useEffect)(()=>{a.current=null,i({scope:n,values:[]});let e=setInterval(()=>{let e=a.current;e!=null&&i(t=>({scope:n,values:[...t.scope===n?t.values:[],e].slice(-40)}))},z);return()=>clearInterval(e)},[n]),(0,I.useEffect)(()=>{t&&(a.current=(t.waiting??0)+(t.prioritized??0)+(t.active??0)+(t.delayed??0)+(t[`waiting-children`]??0))},[t,n]);let o=r.scope===n?r.values:[];return{depth:o,trend:F(o)}}function G(){let{name:e=``}=n(),[t,r]=(0,I.useState)(!1),[a,f]=(0,I.useState)(null),p=T(`queue:${e}`);(0,I.useEffect)(()=>{r(!1),f(null)},[p.scopeKey]);let{data:b,error:x,loading:O,refetch:k}=u((0,I.useCallback)(async()=>{if(!e)return null;if(!(await o.queuesSummary()).some(t=>t.name===e))return{queue:e,exists:!1,detail:null,stall:null,dlq:null,jobs:[],recentJobsError:null};let[t,n,r,i]=await Promise.all([o.queueDetail(e,!1),o.getStallConfig(e).catch(()=>null),o.getDlqConfig(e).catch(()=>null),o.jobsList(e,R,12).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);return{queue:e,exists:!0,detail:t,stall:n?.config??null,dlq:r?.config??null,jobs:i.jobs,recentJobsError:i.error}},[e]),[e]),F=b?.queue===e?b:null,{depth:z,trend:G}=W(e,F?.detail?.counts),K=async(t,n,i,a)=>{if(i&&!window.confirm(i))return;let c=p.begin();if(c){r(!0),f(null);try{let r=await o.queuesSummary();if(!c.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);let i=await n();if(E(i,t),!c.isCurrent())return;let l=i.count;if(l!==void 0&&(!Number.isSafeInteger(l)||l<0))throw Error(`${t} returned an invalid count`);let u=`${t}${l==null?` ✓`:`: ${l}`}`;f({ok:!0,text:u}),s.success(u,e),a?.(),k()}catch(e){if(!c.isCurrent())return;let n=e.message;f({ok:!1,text:n}),s.error(`${t} failed`,n)}finally{c.finish()&&r(!1)}}},q=F?.detail,J=q?.counts,Y=J?C(J.completed??0,J.failed??0):null;return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(y,{title:(0,B.jsx)(`span`,{className:`font-mono`,children:e}),description:`Full per-queue operations and complete live non-terminal depth.`,live:F?.exists===!0&&!!F.detail&&!!F.stall&&!!F.dlq&&!F.recentJobsError&&!x,back:(0,B.jsx)(i,{to:`/queues`,"aria-label":`Back to queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,B.jsx)(c,{className:`size-4`})}),actions:F?.exists===!0?(0,B.jsxs)(B.Fragment,{children:[(0,B.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,B.jsx)(l,{className:`size-3.5`})]}),(0,B.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,B.jsx)(l,{className:`size-3.5`})]}),(0,B.jsx)(d,{variant:`danger`,size:`sm`,disabled:!0,title:D,children:`Obliterate`})]}):void 0}),x&&F&&(0,B.jsx)(m,{message:`Queue refresh failed — showing the last successful snapshot.`,onRetry:k}),x&&!F?(0,B.jsx)(h,{error:x,onRetry:k}):O&&!F?(0,B.jsx)(g,{label:`Loading ${e}…`}):F?.exists===!1||!q||!J?!x&&(0,B.jsx)(_,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,B.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,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(v,{label:q.paused?`Paused`:`Active`,tone:q.paused?`amber`:`green`}),a&&(0,B.jsx)(`span`,{role:`status`,className:a.ok?`text-xs text-success`:`text-xs text-danger`,children:a.text}),(0,B.jsx)(`span`,{className:`text-xs text-warning`,children:D})]}),(0,B.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:L.map(e=>(0,B.jsx)(w,{label:e,value:S(J[e]),tone:e===`failed`&&J.failed?`red`:`default`,compact:!0},e))}),(0,B.jsx)(V,{name:e,jobs:F.jobs,error:F.recentJobsError}),(0,B.jsx)(H,{counts:q.priorityCounts}),(0,B.jsx)(U,{name:e,depth:z,trend:G,rate:Y}),(0,B.jsx)(M,{queue:e,paused:q.paused,busy:t,run:K}),(0,B.jsx)(P,{queue:e,busy:t,run:K},`${e}:limits`),(0,B.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[F.stall?(0,B.jsx)(j,{queue:e,config:F.stall,onSaved:()=>{f({ok:!0,text:`Stall config saved ✓`}),s.success(`Stall config saved`,e)}},`${e}:stall`):(0,B.jsx)(N,{title:`Stall detection`,onRetry:k}),F.dlq?(0,B.jsx)(A,{queue:e,config:F.dlq,onSaved:()=>{f({ok:!0,text:`DLQ config saved ✓`}),s.success(`DLQ config saved`,e)}},`${e}:dlq`):(0,B.jsx)(N,{title:`DLQ policy`,onRetry:k})]})]})]})}export{G as QueueDetailPro};
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{d as n,g as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{t as o}from"./bq-F5BbTG1T.js";import{t as s}from"./toastStore-IZn6OPLZ.js";import{i as c,n as l}from"./icons-BVzwsfbG.js";import{n as u}from"./usePolledData-0CVelkl2.js";import{t as d}from"./Button-Ch1W94fJ.js";import{n as f,t as p}from"./Card-CWxrC8OY.js";import{i as m,n as h,r as g,t as _}from"./feedback-QDN1AsYt.js";import{n as v}from"./StatusBadge-BoOVTnKu.js";import{t as y}from"./PageHeader-CvIyaFOO.js";import{a as b,c as x,s as S,t as C}from"./format-Cg7VCIZW.js";import{n as w}from"./index-BFW2_47n.js";import{r as T,t as E}from"./useServerActionGuard-uGePilQQ.js";import{r as D}from"./flowMutationSafety-YKTHxqKv.js";import{n as O}from"./controlConnectionEpoch-CZsS0wAb.js";import{t as k}from"./AreaChart-DEAalJ6P.js";import{a as A,i as j,n as M,r as N,t as P}from"./QueueActions-BWnmNEqV.js";import{t as F}from"./useThroughputSeries-DgO8uicf.js";var I=e(r(),1),L=[`waiting`,`prioritized`,`active`,`waiting-children`,`delayed`,`completed`,`failed`,`paused`],R=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`],z=2e3,B=a();function V({name:e,jobs:t,error:n}){return(0,B.jsxs)(p,{padded:!1,className:`mb-6`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,B.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Recent jobs`}),(0,B.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,B.jsx)(l,{className:`size-3.5`})]})]}),(0,B.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,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:`ID`}),(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`State`}),(0,B.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,B.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`})]})}),(0,B.jsx)(`tbody`,{children:n?(0,B.jsx)(`tr`,{children:(0,B.jsxs)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,n,`. Retry the page.`]})}):t.length===0?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-faint`,children:`No recent jobs.`})}):t.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)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.id})}),(0,B.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,B.jsx)(`td`,{className:`px-5 py-3 text-muted`,children:e.state??`—`}),(0,B.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[e.attempts??0,` / `,e.maxAttempts??`?`]}),(0,B.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))})]})})]})}function H({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,B.jsxs)(p,{className:`mb-6`,children:[(0,B.jsx)(f,{title:`Jobs by priority`}),(0,B.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(([e,t])=>(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsxs)(`span`,{className:`w-16 shrink-0 text-right font-mono text-xs text-muted`,children:[`p`,e]}),(0,B.jsx)(`div`,{className:`h-4 flex-1 overflow-hidden rounded bg-surface-2`,children:(0,B.jsx)(`div`,{className:`h-full rounded bg-accent`,style:{width:`${Math.max(2,t/n*100)}%`}})}),(0,B.jsx)(`span`,{className:`w-14 shrink-0 tnum text-xs text-fg`,children:S(t)})]},e))}),(0,B.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:`Higher p = higher priority. Waiting jobs only.`})]})}function U({name:e,depth:n,trend:r,rate:i}){return(0,B.jsxs)(p,{className:`mb-6`,children:[(0,B.jsx)(f,{title:`Backlog depth`,action:(0,B.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,r.draining?`bg-emerald-500/10 text-success`:r.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:r.label})}),n.length<2?(0,B.jsx)(`p`,{className:`py-6 text-center text-xs text-faint`,children:`Sampling… the backlog trend appears after a few polls.`}):(0,B.jsx)(k,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:n,area:!0}]}),(0,B.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-xs text-faint`,children:[(0,B.jsx)(`span`,{children:`waiting + prioritized + active + delayed + waiting-children`}),(0,B.jsxs)(`span`,{className:`tnum`,children:[`Error rate `,i==null?`—`:x(i)]})]})]})}function W(e,t){let n=`${O()}\u0000${e}`,[r,i]=(0,I.useState)(()=>({scope:n,values:[]})),a=(0,I.useRef)(null);(0,I.useEffect)(()=>{a.current=null,i({scope:n,values:[]});let e=setInterval(()=>{let e=a.current;e!=null&&i(t=>({scope:n,values:[...t.scope===n?t.values:[],e].slice(-40)}))},z);return()=>clearInterval(e)},[n]),(0,I.useEffect)(()=>{t&&(a.current=(t.waiting??0)+(t.prioritized??0)+(t.active??0)+(t.delayed??0)+(t[`waiting-children`]??0))},[t,n]);let o=r.scope===n?r.values:[];return{depth:o,trend:F(o)}}function G(){let{name:e=``}=n(),[t,r]=(0,I.useState)(!1),[a,f]=(0,I.useState)(null),p=T(`queue:${e}`);(0,I.useEffect)(()=>{r(!1),f(null)},[p.scopeKey]);let{data:b,error:x,loading:O,refetch:k}=u((0,I.useCallback)(async()=>{if(!e)return null;if(!(await o.queuesSummary()).some(t=>t.name===e))return{queue:e,exists:!1,detail:null,stall:null,dlq:null,jobs:[],recentJobsError:null};let[t,n,r,i]=await Promise.all([o.queueDetail(e,!1),o.getStallConfig(e).catch(()=>null),o.getDlqConfig(e).catch(()=>null),o.jobsList(e,R,12).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);return{queue:e,exists:!0,detail:t,stall:n?.config??null,dlq:r?.config??null,jobs:i.jobs,recentJobsError:i.error}},[e]),[e]),F=b?.queue===e?b:null,{depth:z,trend:G}=W(e,F?.detail?.counts),K=async(t,n,i,a)=>{if(i&&!window.confirm(i))return;let c=p.begin();if(c){r(!0),f(null);try{let r=await o.queuesSummary();if(!c.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);let i=await n();if(E(i,t),!c.isCurrent())return;let l=i.count;if(l!==void 0&&(!Number.isSafeInteger(l)||l<0))throw Error(`${t} returned an invalid count`);let u=`${t}${l==null?` ✓`:`: ${l}`}`;f({ok:!0,text:u}),s.success(u,e),a?.(),k()}catch(e){if(!c.isCurrent())return;let n=e.message;f({ok:!1,text:n}),s.error(`${t} failed`,n)}finally{c.finish()&&r(!1)}}},q=F?.detail,J=q?.counts,Y=J?C(J.completed??0,J.failed??0):null;return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(y,{title:(0,B.jsx)(`span`,{className:`font-mono`,children:e}),description:`Full per-queue operations and complete live non-terminal depth.`,live:F?.exists===!0&&!!F.detail&&!!F.stall&&!!F.dlq&&!F.recentJobsError&&!x,back:(0,B.jsx)(i,{to:`/queues`,"aria-label":`Back to queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,B.jsx)(c,{className:`size-4`})}),actions:F?.exists===!0?(0,B.jsxs)(B.Fragment,{children:[(0,B.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,B.jsx)(l,{className:`size-3.5`})]}),(0,B.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,B.jsx)(l,{className:`size-3.5`})]}),(0,B.jsx)(d,{variant:`danger`,size:`sm`,disabled:!0,title:D,children:`Obliterate`})]}):void 0}),x&&F&&(0,B.jsx)(m,{message:`Queue refresh failed — showing the last successful snapshot.`,onRetry:k}),x&&!F?(0,B.jsx)(h,{error:x,onRetry:k}):O&&!F?(0,B.jsx)(g,{label:`Loading ${e}…`}):F?.exists===!1||!q||!J?!x&&(0,B.jsx)(_,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,B.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,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(v,{label:q.paused?`Paused`:`Active`,tone:q.paused?`amber`:`green`}),a&&(0,B.jsx)(`span`,{role:`status`,className:a.ok?`text-xs text-success`:`text-xs text-danger`,children:a.text}),(0,B.jsx)(`span`,{className:`text-xs text-warning`,children:D})]}),(0,B.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:L.map(e=>(0,B.jsx)(w,{label:e,value:S(J[e]),tone:e===`failed`&&J.failed?`red`:`default`,compact:!0},e))}),(0,B.jsx)(V,{name:e,jobs:F.jobs,error:F.recentJobsError}),(0,B.jsx)(H,{counts:q.priorityCounts}),(0,B.jsx)(U,{name:e,depth:z,trend:G,rate:Y}),(0,B.jsx)(M,{queue:e,paused:q.paused,busy:t,run:K}),(0,B.jsx)(P,{queue:e,busy:t,run:K},`${e}:limits`),(0,B.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[F.stall?(0,B.jsx)(j,{queue:e,config:F.stall,onSaved:()=>{f({ok:!0,text:`Stall config saved ✓`}),s.success(`Stall config saved`,e)}},`${e}:stall`):(0,B.jsx)(N,{title:`Stall detection`,onRetry:k}),F.dlq?(0,B.jsx)(A,{queue:e,config:F.dlq,onSaved:()=>{f({ok:!0,text:`DLQ config saved ✓`}),s.success(`DLQ config saved`,e)}},`${e}:dlq`):(0,B.jsx)(N,{title:`DLQ policy`,onRetry:k})]})]})]})}export{G as QueueDetailPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{S as a,T as o,n as s}from"./icons-BVzwsfbG.js";import{t as c}from"./api-BgWE-705.js";import{n as l}from"./usePolledData-0CVelkl2.js";import{i as u,r as d}from"./feedback-QDN1AsYt.js";import{t as f}from"./PageHeader-CvIyaFOO.js";import{s as p}from"./format-Cg7VCIZW.js";import{n as m}from"./index-
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{S as a,T as o,n as s}from"./icons-BVzwsfbG.js";import{t as c}from"./api-BgWE-705.js";import{n as l}from"./usePolledData-0CVelkl2.js";import{i as u,r as d}from"./feedback-QDN1AsYt.js";import{t as f}from"./PageHeader-CvIyaFOO.js";import{s as p}from"./format-Cg7VCIZW.js";import{n as m}from"./index-BFW2_47n.js";import{t as h}from"./Pagination-x-Cwgrul.js";var g=e(n(),1),_=i(),v=20,y={ok:!1,queues:[],total:0,limit:v,offset:0,timestamp:0};function b(){let[e,n]=(0,g.useState)(``),[i,b]=(0,g.useState)(0),{data:x,error:S,loading:C,refetch:w}=l(()=>c.queues(v,i*v),[i]),{data:T}=l(()=>c.overview(),[]),E=x??y,D=(0,g.useMemo)(()=>{let t=E.queues,n=e.trim().toLowerCase();return n?t.filter(e=>e.name.toLowerCase().includes(n)):t},[E,e]);if(C&&!x&&!S)return(0,_.jsx)(d,{label:`Loading queues…`});let O=T?.stats;return(0,_.jsxs)(`div`,{children:[S&&(0,_.jsx)(u,{onRetry:w}),(0,_.jsx)(f,{title:`Queues`,description:x?`${E.total} queues`:`Queue inventory unavailable`,live:!!x&&!S}),(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,_.jsx)(m,{label:`Waiting`,value:O?p(O.waiting):`—`,tone:`amber`,compact:!0}),(0,_.jsx)(m,{label:`Active`,value:O?p(O.active):`—`,tone:`blue`,compact:!0}),(0,_.jsx)(m,{label:`Delayed`,value:O?p(O.delayed):`—`,tone:`default`,compact:!0}),(0,_.jsx)(m,{label:`DLQ`,value:O?p(O.dlq):`—`,tone:O?.dlq?`red`:`default`,compact:!0})]}),(0,_.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,_.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,_.jsx)(`input`,{"aria-label":`Filter queues`,name:`classic-queue-filter`,autoComplete:`off`,value:e,onChange:e=>n(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-x-auto rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full min-w-[52rem] 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:!x&&S?(0,_.jsx)(`tr`,{children:(0,_.jsxs)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,S.message,`. Retry above.`]})}):D.length===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:e?`No queues match on this page.`:`No queues yet.`})}):D.map(e=>(0,_.jsxs)(`tr`,{className:`group 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)(r,{to:`/queues-classic/${encodeURIComponent(e.name)}`,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,_.jsx)(a,{className:`size-4 text-faint`}),e.name]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.waiting)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:p(e.active)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.delayed)}),(0,_.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,e.dlq?`text-red-400`:`text-muted`),children:p(e.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`,e.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`}),e.paused?`Paused`:`Active`]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-faint`,children:(0,_.jsx)(s,{className:`size-4 opacity-0 transition-opacity group-hover:opacity-100`})})]},e.name))})]})}),x&&(0,_.jsx)(h,{page:i,pageSize:v,total:E.total,onPageChange:b,label:`queues`})]})}export{b as Queues};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-F5BbTG1T.js";import{t as o}from"./toastStore-IZn6OPLZ.js";import{S as s,T as c,b as l,n as u,x as d}from"./icons-BVzwsfbG.js";import{n as f}from"./usePolledData-0CVelkl2.js";import{n as p,t as m}from"./Button-Ch1W94fJ.js";import{i as h,n as g,r as _}from"./feedback-QDN1AsYt.js";import{t as v}from"./PageHeader-CvIyaFOO.js";import{s as y}from"./format-Cg7VCIZW.js";import{n as b}from"./index-
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-F5BbTG1T.js";import{t as o}from"./toastStore-IZn6OPLZ.js";import{S as s,T as c,b as l,n as u,x as d}from"./icons-BVzwsfbG.js";import{n as f}from"./usePolledData-0CVelkl2.js";import{n as p,t as m}from"./Button-Ch1W94fJ.js";import{i as h,n as g,r as _}from"./feedback-QDN1AsYt.js";import{t as v}from"./PageHeader-CvIyaFOO.js";import{s as y}from"./format-Cg7VCIZW.js";import{n as b}from"./index-BFW2_47n.js";import{t as x}from"./Pagination-x-Cwgrul.js";import{r as S,t as C}from"./useServerActionGuard-uGePilQQ.js";import{t as w}from"./promisePool-BVfQ9n9Q.js";var T=e(n(),1),E=i(),D=[[`waiting`,`Waiting`],[`prioritized`,`Prioritized`],[`active`,`Active`],[`completed`,`Completed`],[`failed`,`Failed`],[`delayed`,`Delayed`]];function O({rows:e,hasData:n,error:i,search:a,sortCol:o,sortDir:c,bulkBusy:f,busy:m,onSort:h,onToggle:g}){return(0,E.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,E.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,E.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),D.map(([e,t])=>(0,E.jsx)(`th`,{"aria-sort":o===e?c===`desc`?`descending`:`ascending`:void 0,className:`px-5 py-3 text-right font-medium`,children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>h(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,o===e&&(0,E.jsx)(`span`,{"aria-hidden":`true`,children:c===`desc`?`↓`:`↑`})]})},e)),(0,E.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,E.jsx)(`th`,{className:`w-24 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,E.jsx)(`tbody`,{children:!n&&i?(0,E.jsx)(`tr`,{children:(0,E.jsxs)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,i.message,`. Retry above.`]})}):e.length===0?(0,E.jsx)(`tr`,{children:(0,E.jsx)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-faint`,children:a?`No queues match your search.`:`No queues yet.`})}):e.map(e=>{let n=f||m.has(e.name);return(0,E.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(r,{to:`/queues/${encodeURIComponent(e.name)}`,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,E.jsx)(s,{className:`size-4 text-faint`}),e.name]})}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:y(e.counts.waiting)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:y(e.counts.prioritized)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:y(e.counts.active)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:y(e.counts.completed)}),(0,E.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,e.counts.failed?`text-danger`:`text-muted`),children:y(e.counts.failed)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:y(e.counts.delayed)}),(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:[(0,E.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,E.jsx)(p,{"aria-label":e.paused?`Resume queue`:`Pause queue`,disabled:n,onClick:t=>{t.stopPropagation(),g(e)},children:e.paused?(0,E.jsx)(d,{className:`size-3.5 text-success`}):(0,E.jsx)(l,{className:`size-3.5 text-warning`})}),(0,E.jsx)(u,{className:`size-4 text-faint opacity-0 transition-opacity group-hover:opacity-100`})]})})]},e.name)})})]})})}var k=6,A=15,j=[];function M(){let[e,n]=(0,T.useState)(``),[r,i]=(0,T.useState)(0),[s,u]=(0,T.useState)(new Set),[p,D]=(0,T.useState)(!1),[M,N]=(0,T.useState)(null),[P,F]=(0,T.useState)(null),[I,L]=(0,T.useState)(`desc`),R=S(`queues-overview`);(0,T.useEffect)(()=>{u(new Set),D(!1),N(null)},[R.scopeKey]);let{data:z,error:B,loading:V,refetch:H}=f(()=>a.queuesSummary(),[]),U=z??j,W=e=>{P===e?I===`desc`?L(`asc`):F(null):(F(e),L(`desc`)),i(0)},G=(0,T.useMemo)(()=>{let t=e.trim().toLowerCase(),n=[...t?U.filter(e=>e.name.toLowerCase().includes(t)):U].sort((e,t)=>e.name.localeCompare(t.name));if(P){let e=I===`desc`?-1:1;n.sort((t,n)=>e*(t.counts[P]-n.counts[P]))}return n},[U,e,P,I]),K=(0,T.useMemo)(()=>U.reduce((e,t)=>(e.waiting+=t.counts.waiting,e.prioritized+=t.counts.prioritized,e.active+=t.counts.active,e.failed+=t.counts.failed,e.paused+=+!!t.paused,e),{waiting:0,prioritized:0,active:0,failed:0,paused:0}),[U]),q=Math.max(1,Math.ceil(G.length/A)),J=Math.min(r,q-1),Y=G.slice(J*A,J*A+A),X=async e=>{let t=R.begin(`queue:${e.name}`);if(t){u(t=>new Set(t).add(e.name)),N(null);try{if(C(await(e.paused?a.resume(e.name):a.pause(e.name)),e.paused?`Resume queue`:`Pause queue`),!t.isCurrent())return;N({ok:!0,text:`${e.name} ${e.paused?`resumed`:`paused`} ✓`}),H()}catch(n){if(!t.isCurrent())return;N({ok:!1,text:n.message}),o.error(`Failed to ${e.paused?`resume`:`pause`} ${e.name}`,n.message)}finally{t.finish()&&u(t=>{let n=new Set(t);return n.delete(e.name),n})}}},Z=async e=>{let t=U.filter(t=>e===`pause`?!t.paused:t.paused);if(t.length===0){o.info(`No queues to ${e}`);return}if(!window.confirm(`${e===`pause`?`Pause`:`Resume`} ${t.length} queue(s)?`))return;let n=R.begin([`bulk`,...U.map(e=>`queue:${e.name}`)]);if(n){D(!0),N(null);try{let r=await w(t,k,async t=>{if(!n.isCurrent())throw Error(`Queue action target changed`);C(e===`pause`?await a.pause(t.name):await a.resume(t.name),`${e===`pause`?`Pause`:`Resume`} ${t.name}`)});if(!n.isCurrent())return;let i=r.filter(e=>e.status===`rejected`).length,s=`${e===`pause`?`Paused`:`Resumed`} ${t.length-i}/${t.length} queues${i?`, ${i} failed`:``}`;N({ok:i===0,text:s}),i===0?o.success(s):o.error(s),H()}finally{n.finish()&&D(!1)}}};return V&&!z&&!B?(0,E.jsx)(_,{label:`Loading queues…`}):B&&!z?(0,E.jsxs)(`div`,{children:[(0,E.jsx)(v,{title:`Queues`,description:`Queue inventory unavailable`}),(0,E.jsx)(g,{error:B,onRetry:H})]}):(0,E.jsxs)(`div`,{children:[(0,E.jsx)(v,{title:`Queues`,description:z?`${U.length} queues`:`Queue inventory unavailable`,live:!!z&&!B,actions:U.length>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m,{variant:`warning`,size:`sm`,disabled:p||s.size>0||K.paused>=U.length,onClick:()=>Z(`pause`),children:[(0,E.jsx)(l,{className:`size-3.5`}),` Pause all`]}),(0,E.jsxs)(m,{variant:`success`,size:`sm`,disabled:p||s.size>0||K.paused===0,onClick:()=>Z(`resume`),children:[(0,E.jsx)(d,{className:`size-3.5`}),` Resume all`]})]}):void 0}),B&&(0,E.jsx)(h,{message:`Queue refresh failed — showing the last successful inventory.`,onRetry:H}),(0,E.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,E.jsx)(b,{label:`Waiting`,value:y(K.waiting),tone:`amber`,compact:!0}),(0,E.jsx)(b,{label:`Prioritized`,value:y(K.prioritized),tone:`amber`,compact:!0}),(0,E.jsx)(b,{label:`Active`,value:y(K.active),tone:`blue`,compact:!0}),(0,E.jsx)(b,{label:`Failed`,value:y(K.failed),tone:K.failed?`red`:`default`,compact:!0}),(0,E.jsx)(b,{label:`Paused`,value:y(K.paused),tone:K.paused?`amber`:`default`,compact:!0})]}),(0,E.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,E.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,E.jsx)(`input`,{value:e,onChange:e=>{n(e.target.value),i(0)},placeholder:`Search queues…`,"aria-label":`Filter queues`,name:`queue-filter`,autoComplete:`off`,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`})]}),M&&(0,E.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),(0,E.jsx)(O,{rows:Y,hasData:!!z,error:B,search:e,sortCol:P,sortDir:I,bulkBusy:p,busy:s,onSort:W,onToggle:e=>void X(e)}),(0,E.jsx)(x,{page:J,pageSize:A,total:G.length,onPageChange:i,label:`queues`})]})}export{M as QueuesOverview};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{a as r,f as i,m as a,o,p as s}from"./connectionStore-BJLihGaC.js";import{l as c,o as l,s as u,t as d,u as f}from"./bq-F5BbTG1T.js";import{w as p}from"./icons-BVzwsfbG.js";import{n as ee}from"./usePolledData-0CVelkl2.js";import{t as m}from"./Button-Ch1W94fJ.js";import{t as h}from"./Card-CWxrC8OY.js";import{t as g}from"./PageHeader-CvIyaFOO.js";import{a as _}from"./index-
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{a as r,f as i,m as a,o,p as s}from"./connectionStore-BJLihGaC.js";import{l as c,o as l,s as u,t as d,u as f}from"./bq-F5BbTG1T.js";import{w as p}from"./icons-BVzwsfbG.js";import{n as ee}from"./usePolledData-0CVelkl2.js";import{t as m}from"./Button-Ch1W94fJ.js";import{t as h}from"./Card-CWxrC8OY.js";import{t as g}from"./PageHeader-CvIyaFOO.js";import{a as _}from"./index-BFW2_47n.js";import{a as v,n as y,r as b,t as x}from"./form-C4oby9pI.js";var S=e(t(),1),te=`bq-dash-s3`,C=2,w=[`disabled`,`6h`,`12h`,`24h`],T={endpoint:``,region:`us-east-1`,bucket:``,schedule:`disabled`,pathPrefix:``,virtualHostedStyle:`auto`,retention:7};function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function D(e,t,n){return typeof e==`string`&&e.length<=n?e:t}function O(e){return w.includes(e)?e:`disabled`}function k(e){return e===`virtual-hosted`||e===`path-style`?e:`auto`}function A(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=1&&e<=1e6?e:T.retention}function j(e){let t=E(e)?e:{};return{endpoint:D(t.endpoint,T.endpoint,2048),region:D(t.region,T.region,128),bucket:D(t.bucket,T.bucket,255),schedule:O(t.schedule),pathPrefix:D(t.pathPrefix,T.pathPrefix,1024),virtualHostedStyle:k(t.virtualHostedStyle),retention:A(t.retention)}}function M(e){return j(e)}function N(){try{return globalThis.localStorage??null}catch{return null}}function P(e){try{let t=JSON.parse(e),n=E(t)?t:{},r=j(`state`in n?n.state:n),i=typeof n.version==`number`?n.version:void 0;return{hydration:JSON.stringify({state:r,...i===void 0?{}:{version:i}}),canonical:JSON.stringify({state:r,version:C})}}catch{return null}}var F={getItem(e){let t=N();if(!t)return null;let n;try{n=t.getItem(e)}catch{return null}if(n===null||e!==`bq-dash-s3`)return n;let r=P(n);if(!r){try{t.removeItem(e)}catch{}return null}if(n!==r.canonical)try{t.setItem(e,r.canonical)}catch{try{t.removeItem(e)}catch{}}return r.hydration},setItem(e,t){try{N()?.setItem(e,t)}catch{}},removeItem(e){try{N()?.removeItem(e)}catch{}}},ne=a()(s(e=>({...T,accessKeyId:``,secretAccessKey:``,sessionToken:``,set:t=>e(e=>{let n={...e,...t};return{...j(n),accessKeyId:D(n.accessKeyId,``,512),secretAccessKey:D(n.secretAccessKey,``,2048),sessionToken:D(n.sessionToken,``,4096)}})}),{name:te,version:C,storage:i(()=>F),partialize:M,migrate:j,merge:(e,t)=>({...t,...j(e),accessKeyId:``,secretAccessKey:``,sessionToken:``})}));function re(){let e=Promise.resolve();return{async run(t,n){let r=e,i;e=new Promise(e=>{i=e}),await r;try{return n?.throwIfAborted(),await t()}finally{i()}}}}var ie=new Set([`enabled`,`bucket`,`endpoint`,`interval`,`retention`]),I=new Set([`key`,`size`,`date`]);function L(e){let t=z(e,ie,`Backup status`);return typeof t.enabled!=`boolean`&&H(`Backup status`),{enabled:t.enabled,bucket:B(t.bucket,`Backup status bucket`,1024),endpoint:B(t.endpoint,`Backup status endpoint`,4096),interval:B(t.interval,`Backup status interval`,128),retention:B(t.retention,`Backup status retention`,128)}}function R(e){(!Array.isArray(e)||e.length>2e4)&&H(`Backup list`);let t=new Set,n=0;return e.map((e,r)=>{let i=z(e,I,`Backup list item ${r}`),a=B(i.key,`Backup list item ${r} key`,2048),o=B(i.size,`Backup list item ${r} size`,128),s=B(i.date,`Backup list item ${r} date`,128);return n+=a.length+o.length+s.length,(n>2*1024*1024||t.has(a)||!V(s))&&H(`Backup list item ${r}`),t.add(a),{key:a,size:o,date:s}})}function z(e,t,n){(!e||typeof e!=`object`||Array.isArray(e))&&H(n);let r=e;return Object.keys(r).some(e=>!t.has(e))&&H(n),r}function B(e,t,n){return(typeof e!=`string`||e.length<1||e.length>n)&&H(t),e}function V(e){let t=Date.parse(e);return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(e)&&Number.isFinite(t)&&new Date(t).toISOString()===e}function H(e){throw Error(`${e} returned an invalid Bunqueue 2.9.3 contract`)}function U(e){return e.capture?.()??e}async function W(e,t,n){let r=await t.run(async()=>{let t=G(()=>e.restoreContext()),n=await G(()=>e.status().then(e=>L(e.data)));return{context:t,list:await G(()=>e.list().then(e=>R(e.data))),status:n}},n),{list:i,status:a}=r,o=await r.context,s=Array.from(new Set([a,i,o].filter(e=>e.status===`rejected`).map(e=>e.reason instanceof Error?e.reason.message:String(e.reason))));return{status:a.status===`fulfilled`?a.value:void 0,backups:i.status===`fulfilled`?i.value:[],context:o.status===`fulfilled`?o.value:void 0,errors:s}}async function G(e){try{return{status:`fulfilled`,value:await e()}}catch(e){return{status:`rejected`,reason:e}}}function K(e){let t={};for(let n of e.split(`
|
|
2
2
|
`)){let e=n.indexOf(`=`);if(e<1)throw Error(`Generated backup environment is malformed`);let r=n.slice(0,e),i=n.slice(e+1);if(!/^S3_[A-Z0-9_]+$/.test(r))throw Error(`Unexpected backup key: ${r}`);let a;try{a=JSON.parse(i)}catch{if(i===`true`||i===`false`||/^\d+$/.test(i))a=i;else throw Error(`Generated backup value for ${r} is malformed`)}t[r]=String(a)}return t}var q=e=>({method:`POST`,headers:e===void 0?void 0:{"Content-Type":`application/json`},body:e===void 0?void 0:JSON.stringify(e)});function J(e,t){let n=async(n,r)=>(await t(`${n}?target=${encodeURIComponent(e())}`,r)).result;return{status:()=>n(`/backup/status`),list:()=>n(`/backup/list`),backupNow:()=>n(`/backup/now`,q()),restore:(e,t)=>n(`/backup/restore`,q({key:e,database:t})),configure:e=>n(`/backup/configure`,q({environment:e})),restoreContext:async()=>{let e=await t(`/control/status`);return{serverStatus:e.status,database:e.db??null}}}}function ae(){let e=r(),t=f(),n={...l(t)};return J(()=>e,(e,r)=>c(t.baseUrl,e,n,r,!0,`agent`))}var oe={...J(r,u),capture:ae},Y=n();function se({environmentText:e,pollIntervalMs:t=15e3,repository:n=oe}){let r=o(e=>JSON.stringify([e.baseUrl,e.token,e.agentToken])),i=(0,S.useRef)(!0),a=(0,S.useRef)(null);(!a.current||a.current.connectionIdentity!==r||a.current.repository!==n)&&(a.current={connectionIdentity:r,repository:n});let[s]=(0,S.useState)(re),c=ee(e=>W(U(n),s,e),[n,s],{intervalMs:t}),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(``),[p,m]=(0,S.useState)(``),h=(0,S.useRef)(!1);(0,S.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]),(0,S.useEffect)(()=>{h.current=!1,u(``),f(``),m(``)},[r,n]);let g=async(e,t)=>{if(h.current)return;let r=a.current;h.current=!0,u(e),f(``),m(``);try{let o=U(n),l=await s.run(async()=>{if(!Z(r,a,i))throw Error(`Backup operation scope changed before admission.`);return t(o)});if(!Z(r,a,i))return;let u=l?.message;m(u??`${e} completed.`),await c.refetch()}catch(e){Z(r,a,i)&&f(e instanceof Error?e.message:String(e))}finally{Z(r,a,i)&&(h.current=!1,u(``))}},_=()=>{e&&window.confirm(`Apply this S3 configuration to the managed server? A restart is required.`)&&g(`Configuration`,t=>t.configure(K(e)))},v=()=>{window.confirm(`Create a transactionally consistent S3 backup now?`)&&g(`Backup`,e=>e.backupNow())},y=e=>{let t=c.data?.context?.database;!t||c.data?.context?.serverStatus!==`stopped`||window.prompt(`Type RESTORE to replace ${t.path} with ${e}`)===`RESTORE`&&g(`Restore`,n=>n.restore(e,t))},b=c.data;return(0,Y.jsxs)(`section`,{className:`mt-6 overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Live backup operations`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Official Bunqueue 2.9.3 backup CLI, executed by the local control agent.`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:!e||!!l,onClick:_,className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Apply configuration`}),(0,Y.jsx)(`button`,{type:`button`,disabled:!!l,onClick:v,className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:l===`Backup`?`Backing up…`:`Backup now`}),(0,Y.jsx)(`button`,{type:`button`,disabled:!!l||c.loading,onClick:()=>void c.refetch(),className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Refresh`})]})]}),b?.status&&(0,Y.jsx)(ce,{status:b.status,context:b.context}),d||b?.errors.length?(0,Y.jsx)(`div`,{role:`alert`,className:`border-b border-line px-4 py-3 text-xs text-danger`,children:d||b?.errors.join(` · `)}):null,p&&(0,Y.jsx)(`div`,{role:`status`,className:`border-b border-line px-4 py-3 text-xs text-success`,children:p}),(0,Y.jsx)(X,{rows:b?.backups??[],canRestore:b?.context?.serverStatus===`stopped`&&!!b.context.database,busy:!!l,onRestore:y})]})}function ce({status:e,context:t}){return(0,Y.jsx)(`dl`,{className:`grid border-b border-line sm:grid-cols-2 xl:grid-cols-5`,children:[[`Scheduler`,e.enabled?`Enabled after restart`:`Disabled`],[`Bucket`,e.bucket||`—`],[`Endpoint`,e.endpoint],[`Retention`,e.retention],[`Server`,t?.serverStatus??`Unknown`]].map(([e,t])=>(0,Y.jsxs)(`div`,{className:`border-b border-line px-4 py-3 last:border-b-0 xl:border-r xl:border-b-0`,children:[(0,Y.jsx)(`dt`,{className:`text-[10px] uppercase tracking-wider text-faint`,children:e}),(0,Y.jsx)(`dd`,{className:`mt-1 truncate text-xs text-fg`,title:t,children:t})]},e))})}function X({rows:e,canRestore:t,busy:n,onRestore:r}){return e.length?(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full min-w-[680px] text-left text-xs`,children:[(0,Y.jsx)(`thead`,{className:`border-b border-line text-[10px] uppercase tracking-wider text-faint`,children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Object key`}),(0,Y.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Size`}),(0,Y.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Created`}),(0,Y.jsx)(`th`,{className:`px-4 py-2 text-right font-medium`,children:`Restore`})]})}),(0,Y.jsx)(`tbody`,{className:`divide-y divide-line`,children:e.map(e=>(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`max-w-md truncate px-4 py-3 font-mono text-fg`,title:e.key,children:e.key}),(0,Y.jsx)(`td`,{className:`px-4 py-3 text-muted`,children:e.size}),(0,Y.jsx)(`td`,{className:`px-4 py-3 text-muted`,children:e.date}),(0,Y.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,Y.jsx)(`button`,{type:`button`,disabled:!t||n,title:t?`Restore this backup`:`Stop the managed server before restore`,onClick:()=>r(e.key),className:`rounded-md border border-danger/40 px-2.5 py-1.5 text-danger disabled:opacity-35`,children:`Restore`})})]},e.key))})]})}):(0,Y.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted`,children:`No backup objects returned.`})}function Z(e,t,n){return n.current&&e!==null&&t.current===e}function le(e){if(typeof e!=`object`||!e||Array.isArray(e)||typeof e.ok!=`boolean`)throw Error(`Malformed storage status response.`);let t=e.data;if(typeof t!=`object`||!t||Array.isArray(t)||typeof t.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data.`);return{diskFull:t.diskFull}}var Q=e=>JSON.stringify([e.activeProfileId,e.baseUrl,e.agentBaseUrl,e.token,e.agentToken]),ue={"6h":360*60*1e3,"12h":720*60*1e3,"24h":1440*60*1e3};function $(e,t){return`${e}=${typeof t==`string`?JSON.stringify(t):String(t)}`}function de(e){let t=[],n=e.endpoint.trim(),r=e.region.trim(),i=e.bucket.trim(),a=e.accessKeyId.trim(),o=e.secretAccessKey.trim(),s=e.sessionToken.trim(),c=e.pathPrefix.trim();if(e.schedule===`disabled`)return{ok:!0,value:$(`S3_BACKUP_ENABLED`,!1)};if((!r||r.length>128)&&t.push(`Region is required (maximum 128 characters).`),(!i||i.length>255)&&t.push(`Bucket is required (maximum 255 characters).`),(!a||a.length>512)&&t.push(`Access key ID is required (maximum 512 characters).`),(!o||o.length>2048)&&t.push(`Secret access key is required (maximum 2048 characters).`),s.length>4096&&t.push(`Session token is too long.`),(!Number.isSafeInteger(e.retention)||e.retention<1||e.retention>1e6)&&t.push(`Retention must be a whole number from 1 to 1000000.`),c.length>1024&&t.push(`Path prefix is too long.`),n)try{let e=new URL(n);(e.protocol!==`http:`&&e.protocol!==`https:`||e.username||e.password||n.length>2048)&&t.push(`Endpoint must be an http(s) URL without embedded credentials.`)}catch{t.push(`Endpoint must be a valid http(s) URL.`)}if(t.length)return{ok:!1,errors:t};let l=[$(`S3_BACKUP_ENABLED`,!0),$(`S3_ACCESS_KEY_ID`,a),$(`S3_SECRET_ACCESS_KEY`,o),$(`S3_BUCKET`,i),$(`S3_REGION`,r),$(`S3_BACKUP_RETENTION`,e.retention)];return s&&l.push($(`S3_SESSION_TOKEN`,s)),e.virtualHostedStyle!==`auto`&&l.push($(`S3_VIRTUAL_HOSTED_STYLE`,e.virtualHostedStyle===`virtual-hosted`)),n&&l.push($(`S3_ENDPOINT`,n)),c&&l.push($(`S3_BACKUP_PREFIX`,c)),l.push($(`S3_BACKUP_INTERVAL`,ue[e.schedule])),{ok:!0,value:l.join(`
|
|
3
3
|
`)}}function fe({environment:e}){return(0,Y.jsxs)(h,{children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Server environment`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Credentials stay in memory and are copied or applied only when you request it.`})]}),e.ok&&(0,Y.jsx)(_,{value:e.value})]}),e.ok?(0,Y.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap break-all rounded-lg bg-surface-2 p-4 font-mono text-xs text-muted`,children:e.value.replace(/^S3_ACCESS_KEY_ID=.*$/m,`S3_ACCESS_KEY_ID="••••••••"`).replace(/^S3_SECRET_ACCESS_KEY=.*$/m,`S3_SECRET_ACCESS_KEY="••••••••"`).replace(/^S3_SESSION_TOKEN=.*$/m,`S3_SESSION_TOKEN="••••••••"`)}):(0,Y.jsx)(`ul`,{className:`space-y-1 text-sm text-danger`,"aria-label":`Configuration errors`,children:e.errors.map(e=>(0,Y.jsxs)(`li`,{children:[`• `,e]},e))})]})}function pe(){let e=ne(),t=o(Q),[n,r]=(0,S.useState)(null),[i,a]=(0,S.useState)(null),s=(0,S.useRef)(0),c=de(e),l=n?.target===t?n:null,u=i===t;return(0,S.useEffect)(()=>(s.current++,r(null),a(null),()=>{s.current++}),[t]),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(g,{title:`S3 Backup Setup`,description:`Configure and operate Bunqueue 2.9.3 S3 backups.`}),(0,Y.jsxs)(`div`,{className:`mb-6 flex items-center justify-between rounded-xl border border-line bg-surface px-5 py-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-surface-2 text-faint`,children:(0,Y.jsx)(p,{className:`size-5`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`font-semibold text-fg`,children:c.ok?`Configuration draft complete`:`Configuration draft incomplete`}),(0,Y.jsx)(`div`,{className:`text-xs text-faint`,children:c.ok?e.schedule===`disabled`?`Safe disable settings ready to apply`:`Target: ${e.bucket.trim()} · ready to apply`:`Complete the required fields to generate server settings`})]})]}),(0,Y.jsx)(`span`,{className:c.ok?`rounded-full bg-emerald-500/10 px-3 py-1 text-xs font-medium text-success`:`rounded-full bg-amber-500/10 px-3 py-1 text-xs font-medium text-warning`,children:c.ok?`Ready`:`Configure`})]}),(0,Y.jsx)(`div`,{className:`mb-6 rounded-lg border border-line bg-surface/60 px-4 py-2.5 text-xs text-faint`,children:`Apply the generated settings through the local control agent below, then restart Bunqueue. Status, object listing, manual backups, and guarded restores use the official Bunqueue CLI. Non-secret draft fields are stored locally; credentials remain in memory.`}),(0,Y.jsxs)(h,{className:`mb-6`,children:[(0,Y.jsx)(`h2`,{className:`mb-1 text-base font-semibold text-fg`,children:`Connection Settings`}),(0,Y.jsx)(`p`,{className:`mb-4 text-xs text-faint`,children:`Works with AWS S3, Cloudflare R2, MinIO, DigitalOcean Spaces, and any S3-compatible provider.`}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,Y.jsx)(x,{label:`Endpoint`,children:(0,Y.jsx)(y,{name:`s3-endpoint`,value:e.endpoint,onChange:t=>e.set({endpoint:t.target.value}),placeholder:`https://s3.amazonaws.com`,maxLength:2048,autoComplete:`off`,inputMode:`url`})}),(0,Y.jsx)(x,{label:`Region`,children:(0,Y.jsx)(y,{name:`s3-region`,value:e.region,onChange:t=>e.set({region:t.target.value}),placeholder:`us-east-1`,maxLength:128,autoComplete:`off`,spellCheck:!1})}),(0,Y.jsx)(`div`,{className:`md:col-span-2`,children:(0,Y.jsx)(x,{label:`Bucket name`,children:(0,Y.jsx)(y,{name:`s3-bucket`,value:e.bucket,onChange:t=>e.set({bucket:t.target.value}),placeholder:`my-bunqueue-backups`,maxLength:255,autoComplete:`off`,spellCheck:!1})})}),(0,Y.jsx)(x,{label:`Access key ID`,children:(0,Y.jsx)(y,{name:`s3-access-key-id`,value:e.accessKeyId,onChange:t=>e.set({accessKeyId:t.target.value}),placeholder:`AKIA…`,maxLength:512,autoComplete:`off`,spellCheck:!1})}),(0,Y.jsx)(x,{label:`Secret access key`,children:(0,Y.jsx)(y,{name:`s3-secret-access-key`,type:`password`,value:e.secretAccessKey,onChange:t=>e.set({secretAccessKey:t.target.value}),placeholder:`••••••••••••••••`,maxLength:2048,autoComplete:`off`,spellCheck:!1})}),(0,Y.jsx)(`div`,{className:`md:col-span-2`,children:(0,Y.jsx)(x,{label:`Session token (optional, for temporary STS credentials)`,children:(0,Y.jsx)(y,{name:`s3-session-token`,type:`password`,value:e.sessionToken,onChange:t=>e.set({sessionToken:t.target.value}),placeholder:`Temporary AWS session token`,maxLength:4096,autoComplete:`off`,spellCheck:!1})})}),(0,Y.jsx)(`p`,{className:`-mt-2 text-xs text-faint md:col-span-2`,children:`Keys are kept in memory only and cleared on reload.`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(b,{htmlFor:`s3-backup-schedule`,children:`Backup interval`}),(0,Y.jsxs)(v,{id:`s3-backup-schedule`,name:`s3-backup-schedule`,value:e.schedule,onChange:t=>e.set({schedule:t.target.value}),className:`mt-1.5`,title:`Written to S3_BACKUP_ENABLED and S3_BACKUP_INTERVAL in the generated config`,autoComplete:`off`,children:[(0,Y.jsx)(`option`,{value:`disabled`,children:`Disabled`}),(0,Y.jsx)(`option`,{value:`6h`,children:`Every 6 hours`}),(0,Y.jsx)(`option`,{value:`12h`,children:`Every 12 hours`}),(0,Y.jsx)(`option`,{value:`24h`,children:`Every 24 hours`})]})]}),(0,Y.jsx)(x,{label:`Path prefix (optional)`,children:(0,Y.jsx)(y,{name:`s3-path-prefix`,value:e.pathPrefix,onChange:t=>e.set({pathPrefix:t.target.value}),placeholder:`backups/production/`,maxLength:1024,autoComplete:`off`,spellCheck:!1})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(b,{htmlFor:`s3-addressing-style`,children:`Addressing style`}),(0,Y.jsxs)(v,{id:`s3-addressing-style`,name:`s3-addressing-style`,value:e.virtualHostedStyle,onChange:t=>e.set({virtualHostedStyle:t.target.value}),className:`mt-1.5`,children:[(0,Y.jsx)(`option`,{value:`auto`,children:`Provider default`}),(0,Y.jsx)(`option`,{value:`virtual-hosted`,children:`Virtual-hosted style`}),(0,Y.jsx)(`option`,{value:`path-style`,children:`Path style`})]})]}),(0,Y.jsx)(x,{label:`Backups to retain`,children:(0,Y.jsx)(y,{name:`s3-retention`,type:`number`,min:1,max:1e6,step:1,value:e.retention,onChange:t=>e.set({retention:Number(t.target.value)}),inputMode:`numeric`})})]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(m,{onClick:async()=>{let e=t,n=++s.current;r(null),a(e);try{let t=await d.storage();if(n!==s.current||Q(o.getState())!==e)return;let i=le(t);r({target:e,ok:!i.diskFull,msg:i.diskFull?`Server disk is full`:`Server disk healthy — this does not validate the S3 credentials`})}catch(t){if(n!==s.current||Q(o.getState())!==e)return;r({target:e,ok:!1,msg:t.message})}finally{n===s.current&&a(null)}},children:u?`Checking server storage…`:`Check server storage`}),(0,Y.jsx)(`span`,{className:`text-xs text-faint`,children:`This checks SQLite disk health only, not S3 connectivity.`}),l&&(0,Y.jsx)(`span`,{role:`status`,className:l.ok?`text-xs text-success`:`text-xs text-danger`,children:l.msg})]})]}),(0,Y.jsx)(fe,{environment:c}),(0,Y.jsx)(se,{environmentText:c.ok?c.value:void 0})]})}export{pe as S3BackupPro};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CvwrP0tU.js";import{t as i}from"./bq-F5BbTG1T.js";import{C as a,T as o,b as s,x as c}from"./icons-BVzwsfbG.js";import{n as l}from"./usePolledData-0CVelkl2.js";import{t as u}from"./Button-Ch1W94fJ.js";import{n as d,t as f}from"./Card-CWxrC8OY.js";import{i as p,n as m,r as h}from"./feedback-QDN1AsYt.js";import{t as g}from"./PageHeader-CvIyaFOO.js";import{f as _,i as v,l as y,n as b,u as x}from"./format-Cg7VCIZW.js";import{a as S}from"./index-mID5W7vq.js";import{i as C,n as w,t as T}from"./form-C4oby9pI.js";import{t as E}from"./useControlActionGuard-B-bzKZKI.js";var D=e(n(),1),O=r();function k({children:e}){return(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs text-fg`,children:e})}function A({agentBase:e}){return(0,O.jsx)(f,{children:(0,O.jsxs)(`details`,{className:`group`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2`,children:[(0,O.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:`How server control works`}),(0,O.jsx)(`span`,{className:`text-xs text-muted transition-transform group-open:rotate-90`,children:`▶`})]}),(0,O.jsxs)(`div`,{className:`mt-4 space-y-4 text-sm leading-relaxed text-muted`,children:[(0,O.jsxs)(`p`,{children:[`A browser can't start or stop an OS process, so the dashboard talks to a small local`,` `,(0,O.jsx)(`span`,{className:`font-medium text-fg`,children:`control agent`}),` (`,(0,O.jsx)(k,{children:e}),`) that supervises the bunqueue server process — start, stop and restart — and streams its logs back here.`]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Launch & environment`}),(0,O.jsxs)(`p`,{children:[`The agent runs your `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Command`}),` and injects`,` `,(0,O.jsx)(k,{children:`HTTP_PORT`}),` and `,(0,O.jsx)(k,{children:`TCP_PORT`}),`, plus `,(0,O.jsx)(k,{children:`BUNQUEUE_DATA_PATH`}),` `,`only for SQLite. Memory and PostgreSQL modes remove every SQLite path alias before launch. Any `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Environment variables`}),` you add are included too. The default `,(0,O.jsx)(k,{children:`bunx bunqueue@2.9.3 start`}),` resolves the verified release; pointing the command at a local entry (e.g.`,` `,(0,O.jsx)(k,{children:`bun run /path/to/bunqueue/src/main.ts`}),`) works without one.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`When changes apply`}),(0,O.jsxs)(`p`,{children:[`Config is editable any time, but `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Command`}),`, ports and data path only take effect on the `,(0,O.jsx)(`span`,{className:`text-fg`,children:`next start/restart`}),` `,`— the running process keeps the config it launched with until then.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Data path`}),(0,O.jsxs)(`p`,{children:[`Relative paths resolve against the `,(0,O.jsx)(`span`,{className:`text-fg`,children:`agent's`}),` working directory. SQLite creates the database `,(0,O.jsx)(`span`,{className:`text-fg`,children:`file`}),` but not its parent `,(0,O.jsx)(`span`,{className:`text-fg`,children:`folder`}),` — if start fails with`,` `,(0,O.jsx)(k,{children:`SQLITE_CANTOPEN`}),`, create the directory first or use a path whose folder already exists.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Security`}),(0,O.jsxs)(`p`,{children:[`The direct agent listener binds `,(0,O.jsx)(k,{children:`127.0.0.1`}),`, locks CORS to an allowlist (never `,(0,O.jsx)(k,{children:`*`}),`), and rejects a disallowed `,(0,O.jsx)(k,{children:`Origin`}),` or`,` `,(0,O.jsx)(k,{children:`Host`}),` with `,(0,O.jsx)(k,{children:`403`}),`. The all-in-one server's `,(0,O.jsx)(k,{children:`/agent`}),` `,`bridge treats LAN and reverse-proxy access as remote: `,(0,O.jsx)(k,{children:`AGENT_TOKEN`}),` is then mandatory for status, logs, database reads and changes alike. Without it, the bridge stays disabled.`]}),(0,O.jsxs)(`p`,{children:[`If you started the agent with `,(0,O.jsx)(k,{children:`AGENT_TOKEN`}),`, enter that token under`,` `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Settings → Agent token`}),` (or when the lock screen prompts). It stays in memory for this browser session; never bake it into a public`,` `,(0,O.jsx)(k,{children:`VITE_*`}),` value.`]})]})]})]})})}function j(e,t,n,r){return{baseline:F(e),id:r,revision:t,scope:n,value:F(e)}}function ee(e,t,n,r,i){return{accepted:F(e),acceptedRevision:t,before:n?F(n):null,beforeRevision:r,ignoreThroughRequestId:i}}function te(e,t,n,r){return P(t,e.accepted)?!1:r!==void 0&&e.ignoreThroughRequestId!==void 0?r<=e.ignoreThroughRequestId:n===void 0?e.before!==null&&P(t,e.before):n===e.beforeRevision||n===e.acceptedRevision}function M(e){if(!L(e))return R();let{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:a}=e;if(typeof t!=`string`||t.trim()===``||!I(n)||!I(r)||n===r||typeof i!=`string`||!L(a)||Object.values(a).some(e=>typeof e!=`string`))return R();let o=N(e.configRevision);return e.configRevision!==void 0&&o===void 0?R():{config:{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:Object.fromEntries(Object.entries(a))},revision:o}}function N(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:void 0}function ne(e){return I(e.httpPort)?I(e.tcpPort)?e.httpPort===e.tcpPort?`HTTP and TCP ports must differ`:null:`TCP port must be an integer between 1 and 65535`:`HTTP port must be an integer between 1 and 65535`}function re(e,t){if(!e)return[];let n=[];return e.command!==t.command&&n.push(`command`),e.httpPort!==t.httpPort&&n.push(`HTTP port`),e.tcpPort!==t.tcpPort&&n.push(`TCP port`),e.dataPath!==t.dataPath&&n.push(`data path`),z(e.extraEnv)!==z(t.extraEnv)&&n.push(`environment variables`),n}function P(e,t){return JSON.stringify(B(e))===JSON.stringify(B(t))}function F(e){return{...e,extraEnv:{...e.extraEnv}}}function I(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=65535}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(){throw Error(`Configuration save returned a malformed response`)}function z(e){return JSON.stringify(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)))}function B(e){return{...e,extraEnv:Object.fromEntries(Object.entries(e.extraEnv).sort(([e],[t])=>e.localeCompare(t)))}}var V=0,H=e=>Object.entries(e).map(([e,t])=>({id:V++,key:e,value:t})),U=e=>{let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return t};function W(e){let t=e.map(e=>e.trim());return[...new Set(t.filter((e,t,n)=>e&&n.indexOf(e)!==t))]}var ie=[`AUTH_TOKENS`,`LOG_LEVEL`,`BUNQUEUE_STORAGE_DRIVER`,`BUNQUEUE_POSTGRES_URL`,`BUNQUEUE_POSTGRES_NAMESPACE`,`BUNQUEUE_POSTGRES_POOL_SIZE`,`BUNQUEUE_MAX_COMPLETED_JOBS`,`BUNQUEUE_COMPLETED_RETENTION_MS`,`S3_BACKUP_ENABLED`,`S3_BUCKET`,`METRICS_ENABLED`];function G({value:e,onChange:t,disabled:n}){let[r,i]=(0,D.useState)(()=>H(e)),a=e=>{i(e),t(U(e))},o=(e,t)=>a(r.map(n=>n.id===e?{...n,...t}:n)),s=(e=``)=>a([...r,{id:V++,key:e,value:``}]),c=e=>a(r.filter(t=>t.id!==e)),l=new Set(r.map(e=>e.key.trim()).filter(Boolean)),d=W(r.map(e=>e.key)),f=[...new Set(r.map(e=>e.key.trim()).filter(e=>e&&(/[\s=]/.test(e)||/[a-z]/.test(e))))];return(0,O.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.length===0&&(0,O.jsxs)(`p`,{className:`text-xs leading-relaxed text-faint`,children:[`No custom variables. The agent already injects`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`HTTP_PORT`}),`,`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`TCP_PORT`}),`, plus the SQLite data path unless PostgreSQL mode is selected.`]}),r.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`w-2/5 shrink-0`,children:(0,O.jsx)(w,{id:`env-key-${e.id}`,name:`env-key-${e.id}`,"aria-label":`Variable name${e.key?` ${e.key}`:``}`,className:`font-mono`,placeholder:`KEY`,value:e.key,disabled:n,autoComplete:`off`,spellCheck:!1,onChange:t=>o(e.id,{key:t.target.value})})}),(0,O.jsx)(`span`,{className:`text-faint`,children:`=`}),(0,O.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,O.jsx)(w,{id:`env-value-${e.id}`,name:`env-value-${e.id}`,"aria-label":`Value for ${e.key||`variable`}`,className:`font-mono`,placeholder:`value`,value:e.value,disabled:n,autoComplete:`off`,spellCheck:!1,onChange:t=>o(e.id,{value:t.target.value})})}),(0,O.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.key||`variable`}`,disabled:n,onClick:()=>c(e.id),className:`shrink-0 rounded-md px-2 py-1 text-xs text-faint transition-colors hover:text-danger disabled:opacity-40`,children:`✕`})]},e.id)),d.length>0&&(0,O.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Duplicate key`,d.length>1?`s`:``,` — the last value wins: `,d.join(`, `)]}),f.length>0&&(0,O.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Unusual key`,f.length>1?`s`:``,` — env names are usually UPPER_SNAKE_CASE with no spaces or "=": `,f.join(`, `),`. Saved as-is.`]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,O.jsx)(u,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>s(),children:`+ Add variable`}),ie.filter(e=>!l.has(e)).map(e=>(0,O.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>s(e),className:`rounded-md border border-line bg-surface-2 px-2 py-1 font-mono text-[11px] text-muted transition-colors hover:border-line-strong hover:text-fg disabled:opacity-40`,children:[`+ `,e]},e))]})]})}function K({status:e,onSaved:t,running:n,statusRequestId:r,getStatusRequestSequence:o,transitioning:s}){let c=E(`server-config`),l=(0,D.useRef)(0),p=(0,D.useRef)(null),m=(0,D.useRef)(null),[h,g]=(0,D.useState)(null),[_,v]=(0,D.useState)(!1),[y,b]=(0,D.useState)(!1),[x,S]=(0,D.useState)(null),[C,k]=(0,D.useState)(!1),[A,F]=(0,D.useState)(null);(0,D.useEffect)(()=>{p.current&&clearTimeout(p.current),p.current=null,m.current=null,g(null),v(!1),b(!1),S(null),k(!1),F(null)},[c.scopeKey]),(0,D.useEffect)(()=>{if(!e?.config||_)return;let t=m.current;t&&te(t,e.config,N(e.configRevision),r)||(m.current=null,g(j(e.config,N(e.configRevision),c.scopeKey,++l.current)),k(!1))},[c.scopeKey,_,e?.config,e?.configRevision,r]),(0,D.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let I=h?.scope===c.scopeKey?h:null,L=I?.value??e?.config??null;if(!L)return(0,O.jsx)(f,{children:`Loading…`});let R=t=>{let n=I??j(L,N(e?.configRevision),c.scopeKey,++l.current);g({...n,value:{...n.value,...t}}),v(!0),b(!1),k(!1)},z=re(e?.runningConfig??null,L),B=n&&z.length>0,V=s||x!==null,H=()=>{p.current&&clearTimeout(p.current),b(!0),p.current=setTimeout(()=>{p.current=null,b(!1)},2e3)},U=async n=>{let r=c.begin([`config`,`lifecycle`]);if(!r)return;let a=ne(L);if(a)return r.finish(),F(a);let s=I?.baseline??e?.config,u=I?.revision??N(e?.configRevision);if(u===void 0&&s&&e?.config&&!P(s,e.config))return r.finish(),k(!0),F(`Configuration changed elsewhere; reload the latest values before saving.`);F(null),k(!1),S(n?`restart`:`save`);try{let a=await i.control.setConfig(L,u);if(!r.isCurrent())return;let{config:s,revision:d}=M(a);if(m.current=ee(s,d,e?.config??null,N(e?.configRevision),o?.()),g(j(s,d,c.scopeKey,++l.current)),v(!1),n&&await i.control.restart(),!r.isCurrent())return;H(),await t()}catch(e){if(!r.isCurrent())return;let t=e.message;t.startsWith(`Configuration changed since revision`)&&k(!0),F(t)}finally{r.finish()&&S(null)}},W=()=>U(!1);return(0,O.jsxs)(f,{children:[(0,O.jsx)(d,{title:`Configuration`}),(0,O.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:n?`Ports and data path apply on the next restart — edit freely, then restart.`:`Edit and save; the config is used the next time the server starts.`}),(0,O.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),W()},children:[(0,O.jsx)(T,{label:`Command`,hint:`The exact command the agent runs to launch bunqueue. It receives HTTP_PORT and TCP_PORT; BUNQUEUE_DATA_PATH is injected only for SQLite and removed in non-SQLite modes. The default resolves Bunqueue 2.9.3 with bunx; offline installs can point at a local entry.`,children:(0,O.jsx)(w,{name:`server-command`,autoComplete:`off`,spellCheck:!1,value:L.command,disabled:V,onChange:e=>R({command:e.target.value}),placeholder:`bunx bunqueue@2.9.3 start`})}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,O.jsx)(T,{label:`HTTP port`,hint:`Dashboard API + SSE.`,children:(0,O.jsx)(w,{name:`server-http-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:L.httpPort,disabled:V,onChange:e=>R({httpPort:Number(e.target.value)})})}),(0,O.jsx)(T,{label:`TCP port`,hint:`Binary protocol. Must differ from HTTP.`,children:(0,O.jsx)(w,{name:`server-tcp-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:L.tcpPort,disabled:V,onChange:e=>R({tcpPort:Number(e.target.value)})})})]}),(0,O.jsx)(T,{label:`Data path`,hint:`Durable SQLite path for the managed broker and Workflow Engine, relative to the agent's working directory. In PostgreSQL mode the agent keeps it for Workflow state but does not pass it to the broker.`,children:(0,O.jsx)(w,{name:`server-data-path`,autoComplete:`off`,spellCheck:!1,value:L.dataPath,disabled:V,onChange:e=>R({dataPath:e.target.value})})}),(0,O.jsx)(T,{label:`Environment variables`,hint:`Injected on start. Includes Bunqueue 2.9.3 completed-history controls: BUNQUEUE_MAX_COMPLETED_JOBS bounds hot memory, while BUNQUEUE_COMPLETED_RETENTION_MS opts into durable age-based expiry. Memory and PostgreSQL modes remove inherited SQLite path aliases. Applies on the next restart.`,children:(0,O.jsx)(G,{value:L.extraEnv??{},onChange:e=>R({extraEnv:e}),disabled:V},I?.id??`initial`)}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,O.jsx)(u,{type:`submit`,variant:`accent`,size:`sm`,disabled:V,children:`Save config`}),n&&(0,O.jsxs)(u,{variant:`warning`,size:`sm`,disabled:V,onClick:()=>{let e=z.length>0?` Changed: ${z.join(`, `)}.`:``;if(window.confirm(`Save configuration and restart the server to apply it?${e}`))return U(!0)},children:[(0,O.jsx)(a,{className:`size-3.5`}),` Save & restart`]}),B&&!y&&(0,O.jsx)(`span`,{className:`text-xs text-warning`,children:`Restart to apply changes`}),y&&(0,O.jsx)(`span`,{className:`text-xs text-success`,children:`Saved`}),C&&(0,O.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,disabled:V,onClick:()=>{e?.config&&(m.current=null,g(j(e.config,N(e.configRevision),c.scopeKey,++l.current)),v(!1),k(!1),F(null))},children:`Reload latest`}),A&&(0,O.jsx)(`span`,{className:`text-xs text-danger`,children:A})]})]})]})}var q=[`all`,`stdout`,`stderr`,`sys`],J=e=>`${new Date(e).toLocaleTimeString([],{hour12:!1})}.${String(e%1e3).padStart(3,`0`)}`,ae=e=>e===`stderr`?`text-danger/90`:e===`sys`?`text-accent/80`:`text-muted`;function oe(e,t=Date.now()){let n=new Blob([e],{type:`text/plain`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`bunqueue-logs-${t}.log`;try{document.body.appendChild(i),i.click()}finally{i.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}}function se(){let{data:e,error:n,loading:r,refetch:i}=ce(),a=(0,D.useMemo)(()=>e?.lines??[],[e]),[s,c]=(0,D.useState)(`all`),[l,u]=(0,D.useState)(``),[d,g]=(0,D.useState)(!0),[v,y]=(0,D.useState)(!1),b=(0,D.useRef)(null),x=(0,D.useMemo)(()=>{let e=l.trim().toLowerCase();return a.map(e=>e.line.includes(`\x1B`)?{...e,line:_(e.line)}:e).filter(t=>(s===`all`||t.stream===s)&&(!e||t.line.toLowerCase().includes(e)))},[a,s,l]);(0,D.useEffect)(()=>{if(!d)return;let e=b.current;e&&(e.scrollTop=e.scrollHeight)},[x.length,d]);let w=(0,D.useMemo)(()=>x.map(e=>v?`${J(e.ts)} [${e.stream}] ${e.line}`:e.line).join(`
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CvwrP0tU.js";import{t as i}from"./bq-F5BbTG1T.js";import{C as a,T as o,b as s,x as c}from"./icons-BVzwsfbG.js";import{n as l}from"./usePolledData-0CVelkl2.js";import{t as u}from"./Button-Ch1W94fJ.js";import{n as d,t as f}from"./Card-CWxrC8OY.js";import{i as p,n as m,r as h}from"./feedback-QDN1AsYt.js";import{t as g}from"./PageHeader-CvIyaFOO.js";import{f as _,i as v,l as y,n as b,u as x}from"./format-Cg7VCIZW.js";import{a as S}from"./index-BFW2_47n.js";import{i as C,n as w,t as T}from"./form-C4oby9pI.js";import{t as E}from"./useControlActionGuard-B-bzKZKI.js";var D=e(n(),1),O=r();function k({children:e}){return(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs text-fg`,children:e})}function A({agentBase:e}){return(0,O.jsx)(f,{children:(0,O.jsxs)(`details`,{className:`group`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2`,children:[(0,O.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:`How server control works`}),(0,O.jsx)(`span`,{className:`text-xs text-muted transition-transform group-open:rotate-90`,children:`▶`})]}),(0,O.jsxs)(`div`,{className:`mt-4 space-y-4 text-sm leading-relaxed text-muted`,children:[(0,O.jsxs)(`p`,{children:[`A browser can't start or stop an OS process, so the dashboard talks to a small local`,` `,(0,O.jsx)(`span`,{className:`font-medium text-fg`,children:`control agent`}),` (`,(0,O.jsx)(k,{children:e}),`) that supervises the bunqueue server process — start, stop and restart — and streams its logs back here.`]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Launch & environment`}),(0,O.jsxs)(`p`,{children:[`The agent runs your `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Command`}),` and injects`,` `,(0,O.jsx)(k,{children:`HTTP_PORT`}),` and `,(0,O.jsx)(k,{children:`TCP_PORT`}),`, plus `,(0,O.jsx)(k,{children:`BUNQUEUE_DATA_PATH`}),` `,`only for SQLite. Memory and PostgreSQL modes remove every SQLite path alias before launch. Any `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Environment variables`}),` you add are included too. The default `,(0,O.jsx)(k,{children:`bunx bunqueue@2.9.4 start`}),` resolves the verified release; pointing the command at a local entry (e.g.`,` `,(0,O.jsx)(k,{children:`bun run /path/to/bunqueue/src/main.ts`}),`) works without one.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`When changes apply`}),(0,O.jsxs)(`p`,{children:[`Config is editable any time, but `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Command`}),`, ports and data path only take effect on the `,(0,O.jsx)(`span`,{className:`text-fg`,children:`next start/restart`}),` `,`— the running process keeps the config it launched with until then.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Data path`}),(0,O.jsxs)(`p`,{children:[`Relative paths resolve against the `,(0,O.jsx)(`span`,{className:`text-fg`,children:`agent's`}),` working directory. SQLite creates the database `,(0,O.jsx)(`span`,{className:`text-fg`,children:`file`}),` but not its parent `,(0,O.jsx)(`span`,{className:`text-fg`,children:`folder`}),` — if start fails with`,` `,(0,O.jsx)(k,{children:`SQLITE_CANTOPEN`}),`, create the directory first or use a path whose folder already exists.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Security`}),(0,O.jsxs)(`p`,{children:[`The direct agent listener binds `,(0,O.jsx)(k,{children:`127.0.0.1`}),`, locks CORS to an allowlist (never `,(0,O.jsx)(k,{children:`*`}),`), and rejects a disallowed `,(0,O.jsx)(k,{children:`Origin`}),` or`,` `,(0,O.jsx)(k,{children:`Host`}),` with `,(0,O.jsx)(k,{children:`403`}),`. The all-in-one server's `,(0,O.jsx)(k,{children:`/agent`}),` `,`bridge treats LAN and reverse-proxy access as remote: `,(0,O.jsx)(k,{children:`AGENT_TOKEN`}),` is then mandatory for status, logs, database reads and changes alike. Without it, the bridge stays disabled.`]}),(0,O.jsxs)(`p`,{children:[`If you started the agent with `,(0,O.jsx)(k,{children:`AGENT_TOKEN`}),`, enter that token under`,` `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Settings → Agent token`}),` (or when the lock screen prompts). It stays in memory for this browser session; never bake it into a public`,` `,(0,O.jsx)(k,{children:`VITE_*`}),` value.`]})]})]})]})})}function j(e,t,n,r){return{baseline:F(e),id:r,revision:t,scope:n,value:F(e)}}function ee(e,t,n,r,i){return{accepted:F(e),acceptedRevision:t,before:n?F(n):null,beforeRevision:r,ignoreThroughRequestId:i}}function te(e,t,n,r){return P(t,e.accepted)?!1:r!==void 0&&e.ignoreThroughRequestId!==void 0?r<=e.ignoreThroughRequestId:n===void 0?e.before!==null&&P(t,e.before):n===e.beforeRevision||n===e.acceptedRevision}function M(e){if(!L(e))return R();let{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:a}=e;if(typeof t!=`string`||t.trim()===``||!I(n)||!I(r)||n===r||typeof i!=`string`||!L(a)||Object.values(a).some(e=>typeof e!=`string`))return R();let o=N(e.configRevision);return e.configRevision!==void 0&&o===void 0?R():{config:{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:Object.fromEntries(Object.entries(a))},revision:o}}function N(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:void 0}function ne(e){return I(e.httpPort)?I(e.tcpPort)?e.httpPort===e.tcpPort?`HTTP and TCP ports must differ`:null:`TCP port must be an integer between 1 and 65535`:`HTTP port must be an integer between 1 and 65535`}function re(e,t){if(!e)return[];let n=[];return e.command!==t.command&&n.push(`command`),e.httpPort!==t.httpPort&&n.push(`HTTP port`),e.tcpPort!==t.tcpPort&&n.push(`TCP port`),e.dataPath!==t.dataPath&&n.push(`data path`),z(e.extraEnv)!==z(t.extraEnv)&&n.push(`environment variables`),n}function P(e,t){return JSON.stringify(B(e))===JSON.stringify(B(t))}function F(e){return{...e,extraEnv:{...e.extraEnv}}}function I(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=65535}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(){throw Error(`Configuration save returned a malformed response`)}function z(e){return JSON.stringify(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)))}function B(e){return{...e,extraEnv:Object.fromEntries(Object.entries(e.extraEnv).sort(([e],[t])=>e.localeCompare(t)))}}var V=0,H=e=>Object.entries(e).map(([e,t])=>({id:V++,key:e,value:t})),U=e=>{let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return t};function W(e){let t=e.map(e=>e.trim());return[...new Set(t.filter((e,t,n)=>e&&n.indexOf(e)!==t))]}var ie=[`AUTH_TOKENS`,`LOG_LEVEL`,`BUNQUEUE_STORAGE_DRIVER`,`BUNQUEUE_POSTGRES_URL`,`BUNQUEUE_POSTGRES_NAMESPACE`,`BUNQUEUE_POSTGRES_POOL_SIZE`,`BUNQUEUE_MAX_COMPLETED_JOBS`,`BUNQUEUE_COMPLETED_RETENTION_MS`,`S3_BACKUP_ENABLED`,`S3_BUCKET`,`METRICS_ENABLED`];function G({value:e,onChange:t,disabled:n}){let[r,i]=(0,D.useState)(()=>H(e)),a=e=>{i(e),t(U(e))},o=(e,t)=>a(r.map(n=>n.id===e?{...n,...t}:n)),s=(e=``)=>a([...r,{id:V++,key:e,value:``}]),c=e=>a(r.filter(t=>t.id!==e)),l=new Set(r.map(e=>e.key.trim()).filter(Boolean)),d=W(r.map(e=>e.key)),f=[...new Set(r.map(e=>e.key.trim()).filter(e=>e&&(/[\s=]/.test(e)||/[a-z]/.test(e))))];return(0,O.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.length===0&&(0,O.jsxs)(`p`,{className:`text-xs leading-relaxed text-faint`,children:[`No custom variables. The agent already injects`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`HTTP_PORT`}),`,`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`TCP_PORT`}),`, plus the SQLite data path unless PostgreSQL mode is selected.`]}),r.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`w-2/5 shrink-0`,children:(0,O.jsx)(w,{id:`env-key-${e.id}`,name:`env-key-${e.id}`,"aria-label":`Variable name${e.key?` ${e.key}`:``}`,className:`font-mono`,placeholder:`KEY`,value:e.key,disabled:n,autoComplete:`off`,spellCheck:!1,onChange:t=>o(e.id,{key:t.target.value})})}),(0,O.jsx)(`span`,{className:`text-faint`,children:`=`}),(0,O.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,O.jsx)(w,{id:`env-value-${e.id}`,name:`env-value-${e.id}`,"aria-label":`Value for ${e.key||`variable`}`,className:`font-mono`,placeholder:`value`,value:e.value,disabled:n,autoComplete:`off`,spellCheck:!1,onChange:t=>o(e.id,{value:t.target.value})})}),(0,O.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.key||`variable`}`,disabled:n,onClick:()=>c(e.id),className:`shrink-0 rounded-md px-2 py-1 text-xs text-faint transition-colors hover:text-danger disabled:opacity-40`,children:`✕`})]},e.id)),d.length>0&&(0,O.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Duplicate key`,d.length>1?`s`:``,` — the last value wins: `,d.join(`, `)]}),f.length>0&&(0,O.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Unusual key`,f.length>1?`s`:``,` — env names are usually UPPER_SNAKE_CASE with no spaces or "=": `,f.join(`, `),`. Saved as-is.`]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,O.jsx)(u,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>s(),children:`+ Add variable`}),ie.filter(e=>!l.has(e)).map(e=>(0,O.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>s(e),className:`rounded-md border border-line bg-surface-2 px-2 py-1 font-mono text-[11px] text-muted transition-colors hover:border-line-strong hover:text-fg disabled:opacity-40`,children:[`+ `,e]},e))]})]})}function K({status:e,onSaved:t,running:n,statusRequestId:r,getStatusRequestSequence:o,transitioning:s}){let c=E(`server-config`),l=(0,D.useRef)(0),p=(0,D.useRef)(null),m=(0,D.useRef)(null),[h,g]=(0,D.useState)(null),[_,v]=(0,D.useState)(!1),[y,b]=(0,D.useState)(!1),[x,S]=(0,D.useState)(null),[C,k]=(0,D.useState)(!1),[A,F]=(0,D.useState)(null);(0,D.useEffect)(()=>{p.current&&clearTimeout(p.current),p.current=null,m.current=null,g(null),v(!1),b(!1),S(null),k(!1),F(null)},[c.scopeKey]),(0,D.useEffect)(()=>{if(!e?.config||_)return;let t=m.current;t&&te(t,e.config,N(e.configRevision),r)||(m.current=null,g(j(e.config,N(e.configRevision),c.scopeKey,++l.current)),k(!1))},[c.scopeKey,_,e?.config,e?.configRevision,r]),(0,D.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let I=h?.scope===c.scopeKey?h:null,L=I?.value??e?.config??null;if(!L)return(0,O.jsx)(f,{children:`Loading…`});let R=t=>{let n=I??j(L,N(e?.configRevision),c.scopeKey,++l.current);g({...n,value:{...n.value,...t}}),v(!0),b(!1),k(!1)},z=re(e?.runningConfig??null,L),B=n&&z.length>0,V=s||x!==null,H=()=>{p.current&&clearTimeout(p.current),b(!0),p.current=setTimeout(()=>{p.current=null,b(!1)},2e3)},U=async n=>{let r=c.begin([`config`,`lifecycle`]);if(!r)return;let a=ne(L);if(a)return r.finish(),F(a);let s=I?.baseline??e?.config,u=I?.revision??N(e?.configRevision);if(u===void 0&&s&&e?.config&&!P(s,e.config))return r.finish(),k(!0),F(`Configuration changed elsewhere; reload the latest values before saving.`);F(null),k(!1),S(n?`restart`:`save`);try{let a=await i.control.setConfig(L,u);if(!r.isCurrent())return;let{config:s,revision:d}=M(a);if(m.current=ee(s,d,e?.config??null,N(e?.configRevision),o?.()),g(j(s,d,c.scopeKey,++l.current)),v(!1),n&&await i.control.restart(),!r.isCurrent())return;H(),await t()}catch(e){if(!r.isCurrent())return;let t=e.message;t.startsWith(`Configuration changed since revision`)&&k(!0),F(t)}finally{r.finish()&&S(null)}},W=()=>U(!1);return(0,O.jsxs)(f,{children:[(0,O.jsx)(d,{title:`Configuration`}),(0,O.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:n?`Ports and data path apply on the next restart — edit freely, then restart.`:`Edit and save; the config is used the next time the server starts.`}),(0,O.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),W()},children:[(0,O.jsx)(T,{label:`Command`,hint:`The exact command the agent runs to launch bunqueue. It receives HTTP_PORT and TCP_PORT; BUNQUEUE_DATA_PATH is injected only for SQLite and removed in non-SQLite modes. The default resolves Bunqueue 2.9.4 with bunx; offline installs can point at a local entry.`,children:(0,O.jsx)(w,{name:`server-command`,autoComplete:`off`,spellCheck:!1,value:L.command,disabled:V,onChange:e=>R({command:e.target.value}),placeholder:`bunx bunqueue@2.9.4 start`})}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,O.jsx)(T,{label:`HTTP port`,hint:`Dashboard API + SSE.`,children:(0,O.jsx)(w,{name:`server-http-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:L.httpPort,disabled:V,onChange:e=>R({httpPort:Number(e.target.value)})})}),(0,O.jsx)(T,{label:`TCP port`,hint:`Binary protocol. Must differ from HTTP.`,children:(0,O.jsx)(w,{name:`server-tcp-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:L.tcpPort,disabled:V,onChange:e=>R({tcpPort:Number(e.target.value)})})})]}),(0,O.jsx)(T,{label:`Data path`,hint:`Durable SQLite path for the managed broker and Workflow Engine, relative to the agent's working directory. In PostgreSQL mode the agent keeps it for Workflow state but does not pass it to the broker.`,children:(0,O.jsx)(w,{name:`server-data-path`,autoComplete:`off`,spellCheck:!1,value:L.dataPath,disabled:V,onChange:e=>R({dataPath:e.target.value})})}),(0,O.jsx)(T,{label:`Environment variables`,hint:`Injected on start. Includes Bunqueue 2.9.3 completed-history controls: BUNQUEUE_MAX_COMPLETED_JOBS bounds hot memory, while BUNQUEUE_COMPLETED_RETENTION_MS opts into durable age-based expiry. Memory and PostgreSQL modes remove inherited SQLite path aliases. Applies on the next restart.`,children:(0,O.jsx)(G,{value:L.extraEnv??{},onChange:e=>R({extraEnv:e}),disabled:V},I?.id??`initial`)}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,O.jsx)(u,{type:`submit`,variant:`accent`,size:`sm`,disabled:V,children:`Save config`}),n&&(0,O.jsxs)(u,{variant:`warning`,size:`sm`,disabled:V,onClick:()=>{let e=z.length>0?` Changed: ${z.join(`, `)}.`:``;if(window.confirm(`Save configuration and restart the server to apply it?${e}`))return U(!0)},children:[(0,O.jsx)(a,{className:`size-3.5`}),` Save & restart`]}),B&&!y&&(0,O.jsx)(`span`,{className:`text-xs text-warning`,children:`Restart to apply changes`}),y&&(0,O.jsx)(`span`,{className:`text-xs text-success`,children:`Saved`}),C&&(0,O.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,disabled:V,onClick:()=>{e?.config&&(m.current=null,g(j(e.config,N(e.configRevision),c.scopeKey,++l.current)),v(!1),k(!1),F(null))},children:`Reload latest`}),A&&(0,O.jsx)(`span`,{className:`text-xs text-danger`,children:A})]})]})]})}var q=[`all`,`stdout`,`stderr`,`sys`],J=e=>`${new Date(e).toLocaleTimeString([],{hour12:!1})}.${String(e%1e3).padStart(3,`0`)}`,ae=e=>e===`stderr`?`text-danger/90`:e===`sys`?`text-accent/80`:`text-muted`;function oe(e,t=Date.now()){let n=new Blob([e],{type:`text/plain`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`bunqueue-logs-${t}.log`;try{document.body.appendChild(i),i.click()}finally{i.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}}function se(){let{data:e,error:n,loading:r,refetch:i}=ce(),a=(0,D.useMemo)(()=>e?.lines??[],[e]),[s,c]=(0,D.useState)(`all`),[l,u]=(0,D.useState)(``),[d,g]=(0,D.useState)(!0),[v,y]=(0,D.useState)(!1),b=(0,D.useRef)(null),x=(0,D.useMemo)(()=>{let e=l.trim().toLowerCase();return a.map(e=>e.line.includes(`\x1B`)?{...e,line:_(e.line)}:e).filter(t=>(s===`all`||t.stream===s)&&(!e||t.line.toLowerCase().includes(e)))},[a,s,l]);(0,D.useEffect)(()=>{if(!d)return;let e=b.current;e&&(e.scrollTop=e.scrollHeight)},[x.length,d]);let w=(0,D.useMemo)(()=>x.map(e=>v?`${J(e.ts)} [${e.stream}] ${e.line}`:e.line).join(`
|
|
2
2
|
`),[x,v]);return(0,O.jsxs)(f,{padded:!1,className:`overflow-hidden`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-4 py-3`,children:[(0,O.jsx)(`h3`,{className:`mr-1 text-base font-semibold text-fg`,children:`Process logs`}),(0,O.jsx)(C,{options:q,value:s,onChange:c}),(0,O.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,O.jsx)(o,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,O.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),"aria-label":`Filter log lines`,name:`process-log-filter`,autoComplete:`off`,placeholder:`Filter…`,className:`h-8 w-full rounded-lg border border-line bg-surface-2 pl-8 pr-2 text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,O.jsx)(Y,{on:d,onClick:()=>g(e=>!e),label:`Follow`}),(0,O.jsx)(Y,{on:v,onClick:()=>y(e=>!e),label:`Times`}),(0,O.jsx)(S,{value:w}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>{oe(w)},disabled:x.length===0,className:`rounded-md border border-line bg-surface-2 px-2 py-1 text-xs text-muted transition-colors hover:text-fg disabled:opacity-40`,children:`Download`})]}),n&&e&&(0,O.jsx)(`div`,{className:`border-b border-line px-4 pt-3 font-sans`,children:(0,O.jsx)(p,{message:`Process-log refresh failed — showing the last received lines. ${n.message}`,onRetry:i})}),(0,O.jsx)(`div`,{ref:b,className:`max-h-80 min-h-40 overflow-y-auto p-4 font-mono text-xs leading-relaxed`,children:r&&!e&&!n?(0,O.jsx)(`div`,{className:`font-sans`,children:(0,O.jsx)(h,{label:`Loading process logs…`})}):n&&!e?(0,O.jsx)(`div`,{className:`font-sans`,children:(0,O.jsx)(m,{error:n,onRetry:i})}):x.length===0?(0,O.jsx)(`p`,{className:`text-faint`,children:a.length===0?`No output yet.`:`No lines match the current filter.`}):x.map(e=>(0,O.jsxs)(`div`,{className:t(`whitespace-pre-wrap`,ae(e.stream)),children:[v&&(0,O.jsx)(`span`,{className:`mr-2 text-faint`,children:J(e.ts)}),e.line]},e.seq))}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-t border-line px-4 py-2 text-[11px] text-faint`,children:[(0,O.jsx)(`span`,{children:n&&!e?`logs unavailable`:x.length===a.length?`${a.length} lines`:`${x.length} of ${a.length} lines`}),(0,O.jsx)(`span`,{children:n?`refresh failed`:d?`following tail`:`paused`})]})]})}function Y({on:e,onClick:n,label:r}){return(0,O.jsx)(`button`,{type:`button`,onClick:n,"aria-pressed":e,className:t(`rounded-md border px-2 py-1 text-xs transition-colors`,e?`border-accent/40 bg-accent/10 text-accent`:`border-line bg-surface-2 text-muted hover:text-fg`),children:r})}function ce(){return l(()=>i.control.logs(),[])}var X={running:{label:`Running`,tone:`text-success`,dot:`bg-emerald-400`},starting:{label:`Starting`,tone:`text-warning`,dot:`bg-amber-400`},stopping:{label:`Stopping`,tone:`text-warning`,dot:`bg-amber-400`},stopped:{label:`Stopped`,tone:`text-danger`,dot:`bg-red-400`}};function Z({startedAt:e}){let[,t]=(0,D.useState)(0);return(0,D.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,O.jsx)(O.Fragment,{children:x((Date.now()-e)/1e3)})}function Q({label:e,children:t,title:n}){return(0,O.jsxs)(`div`,{className:`min-w-0`,title:n,children:[(0,O.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:e}),(0,O.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,children:t})]})}function le({status:e,agentBase:n,transitioning:r,stale:i=!1,vitals:o=null,busy:l,onStart:d,onStop:f,onRestart:p}){let m=e?.status??`stopped`,h=e?.managementMode===`external`,g=h?e?.reachable===!0:m===`running`,_=h?e?.healthy?{label:`External`,tone:`text-success`,dot:`bg-emerald-400`}:e?.reachable?{label:`External`,tone:`text-warning`,dot:`bg-amber-400`}:{label:`External`,tone:`text-danger`,dot:`bg-red-400`}:X[m]??X.stopped,y=!!e?.healthy&&!i,b=!h&&!g&&e?.exitCode!=null&&e.exitCode!==0,x=e?.runningConfig??e?.config??null,C=x?.httpPort??6790,w=h?e?.externalUrl??`—`:`http://localhost:${C}`,T=w===`—`?`—`:`${w}/health`;return(0,O.jsxs)(`section`,{className:`mb-6 overflow-hidden rounded-xl border border-line bg-surface`,children:[(0,O.jsx)(`div`,{className:t(`h-0.5 bg-gradient-to-r to-transparent`,g&&y?`from-emerald-400/80 via-emerald-400/25`:g||r?`from-amber-400/80 via-amber-400/25`:`from-red-400/70 via-red-400/20`)}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-5 p-5 lg:flex-row lg:items-center lg:justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsxs)(`span`,{className:`relative flex size-3.5 shrink-0`,children:[g&&y&&(0,O.jsx)(`span`,{className:`absolute inline-flex size-full rounded-full bg-emerald-400 opacity-50 motion-safe:animate-ping`}),(0,O.jsx)(`span`,{className:t(`relative inline-flex size-3.5 rounded-full`,_.dot)})]}),(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,O.jsx)(`span`,{className:t(`text-2xl font-bold tracking-tight`,_.tone),children:r&&l?`${l}…`:_.label}),e?.version&&(0,O.jsxs)(`span`,{className:`font-mono text-xs text-muted`,children:[`bunqueue v`,e.version]}),b&&(0,O.jsxs)(`span`,{className:`rounded-full bg-red-500/15 px-2 py-0.5 font-mono text-[11px] font-medium text-danger`,children:[`crashed · exit `,e?.exitCode]})]}),(0,O.jsx)(`div`,{className:`mt-1 font-mono text-xs text-muted`,children:i?(0,O.jsxs)(`span`,{className:`text-warning`,children:[`last known: pid `,e?.pid??`—`,` — agent unreachable, state may have changed`]}):h?(0,O.jsx)(`span`,{title:e?.healthError,children:e?.reachable?y?`healthy via ${T}`:`reachable but unhealthy via ${T}`:`unreachable via ${T}`}):g?(0,O.jsxs)(O.Fragment,{children:[y?`healthy`:`waiting for health…`,` · pid `,e?.pid??`—`,` · up`,` `,e?.startedAt?(0,O.jsx)(Z,{startedAt:e.startedAt}):`—`]}):`process not running — start it below or point the dashboard at an external server`})]})]}),!h&&(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,O.jsxs)(u,{variant:`success`,disabled:g||r||i,onClick:d,children:[(0,O.jsx)(c,{className:`size-4`}),` Start`]}),(0,O.jsxs)(u,{variant:`warning`,disabled:!g||r||i,onClick:f,children:[(0,O.jsx)(s,{className:`size-4`}),` Stop`]}),(0,O.jsxs)(u,{disabled:r||i,onClick:p,children:[(0,O.jsx)(a,{className:`size-4`}),` Restart`]})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 border-t border-line bg-surface-2/30 px-5 py-4 md:grid-cols-3 xl:grid-cols-7`,children:[(0,O.jsx)(Q,{label:`Memory`,children:o?.memory?.rss==null?(0,O.jsx)(`span`,{className:`text-faint`,children:`—`}):(0,O.jsxs)(`span`,{title:`heap ${o.memory.heapUsed??`?`} / ${o.memory.heapTotal??`?`} MB`,children:[o.memory.rss,` MB rss`]})}),(0,O.jsx)(Q,{label:`Connections`,children:o?.connections?`${o.connections.tcp??0} tcp · ${o.connections.ws??0} ws · ${o.connections.sse??0} sse`:(0,O.jsx)(`span`,{className:`text-faint`,children:`—`})}),(0,O.jsx)(Q,{label:h?`Health target`:`API endpoint`,title:T,children:w===`—`?(0,O.jsx)(`span`,{className:`text-faint`,children:w}):(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(`a`,{href:T,target:`_blank`,rel:`noreferrer`,className:`truncate text-accent hover:underline`,children:w}),(0,O.jsx)(S,{value:w})]})}),(0,O.jsx)(Q,{label:h?`Lifecycle`:`Ports`,children:h?`external`:x?`${x.httpPort} http · ${x.tcpPort} tcp`:`—`}),(0,O.jsx)(Q,{label:h?`Health HTTP`:`Started`,children:h?e?.healthStatus??`—`:g&&e?.startedAt?v(e.startedAt):`—`}),(0,O.jsx)(Q,{label:`Control agent`,title:n,children:n.replace(/^https?:\/\//,``)}),(0,O.jsx)(Q,{label:h?`Supervisor`:`Storage`,title:e?.storageMode===`postgres`?`PostgreSQL ${e.postgresTarget??`configured`} · namespace ${e.postgresNamespace??`default`}`:e?.storageMode,children:h?`managed elsewhere`:e?.storageMode===`postgres`?`postgres · ${e.postgresNamespace??`default`}`:e?.storageMode??`—`})]})]})}var $=[{key:`size`,label:`Database`,color:`bg-accent`},{key:`walSize`,label:`WAL`,color:`bg-amber-400`},{key:`shmSize`,label:`SHM`,color:`bg-zinc-500`}];function ue({db:e}){let n=e.totalSize||0;return(0,O.jsxs)(f,{children:[(0,O.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Storage`}),(0,O.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:e.exists?`${b(n)} on disk`:`not created yet`})]}),(0,O.jsxs)(`p`,{className:`mb-4 flex items-center gap-1.5 truncate font-mono text-xs text-faint`,title:e.path,children:[(0,O.jsx)(`span`,{className:`truncate`,children:e.path}),(0,O.jsx)(S,{value:e.path})]}),e.exists&&n>0?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`flex h-2.5 overflow-hidden rounded-full bg-surface-2`,children:$.map(r=>{let i=e[r.key];return i?(0,O.jsx)(`div`,{className:t(`h-full`,r.color),style:{width:`${i/n*100}%`},title:`${r.label}: ${b(i)}`},r.key):null})}),(0,O.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 font-mono text-[11px] text-faint`,children:[$.map(n=>(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(`span`,{className:t(`size-2 rounded-full`,n.color)}),n.label,` `,(0,O.jsx)(`span`,{className:`text-fg`,children:b(e[n.key])})]},n.key)),e.mtimeMs?(0,O.jsxs)(`span`,{className:`ml-auto`,children:[`written `,y(e.mtimeMs)]}):null]})]}):(0,O.jsx)(`p`,{className:`rounded-lg border border-dashed border-line px-4 py-6 text-center text-sm text-faint`,children:`The database appears here after the first start — SQLite creates the file at the configured data path.`})]})}function de(){let e=(0,D.useRef)(0),t=(0,D.useRef)(new WeakMap),{data:n,error:r,refetch:a}=l(async()=>{let n=++e.current,r=await i.control.status();return t.current.set(r,n),r},[]),o=E(`server-lifecycle`),[s,c]=(0,D.useState)(null),[u,m]=(0,D.useState)(null);(0,D.useEffect)(()=>{c(null),m(null)},[o.scopeKey]);let h=n?.managementMode===`external`,_=h?n?.reachable===!0:n?.status===`running`,{data:v}=l(()=>_?i.health():Promise.resolve(null),[_]),y=_?v??null:null,b=y?.connections?` This drops ${y.connections.tcp??0} TCP / ${y.connections.ws??0} WS connections; in-flight jobs are interrupted.`:` In-flight jobs are interrupted.`,x=async(e,t,n)=>{let r=o.begin(`lifecycle`);if(r){if(n&&!window.confirm(n)){r.finish();return}if(!r.isCurrent()){r.finish();return}c(e),m(null);try{if(await t(),!r.isCurrent())return;await a()}catch(e){if(!r.isCurrent())return;m(e.message)}finally{r.finish()&&c(null)}}};if(r&&!n)return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(g,{title:`Server`,description:`Start, stop and restart the bunqueue server.`}),(0,O.jsx)(p,{message:`Control agent unreachable — server lifecycle controls are unavailable.`,onRetry:a}),(0,O.jsxs)(f,{children:[(0,O.jsx)(d,{title:`Control agent not running`}),(0,O.jsxs)(`p`,{className:`text-sm text-muted`,children:[`The local control agent is unreachable at`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:i.agentBase}),`. It manages the bunqueue server process (start / stop / restart). Start it with:`]}),(0,O.jsxs)(`pre`,{className:`mt-3 overflow-x-auto rounded-lg border border-line bg-surface-2 px-3 py-2 text-xs`,children:[`bun start`,` `,`# agent + dashboard together (recommended)`,`
|
|
3
3
|
`,`bun run agent`,` `,`# agent only, if the dashboard is already running`]}),(0,O.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`This page reconnects automatically once the agent is up — no reload needed.`})]})]});let S=n?.status??`stopped`,C=S===`running`,w=S===`starting`||S===`stopping`||s!=null,T=r!=null&&n!=null;return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(g,{title:`Server`,description:h?`Observe the Bunqueue server managed by an external supervisor.`:`Supervise the bunqueue server process — lifecycle, configuration, storage and logs.`}),u&&(0,O.jsx)(`div`,{role:`status`,className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-danger`,children:u}),T&&(0,O.jsx)(`div`,{className:`mb-4 rounded-lg border border-amber-500/20 bg-amber-500/5 px-4 py-2 text-sm text-warning`,children:`Control agent unreachable — showing last known state. Lifecycle actions are disabled until it responds again.`}),(0,O.jsx)(le,{status:n,agentBase:i.agentBase,stale:T,vitals:y,transitioning:w,busy:s,onStart:()=>x(`starting`,()=>i.control.start()),onStop:()=>x(`stopping`,()=>i.control.stop(),`Stop the bunqueue server?${b}`),onRestart:()=>x(`restarting`,()=>i.control.restart(),`Restart the bunqueue server?${b}`)}),h?(0,O.jsxs)(f,{children:[(0,O.jsx)(d,{title:`Managed externally`}),(0,O.jsxs)(`p`,{className:`text-sm text-muted`,children:[`This dashboard is attached to`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:n?.externalUrl??`BUNQUEUE_URL`}),`. Start, stop, restart and launch configuration are intentionally unavailable while`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:`BUNQUEUE_MANAGED=0`}),`. Use systemd, Docker, Kubernetes or the broker's external supervisor instead.`]})]}):(0,O.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,O.jsx)(K,{status:n,onSaved:a,running:C,statusRequestId:n?t.current.get(n):void 0,getStatusRequestSequence:()=>e.current,transitioning:w}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[n?.db&&(0,O.jsx)(ue,{db:n.db}),(0,O.jsx)(se,{})]})]}),(0,O.jsx)(`div`,{className:`mt-6`,children:(0,O.jsx)(A,{agentBase:i.agentBase})})]})}export{de as ServerControl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{c as r,o as i,s as a}from"./connectionStore-BJLihGaC.js";import{f as o}from"./icons-BVzwsfbG.js";import{n as s,t as c}from"./Button-Ch1W94fJ.js";import{n as l,t as u}from"./Card-CWxrC8OY.js";import{t as d}from"./PageHeader-CvIyaFOO.js";import{o as f}from"./index-mID5W7vq.js";import{a as p,n as m,t as h}from"./form-C4oby9pI.js";var g=n(),_=[[`1000`,`1 second`],[`2000`,`2 seconds`],[`3000`,`3 seconds`],[`5000`,`5 seconds`],[`10000`,`10 seconds`]];function v(){let{refreshMs:e,setRefreshMs:t}=i(),{theme:n,setTheme:r}=f();return(0,g.jsxs)(u,{children:[(0,g.jsx)(l,{title:`Appearance & refresh`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,g.jsx)(h,{label:`Theme`,children:(0,g.jsxs)(p,{name:`theme`,autoComplete:`off`,value:n,onChange:e=>r(e.target.value),children:[(0,g.jsx)(`option`,{value:`dark`,children:`Dark`}),(0,g.jsx)(`option`,{value:`light`,children:`Light`})]})}),(0,g.jsx)(h,{label:`Refresh interval`,children:(0,g.jsx)(p,{name:`refresh-interval`,autoComplete:`off`,value:String(e),onChange:e=>t(Number(e.target.value)),children:_.map(([e,t])=>(0,g.jsx)(`option`,{value:e,children:t},e))})})]})]})}var y=e(t(),1),b=1e4,x=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;async function S(e,t={},n=b){let r=new AbortController,i=t.signal,a=i?AbortSignal.any([i,r.signal]):r.signal,o=Error(`Connection test timed out after ${Math.ceil(n/1e3)} seconds.`),s,c,l=new Promise((e,t)=>{s=setTimeout(()=>{r.abort(o),t(o)},n)}),u=i?new Promise((e,t)=>{let n=()=>{t(i.reason??new DOMException(`Connection test aborted`,`AbortError`))};i.aborted?n():(i.addEventListener(`abort`,n,{once:!0}),c=()=>i.removeEventListener(`abort`,n))}):null;try{let n=(async()=>{let n=await fetch(e,{...t,signal:a});return{response:n,value:await n.json()}})();return await Promise.race(u?[n,l,u]:[n,l])}catch(e){throw r.signal.aborted&&r.signal.reason===o?o:e}finally{s!==void 0&&clearTimeout(s),c?.()}}async function C(e,t={},n=b){let{response:r,value:i}=await S(e,t,n);if(!r.ok&&r.status!==503)throw Error(`HTTP ${r.status}`);if(typeof i!=`object`||!i||Array.isArray(i))throw Error(`Malformed health response`);let a=i;if(typeof a.ok!=`boolean`||a.status!==`healthy`&&a.status!==`degraded`||!Number.isSafeInteger(a.uptime)||a.uptime<0||typeof a.version!=`string`||!x.test(a.version)||a.ok!==(a.status===`healthy`))throw Error(`Malformed health response`);return{response:r,health:a}}function w(){let e=i(),[t,n]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),[x,w]=(0,y.useState)(null),[T,E]=(0,y.useState)(null),D=(0,y.useRef)(!0),O=(0,y.useRef)(0),k=(0,y.useRef)(null),A=(0,y.useRef)(null),j=(0,y.useCallback)(()=>{A.current!==null&&clearTimeout(A.current),A.current=null,D.current&&E(null)},[]),M=(0,y.useCallback)(()=>{O.current+=1,k.current?.abort(new DOMException(`Connection test superseded`,`AbortError`)),k.current=null,D.current&&(h(null),_(null))},[]),N=(0,y.useCallback)(()=>{M(),j()},[j,M]);(0,y.useEffect)(()=>(D.current=!0,()=>{D.current=!1,O.current+=1,k.current?.abort(new DOMException(`Settings unmounted`,`AbortError`)),A.current!==null&&clearTimeout(A.current)}),[]),(0,y.useEffect)(()=>{let t=e.profiles.find(t=>t.id===e.activeProfileId);n(t?.name??`Bunqueue`),s(e.baseUrl),l(e.agentBaseUrl),d(e.token),p(e.agentToken),b(null),w(null),M()},[e.activeProfileId,e.agentBaseUrl,e.baseUrl,e.profiles,e.token,e.agentToken,M]);let P=()=>{let e=i.getState();return JSON.stringify([e.activeProfileId,e.baseUrl,e.agentBaseUrl,e.token,e.agentToken])},F=async e=>{M();let t=r(e===`server`?o:c);if(!t){e===`server`?b(a):w(a),_({ok:!1,msg:a});return}e===`server`?b(null):w(null);let n=O.current,i=new AbortController,s=P(),l=()=>D.current&&n===O.current&&!i.signal.aborted&&P()===s;k.current=i,h(e),_(null);let d=performance.now();try{if(e===`server`){let{response:e,health:n}=await C(`${t}/health`,{headers:u.trim()?{Authorization:`Bearer ${u.trim()}`}:void 0,signal:i.signal});if(!l())return;let r=e.status===503||n.status===`degraded`;_({ok:!r,msg:`${r?`Server reachable`:`Connected`} in ${Math.round(performance.now()-d)}ms · bunqueue v${n.version}${r?` · degraded`:``}`})}else{let{response:e,value:n}=await S(`${t}/control/status`,{headers:f.trim()?{Authorization:`Bearer ${f.trim()}`}:void 0,signal:i.signal});if(!e.ok)throw Error(`HTTP ${e.status}`);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Malformed control agent response`);let r=n;if(![`running`,`stopped`,`starting`,`stopping`].includes(String(r.status)))throw Error(`Malformed control agent response`);if(!l())return;_({ok:!0,msg:`Agent connected in ${Math.round(performance.now()-d)}ms · server ${r.status}${r.storageMode?` · ${r.storageMode}`:``}`})}}catch(e){l()&&_({ok:!1,msg:e.message})}finally{D.current&&n===O.current&&(k.current=null,h(null))}},I=()=>{M();let n=r(o),i=r(c);if(b(n?null:a),w(i?null:a),!n||!i)return;let s=e.saveConnection({name:t,baseUrl:n,agentBaseUrl:i,token:u,agentToken:f});j(),E({ok:s.persisted,msg:s.persisted?`Saved ✓`:`Saved for this session only — browser storage unavailable${s.error?`: ${s.error}`:`.`}`}),A.current=setTimeout(()=>D.current&&E(null),4e3)},L=()=>{N(),e.addProfile({name:`Bunqueue ${e.profiles.length+1}`,baseUrl:`http://localhost:6790`,agentBaseUrl:`http://localhost:6800`,token:``,agentToken:``})},R=()=>{let t=e.profiles.find(t=>t.id===e.activeProfileId);!t||!window.confirm(`Remove connection profile "${t.name}"?`)||e.removeProfile(t.id)};return{...e,name:t,setName:n,url:o,setUrl:s,agentUrl:c,setAgentUrl:l,tok:u,setTok:d,agentTok:f,setAgentTok:p,testing:m,result:g,urlError:v,agentUrlError:x,saveNotice:T,edit:N,save:I,add:L,remove:R,testServer:()=>F(`server`),testAgent:()=>F(`agent`)}}function T({id:e,label:t,hint:n,value:r,placeholder:i,onChange:a}){let[c,l]=(0,y.useState)(!1);return(0,g.jsx)(h,{label:t,hint:n,htmlFor:e,children:(0,g.jsxs)(`div`,{className:`relative`,children:[(0,g.jsx)(m,{id:e,name:e,type:c?`text`:`password`,value:r,onChange:e=>a(e.target.value),placeholder:i,className:`pr-10`,autoComplete:`off`,spellCheck:!1}),(0,g.jsx)(s,{"aria-label":c?`Hide ${t.toLowerCase()}`:`Show ${t.toLowerCase()}`,className:`absolute right-0.5 top-1/2 -translate-y-1/2`,onClick:()=>l(e=>!e),children:(0,g.jsx)(o,{className:`size-4`})})]})})}function E(){let e=w(),t=t=>n=>{e.edit(),t(n)};return(0,g.jsxs)(u,{children:[(0,g.jsx)(l,{title:`Bunqueue fleet connections`}),(0,g.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_auto_auto]`,children:[(0,g.jsx)(h,{label:`Active node`,children:(0,g.jsx)(p,{"aria-label":`Active Bunqueue node`,value:e.activeProfileId,onChange:t=>e.activateProfile(t.target.value),children:e.profiles.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))})}),(0,g.jsx)(c,{className:`self-end`,onClick:e.add,children:`Add node`}),(0,g.jsx)(c,{className:`self-end`,variant:`danger`,disabled:e.profiles.length===1,onClick:e.remove,children:`Remove`})]}),(0,g.jsx)(h,{label:`Node name`,children:(0,g.jsx)(m,{name:`profile-name`,value:e.name,onChange:n=>t(e.setName)(n.target.value),maxLength:64,autoComplete:`off`,placeholder:`broker-eu-1`})}),(0,g.jsx)(h,{label:`Server URL`,children:(0,g.jsx)(m,{name:`server-url`,value:e.url,onChange:n=>{t(e.setUrl)(n.target.value)},placeholder:`/api or https://queue.example.com`,autoComplete:`off`,inputMode:`url`,"aria-invalid":e.urlError?!0:void 0,"aria-describedby":e.urlError?`server-url-error`:`server-url-help`})}),e.urlError?(0,g.jsx)(`p`,{id:`server-url-error`,className:`-mt-2 text-xs text-danger`,children:e.urlError}):(0,g.jsx)(`p`,{id:`server-url-help`,className:`-mt-2 text-xs text-faint`,children:`Bunqueue HTTP API for this broker. All queue pages use the selected node.`}),(0,g.jsx)(h,{label:`Control agent URL`,children:(0,g.jsx)(m,{name:`agent-url`,value:e.agentUrl,onChange:n=>t(e.setAgentUrl)(n.target.value),placeholder:`/agent or https://broker.example.com/agent`,autoComplete:`off`,inputMode:`url`,"aria-invalid":e.agentUrlError?!0:void 0,"aria-describedby":e.agentUrlError?`agent-url-error`:`agent-url-help`})}),e.agentUrlError?(0,g.jsx)(`p`,{id:`agent-url-error`,className:`-mt-2 text-xs text-danger`,children:e.agentUrlError}):(0,g.jsx)(`p`,{id:`agent-url-help`,className:`-mt-2 text-xs text-faint`,children:`One paired agent per broker enables lifecycle, configuration, Flow, Workflow and advanced queue controls.`}),(0,g.jsx)(T,{id:`bearer-token`,label:`Bearer token (optional)`,hint:`Server credential, kept in memory only and isolated to this node.`,value:e.tok,onChange:t(e.setTok),placeholder:`only if AUTH_TOKENS is set`}),(0,g.jsx)(T,{id:`agent-token`,label:`Agent token (optional)`,hint:`AGENT_TOKEN for this node, kept in memory only.`,value:e.agentTok,onChange:t(e.setAgentTok),placeholder:`only if AGENT_TOKEN is set`}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(c,{variant:`accent`,onClick:e.save,children:`Save`}),(0,g.jsx)(c,{onClick:e.testServer,children:e.testing===`server`?`Restart test`:`Test connection`}),(0,g.jsx)(c,{onClick:e.testAgent,children:e.testing===`agent`?`Restart agent test`:`Test agent`}),e.saveNotice&&(0,g.jsx)(`span`,{role:`status`,className:e.saveNotice.ok?`text-sm text-success`:`text-sm text-warning`,children:e.saveNotice.msg}),e.result&&(0,g.jsx)(`span`,{role:`status`,className:e.result.ok?`text-sm text-success`:`text-sm text-danger`,children:e.result.msg})]}),(0,g.jsx)(`p`,{className:`-mt-1 text-xs text-faint`,children:`Switching the active node retargets every Dashboard feature atomically. Profile metadata persists; both credentials are erased on reload.`})]})]})}function D(){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(d,{title:`Settings`,description:`Bunqueue fleet connections, credentials and appearance.`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsx)(E,{}),(0,g.jsx)(v,{})]})]})}export{D as Settings};
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{c as r,o as i,s as a}from"./connectionStore-BJLihGaC.js";import{f as o}from"./icons-BVzwsfbG.js";import{n as s,t as c}from"./Button-Ch1W94fJ.js";import{n as l,t as u}from"./Card-CWxrC8OY.js";import{t as d}from"./PageHeader-CvIyaFOO.js";import{o as f}from"./index-BFW2_47n.js";import{a as p,n as m,t as h}from"./form-C4oby9pI.js";var g=n(),_=[[`1000`,`1 second`],[`2000`,`2 seconds`],[`3000`,`3 seconds`],[`5000`,`5 seconds`],[`10000`,`10 seconds`]];function v(){let{refreshMs:e,setRefreshMs:t}=i(),{theme:n,setTheme:r}=f();return(0,g.jsxs)(u,{children:[(0,g.jsx)(l,{title:`Appearance & refresh`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,g.jsx)(h,{label:`Theme`,children:(0,g.jsxs)(p,{name:`theme`,autoComplete:`off`,value:n,onChange:e=>r(e.target.value),children:[(0,g.jsx)(`option`,{value:`dark`,children:`Dark`}),(0,g.jsx)(`option`,{value:`light`,children:`Light`})]})}),(0,g.jsx)(h,{label:`Refresh interval`,children:(0,g.jsx)(p,{name:`refresh-interval`,autoComplete:`off`,value:String(e),onChange:e=>t(Number(e.target.value)),children:_.map(([e,t])=>(0,g.jsx)(`option`,{value:e,children:t},e))})})]})]})}var y=e(t(),1),b=1e4,x=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;async function S(e,t={},n=b){let r=new AbortController,i=t.signal,a=i?AbortSignal.any([i,r.signal]):r.signal,o=Error(`Connection test timed out after ${Math.ceil(n/1e3)} seconds.`),s,c,l=new Promise((e,t)=>{s=setTimeout(()=>{r.abort(o),t(o)},n)}),u=i?new Promise((e,t)=>{let n=()=>{t(i.reason??new DOMException(`Connection test aborted`,`AbortError`))};i.aborted?n():(i.addEventListener(`abort`,n,{once:!0}),c=()=>i.removeEventListener(`abort`,n))}):null;try{let n=(async()=>{let n=await fetch(e,{...t,signal:a});return{response:n,value:await n.json()}})();return await Promise.race(u?[n,l,u]:[n,l])}catch(e){throw r.signal.aborted&&r.signal.reason===o?o:e}finally{s!==void 0&&clearTimeout(s),c?.()}}async function C(e,t={},n=b){let{response:r,value:i}=await S(e,t,n);if(!r.ok&&r.status!==503)throw Error(`HTTP ${r.status}`);if(typeof i!=`object`||!i||Array.isArray(i))throw Error(`Malformed health response`);let a=i;if(typeof a.ok!=`boolean`||a.status!==`healthy`&&a.status!==`degraded`||!Number.isSafeInteger(a.uptime)||a.uptime<0||typeof a.version!=`string`||!x.test(a.version)||a.ok!==(a.status===`healthy`))throw Error(`Malformed health response`);return{response:r,health:a}}function w(){let e=i(),[t,n]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),[x,w]=(0,y.useState)(null),[T,E]=(0,y.useState)(null),D=(0,y.useRef)(!0),O=(0,y.useRef)(0),k=(0,y.useRef)(null),A=(0,y.useRef)(null),j=(0,y.useCallback)(()=>{A.current!==null&&clearTimeout(A.current),A.current=null,D.current&&E(null)},[]),M=(0,y.useCallback)(()=>{O.current+=1,k.current?.abort(new DOMException(`Connection test superseded`,`AbortError`)),k.current=null,D.current&&(h(null),_(null))},[]),N=(0,y.useCallback)(()=>{M(),j()},[j,M]);(0,y.useEffect)(()=>(D.current=!0,()=>{D.current=!1,O.current+=1,k.current?.abort(new DOMException(`Settings unmounted`,`AbortError`)),A.current!==null&&clearTimeout(A.current)}),[]),(0,y.useEffect)(()=>{let t=e.profiles.find(t=>t.id===e.activeProfileId);n(t?.name??`Bunqueue`),s(e.baseUrl),l(e.agentBaseUrl),d(e.token),p(e.agentToken),b(null),w(null),M()},[e.activeProfileId,e.agentBaseUrl,e.baseUrl,e.profiles,e.token,e.agentToken,M]);let P=()=>{let e=i.getState();return JSON.stringify([e.activeProfileId,e.baseUrl,e.agentBaseUrl,e.token,e.agentToken])},F=async e=>{M();let t=r(e===`server`?o:c);if(!t){e===`server`?b(a):w(a),_({ok:!1,msg:a});return}e===`server`?b(null):w(null);let n=O.current,i=new AbortController,s=P(),l=()=>D.current&&n===O.current&&!i.signal.aborted&&P()===s;k.current=i,h(e),_(null);let d=performance.now();try{if(e===`server`){let{response:e,health:n}=await C(`${t}/health`,{headers:u.trim()?{Authorization:`Bearer ${u.trim()}`}:void 0,signal:i.signal});if(!l())return;let r=e.status===503||n.status===`degraded`;_({ok:!r,msg:`${r?`Server reachable`:`Connected`} in ${Math.round(performance.now()-d)}ms · bunqueue v${n.version}${r?` · degraded`:``}`})}else{let{response:e,value:n}=await S(`${t}/control/status`,{headers:f.trim()?{Authorization:`Bearer ${f.trim()}`}:void 0,signal:i.signal});if(!e.ok)throw Error(`HTTP ${e.status}`);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Malformed control agent response`);let r=n;if(![`running`,`stopped`,`starting`,`stopping`].includes(String(r.status)))throw Error(`Malformed control agent response`);if(!l())return;_({ok:!0,msg:`Agent connected in ${Math.round(performance.now()-d)}ms · server ${r.status}${r.storageMode?` · ${r.storageMode}`:``}`})}}catch(e){l()&&_({ok:!1,msg:e.message})}finally{D.current&&n===O.current&&(k.current=null,h(null))}},I=()=>{M();let n=r(o),i=r(c);if(b(n?null:a),w(i?null:a),!n||!i)return;let s=e.saveConnection({name:t,baseUrl:n,agentBaseUrl:i,token:u,agentToken:f});j(),E({ok:s.persisted,msg:s.persisted?`Saved ✓`:`Saved for this session only — browser storage unavailable${s.error?`: ${s.error}`:`.`}`}),A.current=setTimeout(()=>D.current&&E(null),4e3)},L=()=>{N(),e.addProfile({name:`Bunqueue ${e.profiles.length+1}`,baseUrl:`http://localhost:6790`,agentBaseUrl:`http://localhost:6800`,token:``,agentToken:``})},R=()=>{let t=e.profiles.find(t=>t.id===e.activeProfileId);!t||!window.confirm(`Remove connection profile "${t.name}"?`)||e.removeProfile(t.id)};return{...e,name:t,setName:n,url:o,setUrl:s,agentUrl:c,setAgentUrl:l,tok:u,setTok:d,agentTok:f,setAgentTok:p,testing:m,result:g,urlError:v,agentUrlError:x,saveNotice:T,edit:N,save:I,add:L,remove:R,testServer:()=>F(`server`),testAgent:()=>F(`agent`)}}function T({id:e,label:t,hint:n,value:r,placeholder:i,onChange:a}){let[c,l]=(0,y.useState)(!1);return(0,g.jsx)(h,{label:t,hint:n,htmlFor:e,children:(0,g.jsxs)(`div`,{className:`relative`,children:[(0,g.jsx)(m,{id:e,name:e,type:c?`text`:`password`,value:r,onChange:e=>a(e.target.value),placeholder:i,className:`pr-10`,autoComplete:`off`,spellCheck:!1}),(0,g.jsx)(s,{"aria-label":c?`Hide ${t.toLowerCase()}`:`Show ${t.toLowerCase()}`,className:`absolute right-0.5 top-1/2 -translate-y-1/2`,onClick:()=>l(e=>!e),children:(0,g.jsx)(o,{className:`size-4`})})]})})}function E(){let e=w(),t=t=>n=>{e.edit(),t(n)};return(0,g.jsxs)(u,{children:[(0,g.jsx)(l,{title:`Bunqueue fleet connections`}),(0,g.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_auto_auto]`,children:[(0,g.jsx)(h,{label:`Active node`,children:(0,g.jsx)(p,{"aria-label":`Active Bunqueue node`,value:e.activeProfileId,onChange:t=>e.activateProfile(t.target.value),children:e.profiles.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))})}),(0,g.jsx)(c,{className:`self-end`,onClick:e.add,children:`Add node`}),(0,g.jsx)(c,{className:`self-end`,variant:`danger`,disabled:e.profiles.length===1,onClick:e.remove,children:`Remove`})]}),(0,g.jsx)(h,{label:`Node name`,children:(0,g.jsx)(m,{name:`profile-name`,value:e.name,onChange:n=>t(e.setName)(n.target.value),maxLength:64,autoComplete:`off`,placeholder:`broker-eu-1`})}),(0,g.jsx)(h,{label:`Server URL`,children:(0,g.jsx)(m,{name:`server-url`,value:e.url,onChange:n=>{t(e.setUrl)(n.target.value)},placeholder:`/api or https://queue.example.com`,autoComplete:`off`,inputMode:`url`,"aria-invalid":e.urlError?!0:void 0,"aria-describedby":e.urlError?`server-url-error`:`server-url-help`})}),e.urlError?(0,g.jsx)(`p`,{id:`server-url-error`,className:`-mt-2 text-xs text-danger`,children:e.urlError}):(0,g.jsx)(`p`,{id:`server-url-help`,className:`-mt-2 text-xs text-faint`,children:`Bunqueue HTTP API for this broker. All queue pages use the selected node.`}),(0,g.jsx)(h,{label:`Control agent URL`,children:(0,g.jsx)(m,{name:`agent-url`,value:e.agentUrl,onChange:n=>t(e.setAgentUrl)(n.target.value),placeholder:`/agent or https://broker.example.com/agent`,autoComplete:`off`,inputMode:`url`,"aria-invalid":e.agentUrlError?!0:void 0,"aria-describedby":e.agentUrlError?`agent-url-error`:`agent-url-help`})}),e.agentUrlError?(0,g.jsx)(`p`,{id:`agent-url-error`,className:`-mt-2 text-xs text-danger`,children:e.agentUrlError}):(0,g.jsx)(`p`,{id:`agent-url-help`,className:`-mt-2 text-xs text-faint`,children:`One paired agent per broker enables lifecycle, configuration, Flow, Workflow and advanced queue controls.`}),(0,g.jsx)(T,{id:`bearer-token`,label:`Bearer token (optional)`,hint:`Server credential, kept in memory only and isolated to this node.`,value:e.tok,onChange:t(e.setTok),placeholder:`only if AUTH_TOKENS is set`}),(0,g.jsx)(T,{id:`agent-token`,label:`Agent token (optional)`,hint:`AGENT_TOKEN for this node, kept in memory only.`,value:e.agentTok,onChange:t(e.setAgentTok),placeholder:`only if AGENT_TOKEN is set`}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(c,{variant:`accent`,onClick:e.save,children:`Save`}),(0,g.jsx)(c,{onClick:e.testServer,children:e.testing===`server`?`Restart test`:`Test connection`}),(0,g.jsx)(c,{onClick:e.testAgent,children:e.testing===`agent`?`Restart agent test`:`Test agent`}),e.saveNotice&&(0,g.jsx)(`span`,{role:`status`,className:e.saveNotice.ok?`text-sm text-success`:`text-sm text-warning`,children:e.saveNotice.msg}),e.result&&(0,g.jsx)(`span`,{role:`status`,className:e.result.ok?`text-sm text-success`:`text-sm text-danger`,children:e.result.msg})]}),(0,g.jsx)(`p`,{className:`-mt-1 text-xs text-faint`,children:`Switching the active node retargets every Dashboard feature atomically. Profile metadata persists; both credentials are erased on reload.`})]})]})}function D(){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(d,{title:`Settings`,description:`Bunqueue fleet connections, credentials and appearance.`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsx)(E,{}),(0,g.jsx)(v,{})]})]})}export{D as Settings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-CvwrP0tU.js";import{t}from"./api-BgWE-705.js";import{n}from"./usePolledData-0CVelkl2.js";import{n as r,t as i}from"./Card-CWxrC8OY.js";import{i as a,n as o,r as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./PageHeader-CvIyaFOO.js";import{l,n as u,s as d,u as f}from"./format-Cg7VCIZW.js";import{n as p}from"./index-
|
|
1
|
+
import{t as e}from"./react-vendor-CvwrP0tU.js";import{t}from"./api-BgWE-705.js";import{n}from"./usePolledData-0CVelkl2.js";import{n as r,t as i}from"./Card-CWxrC8OY.js";import{i as a,n as o,r as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./PageHeader-CvIyaFOO.js";import{l,n as u,s as d,u as f}from"./format-Cg7VCIZW.js";import{n as p}from"./index-BFW2_47n.js";var m=e(),h={stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},memory:{heapUsed:0,heapTotal:0,rss:0},workers:{total:0,active:0},crons:{total:0},storage:{}};function g(){let{data:e,error:g,loading:v,refetch:y}=n(()=>t.overview(),[]);if(v&&!e&&!g)return(0,m.jsx)(s,{label:`Loading usage…`});if(g&&!e)return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(c,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,m.jsx)(o,{error:g,onRetry:y})]});let{stats:b,memory:x,workers:S,crons:C,storage:w}=e??h,T=typeof w.diskFull==`boolean`;return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(c,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!g&&T}),g&&(0,m.jsx)(a,{message:`Usage refresh failed — showing the last successful snapshot.`,onRetry:y}),(0,m.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,m.jsx)(p,{label:`Jobs Pushed`,value:d(b.totalPushed)}),(0,m.jsx)(p,{label:`Jobs Completed`,value:d(b.totalCompleted),tone:`green`}),(0,m.jsx)(p,{label:`Jobs Failed`,value:d(b.totalFailed),tone:b.totalFailed?`red`:`default`}),(0,m.jsx)(p,{label:`Jobs Pulled`,value:d(b.totalPulled),tone:`blue`})]}),(0,m.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,m.jsxs)(i,{children:[(0,m.jsx)(r,{title:`Runtime`}),(0,m.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,m.jsx)(_,{label:`Uptime`,value:f(b.uptime/1e3)}),(0,m.jsx)(_,{label:`Heap used`,value:u(x.heapUsed*1024*1024)}),(0,m.jsx)(_,{label:`RSS`,value:u(x.rss*1024*1024)}),(0,m.jsx)(_,{label:`Workers`,value:`${S.active} active / ${S.total}`}),(0,m.jsx)(_,{label:`Cron jobs`,value:String(C.total)})]})]}),(0,m.jsxs)(i,{children:[(0,m.jsx)(r,{title:`Storage`}),(0,m.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,m.jsx)(_,{label:`Status`,value:T?w.diskFull?`Disk full`:`Healthy`:`Unavailable`}),(0,m.jsx)(_,{label:`Disk full since`,value:w.diskFull?l(w.since):`—`}),w.error?(0,m.jsx)(_,{label:`Error`,value:String(w.error)}):null]})]})]})]})}function _({label:e,value:t,mono:n}){return(0,m.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,m.jsx)(`dt`,{className:`text-muted`,children:e}),(0,m.jsx)(`dd`,{className:n?`font-mono text-xs text-fg`:`font-medium text-fg`,children:t})]})}export{g as Usage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-CvwrP0tU.js";import{t}from"./bq-F5BbTG1T.js";import{n}from"./usePolledData-0CVelkl2.js";import{n as r,t as i}from"./Card-CWxrC8OY.js";import{i as a,n as o,r as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./PageHeader-CvIyaFOO.js";import{c as l,l as u,n as d,s as f,t as p,u as m}from"./format-Cg7VCIZW.js";import{n as h}from"./index-
|
|
1
|
+
import{t as e}from"./react-vendor-CvwrP0tU.js";import{t}from"./bq-F5BbTG1T.js";import{n}from"./usePolledData-0CVelkl2.js";import{n as r,t as i}from"./Card-CWxrC8OY.js";import{i as a,n as o,r as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./PageHeader-CvIyaFOO.js";import{c as l,l as u,n as d,s as f,t as p,u as m}from"./format-Cg7VCIZW.js";import{n as h}from"./index-BFW2_47n.js";var g=e(),_={overview:{stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},memory:{heapUsed:0,heapTotal:0,rss:0},crons:{total:0}},storage:{},failedTotal:0};function v(){let{data:e,error:v,loading:b,refetch:x}=n(async()=>{let[e,n,r]=await Promise.all([t.overview(),t.storage(),t.queuesSummary()]);if(!n?.data||typeof n.data.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data`);let i=r.reduce((e,t)=>e+(t.counts?.failed??0),0);return{overview:e,storage:n.data,failedTotal:i}},[]);if(b&&!e&&!v)return(0,g.jsx)(s,{label:`Loading usage…`});if(v&&!e)return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(c,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,g.jsx)(o,{error:v,onRetry:x})]});let S=e??_,{stats:C,memory:w,crons:T}=S.overview,{storage:E,failedTotal:D}=S,O=p(C.completed,D),k=C.uptime?m(C.uptime/1e3):`—`;return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(c,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!v}),v&&(0,g.jsx)(a,{message:`Usage refresh failed — showing the last successful snapshot.`,onRetry:x}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,g.jsx)(h,{label:`Completed`,value:f(C.completed),tone:`green`}),(0,g.jsx)(h,{label:`Failed`,value:f(D),tone:D?`red`:`default`}),(0,g.jsx)(h,{label:`Waiting`,value:f(C.waiting),tone:`amber`}),(0,g.jsx)(h,{label:`Active`,value:f(C.active),tone:`blue`}),(0,g.jsx)(h,{label:`Error Rate`,value:O==null?`—`:l(O),tone:O==null?`default`:O>.05?`red`:`green`}),(0,g.jsx)(h,{label:`Uptime`,value:k})]}),(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)(r,{title:`Runtime`}),(0,g.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,g.jsx)(y,{label:`Jobs pushed (since restart)`,value:f(C.totalPushed)}),(0,g.jsx)(y,{label:`Jobs pulled (since restart)`,value:f(C.totalPulled)}),(0,g.jsx)(y,{label:`Heap used`,value:d(w.heapUsed*1024*1024)}),(0,g.jsx)(y,{label:`RSS`,value:d(w.rss*1024*1024)}),(0,g.jsx)(y,{label:`Cron jobs`,value:String(T.total)})]})]}),(0,g.jsxs)(i,{children:[(0,g.jsx)(r,{title:`Storage`}),E.diskFull?(0,g.jsxs)(`div`,{className:`rounded-lg border border-red-500/25 bg-red-500/[0.06] px-4 py-3`,children:[(0,g.jsx)(`div`,{className:`font-semibold text-danger`,children:`Disk full — writes suspended`}),E.error&&(0,g.jsx)(`div`,{className:`mt-1 text-xs text-muted`,children:E.error}),E.since!=null&&(0,g.jsxs)(`div`,{className:`mt-1 text-xs text-faint`,children:[`since `,u(E.since)]})]}):(0,g.jsxs)(`div`,{className:`rounded-lg border border-emerald-500/25 bg-emerald-500/[0.06] px-4 py-3`,children:[(0,g.jsx)(`div`,{className:`font-semibold text-success`,children:`Healthy`}),(0,g.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`Disk writes are being accepted.`})]})]})]})]})}function y({label:e,value:t}){return(0,g.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,g.jsx)(`dt`,{className:`text-muted`,children:e}),(0,g.jsx)(`dd`,{className:`font-medium text-fg`,children:t})]})}export{v as UsagePro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{A as r}from"./icons-BVzwsfbG.js";import{t as i}from"./api-BgWE-705.js";import{n as a}from"./usePolledData-0CVelkl2.js";import{i as o,n as s,r as c,t as l}from"./feedback-QDN1AsYt.js";import{t as u}from"./PageHeader-CvIyaFOO.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{n as p}from"./index-
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{A as r}from"./icons-BVzwsfbG.js";import{t as i}from"./api-BgWE-705.js";import{n as a}from"./usePolledData-0CVelkl2.js";import{i as o,n as s,r as c,t as l}from"./feedback-QDN1AsYt.js";import{t as u}from"./PageHeader-CvIyaFOO.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{n as p}from"./index-BFW2_47n.js";import{t as m}from"./Pagination-x-Cwgrul.js";var h=e(t(),1),g=n(),_=20,v={workers:{total:0,active:0,list:[],truncated:!1}};function y(){let{data:e,error:t,loading:n,refetch:y}=a(()=>i.overview(),[]),[b,x]=(0,h.useState)(0);if(n&&!e&&!t)return(0,g.jsx)(c,{label:`Loading workers…`});if(t&&!e)return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(u,{title:`Workers`,description:`Worker inventory is unavailable.`}),(0,g.jsx)(s,{error:t,onRetry:y})]});let{workers:S}=e??v,C=Math.max(1,Math.ceil(S.list.length/_)),w=Math.min(b,C-1),T=S.list.slice(w*_,w*_+_);return(0,g.jsxs)(`div`,{children:[t&&(0,g.jsx)(o,{message:`Worker refresh failed — showing the last successful inventory.`,onRetry:y}),(0,g.jsx)(u,{title:`Workers`,description:`Registered workers and their throughput.`,live:!!e&&!t}),(0,g.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,g.jsx)(p,{label:`Total`,value:f(S.total),compact:!0}),(0,g.jsx)(p,{label:`Active`,value:f(S.active),tone:`green`,compact:!0})]}),S.list.length===0?(0,g.jsx)(l,{icon:(0,g.jsx)(r,{}),title:`No workers registered`,hint:`Workers appear here once they connect and register with the server.`}):(0,g.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,g.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,g.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Worker`}),(0,g.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queues`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Processed`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Last Seen`})]})}),(0,g.jsx)(`tbody`,{children:T.map(e=>(0,g.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,g.jsxs)(`td`,{className:`px-5 py-3`,children:[(0,g.jsx)(`div`,{className:`font-medium text-fg`,children:e.name||`worker`}),(0,g.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.id})]}),(0,g.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queues.join(`, `)||`—`}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:f(e.activeJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:f(e.processedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:f(e.failedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:d(e.lastSeen)})]},e.id))})]})}),S.truncated&&(0,g.jsxs)(`p`,{className:`mt-3 text-xs text-amber-400`,children:[`Showing first `,f(S.list.length),` of `,f(S.total),` `,`workers.`]}),(0,g.jsx)(m,{page:w,pageSize:_,total:S.list.length,onPageChange:x,label:`workers`})]})}export{y as Workers};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CvwrP0tU.js";import{t as i}from"./bq-F5BbTG1T.js";import{A as a,O as o}from"./icons-BVzwsfbG.js";import{n as s}from"./usePolledData-0CVelkl2.js";import{n as c}from"./Button-Ch1W94fJ.js";import{i as l,n as u,r as d,t as f}from"./feedback-QDN1AsYt.js";import{t as p}from"./PageHeader-CvIyaFOO.js";import{l as m,s as h}from"./format-Cg7VCIZW.js";import{n as g}from"./index-
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CvwrP0tU.js";import{t as i}from"./bq-F5BbTG1T.js";import{A as a,O as o}from"./icons-BVzwsfbG.js";import{n as s}from"./usePolledData-0CVelkl2.js";import{n as c}from"./Button-Ch1W94fJ.js";import{i as l,n as u,r as d,t as f}from"./feedback-QDN1AsYt.js";import{t as p}from"./PageHeader-CvIyaFOO.js";import{l as m,s as h}from"./format-Cg7VCIZW.js";import{n as g}from"./index-BFW2_47n.js";import{r as _,t as v}from"./useServerActionGuard-uGePilQQ.js";var y=e(n(),1),b=r(),x=100,S=`No heartbeat recently — derived from lastSeen`;function C(){let{data:e,error:n,loading:r,refetch:C}=s(async()=>(await i.workers()).data,[]),[T,E]=(0,y.useState)(new Set),[D,O]=(0,y.useState)(null),[k,A]=(0,y.useState)(null),j=_(`workers-pro`);if((0,y.useEffect)(()=>{E(new Set),O(null)},[j.scopeKey]),r&&!e&&!n)return(0,b.jsx)(d,{label:`Loading workers…`});if(n&&!e)return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(p,{title:`Workers`,description:`Worker inventory is unavailable.`}),(0,b.jsx)(u,{error:n,onRetry:C})]});let M=e?.workers??[],N=e?.quarantinedWorkers??[],P=(k?[...M].sort((e,t)=>{let n=k.key===`failed`?e.failedJobs??0:e.lastSeen??0,r=k.key===`failed`?t.failedJobs??0:t.lastSeen??0;return k.dir===`asc`?n-r:r-n}):M).slice(0,x),F=e=>A(t=>t?.key===e?{key:e,dir:t.dir===`desc`?`asc`:`desc`}:{key:e,dir:`desc`}),I=M.filter(e=>e.status===`active`).length,L=M.length-I,R=M.reduce((e,t)=>e+(t.activeJobs??0),0),z=async e=>{if(!window.confirm(`Remove the stale registry record for worker "${e}"? This does not stop the worker process. Continue only after confirming that process is stopped; Bunqueue v2.9.3 workers do not automatically re-register after their heartbeat record is removed.`))return;let t=j.begin(`worker:${e}`);if(t){E(t=>new Set(t).add(e)),O(null);try{if(v(await i.unregisterWorker(e),`Remove stale worker registry record`),!t.isCurrent())return;O({ok:!0,text:`Removed stale registry record for ${e} ✓`}),C()}catch(e){if(!t.isCurrent())return;O({ok:!1,text:`Removal failed: ${e.message}`})}finally{t.finish()&&E(t=>{let n=new Set(t);return n.delete(e),n})}}};return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(p,{title:`Workers`,description:`Registered workers and their throughput.`,live:!!e&&!n}),n&&(0,b.jsx)(l,{message:`Worker refresh failed — showing the last successful inventory.`,onRetry:C}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,b.jsx)(g,{label:`Total`,value:h(M.length+N.length),compact:!0}),(0,b.jsx)(g,{label:`Active`,value:h(I),tone:`green`,compact:!0}),(0,b.jsx)(`div`,{title:S,children:(0,b.jsx)(g,{label:`Stale`,value:h(L),tone:L?`amber`:`default`,compact:!0})}),(0,b.jsx)(g,{label:`Active Jobs`,value:h(R),tone:`blue`,compact:!0}),(0,b.jsx)(g,{label:`Quarantined`,value:h(N.length),tone:N.length?`red`:`default`,compact:!0})]}),N.length>0&&(0,b.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,b.jsxs)(`p`,{className:`text-sm font-medium text-danger`,children:[N.length,` worker registration(s) contain values accepted by Bunqueue 2.9.3 but unsafe to render. Healthy workers remain available below.`]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Their status and active-job count are unknown, so this dashboard will not offer the registry-only removal action for them.`}),(0,b.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs text-muted`,children:N.slice(0,20).map(e=>(0,b.jsxs)(`li`,{className:`truncate font-mono`,children:[`#`,e.index+1,` `,e.id??`(unaddressable id)`,` — `,e.reason]},`${e.index}:${e.id??`unknown`}`))})]}),D&&(0,b.jsx)(`div`,{className:t(`mb-3 text-sm`,D.ok?`text-success`:`text-danger`),children:D.text}),M.length===0?(0,b.jsx)(f,{icon:(0,b.jsx)(a,{}),title:N.length?`No renderable workers`:`No workers registered`,hint:N.length?`Malformed registrations are isolated above instead of taking down the inventory.`:`Workers appear here once they connect and register with the server.`}):(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:`Worker`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queues`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Processed`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:(0,b.jsx)(w,{label:`Failed`,active:k?.key===`failed`?k.dir:null,onClick:()=>F(`failed`)})}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:(0,b.jsx)(w,{label:`Last Seen`,active:k?.key===`lastSeen`?k.dir:null,onClick:()=>F(`lastSeen`)})}),(0,b.jsx)(`th`,{className:`w-16 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,b.jsx)(`tbody`,{children:P.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,b.jsxs)(`td`,{className:`px-5 py-3`,children:[(0,b.jsx)(`div`,{className:`font-medium text-fg`,children:e.name||`worker`}),(0,b.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.id})]}),(0,b.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queues.join(`, `)||`—`}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`span`,{title:e.status===`active`?void 0:S,className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.status===`active`?`bg-emerald-500/10 text-success`:`bg-amber-500/10 text-warning`),children:e.status})}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:h(e.activeJobs)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:h(e.processedJobs)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:h(e.failedJobs)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:m(e.lastSeen)}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`div`,{className:`flex justify-end`,children:e.status===`stale`&&e.activeJobs===0?(0,b.jsx)(c,{"aria-label":`Remove stale registry record for worker ${e.id}`,title:`Registry cleanup only — does not stop the worker process`,disabled:T.has(e.id),onClick:()=>z(e.id),children:(0,b.jsx)(o,{className:`size-3.5`})}):(0,b.jsx)(`span`,{className:`text-xs text-faint`,title:e.status===`stale`?`Registry cleanup is blocked while active jobs are reported`:`Only stale, idle registry records can be removed`,children:`—`})})})]},e.id))})]})}),M.length>x&&(0,b.jsxs)(`p`,{className:`mt-3 text-xs text-warning`,children:[`Showing first `,h(x),` of `,h(M.length),` workers.`]})]})}function w({label:e,active:n,onClick:r}){return(0,b.jsxs)(`button`,{type:`button`,onClick:r,title:`Sort by ${e}`,className:t(`inline-flex items-center gap-1 uppercase tracking-wider transition-colors hover:text-fg`,n?`text-fg`:`text-faint`),children:[e,(0,b.jsx)(`span`,{"aria-hidden":`true`,children:n===`desc`?`↓`:n===`asc`?`↑`:``})]})}export{C as WorkersPro};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){let t=e===`waiting`||e===`delayed`||e===`prioritized`;return{cancel:!1,discard:!1,promote:e===`delayed`,retryDlq:!1,requeueCompleted:!1,setPriority:t,setDelay:t}}function t(e){return e===`updateData`?`Flow data is read-only: replacing the payload can remove dependency metadata.`:e===`retry`?`Flow retry is unavailable: Bunqueue has no atomic job-generation or state precondition.`:e===`remove`||e===`removeUnprocessedChildren`?`Flow removal is unavailable: Bunqueue cannot atomically protect reverse dependencies.`:null}function n(e){let n=t(e);if(n)throw Error(n)}export{n,t as r,e as t};
|