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