From 524d9b9c95c7d99eedda52efece1fb1f317e89ef Mon Sep 17 00:00:00 2001 From: Protocolbot Date: Mon, 6 Jul 2026 15:28:21 -0600 Subject: [PATCH] feat: add 'Load seed protocols' button on About page for admins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No curl needed — admins can now load the 6 example protocols directly from the About page with a single click. --- frontend/app.js | 22 +++++++++++++++++++++- frontend/index.html | 7 +++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/frontend/app.js b/frontend/app.js index 2dd0956..5b83855 100755 --- a/frontend/app.js +++ b/frontend/app.js @@ -100,7 +100,7 @@ function navigate(view) { if (view === 'collections') { location.hash = 'collections'; loadCollections(); } if (view === 'create') { editingSlug = null; resetForm(); } if (view === 'create-collection') { editingCollectionSlug = null; resetCollectionForm(); } - if (view === 'about') { location.hash = 'about'; } + if (view === 'about') { location.hash = 'about'; updateAboutPage(); } window.scrollTo(0, 0); } @@ -821,6 +821,26 @@ async function showUser(username) { } } +// --- About page --- +function updateAboutPage() { + var section = document.getElementById('seedSection'); + if (!section) return; + section.style.display = (currentUser && currentUser.role === 'admin') ? 'block' : 'none'; +} + +async function loadSeedProtocols() { + var btn = document.getElementById('seedBtn'); + if (btn) { btn.disabled = true; btn.textContent = 'Loading...'; } + try { + var result = await api('/seed', { method: 'POST' }); + toast('Loaded ' + result.imported + ' seed protocols'); + if (btn) { btn.textContent = 'Loaded ' + result.imported + ' protocols'; btn.disabled = true; } + } catch (e) { + toast(e.message, true); + if (btn) { btn.disabled = false; btn.textContent = 'Load seed protocols'; } + } +} + // --- Toast --- let toastTimer = null; function toast(msg, isError) { diff --git a/frontend/index.html b/frontend/index.html index d2c19b4..20d750a 100755 --- a/frontend/index.html +++ b/frontend/index.html @@ -87,6 +87,13 @@

License

Hippocratic License (HL3-CORE) — do no harm. See firstdonoharm.dev. Source code available on Gitea.

+