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:
+21
-1
@@ -100,7 +100,7 @@ function navigate(view) {
|
|||||||
if (view === 'collections') { location.hash = 'collections'; loadCollections(); }
|
if (view === 'collections') { location.hash = 'collections'; loadCollections(); }
|
||||||
if (view === 'create') { editingSlug = null; resetForm(); }
|
if (view === 'create') { editingSlug = null; resetForm(); }
|
||||||
if (view === 'create-collection') { editingCollectionSlug = null; resetCollectionForm(); }
|
if (view === 'create-collection') { editingCollectionSlug = null; resetCollectionForm(); }
|
||||||
if (view === 'about') { location.hash = 'about'; }
|
if (view === 'about') { location.hash = 'about'; updateAboutPage(); }
|
||||||
window.scrollTo(0, 0);
|
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 ---
|
// --- Toast ---
|
||||||
let toastTimer = null;
|
let toastTimer = null;
|
||||||
function toast(msg, isError) {
|
function toast(msg, isError) {
|
||||||
|
|||||||
@@ -87,6 +87,13 @@
|
|||||||
<h2>License</h2>
|
<h2>License</h2>
|
||||||
<p class="outcome">Hippocratic License (HL3-CORE) — do no harm. See <a href="https://firstdonoharm.dev/" target="_blank">firstdonoharm.dev</a>. Source code available on <a href="https://git.medlab.host/ntnsndr/protocol-droid" target="_blank">Gitea</a>.</p>
|
<p class="outcome">Hippocratic License (HL3-CORE) — do no harm. See <a href="https://firstdonoharm.dev/" target="_blank">firstdonoharm.dev</a>. Source code available on <a href="https://git.medlab.host/ntnsndr/protocol-droid" target="_blank">Gitea</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="detail-section" id="seedSection" style="display:none">
|
||||||
|
<h2>Seed protocols</h2>
|
||||||
|
<p class="outcome">Load a starter set of 6 example protocols (Round Robin Check-In, Consent Decision-Making, Appreciative Apology, Temperature Reading, Dot Voting, Fishbowl Discussion) into your library.</p>
|
||||||
|
<div class="actions">
|
||||||
|
<button class="btn primary" id="seedBtn" onclick="loadSeedProtocols()">Load seed protocols</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- PROTOCOL DETAIL VIEW -->
|
<!-- PROTOCOL DETAIL VIEW -->
|
||||||
|
|||||||
Reference in New Issue
Block a user