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>
|
||||
<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
@@ -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,
|
||||
|
||||
+12
-13
@@ -1,4 +1,4 @@
|
||||
const CACHE_NAME = "roast-planner-static-v2";
|
||||
const CACHE_NAME = "roast-planner-static-v3";
|
||||
const APP_SHELL = [
|
||||
"/",
|
||||
"/landing.html",
|
||||
@@ -64,18 +64,17 @@ 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)
|
||||
.then((response) => {
|
||||
if (response.ok)
|
||||
caches
|
||||
.open(CACHE_NAME)
|
||||
.then((cache) => cache.put(request, response.clone()));
|
||||
return response;
|
||||
})
|
||||
.catch(() => cached);
|
||||
return cached ?? update;
|
||||
}),
|
||||
fetch(request)
|
||||
.then((response) => {
|
||||
if (response.ok)
|
||||
caches
|
||||
.open(CACHE_NAME)
|
||||
.then((cache) => cache.put(request, response.clone()));
|
||||
return response;
|
||||
})
|
||||
.catch(() => caches.match(request)),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user