Files
dune-dashboard/templates/base.html
T

198 lines
9.8 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Dune Awakening Server Dashboard{% endblock %}</title>
<meta name="csrf-token" content="{{ csrf_token() }}">
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='themes.css') }}">
</head>
<body>
<div id="update-banner" class="update-banner" style="display:none;">
<span>🔄 Update available for Dune Dashboard</span>
<div class="update-actions">
<button onclick="applyUpdate()" class="update-btn primary">Update Now</button>
<button onclick="dismissUpdate()" class="update-btn">Later</button>
</div>
</div>
<nav>
<div class="brand">DUNE DASHBOARD</div>
{% for href, label in nav_pages %}
<a href="{{ href }}" class="{% if current_path == href %}active{% endif %}">{{ label }}</a>
{% endfor %}
<div class="spacer"></div>
<div class="theme-dropdown">
<button class="theme-btn" title="Theme">🎨</button>
<div class="theme-dropdown-content">
<div class="theme-option active" data-theme="default" onclick="setTheme('default')">
<span class="theme-swatch default"></span> Classic Dune
</div>
<div class="theme-option" data-theme="atreides" onclick="setTheme('atreides')">
<span class="theme-swatchatreides"></span> House Atreides
</div>
<div class="theme-option" data-theme="harkonnen" onclick="setTheme('harkonnen')">
<span class="theme-swatch harkonnen"></span> House Harkonnen
</div>
<div class="theme-option" data-theme="fremen" onclick="setTheme('fremen')">
<span class="theme-swatch fremen"></span> Fremen
</div>
<div class="theme-option" data-theme="bene-gesserit" onclick="setTheme('bene-gesserit')">
<span class="theme-swatch bene-gesserit"></span> Bene Gesserit
</div>
<div class="theme-option" data-theme="spacing-guild" onclick="setTheme('spacing-guild')">
<span class="theme-swatch spacing-guild"></span> Spacing Guild
</div>
<div class="theme-option" data-theme="emperor" onclick="setTheme('emperor')">
<span class="theme-swatch emperor"></span> Emperor
</div>
<div class="theme-option" data-theme="corrino" onclick="setTheme('corrino')">
<span class="theme-swatch corrino"></span> House Corrino
</div>
<div class="theme-option" data-theme="mentat" onclick="setTheme('mentat')">
<span class="theme-swatch mentat"></span> Mentat
</div>
<div class="theme-option" data-theme="sardaukar" onclick="setTheme('sardaukar')">
<span class="theme-swatch sardaukar"></span> Sardaukar
</div>
<div class="theme-option" data-theme="tleilax" onclick="setTheme('tleilax')">
<span class="theme-swatch tleilax"></span> Bene Tleilax
</div>
<div class="theme-option" data-theme="ordos" onclick="setTheme('ordos')">
<span class="theme-swatch ordos"></span> House Ordos
</div>
<div class="theme-option" data-theme="ix" onclick="setTheme('ix')">
<span class="theme-swatch ix"></span> Ix
</div>
<div class="theme-option" data-theme="choam" onclick="setTheme('choam')">
<span class="theme-swatch choam"></span> CHOAM
</div>
</div>
</div>
<span style="font-size:12px;color:var(--nav-text);display:flex;align-items:center;">
<span class="conn-dot {% if conn_ok %}online{% else %}offline{% endif %}"></span>
{{ 'Connected' if conn_ok else 'Disconnected' }}
</span>
<button id="check-update-btn" onclick="manualCheckUpdate()" style="font-size:12px;color:var(--nav-text);background:none;border:none;cursor:pointer;padding:4px 8px;" title="Check for updates">🔄 Check Updates</button>
{% if current_user and current_user.is_authenticated %}
<a href="/logout" style="font-size:12px;color:var(--nav-text);">Logout</a>
{% endif %}
</nav>
<main class="container">
{% block content %}{% endblock %}
</main>
<div id="update-progress" class="update-progress" style="display:none;">
<div class="update-progress-inner">
<h3>Updating Dashboard...</h3>
<p id="update-status-text">Checking for updates...</p>
<div class="update-spinner"></div>
</div>
</div>
<script>
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
async function csrfFetch(url, options = {}) {
options.headers = options.headers || {};
options.headers['X-CSRFToken'] = csrfToken;
return fetch(url, options);
}
let updateDismissed = false;
async function checkForUpdate() {
if (updateDismissed) return;
try {
const resp = await fetch('/api/update/status');
const data = await resp.json();
if (data.available) {
document.getElementById('update-banner').style.display = 'flex';
}
} catch (e) {}
}
async function manualCheckUpdate() {
const btn = document.getElementById('check-update-btn');
btn.textContent = 'Checking...';
btn.disabled = true;
try {
const resp = await csrfFetch('/api/update/check', { method: 'POST' });
const data = await resp.json();
if (data.available) {
document.getElementById('update-banner').style.display = 'flex';
btn.textContent = 'Update Available!';
} else {
btn.textContent = 'Up to Date ✓';
setTimeout(() => { btn.textContent = '🔄 Check Updates'; }, 3000);
}
} catch (e) {
btn.textContent = 'Check Failed';
setTimeout(() => { btn.textContent = '🔄 Check Updates'; }, 3000);
}
btn.disabled = false;
}
function dismissUpdate() {
updateDismissed = true;
document.getElementById('update-banner').style.display = 'none';
}
async function applyUpdate() {
const banner = document.getElementById('update-banner');
const progress = document.getElementById('update-progress');
const statusText = document.getElementById('update-status-text');
banner.style.display = 'none';
progress.style.display = 'flex';
try {
const resp = await csrfFetch('/api/update/apply', { method: 'POST' });
const data = await resp.json();
statusText.textContent = data.message || 'Applying update...';
if (data.success) {
statusText.textContent = 'Update complete! Restarting...';
setTimeout(() => { location.reload(); }, 5000);
} else {
statusText.textContent = 'Update failed: ' + (data.message || 'Unknown error');
setTimeout(() => { progress.style.display = 'none'; }, 5000);
}
} catch (e) {
statusText.textContent = 'Update failed: ' + e.message;
setTimeout(() => { progress.style.display = 'none'; }, 5000);
}
}
setInterval(checkForUpdate, 60000);
checkForUpdate();
// Theme System
function setTheme(themeName) {
document.documentElement.setAttribute('data-theme', themeName);
localStorage.setItem('dune-theme', themeName);
updateThemeUI(themeName);
}
function updateThemeUI(themeName) {
document.querySelectorAll('.theme-option').forEach(opt => {
opt.classList.remove('active');
if (opt.getAttribute('data-theme') === themeName) {
opt.classList.add('active');
}
});
}
function initTheme() {
const savedTheme = localStorage.getItem('dune-theme') || 'default';
document.documentElement.setAttribute('data-theme', savedTheme);
updateThemeUI(savedTheme);
}
initTheme();
</script>
{% block scripts %}{% endblock %}
<style>
.update-banner { background: var(--hover); border-bottom: 2px solid var(--accent); padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text); }
.update-actions { display: flex; gap: 8px; }
.update-btn { padding: 4px 12px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-card); color: var(--text); cursor: pointer; font-size: 12px; }
.update-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.update-progress { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.update-progress-inner { background: var(--bg-card); padding: 30px 40px; border-radius: 8px; text-align: center; color: var(--text); max-width: 400px; }
.update-progress-inner h3 { margin: 0 0 10px; }
.update-progress-inner p { margin: 0 0 15px; color: var(--text-muted); font-size: 13px; }
.update-spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
</style>
</body>
</html>