From bf8612969a1981b90eac205e261f6413a1c3c6f6 Mon Sep 17 00:00:00 2001 From: sadnub Date: Fri, 6 Nov 2020 12:06:13 -0500 Subject: [PATCH] fix bulk actions modal --- src/components/FileBar.vue | 45 ++--- .../agents/{BulkScript.vue => BulkAction.vue} | 116 +++++++---- src/components/modals/agents/BulkCommand.vue | 189 ------------------ .../modals/agents/BulkPatchManagement.vue | 156 --------------- src/components/modals/clients/AddClient.vue | 77 ------- src/components/modals/clients/AddSite.vue | 71 ------- .../modals/clients/DeleteClient.vue | 88 -------- src/components/modals/clients/DeleteSite.vue | 108 ---------- src/store/index.js | 8 +- 9 files changed, 100 insertions(+), 758 deletions(-) rename src/components/modals/agents/{BulkScript.vue => BulkAction.vue} (62%) delete mode 100644 src/components/modals/agents/BulkCommand.vue delete mode 100644 src/components/modals/agents/BulkPatchManagement.vue delete mode 100644 src/components/modals/clients/AddClient.vue delete mode 100644 src/components/modals/clients/AddSite.vue delete mode 100644 src/components/modals/clients/DeleteClient.vue delete mode 100644 src/components/modals/clients/DeleteSite.vue diff --git a/src/components/FileBar.vue b/src/components/FileBar.vue index 6d3313e..eba88ec 100644 --- a/src/components/FileBar.vue +++ b/src/components/FileBar.vue @@ -119,15 +119,15 @@ - + Bulk Command - + Bulk Script - + Bulk Patch Management @@ -187,19 +187,9 @@ - - - - - - - - - - - - - + + + @@ -222,9 +212,7 @@ import AdminManager from "@/components/AdminManager"; import InstallAgent from "@/components/modals/agents/InstallAgent"; import UploadMesh from "@/components/modals/core/UploadMesh"; import AuditManager from "@/components/AuditManager"; -import BulkCommand from "@/components/modals/agents/BulkCommand"; -import BulkScript from "@/components/modals/agents/BulkScript"; -import BulkPatchManagement from "@/components/modals/agents/BulkPatchManagement"; +import BulkAction from "@/components/modals/agents/BulkAction"; import Deployment from "@/components/Deployment"; export default { @@ -241,9 +229,7 @@ export default { UploadMesh, AdminManager, AuditManager, - BulkCommand, - BulkScript, - BulkPatchManagement, + BulkAction, Deployment, }, props: ["clients"], @@ -259,9 +245,8 @@ export default { showInstallAgent: false, showUploadMesh: false, showAuditManager: false, - showBulkCommand: false, - showBulkScript: false, - showBulkPatchManagement: false, + showBulkAction: false, + bulkMode: null, showDeployment: false, }; }, @@ -271,7 +256,7 @@ export default { if (type === "client") { this.showClientFormModal = true; - } else if (type === "client") { + } else if (type === "site") { this.showSiteFormModal = true; } }, @@ -280,6 +265,14 @@ export default { this.showClientFormModal = null; this.showSiteFormModal = null; }, + showBulkActionModal(mode) { + this.bulkMode = mode; + this.showBulkAction = true; + }, + closeBulkActionModal() { + this.bulkMode = null; + this.showBulkAction = false; + }, getLog() { this.$store.commit("logs/TOGGLE_LOG_MODAL", true); }, diff --git a/src/components/modals/agents/BulkScript.vue b/src/components/modals/agents/BulkAction.vue similarity index 62% rename from src/components/modals/agents/BulkScript.vue rename to src/components/modals/agents/BulkAction.vue index 797cfcc..2c87d55 100644 --- a/src/components/modals/agents/BulkScript.vue +++ b/src/components/modals/agents/BulkAction.vue @@ -15,14 +15,25 @@

Choose Target

- +
- + - - + - + - + - + - + + +

Shell

+
+ + +
+
+ + + + + + + +
+

Action

+
+ + +
+
+
+ @@ -129,32 +163,32 @@ import { mapGetters } from "vuex"; export default { name: "BulkScript", mixins: [mixins], + props: { + mode: !String, + }, data() { return { target: "client", + selected_mode: null, scriptPK: null, timeout: 900, - tree: null, client: null, + client_options: [], site: null, agents: [], agentMultiple: [], args: [], + cmd: "", + shell: "cmd", }; }, computed: { ...mapGetters(["scripts"]), sites() { - if (this.tree !== null && this.client !== null) { - this.site = this.tree[this.client].sort()[0]; - return this.tree[this.client].sort(); - } + return !!this.client ? this.formatSiteOptions(this.client.sites) : []; }, scriptOptions() { - const ret = []; - this.scripts.forEach(i => { - ret.push({ label: i.name, value: i.id }); - }); + const ret = this.scripts.map(script => ({ label: script.name, value: script.id })); return ret.sort((a, b) => a.label.localeCompare(b.label)); }, }, @@ -162,14 +196,17 @@ export default { send() { this.$q.loading.show(); const data = { - mode: "script", + mode: this.selected_mode, target: this.target, - client: this.client, - site: this.site, + site: this.site.value, + client: this.client.value, agentPKs: this.agentMultiple, scriptPK: this.scriptPK, timeout: this.timeout, args: this.args, + shell: "cmd", + timeout: 300, + cmd: null, }; this.$axios .post("/agents/bulk/", data) @@ -183,25 +220,26 @@ export default { this.notifyError(e.response.data); }); }, - getTree() { - this.$axios.get("/clients/loadclients/").then(r => { - this.tree = r.data; - this.client = Object.keys(r.data).sort()[0]; + getClients() { + this.$axios.get("/clients/clients/").then(r => { + this.client_options = this.formatClientOptions(r.data); + + this.client = this.client_options[0]; + this.site = this.sites[0]; }); }, getAgents() { this.$axios.get("/agents/listagentsnodetail/").then(r => { - const ret = []; - r.data.forEach(i => { - ret.push({ label: i.hostname, value: i.pk }); - }); + const ret = r.data.map(agent => ({ label: agent.hostname, value: agent.pk })); this.agents = Object.freeze(ret.sort((a, b) => a.label.localeCompare(b.label))); }); }, }, created() { - this.getTree(); + this.getClients(); this.getAgents(); + + this.selected_mode = this.mode; }, }; \ No newline at end of file diff --git a/src/components/modals/agents/BulkCommand.vue b/src/components/modals/agents/BulkCommand.vue deleted file mode 100644 index 18f6082..0000000 --- a/src/components/modals/agents/BulkCommand.vue +++ /dev/null @@ -1,189 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/modals/agents/BulkPatchManagement.vue b/src/components/modals/agents/BulkPatchManagement.vue deleted file mode 100644 index 7df2082..0000000 --- a/src/components/modals/agents/BulkPatchManagement.vue +++ /dev/null @@ -1,156 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/modals/clients/AddClient.vue b/src/components/modals/clients/AddClient.vue deleted file mode 100644 index 24bc434..0000000 --- a/src/components/modals/clients/AddClient.vue +++ /dev/null @@ -1,77 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/modals/clients/AddSite.vue b/src/components/modals/clients/AddSite.vue deleted file mode 100644 index 80c56ba..0000000 --- a/src/components/modals/clients/AddSite.vue +++ /dev/null @@ -1,71 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/modals/clients/DeleteClient.vue b/src/components/modals/clients/DeleteClient.vue deleted file mode 100644 index 8753ff0..0000000 --- a/src/components/modals/clients/DeleteClient.vue +++ /dev/null @@ -1,88 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/modals/clients/DeleteSite.vue b/src/components/modals/clients/DeleteSite.vue deleted file mode 100644 index 43f6a71..0000000 --- a/src/components/modals/clients/DeleteSite.vue +++ /dev/null @@ -1,108 +0,0 @@ - - - \ No newline at end of file diff --git a/src/store/index.js b/src/store/index.js index 3fd5c3f..e4f6b32 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -237,8 +237,8 @@ export default function () { for (let site of client.sites) { let site_color = "black" - if (site.maintenance_mode) { site_color = "orange" } - else if (site.failing_checks) { site_color = "red" } + if (site.maintenance_mode) { site_color = "warning" } + else if (site.failing_checks) { site_color = "negative" } childSites.push({ label: site.name, @@ -251,8 +251,8 @@ export default function () { } let client_color = "black" - if (client.maintenance_mode) { client_color = "orange" } - else if (client.failing_checks) { client_color = "red" } + if (client.maintenance_mode) { client_color = "warning" } + else if (client.failing_checks) { client_color = "negative" } output.push({ label: client.name,