blind-monkeys / templates /admin_alerts.html
deanpowers's picture
Sync workspace source: rank tracker module + routes, Grid DB admin page, flaskfactory AI probe + analytics zone, nav.js v16 Blog pill, template refresh
c8c30b4
Raw History Blame Contribute Delete
7.89 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>πŸ”” Coin Alerts β€” Admin</title>
<link rel="stylesheet" href="/css/nav.css?v=4">
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
<style>
* { box-sizing: border-box; }
body { background: #0d1117; color: #e6edf3; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; margin: 0; }
.page-content { max-width: 1100px; margin: 0 auto; padding: 32px 20px; }
h1 { font-size: 24px; margin: 0 0 4px; }
.sub { color: #8b949e; font-size: 14px; margin-bottom: 24px; }
.card { background: #1e2329; border: 2px solid #30363d; border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.card h2 { font-size: 14px; color: #f0b90b; margin: 0 0 16px; letter-spacing: 1px; text-transform: uppercase; }
.field { margin-bottom: 14px; }
.field label { display: block; color: #8b949e; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.field input, .field select { width: 100%; padding: 9px 12px; border-radius: 6px; border: 1px solid #30363d; background: #0d1117; color: #e6edf3; font-size: 13px; font-family: inherit; }
.field input:focus, .field select:focus { outline: none; border-color: #f0b90b; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.btn-primary { padding: 10px 20px; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; border: none; background: #f0b90b; color: #0b0e11; font-family: inherit; }
.btn-primary:hover { background: #d9a70a; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-mini { padding: 5px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; cursor: pointer; border: 1px solid #30363d; background: transparent; color: #8b949e; font-family: inherit; }
.btn-mini:hover { border-color: #f0b90b; color: #f0b90b; }
.btn-danger:hover { border-color: #f87171; color: #f87171; }
.err { color: #f87171; font-size: 12px; margin-top: 8px; display: none; }
.err.show { display: block; }
.hint { color: #484f58; font-size: 11px; margin-top: 4px; }
</style>
</head>
<body>
<nav class="nav-bar">
<div class="nav-brand">πŸ™ˆ Blind Monkeys</div>
<div class="nav-links">
<a href="/" class="nav-link">🏠 Home</a>
<a href="/scan/" class="nav-link">πŸ” Scan</a>
<a href="/settings/" class="nav-link">βš™οΈ Settings</a>
</div>
</nav>
<div class="page-content">
<h1>πŸ”” Coin Alerts</h1>
<div class="sub">Set thresholds and delivery for high-score coin alerts</div>
<div class="card">
<div class="row3">
<div class="field"><label>Master Enable</label>
<select id="ac-enabled"><option value="1">On</option><option value="0">Off</option></select></div>
<div class="field"><label>Telegram</label>
<select id="ac-telegram"><option value="1">Send</option><option value="0">Silent</option></select></div>
<div class="field"><label>In-App Banner</label>
<select id="ac-banner"><option value="1">Show</option><option value="0">Hide</option></select></div>
</div>
<div class="row2">
<div class="field"><label>Conservative Scan</label>
<select id="ac-cons-enabled"><option value="1">Enabled</option><option value="0">Disabled</option></select></div>
<div class="field"><label>Conservative Threshold</label>
<input id="ac-cons-threshold" type="number" min="0" max="500" step="1"></div>
</div>
<div class="row2">
<div class="field"><label>Risk-Taker Scan</label>
<select id="ac-risk-enabled"><option value="1">Enabled</option><option value="0">Disabled</option></select></div>
<div class="field"><label>Risk-Taker Threshold</label>
<input id="ac-risk-threshold" type="number" min="0" max="500" step="1"></div>
</div>
<div class="row2">
<div class="field"><label>Quiet Hours Start (HH:MM)</label>
<input id="ac-qh-start" placeholder="22:00"><div class="hint">Blank = no quiet hours</div></div>
<div class="field"><label>Quiet Hours End (HH:MM)</label>
<input id="ac-qh-end" placeholder="07:00"></div>
</div>
<div class="err" id="ac-err"></div>
<div style="margin-top:16px;">
<button class="btn-primary" id="ac-save">Save Configuration</button>
<button class="btn-mini btn-danger" id="ac-clear" style="margin-left:8px;">Clear Alerts Log</button>
<span id="ac-status" style="margin-left:12px;color:#8b949e;font-size:12px;"></span>
</div>
</div>
</div>
<script>
(function(){
function $(id){return document.getElementById(id);}
function setSel(el,val){ el.value = val ? "1" : "0"; }
function load(){
fetch('/api/admin/alert-config', {cache:'no-store'}).then(function(r){return r.json();}).then(function(c){
if (c.error){ $('ac-err').textContent=c.error; $('ac-err').classList.add('show'); return; }
setSel($('ac-enabled'), c.enabled);
setSel($('ac-telegram'), c.telegram_enabled);
setSel($('ac-banner'), c.banner_enabled);
setSel($('ac-cons-enabled'), (c.conservative||{}).enabled);
setSel($('ac-risk-enabled'), (c.risk||{}).enabled);
$('ac-cons-threshold').value = (c.conservative||{}).threshold || 100;
$('ac-risk-threshold').value = (c.risk||{}).threshold || 100;
$('ac-qh-start').value = ((c.quiet_hours||{}).start) || '';
$('ac-qh-end').value = ((c.quiet_hours||{}).end) || '';
}).catch(function(e){ $('ac-err').textContent='Load failed: '+e.message; $('ac-err').classList.add('show'); });
}
$('ac-save').addEventListener('click', function(){
$('ac-err').classList.remove('show');
var body = {
enabled: $('ac-enabled').value === '1',
telegram_enabled: $('ac-telegram').value === '1',
banner_enabled: $('ac-banner').value === '1',
conservative: { enabled: $('ac-cons-enabled').value === '1', threshold: parseFloat($('ac-cons-threshold').value) || 100 },
risk: { enabled: $('ac-risk-enabled').value === '1', threshold: parseFloat($('ac-risk-threshold').value) || 100 },
quiet_hours: { start: $('ac-qh-start').value.trim(), end: $('ac-qh-end').value.trim() }
};
var b = this; b.disabled = true;
fetch('/api/admin/alert-config', {method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)})
.then(function(r){return r.json();})
.then(function(){ b.disabled = false; $('ac-status').textContent = 'Saved'; setTimeout(function(){$('ac-status').textContent='';},3000); })
.catch(function(e){ b.disabled = false; $('ac-err').textContent = e.message; $('ac-err').classList.add('show'); });
});
$('ac-clear').addEventListener('click', function(){
if (!confirm('Clear all alerts from the log and reset state?')) return;
fetch('/api/admin/alerts/clear', {method:'POST'})
.then(function(r){return r.json();})
.then(function(){ $('ac-status').textContent = 'Cleared'; setTimeout(function(){$('ac-status').textContent='';},3000); })
.catch(function(e){ $('ac-err').textContent = e.message; $('ac-err').classList.add('show'); });
});
load();
})();
</script>
<script src="/css/nav.js?v=16"></script>
<!--Start of Tawk.to Script-->
<script type="text/javascript">
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
(function(){
var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
s1.async=true;
s1.src='https://embed.tawk.to/6ad326872ab00434d21793a2/1k54ic9h0';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
</script>
<!--End of Tawk.to Script-->
</body>
</html>