Fix save docker host issue

This commit is contained in:
Louis Lam 2022-07-30 19:48:12 +08:00
parent f3322398e5
commit 8ced61697a
4 changed files with 18 additions and 9 deletions

View File

@ -139,7 +139,7 @@ async function sendDockerHostList(socket) {
]); ]);
for (let bean of list) { for (let bean of list) {
result.push(bean.export()); result.push(bean.toJSON());
} }
io.to(socket.userID).emit("dockerHostList", result); io.to(socket.userID).emit("dockerHostList", result);

View File

@ -26,8 +26,8 @@ class DockerHost {
} }
bean.user_id = userID; bean.user_id = userID;
bean.docker_daemon = dockerHost.docker_daemon; bean.docker_daemon = dockerHost.dockerDaemon;
bean.docker_type = dockerHost.docker_type; bean.docker_type = dockerHost.dockerType;
bean.name = dockerHost.name; bean.name = dockerHost.name;
await R.store(bean); await R.store(bean);

View File

@ -7,11 +7,11 @@ class DockerHost extends BeanModel {
*/ */
toJSON() { toJSON() {
return { return {
id: this._id, id: this.id,
userId: this._user_id, userID: this.user_id,
daemon: this._dockerDaemon, dockerDaemon: this.docker_daemon,
type: this._dockerType, dockerType: this.docker_type,
name: this._name, name: this.name,
}; };
} }
} }

View File

@ -52,8 +52,9 @@
<script lang="ts"> <script lang="ts">
import { Modal } from "bootstrap"; import { Modal } from "bootstrap";
import Confirm from "./Confirm.vue"; import Confirm from "./Confirm.vue";
import { useToast } from "vue-toastification";
const toast = useToast();
export default { export default {
components: { components: {
@ -88,14 +89,22 @@ export default {
show(dockerHostID) { show(dockerHostID) {
if (dockerHostID) { if (dockerHostID) {
let found = false;
this.id = dockerHostID; this.id = dockerHostID;
for (let n of this.$root.dockerHostList) { for (let n of this.$root.dockerHostList) {
if (n.id === dockerHostID) { if (n.id === dockerHostID) {
this.dockerHost = n; this.dockerHost = n;
found = true;
break; break;
} }
} }
if (!found) {
toast.error("Docker Host not found!");
}
} else { } else {
this.id = null; this.id = null;
this.dockerHost = { this.dockerHost = {