diff --git a/src/components/modals/agents/BulkAction.vue b/src/components/modals/agents/BulkAction.vue
index ab5e58e..a6b4d99 100644
--- a/src/components/modals/agents/BulkAction.vue
+++ b/src/components/modals/agents/BulkAction.vue
@@ -319,14 +319,15 @@ export default {
const filteredScriptOptions = computed(() => {
if (props.mode !== "script") return [];
- if (state.value.osType === "linux")
- return removeExtraOptionCategories(
- scriptOptions.value.filter(script => script.category || script.shell === "shell" || script.shell === "python")
- );
- else
- return removeExtraOptionCategories(
- scriptOptions.value.filter(script => script.category || script.shell !== "shell")
- );
+ return removeExtraOptionCategories(
+ scriptOptions.value.filter(
+ script =>
+ script.category ||
+ !script.supported_platforms ||
+ !script.supported_platforms.length === 0 ||
+ script.supported_platforms.includes(state.value.osType)
+ )
+ );
});
// component lifecycle hooks
diff --git a/src/components/modals/agents/RunScript.vue b/src/components/modals/agents/RunScript.vue
index d4dcf5a..6f0a1e3 100644
--- a/src/components/modals/agents/RunScript.vue
+++ b/src/components/modals/agents/RunScript.vue
@@ -174,14 +174,12 @@ export default {
}
const filteredScriptOptions = computed(() => {
- if (props.agent.plat === "linux")
- return removeExtraOptionCategories(
- scriptOptions.value.filter(script => script.category || script.shell === "shell" || script.shell === "python")
- );
- else
- return removeExtraOptionCategories(
- scriptOptions.value.filter(script => script.category || script.shell !== "shell")
- );
+ return removeExtraOptionCategories(
+ scriptOptions.value.filter(
+ script =>
+ script.category || !script.supported_platforms || script.supported_platforms.includes(props.agent.plat)
+ )
+ );
});
// watchers
diff --git a/src/components/scripts/ScriptFormModal.vue b/src/components/scripts/ScriptFormModal.vue
index cf99806..03db026 100644
--- a/src/components/scripts/ScriptFormModal.vue
+++ b/src/components/scripts/ScriptFormModal.vue
@@ -38,6 +38,16 @@
map-options
label="Shell Type"
/>
+
// composable imports
-import { ref, computed, watch, onMounted } from "vue";
+import { ref, computed, onMounted } from "vue";
import { useQuasar, useDialogPluginComponent } from "quasar";
import { saveScript, editScript, downloadScript } from "@/api/scripts";
-import { useAgentDropdown } from "@/composables/agents";
+import { useAgentDropdown, agentPlatformOptions } from "@/composables/agents";
import { notifySuccess } from "@/utils/notify";
// ui imports
@@ -186,16 +196,6 @@ export default {
const loading = ref(false);
const agentLoading = ref(false);
- // watch(script.value, (newValue, oldValue) => {
- // if (!props.script && script.value.script_body === "") {
- // if (newValue.shell === "shell") {
- // script.value.script_body = "#!/bin/bash\n\n# don't forget to include the shebang above!\n\n";
- // } else if (newValue.shell === "python") {
- // script.value.script_body = "#!/usr/bin/python3\n\n# don't forget to include the shebang above!\n\n";
- // }
- // }
- // });
-
const title = computed(() => {
if (props.script) {
return props.readonly
@@ -274,6 +274,7 @@ export default {
// non-reactive data
shellOptions,
+ agentPlatformOptions,
//computed
title,
diff --git a/src/components/scripts/ScriptManager.vue b/src/components/scripts/ScriptManager.vue
index 9f05b84..c4049a5 100644
--- a/src/components/scripts/ScriptManager.vue
+++ b/src/components/scripts/ScriptManager.vue
@@ -66,6 +66,16 @@
@click="setShowCommunityScripts(!showCommunityScripts)"
/>
+
+
@@ -110,7 +120,9 @@
Shell
- {{ props.node.name }}
+ {{
+ props.node.name
+ }}
{{ props.node.description }}
@@ -171,6 +183,15 @@
Download Script
+
+
+
+
+
+
+ {{ props.node.hidden ? "Show Script" : "Hide Script" }}
+
+
@@ -272,6 +293,15 @@
Download Script
+
+
+
+
+
+
+ {{ props.row.hidden ? "Show Script" : "Hide Script" }}
+
+
@@ -279,9 +309,11 @@
+
+
Powershell
@@ -296,8 +328,14 @@
Shell
-
+
+ {{
+ capitalize(plat)
+ }}
+
+
+
{{ truncateText(props.row.name, 50) }}
{{ props.row.name }}
@@ -334,6 +372,7 @@ import { ref, computed, watch, onMounted } from "vue";
import { useStore } from "vuex";
import { useQuasar, useDialogPluginComponent, exportFile } from "quasar";
import { fetchScripts, editScript, downloadScript, removeScript } from "@/api/scripts";
+import { capitalize } from "@/utils/format";
import { truncateText } from "@/utils/format";
import { notifySuccess } from "@/utils/notify";
@@ -358,6 +397,13 @@ const columns = [
align: "left",
sortable: true,
},
+ {
+ name: "supported_platforms",
+ label: "Platforms",
+ field: "supported_platforms",
+ align: "left",
+ sortable: true,
+ },
{
name: "name",
label: "Name",
@@ -409,11 +455,12 @@ export default {
// script manager logic
const scripts = ref([]);
+ const showHiddenScripts = ref(false);
async function getScripts() {
loading.value = true;
try {
- scripts.value = await fetchScripts();
+ scripts.value = await fetchScripts({ showHiddenScripts: true });
} catch (e) {
console.error(e);
}
@@ -432,6 +479,18 @@ export default {
loading.value = false;
}
+ async function hideScript(script) {
+ loading.value = true;
+ const notifyText = !script.hidden ? "Script was hidden!" : "Script was unhidden!";
+ try {
+ const result = await editScript({ id: script.id, hidden: !script.hidden });
+ await getScripts();
+ notifySuccess(notifyText);
+ } catch (e) {}
+
+ loading.value = false;
+ }
+
function deleteScript(script) {
$q.dialog({
title: `Delete script: ${script.name}?`,
@@ -467,9 +526,15 @@ export default {
const expanded = ref([]);
const loading = ref(false);
- const visibleScripts = computed(() =>
- showCommunityScripts.value ? scripts.value : scripts.value.filter(i => i.script_type !== "builtin")
- );
+ const visibleScripts = computed(() => {
+ if (showHiddenScripts.value) {
+ return showCommunityScripts.value ? scripts.value : scripts.value.filter(i => i.script_type !== "builtin");
+ } else {
+ return showCommunityScripts.value
+ ? scripts.value.filter(i => !i.hidden)
+ : scripts.value.filter(i => i.script_type !== "builtin" && !i.hidden);
+ }
+ });
const categories = computed(() => {
let list = [];
@@ -617,6 +682,7 @@ export default {
expanded,
loading,
showCommunityScripts,
+ showHiddenScripts,
// computed
visibleScripts,
@@ -628,6 +694,7 @@ export default {
getScripts,
deleteScript,
favoriteScript,
+ hideScript,
exportScript,
// dialog methods
@@ -644,6 +711,7 @@ export default {
// helper methods
truncateText,
+ capitalize,
// quasar dialog plugin
dialogRef,
@@ -651,4 +719,4 @@ export default {
};
},
};
-