From 3a891db98f2f402672a3bbb435c01b495bcb343f Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 29 Nov 2020 03:30:31 +0000 Subject: [PATCH] add install agent to site context menu --- src/components/modals/agents/InstallAgent.vue | 18 ++++++++++-- src/views/Dashboard.vue | 28 +++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/components/modals/agents/InstallAgent.vue b/src/components/modals/agents/InstallAgent.vue index a1bf770..874b868 100644 --- a/src/components/modals/agents/InstallAgent.vue +++ b/src/components/modals/agents/InstallAgent.vue @@ -87,6 +87,9 @@ export default { name: "InstallAgent", mixins: [mixins], components: { AgentDownload }, + props: { + sitepk: Number, + }, data() { return { client_options: [], @@ -110,8 +113,19 @@ export default { .get("/clients/clients/") .then(r => { this.client_options = this.formatClientOptions(r.data); - this.client = this.client_options[0]; - this.site = this.sites[0]; + if (this.sitepk !== undefined && this.sitepk !== null) { + this.client_options.forEach(client => { + let site = client.sites.find(site => site.id === this.sitepk); + + if (site !== undefined) { + this.client = client; + this.site = { value: site.id, label: site.name }; + } + }); + } else { + this.client = this.client_options[0]; + this.site = this.sites[0]; + } this.$q.loading.hide(); }) .catch(() => { diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index b0d285c..2bb0f63 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -136,6 +136,18 @@ {{ menuMaintenanceText(props.node) }} + + + + + Install Agent + + @@ -338,6 +350,10 @@ + + + + @@ -352,6 +368,7 @@ import AlertsIcon from "@/components/AlertsIcon"; import PolicyAdd from "@/components/automation/modals/PolicyAdd"; import ClientsForm from "@/components/modals/clients/ClientsForm"; import SitesForm from "@/components/modals/clients/SitesForm"; +import InstallAgent from "@/components/modals/agents/InstallAgent"; export default { components: { @@ -362,6 +379,7 @@ export default { PolicyAdd, ClientsForm, SitesForm, + InstallAgent, }, data() { return { @@ -370,6 +388,8 @@ export default { showSitesFormModal: false, showPolicyAddModal: false, deleteEditModalPk: null, + showInstallAgentModal: false, + sitePk: null, clientOp: null, policyAddType: null, policyAddPk: null, @@ -619,6 +639,14 @@ export default { this.deleteEditModalPk = null; this.clientOp = null; }, + showInstallAgent(node) { + this.sitePk = node.id; + this.showInstallAgentModal = true; + }, + closeInstallAgent() { + this.showInstallAgentModal = false; + this.sitePk = null; + }, reload() { this.$store.dispatch("reload"); },