1
0
mirror of https://github.com/nxshock/gron.git synced 2024-11-27 03:41:00 +05:00

Add workaround for spaces in job config file names

This commit is contained in:
nxshock 2022-11-21 21:37:55 +05:00
parent b118d18516
commit f575d71369
2 changed files with 18 additions and 11 deletions

7
job.go
View File

@ -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 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{ job := &Job{
Name: strings.TrimSuffix(filepath.Base(filePath), filepath.Ext(filePath)), Name: jobName,
Status: Inactive, Status: Inactive,
JobConfig: jobConfig} JobConfig: jobConfig}

View File

@ -76,25 +76,27 @@
html4 = '<span class="orange">&#x27f3; restarting</span>' html4 = '<span class="orange">&#x27f3; restarting</span>'
} }
elementId = encodeURIComponent(message.Name)
if (message.CurrentRunningCount > 0) { 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 != "") { } 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 { } 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) { 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 { } 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("#" + elementId + " > td:nth-child(4)").innerHTML = html4
document.querySelector("#" + message.Name + " > td:nth-child(5)").innerHTML = message.LastStartTime document.querySelector("#" + elementId + " > td:nth-child(5)").innerHTML = message.LastStartTime
document.querySelector("#" + message.Name + " > td:nth-child(6)").innerHTML = message.LastEndTime document.querySelector("#" + elementId + " > td:nth-child(6)").innerHTML = message.LastEndTime
document.querySelector("#" + message.Name + " > td:nth-child(7)").innerHTML = message.LastExecutionDuration document.querySelector("#" + elementId + " > td:nth-child(7)").innerHTML = message.LastExecutionDuration
document.querySelector("#" + message.Name + " > td:nth-child(8)").innerHTML = message.NextLaunch document.querySelector("#" + elementId + " > td:nth-child(8)").innerHTML = message.NextLaunch
} }
function startJob(jobName) { function startJob(jobName) {