Compare commits

...

7 commits

Author SHA1 Message Date
Lance Cain
b403071add
Merge 1dd3205b30 into d451e06e84 2025-01-04 07:26:21 -05:00
Louis Lam
d451e06e84 Update dependencies
Some checks failed
Node.js CI - Dockge / ci (22, ARM) (push) Has been cancelled
Node.js CI - Dockge / ci (22, ARM64) (push) Has been cancelled
Node.js CI - Dockge / ci (22, macos-latest) (push) Has been cancelled
Node.js CI - Dockge / ci (22, ubuntu-latest) (push) Has been cancelled
Node.js CI - Dockge / ci (22, windows-latest) (push) Has been cancelled
json-yaml-validate / json-yaml-validate (push) Has been cancelled
2025-01-04 18:14:17 +08:00
Lance Cain
1dd3205b30 swapped to double quotes
swapped to double quotes from singles on service functions
2024-10-30 09:56:17 -04:00
Lance Cain
635bf624e8
Merge branch 'louislam:master' into container-control-buttons 2024-10-28 09:09:26 -04:00
Lance Cain
f41c17352e
Merge branch 'louislam:master' into container-control-buttons 2024-10-13 13:13:32 -04:00
Lance Cain
faa052933e add restart button
added restart service/container button as well as fixed start/stop buttons for correct statuses of healthy/unhealthy
2024-08-09 10:27:25 -04:00
Lance Cain
cc12f7221e add container buttons
Added start and stop service buttons for each service in a stack by changes to the container and compose components as well as the socket handler and the stack class.
2024-08-08 13:30:47 -04:00
6 changed files with 419 additions and 170 deletions

View file

@ -147,6 +147,8 @@ export class DockerSocketHandler extends AgentSocketHandler {
msgi18n: true, msgi18n: true,
}, callback); }, callback);
server.sendStackList(); server.sendStackList();
stack.leaveCombinedTerminal(socket);
} catch (e) { } catch (e) {
callbackError(e, callback); callbackError(e, callback);
} }
@ -238,6 +240,68 @@ export class DockerSocketHandler extends AgentSocketHandler {
} }
}); });
// Start a service
agentSocket.on("startService", async (stackName: unknown, serviceName: unknown, callback) => {
try {
checkLogin(socket);
if (typeof (stackName) !== "string" || typeof (serviceName) !== "string") {
throw new ValidationError("Stack name and service name must be strings");
}
const stack = await Stack.getStack(server, stackName);
await stack.startService(socket, serviceName);
stack.joinCombinedTerminal(socket); // Ensure the combined terminal is joined
callbackResult({
ok: true,
msg: "Service" + serviceName + " started"
}, callback);
server.sendStackList();
} catch (e) {
callbackError(e, callback);
}
});
// Stop a service
agentSocket.on("stopService", async (stackName: unknown, serviceName: unknown, callback) => {
try {
checkLogin(socket);
if (typeof (stackName) !== "string" || typeof (serviceName) !== "string") {
throw new ValidationError("Stack name and service name must be strings");
}
const stack = await Stack.getStack(server, stackName);
await stack.stopService(socket, serviceName);
callbackResult({
ok: true,
msg: "Service" + serviceName + " stopped"
}, callback);
server.sendStackList();
} catch (e) {
callbackError(e, callback);
}
});
agentSocket.on("restartService", async (stackName: unknown, serviceName: unknown, callback) => {
try {
checkLogin(socket);
if (typeof stackName !== "string" || typeof serviceName !== "string") {
throw new Error("Invalid stackName or serviceName");
}
const stack = await Stack.getStack(server, stackName, true);
await stack.restartService(socket, serviceName);
callbackResult({
ok: true,
msg: "Service" + serviceName + " restarted"
}, callback);
} catch (e) {
callbackError(e, callback);
}
});
// getExternalNetworkList // getExternalNetworkList
agentSocket.on("getDockerNetworkList", async (callback) => { agentSocket.on("getDockerNetworkList", async (callback) => {
try { try {

View file

@ -530,4 +530,34 @@ export class Stack {
} }
} }
async startService(socket: DockgeSocket, serviceName: string) {
const terminalName = getComposeTerminalName(socket.endpoint, this.name);
const exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", ["compose", "up", "-d", serviceName], this.path);
if (exitCode !== 0) {
throw new Error(`Failed to start service ${serviceName}, please check logs for more information.`);
}
return exitCode;
}
async stopService(socket: DockgeSocket, serviceName: string): Promise<number> {
const terminalName = getComposeTerminalName(socket.endpoint, this.name);
const exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", ["compose", "stop", serviceName], this.path);
if (exitCode !== 0) {
throw new Error(`Failed to stop service ${serviceName}, please check logs for more information.`);
}
return exitCode;
}
async restartService(socket: DockgeSocket, serviceName: string): Promise<number> {
const terminalName = getComposeTerminalName(socket.endpoint, this.name);
const exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", ["compose", "restart", serviceName], this.path);
if (exitCode !== 0) {
throw new Error(`Failed to restart service ${serviceName}, please check logs for more information.`);
}
return exitCode;
}
} }

View file

@ -1,7 +1,7 @@
<template> <template>
<div class="shadow-box big-padding mb-3 container"> <div class="shadow-box big-padding mb-3 container">
<div class="row"> <div class="row">
<div class="col-7"> <div class="col-5">
<h4>{{ name }}</h4> <h4>{{ name }}</h4>
<div class="image mb-2"> <div class="image mb-2">
<span class="me-1">{{ imageName }}:</span><span class="tag">{{ imageTag }}</span> <span class="me-1">{{ imageName }}:</span><span class="tag">{{ imageTag }}</span>
@ -14,12 +14,33 @@
</a> </a>
</div> </div>
</div> </div>
<div class="col-5"> <div class="col-7">
<div class="function"> <div class="function">
<router-link v-if="!isEditMode" class="btn btn-normal" :to="terminalRouteLink" disabled=""> <router-link v-if="!isEditMode" class="btn btn-normal" :to="terminalRouteLink" disabled="">
<font-awesome-icon icon="terminal" /> <font-awesome-icon icon="terminal" />
Bash Bash
</router-link> </router-link>
<button v-if="status !== 'running' && status !== 'healthy'"
class="btn btn-primary me-2"
:disabled="processing"
@click="startService">
<font-awesome-icon icon="play" class="me-1" />
Start
</button>
<button v-if="status === 'running' || status === 'healthy' || status === 'unhealthy'"
class="btn btn-danger me-2"
:disabled="processing"
@click="stopService">
<font-awesome-icon icon="stop" class="me-1" />
Stop
</button>
<button v-if="status === 'running' || status === 'healthy' || status === 'unhealthy'"
class="btn btn-warning me-2"
:disabled="processing"
@click="restartService">
<font-awesome-icon icon="sync" class="me-1" />
Restart
</button>
</div> </div>
</div> </div>
</div> </div>
@ -284,6 +305,16 @@ export default defineComponent({
remove() { remove() {
delete this.jsonObject.services[this.name]; delete this.jsonObject.services[this.name];
}, },
startService() {
this.$emit("start-service", this.name);
},
stopService() {
this.$emit("stop-service", this.name);
},
restartService() {
this.$emit("restart-service", this.name);
}
} }
}); });
</script> </script>

View file

@ -129,6 +129,10 @@
:is-edit-mode="isEditMode" :is-edit-mode="isEditMode"
:first="name === Object.keys(jsonConfig.services)[0]" :first="name === Object.keys(jsonConfig.services)[0]"
:status="serviceStatusList[name]" :status="serviceStatusList[name]"
:processing="processing"
@start-service="startService"
@stop-service="stopService"
@restart-service="restartService"
/> />
</div> </div>
@ -786,6 +790,44 @@ export default {
this.stack.name = this.stack?.name?.toLowerCase(); this.stack.name = this.stack?.name?.toLowerCase();
}, },
startService(serviceName) {
this.processing = true;
this.$root.emitAgent(this.endpoint, "startService", this.stack.name, serviceName, (res) => {
this.processing = false;
this.$root.toastRes(res);
if (res.ok) {
this.requestServiceStatus(); // Refresh service status
}
});
},
stopService(serviceName) {
this.processing = true;
this.$root.emitAgent(this.endpoint, "stopService", this.stack.name, serviceName, (res) => {
this.processing = false;
this.$root.toastRes(res);
if (res.ok) {
this.requestServiceStatus(); // Refresh service status
}
});
},
restartService(serviceName) {
this.processing = true;
this.$root.emitAgent(this.endpoint, "restartService", this.stack.name, serviceName, (res) => {
this.processing = false;
this.$root.toastRes(res);
if (res.ok) {
this.requestServiceStatus(); // Refresh service status
}
});
},
} }
}; };
</script> </script>

View file

@ -40,7 +40,7 @@
"dotenv": "~16.3.2", "dotenv": "~16.3.2",
"express": "~4.21.2", "express": "~4.21.2",
"express-static-gzip": "~2.1.8", "express-static-gzip": "~2.1.8",
"http-graceful-shutdown": "~3.1.13", "http-graceful-shutdown": "~3.1.14",
"jsonwebtoken": "~9.0.2", "jsonwebtoken": "~9.0.2",
"jwt-decode": "~3.1.2", "jwt-decode": "~3.1.2",
"knex": "~2.5.1", "knex": "~2.5.1",
@ -49,8 +49,8 @@
"promisify-child-process": "~4.1.2", "promisify-child-process": "~4.1.2",
"redbean-node": "~0.3.3", "redbean-node": "~0.3.3",
"semver": "^7.6.3", "semver": "^7.6.3",
"socket.io": "~4.8.0", "socket.io": "~4.8.1",
"socket.io-client": "~4.8.0", "socket.io-client": "~4.8.1",
"timezones-list": "~3.0.3", "timezones-list": "~3.0.3",
"ts-command-line-args": "~2.5.1", "ts-command-line-args": "~2.5.1",
"tsx": "~4.19.2", "tsx": "~4.19.2",
@ -59,7 +59,7 @@
}, },
"devDependencies": { "devDependencies": {
"@actions/github": "^6.0.0", "@actions/github": "^6.0.0",
"@fontsource/jetbrains-mono": "^5.1.1", "@fontsource/jetbrains-mono": "^5.1.2",
"@fortawesome/fontawesome-svg-core": "6.4.2", "@fortawesome/fontawesome-svg-core": "6.4.2",
"@fortawesome/free-regular-svg-icons": "6.4.2", "@fortawesome/free-regular-svg-icons": "6.4.2",
"@fortawesome/free-solid-svg-icons": "6.4.2", "@fortawesome/free-solid-svg-icons": "6.4.2",
@ -81,19 +81,19 @@
"cross-env": "~7.0.3", "cross-env": "~7.0.3",
"eslint": "~8.50.0", "eslint": "~8.50.0",
"eslint-plugin-jsdoc": "~46.8.2", "eslint-plugin-jsdoc": "~46.8.2",
"eslint-plugin-vue": "~9.17.0", "eslint-plugin-vue": "~9.32.0",
"prismjs": "~1.29.0", "prismjs": "~1.29.0",
"sass": "~1.68.0", "sass": "~1.68.0",
"typescript": "~5.2.2", "typescript": "~5.2.2",
"unplugin-vue-components": "~0.25.2", "unplugin-vue-components": "~0.25.2",
"vite": "~5.4.8", "vite": "~5.4.11",
"vite-plugin-compression": "~0.5.1", "vite-plugin-compression": "~0.5.1",
"vue": "~3.5.12", "vue": "~3.5.13",
"vue-eslint-parser": "~9.3.2", "vue-eslint-parser": "~9.3.2",
"vue-i18n": "~9.5.0", "vue-i18n": "~10.0.5",
"vue-prism-editor": "2.0.0-alpha.2", "vue-prism-editor": "2.0.0-alpha.2",
"vue-qrcode": "~2.2.2", "vue-qrcode": "~2.2.2",
"vue-router": "~4.2.5", "vue-router": "~4.5.0",
"vue-toastification": "2.0.0-rc.5", "vue-toastification": "2.0.0-rc.5",
"wait-on": "^7.2.0", "wait-on": "^7.2.0",
"xterm-addon-web-links": "~0.9.0" "xterm-addon-web-links": "~0.9.0"

400
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff