Skip to content

Commit

Permalink
Add workaround for spaces in job config file names
Browse files Browse the repository at this point in the history
  • Loading branch information
nxshock committed Nov 21, 2022
1 parent b118d18 commit f575d71
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
7 changes: 6 additions & 1 deletion job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
22 changes: 12 additions & 10 deletions webui/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,27 @@ <h2>{{if eq . ""}}Other jobs{{else}}{{.}}{{end}}</h2>
html4 = '<span class="orange">&#x27f3; restarting</span>'
}

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) {
Expand Down

0 comments on commit f575d71

Please sign in to comment.