bunqueue-dashboard 0.0.15 → 0.0.16
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/dist/.vite/manifest.json +57 -57
- package/dist/assets/{AddJob-CgeLluaI.js → AddJob-CMIT6e17.js} +1 -1
- package/dist/assets/{Benchmark-DrUL2MGj.js → Benchmark-Dq1-vJ2k.js} +1 -1
- package/dist/assets/{CopilotPanel-fr19SCy4.js → CopilotPanel-BDZzDmVy.js} +1 -1
- package/dist/assets/{CopyButton-BRNz3U_X.js → CopyButton-XT7ykzf5.js} +1 -1
- package/dist/assets/{Cron-CGpba--B.js → Cron-9hndZ-Z5.js} +1 -1
- package/dist/assets/{CronManager-C8DgqC22.js → CronManager-BQupx6wZ.js} +1 -1
- package/dist/assets/{Database-3TVTb28B.js → Database-Difs7xYV.js} +1 -1
- package/dist/assets/{Diagnostics-Bx3SLh8R.js → Diagnostics-BzVDq9CH.js} +1 -1
- package/dist/assets/{Dlq-fvEtz0IH.js → Dlq-BCUVh_NO.js} +1 -1
- package/dist/assets/{DlqControl-BuoZGZiz.js → DlqControl-Cu2i1oq5.js} +1 -1
- package/dist/assets/{DlqPro-Dc4R2c0h.js → DlqPro-HBrCftLD.js} +1 -1
- package/dist/assets/{Flows-uJwr4Xtd.js → Flows-D3Bvkmd6.js} +1 -1
- package/dist/assets/{JobInspector-BHzMp9AE.js → JobInspector-B7zEuFhM.js} +1 -1
- package/dist/assets/{Jobs-B3ngaITT.js → Jobs-ovYRwmwi.js} +1 -1
- package/dist/assets/{JobsPro-B8ZXHQat.js → JobsPro-DNZivuzq.js} +1 -1
- package/dist/assets/{Logs-BFNzXnJu.js → Logs-CjM7MNYN.js} +1 -1
- package/dist/assets/{LogsPro-BsYmMhV3.js → LogsPro-P73LCkap.js} +1 -1
- package/dist/assets/{McpServer-Dp5CU2Ao.js → McpServer-CUK20-uN.js} +1 -1
- package/dist/assets/{Metrics-BIy2WsIk.js → Metrics-BodjiKpf.js} +1 -1
- package/dist/assets/{MetricsPro-59vtSH96.js → MetricsPro-CqcH6gJp.js} +1 -1
- package/dist/assets/{Overview-CKCv4aez.js → Overview-AwCA3XI2.js} +1 -1
- package/dist/assets/{Pagination-DdeRIp2i.js → Pagination-Cd6lHj2E.js} +1 -1
- package/dist/assets/{QueueControl-Bnk114Oa.js → QueueControl-D7J1JObu.js} +1 -1
- package/dist/assets/{QueueDetail-BjblUfMz.js → QueueDetail-BtiN0s3b.js} +1 -1
- package/dist/assets/{Queues-DLfqg-GX.js → Queues-LrodynCj.js} +1 -1
- package/dist/assets/{QueuesOverview-2q1ROf6f.js → QueuesOverview-DrYjyped.js} +1 -1
- package/dist/assets/{S3Backup-BnL4NviE.js → S3Backup-et1PcCC0.js} +1 -1
- package/dist/assets/{S3BackupPro-MKhVJfmN.js → S3BackupPro-BEo_EVAO.js} +1 -1
- package/dist/assets/{ServerControl-MwMUqZXA.js → ServerControl-BRLFRj7k.js} +1 -1
- package/dist/assets/{Settings-Bg4nYelW.js → Settings-CeRZgZU6.js} +1 -1
- package/dist/assets/{Usage-Cf-_mayK.js → Usage-CHCg6VNy.js} +1 -1
- package/dist/assets/{UsagePro-Dvnkxjtk.js → UsagePro-Cto9k5OI.js} +1 -1
- package/dist/assets/{Webhooks-DI-3YwZu.js → Webhooks-Cm3vZEp7.js} +1 -1
- package/dist/assets/{Workers-DzewyMtr.js → Workers-CVfx3TK-.js} +1 -1
- package/dist/assets/{WorkersPro-DXnomAJx.js → WorkersPro-BidtV_Bp.js} +1 -1
- package/dist/assets/{index-D6Nj5ksZ.js → index-C9fPU4bV.js} +3 -3
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/scripts/embedded.gen.ts +96 -96
- package/scripts/serve.ts +33 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{C as r,D as i,E as a,O as o,R as s,S as c,T as l,Y as u,a as d,c as f,g as p,j as m,v as h,w as g}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{C as r,D as i,E as a,O as o,R as s,S as c,T as l,Y as u,a as d,c as f,g as p,j as m,v as h,w as g}from"./index-C9fPU4bV.js";import{i as _,n as v,t as y}from"./form-PtDLk33Z.js";import{t as b}from"./Pagination-Cd6lHj2E.js";var x=e(t(),1),S=n();function C(){let{data:e,error:t,loading:n,refetch:i}=m(()=>p.crons(),[]),_=e?.crons??[],[v,y]=(0,x.useState)(0),C=Math.max(1,Math.ceil(_.length/15)),T=Math.min(v,C-1),[E,D]=(0,x.useState)(null),O=async e=>{if(window.confirm(`Delete cron "${e}"?`)){D(null);try{await p.deleteCron(e),i()}catch(e){D(e.message)}}};return(0,S.jsxs)(`div`,{children:[t&&(0,S.jsx)(g,{onRetry:i}),(0,S.jsx)(h,{title:`Cron Manager`,description:`Schedule and manage repeatable jobs.`,live:!0}),E&&(0,S.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-danger`,children:E}),(0,S.jsxs)(l,{className:`mb-6`,children:[(0,S.jsx)(a,{title:`Create schedule`}),(0,S.jsx)(w,{onCreate:async e=>{await p.createCron(e),i()}})]}),n&&!e&&!t?(0,S.jsx)(r,{label:`Loading crons…`}):_.length===0?(0,S.jsx)(c,{icon:(0,S.jsx)(s,{}),title:`No scheduled jobs`,hint:`Create one above.`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,S.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Schedule`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Next Run`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Runs`}),(0,S.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,S.jsx)(`tbody`,{children:_.slice(T*15,T*15+15).map(e=>(0,S.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,S.jsx)(`td`,{className:`px-5 py-3 font-medium text-fg`,children:e.name}),(0,S.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,S.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-faint`,children:d(e.nextRun)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:f(e.executions)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,S.jsx)(o,{"aria-label":`Delete cron`,onClick:()=>O(e.name),children:(0,S.jsx)(u,{className:`size-3.5`})})})]},e.name))})]})}),(0,S.jsx)(b,{page:T,pageSize:15,total:_.length,onPageChange:y,label:`crons`})]})]})}function w({onCreate:e}){let[t,n]=(0,x.useState)(``),[r,a]=(0,x.useState)(``),[o,s]=(0,x.useState)(`cron`),[c,l]=(0,x.useState)(``),[u,d]=(0,x.useState)(``),[f,p]=(0,x.useState)(`{}`),[m,h]=(0,x.useState)(null),[g,b]=(0,x.useState)(!1),[C,w]=(0,x.useState)(!1),T=async()=>{if(g)return;if(h(null),w(!1),!t.trim()||!r.trim()){h(`Name and queue are required`);return}let i={};try{i=f.trim()?JSON.parse(f):{}}catch{h(`Data is not valid JSON`);return}let a={name:t,queue:r,data:i};if(o===`cron`){if(!c.trim()){h(`Cron expression required`);return}a.schedule=c.trim()}else{let e=Number(u);if(!Number.isInteger(e)||e<=0){h(`Interval must be a whole number of milliseconds greater than 0`);return}a.repeatEvery=e}b(!0);try{await e(a),n(``),l(``),d(``),w(!0),setTimeout(()=>w(!1),3e3)}catch(e){h(e.message)}finally{b(!1)}};return(0,S.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),T()},children:[(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,S.jsx)(y,{label:`Name`,children:(0,S.jsx)(v,{value:t,onChange:e=>n(e.target.value),placeholder:`daily-report`})}),(0,S.jsx)(y,{label:`Queue`,children:(0,S.jsx)(v,{value:r,onChange:e=>a(e.target.value),placeholder:`reports`})})]}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,S.jsx)(_,{options:[`cron`,`every`],value:o,onChange:s}),o===`cron`?(0,S.jsx)(`div`,{className:`min-w-56 flex-1`,children:(0,S.jsx)(y,{label:`Cron expression`,children:(0,S.jsx)(v,{value:c,onChange:e=>l(e.target.value),placeholder:`0 9 * * *`})})}):(0,S.jsx)(`div`,{className:`w-40`,children:(0,S.jsx)(y,{label:`Every (ms)`,children:(0,S.jsx)(v,{type:`number`,value:u,onChange:e=>d(e.target.value),placeholder:`30000`})})})]}),(0,S.jsx)(y,{label:`Data (JSON)`,children:(0,S.jsx)(v,{value:f,onChange:e=>p(e.target.value),className:`font-mono`})}),(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(i,{type:`submit`,variant:`accent`,size:`sm`,disabled:g,children:g?`Creating…`:`Create`}),m&&(0,S.jsx)(`span`,{className:`text-xs text-danger`,children:m}),C&&(0,S.jsx)(`span`,{className:`text-xs text-success`,children:`Cron created ✓`})]})]})}export{C as CronManager};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{m as n,t as r}from"./react-vendor-CHIHtdAC.js";import{C as i,D as a,E as o,I as s,J as c,S as l,T as u,_ as d,c as f,g as p,j as m,m as h,r as g,v as _,w as ee}from"./index-
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{m as n,t as r}from"./react-vendor-CHIHtdAC.js";import{C as i,D as a,E as o,I as s,J as c,S as l,T as u,_ as d,c as f,g as p,j as m,m as h,r as g,v as _,w as ee}from"./index-C9fPU4bV.js";import{a as v}from"./form-PtDLk33Z.js";import{t as te}from"./Pagination-Cd6lHj2E.js";import{t as y}from"./CopyButton-XT7ykzf5.js";var b=e(n(),1),x=r(),S=50,C=500,ne=2e5,w=`bq-dash-db-history`,T=10;function E(e){let t=e==null?``:String(e);return/[",\n]/.test(t)?`"${t.replaceAll(`"`,`""`)}"`:t}function D(e,t){return[e.map(E).join(`,`),...t.map(e=>e.map(E).join(`,`))].join(`
|
|
2
2
|
`)}function O(e,t,n){let r=URL.createObjectURL(new Blob([n],{type:t})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r)}function k(){try{let e=JSON.parse(localStorage.getItem(w)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function A(e){try{localStorage.setItem(w,JSON.stringify(e))}catch{}return e}function j(e){return A([e,...k().filter(t=>t!==e)].slice(0,T))}function M(e){if(e==null)return`NULL`;let t=typeof e==`string`?e:String(e);try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function N({value:e,align:n}){if(e==null)return(0,x.jsx)(`span`,{className:`italic text-faint`,children:`NULL`});let r=typeof e==`string`?e:String(e);return(0,x.jsx)(`span`,{className:t(`block max-w-[24rem] truncate`,n===`right`&&`text-right tabular-nums`),title:r,children:r})}function P({columns:e,rows:n,truncatedCells:r,colMeta:i,sort:a,onSort:o,onRowClick:s,dimmed:c}){let l=(0,b.useMemo)(()=>e.map((e,t)=>{let r=i?.[e]?.type?.toUpperCase()??``;if(/INT|REAL|NUM|DEC|DOUB|FLOA/.test(r))return!0;let a=!1;for(let e of n){let n=e[t];if(n!=null&&(a=!0,typeof n!=`number`))return!1}return a}),[e,n,i]);return(0,x.jsx)(`div`,{className:t(`max-h-[70vh] overflow-auto rounded-xl border border-line bg-surface transition-opacity`,c&&`pointer-events-none opacity-50`),children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsx)(`tr`,{className:`text-left text-[11px] uppercase tracking-wider text-faint`,children:e.map((e,n)=>{let r=i?.[e];return(0,x.jsx)(`th`,{className:t(`sticky top-0 z-10 whitespace-nowrap border-b border-line bg-surface px-4 py-3 font-medium`,l[n]&&`text-right`),"aria-sort":a?.col===e?a.dir===`asc`?`ascending`:`descending`:void 0,children:o?(0,x.jsxs)(`button`,{type:`button`,onClick:()=>o(e),"aria-label":`Sort by ${e}`,className:`inline-flex items-center gap-1 uppercase tracking-wider hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[e,r?.primaryKey&&(0,x.jsx)(`span`,{className:`rounded bg-accent/15 px-1 py-0.5 text-[9px] font-semibold text-accent`,children:`PK`}),r?.type&&(0,x.jsx)(`span`,{className:`text-faint/70`,children:r.type.toLowerCase()}),(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`text-accent`,children:a?.col===e?a.dir===`asc`?`▲`:`▼`:``})]}):e},e)})})}),(0,x.jsx)(`tbody`,{children:n.map((e,n)=>(0,x.jsx)(`tr`,{onClick:s?()=>s(n):void 0,className:t(`border-b border-line font-mono text-xs last:border-0 hover:bg-surface-2/40`,s&&`cursor-pointer`),children:e.map((e,t)=>(0,x.jsx)(`td`,{className:`whitespace-nowrap px-4 py-2 text-muted`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(N,{value:e,align:l[t]?`right`:`left`}),r?.[n]?.[t]&&(0,x.jsx)(`span`,{title:`Value truncated — click the row to view it in full`,className:`shrink-0 rounded bg-warning/15 px-1 text-[9px] font-semibold text-warning`,children:`…`})]})},t))},n))})]})})}function F(){let[e,n]=(0,b.useState)(``),[r,o]=(0,b.useState)(0),[s,c]=(0,b.useState)(null),[v,y]=(0,b.useState)(`data`),[w,T]=(0,b.useState)(null),[E,k]=(0,b.useState)(null),[A,j]=(0,b.useState)(`SELECT name FROM sqlite_master WHERE type = 'table'`),M=(0,b.useRef)(null),{data:N,error:F,loading:re,refetch:ie}=m(()=>p.db.tables(),[],{intervalMs:1e4}),B=(0,b.useMemo)(()=>N?.tables??[],[N]),V=F instanceof h&&F.status===404,{data:H}=m(()=>V?Promise.resolve(null):p.db.info(),[V],{intervalMs:15e3}),U=e||B[0]?.name||``;(0,b.useEffect)(()=>{!e&&B[0]&&n(B[0].name)},[e,B]);let{data:W}=m(()=>U?p.db.schema(U):Promise.resolve(null),[U],{intervalMs:3e4}),ae=(0,b.useMemo)(()=>{let e={};if(W?.table===U)for(let t of W.columns)e[t.name]={type:t.type,primaryKey:t.primaryKey};return e},[W,U]),G=w?`${w.column}|${w.op}|${w.value}`:``,{data:K,error:q,loading:J}=m((0,b.useCallback)(async()=>U?{...await p.db.rows(U,S,r*S,s?.col,s?.dir,w??void 0),page:r,filterKey:G}:null,[U,r,s,w,G]),[U,r,s,G],{intervalMs:6e3}),Y=K&&K.table===U&&K.page===r&&K.orderBy===(s?.col??null)&&(!s||K.dir===s.dir)&&K.filterKey===G?K:null;(0,b.useEffect)(()=>{Y&&Y.total>0&&Y.rows.length===0&&r>0&&o(Math.max(0,Math.ceil(Y.total/S)-1))},[Y,r]);let[X,Z]=(0,b.useState)(!1),[Q,$]=(0,b.useState)(null),oe=()=>{o(0),c(null),T(null),k(null)},se=e=>{n(e),y(`data`),oe()},ce=e=>{o(0),k(null),c(t=>t?.col===e?t.dir===`asc`?{col:e,dir:`desc`}:null:{col:e,dir:`asc`})},le=()=>{Y&&O(`${Y.table}-page${r+1}.csv`,`text/csv`,D(Y.columns,Y.rows))},ue=async()=>{if(!(!U||X)){Z(!0),$(null);try{let e=[],t=[],n=0,r=!1;for(;;){let i=await p.db.rows(U,C,n,s?.col,s?.dir,w??void 0);if(t=i.columns,e.push(...i.rows),n+=C,e.length>=ne){r=!0;break}if(i.rows.length<C||n>=i.total)break}O(`${U}.csv`,`text/csv`,D(t,e)),$(r?`Exported the first ${f(e.length)} rows (export cap reached)`:`Exported ${f(e.length)} rows`)}catch(e){$(`Export failed: ${e.message}`)}finally{Z(!1)}}},de=()=>{j(`SELECT * FROM "${U.replaceAll(`"`,`""`)}" LIMIT 100`),requestAnimationFrame(()=>{M.current?.focus(),M.current?.scrollIntoView({behavior:`smooth`,block:`center`})})},fe=!!Y?.truncatedCells.some(e=>e.some(Boolean));return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(_,{title:`Database`,description:`SQLite inspector — schema, data and queries over a read-only connection.`,actions:(0,x.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2.5 py-1 text-[11px] font-medium text-success`,children:`read-only`})}),F&&!V&&(0,x.jsx)(ee,{message:`Could not read the database — ${F.message}`,onRetry:ie}),H&&(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-5`,children:[(0,x.jsx)(d,{label:`SQLite`,value:H.sqliteVersion,compact:!0}),(0,x.jsx)(d,{label:`On disk`,value:g(H.fileSize+H.walSize),compact:!0}),(0,x.jsx)(d,{label:`Journal`,value:H.journalMode.toUpperCase(),compact:!0}),(0,x.jsx)(d,{label:`Tables`,value:f(H.tables),compact:!0}),(0,x.jsx)(d,{label:`Indexes`,value:f(H.indexes),compact:!0})]}),V?(0,x.jsx)(l,{title:`No database yet`,hint:F.message}):re&&B.length===0?(0,x.jsx)(i,{label:`Reading database…`}):(0,x.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-4`,children:[(0,x.jsxs)(u,{padded:!1,className:`self-start overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`border-b border-line px-4 py-3 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Tables (`,B.length,`)`]}),(0,x.jsxs)(`ul`,{className:`max-h-[28rem] overflow-y-auto`,children:[B.map(e=>(0,x.jsx)(`li`,{children:(0,x.jsxs)(`button`,{type:`button`,onClick:()=>se(e.name),className:t(`flex w-full items-center justify-between gap-2 px-4 py-2 text-left text-sm transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,U===e.name?`bg-surface-2 text-fg`:`text-muted hover:bg-surface-2/60 hover:text-fg`),children:[(0,x.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.name}),(0,x.jsx)(`span`,{className:`shrink-0 text-[11px] text-faint tabular-nums`,children:f(e.rows)})]})},e.name)),B.length===0&&(0,x.jsx)(`li`,{className:`px-4 py-6 text-center text-xs text-faint`,children:`No tables.`})]})]}),(0,x.jsx)(`div`,{className:`min-w-0 lg:col-span-3`,children:B.length===0?(0,x.jsx)(l,{title:`No tables`,hint:`This database has no user tables yet.`}):(0,x.jsxs)(x.Fragment,{children:[U&&(0,x.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`mr-auto min-w-0 truncate font-mono text-sm text-fg`,title:U,children:U}),(0,x.jsx)(a,{size:`sm`,variant:`ghost`,onClick:de,children:`Query`}),(0,x.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-lg border border-line bg-surface p-1`,children:[`data`,`schema`].map(e=>(0,x.jsx)(`button`,{type:`button`,onClick:()=>y(e),"aria-pressed":v===e,className:t(`rounded-md px-3 py-1 text-xs font-medium capitalize transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,v===e?`bg-surface-2 text-fg`:`text-muted hover:text-fg`),children:e},e))}),v===`data`&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(a,{size:`sm`,disabled:!Y||Y.rows.length===0,title:Y?`Exports the ${Y.rows.length} rows on this page only`:void 0,onClick:le,children:[`Export page`,Y?` (${Y.rows.length})`:``]}),(0,x.jsx)(a,{size:`sm`,variant:`accent`,disabled:X||!Y||Y.total===0,onClick:ue,children:X?`Exporting…`:`Export table${Y?` (${f(Y.total)})`:``}`})]})]}),v===`data`&&U&&(0,x.jsx)(I,{columns:Y?.columns??W?.columns.map(e=>e.name)??[],filter:w,onChange:e=>{T(e),o(0),k(null)}}),Q&&(0,x.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:Q}),v===`schema`?W?.table===U?(0,x.jsx)(R,{schema:W}):(0,x.jsx)(i,{label:`Reading schema of ${U}…`}):q&&!Y?(0,x.jsx)(l,{title:`Could not read table`,hint:q.message}):J&&!Y&&K?.table!==U?(0,x.jsx)(i,{label:`Reading ${U}…`}):!Y&&!K?(0,x.jsx)(l,{title:`Select a table`,hint:`Pick a table on the left to browse its rows.`}):(Y??K)&&(Y??K)?.total===0?(0,x.jsx)(l,{title:w?`No matching rows`:`Empty table`,hint:w?`No rows match the current filter.`:`"${(Y??K)?.table}" has no rows.`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(P,{columns:(Y??K)?.columns??[],rows:(Y??K)?.rows??[],truncatedCells:(Y??K)?.truncatedCells,colMeta:ae,sort:s,onSort:ce,onRowClick:e=>k(e),dimmed:J&&!Y}),fe&&(0,x.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Cells over 2000 chars and BLOBs are abbreviated in the grid and CSV — click a row to view the full value.`}),(0,x.jsx)(te,{page:r,pageSize:S,total:(Y??K)?.total??0,onPageChange:e=>{o(e),k(null)},label:`rows`})]}),(0,x.jsx)(z,{sql:A,setSql:j,editorRef:M})]})})]}),Y&&E!=null&&Y.rows[E]&&(0,x.jsx)(L,{table:Y.table,columns:Y.columns,row:Y.rows[E],rowid:Y.rowids[E],truncated:Y.truncatedCells[E],onClose:()=>k(null)})]})}function I({columns:e,filter:t,onChange:n}){let[r,i]=(0,b.useState)(t?.column??``),[o,s]=(0,b.useState)(t?.op??`contains`),[l,u]=(0,b.useState)(t?.value??``),d=r||e[0]||``,f=()=>n(l.trim()?{column:d,op:o,value:l.trim()}:null);return e.length===0?null:(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`div`,{className:`w-40`,children:(0,x.jsx)(v,{value:d,"aria-label":`Filter column`,onChange:e=>i(e.target.value),children:e.map(e=>(0,x.jsx)(`option`,{value:e,children:e},e))})}),(0,x.jsx)(`div`,{className:`w-32`,children:(0,x.jsxs)(v,{value:o,"aria-label":`Filter operator`,onChange:e=>s(e.target.value),children:[(0,x.jsx)(`option`,{value:`contains`,children:`contains`}),(0,x.jsx)(`option`,{value:`eq`,children:`=`}),(0,x.jsx)(`option`,{value:`ne`,children:`≠`})]})}),(0,x.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,x.jsx)(c,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,x.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>e.key===`Enter`&&f(),"aria-label":`Filter value`,placeholder:`value — Enter to filter`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-8 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,x.jsx)(a,{size:`sm`,onClick:f,disabled:!l.trim(),children:`Filter`}),t&&(0,x.jsx)(a,{size:`sm`,variant:`ghost`,onClick:()=>{u(``),n(null)},children:`Clear`})]})}function L({table:e,columns:t,row:n,rowid:r,truncated:i,onClose:a}){let[o,c]=(0,b.useState)({});return(0,b.useEffect)(()=>{let e=e=>e.key===`Escape`&&a();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,b.useEffect)(()=>{if(r==null)return;let n=!1;return(async()=>{for(let a=0;a<t.length;a++)if(i[a])try{let i=await p.db.cell(e,r,t[a]);n||c(e=>({...e,[t[a]]:i.value}))}catch{}})(),()=>{n=!0}},[e,r,t,i]),(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,"aria-label":`Close row detail`,onClick:a,className:`fixed inset-0 z-40 bg-black/50`}),(0,x.jsxs)(`aside`,{className:`fixed inset-y-0 right-0 z-50 flex w-full max-w-xl flex-col border-l border-line bg-surface shadow-xl`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-5 py-4`,children:[(0,x.jsxs)(`h2`,{className:`font-mono text-sm text-fg`,children:[e,` · row detail`]}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`Close`,onClick:a,className:`flex size-8 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,x.jsx)(s,{className:`size-4`})})]}),(0,x.jsx)(`div`,{className:`flex-1 overflow-y-auto p-5`,children:(0,x.jsx)(`dl`,{className:`flex flex-col gap-4`,children:t.map((e,t)=>{let r=e in o?o[e]:n[t],a=M(r),s=a.includes(`
|
|
3
3
|
`)||a.length>80;return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`dt`,{className:`mb-1 flex items-center gap-1.5 text-[11px] uppercase tracking-wider text-faint`,children:[e,r!=null&&(0,x.jsx)(y,{value:String(r)}),i[t]&&!(e in o)&&(0,x.jsx)(`span`,{className:`text-warning`,children:`(loading full value…)`})]}),(0,x.jsx)(`dd`,{children:r==null?(0,x.jsx)(`span`,{className:`italic text-faint`,children:`NULL`}):s?(0,x.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:a}):(0,x.jsx)(`span`,{className:`break-words font-mono text-sm text-fg`,children:a})})]},e)})})})]})]})}function R({schema:e}){return(0,x.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Column`}),(0,x.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Type`}),(0,x.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Constraints`}),(0,x.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Default`})]})}),(0,x.jsx)(`tbody`,{children:e.columns.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,x.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-fg`,children:e.name}),(0,x.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-muted`,children:e.type}),(0,x.jsxs)(`td`,{className:`px-4 py-2 text-xs`,children:[e.primaryKey&&(0,x.jsx)(`span`,{className:`mr-1 rounded-md bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold text-accent`,children:`PK`}),e.notNull&&(0,x.jsx)(`span`,{className:`rounded-md bg-surface-2 px-1.5 py-0.5 text-[10px] font-semibold text-muted`,children:`NOT NULL`})]}),(0,x.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-faint`,children:e.defaultValue??`—`})]},e.name))})]})}),(0,x.jsxs)(u,{children:[(0,x.jsx)(o,{title:`Indexes (${e.indexes.length})`}),e.indexes.length===0?(0,x.jsx)(`p`,{className:`text-xs text-faint`,children:`No indexes on this table.`}):(0,x.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.indexes.map(e=>(0,x.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2 font-mono text-xs`,children:[(0,x.jsx)(`span`,{className:`text-fg`,children:e.name}),e.unique&&(0,x.jsx)(`span`,{className:`rounded-md bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold text-accent`,children:`UNIQUE`}),(0,x.jsxs)(`span`,{className:`text-faint`,children:[`(`,e.columns.join(`, `),`)`]})]},e.name))})]}),e.sql&&(0,x.jsxs)(u,{children:[(0,x.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,x.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`DDL`}),(0,x.jsx)(y,{value:e.sql})]}),(0,x.jsx)(`pre`,{className:`overflow-x-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:e.sql})]})]})}function z({sql:e,setSql:t,editorRef:n}){let[r,i]=(0,b.useState)(!1),[s,c]=(0,b.useState)(null),[l,d]=(0,b.useState)(k),[m,h]=(0,b.useState)(null),g=(0,b.useRef)(0);(0,b.useEffect)(()=>()=>{g.current++},[]);let _=async(t=e,n=!0)=>{if(!t.trim()||r)return;let a=++g.current;i(!0),c(null);try{let r=await p.db.query(t);if(a!==g.current)return;h(r),n&&d(j(e.trim()))}catch(e){if(a!==g.current)return;h(null),c(e.message)}finally{a===g.current&&i(!1)}};return(0,x.jsxs)(u,{className:`mt-6`,children:[(0,x.jsx)(o,{title:`Query`,action:(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(a,{size:`sm`,disabled:r||!e.trim(),onClick:()=>{let t=e.trim();t&&_(`EXPLAIN QUERY PLAN ${t}`,!1)},children:`Explain`}),(0,x.jsx)(a,{size:`sm`,variant:`accent`,disabled:r||!e.trim(),onClick:()=>_(),children:r?`Running…`:`Run`})]})}),(0,x.jsx)(`textarea`,{ref:n,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&_()},rows:3,spellCheck:!1,"aria-label":`SQL query`,placeholder:`SELECT … — read-only: writes are rejected by the engine`,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),(0,x.jsx)(`p`,{className:`mt-1 text-[11px] text-faint`,children:`⌘/Ctrl+Enter runs. Connection is read-only.`}),l.length>0&&(0,x.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[(0,x.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`History`}),l.map(e=>(0,x.jsx)(`button`,{type:`button`,onClick:()=>t(e),title:e,className:`max-w-56 truncate 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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:e},e)),(0,x.jsx)(`button`,{type:`button`,onClick:()=>{A([]),d([])},className:`rounded-md px-2 py-1 text-[11px] text-faint transition-colors hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Clear`})]}),(0,x.jsxs)(`div`,{"aria-live":`polite`,children:[s&&(0,x.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:s}),m&&!s&&(0,x.jsxs)(`div`,{className:`mt-4`,children:[(0,x.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-3`,children:[(0,x.jsxs)(`p`,{className:`text-xs text-faint`,children:[m.truncated?`≥ `:``,f(m.rowCount),` row`,m.rowCount===1?``:`s`,` ·`,` `,f(m.ms),` ms`,m.truncated&&(0,x.jsxs)(`span`,{className:`text-warning`,children:[` — showing first `,m.rows.length]})]}),m.rows.length>0&&(0,x.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,x.jsx)(a,{size:`sm`,onClick:()=>O(`query-results.csv`,`text/csv`,D(m.columns,m.rows)),children:`CSV`}),(0,x.jsx)(a,{size:`sm`,onClick:()=>O(`query-results.json`,`application/json`,JSON.stringify(m.rows.map(e=>Object.fromEntries(m.columns.map((t,n)=>[t,e[n]]))),null,2)),children:`JSON`})]})]}),m.rows.length>0?(0,x.jsx)(P,{columns:m.columns,rows:m.rows}):(0,x.jsx)(`p`,{className:`text-xs text-faint`,children:`Query returned no rows.`})]})]})]})}export{F as Database};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{C as r,D as i,E as a,T as o,_ as s,c,d as l,g as u,j as d,r as f,v as p,w as m}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{C as r,D as i,E as a,T as o,_ as s,c,d as l,g as u,j as d,r as f,v as p,w as m}from"./index-C9fPU4bV.js";var h=e(t(),1),g=n(),_={health:{},storage:null,stats:null};function v(){let{data:e,error:t,loading:n,refetch:v}=d(async()=>{let[e,t,n]=await Promise.all([u.health(),u.storage().catch(()=>null),u.stats().catch(()=>null)]);return{health:e,storage:t,stats:n}},[]),[x,S]=(0,h.useState)(null),C=async()=>{S(`…`);let e=performance.now();try{await u.ping(),S(`${Math.round(performance.now()-e)} ms`)}catch{S(`unreachable`)}};if(n&&!e&&!t)return(0,g.jsx)(r,{label:`Loading diagnostics…`});let w=e??_,T=w.health,E=w.storage?.data,D=w.stats?.stats;return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(p,{title:`Diagnostics`,description:`Server health, storage, memory and connections.`,live:!t}),t&&(0,g.jsx)(m,{onRetry:v}),(0,g.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,g.jsx)(s,{label:`Status`,value:T.status??(T.ok?`healthy`:`degraded`),tone:T.ok?`green`:`red`,compact:!0}),(0,g.jsx)(s,{label:`Version`,value:T.version?`v${T.version}`:`—`,compact:!0}),(0,g.jsx)(s,{label:`Uptime`,value:l(T.uptime),compact:!0}),(0,g.jsx)(s,{label:`Disk`,value:E?.diskFull?`Full`:`Healthy`,tone:E?.diskFull?`red`:`green`,compact:!0})]}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsxs)(o,{children:[(0,g.jsx)(a,{title:`Connectivity`,action:(0,g.jsxs)(i,{size:`sm`,onClick:C,children:[`Ping`,x?` · ${x}`:``]})}),(0,g.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,g.jsx)(y,{k:`WebSocket clients`,v:String(T.connections?.ws??0)}),(0,g.jsx)(y,{k:`SSE clients`,v:String(T.connections?.sse??0)}),(0,g.jsx)(y,{k:`Storage error`,v:E?.error?String(E.error):`none`})]})]}),(0,g.jsxs)(o,{children:[(0,g.jsx)(a,{title:`Memory`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,g.jsx)(b,{k:`Heap used`,v:f((T.memory?.heapUsed??0)*1024*1024)}),(0,g.jsx)(b,{k:`Heap total`,v:f((T.memory?.heapTotal??0)*1024*1024)}),(0,g.jsx)(b,{k:`RSS`,v:f((T.memory?.rss??0)*1024*1024)})]})]})]}),D&&(0,g.jsxs)(o,{className:`mt-6`,children:[(0,g.jsx)(a,{title:`Totals since restart`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,g.jsx)(b,{k:`Pushed`,v:c(D.totalPushed)}),(0,g.jsx)(b,{k:`Pulled`,v:c(D.totalPulled)}),(0,g.jsx)(b,{k:`Completed`,v:c(D.totalCompleted)}),(0,g.jsx)(b,{k:`Failed`,v:c(D.totalFailed)})]})]})]})}function y({k:e,v: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})]})}function b({k:e,v:t}){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,g.jsx)(`div`,{className:`mt-1 text-lg font-semibold tnum text-fg`,children:t})]})}export{v as Diagnostics};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{C as r,D as i,M as a,S as o,_ as s,c,j as l,u,v as d,w as f,z as p}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{C as r,D as i,M as a,S as o,_ as s,c,j as l,u,v as d,w as f,z as p}from"./index-C9fPU4bV.js";import{a as m}from"./form-PtDLk33Z.js";import{t as h}from"./Pagination-Cd6lHj2E.js";var g=e(t(),1),_=n(),v=25;function y(){let[e,t]=(0,g.useState)(``),[n,y]=(0,g.useState)(0),[b,x]=(0,g.useState)(!1),[S,C]=(0,g.useState)(null),{data:w}=l(()=>a.queues(500),[],{intervalMs:3e4});(0,g.useEffect)(()=>{e||!w?.queues?.length||t((w.queues.find(e=>e.dlq>0)??w.queues[0]).name)},[w,e]);let{data:T,error:E,loading:D,refetch:O}=l((0,g.useCallback)(async()=>{if(!e)return{entries:[],total:0};let t=await a.dlq(e,v,n*v);return{entries:t.entries??[],total:t.total??t.entries?.length??0}},[e,n]),[e,n]),k=async(t,n)=>{if(window.confirm(`${t} the dead letter queue for "${e}"?`)){x(!0),C(null);try{await n(),C(`${t} done`),O()}catch(e){C(e.message)}finally{x(!1)}}},A=T?.entries??[];return(0,_.jsxs)(`div`,{children:[E&&(0,_.jsx)(f,{onRetry:O}),(0,_.jsx)(d,{title:`Dead Letter Queue`,description:`Jobs that exhausted their retries.`,live:!0,actions:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(i,{size:`sm`,disabled:!e||b,onClick:()=>k(`Retry`,()=>a.retryDlq(e)),children:`Retry all`}),(0,_.jsx)(i,{variant:`danger`,size:`sm`,disabled:!e||b,onClick:()=>k(`Purge`,()=>a.purgeDlq(e)),children:`Purge`})]})}),(0,_.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,_.jsx)(`div`,{className:`w-56`,children:(0,_.jsx)(m,{value:e,onChange:e=>{t(e.target.value),y(0)},children:(w?.queues??[]).map(e=>(0,_.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,_.jsx)(`div`,{className:`w-40`,children:(0,_.jsx)(s,{label:`DLQ Entries`,value:c(T?.total),tone:T?.total?`red`:`default`,compact:!0})}),S&&(0,_.jsx)(`span`,{className:`text-xs text-muted`,children:S})]}),D&&!T&&!E?(0,_.jsx)(r,{label:`Loading DLQ…`}):A.length===0?(0,_.jsx)(o,{icon:(0,_.jsx)(p,{}),title:`Dead letter queue is empty`,hint:`Jobs land here after exhausting their retry attempts.`}):(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,_.jsx)(`tbody`,{children:A.map((e,t)=>(0,_.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.jobId??e.id}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name||`unknown`}),(0,_.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-red-400/90`,children:String(e.reason||e.error||`—`)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:Array.isArray(e.attempts)?e.attempts.length:e.attempts??`—`}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.failedAt??e.enteredAt)})]},e.jobId??e.id??t))})]})}),T&&(0,_.jsx)(h,{page:n,pageSize:v,total:T.total,onPageChange:y,label:`entries`})]})}export{y as Dlq};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{C as r,D as i,K as a,O as o,S as s,_ as c,c as l,g as u,j as d,u as f,v as p,w as m,z as h}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{C as r,D as i,K as a,O as o,S as s,_ as c,c as l,g as u,j as d,u as f,v as p,w as m,z as h}from"./index-C9fPU4bV.js";import{a as g}from"./form-PtDLk33Z.js";import{t as _}from"./Pagination-Cd6lHj2E.js";var v=e(t(),1),y=n(),b=25;function x(){let[e,t]=(0,v.useState)(``),[n,x]=(0,v.useState)(0),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(null),{data:E}=d(()=>u.queues(),[],{intervalMs:3e4});(0,v.useEffect)(()=>{e||!E?.queues?.length||t((E.queues.find(e=>e.dlq>0)??E.queues[0]).name)},[E,e]);let{data:D,error:O,loading:k,refetch:A}=d((0,v.useCallback)(async()=>{if(!e)return{queue:e,page:n,entries:[],total:0};let t=await u.dlq(e,b,n*b);return{queue:e,page:n,entries:t.entries??[],total:t.total??0}},[e,n]),[e,n]),j=D&&D.queue===e&&D.page===n?D:null;(0,v.useEffect)(()=>{if(!j)return;let e=Math.max(0,Math.ceil((j.total??0)/b)-1);n>e&&x(e)},[j,n]);let M=async(e,t,n)=>{if(!(n&&!window.confirm(n))){C(!0),T(null);try{let n=(await t())?.count??0;T({ok:!0,text:`${e} ${l(n)} ${n===1?`entry`:`entries`}`}),A()}catch(e){T({ok:!1,text:e.message})}finally{C(!1)}}},N=j?.entries??[];return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(p,{title:`Dead Letter Queue`,description:`Inspect and replay jobs that exhausted their retries.`,live:!0,actions:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(i,{size:`sm`,disabled:!e||S,onClick:()=>M(`Retried`,()=>u.retryDlq(e),`Retry all ${j?.total??0} DLQ entries for "${e}"?`),children:[(0,y.jsx)(a,{className:`size-3.5`}),` Retry all`]}),(0,y.jsx)(i,{variant:`danger`,size:`sm`,disabled:!e||S,onClick:()=>M(`Purged`,()=>u.purgeDlq(e),`Purge all ${j?.total??0} DLQ entries for "${e}"?`),children:`Purge`})]})}),O&&(0,y.jsx)(m,{onRetry:A}),(0,y.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-56`,children:(0,y.jsx)(g,{value:e,"aria-label":`Queue`,onChange:e=>{t(e.target.value),x(0)},children:(E?.queues??[]).map(e=>(0,y.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,y.jsx)(`div`,{className:`w-40`,children:(0,y.jsx)(c,{label:`Entries`,value:l(j?.total),tone:j?.total?`red`:`default`,compact:!0})}),w&&(0,y.jsx)(`span`,{className:w.ok?`text-sm text-success`:`text-sm text-danger`,children:w.text})]}),k&&!j&&!O?(0,y.jsx)(r,{label:`Loading DLQ…`}):N.length===0?(0,y.jsx)(s,{icon:(0,y.jsx)(h,{}),title:`Dead letter queue is empty`,hint:`Failed jobs that exhaust their retries land here.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Error`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,y.jsx)(`th`,{className:`w-20 px-5 py-3`})]})}),(0,y.jsx)(`tbody`,{children:N.map(t=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:t.job.id}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:t.reason})}),(0,y.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:t.error||`—`}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:t.job.attempts??t.attempts?.length??`—`}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:f(t.enteredAt)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,y.jsx)(o,{"aria-label":`Retry job`,disabled:S,onClick:()=>M(`Retried`,()=>u.retryDlq(e,t.job.id)),children:(0,y.jsx)(a,{className:`size-3.5`})})})]},`${t.job.id}-${t.enteredAt}`))})]})}),j&&(0,y.jsx)(_,{page:n,pageSize:b,total:j.total,onPageChange:x,label:`entries`})]})}export{x as DlqControl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{m as n,r,t as i}from"./react-vendor-CHIHtdAC.js";import{C as a,D as o,K as s,O as c,S as l,T as u,c as d,g as f,j as p,u as m,v as h,w as g,z as _}from"./index-
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{m as n,r,t as i}from"./react-vendor-CHIHtdAC.js";import{C as a,D as o,K as s,O as c,S as l,T as u,c as d,g as f,j as p,u as m,v as h,w as g,z as _}from"./index-C9fPU4bV.js";import{a as v}from"./form-PtDLk33Z.js";import{t as y}from"./Pagination-Cd6lHj2E.js";var b=e(n(),1),x=i(),S=25;function C(){let[e,n]=(0,b.useState)(``),[i,C]=(0,b.useState)(`all`),[w,T]=(0,b.useState)(`newest`),[E,D]=(0,b.useState)(``),[O,k]=(0,b.useState)(0),[A,j]=(0,b.useState)(!1),[M,N]=(0,b.useState)(null),{data:P,refetch:F}=p(()=>f.queues(),[],{intervalMs:1e4}),I=P?.queues??[],L=I.reduce((e,t)=>e+t.dlq,0),{data:R,error:z,loading:B,refetch:V}=p((0,b.useCallback)(async()=>{if(!e)return{queue:e,page:O,entries:[],entriesTotal:0,stats:null};let[t,n]=await Promise.all([f.dlq(e,S,O*S),f.dlqStats(e).catch(()=>null)]);return{queue:e,page:O,entries:t.entries??[],entriesTotal:t.total??0,stats:n?.stats??null}},[e,O]),[e,O]),H=R&&R.queue===e&&R.page===O?R:null;(0,b.useEffect)(()=>{if(!H)return;let e=H.entriesTotal??0;O>0&&O*S>=e&&k(Math.max(0,Math.ceil(e/S)-1))},[H,O]);let U=async(e,t,n)=>{if(window.confirm(e)){j(!0),N(null);try{let e=(await n())?.count??0;N({ok:!0,text:`${t} ${d(e)} ${e===1?`entry`:`entries`}`}),V(),F()}catch(e){N({ok:!1,text:e.message})}finally{j(!1)}}},W=e=>{Y.current=!0,n(e),k(0),C(`all`)},G=H?.stats?.byReason??{},K=Object.keys(G).filter(e=>G[e]>0),q=[...K].sort((e,t)=>(G[t]??0)-(G[e]??0))[0],J=(0,b.useMemo)(()=>I.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[I]),Y=(0,b.useRef)(!1);(0,b.useEffect)(()=>{Y.current||e||J.length===0||(Y.current=!0,n(J[0].name),k(0),C(`all`))},[e,J]);let X=(0,b.useMemo)(()=>{let e=H?.entries??[];i!==`all`&&(e=e.filter(e=>e.reason===i));let t=E.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>w===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[H,i,E,w]),Z=L===0,Q=i!==`all`||E.trim()!==``,$=(H?.entriesTotal??0)>S;return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(h,{title:`Dead Letter Queue`,description:`Jobs that failed after exhausting all retries. Monitor, retry, or purge.`,live:!0}),z&&(0,x.jsx)(g,{onRetry:V}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,x.jsxs)(u,{children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,x.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,Z?`bg-emerald-500/10 text-success`:`bg-red-500/10 text-danger`),children:Z?`Healthy`:`Attention`})]}),(0,x.jsx)(`div`,{className:t(`mt-2 text-3xl font-bold tnum`,Z?`text-success`:`text-danger`),children:d(L)})]}),(0,x.jsxs)(u,{children:[(0,x.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,x.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:e?q??`No failures`:`Select a queue`})]}),(0,x.jsxs)(u,{children:[(0,x.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,x.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:H?.stats?d(H.stats.pendingRetry??0):`—`}),(0,x.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:e?`in this queue`:`awaiting retry`})]}),(0,x.jsxs)(u,{children:[(0,x.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,x.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:H?.stats?d(K.length):`—`}),(0,x.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]}),J.length>0&&(0,x.jsxs)(u,{className:`mb-6`,children:[(0,x.jsx)(`div`,{className:`mb-3 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,x.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:J.map(n=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>W(n.name),className:t(`rounded-lg border p-3 text-left transition-colors`,e===n.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,x.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:n.name}),(0,x.jsx)(`div`,{className:`mt-1 text-xl font-bold tnum text-danger`,children:n.dlq})]},n.name))})]}),(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-48`,children:(0,x.jsxs)(v,{value:e,onChange:e=>W(e.target.value),children:[(0,x.jsx)(`option`,{value:``,children:`Select a queue…`}),I.map(e=>(0,x.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,x.jsx)(`div`,{className:`w-40`,children:(0,x.jsxs)(v,{value:i,onChange:e=>C(e.target.value),"aria-label":`Filter by reason`,children:[(0,x.jsx)(`option`,{value:`all`,children:`All Reasons`}),K.map(e=>(0,x.jsx)(`option`,{value:e,children:e},e))]})}),(0,x.jsx)(`div`,{className:`w-36`,children:(0,x.jsxs)(v,{value:w,onChange:e=>T(e.target.value),"aria-label":$?`Sort this page`:`Sort`,children:[(0,x.jsxs)(`option`,{value:`newest`,children:[`Newest First`,$?` (this page)`:``]}),(0,x.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,$?` (this page)`:``]})]})}),(0,x.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),placeholder:`Filter this page by job ID…`,"aria-label":`Filter this page by job ID`,className:`h-9 min-w-40 flex-1 rounded-lg border border-line bg-surface px-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),(0,x.jsxs)(o,{size:`sm`,disabled:!e||A,onClick:()=>U(`Retry all for "${e}"?`,`Retried`,()=>f.retryDlq(e)),children:[(0,x.jsx)(s,{className:`size-3.5`}),` Retry All`]}),(0,x.jsx)(o,{variant:`danger`,size:`sm`,disabled:!e||A,onClick:()=>U(`Purge all for "${e}"?`,`Purged`,()=>f.purgeDlq(e)),children:`Purge All`})]}),M&&(0,x.jsx)(`div`,{className:t(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),B&&!H&&!z?(0,x.jsx)(a,{label:`Loading DLQ…`}):e?X.length===0?(0,x.jsx)(l,{icon:(0,x.jsx)(_,{}),title:Q?`No matches on this page`:`No dead letter entries`,hint:Q?`No entries on this page match your filter — the filter is page-scoped. Use the pager below to check other pages.`:`This queue has no dead letter entries.`}):(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Error`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,x.jsx)(`th`,{className:`w-16 px-5 py-3`})]})}),(0,x.jsx)(`tbody`,{children:X.map(t=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(r,{to:`/job?id=${encodeURIComponent(t.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:t.job.id})}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:t.reason})}),(0,x.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:t.error||`—`}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:m(t.enteredAt)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,x.jsx)(c,{"aria-label":`Retry`,disabled:A,onClick:()=>U(`Retry job ${t.job.id.slice(0,8)}… from "${e}"?`,`Retried`,()=>f.retryDlq(e,t.job.id)),children:(0,x.jsx)(s,{className:`size-3.5`})})})]},`${t.job.id}-${t.enteredAt}`))})]})}):(0,x.jsx)(l,{icon:(0,x.jsx)(_,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),e&&H&&(0,x.jsx)(y,{page:O,pageSize:S,total:H.entriesTotal,onPageChange:k,label:`entries`})]})}export{C as DlqPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{d as n,m as r,r as i,t as a}from"./react-vendor-CHIHtdAC.js";import{C as o,T as s,g as c,v as l,w as u,x as d}from"./index-
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{d as n,m as r,r as i,t as a}from"./react-vendor-CHIHtdAC.js";import{C as o,T as s,g as c,v as l,w as u,x as d}from"./index-C9fPU4bV.js";var f=e(r(),1),p={nodeWidth:168,nodeHeight:60,colGap:72,rowGap:20,padding:24};function m(e,t){let n=new Map,r=new Map,i=new Map;for(let t of e)n.set(t,0),r.set(t,0),i.set(t,[]);for(let e of t)!n.has(e.from)||!n.has(e.to)||e.from===e.to||(i.get(e.from)?.push(e.to),r.set(e.to,(r.get(e.to)??0)+1));let a=e.filter(e=>(r.get(e)??0)===0),o=0;for(;a.length;){let s=a.shift();o+=1;for(let e of i.get(s)??[]){n.set(e,Math.max(n.get(e)??0,(n.get(s)??0)+1));let t=(r.get(e)??0)-1;r.set(e,t),t===0&&a.push(e)}if(o>e.length+t.length)break}return n}function h(e,t,n={}){let r={...p,...n},i=m(e,t),a=new Map,o=0;for(let t of e){let e=i.get(t)??0;o=Math.max(o,e);let n=a.get(e);n?n.push(t):a.set(e,[t])}let s=0;for(let e of a.values())s=Math.max(s,e.length);let c=s*r.nodeHeight+Math.max(0,s-1)*r.rowGap,l=[];for(let e=0;e<=o;e++){let t=a.get(e)??[],n=t.length*r.nodeHeight+Math.max(0,t.length-1)*r.rowGap,i=r.padding+(c-n)/2;t.forEach((t,n)=>{l.push({id:t,layer:e,x:r.padding+e*(r.nodeWidth+r.colGap),y:i+n*(r.nodeHeight+r.rowGap)})})}return{nodes:l,width:r.padding*2+(o+1)*r.nodeWidth+o*r.colGap,height:r.padding*2+c}}var g=a(),_=168,v=60,y={nodeWidth:_,nodeHeight:v},b=60,x=6,S=`flow-order-9a3f`,C={completed:`border-success/50 bg-success/10 text-success`,failed:`border-danger/50 bg-danger/10 text-danger`,active:`border-blue-400/60 bg-blue-400/10 text-blue-400`,delayed:`border-accent/50 bg-accent/10 text-accent`,waiting:`border-warning/50 bg-warning/10 text-warning`,prioritized:`border-warning/50 bg-warning/10 text-warning`},w=e=>e&&C[e]||`border-line bg-surface-2 text-muted`,T=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,E=`bq-dash-recent-flows`,D=8;function O(){try{let e=JSON.parse(localStorage.getItem(E)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e?.root==`string`&&typeof e?.nodes==`number`&&typeof e?.at==`number`):[]}catch{return[]}}function k(e,t){let n=[t,...e.filter(e=>e.root!==t.root)].slice(0,D);try{localStorage.setItem(E,JSON.stringify(n))}catch{}return n}async function A(e){let t=e,n=new Set([e]);for(let e=0;e<12;e++){try{let{job:e}=await c.job(t),r=e?.parentId;if(r&&!n.has(r)){n.add(r),t=r;continue}}catch{}break}return t}async function j(e){let t=new Map,n=[],r=new Set,i=[{id:e,depth:0}];for(;i.length&&t.size<b;){let{id:e,depth:a}=i.shift();if(t.has(e))continue;let o=null;try{o=(await c.job(e)).job??null}catch{}if(t.set(e,o??{id:e,state:`unknown`}),!o||a>=x)continue;let s=(e,t,o,s)=>{let c=`${e}->${t}:${o}`;r.has(c)||(r.add(c),n.push({from:e,to:t,kind:o})),i.push({id:s,depth:a+1})};for(let t of o.childrenIds??[])s(e,t,`child`,t);for(let t of o.dependsOn??[])s(t,e,`depends`,t)}return{jobs:t,edges:n}}function M(e,t,n,r){let i=(e+n)/2;return`M${e},${t} C${i},${t} ${i},${r} ${n},${r}`}function N(){let[e,r]=n(),a=e.get(`root`)??(d()?S:``),[c,p]=(0,f.useState)(a),[m,x]=(0,f.useState)(null),[C,E]=(0,f.useState)(null),[D,N]=(0,f.useState)(!1),[F,I]=(0,f.useState)(null),[L,R]=(0,f.useState)(O),z=(0,f.useRef)(0),B=(0,f.useCallback)(async e=>{let t=e.trim();if(!t){x(null);return}let n=++z.current;N(!0),I(null);try{let e=await A(t),r=await j(e);if(n!==z.current)return;x(r),E(e),r.jobs.size>1&&R(t=>k(t,{root:e,nodes:r.jobs.size,at:Date.now()}))}catch(e){if(n!==z.current)return;I(e.message||`Failed to load flow`),x(null)}finally{n===z.current&&N(!1)}},[]);(0,f.useEffect)(()=>{a&&B(a)},[a,B]);let V=e=>{e.preventDefault();let t=c.trim();t&&r(t?{root:t}:{},{replace:!0})},H=m?h([...m.jobs.keys()],m.edges,y):null,U=new Map(H?.nodes.map(e=>[e.id,e])??[]),W=C?m?.jobs.get(C):void 0;return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(l,{title:`Flows`,description:`Visualize a job flow: parent, children, and dependency edges as an interactive graph.`,actions:m&&(0,g.jsx)(`button`,{type:`button`,onClick:()=>B(c||a),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Refresh`})}),(0,g.jsxs)(s,{className:`mb-6`,children:[(0,g.jsxs)(`form`,{onSubmit:V,className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(`input`,{value:c,onChange:e=>p(e.target.value),placeholder:`Job ID (any node in the flow)`,"aria-label":`Root job ID`,className:`min-w-0 flex-1 rounded-lg border border-line bg-surface-2 px-3 py-2 font-mono text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/50`}),(0,g.jsx)(`button`,{type:`submit`,disabled:!c.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-50`,children:`Load flow`})]}),(0,g.jsxs)(`p`,{className:`mt-2 text-xs text-faint`,children:[`Paste any job ID from the Job Inspector. The graph climbs to the flow root, then walks children and dependencies (up to `,b,` nodes).`]})]}),F&&(0,g.jsx)(u,{onRetry:()=>B(c||a)}),D&&!m&&(0,g.jsx)(o,{label:`Loading flow…`}),!D&&!m&&!F&&(0,g.jsx)(s,{children:(0,g.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,g.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow loaded.`}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Enter a job ID above, or open a job that is part of a flow and choose “View flow”.`}),L.length>0&&(0,g.jsxs)(`div`,{className:`mt-6`,children:[(0,g.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Recently viewed`}),(0,g.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:L.map(e=>(0,g.jsxs)(`button`,{type:`button`,onClick:()=>{p(e.root),r({root:e.root},{replace:!0})},className:`rounded-lg border border-line bg-surface-2 px-3 py-1.5 font-mono text-xs text-muted transition-colors hover:border-line-strong hover:text-fg`,children:[T(e.root),(0,g.jsxs)(`span`,{className:`ml-2 text-faint`,children:[e.nodes,` nodes`]})]},e.root))})]})]})}),m&&H&&(0,g.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1fr_260px]`,children:[(0,g.jsx)(s,{padded:!1,className:`overflow-auto p-4`,children:(0,g.jsxs)(`div`,{className:`relative`,style:{width:H.width,height:H.height},children:[(0,g.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 text-line`,width:H.width,height:H.height,children:[(0,g.jsx)(`title`,{children:`Flow edges`}),m.edges.map(e=>{let t=U.get(e.from),n=U.get(e.to);return!t||!n?null:(0,g.jsx)(`path`,{d:M(t.x+_,t.y+v/2,n.x,n.y+v/2),fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeDasharray:e.kind===`depends`?`4 4`:void 0,opacity:.5},`${e.from}-${e.to}-${e.kind}`)})]}),H.nodes.map(e=>{let n=m.jobs.get(e.id);return(0,g.jsxs)(`button`,{type:`button`,onClick:()=>E(e.id),style:{left:e.x,top:e.y,width:_,height:v},className:t(`absolute flex flex-col justify-center gap-0.5 rounded-lg border px-3 text-left transition-shadow`,w(n?.state),C===e.id&&`ring-2 ring-accent`),children:[(0,g.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:T(e.id)}),(0,g.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,g.jsx)(`span`,{className:`truncate`,children:n?.queue??`—`}),(0,g.jsx)(`span`,{className:`font-medium`,children:n?.state??`unknown`})]})]},e.id)})]})}),(0,g.jsxs)(s,{children:[W?(0,g.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-xs text-faint`,children:`Job`}),(0,g.jsx)(`div`,{className:`break-all font-mono text-xs text-fg`,children:W.id})]}),(0,g.jsx)(P,{label:`Queue`,value:W.queue??`—`}),(0,g.jsx)(P,{label:`State`,value:W.state??`unknown`}),(0,g.jsx)(P,{label:`Priority`,value:String(W.priority??0)}),(0,g.jsx)(P,{label:`Children`,value:String(W.childrenIds?.length??0)}),(0,g.jsx)(P,{label:`Depends on`,value:String(W.dependsOn?.length??0)}),(0,g.jsx)(i,{to:`/job?id=${encodeURIComponent(W.id)}`,className:`inline-block rounded-lg border border-line px-3 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg`,children:`Open in Job Inspector`})]}):(0,g.jsx)(`p`,{className:`text-sm text-muted`,children:`Click a node to inspect it.`}),(0,g.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-xs text-faint`,children:[(0,g.jsxs)(`div`,{className:`mb-1`,children:[m.jobs.size,` node`,m.jobs.size===1?``:`s`,` · `,m.edges.length,` edge`,m.edges.length===1?``:`s`]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,g.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,g.jsx)(`span`,{className:`inline-block h-px w-4 bg-current`}),` child`]}),(0,g.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,g.jsx)(`span`,{className:`inline-block h-px w-4 border-t border-dashed border-current`}),` `,`depends`]})]})]})]})]})]})}function P({label:e,value:t}){return(0,g.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,g.jsx)(`span`,{className:`text-xs text-faint`,children:e}),(0,g.jsx)(`span`,{className:`text-fg`,children:t})]})}export{N as Flows};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{d as t,m as n,r,t as i}from"./react-vendor-CHIHtdAC.js";import{C as a,D as o,E as s,J as c,S as l,T as u,a as d,g as f,m as p,o as m,v as h,y as g}from"./index-D6Nj5ksZ.js";import{a as _,n as v}from"./form-PtDLk33Z.js";import{t as y}from"./CopyButton-BRNz3U_X.js";import{t as b}from"./jobActions-CuOdMglt.js";var x=e(n(),1),S=i();function C({job:e,busy:t,act:n}){let r=b(e.state),i=r.cancel||r.discard||r.promote||r.retryActive||r.retryDlq||r.requeueCompleted||r.setPriority||r.setDelay||r.fail||r.moveToDelayed;return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Actions`}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>f.promoteJob(e.id)),children:`Promote (run now)`}),r.retryActive&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>f.retryJob(e.id)),children:`Retry (move to waiting)`}),r.retryDlq&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>f.retryDlq(e.queue??``,e.id)),children:`Retry from DLQ`}),r.requeueCompleted&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Requeue`,()=>f.retryCompleted(e.queue??``,e.id)),children:`Requeue`}),r.moveToDelayed&&(0,S.jsx)(w,{label:`Move to delayed (ms)`,cta:`To delayed`,disabled:t,onSubmit:t=>n(`Move to delayed`,()=>f.moveToDelayed(e.id,t))}),r.discard&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Discard`,()=>f.discardJob(e.id)),children:`Discard (to DLQ)`}),r.setPriority&&(0,S.jsx)(w,{label:`Set priority`,cta:`Set`,disabled:t,onSubmit:t=>n(`Priority`,()=>f.changePriority(e.id,t))}),r.setDelay&&(0,S.jsx)(w,{label:`Set delay (ms)`,cta:`Delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>f.changeDelay(e.id,t))}),r.fail&&(0,S.jsx)(T,{label:`Fail reason (optional)`,cta:`Fail`,variant:`warning`,disabled:t,onSubmit:t=>n(`Fail`,()=>f.failJob(e.id,t||void 0),`Force-fail this active job?`)}),r.cancel&&(0,S.jsx)(o,{variant:`danger`,size:`sm`,disabled:t,onClick:()=>n(`Cancel`,()=>f.cancelJob(e.id),`Cancel and remove this job?`),children:`Cancel (delete)`}),!i&&(0,S.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function w({label:e,cta:t,disabled:n,onSubmit:r}){let[i,a]=(0,x.useState)(``);return(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(v,{type:`number`,value:i,onChange:e=>a(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,S.jsx)(o,{size:`sm`,disabled:n||i.trim()===``,onClick:()=>r(Number(i)),children:t})]})}function T({label:e,cta:t,disabled:n,variant:r=`default`,onSubmit:i}){let[a,s]=(0,x.useState)(``);return(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(v,{value:a,onChange:e=>s(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,S.jsx)(o,{size:`sm`,variant:r,disabled:n,onClick:()=>{i(a),s(``)},children:t})]})}var E=36e5,D=10;function O(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??E,a=r?.delay??e.backoff??1e3,o=[];for(let e=n;e<t&&o.length<D;e++){let t=r?.type===`fixed`?a:a*2**e;o.push({attempt:e+1,delayMs:Math.min(t,i)})}return o}function k({job:e}){let t=e.maxAttempts??0,n=e.attempts??0;if(t<=1)return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Backoff`}),(0,S.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Backoff schedule`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Max attempts reached — no further retries will be scheduled.`})]});let r=e.backoffConfig,i=r?r.type:`exponential (default)`,a=t-n,o=O(e);return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Backoff schedule`,action:(0,S.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${m(r.maxDelay)}`:``]})}),(0,S.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map(e=>(0,S.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,S.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,S.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,m(e.delayMs)]})]},e.attempt))}),a>D&&(0,S.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,D,` of `,a,` remaining attempts.`]}),(0,S.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Approximate — the server applies ±`,r?.type===`fixed`?`20`:`50`,`% jitter at retry time, capped at `,m(r?.maxDelay??E),`.`]})]})}function A({jobId:e}){let[t,n]=(0,x.useState)(!1),[r,i]=(0,x.useState)(!1),[a,c]=(0,x.useState)(!1),[l,d]=(0,x.useState)(void 0),[p,m]=(0,x.useState)(null),h=async()=>{c(!0),m(null);try{d((await f.jobChildren(e)).data?.values),i(!0)}catch(e){m(e.message)}finally{c(!1)}},g=()=>{let e=!t;n(e),e&&!r&&!a&&h()},_=l&&typeof l==`object`?Array.isArray(l)?l.length:Object.keys(l).length:0;return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Child values`,action:(0,S.jsx)(o,{size:`sm`,variant:`ghost`,onClick:g,children:t?`Hide`:`Show`})}),t?a?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):p?(0,S.jsx)(`p`,{className:`text-xs text-danger`,children:p}):_===0?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,S.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(l,null,2)}):(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Resolved return values from this flow job's children.`})]})}function j({data:e,busy:t,onSave:n}){let[r,i]=(0,x.useState)(()=>JSON.stringify(e??null,null,2)),[a,c]=(0,x.useState)(null),l=(0,x.useRef)(r);return(0,x.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,i(t),c(null))},[e]),(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Edit data`,action:(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>{let e;try{e=JSON.parse(r)}catch(e){c(`Invalid JSON: ${e.message}`);return}c(null),n(e)},children:`Save data`})}),(0,S.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),spellCheck:!1,rows:8,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),a&&(0,S.jsx)(`p`,{className:`mt-2 text-xs text-danger`,children:a})]})}function M({jobId:e}){let[t,n]=(0,x.useState)([]),[r,i]=(0,x.useState)(0),[a,c]=(0,x.useState)(!1),[l,d]=(0,x.useState)(null),[p,m]=(0,x.useState)(``),[h,g]=(0,x.useState)(`info`),[y,b]=(0,x.useState)(!1),C=(0,x.useCallback)(async()=>{c(!0),d(null);try{let t=await f.jobLogs(e);n(t.data?.logs??[]),i(t.data?.count??0)}catch(e){d(e.message)}finally{c(!1)}},[e]);(0,x.useEffect)(()=>{C()},[C]);let w=async()=>{if(y)return;let t=p.trim();if(t){b(!0),d(null);try{await f.addJobLog(e,t,h),m(``),await C()}catch(e){d(e.message)}finally{b(!1)}}};return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Logs`,action:(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:r}),(0,S.jsx)(o,{size:`sm`,variant:`ghost`,disabled:a||y,onClick:C,children:`Refresh`}),(0,S.jsx)(o,{size:`sm`,variant:`danger`,disabled:y||t.length===0,onClick:async()=>{if(window.confirm(`Clear all logs for this job?`)){b(!0),d(null);try{await f.clearJobLogs(e),await C()}catch(e){d(e.message)}finally{b(!1)}}},children:`Clear logs`})]})}),l&&(0,S.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:l}),t.length===0?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,S.jsx)(`ol`,{className:`flex max-h-64 flex-col gap-1 overflow-auto rounded-lg bg-surface-2 p-3`,children:t.map((e,t)=>(0,S.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,S.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,S.jsx)(v,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>e.key===`Enter`&&w(),placeholder:`Add a log line…`,className:`h-8 flex-1 text-xs`}),(0,S.jsxs)(_,{value:h,onChange:e=>g(e.target.value),className:`h-8 w-24 text-xs`,children:[(0,S.jsx)(`option`,{value:`info`,children:`info`}),(0,S.jsx)(`option`,{value:`warn`,children:`warn`}),(0,S.jsx)(`option`,{value:`error`,children:`error`})]}),(0,S.jsx)(o,{size:`sm`,disabled:y||p.trim()===``,onClick:w,children:`Add`})]})]})}function N({timeline:e}){let t=e??[];return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Timeline`}),t.length===0?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,S.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,S.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(g,{status:e.state}),e.attempt!=null&&(0,S.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,S.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:d(e.timestamp)})]}),(e.worker||e.error)&&(0,S.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,S.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,S.jsx)(`div`,{className:`mt-0.5 text-xs text-danger/90`,children:e.error})]})]},t))})]})}function P(e){let t=e.timeline??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.state===`failed`&&n.error)return{message:n.error,attempt:n.attempt,timestamp:n.timestamp}}return null}function F(){let[e,n]=t(),[i,v]=(0,x.useState)(e.get(`id`)??``),[b,w]=(0,x.useState)(`id`),[T,E]=(0,x.useState)(null),[D,O]=(0,x.useState)({fetched:!1,value:void 0}),[F,R]=(0,x.useState)(!1),[z,B]=(0,x.useState)(!1),[V,H]=(0,x.useState)(null),[U,W]=(0,x.useState)(!1),G=(0,x.useRef)(0),K=async(e,t=b,r=!1)=>{let i=e.trim();if(!i)return;let a=++G.current;R(!0),B(!1),r||H(null);try{let e=(await(t===`custom`?f.jobByCustomId(i):f.job(i))).job;if(!e){if(a!==G.current)return;E(null),O({fetched:!1,value:void 0}),B(!0),n({},{replace:!0});return}let r=e.state===`completed`?await f.jobResult(e.id).catch(()=>null):null;if(a!==G.current)return;E(e),v(t===`custom`?e.id:i),n({id:e.id},{replace:!0}),O(r?{fetched:!0,value:r.result}:{fetched:!1,value:void 0})}catch(e){if(a!==G.current)return;e instanceof p&&(e.status===404||/not found/i.test(e.message))?(E(null),O({fetched:!1,value:void 0}),B(!0),n({},{replace:!0})):H({ok:!1,text:e.message})}finally{a===G.current&&R(!1)}},q=e.get(`id`);(0,x.useEffect)(()=>{q&&q!==T?.id&&K(q,`id`)},[q,T?.id]);let J=async(e,t,r)=>{if(!(r&&!window.confirm(r))&&T){W(!0),H(null);try{await t(),H({ok:!0,text:`${e} ✓`}),e===`Cancel`?(E(null),O({fetched:!1,value:void 0}),n({},{replace:!0})):await K(T.id,`id`,!0)}catch(e){H({ok:!1,text:e.message})}finally{W(!1)}}},Y=T?.state,X=T?P(T):null,Z=(T?.stacktrace?.length??0)>0,Q=(T?.childrenIds?.length??0)>0;return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(h,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:T&&(Q||T.parentId)?(0,S.jsx)(r,{to:`/flows?root=${encodeURIComponent(T.id)}`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`View flow`}):void 0}),(0,S.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,S.jsxs)(_,{value:b,onChange:e=>w(e.target.value),className:`w-40`,children:[(0,S.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,S.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,S.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,S.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,S.jsx)(`input`,{value:i,onChange:e=>v(e.target.value),onKeyDown:e=>e.key===`Enter`&&K(i),placeholder:b===`custom`?`custom / idempotency id — Enter to look up`:`job id (UUID) — Enter to look up`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 font-mono text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,S.jsx)(o,{variant:`accent`,disabled:F,onClick:()=>K(i),children:`Look up`})]}),V&&(0,S.jsx)(`div`,{className:V.ok?`mb-4 text-sm text-success`:`mb-4 text-sm text-danger`,children:V.text}),F&&!T?(0,S.jsx)(a,{label:`Loading job…`}):z?(0,S.jsx)(l,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`}):T?(0,S.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,S.jsxs)(u,{children:[(0,S.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:T.id}),(0,S.jsx)(y,{value:T.id})]}),(0,S.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:T.queue})]}),(0,S.jsx)(g,{status:Y??`waiting`})]}),(0,S.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,S.jsx)(I,{k:`Priority`,v:String(T.priority??0)}),(0,S.jsx)(I,{k:`Attempts`,v:`${T.attempts??0} / ${T.maxAttempts??`?`}`}),(0,S.jsx)(I,{k:`Progress`,v:`${T.progress??0}%`}),(0,S.jsx)(I,{k:`Created`,v:d(T.createdAt)}),(0,S.jsx)(I,{k:`Started`,v:d(T.startedAt??void 0)}),(0,S.jsx)(I,{k:`Completed`,v:d(T.completedAt??void 0)}),(0,S.jsx)(I,{k:`Duration`,v:m(T.startedAt&&T.completedAt?T.completedAt-T.startedAt:void 0)}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,S.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,S.jsx)(`span`,{className:`truncate font-mono`,children:T.customId??`—`}),T.customId&&(0,S.jsx)(y,{value:T.customId})]})]})]})]}),(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Data`}),(0,S.jsx)(L,{value:T.data})]}),(0,S.jsx)(j,{data:T.data,busy:U,onSave:e=>J(`Data`,()=>f.updateJobData(T.id,e))}),Y===`completed`&&(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Result`}),D.fetched&&D.value!==void 0&&D.value!==null?(0,S.jsx)(L,{value:D.value}):(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]}),(X||Z)&&(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Error`}),X&&(0,S.jsxs)(`div`,{className:`mb-3`,children:[(0,S.jsx)(`p`,{className:`text-sm text-danger`,children:X.message}),(0,S.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[X.attempt==null?``:`Attempt ${X.attempt} · `,d(X.timestamp)]})]}),Z&&(0,S.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-surface-2 p-3 font-mono text-xs text-danger/90`,children:T.stacktrace?.join(`
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{d as t,m as n,r,t as i}from"./react-vendor-CHIHtdAC.js";import{C as a,D as o,E as s,J as c,S as l,T as u,a as d,g as f,m as p,o as m,v as h,y as g}from"./index-C9fPU4bV.js";import{a as _,n as v}from"./form-PtDLk33Z.js";import{t as y}from"./CopyButton-XT7ykzf5.js";import{t as b}from"./jobActions-CuOdMglt.js";var x=e(n(),1),S=i();function C({job:e,busy:t,act:n}){let r=b(e.state),i=r.cancel||r.discard||r.promote||r.retryActive||r.retryDlq||r.requeueCompleted||r.setPriority||r.setDelay||r.fail||r.moveToDelayed;return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Actions`}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>f.promoteJob(e.id)),children:`Promote (run now)`}),r.retryActive&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>f.retryJob(e.id)),children:`Retry (move to waiting)`}),r.retryDlq&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>f.retryDlq(e.queue??``,e.id)),children:`Retry from DLQ`}),r.requeueCompleted&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Requeue`,()=>f.retryCompleted(e.queue??``,e.id)),children:`Requeue`}),r.moveToDelayed&&(0,S.jsx)(w,{label:`Move to delayed (ms)`,cta:`To delayed`,disabled:t,onSubmit:t=>n(`Move to delayed`,()=>f.moveToDelayed(e.id,t))}),r.discard&&(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Discard`,()=>f.discardJob(e.id)),children:`Discard (to DLQ)`}),r.setPriority&&(0,S.jsx)(w,{label:`Set priority`,cta:`Set`,disabled:t,onSubmit:t=>n(`Priority`,()=>f.changePriority(e.id,t))}),r.setDelay&&(0,S.jsx)(w,{label:`Set delay (ms)`,cta:`Delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>f.changeDelay(e.id,t))}),r.fail&&(0,S.jsx)(T,{label:`Fail reason (optional)`,cta:`Fail`,variant:`warning`,disabled:t,onSubmit:t=>n(`Fail`,()=>f.failJob(e.id,t||void 0),`Force-fail this active job?`)}),r.cancel&&(0,S.jsx)(o,{variant:`danger`,size:`sm`,disabled:t,onClick:()=>n(`Cancel`,()=>f.cancelJob(e.id),`Cancel and remove this job?`),children:`Cancel (delete)`}),!i&&(0,S.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function w({label:e,cta:t,disabled:n,onSubmit:r}){let[i,a]=(0,x.useState)(``);return(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(v,{type:`number`,value:i,onChange:e=>a(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,S.jsx)(o,{size:`sm`,disabled:n||i.trim()===``,onClick:()=>r(Number(i)),children:t})]})}function T({label:e,cta:t,disabled:n,variant:r=`default`,onSubmit:i}){let[a,s]=(0,x.useState)(``);return(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(v,{value:a,onChange:e=>s(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,S.jsx)(o,{size:`sm`,variant:r,disabled:n,onClick:()=>{i(a),s(``)},children:t})]})}var E=36e5,D=10;function O(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??E,a=r?.delay??e.backoff??1e3,o=[];for(let e=n;e<t&&o.length<D;e++){let t=r?.type===`fixed`?a:a*2**e;o.push({attempt:e+1,delayMs:Math.min(t,i)})}return o}function k({job:e}){let t=e.maxAttempts??0,n=e.attempts??0;if(t<=1)return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Backoff`}),(0,S.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Backoff schedule`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Max attempts reached — no further retries will be scheduled.`})]});let r=e.backoffConfig,i=r?r.type:`exponential (default)`,a=t-n,o=O(e);return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Backoff schedule`,action:(0,S.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${m(r.maxDelay)}`:``]})}),(0,S.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map(e=>(0,S.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,S.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,S.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,m(e.delayMs)]})]},e.attempt))}),a>D&&(0,S.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,D,` of `,a,` remaining attempts.`]}),(0,S.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Approximate — the server applies ±`,r?.type===`fixed`?`20`:`50`,`% jitter at retry time, capped at `,m(r?.maxDelay??E),`.`]})]})}function A({jobId:e}){let[t,n]=(0,x.useState)(!1),[r,i]=(0,x.useState)(!1),[a,c]=(0,x.useState)(!1),[l,d]=(0,x.useState)(void 0),[p,m]=(0,x.useState)(null),h=async()=>{c(!0),m(null);try{d((await f.jobChildren(e)).data?.values),i(!0)}catch(e){m(e.message)}finally{c(!1)}},g=()=>{let e=!t;n(e),e&&!r&&!a&&h()},_=l&&typeof l==`object`?Array.isArray(l)?l.length:Object.keys(l).length:0;return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Child values`,action:(0,S.jsx)(o,{size:`sm`,variant:`ghost`,onClick:g,children:t?`Hide`:`Show`})}),t?a?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):p?(0,S.jsx)(`p`,{className:`text-xs text-danger`,children:p}):_===0?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,S.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(l,null,2)}):(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Resolved return values from this flow job's children.`})]})}function j({data:e,busy:t,onSave:n}){let[r,i]=(0,x.useState)(()=>JSON.stringify(e??null,null,2)),[a,c]=(0,x.useState)(null),l=(0,x.useRef)(r);return(0,x.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,i(t),c(null))},[e]),(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Edit data`,action:(0,S.jsx)(o,{size:`sm`,disabled:t,onClick:()=>{let e;try{e=JSON.parse(r)}catch(e){c(`Invalid JSON: ${e.message}`);return}c(null),n(e)},children:`Save data`})}),(0,S.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),spellCheck:!1,rows:8,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),a&&(0,S.jsx)(`p`,{className:`mt-2 text-xs text-danger`,children:a})]})}function M({jobId:e}){let[t,n]=(0,x.useState)([]),[r,i]=(0,x.useState)(0),[a,c]=(0,x.useState)(!1),[l,d]=(0,x.useState)(null),[p,m]=(0,x.useState)(``),[h,g]=(0,x.useState)(`info`),[y,b]=(0,x.useState)(!1),C=(0,x.useCallback)(async()=>{c(!0),d(null);try{let t=await f.jobLogs(e);n(t.data?.logs??[]),i(t.data?.count??0)}catch(e){d(e.message)}finally{c(!1)}},[e]);(0,x.useEffect)(()=>{C()},[C]);let w=async()=>{if(y)return;let t=p.trim();if(t){b(!0),d(null);try{await f.addJobLog(e,t,h),m(``),await C()}catch(e){d(e.message)}finally{b(!1)}}};return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Logs`,action:(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:r}),(0,S.jsx)(o,{size:`sm`,variant:`ghost`,disabled:a||y,onClick:C,children:`Refresh`}),(0,S.jsx)(o,{size:`sm`,variant:`danger`,disabled:y||t.length===0,onClick:async()=>{if(window.confirm(`Clear all logs for this job?`)){b(!0),d(null);try{await f.clearJobLogs(e),await C()}catch(e){d(e.message)}finally{b(!1)}}},children:`Clear logs`})]})}),l&&(0,S.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:l}),t.length===0?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,S.jsx)(`ol`,{className:`flex max-h-64 flex-col gap-1 overflow-auto rounded-lg bg-surface-2 p-3`,children:t.map((e,t)=>(0,S.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,S.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,S.jsx)(v,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>e.key===`Enter`&&w(),placeholder:`Add a log line…`,className:`h-8 flex-1 text-xs`}),(0,S.jsxs)(_,{value:h,onChange:e=>g(e.target.value),className:`h-8 w-24 text-xs`,children:[(0,S.jsx)(`option`,{value:`info`,children:`info`}),(0,S.jsx)(`option`,{value:`warn`,children:`warn`}),(0,S.jsx)(`option`,{value:`error`,children:`error`})]}),(0,S.jsx)(o,{size:`sm`,disabled:y||p.trim()===``,onClick:w,children:`Add`})]})]})}function N({timeline:e}){let t=e??[];return(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Timeline`}),t.length===0?(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,S.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,S.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(g,{status:e.state}),e.attempt!=null&&(0,S.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,S.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:d(e.timestamp)})]}),(e.worker||e.error)&&(0,S.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,S.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,S.jsx)(`div`,{className:`mt-0.5 text-xs text-danger/90`,children:e.error})]})]},t))})]})}function P(e){let t=e.timeline??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.state===`failed`&&n.error)return{message:n.error,attempt:n.attempt,timestamp:n.timestamp}}return null}function F(){let[e,n]=t(),[i,v]=(0,x.useState)(e.get(`id`)??``),[b,w]=(0,x.useState)(`id`),[T,E]=(0,x.useState)(null),[D,O]=(0,x.useState)({fetched:!1,value:void 0}),[F,R]=(0,x.useState)(!1),[z,B]=(0,x.useState)(!1),[V,H]=(0,x.useState)(null),[U,W]=(0,x.useState)(!1),G=(0,x.useRef)(0),K=async(e,t=b,r=!1)=>{let i=e.trim();if(!i)return;let a=++G.current;R(!0),B(!1),r||H(null);try{let e=(await(t===`custom`?f.jobByCustomId(i):f.job(i))).job;if(!e){if(a!==G.current)return;E(null),O({fetched:!1,value:void 0}),B(!0),n({},{replace:!0});return}let r=e.state===`completed`?await f.jobResult(e.id).catch(()=>null):null;if(a!==G.current)return;E(e),v(t===`custom`?e.id:i),n({id:e.id},{replace:!0}),O(r?{fetched:!0,value:r.result}:{fetched:!1,value:void 0})}catch(e){if(a!==G.current)return;e instanceof p&&(e.status===404||/not found/i.test(e.message))?(E(null),O({fetched:!1,value:void 0}),B(!0),n({},{replace:!0})):H({ok:!1,text:e.message})}finally{a===G.current&&R(!1)}},q=e.get(`id`);(0,x.useEffect)(()=>{q&&q!==T?.id&&K(q,`id`)},[q,T?.id]);let J=async(e,t,r)=>{if(!(r&&!window.confirm(r))&&T){W(!0),H(null);try{await t(),H({ok:!0,text:`${e} ✓`}),e===`Cancel`?(E(null),O({fetched:!1,value:void 0}),n({},{replace:!0})):await K(T.id,`id`,!0)}catch(e){H({ok:!1,text:e.message})}finally{W(!1)}}},Y=T?.state,X=T?P(T):null,Z=(T?.stacktrace?.length??0)>0,Q=(T?.childrenIds?.length??0)>0;return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(h,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:T&&(Q||T.parentId)?(0,S.jsx)(r,{to:`/flows?root=${encodeURIComponent(T.id)}`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`View flow`}):void 0}),(0,S.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,S.jsxs)(_,{value:b,onChange:e=>w(e.target.value),className:`w-40`,children:[(0,S.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,S.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,S.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,S.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,S.jsx)(`input`,{value:i,onChange:e=>v(e.target.value),onKeyDown:e=>e.key===`Enter`&&K(i),placeholder:b===`custom`?`custom / idempotency id — Enter to look up`:`job id (UUID) — Enter to look up`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 font-mono text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,S.jsx)(o,{variant:`accent`,disabled:F,onClick:()=>K(i),children:`Look up`})]}),V&&(0,S.jsx)(`div`,{className:V.ok?`mb-4 text-sm text-success`:`mb-4 text-sm text-danger`,children:V.text}),F&&!T?(0,S.jsx)(a,{label:`Loading job…`}):z?(0,S.jsx)(l,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`}):T?(0,S.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,S.jsxs)(u,{children:[(0,S.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:T.id}),(0,S.jsx)(y,{value:T.id})]}),(0,S.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:T.queue})]}),(0,S.jsx)(g,{status:Y??`waiting`})]}),(0,S.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,S.jsx)(I,{k:`Priority`,v:String(T.priority??0)}),(0,S.jsx)(I,{k:`Attempts`,v:`${T.attempts??0} / ${T.maxAttempts??`?`}`}),(0,S.jsx)(I,{k:`Progress`,v:`${T.progress??0}%`}),(0,S.jsx)(I,{k:`Created`,v:d(T.createdAt)}),(0,S.jsx)(I,{k:`Started`,v:d(T.startedAt??void 0)}),(0,S.jsx)(I,{k:`Completed`,v:d(T.completedAt??void 0)}),(0,S.jsx)(I,{k:`Duration`,v:m(T.startedAt&&T.completedAt?T.completedAt-T.startedAt:void 0)}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,S.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,S.jsx)(`span`,{className:`truncate font-mono`,children:T.customId??`—`}),T.customId&&(0,S.jsx)(y,{value:T.customId})]})]})]})]}),(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Data`}),(0,S.jsx)(L,{value:T.data})]}),(0,S.jsx)(j,{data:T.data,busy:U,onSave:e=>J(`Data`,()=>f.updateJobData(T.id,e))}),Y===`completed`&&(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Result`}),D.fetched&&D.value!==void 0&&D.value!==null?(0,S.jsx)(L,{value:D.value}):(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]}),(X||Z)&&(0,S.jsxs)(u,{children:[(0,S.jsx)(s,{title:`Error`}),X&&(0,S.jsxs)(`div`,{className:`mb-3`,children:[(0,S.jsx)(`p`,{className:`text-sm text-danger`,children:X.message}),(0,S.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[X.attempt==null?``:`Attempt ${X.attempt} · `,d(X.timestamp)]})]}),Z&&(0,S.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-surface-2 p-3 font-mono text-xs text-danger/90`,children:T.stacktrace?.join(`
|
|
2
2
|
`)})]}),(0,S.jsx)(M,{jobId:T.id},`logs-${T.id}`),Q&&(0,S.jsx)(A,{jobId:T.id},`children-${T.id}`),(0,S.jsx)(N,{timeline:T.timeline}),(0,S.jsx)(k,{job:T})]}),(0,S.jsx)(C,{job:T,busy:U,act:J})]}):(0,S.jsx)(l,{title:`No job loaded`,hint:`Enter a job ID above to inspect it.`})]})}function I({k:e,v:t}){return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,S.jsx)(`dd`,{className:`text-fg`,children:t})]})}function L({value:e}){return(0,S.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(e??null,null,2)})}export{F as JobInspector};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{d as t,m as n,t as r}from"./react-vendor-CHIHtdAC.js";import{C as i,J as a,M as o,O as s,Y as c,_ as l,c as u,f as d,j as f,l as p,n as m,o as h,u as g,v as _,w as v,y}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{d as t,m as n,t as r}from"./react-vendor-CHIHtdAC.js";import{C as i,J as a,M as o,O as s,Y as c,_ as l,c as u,f as d,j as f,l as p,n as m,o as h,u as g,v as _,w as v,y}from"./index-C9fPU4bV.js";import{a as b,i as x}from"./form-PtDLk33Z.js";var S=e(n(),1),C=r(),w=`__all__`,T=[`all`,`waiting`,`active`,`completed`,`failed`];function E(){let[e]=t(),[n,r]=(0,S.useState)(e.get(`queue`)??w),[E,D]=(0,S.useState)(`all`),[O,k]=(0,S.useState)(``),{data:A}=f(()=>o.queues(500),[]),{data:j}=f(()=>o.overview(),[]),{data:M,error:N,loading:P,refetch:F}=f((0,S.useCallback)(async()=>{let e=n===w?(A?.queues??[]).map(e=>e.name).slice(0,25):[n],t=E===`all`?void 0:[E];return(await Promise.all(e.map(e=>o.jobsList(e,{states:t,limit:40}).then(t=>(t.jobs??[]).map(t=>({...t,queue:t.queue??e}))).catch(()=>[])))).flat().sort((e,t)=>(t.createdAt??0)-(e.createdAt??0))},[n,E,A]),[n,E]),I=(0,S.useMemo)(()=>{let e=M??[],t=O.trim().toLowerCase();return(t?e.filter(e=>e.id.toLowerCase().includes(t)||(e.name??``).toLowerCase().includes(t)):e).slice(0,100)},[M,O]),L=j?.stats,R=L?m(L.totalCompleted,L.totalFailed)??0:0,z=async e=>{if(window.confirm(`Cancel job ${e}?`))try{await o.cancelJob(e),F()}catch{}};return(0,C.jsxs)(`div`,{children:[N&&(0,C.jsx)(v,{onRetry:F}),(0,C.jsx)(_,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!0}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,C.jsx)(l,{label:`Total`,value:u((L?.totalCompleted??0)+(L?.totalFailed??0)+(L?.waiting??0)+(L?.active??0)),compact:!0}),(0,C.jsx)(l,{label:`Waiting`,value:u(L?.waiting),tone:`amber`,compact:!0}),(0,C.jsx)(l,{label:`Active`,value:u(L?.active),tone:`blue`,compact:!0}),(0,C.jsx)(l,{label:`Completed`,value:u(L?.totalCompleted),tone:`green`,compact:!0}),(0,C.jsx)(l,{label:`Failed`,value:u(L?.totalFailed),tone:L?.totalFailed?`red`:`default`,compact:!0}),(0,C.jsx)(l,{label:`Error Rate`,value:p(R),tone:R>.05?`red`:`green`,compact:!0})]}),(0,C.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,C.jsx)(`div`,{className:`w-48`,children:(0,C.jsxs)(b,{value:n,onChange:e=>r(e.target.value),children:[(0,C.jsx)(`option`,{value:w,children:`All Queues`}),(A?.queues??[]).map(e=>(0,C.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,C.jsx)(x,{options:T,value:E,onChange:D}),(0,C.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,C.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,C.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),placeholder:`Search by ID or name…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),P&&!M&&!N?(0,C.jsx)(i,{label:`Loading jobs…`}):(0,C.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,C.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,C.jsx)(`tbody`,{children:I.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:`No jobs found.`})}):I.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:e.id}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name||`unknown`}),(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(y,{status:String(e.state??e.status??`waiting`)})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:g(e.createdAt)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:h(d(e.processedOn,e.finishedOn))}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,C.jsx)(s,{"aria-label":`Cancel job`,onClick:()=>z(e.id),children:(0,C.jsx)(c,{className:`size-3.5`})})})]},`${e.queue}:${e.id}`))})]})})]})}export{E as Jobs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{d as n,m as r,r as i,t as a}from"./react-vendor-CHIHtdAC.js";import{B as o,C as ee,D as s,I as te,J as c,K as l,O as u,W as ne,Y as d,_ as f,a as re,c as ie,g as p,j as m,l as ae,n as h,o as oe,v as g,w as se,y as ce}from"./index-
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{d as n,m as r,r as i,t as a}from"./react-vendor-CHIHtdAC.js";import{B as o,C as ee,D as s,I as te,J as c,K as l,O as u,W as ne,Y as d,_ as f,a as re,c as ie,g as p,j as m,l as ae,n as h,o as oe,v as g,w as se,y as ce}from"./index-C9fPU4bV.js";import{a as le,i as ue}from"./form-PtDLk33Z.js";import{t as de}from"./Pagination-Cd6lHj2E.js";import{t as _}from"./jobActions-CuOdMglt.js";var v=e(r(),1),y=a(),b=[`all`,`waiting`,`active`,`completed`,`failed`],x=25;function S(e=0){return e>=10?{t:`HIGH`,c:`text-warning`}:e>=1?{t:`MEDIUM`,c:`text-blue-400`}:{t:`LOW`,c:`text-faint`}}function C(e){let t=_(e.state);return t.retryActive?p.retryJob(e.id):t.retryDlq?p.retryDlq(e.queue??``,e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not retryable`))}function w(){let[e]=n(),[r,a]=(0,v.useState)(e.get(`queue`)??``),[w,fe]=(0,v.useState)(`all`),[T,pe]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),[O,k]=(0,v.useState)(new Set),[me,A]=(0,v.useState)(new Set),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(null),{data:F}=m(()=>p.queuesSummary(),[],{intervalMs:3e4}),{data:I}=m(()=>p.overview(),[],{intervalMs:1e4});(0,v.useEffect)(()=>{!r&&F?.length&&a(F[0].name)},[F,r]);let L=`${r}|${w}|${E}`,{data:R,error:z,loading:B,refetch:V}=m((0,v.useCallback)(async()=>{if(!r)return{view:L,jobs:[]};let e=w===`all`?void 0:[w];return{view:L,jobs:((await p.jobsList(r,e,x,E*x)).jobs??[]).map(e=>({...e,queue:e.queue??r}))}},[r,w,E,L]),[r,w,E]),H=R&&R.view===L?R.jobs:null,he=(H?.length??0)===x,U=(0,v.useMemo)(()=>{let e=T.trim().toLowerCase();return e?(H??[]).filter(t=>t.id.toLowerCase().includes(e)):H??[]},[H,T]),W=I?.stats,G=(0,v.useMemo)(()=>(F??[]).reduce((e,t)=>e+(t.counts?.failed??0),0),[F]),K=W?h(W.completed,G):null,q=e=>W?ie(e):`—`,J=()=>D(0);(0,v.useEffect)(()=>{k(new Set)},[r,w,E]);let ge=e=>k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Y=U.length>0&&U.every(e=>O.has(e.id)),_e=()=>k(()=>Y?new Set:new Set(U.map(e=>e.id))),X=async(e,t,n,r)=>{if(!(r&&!window.confirm(r))){A(t=>new Set(t).add(e.id)),P(null);try{await n(),P({ok:!0,text:`${t} ✓`})}catch(e){P({ok:!1,text:`${t} failed: ${e.message}`})}finally{A(t=>{let n=new Set(t);return n.delete(e.id),n}),V()}}},Z=async(e,t,n)=>{let r=U.filter(e=>O.has(e.id));if(r.length===0||n&&!window.confirm(n(r.length)))return;M(!0),P(null);let i=await Promise.allSettled(r.map(t)),a=i.filter(e=>e.status===`fulfilled`).length,o=i.length-a;P({ok:o===0,text:`${e}: ${a} succeeded${o?`, ${o} not eligible / failed`:``}`}),k(new Set),M(!1),V()},Q=U.filter(e=>O.has(e.id)),$={retry:Q.some(e=>{let t=_(e.state);return t.retryActive||t.retryDlq}),promote:Q.some(e=>_(e.state).promote),requeue:Q.some(e=>_(e.state).requeueCompleted),fail:Q.some(e=>_(e.state).fail),cancel:Q.some(e=>_(e.state).cancel)};return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(g,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!0}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(f,{label:`Total`,value:q((W?.completed??0)+G+(W?.waiting??0)+(W?.active??0)+(W?.delayed??0)),hint:`all queues`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:q(W?.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:q(W?.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:q(W?.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:q(G),tone:G?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Error Rate`,value:K==null?`—`:ae(K),tone:K==null?`default`:K>.05?`red`:`green`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsx)(le,{value:r,"aria-label":`Queue`,onChange:e=>{a(e.target.value),J()},children:(F??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,y.jsx)(ue,{options:b,value:w,onChange:e=>{fe(e),J()}}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{value:T,onChange:e=>pe(e.target.value),placeholder:`Filter this page by ID…`,"aria-label":`Filter by job ID`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),O.size>0&&(0,y.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,y.jsxs)(`span`,{className:`mr-1 text-muted`,children:[O.size,` selected`]}),$.retry&&(0,y.jsx)(s,{size:`sm`,disabled:j,onClick:()=>Z(`Retry`,C),children:`Retry selected`}),$.promote&&(0,y.jsx)(s,{size:`sm`,disabled:j,onClick:()=>Z(`Promote`,e=>_(e.state).promote?p.promoteJob(e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not delayed`))),children:`Promote selected`}),$.requeue&&(0,y.jsx)(s,{size:`sm`,disabled:j,onClick:()=>Z(`Requeue`,e=>_(e.state).requeueCompleted?p.retryCompleted(e.queue??``,e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not completed`))),children:`Requeue selected`}),$.fail&&(0,y.jsx)(s,{variant:`warning`,size:`sm`,disabled:j,onClick:()=>Z(`Fail`,e=>_(e.state).fail?p.failJob(e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not active`)),e=>`Force-fail ${e} job(s)?`),children:`Fail selected`}),$.cancel&&(0,y.jsx)(s,{variant:`danger`,size:`sm`,disabled:j,onClick:()=>Z(`Cancel`,e=>_(e.state).cancel?p.cancelJob(e.id):Promise.reject(Error(`"${e.state??`unknown`}" cannot be cancelled`)),e=>`Cancel ${e} job(s)? This cannot be undone.`),children:`Cancel selected`}),!$.retry&&!$.promote&&!$.requeue&&!$.fail&&!$.cancel&&(0,y.jsx)(`span`,{className:`text-xs text-faint`,children:`No actions apply to the selected job states.`})]}),N&&(0,y.jsx)(`div`,{className:t(`mb-3 text-sm`,N.ok?`text-success`:`text-danger`),children:N.text}),z&&(0,y.jsx)(se,{onRetry:V}),B&&!H&&!z?(0,y.jsx)(ee,{label:`Loading jobs…`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`w-10 px-5 py-3`,children:(0,y.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:_e,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Priority`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,y.jsx)(`th`,{className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,y.jsx)(`tbody`,{children:U.length===0?(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:T.trim()?`No jobs on this page match your ID filter.`:r?`No jobs found.`:`Select a queue.`})}):U.map(e=>{let n=S(e.priority),r=_(e.state),a=me.has(e.id);return(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`input`,{type:`checkbox`,checked:O.has(e.id),onChange:()=>ge(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,y.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(ce,{status:String(e.state??`waiting`)})}),(0,y.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.c),children:n.t}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:re(e.createdAt)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:oe(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,y.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,children:(0,y.jsx)(u,{"aria-label":`Inspect job`,children:(0,y.jsx)(o,{className:`size-3.5`})})}),r.promote&&(0,y.jsx)(u,{"aria-label":`Promote job`,disabled:a,onClick:()=>X(e,`Promote`,()=>p.promoteJob(e.id)),children:(0,y.jsx)(ne,{className:`size-3.5`})}),(r.retryActive||r.retryDlq)&&(0,y.jsx)(u,{"aria-label":`Retry job`,disabled:a,onClick:()=>X(e,`Retry`,()=>C(e)),children:(0,y.jsx)(l,{className:`size-3.5`})}),r.requeueCompleted&&(0,y.jsx)(u,{"aria-label":`Requeue job`,disabled:a,onClick:()=>X(e,`Requeue`,()=>p.retryCompleted(e.queue??``,e.id)),children:(0,y.jsx)(l,{className:`size-3.5`})}),r.fail&&(0,y.jsx)(u,{"aria-label":`Fail job`,disabled:a,onClick:()=>X(e,`Fail`,()=>p.failJob(e.id),`Force-fail this active job?`),children:(0,y.jsx)(te,{className:`size-3.5`})}),r.cancel&&(0,y.jsx)(u,{"aria-label":`Cancel job`,disabled:a,onClick:()=>X(e,`Cancel`,()=>p.cancelJob(e.id),`Cancel this job?`),children:(0,y.jsx)(d,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,y.jsx)(de,{page:E,pageSize:x,hasNext:he,onPageChange:D,label:`jobs`})]})]})}export{w as JobsPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{H as r,J as i,M as a,S as o,_ as s,c,j as l,t as u,u as d,v as f,w as p,y as m}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{H as r,J as i,M as a,S as o,_ as s,c,j as l,t as u,u as d,v as f,w as p,y as m}from"./index-C9fPU4bV.js";import{a as h,i as g}from"./form-PtDLk33Z.js";import{t as _}from"./Pagination-Cd6lHj2E.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;function C(){let[e,t]=(0,v.useState)(b),[n,C]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O}=l(()=>a.queues(500),[],{intervalMs:3e4}),{events:k,counters:A,throughput:j,connected:M}=u(e===b?void 0:e),N=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return k.filter(t=>n!==`all`&&t.status!==n?!1:e?(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e):!0)},[k,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let P=Math.max(1,Math.ceil(N.length/S)),F=Math.min(E,P-1);return(0,y.jsxs)(`div`,{children:[!M&&k.length===0&&(0,y.jsx)(p,{}),(0,y.jsx)(f,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:M}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(s,{label:`Total Events`,value:c(A.total),compact:!0}),(0,y.jsx)(s,{label:`Completed`,value:c(A.completed),tone:`green`,compact:!0}),(0,y.jsx)(s,{label:`Failed`,value:c(A.failed),tone:A.failed?`red`:`default`,compact:!0}),(0,y.jsx)(s,{label:`Waiting`,value:c(A.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(s,{label:`Active`,value:c(A.active),tone:`blue`,compact:!0}),(0,y.jsx)(s,{label:`Throughput`,value:`${j.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(h,{value:e,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(g,{options:x,value:n,onChange:C}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(i,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),N.length===0?(0,y.jsx)(o,{icon:(0,y.jsx)(r,{}),title:M?`Waiting for activity…`:`Connecting to the event stream…`,hint:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job Name`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:N.slice(F*S,F*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(m,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name||`unknown`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:d(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(_,{page:F,pageSize:S,total:N.length,onPageChange:D,label:`events`})]})}export{C as Logs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{J as r,_ as i,c as a,g as o,j as s,t as c,u as l,v as u,w as d,y as f}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{J as r,_ as i,c as a,g as o,j as s,t as c,u as l,v as u,w as d,y as f}from"./index-C9fPU4bV.js";import{a as p,i as m}from"./form-PtDLk33Z.js";import{t as h}from"./Pagination-Cd6lHj2E.js";var g=e(t(),1),_=n(),v=`__all__`,y=[`all`,`waiting`,`active`,`completed`,`failed`],b=10;function x(){let[e,t]=(0,g.useState)(v),[n,x]=(0,g.useState)(`all`),[S,C]=(0,g.useState)(``),[w,T]=(0,g.useState)(0),{data:E,error:D,refetch:O}=s(()=>o.queues(),[],{intervalMs:3e4}),{events:k,counters:A,throughput:j,connected:M}=c(e===v?void 0:e),N=(0,g.useMemo)(()=>{let e=S.trim().toLowerCase();return k.filter(t=>n!==`all`&&t.status!==n?!1:e?(t.jobId??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e):!0)},[k,n,S]);(0,g.useEffect)(()=>T(0),[e,n,S]);let P=w*b,F=N.slice(P,P+b);return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:M}),D&&(0,_.jsx)(d,{onRetry:O}),(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(i,{label:`Total Events`,value:a(A.total),compact:!0}),(0,_.jsx)(i,{label:`Completed`,value:a(A.completed),tone:`green`,compact:!0}),(0,_.jsx)(i,{label:`Failed`,value:a(A.failed),tone:A.failed?`red`:`default`,compact:!0}),(0,_.jsx)(i,{label:`Waiting`,value:a(A.waiting),tone:`amber`,compact:!0}),(0,_.jsx)(i,{label:`Active`,value:a(A.active),tone:`blue`,compact:!0}),(0,_.jsx)(i,{label:`Throughput`,value:`${j.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,_.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,_.jsx)(`div`,{className:`w-48`,children:(0,_.jsxs)(p,{"aria-label":`Filter by queue`,value:e,onChange:e=>t(e.target.value),children:[(0,_.jsx)(`option`,{value:v,children:`All Queues`}),(E?.queues??[]).map(e=>(0,_.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,_.jsx)(m,{options:y,value:n,onChange:x}),(0,_.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,_.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,_.jsx)(`input`,{"aria-label":`Search by job ID or queue`,value:S,onChange:e=>C(e.target.value),placeholder:`Search by job ID or queue…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,_.jsx)(`tbody`,{children:F.length===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:M?k.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):F.map(e=>(0,_.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsx)(f,{status:e.status})}),(0,_.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:e.event}),(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:l(e.timestamp)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,_.jsx)(h,{page:w,pageSize:b,total:N.length,onPageChange:T,label:`events`})]})}export{x as LogsPro};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-CHIHtdAC.js";import{E as t,T as n,_ as r,v as i}from"./index-
|
|
1
|
+
import{t as e}from"./react-vendor-CHIHtdAC.js";import{E as t,T as n,_ as r,v as i}from"./index-C9fPU4bV.js";import{t as a}from"./CopyButton-XT7ykzf5.js";var o=e(),s=`{
|
|
2
2
|
"mcpServers": {
|
|
3
3
|
"bunqueue": {
|
|
4
4
|
"command": "bunx",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-CHIHtdAC.js";import{C as t,E as n,M as r,T as i,_ as a,c as o,j as s,r as c,v as l,w as u}from"./index-
|
|
1
|
+
import{t as e}from"./react-vendor-CHIHtdAC.js";import{C as t,E as n,M as r,T as i,_ as a,c as o,j as s,r as c,v as l,w as u}from"./index-C9fPU4bV.js";var d=e(),f={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function p(){let{data:e,error:p,loading:g,refetch:_}=s(()=>r.overview(),[]);if(g&&!e&&!p)return(0,d.jsx)(t,{label:`Loading metrics…`});let{stats:v,throughput:y,latency:b,memory:x,collections:S}=e??f,C={};for(let[e,t]of Object.entries(b.percentiles??{}))t&&typeof t==`object`&&(C[`${e} p50`]=t.p50,C[`${e} p95`]=t.p95,C[`${e} p99`]=t.p99);return(0,d.jsxs)(`div`,{children:[p&&(0,d.jsx)(u,{onRetry:_}),(0,d.jsx)(l,{title:`Metrics`,description:`Throughput, latency, and resource internals.`,live:!0}),(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,d.jsx)(a,{label:`Pushed /s`,value:y.pushPerSec.toFixed(1),compact:!0}),(0,d.jsx)(a,{label:`Pulled /s`,value:y.pullPerSec.toFixed(1),tone:`blue`,compact:!0}),(0,d.jsx)(a,{label:`Completed /s`,value:y.completePerSec.toFixed(1),tone:`green`,compact:!0}),(0,d.jsx)(a,{label:`Failed /s`,value:y.failPerSec.toFixed(1),tone:`red`,compact:!0})]}),(0,d.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,d.jsxs)(i,{children:[(0,d.jsx)(n,{title:`Totals`}),(0,d.jsx)(m,{rows:[[`Pushed`,o(v.totalPushed)],[`Pulled`,o(v.totalPulled)],[`Completed`,o(v.totalCompleted)],[`Failed`,o(v.totalFailed)]]})]}),(0,d.jsxs)(i,{children:[(0,d.jsx)(n,{title:`Memory`}),(0,d.jsx)(m,{rows:[[`Heap Used`,c(x.heapUsed*1024*1024)],[`Heap Total`,c(x.heapTotal*1024*1024)],[`RSS`,c(x.rss*1024*1024)]]})]}),(0,d.jsxs)(i,{children:[(0,d.jsx)(n,{title:`Latency — percentiles (ms)`}),(0,d.jsx)(h,{record:C,suffix:`ms`})]}),(0,d.jsxs)(i,{children:[(0,d.jsx)(n,{title:`Latency — averages (ms)`}),(0,d.jsx)(h,{record:b.averages,suffix:`ms`})]})]}),(0,d.jsx)(`div`,{className:`mt-6`,children:(0,d.jsxs)(i,{children:[(0,d.jsx)(n,{title:`In-memory collections`}),(0,d.jsx)(h,{record:S})]})})]})}function m({rows:e}){return(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:e.map(([e,t])=>(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,d.jsx)(`div`,{className:`mt-1 text-xl font-semibold tnum text-fg`,children:t})]},e))})}function h({record:e,suffix:t}){let n=Object.entries(e??{});return n.length===0?(0,d.jsx)(`p`,{className:`py-4 text-sm text-faint`,children:`No data.`}):(0,d.jsx)(`dl`,{className:`divide-y divide-line`,children:n.map(([e,n])=>(0,d.jsxs)(`div`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,d.jsx)(`dt`,{className:`font-mono text-xs text-muted`,children:e}),(0,d.jsxs)(`dd`,{className:`tnum font-medium text-fg`,children:[typeof n==`number`?o(Math.round(n*100)/100):String(n),t&&(0,d.jsx)(`span`,{className:`ml-1 text-xs text-faint`,children:t})]})]},e))})}export{p as Metrics};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{m as n,t as r}from"./react-vendor-CHIHtdAC.js";import{A as i,C as a,E as o,T as s,_ as c,c as l,d as u,g as d,i as f,j as p,l as m,n as h,v as g,w as _}from"./index-D6Nj5ksZ.js";import{t as v}from"./Pagination-DdeRIp2i.js";import{t as y}from"./AreaChart-DzUXW8u3.js";var b=e(n(),1);function x(e=60){let[t,n]=(0,b.useState)({push:[],complete:[],fail:[],depth:[]}),[r,a]=(0,b.useState)(null),o=(0,b.useRef)(!0),s=(0,b.useRef)(!1);return(0,b.useEffect)(()=>{o.current=!0;let t=i(()=>typeof document<`u`&&document.hidden),r=async()=>{if(!s.current&&t()){s.current=!0;try{let t=await d.overview();if(!o.current)return;a(t);let r=(t.stats.waiting??0)+(t.stats.active??0)+(t.stats.delayed??0);n(n=>({push:[...n.push,t.throughput.pushPerSec].slice(-e),complete:[...n.complete,t.throughput.completePerSec].slice(-e),fail:[...n.fail,t.throughput.failPerSec].slice(-e),depth:[...n.depth,r].slice(-e)}))}catch{}finally{s.current=!1}}};r();let c=setInterval(r,1e3);return()=>{o.current=!1,clearInterval(c)}},[e]),{...t,latest:r}}function S(e){if(e.length<2)return{slope:0,label:`steady`,draining:!1};let t=e.length,n=(t-1)/2,r=e.reduce((e,t)=>e+t,0)/t,i=0,a=0;for(let o=0;o<t;o++)i+=(o-n)*(e[o]-r),a+=(o-n)**2;let o=a===0?0:i/a,s=o<-.05;return{slope:o,label:s?`draining`:o>.05?`accumulating`:`steady`,draining:s}}var C=r(),w=[`-60s`,`-45s`,`-30s`,`-15s`,`now`],T=15,E=[`push`,`pull`,`ack`],D={stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}}};function O(){let e=x(60),[n,r]=(0,b.useState)(0),{data:i,error:O,loading:M,refetch:N}=p(async()=>({details:await d.queuesSummary()}),[]),P=i?.details??[],F=Math.max(1,Math.ceil(P.length/T)),I=Math.min(n,F-1),L=(0,b.useMemo)(()=>P.slice(I*T,I*T+T),[P,I]),R=(0,b.useMemo)(()=>P.reduce((e,t)=>e+(t.counts?.failed??0),0),[P]);if(M&&!i&&!O)return(0,C.jsx)(a,{label:`Loading metrics…`});let{stats:z,throughput:B,latency:V}=e.latest??D,H=h(z.completed,R),U=S(e.depth),W=e.depth.length?e.depth[e.depth.length-1]:0;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(g,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:!O}),O&&(0,C.jsx)(_,{onRetry:N}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(c,{label:`Total Completed`,value:f(z.completed),tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(c,{label:`Total Failed`,value:l(R),tone:R?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(c,{label:`Push/sec`,value:B.pushPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(c,{label:`Pull/sec`,value:B.pullPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(A,{color:`#ec4899`,label:`Pushed`,value:B.pushPerSec}),(0,C.jsx)(A,{color:`#34d399`,label:`Completed`,value:B.completePerSec}),(0,C.jsx)(A,{color:`#f87171`,label:`Failed`,value:B.failPerSec})]})]}),(0,C.jsx)(y,{xLabels:w,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]})]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Backlog over time (waiting + active + delayed). The trend says whether you're draining or falling behind — more useful than any single gauge.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:l(W)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,U.label===`draining`?`text-success`:U.label===`accumulating`?`text-danger`:`text-faint`),children:U.label===`steady`?`steady`:`${U.slope>0?`+`:``}${U.slope.toFixed(1)}/s · ${U.label}`})]})]}),(0,C.jsx)(y,{xLabels:w,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:U.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]})]}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,H!=null&&H>.05?`text-danger`:`text-fg`),children:H==null?`—`:m(H)}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:`error rate`})]}),(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,H==null?`text-fg`:`text-success`),children:H==null?`—`:m(1-H)}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:`success rate`})]})]}),H==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-H)*100}%`}})}),(0,C.jsxs)(`div`,{className:`mt-2 flex justify-between font-mono text-[11px] text-faint`,children:[(0,C.jsxs)(`span`,{children:[f(z.completed),` completed`]}),(0,C.jsxs)(`span`,{children:[l(R),` failed`]})]})]}),(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(j,{color:`bg-blue-400`,label:`Queued`,value:l(z.waiting)}),(0,C.jsx)(j,{color:`bg-accent`,label:`Processing`,value:l(z.active)}),(0,C.jsx)(j,{color:`bg-amber-400`,label:`Delayed`,value:l(z.delayed)}),(0,C.jsx)(j,{color:`bg-red-400`,label:`Dead Letter`,value:l(z.dlq)}),(0,C.jsx)(j,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:f(z.totalPushed)}),(0,C.jsx)(j,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:f(z.totalPulled)}),(0,C.jsx)(j,{color:`bg-emerald-400`,label:`Uptime`,value:u(z.uptime/1e3)})]})]})]}),(0,C.jsxs)(s,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:E.map(e=>{let t=V?.percentiles?.[e],n=V?.averages?.[`${e}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:e}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(t?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(t?.p95)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:k(t?.p99)})]},e)})})]})})]}),(0,C.jsxs)(s,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:L.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:6,className:`px-5 py-12 text-center text-sm text-faint`,children:`No queues yet.`})}):L.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:l(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:l(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:l(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:l(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:I,pageSize:T,total:P.length,onPageChange:r,label:`queues`})})]})]})}function k(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}function A({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}function j({color:e,label:n,value:r}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}export{O as MetricsPro};
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{m as n,t as r}from"./react-vendor-CHIHtdAC.js";import{A as i,C as a,E as o,T as s,_ as c,c as l,d as u,g as d,i as f,j as p,l as m,n as h,v as g,w as _}from"./index-C9fPU4bV.js";import{t as v}from"./Pagination-Cd6lHj2E.js";import{t as y}from"./AreaChart-DzUXW8u3.js";var b=e(n(),1);function x(e=60){let[t,n]=(0,b.useState)({push:[],complete:[],fail:[],depth:[]}),[r,a]=(0,b.useState)(null),o=(0,b.useRef)(!0),s=(0,b.useRef)(!1);return(0,b.useEffect)(()=>{o.current=!0;let t=i(()=>typeof document<`u`&&document.hidden),r=async()=>{if(!s.current&&t()){s.current=!0;try{let t=await d.overview();if(!o.current)return;a(t);let r=(t.stats.waiting??0)+(t.stats.active??0)+(t.stats.delayed??0);n(n=>({push:[...n.push,t.throughput.pushPerSec].slice(-e),complete:[...n.complete,t.throughput.completePerSec].slice(-e),fail:[...n.fail,t.throughput.failPerSec].slice(-e),depth:[...n.depth,r].slice(-e)}))}catch{}finally{s.current=!1}}};r();let c=setInterval(r,1e3);return()=>{o.current=!1,clearInterval(c)}},[e]),{...t,latest:r}}function S(e){if(e.length<2)return{slope:0,label:`steady`,draining:!1};let t=e.length,n=(t-1)/2,r=e.reduce((e,t)=>e+t,0)/t,i=0,a=0;for(let o=0;o<t;o++)i+=(o-n)*(e[o]-r),a+=(o-n)**2;let o=a===0?0:i/a,s=o<-.05;return{slope:o,label:s?`draining`:o>.05?`accumulating`:`steady`,draining:s}}var C=r(),w=[`-60s`,`-45s`,`-30s`,`-15s`,`now`],T=15,E=[`push`,`pull`,`ack`],D={stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}}};function O(){let e=x(60),[n,r]=(0,b.useState)(0),{data:i,error:O,loading:M,refetch:N}=p(async()=>({details:await d.queuesSummary()}),[]),P=i?.details??[],F=Math.max(1,Math.ceil(P.length/T)),I=Math.min(n,F-1),L=(0,b.useMemo)(()=>P.slice(I*T,I*T+T),[P,I]),R=(0,b.useMemo)(()=>P.reduce((e,t)=>e+(t.counts?.failed??0),0),[P]);if(M&&!i&&!O)return(0,C.jsx)(a,{label:`Loading metrics…`});let{stats:z,throughput:B,latency:V}=e.latest??D,H=h(z.completed,R),U=S(e.depth),W=e.depth.length?e.depth[e.depth.length-1]:0;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(g,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:!O}),O&&(0,C.jsx)(_,{onRetry:N}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(c,{label:`Total Completed`,value:f(z.completed),tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(c,{label:`Total Failed`,value:l(R),tone:R?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(c,{label:`Push/sec`,value:B.pushPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(c,{label:`Pull/sec`,value:B.pullPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(A,{color:`#ec4899`,label:`Pushed`,value:B.pushPerSec}),(0,C.jsx)(A,{color:`#34d399`,label:`Completed`,value:B.completePerSec}),(0,C.jsx)(A,{color:`#f87171`,label:`Failed`,value:B.failPerSec})]})]}),(0,C.jsx)(y,{xLabels:w,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]})]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Backlog over time (waiting + active + delayed). The trend says whether you're draining or falling behind — more useful than any single gauge.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:l(W)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,U.label===`draining`?`text-success`:U.label===`accumulating`?`text-danger`:`text-faint`),children:U.label===`steady`?`steady`:`${U.slope>0?`+`:``}${U.slope.toFixed(1)}/s · ${U.label}`})]})]}),(0,C.jsx)(y,{xLabels:w,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:U.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]})]}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,H!=null&&H>.05?`text-danger`:`text-fg`),children:H==null?`—`:m(H)}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:`error rate`})]}),(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,H==null?`text-fg`:`text-success`),children:H==null?`—`:m(1-H)}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:`success rate`})]})]}),H==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-H)*100}%`}})}),(0,C.jsxs)(`div`,{className:`mt-2 flex justify-between font-mono text-[11px] text-faint`,children:[(0,C.jsxs)(`span`,{children:[f(z.completed),` completed`]}),(0,C.jsxs)(`span`,{children:[l(R),` failed`]})]})]}),(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(j,{color:`bg-blue-400`,label:`Queued`,value:l(z.waiting)}),(0,C.jsx)(j,{color:`bg-accent`,label:`Processing`,value:l(z.active)}),(0,C.jsx)(j,{color:`bg-amber-400`,label:`Delayed`,value:l(z.delayed)}),(0,C.jsx)(j,{color:`bg-red-400`,label:`Dead Letter`,value:l(z.dlq)}),(0,C.jsx)(j,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:f(z.totalPushed)}),(0,C.jsx)(j,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:f(z.totalPulled)}),(0,C.jsx)(j,{color:`bg-emerald-400`,label:`Uptime`,value:u(z.uptime/1e3)})]})]})]}),(0,C.jsxs)(s,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:E.map(e=>{let t=V?.percentiles?.[e],n=V?.averages?.[`${e}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:e}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(t?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(t?.p95)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:k(t?.p99)})]},e)})})]})})]}),(0,C.jsxs)(s,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:L.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:6,className:`px-5 py-12 text-center text-sm text-faint`,children:`No queues yet.`})}):L.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:l(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:l(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:l(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:l(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:I,pageSize:T,total:P.length,onPageChange:r,label:`queues`})})]})]})}function k(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}function A({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}function j({color:e,label:n,value:r}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}export{O as MetricsPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-CHIHtdAC.js";import{C as t,E as n,M as r,R as i,T as a,X as o,_ as s,c,d as l,j as u,l as d,n as f,r as p,v as m,w as h}from"./index-
|
|
1
|
+
import{t as e}from"./react-vendor-CHIHtdAC.js";import{C as t,E as n,M as r,R as i,T as a,X as o,_ as s,c,d as l,j as u,l as d,n as f,r as p,v as m,w as h}from"./index-C9fPU4bV.js";var g=e(),_={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function v(){let{data:e,error:v,loading:x,refetch:S}=u(()=>r.overview(),[]);if(x&&!e&&!v)return(0,g.jsx)(t,{label:`Loading overview…`});let{stats:C,throughput:w,memory:T,workers:E,crons:D,storage:O}=e??_,k=f(C.totalCompleted,C.totalFailed)??0;return(0,g.jsxs)(`div`,{children:[v&&(0,g.jsx)(h,{onRetry:S}),(0,g.jsx)(m,{title:`Overview`,description:`Live health and throughput across all queues.`,live:!0}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,g.jsx)(s,{label:`Waiting`,value:c(C.waiting),tone:`amber`}),(0,g.jsx)(s,{label:`Active`,value:c(C.active),tone:`blue`}),(0,g.jsx)(s,{label:`Completed`,value:c(C.totalCompleted),tone:`green`}),(0,g.jsx)(s,{label:`Failed`,value:c(C.totalFailed),tone:`red`}),(0,g.jsx)(s,{label:`DLQ`,value:c(C.dlq),tone:C.dlq>0?`red`:`default`}),(0,g.jsx)(s,{label:`Error Rate`,value:d(k),tone:k>.05?`red`:`green`})]}),(0,g.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsxs)(a,{children:[(0,g.jsx)(n,{title:`Throughput`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,g.jsx)(y,{label:`Pushed`,value:w.pushPerSec,tone:`text-fg`}),(0,g.jsx)(y,{label:`Pulled`,value:w.pullPerSec,tone:`text-blue-400`}),(0,g.jsx)(y,{label:`Completed`,value:w.completePerSec,tone:`text-emerald-400`}),(0,g.jsx)(y,{label:`Failed`,value:w.failPerSec,tone:`text-red-400`})]})]}),(0,g.jsxs)(a,{children:[(0,g.jsx)(n,{title:`Resources`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,g.jsx)(b,{label:`Uptime`,value:l(C.uptime)}),(0,g.jsx)(b,{label:`Heap`,value:p(T.heapUsed*1024*1024)}),(0,g.jsx)(b,{label:`RSS`,value:p(T.rss*1024*1024)}),(0,g.jsx)(b,{label:`Storage`,value:O.diskFull?`Disk full`:`Healthy`,tone:O.diskFull?`text-red-400`:`text-emerald-400`})]})]})]}),(0,g.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsxs)(a,{children:[(0,g.jsx)(n,{title:`Workers`,icon:(0,g.jsx)(o,{className:`size-4 text-faint`}),action:(0,g.jsxs)(`span`,{className:`text-sm text-muted`,children:[(0,g.jsx)(`span`,{className:`font-semibold text-emerald-400`,children:E.active}),` /`,` `,E.total,` active`]})}),E.list.length===0?(0,g.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No workers registered.`}):(0,g.jsx)(`ul`,{className:`divide-y divide-line`,children:E.list.slice(0,6).map(e=>(0,g.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,g.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name||e.id}),(0,g.jsxs)(`span`,{className:`text-xs text-faint`,children:[e.queues.join(`, `)||`—`,` · `,c(e.processedJobs),` done`]})]},e.id))})]}),(0,g.jsxs)(a,{children:[(0,g.jsx)(n,{title:`Cron Jobs`,icon:(0,g.jsx)(i,{className:`size-4 text-faint`}),action:(0,g.jsxs)(`span`,{className:`text-sm text-muted`,children:[D.total,` scheduled`]})}),D.list.length===0?(0,g.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No cron jobs.`}):(0,g.jsx)(`ul`,{className:`divide-y divide-line`,children:D.list.slice(0,6).map(e=>(0,g.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,g.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),(0,g.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)})]},e.name))})]})]})]})}function y({label:e,value:t,tone:n}){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,g.jsxs)(`div`,{className:`mt-1 text-2xl font-semibold tnum ${n}`,children:[t.toFixed(1),(0,g.jsx)(`span`,{className:`ml-0.5 text-sm font-normal text-faint`,children:`/s`})]})]})}function b({label:e,value:t,tone:n=`text-fg`}){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,g.jsx)(`div`,{className:`mt-1 text-base font-semibold ${n}`,children:t})]})}export{v as Overview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{c as r}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{c as r}from"./index-C9fPU4bV.js";var i=e(t(),1),a=n();function o({page:e,pageSize:t,total:n,hasNext:o,onPageChange:s,label:c=`items`,className:l}){let u=n!=null,d=u?Math.max(1,Math.ceil(n/t)):void 0;(0,i.useEffect)(()=>{u&&e>d-1&&s(d-1)},[u,e,d,s]);let f=u?Math.min(e,d-1):e,p=f*t,m=f>0,h=u?f<d-1:!!o;if(u&&n<=t&&f===0)return null;let g=u?n===0?`No ${c}`:`${r(p+1)}–${r(Math.min(p+t,n))} of ${r(n)} ${c}`:`Page ${f+1}`;return(0,a.jsxs)(`div`,{className:`mt-4 flex items-center justify-between text-sm text-faint ${l??``}`,children:[(0,a.jsx)(`span`,{children:g}),(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsx)(`button`,{type:`button`,disabled:!m,onClick:()=>s(f-1),className:`rounded-md px-3 py-1 text-xs hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 disabled:hover:text-faint`,children:`Previous`}),(0,a.jsx)(`span`,{className:`rounded-md bg-accent/15 px-2.5 py-1 text-xs font-medium text-accent tnum`,children:u?`${f+1} / ${d}`:f+1}),(0,a.jsx)(`button`,{type:`button`,disabled:!h,onClick:()=>s(f+1),className:`rounded-md px-3 py-1 text-xs hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 disabled:hover:text-faint`,children:`Next`})]})]})}export{o as t};
|