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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user