From f575d71369a75d78343e019a7d85a3a9117b4d1d Mon Sep 17 00:00:00 2001 From: nxshock Date: Mon, 21 Nov 2022 21:37:55 +0500 Subject: [PATCH] Add workaround for spaces in job config file names --- job.go | 7 ++++++- webui/index.htm | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/job.go b/job.go index 07ab288..f3e7ca4 100644 --- a/job.go +++ b/job.go @@ -84,8 +84,13 @@ func readJob(filePath string) (*Job, error) { return nil, fmt.Errorf("unknown job type id: %v", int(jobConfig.Type)) // TODO: add job name to log } + jobName := strings.TrimSuffix(filepath.Base(filePath), filepath.Ext(filePath)) + jobName = strings.ReplaceAll(jobName, " ", "") + jobName = strings.ReplaceAll(jobName, "_", "") + jobName = strings.ReplaceAll(jobName, "#", "") + job := &Job{ - Name: strings.TrimSuffix(filepath.Base(filePath), filepath.Ext(filePath)), + Name: jobName, Status: Inactive, JobConfig: jobConfig} diff --git a/webui/index.htm b/webui/index.htm index defdeed..9bb71f4 100644 --- a/webui/index.htm +++ b/webui/index.htm @@ -76,25 +76,27 @@ html4 = '⟳ restarting' } + elementId = encodeURIComponent(message.Name) + if (message.CurrentRunningCount > 0) { - document.querySelector("#" + message.Name + " > td:nth-child(1) > button").className = "runningbg" + document.querySelector("#" + elementId + " > td:nth-child(1) > button").className = "runningbg" } else if (message.LastError != "") { - document.querySelector("#" + message.Name + " > td:nth-child(1) > button").className = "errorbg" + document.querySelector("#" + elementId + " > td:nth-child(1) > button").className = "errorbg" } else { - document.querySelector("#" + message.Name + " > td:nth-child(1) > button").removeAttribute("class") + document.querySelector("#" + elementId + " > td:nth-child(1) > button").removeAttribute("class") } if (message.CurrentRunningCount > 0) { - document.querySelector("#" + message.Name + " > td:nth-child(1) > button").setAttribute("disabled", "true") + document.querySelector("#" + elementId + " > td:nth-child(1) > button").setAttribute("disabled", "true") } else { - document.querySelector("#" + message.Name + " > td:nth-child(1) > button").removeAttribute("disabled") + document.querySelector("#" + elementId + " > td:nth-child(1) > button").removeAttribute("disabled") } - document.querySelector("#" + message.Name + " > td:nth-child(4)").innerHTML = html4 - document.querySelector("#" + message.Name + " > td:nth-child(5)").innerHTML = message.LastStartTime - document.querySelector("#" + message.Name + " > td:nth-child(6)").innerHTML = message.LastEndTime - document.querySelector("#" + message.Name + " > td:nth-child(7)").innerHTML = message.LastExecutionDuration - document.querySelector("#" + message.Name + " > td:nth-child(8)").innerHTML = message.NextLaunch + document.querySelector("#" + elementId + " > td:nth-child(4)").innerHTML = html4 + document.querySelector("#" + elementId + " > td:nth-child(5)").innerHTML = message.LastStartTime + document.querySelector("#" + elementId + " > td:nth-child(6)").innerHTML = message.LastEndTime + document.querySelector("#" + elementId + " > td:nth-child(7)").innerHTML = message.LastExecutionDuration + document.querySelector("#" + elementId + " > td:nth-child(8)").innerHTML = message.NextLaunch } function startJob(jobName) {