import type { ReactNode } from 'react'; import { bytesRatioToString, mbToBytes } from '@/lib/formatters'; import { useNavigate } from '@tanstack/react-router'; import { deleteAdminNodeInput, type NodeUtilization } from '@/api/admin/nodes/queries'; import { useAdminVersion } from '@/api/admin/version/queries'; import { useAdminNodeSystemInformation, useAdminNodeUtilization, useDeleteAdminNode } from '@/api/admin/nodes/queries'; import { useNodeDetail } from '@/components/admin/nodes/useNodeDetail'; import TitledGreyBox from '@/components/elements/TitledGreyBox'; import Code from '@/components/elements/Code'; import ProgressBar from '@/components/elements/ProgressBar'; import type { UiTone } from '@/themes/skins'; import Spinner from '@/components/elements/Spinner'; import Button from '@/components/elements/Button'; import { Dialog } from '@/components/elements/dialog'; const usageTone = (metric: NodeUtilization['memory'] | undefined): UiTone => { if (!metric) { return 'neutral'; } if (metric.css === 'red') { return 'danger'; } if (metric.css === 'yellow') { return 'warning'; } return 'success'; }; type SystemInformation = NonNullable['data']>; interface SystemInformationValueProps { info: SystemInformation | undefined; error: unknown; children: (info: SystemInformation) => ReactNode; } const SystemInformationValue = ({ info, error, children }: SystemInformationValueProps) => { if (error) { return Unavailable; } if (!info) { return ; } return children(info); }; const megabytes = (formatted: string): number => Number(formatted.replaceAll(',', '')); const UsageBox = ({ title, metric }: { title: string; metric: NodeUtilization['memory'] | undefined }) => { const percent = metric ? Math.min(metric.percent, 100) : 0; return (

{metric ? ( bytesRatioToString(mbToBytes(megabytes(metric.value)), mbToBytes(megabytes(metric.max))) ) : ( )}

); }; export default function NodeAboutTab() { const { node } = useNodeDetail(); const { attributes } = node; const navigate = useNavigate(); const { data: version } = useAdminVersion(); const deleteNode = useDeleteAdminNode(); const { data: utilization } = useAdminNodeUtilization(attributes.id); const { data: info, error: infoError } = useAdminNodeSystemInformation(attributes.id, { refetchInterval: 10000, }); const canDelete = attributes.servers_count === 0; const onDelete = (close: () => void) => { deleteNode .mutateAsync(deleteAdminNodeInput(attributes.id, attributes.name)) .then(() => navigate({ to: '/panel/nodes' })) .catch(close); }; return (
Daemon Version {(value) => {value.version}} {version && ( Latest: {version.daemon} )}
System Information {(value) => `${value.os} (${value.architecture}) ${value.kernel_version}`}
Total CPU Threads {(value) => value.cpu_count}
{attributes.description && (
                            {attributes.description}
                        
)}

Deleting a node is irreversible and immediately removes it from the Panel. There must be no servers associated with this node to continue.

{!canDelete && (

Move or delete all servers on this node before deleting it.

)}
onDelete(close)} trigger={({ onClick }) => ( )} > Deleting {attributes.name} is permanent and cannot be undone.
{attributes.maintenance_mode && (

This node is currently under maintenance.

)}

{attributes.servers_count}

See the Servers tab for the full server list.

); }