PageSourceSearch

https://jobspidey.com/assets/AdminLogs-CZhfAsz-.js

js jobspidey.com collected 2026-10-04 03:13:58 UTC 9,739 bytes, 1 lines download raw bytes

1import{u as T,r as a,j as e}from"./index-gGPAhYiP.js";import{f as r}from"./dateUtils-CQABwbqK.js";import{R as O}from"./refresh-cw-BetVHXP4.js";import{S as w}from"./server-LEzFOhin.js";import{A as k}from"./activity-_ybApD2d.js";import{C as _}from"./cpu-D-0TrUD2.js";import{T as S}from"./triangle-alert-DjMcCygt.js";import{C as P}from"./clock-D6CgLgAW.js";import{C as D}from"./circle-x-DC8nzKsn.js";import{C as W}from"./circle-check-big-CNV11qTi.js";function h({label:c,value:o,icon:i,tone:t="slate"}){const l={slate:"bg-white border-gray-100 text-gray-900",blue:"bg-blue-50 border-blue-100 text-blue-700",amber:"bg-amber-50 border-amber-100 text-amber-700",red:"bg-red-50 border-red-100 text-red-700"};return e.jsxs("div",{className:`rounded-2xl border p-5 shadow-sm ${l[t]||l.slate}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-[0.22em] text-gray-500",children:c}),e.jsx(i,{className:"w-4 h-4"})]}),e.jsx("p",{className:"mt-3 text-3xl font-black tracking-tight",children:o})]})}function J(){const{api:c}=T(),[o,i]=a.useState([]),[t,l]=a.useState(null),[C,N]=a.useState(!0),[p,f]=a.useState(!0),[y,b]=a.useState(""),[n,g]=a.useState(""),[v,E]=a.useState(""),x=a.useCallback(async(s="")=>{N(!0),f(!0),b(""),g("");try{let d="/admin/logs?limit=50";s&&(d+=`&status_filter=${s}`);const[u,j]=await Promise.allSettled([c.get(d),c.get("/admin/worker-health")]);u.status==="fulfilled"?i(u.value.data):(console.error(u.reason),i([]),b("We couldn't load worker logs right now.")),j.status==="fulfilled"?l(j.value.data):(console.error(j.reason),l(null),g("Worker health is temporarily unavailable."))}catch(d){console.error(d),i([]),l(null),b("We couldn't load worker logs right now."),g("Worker health is temporarily unavailable.")}finally{N(!1),f(!1)}},[c]);a.useEffect(()=>{x()},[x]);const L=s=>{E(s),x(s)},I=s=>{switch(s){case"COMPLETED":return e.jsx(W,{className:"w-4 h-4 text-emerald-500"});case"FAILED":return e.jsx(D,{className:"w-4 h-4 text-red-500"});case"PROCESSING":return e.jsx(k,{className:"w-4 h-4 text-blue-500 animate-pulse"});case"PROCESSING_AI":return e.jsx(_,{className:"w-4 h-4 text-violet-500"});default:return e.jsx(P,{className:"w-4 h-4 text-amber-500"})}},R=s=>{switch(s){case"COMPLETED":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"FAILED":return"bg-red-50 text-red-700 border-red-100";case"PROCESSING":return"bg-blue-50 text-blue-700 border-blue-100";case"PROCESSING_AI":return"bg-violet-50 text-violet-700 border-violet-100";default:return"bg-amber-50 text-amber-700 border-amber-100"}},A=["","PENDING","PROCESSING","PROCESSING_AI","COMPLETED","FAILED"],m=s=>p?"...":n?"-":s??0;return e.jsxs("div",{className:"p-8 max-w-7xl mx-auto font-sans",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-black text-brand-dark tracking-tight",children:"Worker Monitoring"}),e.jsx("p",{className:"text-brand-secondary mt-1",children:"Track active scraper hosts, stale tasks, and task history."})]}),e.jsxs("button",{onClick:()=>x(v),className:"flex items-center gap-2 bg-white border border-gray-200 shadow-sm px-4 py-2.5 rounded-lg text-sm font-bold text-gray-700 hover:bg-gray-50 transition-colors",children:[e.jsx(O,{className:"w-4 h-4"})," Refresh"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4 mb-6",children:[e.jsx(h,{label:"Online Workers",value:m(t?.online_worker_count),icon:w,tone:"blue"}),e.jsx(h,{label:"Scraping Tasks",value:m(t?.active_processing_tasks),icon:k,tone:"slate"}),e.jsx(h,{label:"Cloud Handoff Tasks",value:m(t?.processing_ai_tasks),icon:_,tone:"amber"}),e.jsx(h,{label:"Stale Tasks",value:m(t?.stale_processing_tasks),icon:S,tone:"red"})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6 mb-8",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-soft border border-gray-100 p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(w,{className:"w-5 h-5 text-[var(--app-accent)]"}),e.jsx("h2",{className:"text-lg font-black text-gray-900",children:"Online Worker Hosts"})]}),p?e.jsx("p",{className:"text-sm text-gray-400",children:"Loading worker status..."}):n?e.jsx("p",{className:"text-sm text-amber-600",children:n}):t?.workers?.length?e.jsx("div",{className:"space-y-3",children:t.workers.map(s=>e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-gray-50 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-black text-gray-900",children:s.worker_id}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s.worker_host||"Unknown host"})]}),e.jsxs("span",{className:"rounded-full bg-[var(--app-surface-strong)] px-2.5 py-1 text-xs font-bold text-[var(--app-accent)]",children:[s.active_task_count," active"]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 md:grid-cols-2 gap-2 text-xs text-gray-500",children:[e.jsxs("p",{children:["Last seen: ",r(s.last_seen_at||s.last_heartbeat_at)]}),e.jsxs("p",{children:["Lease until: ",r(s.lease_expires_at)]})]}),e.jsxs("p",{className:"mt-2 text-xs text-gray-400",children:["Tasks: ",(s.task_ids||[]).map(d=>`#${d}
1`).join(", ")]})]},s.worker_id))}):e.jsx("p",{className:"text-sm text-gray-400",children:"No active scraping workers right now."})]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-soft border border-gray-100 p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(S,{className:"w-5 h-5 text-red-500"}),e.jsx("h2",{className:"text-lg font-black text-gray-900",children:"Stale Tasks Waiting For Recovery"})]}),p?e.jsx("p",{className:"text-sm text-gray-400",children:"Loading stale tasks..."}):n?e.jsx("p",{className:"text-sm text-amber-600",children:n}):t?.stale_tasks?.length?e.jsx("div",{className:"space-y-3",children:t.stale_tasks.map(s=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-red-50 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-black text-red-900",children:["Task #",s.id," - ",s.task_type]}),e.jsxs("p",{className:"text-xs text-red-700 mt-1",children:["User #",s.user_id," - ",s.worker_id||"Unknown worker"]})]}),e.jsxs("span",{className:"rounded-full bg-white px-2.5 py-1 text-xs font-bold text-red-700 border border-red-200",children:["Recoveries: ",s.recovery_count||0]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-1 text-xs text-red-700",children:[e.jsxs("p",{children:["Last update: ",r(s.updated_at)]}),e.jsxs("p",{children:["Lease expired: ",r(s.lease_expires_at)]})]})]},s.id))}):e.jsx("p",{className:"text-sm text-gray-400",children:"No stale scraping tasks detected."})]})]}),e.jsx("div",{className:"flex gap-2 mb-6 flex-wrap",children:A.map(s=>e.jsx("button",{onClick:()=>L(s),className:`px-4 py-2 rounded-lg text-xs font-bold uppercase tracking-wider transition-all border ${v===s?"bg-brand-primary text-white border-brand-primary shadow-md shadow-brand-primary/20":"bg-white text-gray-600 border-gray-200 hover:border-gray-300"}`,children:s||"All"},s))}),e.jsx("div",{className:"bg-white rounded-2xl shadow-soft border border-gray-100 overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50 border-b border-gray-100 text-xs font-bold text-gray-500 uppercase tracking-wider",children:[e.jsx("th",{className:"p-4 pl-6",children:"ID"}),e.jsx("th",{className:"p-4",children:"Type"}),e.jsx("th",{className:"p-4",children:"User"}),e.jsx("th",{className:"p-4",children:"Status"}),e.jsx("th",{className:"p-4",children:"Worker"}),e.jsx("th",{className:"p-4",children:"Attempts"}),e.jsx("th",{className:"p-4",children:"Last Heartbeat"}),e.jsx("th",{className:"p-4",children:"Lease"}),e.jsx("th",{className:"p-4",children:"Updated"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:C?e.jsx("tr",{children:e.jsx("td",{colSpan:"9",className:"p-8 text-center text-gray-400",children:"Loading..."})}):y?e.jsx("tr",{children:e.jsx("td",{colSpan:"9",className:"p-8 text-center text-red-500",children:y})}):o.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:"9",className:"p-8 text-center text-gray-400",children:"No worker tasks found."})}):o.map(s=>e.jsxs("tr",{className:"hover:bg-[var(--app-surface-soft)] transition-colors",children:[e.jsxs("td",{className:"p-4 pl-6 text-sm font-bold text-gray-400",children:["#",s.id]}),e.jsx("td",{className:"p-4 text-sm font-bold text-gray-700 uppercase",children:s.task_type}),e.jsxs("td",{className:"p-4 text-sm text-gray-500",children:["#",s.user_id]}),e.jsx("td",{className:"p-4",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-bold border ${R(s.status)}`,children:[I(s.status)," ",s.status]})}),e.jsxs("td",{className:"p-4 text-xs text-gray-500",children:[e.jsx("p",{className:"font-bold text-gray-700",children:s.worker_id||"-"}),e.jsx("p",{children:s.worker_host||"-"})]}),e.jsxs("td",{className:"p-4 text-xs text-gray-500",children:[e.jsxs("p",{children:["Attempts: ",s.attempt_count||0]}),e.jsxs("p",{children:["Recoveries: ",s.recovery_count||0]})]}),e.jsx("td",{className:"p-4 text-xs text-gray-500",children:r(s.last_heartbeat_at)}),e.jsx("td",{className:"p-4 text-xs text-gray-500",children:r(s.lease_expires_at)}),e.jsx("td",{className:"p-4 text-xs text-gray-500",children:r(s.updated_at)})]},s.id))})]})})})]})}export{J as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.