Alter 4 files

Update `selectSite.js`
Update `submit.js`
Update `index.html`
Update `web.py`
This commit is contained in:
akp 2022-11-09 00:13:22 +00:00
parent b3946f752c
commit caa8f92d65
No known key found for this signature in database
GPG key ID: AA5726202C8879B7
4 changed files with 41 additions and 2 deletions

View file

@ -4,6 +4,22 @@ const selectSiteBlock = document.getElementById("select_site");
const nextButton = document.getElementById("select_site__next_button")
const siteIDInput = document.getElementById("select_site__site_id_input")
siteIDInput.addEventListener("change", () => {
if (siteIDInput.value.trim() === "") {
localStorage.removeItem("site")
} else {
localStorage.setItem("site", siteIDInput.value.trim())
}
})
document.addEventListener("load", () => {
const x = localStorage.getItem("site")
if (x === undefined) {
return
}
siteIDInput.value = x
})
nextButton.addEventListener("click", () => {
hide(errorIndicator)
hide(selectSiteBlock)

View file

@ -4,6 +4,22 @@ const submitBlock = document.getElementById("submit")
const nextButton = document.getElementById("submit__next_button")
const ntfyTopicInput = document.getElementById("submit__ntfy_topic")
ntfyTopicInput.addEventListener("change", () => {
if (ntfyTopicInput.value.trim() === "") {
localStorage.removeItem("ntfy_topic")
} else {
localStorage.setItem("ntfy_topic", ntfyTopicInput.value.trim())
}
})
document.addEventListener("load", () => {
const x = localStorage.getItem("ntfy_topic")
if (x === undefined) {
return
}
ntfyTopicInput.value = x
})
nextButton.addEventListener("click", () => {
hide(errorIndicator)
hide(submitBlock)

View file

@ -27,6 +27,7 @@
<input type="text" class="form-control" id="select_site__site_id_input" placeholder="0000">
</div>
<button type="button" class="btn btn-primary" id="select_site__next_button">Next</button>
<p class="pt-2">You can find the Circuit site ID by going to <a href="https://www.circuit.co.uk/circuit-view" target="_blank">this page</a>, and selecting your accommodation. The site ID is the four digit number at the end of the URL.</p>
</div>
<div id="select_machine" style="display:none;">

View file

@ -195,10 +195,10 @@ def _api_run_watcher() -> Union[any, Tuple[any, int]]:
completed_items.append(i)
continue
if target_machine.state == MachineState.Completed:
if target_machine.state == MachineState.Completed or target_machine.state == MachineState.Available:
requests.post(
f"https://ntfy.sh/{ws.ntfy_topic}",
data=f"{target_machine.type} {target_machine.number} is finished!",
data=f"{_first_letter_upper(target_machine.type.value.lower())} {target_machine.number} is finished!",
headers={
"Title": (
"Washing"
@ -219,3 +219,9 @@ def _api_run_watcher() -> Union[any, Tuple[any, int]]:
job_lock.release()
return "", 204
def _first_letter_upper(x: str) -> str:
if len(x) == 0:
return ""
return x[0].upper() + x[1:]