Adds a dedicated Volumes page (sidebar) with per-host sections (local + each
online agent), matching the Networks/Images layout. Lists volumes with driver,
owning stack, in-use containers and mountpoint; admins can delete (with an
in-use warning + force option) and prune unused, plus an "only unused" filter.
- agent_app.py: /agent/volumes (list/delete with in-use 409 guard/prune)
reusing volume_service.
- routers/agents.py: proxy routes /api/agents/{id}/volumes/* (audit-logged
delete/prune).
- Frontend: volumesApi list/remove/prune take an optional agentId; new
pages/Volumes.tsx (VolumesSection per host) + sidebar entry + /volumes route.
The volume wizard (generate-yaml/host paths) stays local and unchanged.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
import api from "./client";
|
|
import type { HostPathResult, VolumeInfo } from "@/types";
|
|
|
|
// Base path for the local host or, when agentId is given, a remote agent.
|
|
const base = (agentId?: number) =>
|
|
agentId != null ? `/api/agents/${agentId}/volumes` : "/api/volumes";
|
|
|
|
export const volumesApi = {
|
|
list: (agentId?: number) =>
|
|
api.get<VolumeInfo[]>(base(agentId)).then((r) => r.data),
|
|
remove: (name: string, force = false, agentId?: number) =>
|
|
api.delete(`${base(agentId)}/${name}?force=${force}`).then((r) => r.data),
|
|
prune: (agentId?: number) =>
|
|
api.post<{ VolumesDeleted: string[] | null }>(`${base(agentId)}/prune`).then((r) => r.data),
|
|
generateYaml: (spec: Record<string, unknown>) =>
|
|
api
|
|
.post<{ yaml: string }>("/api/volumes/generate-yaml", spec)
|
|
.then((r) => r.data.yaml),
|
|
hostPaths: (path: string, showHidden = false) =>
|
|
api
|
|
.get<HostPathResult>(
|
|
`/api/host/paths?path=${encodeURIComponent(path)}&show_hidden=${showHidden}`
|
|
)
|
|
.then((r) => r.data),
|
|
};
|