mirror of
https://github.com/louislam/dockge.git
synced 2024-11-30 14:24:02 +00:00
Fix ts issues
This commit is contained in:
parent
fa0a4f8ccf
commit
cacee2221e
4 changed files with 35 additions and 21 deletions
|
@ -1,5 +1,5 @@
|
|||
import { DockgeServer } from "./dockge-server";
|
||||
import { AgentSocket } from "../../common/agent-socket";
|
||||
import { AgentSocket } from "../common/agent-socket";
|
||||
import { DockgeSocket } from "./util-server";
|
||||
|
||||
export abstract class AgentSocketHandler {
|
||||
|
|
|
@ -112,10 +112,10 @@ export class DockerSocketHandler extends AgentSocketHandler {
|
|||
|
||||
const stack = await Stack.getStack(server, stackName);
|
||||
await stack.start(socket);
|
||||
callback({
|
||||
callbackResult({
|
||||
ok: true,
|
||||
msg: "Started"
|
||||
});
|
||||
}, callback);
|
||||
server.sendStackList();
|
||||
|
||||
stack.joinCombinedTerminal(socket);
|
||||
|
@ -136,10 +136,10 @@ export class DockerSocketHandler extends AgentSocketHandler {
|
|||
|
||||
const stack = await Stack.getStack(server, stackName);
|
||||
await stack.stop(socket);
|
||||
callback({
|
||||
callbackResult({
|
||||
ok: true,
|
||||
msg: "Stopped"
|
||||
});
|
||||
}, callback);
|
||||
server.sendStackList();
|
||||
} catch (e) {
|
||||
callbackError(e, callback);
|
||||
|
@ -157,10 +157,10 @@ export class DockerSocketHandler extends AgentSocketHandler {
|
|||
|
||||
const stack = await Stack.getStack(server, stackName);
|
||||
await stack.restart(socket);
|
||||
callback({
|
||||
callbackResult({
|
||||
ok: true,
|
||||
msg: "Restarted"
|
||||
});
|
||||
}, callback);
|
||||
server.sendStackList();
|
||||
} catch (e) {
|
||||
callbackError(e, callback);
|
||||
|
@ -178,10 +178,10 @@ export class DockerSocketHandler extends AgentSocketHandler {
|
|||
|
||||
const stack = await Stack.getStack(server, stackName);
|
||||
await stack.update(socket);
|
||||
callback({
|
||||
callbackResult({
|
||||
ok: true,
|
||||
msg: "Updated"
|
||||
});
|
||||
}, callback);
|
||||
server.sendStackList();
|
||||
} catch (e) {
|
||||
callbackError(e, callback);
|
||||
|
@ -199,10 +199,10 @@ export class DockerSocketHandler extends AgentSocketHandler {
|
|||
|
||||
const stack = await Stack.getStack(server, stackName);
|
||||
await stack.down(socket);
|
||||
callback({
|
||||
callbackResult({
|
||||
ok: true,
|
||||
msg: "Downed"
|
||||
});
|
||||
}, callback);
|
||||
server.sendStackList();
|
||||
} catch (e) {
|
||||
callbackError(e, callback);
|
||||
|
@ -220,10 +220,10 @@ export class DockerSocketHandler extends AgentSocketHandler {
|
|||
|
||||
const stack = await Stack.getStack(server, stackName, true);
|
||||
const serviceStatusList = Object.fromEntries(await stack.getServiceStatusList());
|
||||
callback({
|
||||
callbackResult({
|
||||
ok: true,
|
||||
serviceStatusList,
|
||||
});
|
||||
}, callback);
|
||||
} catch (e) {
|
||||
callbackError(e, callback);
|
||||
}
|
||||
|
@ -234,10 +234,10 @@ export class DockerSocketHandler extends AgentSocketHandler {
|
|||
try {
|
||||
checkLogin(socket);
|
||||
const dockerNetworkList = await server.getDockerNetworkList();
|
||||
callback({
|
||||
callbackResult({
|
||||
ok: true,
|
||||
dockerNetworkList,
|
||||
});
|
||||
}, callback);
|
||||
} catch (e) {
|
||||
callbackError(e, callback);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
import { SocketHandler } from "../socket-handler.js";
|
||||
import { DockgeServer } from "../dockge-server";
|
||||
import { log } from "../log";
|
||||
import { callbackError, checkLogin, DockgeSocket } from "../util-server";
|
||||
import { callbackError, callbackResult, checkLogin, DockgeSocket } from "../util-server";
|
||||
import { LooseObject } from "../../common/util-common";
|
||||
|
||||
export class ManageAgentSocketHandler extends SocketHandler {
|
||||
|
||||
create(socket : DockgeSocket, server : DockgeServer) {
|
||||
// addAgent
|
||||
socket.on("addAgent", async (data : unknown, callback : unknown) => {
|
||||
socket.on("addAgent", async (requestData : unknown, callback : unknown) => {
|
||||
try {
|
||||
log.debug("manage-agent-socket-handler", "addAgent");
|
||||
checkLogin(socket);
|
||||
|
||||
if (typeof(requestData) !== "object") {
|
||||
throw new Error("Data must be an object");
|
||||
}
|
||||
|
||||
let data = requestData as LooseObject;
|
||||
let manager = socket.instanceManager;
|
||||
await manager.test(data.url, data.username, data.password);
|
||||
await manager.add(data.url, data.username, data.password);
|
||||
|
@ -23,11 +30,11 @@ export class ManageAgentSocketHandler extends SocketHandler {
|
|||
server.disconnectAllSocketClients(undefined, socket.id);
|
||||
manager.sendAgentList();
|
||||
|
||||
callback({
|
||||
callbackResult({
|
||||
ok: true,
|
||||
msg: "agentAddedSuccessfully",
|
||||
msgi18n: true,
|
||||
});
|
||||
}, callback);
|
||||
|
||||
} catch (e) {
|
||||
callbackError(e, callback);
|
||||
|
@ -39,17 +46,22 @@ export class ManageAgentSocketHandler extends SocketHandler {
|
|||
try {
|
||||
log.debug("manage-agent-socket-handler", "removeAgent");
|
||||
checkLogin(socket);
|
||||
|
||||
if (typeof(url) !== "string") {
|
||||
throw new Error("URL must be a string");
|
||||
}
|
||||
|
||||
let manager = socket.instanceManager;
|
||||
await manager.remove(url);
|
||||
|
||||
server.disconnectAllSocketClients(undefined, socket.id);
|
||||
manager.sendAgentList();
|
||||
|
||||
callback({
|
||||
callbackResult({
|
||||
ok: true,
|
||||
msg: "agentRemovedSuccessfully",
|
||||
msgi18n: true,
|
||||
});
|
||||
}, callback);
|
||||
} catch (e) {
|
||||
callbackError(e, callback);
|
||||
}
|
||||
|
|
|
@ -14,9 +14,11 @@
|
|||
"dev:backend": "cross-env NODE_ENV=development tsx watch --inspect ./backend/index.ts",
|
||||
"dev:frontend": "cross-env NODE_ENV=development vite --host --config ./frontend/vite.config.ts",
|
||||
"release-final": "tsx ./extra/test-docker.ts && tsx extra/update-version.ts && pnpm run build:frontend && npm run build:docker",
|
||||
"release-beta": "tsx ./extra/test-docker.ts && tsx extra/update-version.ts && pnpm run build:frontend && npm run build:docker-beta",
|
||||
"build:frontend": "vite build --config ./frontend/vite.config.ts",
|
||||
"build:docker-base": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/dockge:base -f ./docker/Base.Dockerfile . --push",
|
||||
"build:docker": "node ./extra/env2arg.js docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/dockge:latest -t louislam/dockge:1 -t louislam/dockge:$VERSION --target release -f ./docker/Dockerfile . --push",
|
||||
"build:docker-beta": "node ./extra/env2arg.js docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/dockge:beta -t louislam/dockge:$VERSION --target release -f ./docker/Dockerfile . --push",
|
||||
"build:docker-nightly": "pnpm run build:frontend && docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/dockge:nightly --target nightly -f ./docker/Dockerfile . --push",
|
||||
"build:healthcheck": "docker buildx build -f docker/BuildHealthCheck.Dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/dockge:build-healthcheck . --push",
|
||||
"start-docker": "docker run --rm -p 5001:5001 --name dockge louislam/dockge:latest",
|
||||
|
|
Loading…
Reference in a new issue