summaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'frontend')
-rw-r--r--frontend/index.html2
-rw-r--r--frontend/main.js2
-rw-r--r--frontend/start/index.html2
-rw-r--r--frontend/status/index.html6
-rw-r--r--frontend/style.css1
-rw-r--r--frontend/sw.js40
-rw-r--r--frontend/timer/index.html7
7 files changed, 51 insertions, 9 deletions
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>