From 7dbba931171db8bcc09d85b9eddea32644d21702 Mon Sep 17 00:00:00 2001 From: sadnub Date: Mon, 2 Aug 2021 09:34:17 -0400 Subject: [PATCH] change favorited script run on agent to opent he Run Script modal with the script and defaults populated --- src/components/AgentTable.vue | 23 +++-------- src/components/modals/agents/RunScript.vue | 3 +- src/views/Dashboard.vue | 48 +++++++++++----------- 3 files changed, 31 insertions(+), 43 deletions(-) diff --git a/src/components/AgentTable.vue b/src/components/AgentTable.vue index 33a7fa4..d6ef94e 100644 --- a/src/components/AgentTable.vue +++ b/src/components/AgentTable.vue @@ -112,7 +112,7 @@ - + Run URL Action @@ -164,7 +164,7 @@ dense clickable v-close-popup - @click="runFavScript(script.value, props.row.id)" + @click="showRunScript(props.row, script.value)" > {{ script.label }} @@ -531,24 +531,10 @@ export default { } }, 500); }, - runFavScript(scriptpk, agentpk) { - const script = this.favoriteScripts.find(i => i.value === scriptpk); - const data = { - pk: agentpk, - timeout: script.timeout, - scriptPK: scriptpk, - output: "forget", - args: script.args, - }; - this.$axios - .post("/agents/runscript/", data) - .then(r => this.notifySuccess(r.data)) - .catch(e => {}); - }, getFavoriteScripts() { this.favoriteScripts = []; this.$axios - .get("/scripts/scripts/") + .get("/scripts/") .then(r => { if (r.data.filter(k => k.favorite === true).length === 0) { this.notifyWarning("You don't have any scripts favorited!"); @@ -797,11 +783,12 @@ export default { }) .catch(() => {}); }, - showRunScript(agent) { + showRunScript(agent, script = undefined) { this.$q.dialog({ component: RunScript, componentProps: { agent, + script, }, }); }, diff --git a/src/components/modals/agents/RunScript.vue b/src/components/modals/agents/RunScript.vue index 5144841..4adf195 100644 --- a/src/components/modals/agents/RunScript.vue +++ b/src/components/modals/agents/RunScript.vue @@ -122,6 +122,7 @@ export default { components: { TacticalDropdown }, props: { agent: !Object, + script: Number, }, setup(props) { // setup vuex store @@ -132,7 +133,7 @@ export default { const { dialogRef, onDialogHide } = useDialogPluginComponent(); // setup dropdowns - const { script, scriptOptions, defaultTimeout, defaultArgs, getScriptOptions } = useScriptDropdown(); + const { script, scriptOptions, defaultTimeout, defaultArgs, getScriptOptions } = useScriptDropdown(props.script); const { customFieldOptions, getCustomFieldOptions } = useCustomFieldDropdown(); // main run script functionaity diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index e9ae49e..463322a 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -156,30 +156,6 @@ {{ menuMaintenanceText(props.node) }} - - - - - Run URL Action - - - - - - - {{ action.name }} - - - - - Assign Alert Template + + + + + Run URL Action + + + + + + + {{ action.name }} + + + + +