Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99d7e8f121 | ||
|
|
8f82000e31 | ||
|
|
089ee6916f |
+1347
-368
File diff suppressed because it is too large
Load Diff
+7
-4
@@ -53,10 +53,13 @@
|
|||||||
<button id="btn-load" type="button" class="ghost-btn">Load</button>
|
<button id="btn-load" type="button" class="ghost-btn">Load</button>
|
||||||
<input id="file-load" type="file" accept="application/json" />
|
<input id="file-load" type="file" accept="application/json" />
|
||||||
<button id="btn-save" type="button" class="ghost-btn">Download</button>
|
<button id="btn-save" type="button" class="ghost-btn">Download</button>
|
||||||
<button id="btn-admin" type="button" class="ghost-btn hidden">
|
<details class="account-menu">
|
||||||
Admin
|
<summary class="ghost-btn">Account</summary>
|
||||||
</button>
|
<div class="account-menu-popover">
|
||||||
<button id="btn-logout" type="button" class="ghost-btn">Log out</button>
|
<a id="menu-admin" class="hidden" href="/admin">Admin</a>
|
||||||
|
<button id="btn-logout" type="button">Log out</button>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
<button id="btn-print" type="button" class="primary-btn">Print</button>
|
<button id="btn-print" type="button" class="primary-btn">Print</button>
|
||||||
<span class="autosave-chip" id="autosave-status"
|
<span class="autosave-chip" id="autosave-status"
|
||||||
><span class="dot"></span
|
><span class="dot"></span
|
||||||
|
|||||||
+3
-13
@@ -595,7 +595,7 @@ function wireToolbar() {
|
|||||||
await protectedFetch("/api/auth/logout", { method: "POST" });
|
await protectedFetch("/api/auth/logout", { method: "POST" });
|
||||||
} finally {
|
} finally {
|
||||||
clearDraft();
|
clearDraft();
|
||||||
location.assign("/");
|
location.replace("/");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.getElementById("btn-add-actuator").addEventListener("click", () => {
|
document.getElementById("btn-add-actuator").addEventListener("click", () => {
|
||||||
@@ -664,6 +664,8 @@ async function init() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { user } = await meResponse.json();
|
const { user } = await meResponse.json();
|
||||||
|
if (user.role === "admin")
|
||||||
|
document.getElementById("menu-admin").classList.remove("hidden");
|
||||||
state.plan = loadFromStorage(user.id) ?? blankPlan();
|
state.plan = loadFromStorage(user.id) ?? blankPlan();
|
||||||
const response = await fetch("/api/plans");
|
const response = await fetch("/api/plans");
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
@@ -687,18 +689,6 @@ async function init() {
|
|||||||
wireToolbar();
|
wireToolbar();
|
||||||
wirePwa();
|
wirePwa();
|
||||||
wireSectionNav();
|
wireSectionNav();
|
||||||
fetch("/api/auth/me")
|
|
||||||
.then((r) => (r.ok ? r.json() : null))
|
|
||||||
.then((body) => {
|
|
||||||
if (body?.user?.role === "admin") {
|
|
||||||
const button = document.getElementById("btn-admin");
|
|
||||||
button.classList.remove("hidden");
|
|
||||||
button.onclick = () => {
|
|
||||||
location.href = "/admin";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(() => {});
|
|
||||||
initPrefillPanel({
|
initPrefillPanel({
|
||||||
state,
|
state,
|
||||||
renderBlendRows: renderBlend,
|
renderBlendRows: renderBlend,
|
||||||
|
|||||||
+5
-6
@@ -1,4 +1,4 @@
|
|||||||
const CACHE_NAME = "roast-planner-static-v2";
|
const CACHE_NAME = "roast-planner-static-v3";
|
||||||
const APP_SHELL = [
|
const APP_SHELL = [
|
||||||
"/",
|
"/",
|
||||||
"/landing.html",
|
"/landing.html",
|
||||||
@@ -64,9 +64,10 @@ self.addEventListener("fetch", (event) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prefer fresh JavaScript and styles so installed clients receive UI/security updates
|
||||||
|
// immediately; use the cache only when offline.
|
||||||
event.respondWith(
|
event.respondWith(
|
||||||
caches.match(request).then((cached) => {
|
fetch(request)
|
||||||
const update = fetch(request)
|
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.ok)
|
if (response.ok)
|
||||||
caches
|
caches
|
||||||
@@ -74,8 +75,6 @@ self.addEventListener("fetch", (event) => {
|
|||||||
.then((cache) => cache.put(request, response.clone()));
|
.then((cache) => cache.put(request, response.clone()));
|
||||||
return response;
|
return response;
|
||||||
})
|
})
|
||||||
.catch(() => cached);
|
.catch(() => caches.match(request)),
|
||||||
return cached ?? update;
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user