diff --git a/Data/Server/WebUI/src/Scheduling/Create_Job.jsx b/Data/Server/WebUI/src/Scheduling/Create_Job.jsx index 92893d9..fcfbab3 100644 --- a/Data/Server/WebUI/src/Scheduling/Create_Job.jsx +++ b/Data/Server/WebUI/src/Scheduling/Create_Job.jsx @@ -362,9 +362,18 @@ export default function CreateJob({ onCancel, onCreated, initialJob = null }) { const fetchAssemblyDoc = useCallback(async (type, rawPath) => { const normalizedPath = normalizeComponentPath(type, rawPath); if (!normalizedPath) return { doc: null, normalizedPath: "" }; + const trimmed = normalizedPath.replace(/\\/g, "/").replace(/^\/+/, "").trim(); + if (!trimmed) return { doc: null, normalizedPath: "" }; + let requestPath = trimmed; + if (type === "script" && requestPath.toLowerCase().startsWith("scripts/")) { + requestPath = requestPath.slice("Scripts/".length); + } else if (type === "ansible" && requestPath.toLowerCase().startsWith("ansible_playbooks/")) { + requestPath = requestPath.slice("Ansible_Playbooks/".length); + } + if (!requestPath) return { doc: null, normalizedPath }; try { const island = type === "ansible" ? "ansible" : "scripts"; - const resp = await fetch(`/api/assembly/load?island=${island}&path=${encodeURIComponent(normalizedPath)}`); + const resp = await fetch(`/api/assembly/load?island=${island}&path=${encodeURIComponent(requestPath)}`); if (!resp.ok) { return { doc: null, normalizedPath }; } diff --git a/Data/Server/WebUI/src/Scheduling/Quick_Job.jsx b/Data/Server/WebUI/src/Scheduling/Quick_Job.jsx index 9257ec8..59033b0 100644 --- a/Data/Server/WebUI/src/Scheduling/Quick_Job.jsx +++ b/Data/Server/WebUI/src/Scheduling/Quick_Job.jsx @@ -200,9 +200,20 @@ export default function QuickJob({ open, onClose, hostnames = [] }) { setVariableStatus({ loading: true, error: "" }); try { const island = mode === "ansible" ? "ansible" : "scripts"; - const relPath = island === "scripts" - ? (selectedPath.startsWith("Scripts/") ? selectedPath : `Scripts/${selectedPath}`) - : selectedPath; + const trimmed = (selectedPath || "").replace(/\\/g, "/").replace(/^\/+/, "").trim(); + if (!trimmed) { + setVariables([]); + setVariableValues({}); + setVariableErrors({}); + setVariableStatus({ loading: false, error: "" }); + return; + } + let relPath = trimmed; + if (island === "scripts" && relPath.toLowerCase().startsWith("scripts/")) { + relPath = relPath.slice("Scripts/".length); + } else if (island === "ansible" && relPath.toLowerCase().startsWith("ansible_playbooks/")) { + relPath = relPath.slice("Ansible_Playbooks/".length); + } const resp = await fetch(`/api/assembly/load?island=${island}&path=${encodeURIComponent(relPath)}`); if (!resp.ok) throw new Error(`Failed to load assembly (HTTP ${resp.status})`); const data = await resp.json();