feat: add 'Load seed protocols' button on About page for admins

No curl needed — admins can now load the 6 example protocols
directly from the About page with a single click.
This commit is contained in:
Protocolbot
2026-07-06 15:28:21 -06:00
parent 385f68a1d7
commit 524d9b9c95
2 changed files with 28 additions and 1 deletions
+21 -1
View File
@@ -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) {