rework script testing a bit. Fix mismatch object properties and props

This commit is contained in:
sadnub
2021-08-28 10:33:18 -04:00
parent ef2984cb2a
commit ad88e5531a
2 changed files with 12 additions and 18 deletions

View File

@@ -110,7 +110,7 @@
<script>
// composable imports
import { ref, computed, watch } from "vue";
import { ref, computed } from "vue";
import { useQuasar, useDialogPluginComponent } from "quasar";
import { saveScript, editScript, downloadScript } from "@/api/scripts";
import { notifySuccess } from "@/utils/notify";
@@ -148,7 +148,9 @@ export default {
const $q = useQuasar();
// script form logic
const script = props.script ? ref(Object.assign({}, props.script)) : ref({ shell: "powershell", timeout: 90 });
const script = props.script
? ref(Object.assign({}, props.script))
: ref({ shell: "powershell", default_timeout: 90 });
if (props.clone) script.value.name = `(Copy) ${script.value.name}`;
const code = ref("");
@@ -172,15 +174,8 @@ export default {
if (props.script)
downloadScript(script.value.id, { with_snippets: props.readonly }).then(r => {
code.value = r.code;
script.value.code = r.code;
});
watch(code, (newValue, oldValue) => {
if (newValue) {
script.value.code = code.value;
}
});
async function submitForm() {
loading.value = true;
let result = "";
@@ -208,7 +203,7 @@ export default {
$q.dialog({
component: TestScriptModal,
componentProps: {
script: script.value,
script: { ...script.value, code: code.value },
},
});
}

View File

@@ -58,7 +58,7 @@
<script>
// composition imports
import { ref, toRefs, onMounted } from "vue";
import { ref, onMounted } from "vue";
import { useAgentDropdown } from "@/composables/agents";
import { testScript } from "@/api/scripts";
import { useDialogPluginComponent } from "quasar";
@@ -82,11 +82,10 @@ export default {
// setup quasar dialog plugin
const { dialogRef, onDialogHide } = useDialogPluginComponent();
// make script object props single reactive properties
const { code, default_timeout, args, shell } = toRefs(props.script);
// main run script functionality
const agent = ref(null);
const timeout = ref(props.script.default_timeout);
const args = ref(props.script.args);
const ret = ref(null);
const loading = ref(false);
@@ -94,10 +93,10 @@ export default {
loading.value = true;
const data = {
agent: agent.value,
code: code.value,
timeout: default_timeout.value,
code: props.script.code,
timeout: timeout.value,
args: args.value,
shell: shell.value,
shell: props.script.shell,
};
ret.value = await testScript(data);
@@ -109,7 +108,7 @@ export default {
return {
// reactive data
agent,
timeout: default_timeout,
timeout,
args,
ret,
loading,