Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions demo/static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function render(state) {
<small>${r.method} · cap ${stroops(r.max_spend_per_period)} (${xlm(r.max_spend_per_period)}) · max ${r.max_calls_per_period} calls</small>
</article>`
)
.join("");
.join("") || `<p class="empty">No policy rules installed.</p>`;

$("market").innerHTML = (state.resources || [])
.map(
Expand All @@ -98,7 +98,7 @@ function render(state) {
<small>${r.price} stroops / call · ${xlm(r.price)}</small>
</article>`
)
.join("");
.join("") || `<p class="empty">Marketplace is empty.</p>`;

$("bars").innerHTML = (state.rules || [])
.map(
Expand All @@ -107,15 +107,15 @@ function render(state) {
<div class="bar"><i style="width:${Math.min(100, r.used_pct)}%"></i></div>
</div>`
)
.join("");
.join("") || `<p class="empty">No spend yet this period.</p>`;

$("audit").innerHTML = (state.audit || [])
.map((e) => {
const cls = e.decision === "denied" ? "denied" : "approved";
const extra = e.tx_hash ? ` tx ${e.tx_hash}` : "";
return `<div class="row ${cls}"><span>${e.decision} · ${e.reason} · ${e.resource_id || "policy"} · ${e.amount} · rem ${e.remaining}${extra}</span><time>${relTime(e.ts)}</time></div>`;
})
.join("");
.join("") || `<p class="empty">No auth_decision events yet.</p>`;
}

async function refresh() {
Expand Down Expand Up @@ -173,6 +173,9 @@ async function pay(id) {
$("discover").onclick = discover;
$("budget-btn").onclick = budget;
$("reset").onclick = async () => {
if (!window.confirm("Reset the live pitch demo? Current spend and audit events will be wiped.")) {
return;
}
await api("/api/reset", { method: "POST" });
consoleEl.innerHTML = "";
$("script").innerHTML = "Demo reset. Policy regenerated from 75 synthetic transactions.";
Expand Down
2 changes: 1 addition & 1 deletion demo/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ input {
.err { color: var(--deny); }
.dim { color: var(--muted); }

.cards { display: flex; flex-direction: column; gap: 8px; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 0; }
.card {
border: 1px solid var(--line);
border-radius: 10px;
Expand Down
12 changes: 12 additions & 0 deletions demo/tests/test_empty_reset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]


def test_empty_states_and_reset_confirm():
js = (ROOT / "static" / "app.js").read_text(encoding="utf-8")
css = (ROOT / "static" / "styles.css").read_text(encoding="utf-8")
assert "No auth_decision events yet." in js
assert "Marketplace is empty." in js
assert "window.confirm" in js
assert ".empty" in css
Loading