diff --git a/app/static/index.html b/app/static/index.html
index 5e04ca1..25796f5 100644
--- a/app/static/index.html
+++ b/app/static/index.html
@@ -63,6 +63,29 @@
Preleva
+
+
Log
@@ -143,6 +166,45 @@ async function withdraw() {
}
if (token) showDashboard();
+
+async function callAdmin(method, path, body) {
+ const adminToken = document.getElementById('admin-token').value;
+ const headers = { 'Content-Type': 'application/json', 'X-Admin-Token': adminToken };
+ const res = await fetch(path, { method, headers, body: body ? JSON.stringify(body) : undefined });
+ const data = await res.json().catch(() => ({}));
+ log({ request: method + ' ' + path, status: res.status, response: data });
+ if (!res.ok) throw new Error(data.detail || res.statusText);
+ return data;
+}
+
+function adminStatus(msg, ok) {
+ const el = document.getElementById('admin-status');
+ el.textContent = msg;
+ el.style.color = ok ? '#2a7a2a' : '#a02020';
+}
+
+async function adminLoad() {
+ try {
+ const data = await callAdmin('GET', '/admin/config');
+ document.getElementById('admin-fee-address').value = data.fee_address;
+ document.getElementById('admin-bet-amount').value = data.bet_amount_sats;
+ document.getElementById('admin-form').classList.remove('hidden');
+ adminStatus('Configurazione caricata.', true);
+ } catch (e) {
+ adminStatus('Errore: token admin non valido o server non raggiungibile.', false);
+ }
+}
+
+async function adminSave() {
+ const feeAddress = document.getElementById('admin-fee-address').value;
+ const betAmount = parseInt(document.getElementById('admin-bet-amount').value, 10);
+ try {
+ await callAdmin('PUT', '/admin/config', { fee_address: feeAddress, bet_amount_sats: betAmount });
+ adminStatus('Salvato.', true);
+ } catch (e) {
+ adminStatus('Errore nel salvataggio: ' + e.message, false);
+ }
+}