feat(nodes): add server auto-setup and cluster-info badge

Add an 'Auto-setup' dialog that onboards a Proxmox server by password and
lets the backend auto-create the API token (adds all nodes for a cluster).
Show a cluster/standalone badge with node count on the node detail page.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-15 00:30:44 +05:00
parent 5d6acd619e
commit bb5d30ab68
5 changed files with 137 additions and 11 deletions

View File

@@ -129,6 +129,55 @@ export function useTestServerCredentials() {
});
}
export interface ClusterInfo {
server_id: number;
server_name: string;
is_cluster: boolean;
node_count?: number;
nodes?: string[];
error?: string;
}
export function useClusterInfo(serverId: number) {
return useQuery({
queryKey: nodeKeys.clusterInfo(serverId),
queryFn: () => apiClient.get<ClusterInfo>(`/proxmox/api/servers/${serverId}/cluster-info`),
enabled: serverId > 0,
});
}
export interface AutoSetupArgs {
name: string;
hostname?: string;
ip_address: string;
port?: number;
api_user?: string;
password: string;
verify_ssl?: boolean;
description?: string;
}
export interface AutoSetupResult {
cluster?: boolean;
nodes_count?: number;
servers?: Array<{ name: string; node: string; ip: string; status: string }>;
message?: string;
}
// Add a server by password — the backend auto-creates an API token.
export function useAutoSetupServer() {
const qc = useQueryClient();
return useMutation({
mutationFn: (data: AutoSetupArgs) => apiClient.post<AutoSetupResult>('/proxmox/api/servers/auto-setup', data),
onSuccess: () => {
qc.invalidateQueries({ queryKey: nodeKeys.servers });
qc.invalidateQueries({ queryKey: nodeKeys.topology });
qc.invalidateQueries({ queryKey: vmKeys.all });
qc.invalidateQueries({ queryKey: vmKeys.resourcesAll });
},
});
}
// ==================== Node network interfaces ====================
export function useNodeNetworks(serverId: number, node: string) {