diff --git a/backend/dockge-server.ts b/backend/dockge-server.ts index cf65d13..9d6fc43 100644 --- a/backend/dockge-server.ts +++ b/backend/dockge-server.ts @@ -331,7 +331,7 @@ export class DockgeServer { version: versionProperty, latestVersion: latestVersionProperty, isContainer, - //primaryBaseURL: await Settings.get("primaryBaseURL"), + primaryHostname: await Settings.get("primaryHostname"), //serverTimezone: await this.getTimezone(), //serverTimezoneOffset: this.getTimezoneOffset(), }); diff --git a/backend/stack.ts b/backend/stack.ts index 8afb0e1..5a15fc1 100644 --- a/backend/stack.ts +++ b/backend/stack.ts @@ -343,8 +343,6 @@ export class Stack { let lines = res.toString().split("\n"); - console.log(lines); - for (let line of lines) { try { let obj = JSON.parse(line); diff --git a/backend/util-common.ts b/backend/util-common.ts index 278544f..576d8d8 100644 --- a/backend/util-common.ts +++ b/backend/util-common.ts @@ -254,3 +254,84 @@ function copyYAMLCommentsItems(items : any, srcItems : any) { } } } + +/** + * Possible Inputs: + * ports: + * - "3000" + * - "3000-3005" + * - "8000:8000" + * - "9090-9091:8080-8081" + * - "49100:22" + * - "8000-9000:80" + * - "127.0.0.1:8001:8001" + * - "127.0.0.1:5000-5010:5000-5010" + * - "6060:6060/udp" + * @param input + * @param defaultHostname + */ +export function parseDockerPort(input : string, defaultHostname : string = "localhost") { + let hostname = defaultHostname; + let port; + let display; + + const parts = input.split("/"); + const part1 = parts[0]; + let protocol = parts[1] || "tcp"; + + // Split the last ":" + const lastColon = part1.lastIndexOf(":"); + + if (lastColon === -1) { + // No colon, so it's just a port or port range + // Check if it's a port range + const dash = part1.indexOf("-"); + if (dash === -1) { + // No dash, so it's just a port + port = part1; + } else { + // Has dash, so it's a port range, use the first port + port = part1.substring(0, dash); + } + + display = part1; + + } else { + // Has colon, so it's a port mapping + let hostPart = part1.substring(0, lastColon); + display = hostPart; + + // Check if it's a port range + const dash = part1.indexOf("-"); + + if (dash !== -1) { + // Has dash, so it's a port range, use the first port + hostPart = part1.substring(0, dash); + } + + // Check if it has a ip (ip:port) + const colon = hostPart.indexOf(":"); + + if (colon !== -1) { + // Has colon, so it's a ip:port + hostname = hostPart.substring(0, colon); + port = hostPart.substring(colon + 1); + } else { + // No colon, so it's just a port + port = hostPart; + } + } + + let portInt = parseInt(port); + + if (portInt == 443) { + protocol = "https"; + } else if (protocol === "tcp") { + protocol = "http"; + } + + return { + url: protocol + "://" + hostname + ":" + portInt, + display: display, + }; +} diff --git a/frontend/src/components/ArrayInput.vue b/frontend/src/components/ArrayInput.vue index 52a54bd..2271083 100644 --- a/frontend/src/components/ArrayInput.vue +++ b/frontend/src/components/ArrayInput.vue @@ -1,13 +1,18 @@ @@ -55,6 +60,21 @@ export default { return this.$parent.$parent.service; }, + valid() { + // Check if the array is actually an array + if (!Array.isArray(this.array)) { + return false; + } + + // Check if the array contains non-object only. + for (let item of this.array) { + if (typeof item === "object") { + return false; + } + } + return true; + } + }, created() { diff --git a/frontend/src/components/Container.vue b/frontend/src/components/Container.vue index ab530fb..57b3843 100644 --- a/frontend/src/components/Container.vue +++ b/frontend/src/components/Container.vue @@ -8,6 +8,10 @@
{{ status }} + + + {{ parsePort(port).display }} +
@@ -128,6 +132,7 @@ -