mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-08 14:08:51 +00:00
ed8fa7e11f
Complete frontend visual redesign using certctl logo color palette: - Deep teal sidebar (#0c2e25) with prominent centered logo (64px in white pill) - Light content area (#f0f4f8) with white cards and visible borders - Brand colors from logo: teal (#2ea88f), blue (#3b7dd8), orange (#e8873a), green (#4ebe6e) - Inter + JetBrains Mono typography, colored stat card top borders - All 17 pages + 7 components updated (25 files, ~700 lines changed) - 15 new dashboard screenshots replacing old dark theme screenshots - Prometheus metrics e2e test added, integration test mock fixes - Docs updated: architecture.md theme description, testing-guide.md DNS-PERSIST-01 coverage Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
95 lines
3.1 KiB
TypeScript
95 lines
3.1 KiB
TypeScript
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { getAgentGroups, deleteAgentGroup } from '../api/client';
|
|
import PageHeader from '../components/PageHeader';
|
|
import DataTable from '../components/DataTable';
|
|
import type { Column } from '../components/DataTable';
|
|
import StatusBadge from '../components/StatusBadge';
|
|
import ErrorState from '../components/ErrorState';
|
|
import { formatDateTime } from '../api/utils';
|
|
import type { AgentGroup } from '../api/types';
|
|
|
|
export default function AgentGroupsPage() {
|
|
const queryClient = useQueryClient();
|
|
|
|
const { data, isLoading, error, refetch } = useQuery({
|
|
queryKey: ['agent-groups'],
|
|
queryFn: () => getAgentGroups(),
|
|
});
|
|
|
|
const deleteMutation = useMutation({
|
|
mutationFn: deleteAgentGroup,
|
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['agent-groups'] }),
|
|
});
|
|
|
|
const columns: Column<AgentGroup>[] = [
|
|
{
|
|
key: 'name',
|
|
label: 'Group',
|
|
render: (g) => (
|
|
<div>
|
|
<div className="font-medium text-ink">{g.name}</div>
|
|
<div className="text-xs text-ink-faint font-mono">{g.id}</div>
|
|
{g.description && (
|
|
<div className="text-xs text-ink-muted mt-0.5 max-w-xs truncate">{g.description}</div>
|
|
)}
|
|
</div>
|
|
),
|
|
},
|
|
{
|
|
key: 'criteria',
|
|
label: 'Match Criteria',
|
|
render: (g) => {
|
|
const criteria: string[] = [];
|
|
if (g.match_os) criteria.push(`OS: ${g.match_os}`);
|
|
if (g.match_architecture) criteria.push(`Arch: ${g.match_architecture}`);
|
|
if (g.match_ip_cidr) criteria.push(`IP: ${g.match_ip_cidr}`);
|
|
if (g.match_version) criteria.push(`Ver: ${g.match_version}`);
|
|
return criteria.length > 0 ? (
|
|
<div className="flex flex-wrap gap-1">
|
|
{criteria.map((c, i) => (
|
|
<span key={i} className="badge badge-neutral text-xs">{c}</span>
|
|
))}
|
|
</div>
|
|
) : (
|
|
<span className="text-ink-faint text-xs">Manual only</span>
|
|
);
|
|
},
|
|
},
|
|
{
|
|
key: 'enabled',
|
|
label: 'Status',
|
|
render: (g) => <StatusBadge status={g.enabled ? 'active' : 'disabled'} />,
|
|
},
|
|
{
|
|
key: 'created',
|
|
label: 'Created',
|
|
render: (g) => <span className="text-xs text-ink-muted">{formatDateTime(g.created_at)}</span>,
|
|
},
|
|
{
|
|
key: 'actions',
|
|
label: '',
|
|
render: (g) => (
|
|
<button
|
|
onClick={(e) => { e.stopPropagation(); if (confirm(`Delete group ${g.name}?`)) deleteMutation.mutate(g.id); }}
|
|
className="text-xs text-red-600 hover:text-red-700 transition-colors"
|
|
>
|
|
Delete
|
|
</button>
|
|
),
|
|
},
|
|
];
|
|
|
|
return (
|
|
<>
|
|
<PageHeader title="Agent Groups" subtitle={data ? `${data.total} groups` : undefined} />
|
|
<div className="flex-1 overflow-y-auto">
|
|
{error ? (
|
|
<ErrorState error={error as Error} onRetry={() => refetch()} />
|
|
) : (
|
|
<DataTable columns={columns} data={data?.data || []} isLoading={isLoading} emptyMessage="No agent groups configured" />
|
|
)}
|
|
</div>
|
|
</>
|
|
);
|
|
}
|