Require password to access logs page

This commit is contained in:
Peter Stockings
2025-12-23 23:16:56 +11:00
parent dc20afd0f3
commit 45bee0504b
5 changed files with 501 additions and 101 deletions

261
templates/logs.html Normal file
View File

@@ -0,0 +1,261 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Logs - DokkuStatus</title>
<link rel="icon"
href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='0.9em' font-size='90'>⚡</text></svg>" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap"
rel="stylesheet">
<style>
* {
box-sizing: border-box;
}
body {
font-family: 'JetBrains Mono', monospace;
margin: 0;
padding: 0;
background: #0a0e17;
min-height: 100vh;
color: #c9d1d9;
}
.container {
max-width: 1600px;
margin: 0 auto;
padding: 20px;
}
.header-terminal {
background: #161b22;
border: 2px solid #00d9ff;
box-shadow: 0 0 20px rgba(0, 217, 255, 0.3);
padding: 20px 24px;
margin-bottom: 20px;
display: flex;
justify-content: space-between;
align-items: center;
}
h1 {
margin: 0;
font-size: 24px;
font-weight: 700;
color: #00d9ff;
text-transform: uppercase;
letter-spacing: 1px;
}
.logout-btn {
background: rgba(255, 85, 85, 0.1);
border: 1px solid #ff5555;
color: #ff5555;
padding: 6px 16px;
text-decoration: none;
font-size: 10px;
font-weight: 700;
letter-spacing: 1px;
transition: all 0.2s ease;
display: inline-block;
}
.logout-btn:hover {
background: rgba(255, 85, 85, 0.2);
}
.refresh-btn {
background: rgba(0, 255, 136, 0.1);
border: 1px solid #00ff88;
color: #00ff88;
padding: 6px 16px;
text-decoration: none;
font-size: 10px;
font-weight: 700;
letter-spacing: 1px;
transition: all 0.2s ease;
display: inline-block;
cursor: pointer;
margin-right: 12px;
}
.refresh-btn:hover {
background: rgba(0, 255, 136, 0.2);
box-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}
h2 {
font-size: 16px;
font-weight: 700;
letter-spacing: 2px;
color: #00d9ff;
margin: 0 0 16px 0;
text-transform: uppercase;
padding-left: 12px;
border-left: 3px solid #00ff88;
}
.log-card {
border: 2px solid #30363d;
margin-bottom: 16px;
background: rgba(0, 217, 255, 0.02);
}
.log-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 16px;
cursor: pointer;
background: rgba(0, 0, 0, 0.2);
}
.log-header:hover {
background: rgba(0, 217, 255, 0.05);
}
.app-name {
font-weight: 700;
color: #00d9ff;
}
.expand-btn {
background: rgba(0, 217, 255, 0.1);
border: 1px solid #00d9ff;
color: #00d9ff;
padding: 4px 12px;
font-size: 10px;
font-weight: 700;
cursor: pointer;
pointer-events: none;
}
.log-content {
display: none;
border-top: 2px solid #30363d;
padding: 16px;
background: #0a0e17;
}
.log-controls {
display: flex;
justify-content: space-between;
margin-bottom: 12px;
}
.log-title {
color: #00d9ff;
font-size: 10px;
font-weight: 700;
letter-spacing: 2px;
}
.copy-btn {
background: rgba(0, 255, 136, 0.1);
border: 1px solid #00ff88;
color: #00ff88;
padding: 4px 10px;
font-size: 10px;
font-weight: 700;
cursor: pointer;
transition: all 0.2s ease;
}
.copy-btn:hover {
background: rgba(0, 255, 136, 0.2);
}
.log-viewer {
background: #000;
border: 1px solid #30363d;
padding: 12px;
max-height: 500px;
overflow-y: auto;
font-size: 11px;
line-height: 1.6;
}
.log-line {
margin: 2px 0;
}
.log-error {
color: #ff5555;
}
.log-warn {
color: #ffb86c;
}
.log-info {
color: #8b949e;
}
</style>
</head>
<body>
<div class="container">
<div class="header-terminal">
<h1>[ APPLICATION LOGS ]</h1>
<div>
<button onclick="location.reload()" class="refresh-btn">[REFRESH]</button>
<a href="/logout" class="logout-btn">[LOGOUT]</a>
</div>
</div>
{% for r in data.apps %}
<div class="log-card">
<div class="log-header" onclick="toggleLogs('logs-{{ loop.index }}')">
<div class="app-name">[{{ r.app }}]</div>
<button class="expand-btn">[EXPAND]</button>
</div>
<div id="logs-{{ loop.index }}" class="log-content">
<div class="log-controls">
<div class="log-title">[LAST 50 LINES]</div>
<button class="copy-btn" onclick="event.stopPropagation(); copyLogs('logs-text-{{ loop.index }}')">
COPY
</button>
</div>
<div id="logs-text-{{ loop.index }}" class="log-viewer">
{% if r.logs %}
{% for log in r.logs %}
<div class="log-line log-{{ log.level }}">{{ log.text }}</div>
{% endfor %}
{% else %}
<div class="log-info">[no logs available]</div>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
<script>
function toggleLogs(id) {
const el = document.getElementById(id);
el.style.display = el.style.display === 'none' ? 'block' : 'none';
}
function copyLogs(id) {
const el = document.getElementById(id);
navigator.clipboard.writeText(el.innerText).then(() => {
const btn = event.target;
const orig = btn.textContent;
btn.textContent = 'COPIED!';
btn.style.background = 'rgba(0, 255, 136, 0.3)';
setTimeout(() => {
btn.textContent = orig;
btn.style.background = 'rgba(0, 255, 136, 0.1)';
}, 1500);
});
}
</script>
</body>
</html>