2022-03-30 21:06:55 +05:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
|
|
<title>gron</title>
|
|
|
|
<link rel="stylesheet" href="/style.css">
|
2022-11-20 14:44:03 +05:00
|
|
|
<link rel="icon" href="data:,">
|
2022-03-30 21:06:55 +05:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<main>
|
|
|
|
<div class="dropdown">
|
|
|
|
<button class="dropbtn">☰ Menu</button>
|
|
|
|
<div class="dropdown-content">
|
|
|
|
<a href="/reloadJobs">⟳ Reload jobs</a>
|
|
|
|
<a>
|
|
|
|
<hr>
|
|
|
|
</a>
|
|
|
|
<a href="/shutdown">⏻ Shutdown</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-10-21 20:12:41 +05:00
|
|
|
{{range .Categories}}
|
|
|
|
<h2>{{if eq . ""}}Other jobs{{else}}{{.}}{{end}}</h2>
|
2022-03-30 21:06:55 +05:00
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Description</th>
|
|
|
|
<th>Cron</th>
|
|
|
|
<th>Status</th>
|
|
|
|
<th>Start time</th>
|
|
|
|
<th>Finish time</th>
|
|
|
|
<th>Duration</th>
|
|
|
|
<th>Next launch</th>
|
|
|
|
<th>Details</th>
|
|
|
|
</tr>
|
2022-10-21 20:12:41 +05:00
|
|
|
{{range (index $.Jobs .)}}
|
2022-11-20 14:44:03 +05:00
|
|
|
<tr id="{{.Name}}">
|
2022-03-30 21:06:55 +05:00
|
|
|
<td class="no-padding">
|
2022-11-20 14:44:03 +05:00
|
|
|
<button{{if gt .CurrentRunningCount 0}} class="runningbg" {{else}}{{if .LastError}} class="errorbg" {{end}}{{end}} name="jobName" value="{{.Name}}" {{if gt .CurrentRunningCount 0}} disabled{{end}} onclick='startJob("{{.Name}}")'>{{.Name}}</button>
|
2022-03-30 21:06:55 +05:00
|
|
|
</td>
|
|
|
|
<td class="smaller">{{.JobConfig.Description}}</td>
|
|
|
|
<td class="nowrap" align="right">
|
|
|
|
<pre>{{.JobConfig.Cron}}</pre>
|
|
|
|
</td>
|
|
|
|
<td class="nowrap">{{if eq .Status 0}}⯀ inactive{{end}}{{if eq .Status 1}}<span class="green">⯈ running</span>{{end}}{{if eq .Status 2}}<span class="red">⯁ error</span>{{end}}{{if eq .Status 3}}<span class="orange">⟳ restarting</span>{{end}}</td>
|
|
|
|
<td>{{.LastStartTime}}</td>
|
|
|
|
<td>{{.LastEndTime}}</td>
|
|
|
|
<td align="right">{{.LastExecutionDuration}}</td>
|
|
|
|
<td>{{.NextLaunch}}</td>
|
|
|
|
<td class="centered"><a href="/details?jobName={{.Name}}">open</a></td>
|
|
|
|
</tr>{{end}}
|
2022-10-21 20:12:41 +05:00
|
|
|
</table>{{end}}
|
2022-03-30 21:06:55 +05:00
|
|
|
</main>
|
|
|
|
</body>
|
2022-11-20 14:44:03 +05:00
|
|
|
<script>
|
|
|
|
let socket = new WebSocket("ws://" + window.location.host + "/ws")
|
|
|
|
|
|
|
|
socket.onerror = function(error) {
|
|
|
|
console.log("WebSocket error: " + JSON.stringify(error))
|
|
|
|
socket.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
socket.onmessage = function(event) {
|
|
|
|
message = JSON.parse(event.data);
|
|
|
|
|
|
|
|
html4 = "unknown"
|
|
|
|
if (message.Status == 0) {
|
|
|
|
html4 = "⯀ inactive"
|
|
|
|
} else if (message.Status == 1) {
|
|
|
|
html4 = '<span class="green">⯈ running</span>'
|
|
|
|
} else if (message.Status == 2) {
|
|
|
|
html4 = '<span class="red">⯁ error</span>'
|
|
|
|
} else if (message.Status == 3) {
|
|
|
|
html4 = '<span class="orange">⟳ restarting</span>'
|
|
|
|
}
|
|
|
|
|
2022-11-21 21:37:55 +05:00
|
|
|
elementId = encodeURIComponent(message.Name)
|
|
|
|
|
2022-11-20 14:44:03 +05:00
|
|
|
if (message.CurrentRunningCount > 0) {
|
2022-11-21 21:37:55 +05:00
|
|
|
document.querySelector("#" + elementId + " > td:nth-child(1) > button").className = "runningbg"
|
2022-11-20 14:44:03 +05:00
|
|
|
} else if (message.LastError != "") {
|
2022-11-21 21:37:55 +05:00
|
|
|
document.querySelector("#" + elementId + " > td:nth-child(1) > button").className = "errorbg"
|
2022-11-20 14:44:03 +05:00
|
|
|
} else {
|
2022-11-21 21:37:55 +05:00
|
|
|
document.querySelector("#" + elementId + " > td:nth-child(1) > button").removeAttribute("class")
|
2022-11-20 14:44:03 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (message.CurrentRunningCount > 0) {
|
2022-11-21 21:37:55 +05:00
|
|
|
document.querySelector("#" + elementId + " > td:nth-child(1) > button").setAttribute("disabled", "true")
|
2022-11-20 14:44:03 +05:00
|
|
|
} else {
|
2022-11-21 21:37:55 +05:00
|
|
|
document.querySelector("#" + elementId + " > td:nth-child(1) > button").removeAttribute("disabled")
|
2022-11-20 14:44:03 +05:00
|
|
|
}
|
|
|
|
|
2022-11-21 21:37:55 +05:00
|
|
|
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
|
2022-11-20 14:44:03 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
function startJob(jobName) {
|
|
|
|
socket.send(JSON.stringify({
|
|
|
|
jobName
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
</script>
|
2022-03-30 21:06:55 +05:00
|
|
|
|
|
|
|
</html>
|