1import{j as e}from"./vendor-query-DPZO-Gta.js";import{r as a,L as _}from"./vendor-react-BomFe3BT.js";import{V as h,z as u}from"./index-BLzMsaFd.js";import"./vendor-charts-DodUWJ0z.js";function L({status:r}){const l={running:"bg-green-100 text-green-800",stopped:"bg-red-100 text-red-800",error:"bg-red-100 text-red-800",unknown:"bg-gray-100 text-gray-800",healthy:"bg-green-100 text-green-800",degraded:"bg-yellow-100 text-yellow-800",critical:"bg-red-100 text-red-800"};return e.jsxs("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${l[r]||l.unknown}`,children:[e.jsx("span",{className:`w-2 h-2 rounded-full mr-1.5 ${r==="running"||r==="healthy"?"bg-green-500":r==="stopped"||r==="error"||r==="critical"?"bg-red-500":r==="degraded"?"bg-yellow-500":"bg-gray-500"}`}),r.charAt(0).toUpperCase()+r.slice(1)]})}function B({type:r}){const l={server:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.25 14.25h13.5m-13.5 0a3 3 0 01-3-3m3 3a3 3 0 100 6h13.5a3 3 0 100-6m-16.5-3a3 3 0 013-3h13.5a3 3 0 013 3m-19.5 0a4.5 4.5 0 01.9-2.7L5.737 5.1a3.375 3.375 0 012.7-1.35h7.126c1.062 0 2.062.5 2.7 1.35l2.587 3.45a4.5 4.5 0 01.9 2.7m0 0a3 3 0 01-3 3m0 3h.008v.008h-.008v-.008zm0-6h.008v.008h-.008v-.008zm-3 6h.008v.008h-.008v-.008zm0-6h.008v.008h-.008v-.008z"})}),worker:e.jsxs("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.99l1.005.828c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.28c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.02-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.992a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.99l-1.004-.828a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.281z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),scheduler:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})}),database:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 6.375c0 2.278-3.694 4.125-8.25 4.125S3.75 8.653 3.75 6.375m16.5 0c0-2.278-3.694-4.125-8.25-4.125S3.75 4.097 3.75 6.375m16.5 0v11.25c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125V6.375m16.5 0v3.75m-16.5-3.75v3.75m16.5 0v3.75C20.25 16.153 16.556 18 12 18s-8.25-1.847-8.25-4.125v-3.75m16.5 0c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125"})}),service:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})})};return e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${r==="server"?"bg-blue-100 text-blue-600":r==="worker"?"bg-purple-100 text-purple-600":r==="scheduler"?"bg-orange-100 text-orange-600":r==="database"?"bg-green-100 text-green-600":"bg-gray-100 text-gray-600"}`,children:l[r]||l.service})}function A(){const[r,l]=a.useState(null),[C,S]=a.useState(!0),[p,v]=a.useState(!1),[y,j]=a.useState(null),[b,d]=a.use
1State(null),[c,f]=a.useState(null),[N,x]=a.useState([]),[m,w]=a.useState(!1);a.useEffect(()=>{i();const s=setInterval(i,3e4);return()=>clearInterval(s)},[]);const i=async(s=!0)=>{var n,o;try{s&&v(!0);const t=await h.getSystemHealth();l(t.data),j(null)}catch(t){const g=((o=(n=t==null?void 0:t.response)==null?void 0:n.data)==null?void 0:o.detail)||(t==null?void 0:t.message)||"Failed to load system health";j(g)}finally{S(!1),v(!1)}},M=async s=>{var n,o;if(confirm(`Are you sure you want to restart ${s}? This may cause temporary service disruption.`))try{d(s),await h.restartComponent(s),u.success(`${s} restart initiated`),setTimeout(()=>{i(!1),d(null)},3e3)}catch(t){const g=((o=(n=t==null?void 0:t.response)==null?void 0:n.data)==null?void 0:o.detail)||(t==null?void 0:t.message)||"Failed to restart component";u.error(g),d(null)}},k=async s=>{try{w(!0),f(s);const n=await h.getComponentLogs(s,100);x(n.data.lines||[])}catch{u.error("Failed to load logs"),x([])}finally{w(!1)}};return C?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-600"})}):y&&!r?e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-red-700",children:y}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"System Health"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"Monitor and manage system components"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx(L,{status:r.overall_status}),e.jsxs("button",{onClick:()=>i(),disabled:p,className:"px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition-colors disabled:opacity-50 flex items-center gap-2",children:[e.jsx("svg",{className:`w-4 h-4 ${p?"animate-spin":""}`,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"})}),"Refresh"]}),e.jsx(_,{to:"/admin",className:"px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition-colors",children:"Back to Dashboard"})]})]}),r&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-4",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Total Components"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:r.summary.total})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-4",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Running"}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:r.summary.running})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-4",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Stopped"}),e.jsx("p",{className:"text-2xl font-bold text-red-600",children:r.summary.stopped})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-4",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Errors"}),e.jsx("p",{className:"text-2xl font-bold text-red-600",children:r.summary.error})]})]}),r&&e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-200",children:e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"System Components"})}),e.jsx("div",{className:"divide-y divide-gray-100",children:r.components.map(s=>e.jsx("div",{className:"px-6 py-4 hover:bg-gray-50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(B,{type:s.type}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-medium text-gray-900",children:s.name}),e.jsx(L,{status:s.status})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:s.description}),e.jsxs("div",{className:"flex items-center gap-4 mt-1 text-xs text-gray-400",children:[s.pid&&e.jsxs("span",{children:["PID: ",s.pid]}),s.port&&e.jsxs("span",{children:["Port: ",s.port]}),s.memory_usage&&e.jsxs("span",{children:["Memory: ",s.memory_usage]}),s.active_connections!==void 0&&e.jsxs("span",{children:["Connections: ",s.active_connections]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.restart_command&&e.jsx("button",{onClick:()=>k(s.restart_command),className:"px-3 py-1.5 text-sm text-gray-600 hover:text-gray-800 hover:bg-gray-100 rounded-lg transition-colors",children:"View Logs"}),s.can_restart&&s.restart_command&&e.jsx("button",{onClick:()=>M(s.restart_command),disabled:b===s.restart_command,className:"px-3 py-1.5 text-sm bg-orange-100 text-orange-700 hover:bg-orange-200 rounded-lg transition-colors disabled:opacity-50 flex items-center gap-1",children:b===s.restart_command?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"})}),"Restarting..."]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"})}),"Restart"]})})]})]})},s.name))})]}),c&&e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 flex items-center justify-between",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Logs: ",c]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>k(c),disabled:m,className:"px-3 py-1.5 text-sm text-gray-600 hover:text-gray-800 hover:bg-gray-100 rounded-lg transition-colors disabled:opacity-50",children:m?"Loading...":"Refresh Logs"}),e.jsx("button",{onClick:()=>{f(null),x([])},className:"px-3 py-1.5 text-sm text-gray-600 hover:text-gray-800 hover:bg-gray-100 rounded-lg transition-colors",children:"Close"})]})]}),e.jsx("div",{className:"bg-gray-900 p-4 max-h-96 overflow-auto",children:m?e.jsx("div",{className:"text-gray-400 text-center py-4",children:"Loading logs..."}):N.length===0?e.jsx("div",{className:"text-gray-400 text-center py-4",children:"No logs available"}):e.jsx("pre",{className:"text-xs text-gray-300 font-mono whitespace-pre-wrap",children:N.join(` 2`)})})]}),r&&e.jsxs("div",{className:"text-center text-sm text-gray-400",children:["Last updated: ",new Date(r.timestamp).toLocaleStr
2ing()]})]})}export{A 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.