Alter 4 files
Update `selectSite.js` Update `submit.js` Update `index.html` Update `web.py`
This commit is contained in:
parent
b3946f752c
commit
caa8f92d65
4 changed files with 41 additions and 2 deletions
|
@ -4,6 +4,22 @@ const selectSiteBlock = document.getElementById("select_site");
|
||||||
const nextButton = document.getElementById("select_site__next_button")
|
const nextButton = document.getElementById("select_site__next_button")
|
||||||
const siteIDInput = document.getElementById("select_site__site_id_input")
|
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", () => {
|
nextButton.addEventListener("click", () => {
|
||||||
hide(errorIndicator)
|
hide(errorIndicator)
|
||||||
hide(selectSiteBlock)
|
hide(selectSiteBlock)
|
||||||
|
|
|
@ -4,6 +4,22 @@ const submitBlock = document.getElementById("submit")
|
||||||
const nextButton = document.getElementById("submit__next_button")
|
const nextButton = document.getElementById("submit__next_button")
|
||||||
const ntfyTopicInput = document.getElementById("submit__ntfy_topic")
|
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", () => {
|
nextButton.addEventListener("click", () => {
|
||||||
hide(errorIndicator)
|
hide(errorIndicator)
|
||||||
hide(submitBlock)
|
hide(submitBlock)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
<input type="text" class="form-control" id="select_site__site_id_input" placeholder="0000">
|
<input type="text" class="form-control" id="select_site__site_id_input" placeholder="0000">
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="btn btn-primary" id="select_site__next_button">Next</button>
|
<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>
|
||||||
|
|
||||||
<div id="select_machine" style="display:none;">
|
<div id="select_machine" style="display:none;">
|
||||||
|
|
|
@ -195,10 +195,10 @@ def _api_run_watcher() -> Union[any, Tuple[any, int]]:
|
||||||
completed_items.append(i)
|
completed_items.append(i)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if target_machine.state == MachineState.Completed:
|
if target_machine.state == MachineState.Completed or target_machine.state == MachineState.Available:
|
||||||
requests.post(
|
requests.post(
|
||||||
f"https://ntfy.sh/{ws.ntfy_topic}",
|
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={
|
headers={
|
||||||
"Title": (
|
"Title": (
|
||||||
"Washing"
|
"Washing"
|
||||||
|
@ -219,3 +219,9 @@ def _api_run_watcher() -> Union[any, Tuple[any, int]]:
|
||||||
job_lock.release()
|
job_lock.release()
|
||||||
|
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
|
|
||||||
|
def _first_letter_upper(x: str) -> str:
|
||||||
|
if len(x) == 0:
|
||||||
|
return ""
|
||||||
|
return x[0].upper() + x[1:]
|
||||||
|
|
Reference in a new issue