malp/assets/page.erb

421 lines
9.4 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= hostname %> status - MALP</title>
<style>
body {
background: #0f1117;
color: #e2e8f0;
font-family: 'Segoe UI', system-ui, sans-serif;
min-height: 100vh;
margin: 0;
padding: 2rem;
display: flex;
flex-direction: column;
align-items: center;
}
header {
width: 100%;
max-width: 400px;
text-align: center;
margin-bottom: 2rem;
padding-bottom: 1rem;
border-bottom: 1px solid #1e2433;
}
header h1 {
font-size: 1.4rem;
font-weight: 600;
letter-spacing: 0.05em;
color: #94a3b8;
text-transform: uppercase;
}
header h1 span { color: #e2e8f0; }
.card {
background: #161b27;
border-radius: 12px;
padding: 1rem 1.1rem;
border: 1px solid #1e2433;
transition: border-color 0.2s;
}
.card.auth {
padding: 2rem;
width: 100%;
max-width: 400px;
box-sizing: border-box;
}
.card-title {
font-size: 0.8rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.06em;
color: #94a3b8;
}
.card.auth .card-title {
margin-bottom: 1.5rem;
text-align: center;
}
#content {
align-self: stretch;
}
.form-group {
margin-bottom: 1rem;
}
label {
display: block;
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
color: #475569;
margin-bottom: 0.4rem;
}
input[type="text"],
input[type="password"] {
width: 100%;
box-sizing: border-box;
padding: 0.6rem 0.8rem;
background: #0f1117;
border: 1px solid #1e2433;
border-radius: 7px;
color: #e2e8f0;
font-family: inherit;
font-size: 0.9rem;
outline: none;
transition: border-color 0.2s;
}
input[type="text"]:focus,
input[type="password"]:focus {
border-color: #4ade80;
}
button {
width: 100%;
padding: 0.65rem;
margin-top: 0.5rem;
background: #14532d;
color: #4ade80;
border: none;
border-radius: 7px;
font-family: inherit;
font-size: 0.8rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.06em;
cursor: pointer;
transition: background 0.2s;
}
button:hover {
background: #166534;
}
.logout-form {
position: fixed;
top: 1rem;
right: 1rem;
}
.logout-btn {
width: auto;
padding: 0.4rem 0.8rem;
margin: 0;
background: #1e2433;
color: #94a3b8;
font-size: 0.75rem;
}
.logout-btn:hover {
background: #2a3040;
}
.spinner {
width: 24px;
height: 24px;
margin: 1rem auto;
border: 3px solid #1e2433;
border-top-color: #4ade80;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.last-updated {
font-size: 0.75rem;
color: #475569;
}
.overall-status {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.85rem;
font-weight: 600;
color: #4ade80;
}
.grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 1rem;
align-items: start;
}
@media (max-width: 1200px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .grid { grid-template-columns: 1fr; } }
/* span modifiers */
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.card:hover { border-color: #2d3748; }
.card.ok { border-left: 3px solid #22c55e; }
.card.warn { border-left: 3px solid #f59e0b; }
.card.bad { border-left: 3px solid #ef4444; }
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.badge {
font-size: 0.65rem;
font-weight: 700;
padding: 0.15rem 0.5rem;
border-radius: 999px;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.badge.ok { background: #14532d; color: #4ade80; }
.badge.warn { background: #451a03; color: #fbbf24; }
.badge.bad { background: #450a0a; color: #f87171; }
.card-value {
font-size: 1.6rem;
font-weight: 700;
line-height: 1.1;
margin-bottom: 0.15rem;
}
.card-value.ok { color: #4ade80; }
.card-value.warn { color: #fbbf24; }
.card-value.bad { color: #f87171; }
.card-sub {
font-size: 0.72rem;
color: #475569;
margin-bottom: 0.6rem;
}
/* progress bar */
.bar-track {
height: 4px;
background: #1e2433;
border-radius: 2px;
overflow: hidden;
margin-top: 0.5rem;
}
.bar-fill {
height: 100%;
border-radius: 2px;
transition: width 0.4s ease;
}
.bar-fill.ok { background: #22c55e; }
.bar-fill.warn { background: #f59e0b; }
.bar-fill.bad { background: #ef4444; }
/* subitems */
.subitems {
display: flex;
flex-direction: column;
gap: 0.45rem;
margin-top: 0.6rem;
}
.subitem {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.4rem 0.6rem;
background: #0f1117;
border-radius: 7px;
font-size: 0.78rem;
}
.subitem-left {
display: flex;
align-items: center;
gap: 0.45rem;
}
.dot {
width: 7px; height: 7px;
border-radius: 50%;
flex-shrink: 0;
}
.dot.ok { background: #22c55e; box-shadow: 0 0 5px #22c55e88; }
.dot.warn { background: #f59e0b; box-shadow: 0 0 5px #f59e0b88; }
.dot.bad { background: #ef4444; box-shadow: 0 0 5px #ef444488; }
.subitem-name { color: #cbd5e1; }
.subitem-value {
font-size: 0.72rem;
font-weight: 600;
}
.subitem-value.ok { color: #4ade80; }
.subitem-value.warn { color: #fbbf24; }
.subitem-value.bad { color: #f87171; }
/* drive capacity chip (shown inline in card title) */
.card-capacity {
display: inline-block;
font-size: 0.7rem;
font-weight: 600;
color: #cbd5e1;
background: #0f1117;
border: 1px solid #1e2433;
padding: 0.1rem 0.4rem;
border-radius: 4px;
margin-left: 0.4rem;
text-transform: none;
letter-spacing: 0;
font-variant-numeric: tabular-nums;
}
/* drive type badge */
.drive-type {
font-size: 0.6rem;
font-weight: 700;
padding: 0.1rem 0.35rem;
border-radius: 4px;
text-transform: uppercase;
letter-spacing: 0.05em;
margin-left: 0.35rem;
}
.drive-type.hdd { background: #1e3a5f; color: #60a5fa; }
.drive-type.ssd { background: #2d1b69; color: #a78bfa; }
.drive-type.nvme { background: #134e4a; color: #5eead4; }
/* per-drive health stats row */
.drive-stats {
display: flex;
flex-wrap: wrap;
gap: 0.3rem;
}
.stat {
font-size: 0.67rem;
font-weight: 600;
padding: 0.15rem 0.45rem;
border-radius: 5px;
}
.stat.ok { background: #0f2a1a; color: #4ade80; }
.stat.warn { background: #2d1a00; color: #fbbf24; }
.stat.bad { background: #2d0a0a; color: #f87171; }
/* uptime row */
.uptime-blocks {
display: flex;
gap: 2px;
margin-top: 0.5rem;
}
.uptime-block {
flex: 1;
height: 20px;
border-radius: 3px;
}
.uptime-block.ok { background: #22c55e; }
.uptime-block.bad { background: #ef4444; }
.uptime-block.warn { background: #f59e0b; }
.uptime-block.empty { background: #1e2433; }
.section-label {
font-size: 0.68rem;
color: #334155;
text-transform: uppercase;
letter-spacing: 0.08em;
margin: 1.5rem 0 0.5rem;
grid-column: 1 / -1;
}
</style>
</head>
<body>
<% if authenticated %>
<form method="post" class="logout-form">
<input type="hidden" name="action" value="logout">
<button type="submit" class="logout-btn">Log Out</button>
</form>
<% end %>
<header>
<h1><span><%= hostname %></span> status - MALP</h1>
</header>
<% if authenticated %>
<div id="content" class="grid"><div class="spinner"></div></div>
<script>
fetch("?content", { credentials: "same-origin" })
.then(function(response) {
if (response.ok) return response.text();
throw new Error();
})
.then(function(html) {
document.getElementById("content").innerHTML = html;
})
.catch(function() {
document.getElementById("content").innerHTML = "Error";
});
</script>
<% end %>
<% unless authenticated %>
<div class="card auth">
<div class="card-title">Sign In</div>
<form method="post">
<div class="form-group">
<label for="username">Username</label>
<input type="text" id="username" name="username" autocomplete="username" required autofocus>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" autocomplete="current-password" required>
</div>
<button type="submit">Log In</button>
</form>
</div>
<% end %>
</body>
</html>