From 8e3ff25f7b29e9b3cdef4ba4c1d3bf9237017dc0 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sun, 12 Nov 2023 20:32:40 +0800 Subject: [PATCH] Followup #3864, rebase for 1.23.x (#4016) * Fix: Use ActionSelect Docker Host & validate input * Fix: Handle docker host deleted while editing * UI: Use add for ActionSelect & prevent delete instead --------- Co-authored-by: Nelson Chan --- server/model/monitor.js | 8 ++++-- src/components/ActionSelect.vue | 22 +++++++++++++-- src/components/DockerHostDialog.vue | 3 +- src/lang/en.json | 2 ++ src/pages/EditMonitor.vue | 44 ++++++++++++++++++++--------- 5 files changed, 59 insertions(+), 20 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 27f68d7a..e4d112bd 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -739,8 +739,6 @@ class Monitor extends BeanModel { } else if (this.type === "docker") { log.debug("monitor", `[${this.name}] Prepare Options for Axios`); - const dockerHost = await R.load("docker_host", this.docker_host); - const options = { url: `/containers/${this.docker_container}/json`, timeout: this.interval * 1000 * 0.8, @@ -757,6 +755,12 @@ class Monitor extends BeanModel { }), }; + const dockerHost = await R.load("docker_host", this.docker_host); + + if (!dockerHost) { + throw new Error("Failed to load docker host config"); + } + if (dockerHost._dockerType === "socket") { options.socketPath = dockerHost._dockerDaemon; } else if (dockerHost._dockerType === "tcp") { diff --git a/src/components/ActionSelect.vue b/src/components/ActionSelect.vue index ae09e656..78daebc2 100644 --- a/src/components/ActionSelect.vue +++ b/src/components/ActionSelect.vue @@ -1,9 +1,9 @@