added page to main
This commit is contained in:
parent
81018b8aba
commit
950ae0a4e9
33
main.go
33
main.go
|
|
@ -2287,7 +2287,38 @@ func apiAlarms(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
func serveUI(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path == "/" {
|
||||
// Parse and execute template with config data
|
||||
// Check license before serving the UI
|
||||
if licenseMgr != nil {
|
||||
status := licenseMgr.Status()
|
||||
if status.Locked {
|
||||
// Serve fallback activation page when locked
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
fmt.Fprintf(w, `<!doctype html>
|
||||
<html><head><meta charset="utf-8"><title>Force Monitor — License Required</title>
|
||||
<style>body{font-family:Segoe UI,Arial,sans-serif;background:#0f172a;color:#e2e8f0;margin:0;padding:32px} .card{max-width:760px;margin:0 auto;background:#111827;padding:24px;border-radius:16px} code,pre{background:#020617;padding:10px;border-radius:12px;display:block;white-space:pre-wrap} button{padding:10px 16px;border-radius:10px;border:0;background:#2563eb;color:#fff;cursor:pointer} textarea{width:100%%;min-height:180px;border-radius:12px;padding:12px;background:#020617;color:#e2e8f0;border:1px solid #334155}</style></head>
|
||||
<body><div class="card"><h1>Force Monitor</h1><p><strong>Machine fingerprint:</strong> %s</p>
|
||||
<p><strong>License mode:</strong> %s</p>
|
||||
<p><strong>Message:</strong> %s</p>
|
||||
<p><a href="/api/license/status" style="color:#93c5fd">GET /api/license/status</a></p>
|
||||
<p><a href="/api/license/request" style="color:#93c5fd">GET /api/license/request</a></p>
|
||||
<h3>Paste signed license JSON</h3>
|
||||
<textarea id="licenseText" placeholder='{"app":"force_monitor",...}'></textarea>
|
||||
<div style="margin-top:12px"><button onclick="activate()">Activate license</button></div>
|
||||
<pre id="out"></pre>
|
||||
<script>
|
||||
async function activate(){
|
||||
const t = document.getElementById('licenseText').value;
|
||||
const res = await fetch('/api/license/activate', {method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({license_text:t})});
|
||||
const j = await res.json().catch(() => ({}));
|
||||
document.getElementById('out').textContent = JSON.stringify(j, null, 2);
|
||||
if(j.status === 'activated') setTimeout(() => location.reload(), 800);
|
||||
}
|
||||
</script></div></body></html>`, status.FingerprintShort, status.Mode, status.Message)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// License OK — serve the full dashboard template
|
||||
tmpl, err := template.ParseFiles(filepath.Join("static", "index.html"))
|
||||
if err != nil {
|
||||
log.Printf("template parse error: %v", err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue