All checks were successful
Docker image / publish (push) Successful in 59s
Update the shadcn preset and visual Compose editor. Add deployment previews, history, attention notices, and cleanup safeguards. Use the supplied icon in the app header and authentication screens.
30 lines
1.6 KiB
TypeScript
30 lines
1.6 KiB
TypeScript
import { AgentSocketHandler } from "../agent-socket-handler";
|
|
import type { DockgeServer } from "../dockge-server";
|
|
import { callbackError, callbackResult, checkLogin, DockgeSocket, ValidationError } from "../util-server";
|
|
import type { AgentSocket } from "../../common/agent-socket";
|
|
|
|
export class ContainerManagementSocketHandler extends AgentSocketHandler {
|
|
create(socket: DockgeSocket, server: DockgeServer, agentSocket: AgentSocket) {
|
|
const on = (event: string, fallback: string, action: (...args: unknown[]) => Promise<object>) => {
|
|
agentSocket.on(event, async (...args: unknown[]) => {
|
|
const callback = args.pop();
|
|
if (typeof callback !== "function") {
|
|
return;
|
|
}
|
|
try {
|
|
checkLogin(socket);
|
|
callbackResult({ ok: true,
|
|
...await action(...args) }, callback);
|
|
} catch (error) {
|
|
callbackError(error instanceof ValidationError ? error : new Error(fallback), callback);
|
|
}
|
|
});
|
|
};
|
|
|
|
on("listHostContainers", "containerInventoryFailed", async () => ({ items: await server.containerManagement.list() }));
|
|
on("getHostContainerDetails", "containerDetailsFailed", async id => ({ details: await server.containerManagement.details(id) }));
|
|
on("containerFiles", "containerFileFailed", request => server.containerFileExplorer.request(socket.id, request));
|
|
socket.on("disconnect", () => server.containerFileExplorer.disconnect(socket.id));
|
|
}
|
|
}
|