diff options
| author | altaf-creator <dev@altafcreator.com> | 2026-01-16 20:34:35 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2026-01-16 20:34:35 +0800 |
| commit | 82ea96facb47eaa7f033ca094c8caf21d082480f (patch) | |
| tree | 60f6b26302577870029384dba2d59e1db166fa81 | |
| parent | 83c5deaa22742bce41ae38d9730fc4b5dd63eecf (diff) | |
enhancements
| -rw-r--r-- | backend/main.py | 4 | ||||
| -rw-r--r-- | frontend/index.html | 2 | ||||
| -rw-r--r-- | frontend/main.js | 2 | ||||
| -rw-r--r-- | frontend/start/index.html | 2 | ||||
| -rw-r--r-- | frontend/status/index.html | 6 | ||||
| -rw-r--r-- | frontend/style.css | 1 | ||||
| -rw-r--r-- | frontend/sw.js | 40 | ||||
| -rw-r--r-- | frontend/timer/index.html | 7 |
8 files changed, 54 insertions, 10 deletions
diff --git a/backend/main.py b/backend/main.py index 8dc6470..c42e83f 100644 --- a/backend/main.py +++ b/backend/main.py @@ -216,7 +216,9 @@ def final_timer_finished(timer_id): out[0][RowIndices.SUBSCRIPTION_ID], { "title": "Laundry Finished", - "body": "Do collect your laundry, then press this notification to mark your laundry as collected.", + "body": "Your laundry is finished! Please collect your laundry.", + "requireInteraction": True, + "timerId": timer_id, } ) diff --git a/frontend/index.html b/frontend/index.html index f40c70c..83cb79a 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -5,7 +5,7 @@ <link rel="stylesheet" href="./style.css" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="manifest" href="/manifest.json" /> - <title>Victoria Hall LaundryWeb</title> + <title>LaundryWeb</title> </head> <body> <div class="section-container row bg-1" style="height: 164px;"> diff --git a/frontend/main.js b/frontend/main.js index bfbb1ec..41da70f 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -47,7 +47,7 @@ async function subscribe() { console.log(db_reply) - return db_reply.status == 200; + return db_reply.ok; } catch (e) { console.log("ERR in regis, ", e); return false; diff --git a/frontend/start/index.html b/frontend/start/index.html index c52fce1..426fb79 100644 --- a/frontend/start/index.html +++ b/frontend/start/index.html @@ -5,7 +5,7 @@ <link rel="stylesheet" href="/style.css"> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="manifest" href="/manifest.json" /> - <title>Victoria Hall LaundryWeb</title> + <title>LaundryWeb</title> </head> <body> <div class="section-container row bg-1" style="height: 164px;"> diff --git a/frontend/status/index.html b/frontend/status/index.html index 97c5504..b4c3fff 100644 --- a/frontend/status/index.html +++ b/frontend/status/index.html @@ -5,7 +5,7 @@ <link rel="stylesheet" href="/style.css"> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="manifest" href="/manifest.json" /> - <title>Victoria Hall LaundryWeb</title> + <title>LaundryWeb</title> </head> <body> <style> @@ -17,6 +17,10 @@ <span id="logo">Victoria Hall<br>LaundryWeb</span> <span id="logo-id">H?</span> </div> + <div class="section-container row bg-2" style="padding: 8px; gap: 8px;"> + <button class="button button-tab bg-3" onclick="window.location.href = '/timer/'">Timer</button> + <button class="button button-tab bg-3" disabled>Status</button> + </div> <div class="section-container row bg-red" id="notif-panel"> <div class="flex-center-container"> <span class="icon">🔔</span> diff --git a/frontend/style.css b/frontend/style.css index 6973278..8b53636 100644 --- a/frontend/style.css +++ b/frontend/style.css @@ -92,6 +92,7 @@ body { border-radius: 48px; border: none; cursor: pointer; + color: black; } .button:hover:not(:disabled) { diff --git a/frontend/sw.js b/frontend/sw.js index f0ba7d8..bd38341 100644 --- a/frontend/sw.js +++ b/frontend/sw.js @@ -2,7 +2,41 @@ self.addEventListener('push', (e) => { console.log(e.data); const data = e.data.json(); console.log(data); - self.registration.showNotification(data.title, { - body: data.body, - }); + if (data.requireInteraction) { + self.registration.showNotification(data.title, { + body: data.body, + vibrate: [200, 100, 200], + requireInteraction: data.requireInteraction, + actions: [ + { + title: "I've collected my laundry!", + action: "collect", + } + ], + data: {timerId: data.timerId}, + }); + } else { + self.registration.showNotification(data.title, { + body: data.body, + vibrate: [200, 100, 200], + }); + } +}); + +self.addEventListener("notificationclick", (event) => { + if (event.action === "collect") { + timerId = event.data.timerId; + console.log("finishing timer! w/ id "+timerId.toString()); + fetch(`${API_URL}/finish`, { + method: "POST", + credentials: "include", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({id: timerId}), + }); + clients.openWindow("/timer/"); + } else { + clients.openWindow("/timer/"); + } }); diff --git a/frontend/timer/index.html b/frontend/timer/index.html index 7972c78..3ddf5b1 100644 --- a/frontend/timer/index.html +++ b/frontend/timer/index.html @@ -5,7 +5,7 @@ <link rel="stylesheet" href="/style.css"> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="manifest" href="/manifest.json" /> - <title>Victoria Hall LaundryWeb</title> + <title>LaundryWeb</title> </head> <body> <div class="section-container row bg-1" style="height: 164px;"> @@ -16,7 +16,10 @@ <button class="button button-tab bg-3" disabled>Timer</button> <button class="button button-tab bg-3" onclick="window.location.href = '/status/'">Status</button> </div> - <div id="timer-container" class="section-container no-pad"></div> + <div id="timer-container" class="section-container no-pad"> + <img src="/assets/img/washer_off.png" alt="" style="width: 2rem; margin-top: 3rem; margin-right: auto; margin-left: auto; opacity: .5;"> + <span style="opacity: .5; margin-top: .5rem; margin-bottom: 2rem; display: block;">You currently don't have any laundry.</span> + </div> <div class="section-container credits-container"> <span>Developed by <a href="https://altafcreator.com">Athaalaa Altaf Hafidz</a>, a fellow resident • <a href="https://git.altafcreator.com/victoriahall-laundryweb.git/">Source Code</a></span> </div> |
