Sync from main server - 2026-04-18 18:47:38
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
/* ═══════════════════════════════════════════════════════════════
|
||||
Navitrends Ops Platform
|
||||
Ops Platform — Server 173.249.20.244
|
||||
Fonts: Syne (display) + Geist Mono (data/code)
|
||||
Theme: Dark (default) / Light — toggled via [data-theme="light"]
|
||||
Design ported from 83.171.248.100 platform
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600&display=swap');
|
||||
|
||||
/* ── DARK THEME (default) ──────────────────────────────────── */
|
||||
:root {
|
||||
--bg: #0a0b0e;
|
||||
@@ -31,6 +34,14 @@
|
||||
--font: 'Syne', sans-serif;
|
||||
--mono: 'Geist Mono', monospace;
|
||||
--trans: 0.18s ease;
|
||||
|
||||
/* keep legacy var names used in 173 templates */
|
||||
--bg2: var(--surface);
|
||||
--bg3: var(--surface2);
|
||||
--bg4: #1e2535;
|
||||
--purple-d: #6366f1;
|
||||
--sidebar-w: 220px;
|
||||
--sans: 'Syne', sans-serif;
|
||||
}
|
||||
|
||||
/* ── LIGHT THEME ───────────────────────────────────────────── */
|
||||
@@ -54,6 +65,10 @@
|
||||
--cyan: #0891b2;
|
||||
|
||||
--shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
|
||||
|
||||
--bg2: var(--surface);
|
||||
--bg3: var(--surface2);
|
||||
--bg4: #edf2fb;
|
||||
}
|
||||
|
||||
/* ── RESET ─────────────────────────────────────────────────── */
|
||||
@@ -75,26 +90,38 @@ html, body {
|
||||
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
|
||||
|
||||
/* ── LAYOUT ────────────────────────────────────────────────── */
|
||||
.layout { display: flex; height: 100vh; overflow: hidden; }
|
||||
.layout { display: flex; min-height: 100vh; }
|
||||
|
||||
/* ── SIDEBAR ───────────────────────────────────────────────── */
|
||||
.sidebar {
|
||||
width: 220px; min-width: 220px;
|
||||
width: var(--sidebar-w);
|
||||
min-width: var(--sidebar-w);
|
||||
background: var(--surface);
|
||||
border-right: 1px solid var(--border);
|
||||
display: flex; flex-direction: column;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: fixed;
|
||||
top: 0; left: 0; bottom: 0;
|
||||
z-index: 100;
|
||||
padding: 20px 12px;
|
||||
transition: background 0.3s, border-color 0.3s;
|
||||
}
|
||||
|
||||
.sidebar-brand {
|
||||
display: flex; align-items: center; gap: 12px;
|
||||
.sidebar-brand,
|
||||
a.sidebar-brand-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 0 8px 24px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
margin-bottom: 20px;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.brand-mark {
|
||||
width: 36px; height: 36px; background: var(--accent);
|
||||
width: 36px; height: 36px;
|
||||
background: var(--accent);
|
||||
border-radius: 8px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
font-family: var(--mono); font-weight: 500; font-size: 12px; color: #fff;
|
||||
@@ -103,11 +130,13 @@ html, body {
|
||||
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: 0.02em; }
|
||||
.brand-sub { font-size: 10px; color: var(--text3); font-family: var(--mono); letter-spacing: 0.08em; }
|
||||
|
||||
.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
|
||||
/* nav */
|
||||
.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
|
||||
.nav-group-label,
|
||||
.nav-section-label {
|
||||
font-size: 9px; letter-spacing: 0.12em; color: var(--text3);
|
||||
font-family: var(--mono); padding: 0 8px;
|
||||
margin-bottom: 6px; margin-top: 4px;
|
||||
margin-bottom: 6px; margin-top: 8px;
|
||||
}
|
||||
.nav-item {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
@@ -115,22 +144,27 @@ html, body {
|
||||
color: var(--text2); text-decoration: none;
|
||||
font-size: 13px; font-weight: 500; cursor: pointer;
|
||||
transition: background var(--trans), color var(--trans);
|
||||
margin-bottom: 1px;
|
||||
}
|
||||
.nav-item i { width: 16px; text-align: center; font-size: 13px; }
|
||||
.nav-item span { flex: 1; }
|
||||
.nav-item:hover { background: var(--surface2); color: var(--text); }
|
||||
.nav-item.active { background: var(--accent); color: #fff; }
|
||||
.nav-item i { width: 16px; text-align: center; font-size: 13px; }
|
||||
.nav-badge {
|
||||
margin-left: auto; font-family: var(--mono); font-size: 10px;
|
||||
background: var(--border2); color: var(--text2);
|
||||
padding: 2px 6px; border-radius: 20px;
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
.nav-item.active .nav-badge { background: rgba(255,255,255,0.25); color: #fff; }
|
||||
.nav-item.active .nav-badge { background: rgba(255,255,255,0.25); color: #fff; border-color: transparent; }
|
||||
|
||||
/* sidebar footer */
|
||||
.sidebar-footer {
|
||||
display: flex; align-items: center; gap: 8px;
|
||||
padding-top: 16px; border-top: 1px solid var(--border); margin-top: auto;
|
||||
}
|
||||
.server-pill {
|
||||
.server-pill,
|
||||
.status-pill {
|
||||
flex: 1; display: flex; align-items: center; gap: 7px;
|
||||
background: var(--surface2); border-radius: 20px;
|
||||
padding: 6px 10px; font-family: var(--mono);
|
||||
@@ -147,15 +181,18 @@ html, body {
|
||||
50% { box-shadow: 0 0 0 4px rgba(34,197,94,0); }
|
||||
}
|
||||
|
||||
.logout-btn {
|
||||
.logout-btn,
|
||||
.icon-btn-sm {
|
||||
width: 32px; height: 32px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
border-radius: 8px; color: var(--text3); text-decoration: none;
|
||||
background: transparent; border: none; cursor: pointer; font-size: 13px;
|
||||
transition: background var(--trans), color var(--trans);
|
||||
}
|
||||
.logout-btn:hover { background: var(--red); color: #fff; }
|
||||
.logout-btn:hover { background: var(--red); color: #fff; }
|
||||
.icon-btn-sm:hover { background: var(--surface2); color: var(--text); }
|
||||
|
||||
/* ── THEME TOGGLE BUTTON ───────────────────────────────────── */
|
||||
/* theme toggle */
|
||||
.theme-toggle {
|
||||
width: 32px; height: 32px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
@@ -167,17 +204,25 @@ html, body {
|
||||
.theme-toggle:hover { background: var(--border2); color: var(--text); }
|
||||
|
||||
/* ── MAIN ──────────────────────────────────────────────────── */
|
||||
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
|
||||
.main {
|
||||
margin-left: var(--sidebar-w);
|
||||
flex: 1;
|
||||
display: flex; flex-direction: column;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* ── TOPBAR ────────────────────────────────────────────────── */
|
||||
.topbar {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
padding: 18px 28px; border-bottom: 1px solid var(--border);
|
||||
background: var(--surface); flex-shrink: 0;
|
||||
position: sticky; top: 0; z-index: 50;
|
||||
transition: background 0.3s, border-color 0.3s;
|
||||
}
|
||||
.topbar-left { display: flex; align-items: baseline; gap: 12px; }
|
||||
.page-title { font-size: 20px; font-weight: 700; }
|
||||
.page-subtitle { font-family: var(--mono); font-size: 11px; color: var(--text3); }
|
||||
.page-subtitle,
|
||||
.page-sub { font-family: var(--mono); font-size: 11px; color: var(--text3); }
|
||||
.topbar-right { display: flex; align-items: center; gap: 10px; }
|
||||
|
||||
.icon-btn {
|
||||
@@ -188,7 +233,8 @@ html, body {
|
||||
transition: background var(--trans), color var(--trans); font-size: 13px;
|
||||
}
|
||||
.icon-btn:hover { background: var(--border2); color: var(--text); }
|
||||
.icon-btn.spinning i { animation: spin 0.8s linear infinite; }
|
||||
.icon-btn.spinning i,
|
||||
.icon-btn .spinning { animation: spin 0.8s linear infinite; }
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
|
||||
.uptime-chip {
|
||||
@@ -197,18 +243,8 @@ html, body {
|
||||
padding: 5px 12px; border-radius: 20px;
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1; overflow-y: auto; padding: 24px 28px;
|
||||
display: flex; flex-direction: column; gap: 20px;
|
||||
}
|
||||
|
||||
/* ── PAGES ─────────────────────────────────────────────────── */
|
||||
.page { display: none; flex-direction: column; gap: 20px; }
|
||||
.page.active { display: flex; animation: fadeIn 0.2s ease; }
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(5px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
/* ── CONTENT ───────────────────────────────────────────────── */
|
||||
.content { flex: 1; padding: 24px 28px; display: flex; flex-direction: column; gap: 20px; }
|
||||
|
||||
/* ── CARDS ─────────────────────────────────────────────────── */
|
||||
.card {
|
||||
@@ -216,6 +252,7 @@ html, body {
|
||||
border-radius: var(--radius-lg); padding: 20px;
|
||||
box-shadow: var(--shadow);
|
||||
transition: background 0.3s, border-color 0.3s;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.card-header {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
@@ -226,63 +263,114 @@ html, body {
|
||||
display: flex; align-items: center; gap: 8px; color: var(--text);
|
||||
}
|
||||
.card-title i { color: var(--accent2); font-size: 12px; }
|
||||
.card-meta { font-family: var(--mono); font-size: 11px; color: var(--text3); }
|
||||
.card-meta,
|
||||
.badge-chip {
|
||||
font-family: var(--mono); font-size: 11px; color: var(--text3);
|
||||
background: var(--surface2); border: 1px solid var(--border);
|
||||
padding: 3px 8px; border-radius: 20px;
|
||||
}
|
||||
|
||||
/* ── SYSTEM METRICS ────────────────────────────────────────── */
|
||||
.metrics-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
|
||||
/* ── METRICS ROW ───────────────────────────────────────────── */
|
||||
.metrics-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 14px;
|
||||
}
|
||||
.metric-card {
|
||||
background: var(--surface2); border: 1px solid var(--border);
|
||||
border-radius: var(--radius); padding: 16px; position: relative; overflow: hidden;
|
||||
border-radius: var(--radius); padding: 16px 18px;
|
||||
position: relative; overflow: hidden;
|
||||
transition: background 0.3s, border-color 0.3s;
|
||||
}
|
||||
.metric-card::before {
|
||||
content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--accent);
|
||||
content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
|
||||
background: var(--accent);
|
||||
}
|
||||
.metric-card.mem::before { background: var(--purple); }
|
||||
.metric-card.disk::before { background: var(--cyan); }
|
||||
.metric-card.load::before { background: var(--yellow); }
|
||||
.metric-card:nth-child(2)::before { background: var(--purple); }
|
||||
.metric-card:nth-child(3)::before { background: var(--cyan); }
|
||||
.metric-card:nth-child(4)::before { background: var(--yellow); }
|
||||
|
||||
.metric-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; color: var(--text3); margin-bottom: 8px; }
|
||||
.metric-value { font-family: var(--mono); font-size: 22px; font-weight: 500; color: var(--text); line-height: 1; margin-bottom: 10px; }
|
||||
.metric-value span { font-size: 12px; color: var(--text3); }
|
||||
|
||||
.gauge-bar { height: 3px; background: var(--border2); border-radius: 4px; overflow: hidden; }
|
||||
.gauge-fill {
|
||||
height: 100%; border-radius: 4px; background: var(--accent);
|
||||
transition: width 0.6s ease;
|
||||
.metric-label {
|
||||
font-family: var(--mono); font-size: 9px; font-weight: 700;
|
||||
letter-spacing: 0.12em; color: var(--text3); margin-bottom: 8px;
|
||||
}
|
||||
.metric-card.mem .gauge-fill { background: var(--purple); }
|
||||
.metric-card.disk .gauge-fill { background: var(--cyan); }
|
||||
.metric-card.load .gauge-fill { background: var(--yellow); }
|
||||
.metric-value {
|
||||
font-family: var(--mono); font-size: 26px; font-weight: 700;
|
||||
letter-spacing: -0.02em; color: var(--text);
|
||||
line-height: 1; margin-bottom: 10px;
|
||||
}
|
||||
.metric-value.small { font-size: 16px; }
|
||||
.metric-unit { font-size: 13px; color: var(--text3); font-weight: 400; }
|
||||
|
||||
/* unified gauge names (83 uses gauge-bar/gauge-fill; 173 uses gauge-track/gauge-fill) */
|
||||
.gauge-bar,
|
||||
.gauge-track { height: 3px; background: var(--border2); border-radius: 4px; overflow: hidden; }
|
||||
.gauge-fill {
|
||||
height: 100%; border-radius: 4px;
|
||||
background: var(--accent);
|
||||
transition: width 0.6s ease; max-width: 100%;
|
||||
}
|
||||
.metric-card:nth-child(2) .gauge-fill { background: var(--purple); }
|
||||
.metric-card:nth-child(3) .gauge-fill { background: var(--cyan); }
|
||||
.metric-card:nth-child(4) .gauge-fill { background: var(--yellow); }
|
||||
|
||||
/* ── STAT ROW ──────────────────────────────────────────────── */
|
||||
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
|
||||
.stat-card {
|
||||
/* 173 uses stat-box; 83 uses stat-card — support both */
|
||||
.stat-row { display: flex; gap: 0; }
|
||||
|
||||
.stat-box {
|
||||
flex: 1; text-align: center;
|
||||
padding: 16px 8px;
|
||||
border-right: 1px solid var(--border);
|
||||
}
|
||||
.stat-box:last-child { border-right: none; }
|
||||
.stat-num {
|
||||
font-size: 28px; font-weight: 700;
|
||||
font-family: var(--mono); letter-spacing: -0.02em; margin-bottom: 4px;
|
||||
color: var(--text);
|
||||
}
|
||||
.stat-num.green { color: var(--green); }
|
||||
.stat-num.cyan { color: var(--cyan); }
|
||||
.stat-num.dim { color: var(--text3); font-size: 14px; }
|
||||
.stat-lbl { font-size: 10px; color: var(--text3); letter-spacing: 0.06em; }
|
||||
|
||||
.stat-row .stat-card {
|
||||
flex: 1; text-align: center;
|
||||
background: var(--surface2); border: 1px solid var(--border);
|
||||
border-radius: var(--radius); padding: 14px 16px; text-align: center;
|
||||
transition: background 0.3s;
|
||||
border-radius: var(--radius); padding: 14px 16px;
|
||||
}
|
||||
.stat-number { font-family: var(--mono); font-size: 28px; font-weight: 500; color: var(--accent2); line-height: 1; }
|
||||
.stat-label { font-size: 11px; color: var(--text3); margin-top: 5px; letter-spacing: 0.04em; }
|
||||
|
||||
/* ── CONTAINERS TABLE ──────────────────────────────────────── */
|
||||
.ct-table { width: 100%; border-collapse: collapse; }
|
||||
/* ── TABLES ────────────────────────────────────────────────── */
|
||||
.table-wrap,
|
||||
.ct-table-wrap { overflow-x: auto; }
|
||||
|
||||
.data-table,
|
||||
.ct-table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||||
|
||||
.data-table th,
|
||||
.ct-table th {
|
||||
font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
|
||||
color: var(--text3); padding: 6px 10px; text-align: left;
|
||||
text-align: left;
|
||||
font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
|
||||
color: var(--text3); padding: 6px 12px 10px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.data-table td,
|
||||
.ct-table td {
|
||||
padding: 10px; border-bottom: 1px solid var(--border);
|
||||
font-size: 13px; vertical-align: middle;
|
||||
padding: 10px 12px; border-bottom: 1px solid var(--border);
|
||||
vertical-align: middle;
|
||||
}
|
||||
.data-table tr:last-child td,
|
||||
.ct-table tr:last-child td { border-bottom: none; }
|
||||
.data-table tr:hover td,
|
||||
.ct-table tr:hover td { background: var(--surface2); }
|
||||
|
||||
.ct-name { font-family: var(--mono); font-size: 13px; color: var(--text); font-weight: 500; }
|
||||
.ct-image { font-family: var(--mono); font-size: 11px; color: var(--text3); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.ct-ports { font-family: var(--mono); font-size: 11px; color: var(--cyan); }
|
||||
.ct-owner { font-family: var(--mono); font-size: 11px; color: var(--purple); }
|
||||
.ct-name { font-family: var(--mono); font-weight: 500; font-size: 12px; color: var(--text); }
|
||||
.ct-image { font-family: var(--mono); font-size: 11px; color: var(--text3); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.ct-ports { font-family: var(--mono); font-size: 11px; color: var(--cyan); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.mono { font-family: var(--mono); }
|
||||
.dim { color: var(--text3); font-size: 12px; }
|
||||
|
||||
/* ── BADGES ────────────────────────────────────────────────── */
|
||||
.badge {
|
||||
@@ -290,80 +378,94 @@ html, body {
|
||||
padding: 3px 9px; border-radius: 20px;
|
||||
font-family: var(--mono); font-size: 11px; font-weight: 500;
|
||||
}
|
||||
.badge-run { background: rgba(34,197,94,0.12); color: var(--green); }
|
||||
.badge-stop { background: rgba(239,68,68,0.12); color: var(--red); }
|
||||
.badge-run::before { content:''; width:5px; height:5px; background:var(--green); border-radius:50%; }
|
||||
.badge-stop::before { content:''; width:5px; height:5px; background:var(--red); border-radius:50%; }
|
||||
[data-theme="light"] .badge-run { background: rgba(22,163,74,0.1); }
|
||||
[data-theme="light"] .badge-stop { background: rgba(220,38,38,0.1); }
|
||||
/* support both naming conventions */
|
||||
.badge-run, .badge.run { background: rgba(34,197,94,0.12); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
|
||||
.badge-stop, .badge.stop { background: rgba(239,68,68,0.12); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
|
||||
.badge-run::before, .badge.run::before { content:''; width:5px; height:5px; background:var(--green); border-radius:50%; }
|
||||
.badge-stop::before, .badge.stop::before { content:''; width:5px; height:5px; background:var(--red); border-radius:50%; }
|
||||
[data-theme="light"] .badge-run, [data-theme="light"] .badge.run { background: rgba(22,163,74,0.1); }
|
||||
[data-theme="light"] .badge-stop, [data-theme="light"] .badge.stop { background: rgba(220,38,38,0.1); }
|
||||
|
||||
/* ── INLINE STAT BARS ──────────────────────────────────────── */
|
||||
.stat-bar-wrap { display: flex; align-items: center; gap: 6px; min-width: 90px; }
|
||||
.stat-bar-bg { flex: 1; height: 4px; background: var(--border2); border-radius: 4px; overflow: hidden; }
|
||||
.stat-bar-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.5s ease; }
|
||||
/* 173 uses bar-wrap/bar-bg/bar-fill; 83 uses stat-bar-wrap etc — support both */
|
||||
.stat-bar-wrap,
|
||||
.bar-wrap { display: flex; align-items: center; gap: 6px; min-width: 90px; }
|
||||
.stat-bar-bg,
|
||||
.bar-bg { flex: 1; height: 4px; background: var(--border2); border-radius: 4px; overflow: hidden; }
|
||||
.stat-bar-fill,
|
||||
.bar-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.5s ease; }
|
||||
.bar-fill.warn,
|
||||
.stat-bar-fill.warn { background: var(--yellow); }
|
||||
.bar-fill.crit,
|
||||
.stat-bar-fill.crit { background: var(--red); }
|
||||
.stat-pct { font-family: var(--mono); font-size: 10px; color: var(--text3); min-width: 36px; }
|
||||
.stat-pct,
|
||||
.stat-val { font-family: var(--mono); font-size: 11px; color: var(--text3); min-width: 36px; }
|
||||
.stat-val.cyan { color: var(--cyan); }
|
||||
|
||||
/* ── USERS GRID ────────────────────────────────────────────── */
|
||||
.users-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
|
||||
.user-card {
|
||||
background: var(--surface2); border: 1px solid var(--border);
|
||||
border-radius: var(--radius); padding: 16px; cursor: pointer;
|
||||
transition: border-color var(--trans), background var(--trans), box-shadow var(--trans);
|
||||
}
|
||||
.user-card:hover { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2); }
|
||||
.user-card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
|
||||
.user-avatar {
|
||||
width: 38px; height: 38px; border-radius: 50%; display: flex;
|
||||
align-items: center; justify-content: center;
|
||||
font-weight: 700; font-size: 14px; flex-shrink: 0; color: #fff;
|
||||
}
|
||||
.user-name { font-weight: 600; font-size: 14px; }
|
||||
.user-uid { font-family: var(--mono); font-size: 11px; color: var(--text3); }
|
||||
.user-tags { display: flex; gap: 6px; flex-wrap: wrap; }
|
||||
.user-tag {
|
||||
font-family: var(--mono); font-size: 10px;
|
||||
padding: 2px 8px; border-radius: 20px;
|
||||
background: var(--border2); color: var(--text2);
|
||||
}
|
||||
.user-tag.docker { background: rgba(59,130,246,0.15); color: var(--accent2); }
|
||||
.user-tag.linger { background: rgba(34,197,94,0.12); color: var(--green); }
|
||||
[data-theme="light"] .user-tag.docker { background: rgba(37,99,235,0.1); }
|
||||
[data-theme="light"] .user-tag.linger { background: rgba(22,163,74,0.1); }
|
||||
/* ── ACTION BUTTONS ────────────────────────────────────────── */
|
||||
/* unified: 83 uses ctr-action-btn; 173 uses act-btn — both work */
|
||||
.action-btns { display: flex; gap: 4px; align-items: center; }
|
||||
|
||||
.user-stats { display: flex; gap: 16px; margin-top: 10px; }
|
||||
.user-stat { font-family: var(--mono); font-size: 11px; color: var(--text3); }
|
||||
.user-stat strong { color: var(--text); }
|
||||
.ctr-action-btn,
|
||||
.act-btn {
|
||||
width: 28px; height: 28px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
border-radius: 7px; border: none; cursor: pointer; font-size: 11px;
|
||||
transition: background 0.15s, transform 0.1s, opacity 0.15s;
|
||||
}
|
||||
.ctr-action-btn:hover,
|
||||
.act-btn:hover { transform: scale(1.12); }
|
||||
.ctr-action-btn:disabled,
|
||||
.act-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
|
||||
|
||||
.ctr-action-btn.restart,
|
||||
.act-btn.restart { background: rgba(59,130,246,0.15); color: var(--accent2); }
|
||||
.ctr-action-btn.restart:hover,
|
||||
.act-btn.restart:hover { background: rgba(59,130,246,0.3); }
|
||||
|
||||
.ctr-action-btn.stop,
|
||||
.act-btn.stop { background: rgba(239,68,68,0.12); color: var(--red); }
|
||||
.ctr-action-btn.stop:hover,
|
||||
.act-btn.stop:hover { background: rgba(239,68,68,0.25); }
|
||||
|
||||
.ctr-action-btn.start,
|
||||
.act-btn.start { background: rgba(34,197,94,0.12); color: var(--green); }
|
||||
.ctr-action-btn.start:hover,
|
||||
.act-btn.start:hover { background: rgba(34,197,94,0.25); }
|
||||
|
||||
/* ── BUTTONS ───────────────────────────────────────────────── */
|
||||
.btn {
|
||||
display: inline-flex; align-items: center; gap: 7px;
|
||||
padding: 9px 16px; border-radius: 8px;
|
||||
font-size: 13px; font-weight: 600; font-family: var(--font);
|
||||
cursor: pointer; border: none; text-decoration: none;
|
||||
transition: opacity var(--trans), filter var(--trans), transform 0.1s;
|
||||
}
|
||||
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
|
||||
.btn:active { transform: translateY(0); }
|
||||
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; transform: none; }
|
||||
|
||||
.btn-primary, .btn.primary { background: var(--accent); color: #fff; }
|
||||
.btn-danger, .btn.danger { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
|
||||
.btn-success { background: var(--green); color: #fff; }
|
||||
.btn-ghost, .btn.ghost { background: var(--surface2); border: 1px solid var(--border2); color: var(--text2); }
|
||||
.btn-ghost:hover, .btn.ghost:hover { background: var(--border2); color: var(--text); filter: none; }
|
||||
.btn-sm, .btn.sm { padding: 5px 11px; font-size: 12px; }
|
||||
.btn-lg, .btn.lg { padding: 12px 24px; font-size: 14px; }
|
||||
|
||||
/* ── RESTORE FORM ──────────────────────────────────────────── */
|
||||
.restore-form { display: flex; flex-direction: column; gap: 0; }
|
||||
.form-section { padding: 20px 0; border-bottom: 1px solid var(--border); }
|
||||
.restore-form { max-width: 700px; display: flex; flex-direction: column; gap: 0; }
|
||||
.form-section { padding: 20px 0; border-bottom: 1px solid var(--border); margin-bottom: 0; }
|
||||
.form-section:last-child { border-bottom: none; }
|
||||
.form-section-title { font-size: 10px; font-family: var(--mono); letter-spacing: 0.12em; color: var(--text3); margin-bottom: 14px; }
|
||||
|
||||
.radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
|
||||
.radio-card { cursor: pointer; flex: 1; min-width: 180px; }
|
||||
.radio-card input { display: none; }
|
||||
.radio-body {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
padding: 12px 14px; border: 1px solid var(--border2);
|
||||
border-radius: var(--radius); background: var(--surface2);
|
||||
transition: border-color var(--trans), background var(--trans);
|
||||
.form-section-title {
|
||||
font-size: 9px; font-family: var(--mono); font-weight: 700;
|
||||
letter-spacing: 0.12em; color: var(--text3); margin-bottom: 14px;
|
||||
}
|
||||
.radio-card input:checked + .radio-body { border-color: var(--accent); background: rgba(59,130,246,0.08); }
|
||||
[data-theme="light"] .radio-card input:checked + .radio-body { background: rgba(37,99,235,0.06); }
|
||||
.radio-label { font-size: 13px; font-weight: 600; }
|
||||
.radio-desc { font-size: 11px; color: var(--text3); }
|
||||
.radio-desc code { background: var(--border2); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); }
|
||||
.radio-icon { font-size: 18px; }
|
||||
.radio-card.small .radio-body { padding: 9px 12px; gap: 8px; }
|
||||
.radio-card.small .radio-label { font-size: 12px; }
|
||||
|
||||
.form-row { display: flex; gap: 12px; }
|
||||
.form-row .form-group { flex: 1; }
|
||||
.form-group { display: flex; flex-direction: column; gap: 6px; }
|
||||
.form-label { font-size: 11px; font-weight: 600; color: var(--text2); letter-spacing: 0.06em; }
|
||||
.form-label {
|
||||
font-size: 11px; font-weight: 600; color: var(--text2);
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
.form-input {
|
||||
background: var(--surface2); border: 1px solid var(--border2);
|
||||
border-radius: 8px; padding: 9px 12px; font-size: 13px;
|
||||
@@ -372,36 +474,45 @@ html, body {
|
||||
}
|
||||
.form-input:focus { outline: none; border-color: var(--accent); }
|
||||
.form-input[readonly] { opacity: 0.6; cursor: default; }
|
||||
.form-row { display: flex; gap: 12px; }
|
||||
.form-row .form-group { flex: 1; }
|
||||
.form-note { font-size: 12px; color: var(--text3); margin-top: 8px; }
|
||||
.form-check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
|
||||
.form-check input { accent-color: var(--accent); width: 14px; height: 14px; }
|
||||
|
||||
/* ── BUTTONS ───────────────────────────────────────────────── */
|
||||
.btn {
|
||||
display: inline-flex; align-items: center; gap: 7px;
|
||||
padding: 9px 16px; border-radius: 8px;
|
||||
font-size: 13px; font-weight: 600; font-family: var(--font);
|
||||
cursor: pointer; border: none;
|
||||
transition: opacity var(--trans), background var(--trans), filter var(--trans);
|
||||
.radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
|
||||
.radio-card { cursor: pointer; flex: 1; min-width: 160px; }
|
||||
.radio-card.sm { flex: unset; }
|
||||
.radio-card input { display: none; }
|
||||
.radio-body {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
padding: 12px 14px; border: 1px solid var(--border2);
|
||||
border-radius: var(--radius); background: var(--surface2);
|
||||
transition: border-color var(--trans), background var(--trans);
|
||||
}
|
||||
.btn:hover { filter: brightness(1.1); }
|
||||
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
|
||||
.btn-primary { background: var(--accent); color: #fff; }
|
||||
.btn-danger { background: var(--red); color: #fff; }
|
||||
.btn-success { background: var(--green); color: #fff; }
|
||||
.btn-ghost { background: var(--surface2); border: 1px solid var(--border2); color: var(--text2); }
|
||||
.btn-ghost:hover { background: var(--border2); color: var(--text); filter: none; }
|
||||
.btn-sm { padding: 5px 11px; font-size: 12px; }
|
||||
.btn-lg { padding: 12px 24px; font-size: 14px; }
|
||||
.radio-card.sm .radio-body { padding: 9px 12px; min-width: 110px; }
|
||||
.radio-card input:checked + .radio-body { border-color: var(--accent); background: rgba(59,130,246,0.08); }
|
||||
[data-theme="light"] .radio-card input:checked + .radio-body { background: rgba(37,99,235,0.06); }
|
||||
.radio-icon { font-size: 16px; color: var(--accent2); }
|
||||
.radio-label { font-size: 13px; font-weight: 600; }
|
||||
.radio-desc { font-size: 11px; color: var(--text3); font-family: var(--mono); margin-top: 2px; }
|
||||
.radio-desc code { background: var(--border2); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); }
|
||||
|
||||
/* ── LOG CONSOLE ───────────────────────────────────────────── */
|
||||
.log-header {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
margin-bottom: 10px; font-size: 12px; font-weight: 600; color: var(--text2);
|
||||
}
|
||||
.log-console {
|
||||
background: #05060a; border: 1px solid var(--border);
|
||||
border-radius: var(--radius); padding: 14px 16px;
|
||||
font-family: var(--mono); font-size: 12px; line-height: 1.7;
|
||||
max-height: 400px; overflow-y: auto; color: #8892a4;
|
||||
white-space: pre-wrap; word-break: break-all;
|
||||
}
|
||||
[data-theme="light"] .log-console { background: #1a1f2e; border-color: #2d3555; }
|
||||
.log-line { white-space: pre-wrap; word-break: break-all; }
|
||||
.log-line { margin: 0; }
|
||||
.log-elapsed { font-size: 11px; font-family: var(--mono); color: var(--text3); margin-top: 6px; }
|
||||
|
||||
/* ── BACKUP LIST ───────────────────────────────────────────── */
|
||||
.backup-list { display: flex; flex-direction: column; gap: 8px; }
|
||||
@@ -411,28 +522,101 @@ html, body {
|
||||
background: var(--surface2); gap: 10px; flex-wrap: wrap;
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
.backup-name { font-family: var(--mono); font-size: 12px; color: var(--text2); }
|
||||
.backup-name { font-family: var(--mono); font-size: 12px; color: var(--text2); }
|
||||
.backup-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
|
||||
.btn-delete-backup { color: var(--red) !important; opacity: 0.7; transition: opacity 0.15s; }
|
||||
.btn-delete-backup:hover { opacity: 1; }
|
||||
.btn-audit { color: var(--cyan) !important; opacity: 0.85; }
|
||||
.btn-audit:hover { opacity: 1; }
|
||||
|
||||
/* ── TWO COLUMN ────────────────────────────────────────────── */
|
||||
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
|
||||
@media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } }
|
||||
/* ── MODAL ─────────────────────────────────────────────────── */
|
||||
.modal-overlay {
|
||||
position: fixed; inset: 0; z-index: 1000;
|
||||
background: rgba(0,0,0,0.65);
|
||||
backdrop-filter: blur(3px);
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
padding: 20px; animation: fadeIn 0.15s ease;
|
||||
}
|
||||
.modal-box {
|
||||
background: #111318; border: 1px solid #1e2330;
|
||||
border-radius: 16px; width: 100%; max-width: 600px;
|
||||
max-height: 88vh; overflow-y: auto; padding: 24px;
|
||||
box-shadow: 0 32px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
|
||||
position: relative;
|
||||
}
|
||||
[data-theme="light"] .modal-box { background: #fff; border-color: #dde1ed; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
|
||||
.modal-header {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid #1e2330;
|
||||
}
|
||||
[data-theme="light"] .modal-header { border-bottom-color: #dde1ed; }
|
||||
.modal-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; color: #e8ecf4; }
|
||||
[data-theme="light"] .modal-title { color: #0f1117; }
|
||||
.modal-close {
|
||||
background: none; border: none; cursor: pointer; color: #4a5568;
|
||||
font-size: 18px; line-height: 1; padding: 6px 10px; border-radius: 8px;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
.modal-close:hover { background: rgba(239,68,68,0.12); color: #ef4444; }
|
||||
.audit-footer {
|
||||
display: flex; gap: 8px; margin-top: 18px; padding-top: 14px;
|
||||
border-top: 1px solid #1e2330;
|
||||
}
|
||||
[data-theme="light"] .audit-footer { border-top-color: #dde1ed; }
|
||||
|
||||
/* ── FORM GRID ─────────────────────────────────────────────── */
|
||||
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
|
||||
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
|
||||
|
||||
/* ── SECTION HEADER ────────────────────────────────────────── */
|
||||
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
|
||||
.section-title { font-size: 13px; font-weight: 600; color: var(--text2); font-family: var(--mono); letter-spacing: 0.06em; }
|
||||
/* ── NOTICE ────────────────────────────────────────────────── */
|
||||
.notice {
|
||||
padding: 12px 16px; border-radius: var(--radius);
|
||||
font-size: 13px; display: flex; align-items: flex-start; gap: 10px;
|
||||
}
|
||||
.notice.warning {
|
||||
background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.2);
|
||||
color: var(--yellow);
|
||||
}
|
||||
.notice code { font-family: var(--mono); font-size: 12px; background: rgba(255,255,255,0.08); padding: 1px 5px; border-radius: 4px; }
|
||||
|
||||
/* ── ALERTS ────────────────────────────────────────────────── */
|
||||
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; display: none; }
|
||||
.alert.show { display: block; }
|
||||
.alert-success { background: rgba(34,197,94,0.1); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
|
||||
.alert-error { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
|
||||
[data-theme="light"] .alert-success { background: rgba(22,163,74,0.08); }
|
||||
[data-theme="light"] .alert-error { background: rgba(220,38,38,0.08); }
|
||||
.alert.show { display: block; }
|
||||
.alert-success { background: rgba(34,197,94,0.1); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
|
||||
.alert-error { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
|
||||
|
||||
/* ── EMPTY STATE ───────────────────────────────────────────── */
|
||||
.empty-state { text-align: center; padding: 36px; color: var(--text3); font-size: 13px; }
|
||||
.empty-state,
|
||||
.empty {
|
||||
text-align: center; padding: 36px; color: var(--text3);
|
||||
font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 8px;
|
||||
}
|
||||
.empty-state i { font-size: 26px; display: block; margin-bottom: 10px; opacity: 0.35; }
|
||||
.empty.warn { color: var(--yellow); }
|
||||
|
||||
/* ── SETTINGS ──────────────────────────────────────────────── */
|
||||
.settings-grid { display: flex; flex-direction: column; gap: 0; }
|
||||
.settings-row {
|
||||
display: flex; justify-content: space-between; align-items: flex-start;
|
||||
gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.settings-row:last-child { border-bottom: none; }
|
||||
.settings-label {
|
||||
font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
|
||||
color: var(--text3); text-transform: uppercase; flex: 0 0 180px;
|
||||
}
|
||||
.settings-value { font-size: 14px; color: var(--text2); text-align: right; flex: 1; line-height: 1.45; }
|
||||
|
||||
/* ── TWO COL ───────────────────────────────────────────────── */
|
||||
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
|
||||
@media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } }
|
||||
|
||||
/* ── UTILITIES ─────────────────────────────────────────────── */
|
||||
.row-gap { display: flex; align-items: center; gap: 8px; }
|
||||
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
|
||||
.section-title { font-size: 13px; font-weight: 600; color: var(--text2); font-family: var(--mono); letter-spacing: 0.06em; }
|
||||
|
||||
/* ── ANIMATION ─────────────────────────────────────────────── */
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(5px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
/* manual backup wrapper */
|
||||
#manual-backup-wrapper { border-top: 1px solid var(--border); padding-top: 16px; }
|
||||
634
platform/static/js/platform.js
Normal file
634
platform/static/js/platform.js
Normal file
@@ -0,0 +1,634 @@
|
||||
const extraState = { app: false, all: false };
|
||||
let selectedUser = null;
|
||||
let manualBackupJobId = null;
|
||||
let manualBackupPoll = null;
|
||||
let currentJobId = null;
|
||||
let pollInterval = null;
|
||||
|
||||
function el(id) { return document.getElementById(id); }
|
||||
|
||||
function escapeHtml(s) {
|
||||
if (s == null) return '';
|
||||
return String(s)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
}
|
||||
|
||||
function auditScoreBlockTierClass(tier) {
|
||||
const t = String(tier || 'fair');
|
||||
if (t === 'excellent' || t === 'good') return 'audit-tier-good';
|
||||
if (t === 'fair') return 'audit-tier-fair';
|
||||
if (t === 'poor') return 'audit-tier-poor';
|
||||
return 'audit-tier-critical';
|
||||
}
|
||||
|
||||
function renderAuditModalContent(d, filename) {
|
||||
if (d.error) {
|
||||
return `<div class="empty-state" style="color:var(--red)">${escapeHtml(d.error)}</div>
|
||||
<div class="audit-footer"><button type="button" class="btn btn-ghost btn-sm" onclick="closeAuditModal()">Close</button></div>`;
|
||||
}
|
||||
|
||||
const tierCls = auditScoreBlockTierClass(d.health_tier);
|
||||
const score = Math.max(0, Math.min(100, Number(d.score) || 0));
|
||||
const fileSize = d.file_size_display
|
||||
? escapeHtml(d.file_size_display)
|
||||
: (d.file_size_bytes != null ? escapeHtml(String(d.file_size_bytes)) + ' B' : '—');
|
||||
const fname = escapeHtml(d.backup_file || filename);
|
||||
const summary = escapeHtml(d.summary || '');
|
||||
const healthLabel = escapeHtml(d.health_label || '');
|
||||
const badgeSafe = !!d.ok;
|
||||
const badgeText = badgeSafe ? '✓ Safe to restore' : '✗ Review before restore';
|
||||
const badgeClass = badgeSafe ? 'audit-health-badge audit-health-badge-safe' : 'audit-health-badge audit-health-badge-unsafe';
|
||||
|
||||
const checksHtml = (d.checks || []).map((c) => {
|
||||
const st = c.status === 'fail' ? 'fail' : c.status === 'warn' ? 'warn' : 'pass';
|
||||
const icon = st === 'pass' ? '✓' : st === 'warn' ? '⚠' : '✗';
|
||||
const iconCls = `audit-check-icon audit-check-icon-${st}`;
|
||||
const detail = escapeHtml(c.detail || '');
|
||||
const moreLines = Array.isArray(c.more) ? c.more : [];
|
||||
const moreBlock = moreLines.length
|
||||
? `<ul class="audit-check-more">${moreLines.map((line) => `<li>${escapeHtml(line)}</li>`).join('')}</ul>`
|
||||
: '';
|
||||
|
||||
return `<details class="audit-check-row status-${st}">
|
||||
<summary class="audit-check-summary">
|
||||
<span class="${iconCls}">${icon}</span>
|
||||
<span class="audit-check-name">${escapeHtml(c.name)}</span>
|
||||
<span class="audit-check-pill audit-check-pill-${st}">${st}</span>
|
||||
<span class="audit-check-chevron" aria-hidden="true"></span>
|
||||
</summary>
|
||||
<div class="audit-check-body">
|
||||
<p class="audit-check-detail">${detail}</p>
|
||||
${moreBlock}
|
||||
</div>
|
||||
</details>`;
|
||||
}).join('');
|
||||
|
||||
return `<div class="audit-file-label">File</div>
|
||||
<code class="audit-filename">${fname}</code>
|
||||
<div class="audit-file-meta"><span class="audit-file-meta-label">Size</span><span class="audit-file-meta-value">${fileSize}</span></div>
|
||||
<div class="audit-score-block ${tierCls}">
|
||||
<div class="audit-score-numcol">
|
||||
<div class="audit-score-number">${score}</div>
|
||||
<div class="audit-score-label">Score</div>
|
||||
</div>
|
||||
<div class="audit-score-info">
|
||||
<div class="audit-health-row">
|
||||
<span class="audit-health-label">${healthLabel}</span>
|
||||
<span class="${badgeClass}">${badgeText}</span>
|
||||
</div>
|
||||
<p class="audit-summary">${summary}</p>
|
||||
<div class="audit-progress" role="progressbar" aria-valuenow="${score}" aria-valuemin="0" aria-valuemax="100"><div class="audit-progress-fill ${tierCls}" style="width:${score}%"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="audit-checks-hint">Expand a row to see exactly what was verified (size, checksum, archive test, paths, …).</p>
|
||||
<div class="audit-checks">${checksHtml}</div>
|
||||
<div class="audit-footer">
|
||||
<button type="button" class="btn btn-ghost btn-sm" onclick="closeAuditModal()">Close</button>
|
||||
<button type="button" class="btn btn-primary btn-sm" onclick="quickRestoreFromAuditModal()"><i class="fas fa-rotate-left"></i> Restore this backup</button>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function quickRestoreFromAuditModal() {
|
||||
const modal = el('audit-modal');
|
||||
if (!modal) return;
|
||||
const s = modal.dataset.auditSource || '';
|
||||
const f = modal.dataset.auditFile || '';
|
||||
modal.style.display = 'none';
|
||||
if (s && f) quickRestore(s, f);
|
||||
}
|
||||
|
||||
function setText(id, value) {
|
||||
const node = el(id);
|
||||
if (node) node.textContent = value;
|
||||
}
|
||||
|
||||
function toggleExtraColumns(prefix) {
|
||||
extraState[prefix] = !extraState[prefix];
|
||||
const show = extraState[prefix];
|
||||
document.querySelectorAll(`.${prefix}-extra`).forEach((node) => {
|
||||
node.style.display = show ? "" : "none";
|
||||
});
|
||||
const btn = el(`${prefix}-toggle-btn`);
|
||||
if (btn) {
|
||||
btn.innerHTML = show
|
||||
? '<i class="fas fa-eye-slash"></i> Show less'
|
||||
: '<i class="fas fa-eye"></i> Show more';
|
||||
}
|
||||
}
|
||||
|
||||
/** Sidebar counts (present in base.html on every page). */
|
||||
async function refreshSidebarNavBadges() {
|
||||
const setBadges = (containerCount, userCount) => {
|
||||
const c = el('nav-badge-containers');
|
||||
const u = el('nav-badge-users');
|
||||
if (c) c.textContent = containerCount != null ? containerCount : '—';
|
||||
if (u) u.textContent = userCount != null ? userCount : '—';
|
||||
};
|
||||
try {
|
||||
const r = await fetch('/api/nav-summary', { credentials: 'same-origin' });
|
||||
const d = r.ok ? await r.json() : null;
|
||||
const cc = d && Number.isFinite(Number(d.container_count)) ? Number(d.container_count) : null;
|
||||
const uc = d && Number.isFinite(Number(d.user_count)) ? Number(d.user_count) : null;
|
||||
setBadges(cc, uc);
|
||||
} catch (_) {
|
||||
setBadges(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
async function checkServerStatus() {
|
||||
try {
|
||||
const r = await fetch('/server/status');
|
||||
const d = await r.json();
|
||||
const dot = el('pulse-dot');
|
||||
const text = el('server-status-text');
|
||||
if (!dot || !text) return;
|
||||
if (d.status === 'online') {
|
||||
dot.className = 'pulse-dot online';
|
||||
text.textContent = 'Online';
|
||||
} else {
|
||||
dot.className = 'pulse-dot offline';
|
||||
text.textContent = 'Offline';
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
async function refreshSystemMetrics() {
|
||||
try {
|
||||
const r = await fetch('/api/system');
|
||||
const d = await r.json();
|
||||
if (el('m-cpu')) el('m-cpu').innerHTML = d.cpu_pct + '<span>%</span>';
|
||||
setText('m-mem', d.memory);
|
||||
setText('m-disk', d.disk);
|
||||
setText('m-load', d.load);
|
||||
if (el('g-cpu')) el('g-cpu').style.width = Math.min(parseFloat(d.cpu_pct) || 0, 100) + '%';
|
||||
if (el('g-mem')) el('g-mem').style.width = Math.min(parseFloat(d.mem_pct) || 0, 100) + '%';
|
||||
if (el('g-disk')) el('g-disk').style.width = Math.min(parseFloat(d.disk_pct) || 0, 100) + '%';
|
||||
setText('uptime-chip', d.uptime);
|
||||
if (el('settings-uptime')) el('settings-uptime').value = d.uptime;
|
||||
if (d.hostname && el('this-server-desc')) el('this-server-desc').textContent = d.hostname;
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
async function refreshContainerStats() {
|
||||
try {
|
||||
const r = await fetch('/api/stats');
|
||||
const stats = await r.json();
|
||||
document.querySelectorAll('[data-stat]').forEach((node) => {
|
||||
const name = node.dataset.ctr;
|
||||
const stat = node.dataset.stat;
|
||||
const s = stats[name];
|
||||
if (!s) return;
|
||||
if (stat === 'cpu') node.textContent = s.cpu || '—';
|
||||
if (stat === 'net') node.textContent = s.net || '—';
|
||||
if (stat === 'block') node.textContent = s.block || '—';
|
||||
if (stat === 'mem_pct') node.textContent = s.mem_pct || '—';
|
||||
if (stat === 'mem_bar') {
|
||||
const pct = parseFloat(s.mem_pct) || 0;
|
||||
node.style.width = Math.min(pct, 100) + '%';
|
||||
node.className = 'stat-bar-fill' + (pct > 85 ? ' crit' : pct > 65 ? ' warn' : '');
|
||||
}
|
||||
});
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
function statusBadgeHTML(status) {
|
||||
if (status === 'running') return '<span class="badge badge-run">Running</span>';
|
||||
if (status === 'stopped') return '<span class="badge badge-stop">Stopped</span>';
|
||||
return '<span class="badge" style="background:rgba(107,114,128,0.15);color:var(--text2)">Unknown</span>';
|
||||
}
|
||||
|
||||
function updateContainerStatusBadge(name, status) {
|
||||
document.querySelectorAll(`.ctr-status-cell[data-ctr="${name}"]`).forEach((cell) => {
|
||||
cell.innerHTML = statusBadgeHTML(status);
|
||||
});
|
||||
document.querySelectorAll('#all-containers-body tr').forEach((row) => {
|
||||
const nameTd = row.querySelector('.ct-name');
|
||||
if (nameTd && nameTd.textContent.trim() === name) {
|
||||
const statusTd = row.cells[2];
|
||||
if (statusTd) statusTd.innerHTML = statusBadgeHTML(status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function ctrAction(name, action, btn) {
|
||||
const origHTML = btn.innerHTML;
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i>';
|
||||
try {
|
||||
const r = await fetch('/api/container/action', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name, action })
|
||||
});
|
||||
const d = await r.json();
|
||||
if (d.new_status) updateContainerStatusBadge(name, d.new_status);
|
||||
btn.innerHTML = d.success ? '<i class="fas fa-check"></i>' : '<i class="fas fa-times"></i>';
|
||||
setTimeout(() => {
|
||||
btn.innerHTML = origHTML;
|
||||
btn.disabled = false;
|
||||
setTimeout(() => {
|
||||
refreshContainerStats();
|
||||
if (el('all-containers-body')) loadAllContainers();
|
||||
}, 1500);
|
||||
}, 1200);
|
||||
} catch (_) {
|
||||
btn.innerHTML = origHTML;
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function buildActionBtns(name) {
|
||||
return `<div class="action-btns">
|
||||
<button class="ctr-action-btn restart" title="Restart" onclick="ctrAction('${name}','restart',this)"><i class="fas fa-rotate-right"></i></button>
|
||||
<button class="ctr-action-btn stop" title="Stop" onclick="ctrAction('${name}','stop',this)"><i class="fas fa-stop"></i></button>
|
||||
<button class="ctr-action-btn start" title="Start" onclick="ctrAction('${name}','start',this)"><i class="fas fa-play"></i></button>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
async function loadAllContainers() {
|
||||
const body = el('all-containers-body');
|
||||
if (!body) return;
|
||||
const meta = el('all-ctr-meta');
|
||||
body.innerHTML = '<tr><td colspan="10"><div class="empty-state"><i class="fas fa-spinner fa-spin"></i> Loading…</div></td></tr>';
|
||||
try {
|
||||
const [ctrRes, statRes] = await Promise.all([fetch('/api/containers/all'), fetch('/api/stats')]);
|
||||
const { containers, running } = await ctrRes.json();
|
||||
const stats = await statRes.json();
|
||||
if (meta) meta.textContent = `${containers.length} total · ${running} running`;
|
||||
if (el('nav-badge-containers')) el('nav-badge-containers').textContent = containers.length;
|
||||
if (!containers.length) {
|
||||
body.innerHTML = '<tr><td colspan="10"><div class="empty-state"><i class="fas fa-inbox"></i>No containers</div></td></tr>';
|
||||
return;
|
||||
}
|
||||
const showExtra = extraState.all;
|
||||
body.innerHTML = containers.map((c) => {
|
||||
const up = c.status.includes('Up');
|
||||
const s = stats[c.name] || {};
|
||||
const pct = parseFloat(s.mem_pct) || 0;
|
||||
const cls = pct > 85 ? 'crit' : pct > 65 ? 'warn' : '';
|
||||
const ed = showExtra ? '' : 'display:none;';
|
||||
return `<tr>
|
||||
<td class="ct-name">${c.name}</td><td class="ct-owner">${c.owner}</td>
|
||||
<td>${up ? '<span class="badge badge-run">Running</span>' : '<span class="badge badge-stop">Stopped</span>'}</td>
|
||||
<td><span class="stat-pct">${s.cpu || '—'}</span></td>
|
||||
<td><div class="stat-bar-wrap"><div class="stat-bar-bg"><div class="stat-bar-fill ${cls}" style="width:${Math.min(pct,100)}%"></div></div><span class="stat-pct">${s.mem_pct || '—'}</span></div></td>
|
||||
<td><span class="stat-pct" style="color:var(--cyan)">${s.net || '—'}</span></td>
|
||||
<td class="col-extra all-extra" style="${ed}"><span class="stat-pct" style="color:var(--yellow)">${s.block || '—'}</span></td>
|
||||
<td class="col-extra all-extra ct-image" style="${ed}">${c.image}</td>
|
||||
<td class="col-extra all-extra ct-ports" style="${ed}">${c.ports || '—'}</td>
|
||||
<td>${buildActionBtns(c.name)}</td></tr>`;
|
||||
}).join('');
|
||||
} catch (e) {
|
||||
body.innerHTML = `<tr><td colspan="10"><div class="empty-state">${e}</div></td></tr>`;
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshBackupsList() {
|
||||
try {
|
||||
const r = await fetch('/api/backups');
|
||||
const d = await r.json();
|
||||
renderBackupList(d.local, 'local-backup-list', 'local');
|
||||
renderBackupList(d.vm, 'vm-backup-list', 'vm');
|
||||
if (el('stat-local-bk')) el('stat-local-bk').textContent = d.local.length;
|
||||
if (el('stat-vm-bk')) el('stat-vm-bk').textContent = d.vm.length;
|
||||
if (el('local-options')) el('local-options').innerHTML = d.local.length ? d.local.map((b) => `<option value="${b}" data-source="local">${b}</option>`).join('') : '<option disabled>No local backups</option>';
|
||||
if (el('vm-options')) el('vm-options').innerHTML = d.vm.length ? d.vm.map((b) => `<option value="${b}" data-source="vm">${b}</option>`).join('') : '<option disabled>No VM backups</option>';
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
function renderBackupList(items, id, source) {
|
||||
const node = el(id);
|
||||
if (!node) return;
|
||||
if (!items || !items.length) {
|
||||
node.innerHTML = '<div class="empty-state"><i class="fas fa-inbox"></i>No backups</div>';
|
||||
return;
|
||||
}
|
||||
node.innerHTML = items.map((b) => `
|
||||
<div class="backup-item" id="bk-item-${source}-${b.replace(/[^a-z0-9]/gi,'_')}">
|
||||
<span class="backup-name">${b}</span>
|
||||
<div class="backup-actions">
|
||||
<button class="btn btn-ghost btn-sm btn-audit" onclick="auditBackup('${source}','${b}',this)"><i class="fas fa-shield-check"></i> Audit</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="quickRestore('${source}','${b}')">↩ Restore</button>
|
||||
<button class="btn btn-ghost btn-sm btn-delete-backup" onclick="deleteBackup('${source}','${b}',this)"><i class="fas fa-trash"></i></button>
|
||||
</div>
|
||||
</div>`).join('');
|
||||
}
|
||||
|
||||
async function auditBackup(source, filename, btn) {
|
||||
const modal = el('audit-modal');
|
||||
const content = el('audit-modal-content');
|
||||
if (!modal || !content) return;
|
||||
modal.dataset.auditSource = source;
|
||||
modal.dataset.auditFile = filename;
|
||||
modal.style.display = 'flex';
|
||||
content.innerHTML = '<div class="empty-state"><i class="fas fa-spinner fa-spin"></i> Running audit…</div>';
|
||||
if (btn) { btn.disabled = true; btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i>'; }
|
||||
try {
|
||||
const r = await fetch('/api/backups/audit', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ backup_file: filename, source })
|
||||
});
|
||||
const d = await r.json();
|
||||
if (!r.ok) {
|
||||
content.innerHTML = renderAuditModalContent({ error: d.error || d.message || `HTTP ${r.status}` }, filename);
|
||||
return;
|
||||
}
|
||||
content.innerHTML = renderAuditModalContent(d, filename);
|
||||
} catch (e) {
|
||||
content.innerHTML = `<div class="empty-state" style="color:var(--red)">Audit failed: ${escapeHtml(e)}</div>
|
||||
<div class="audit-footer"><button type="button" class="btn btn-ghost btn-sm" onclick="closeAuditModal()">Close</button></div>`;
|
||||
} finally {
|
||||
if (btn) { btn.disabled = false; btn.innerHTML = '<i class="fas fa-shield-check"></i> Audit'; }
|
||||
}
|
||||
}
|
||||
|
||||
function closeAuditModal(e) {
|
||||
const modal = el('audit-modal');
|
||||
if (!modal) return;
|
||||
if (!e || e.target === modal) modal.style.display = 'none';
|
||||
}
|
||||
|
||||
async function deleteBackup(source, filename, btn) {
|
||||
if (!confirm(`Delete backup:\n${filename}\n\nThis cannot be undone.`)) return;
|
||||
if (btn) { btn.disabled = true; btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i>'; }
|
||||
try {
|
||||
const r = await fetch('/api/backups/delete', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ backup_file: filename, source })
|
||||
});
|
||||
const d = await r.json();
|
||||
if (!d.success) alert(`Delete failed: ${d.message}`);
|
||||
refreshBackupsList();
|
||||
} catch (e) {
|
||||
alert(`Error: ${e}`);
|
||||
} finally {
|
||||
if (btn) { btn.disabled = false; btn.innerHTML = '<i class="fas fa-trash"></i>'; }
|
||||
}
|
||||
}
|
||||
|
||||
async function runManualBackup() {
|
||||
const btn = el('manual-backup-btn');
|
||||
if (!btn) return;
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Starting…';
|
||||
const wrapper = el('manual-backup-wrapper');
|
||||
const logEl = el('manual-backup-log');
|
||||
if (wrapper) wrapper.style.display = '';
|
||||
if (logEl) logEl.innerHTML = '';
|
||||
try {
|
||||
const r = await fetch('/api/backups/run', { method: 'POST' });
|
||||
const d = await r.json();
|
||||
if (!d.success) throw new Error(d.message || 'Failed');
|
||||
manualBackupJobId = d.job_id;
|
||||
pollManualBackup();
|
||||
} catch (e) {
|
||||
if (logEl) logEl.textContent = `❌ ${e}`;
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="fas fa-play"></i> Run Backup Now';
|
||||
}
|
||||
}
|
||||
|
||||
function pollManualBackup() {
|
||||
if (manualBackupPoll) clearInterval(manualBackupPoll);
|
||||
let lastLine = 0;
|
||||
manualBackupPoll = setInterval(async () => {
|
||||
if (!manualBackupJobId) return;
|
||||
try {
|
||||
const r = await fetch(`/api/backups/run/status/${manualBackupJobId}`);
|
||||
const d = await r.json();
|
||||
d.log.slice(lastLine).forEach(appendBackupLog);
|
||||
lastLine = d.log.length;
|
||||
if (el('manual-backup-elapsed')) el('manual-backup-elapsed').textContent = `⏱ ${d.elapsed}s`;
|
||||
if (d.status !== 'running') {
|
||||
clearInterval(manualBackupPoll);
|
||||
if (el('manual-backup-btn')) {
|
||||
el('manual-backup-btn').disabled = false;
|
||||
el('manual-backup-btn').innerHTML = '<i class="fas fa-play"></i> Run Backup Now';
|
||||
}
|
||||
if (d.status === 'done') setTimeout(refreshBackupsList, 1200);
|
||||
}
|
||||
} catch (_) {}
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
function appendBackupLog(line) {
|
||||
const logEl = el('manual-backup-log');
|
||||
if (!logEl) return;
|
||||
const div = document.createElement('div');
|
||||
div.className = 'log-line';
|
||||
div.textContent = line;
|
||||
logEl.appendChild(div);
|
||||
logEl.scrollTop = logEl.scrollHeight;
|
||||
}
|
||||
|
||||
async function loadBackupLog() {
|
||||
const node = el('backup-history-list');
|
||||
if (!node) return;
|
||||
node.innerHTML = '<div class="empty-state"><i class="fas fa-spinner fa-spin"></i> Loading…</div>';
|
||||
try {
|
||||
const r = await fetch('/api/backups/log?limit=15');
|
||||
const d = await r.json();
|
||||
if (!d.entries || !d.entries.length) {
|
||||
node.innerHTML = '<div class="empty-state"><i class="fas fa-inbox"></i>No backup history yet</div>';
|
||||
return;
|
||||
}
|
||||
node.innerHTML = d.entries.map((e) => `<div class="backup-item"><span class="backup-name">${e.name}</span><span class="card-meta">${e.status}</span></div>`).join('');
|
||||
} catch (e) {
|
||||
node.innerHTML = `<div class="empty-state">Error loading log: ${e}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
const userColors = ['#3b82f6', '#a78bfa', '#22c55e', '#f59e0b', '#ef4444', '#22d3ee'];
|
||||
async function loadUsers() {
|
||||
const grid = el('users-grid');
|
||||
if (!grid) return;
|
||||
try {
|
||||
const r = await fetch('/api/users');
|
||||
const users = await r.json();
|
||||
if (el('nav-badge-users')) el('nav-badge-users').textContent = users.length;
|
||||
if (el('stat-users')) el('stat-users').textContent = users.length;
|
||||
if (!users.length) {
|
||||
grid.innerHTML = '<div class="empty-state" style="grid-column:1/-1"><i class="fas fa-user-slash"></i>No users</div>';
|
||||
return;
|
||||
}
|
||||
grid.innerHTML = users.map((u, i) => `<div class="user-card" onclick="loadUserContainers('${u.name}')"><div class="user-card-top"><div class="user-avatar" style="background:${userColors[i % userColors.length]}">${u.name[0].toUpperCase()}</div><div><div class="user-name">${u.name}</div><div class="user-uid">uid ${u.uid}</div></div></div><div class="user-tags">${u.has_docker ? '<span class="user-tag docker"><i class="fab fa-docker"></i> docker</span>' : ''}${u.linger ? '<span class="user-tag linger">linger</span>' : ''}${u.has_vdisk ? '<span class="user-tag" style="background:rgba(34,211,238,0.12);color:var(--cyan)">💾 vdisk</span>' : ''}</div><div class="user-stats"><div class="user-stat">Disk: <strong>${u.disk_used}</strong></div><div class="user-stat">Ctrs: <strong>${u.container_count}</strong></div></div></div>`).join('');
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
async function loadUserContainers(username) {
|
||||
selectedUser = username;
|
||||
if (el('user-detail-panel')) el('user-detail-panel').style.display = '';
|
||||
setText('user-detail-title', `${username}'s Containers`);
|
||||
const body = el('user-containers-body');
|
||||
if (!body) return;
|
||||
body.innerHTML = '<tr><td colspan="4"><div class="empty-state"><i class="fas fa-spinner fa-spin"></i></div></td></tr>';
|
||||
try {
|
||||
const r = await fetch(`/api/users/${username}/containers`);
|
||||
const ctrs = await r.json();
|
||||
if (!ctrs.length) {
|
||||
body.innerHTML = '<tr><td colspan="4"><div class="empty-state"><i class="fas fa-inbox"></i>No containers</div></td></tr>';
|
||||
return;
|
||||
}
|
||||
body.innerHTML = ctrs.map((c) => `<tr><td class="ct-name">${c.name}</td><td>${c.status.includes('Up') ? '<span class="badge badge-run">Running</span>' : '<span class="badge badge-stop">Stopped</span>'}</td><td class="ct-image">${c.image}</td><td class="ct-ports">${c.ports || '—'}</td></tr>`).join('');
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
function showAlert(id, type, msg) {
|
||||
const node = el(id);
|
||||
if (!node) return;
|
||||
node.className = `alert alert-${type} show`;
|
||||
node.textContent = msg;
|
||||
}
|
||||
|
||||
async function createUser() {
|
||||
const username = el('new-username')?.value.trim();
|
||||
const password = el('new-password')?.value.trim();
|
||||
const quota = el('new-quota')?.value.trim();
|
||||
const docker = !!el('new-docker')?.checked;
|
||||
if (!username) return showAlert('create-user-result', 'error', 'Username required');
|
||||
const btn = event.target;
|
||||
btn.disabled = true;
|
||||
try {
|
||||
const r = await fetch('/api/users/create', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ username, password: password || null, setup_docker: docker, disk_quota_mb: quota ? parseInt(quota, 10) : null })
|
||||
});
|
||||
const d = await r.json();
|
||||
showAlert('create-user-result', d.success ? 'success' : 'error', d.message || '');
|
||||
if (d.success) loadUsers();
|
||||
} catch (e) {
|
||||
showAlert('create-user-result', 'error', `${e}`);
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteUser() {
|
||||
if (!selectedUser || !confirm(`Delete user "${selectedUser}"?`)) return;
|
||||
const removeHome = confirm(`Also delete /home/${selectedUser}?`);
|
||||
try {
|
||||
const r = await fetch('/api/users/delete', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ username: selectedUser, remove_home: removeHome })
|
||||
});
|
||||
const d = await r.json();
|
||||
showAlert('user-action-result', d.success ? 'success' : 'error', d.message || '');
|
||||
if (d.success) {
|
||||
if (el('user-detail-panel')) el('user-detail-panel').style.display = 'none';
|
||||
loadUsers();
|
||||
}
|
||||
} catch (e) {
|
||||
showAlert('user-action-result', 'error', `${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
function updateBackupList() {
|
||||
const src = document.querySelector('input[name="backup_source"]:checked')?.value;
|
||||
if (!src) return;
|
||||
if (el('local-options')) el('local-options').style.display = src === 'local' ? '' : 'none';
|
||||
if (el('vm-options')) el('vm-options').style.display = src === 'vm' ? '' : 'none';
|
||||
}
|
||||
function toggleRemoteFields() {
|
||||
const v = document.querySelector('input[name="restore_target"]:checked')?.value;
|
||||
if (el('remote-fields')) el('remote-fields').style.display = v === 'remote' ? '' : 'none';
|
||||
}
|
||||
function toggleAuthFields() {
|
||||
const m = document.querySelector('input[name="auth_method"]:checked')?.value;
|
||||
if (el('key-field')) el('key-field').style.display = m === 'key' ? '' : 'none';
|
||||
if (el('password-field')) el('password-field').style.display = m === 'password' ? '' : 'none';
|
||||
}
|
||||
|
||||
function quickRestore(source, filename) {
|
||||
window.location.href = `/restore?source=${encodeURIComponent(source)}&file=${encodeURIComponent(filename)}`;
|
||||
}
|
||||
|
||||
function appendLog(line) {
|
||||
const logEl = el('restore-log');
|
||||
if (!logEl) return;
|
||||
const div = document.createElement('div');
|
||||
div.className = 'log-line';
|
||||
div.textContent = line;
|
||||
logEl.appendChild(div);
|
||||
logEl.scrollTop = logEl.scrollHeight;
|
||||
}
|
||||
|
||||
async function launchRestore() {
|
||||
const src = document.querySelector('input[name="backup_source"]:checked')?.value;
|
||||
const file = el('backup-file-select')?.value;
|
||||
const target = document.querySelector('input[name="restore_target"]:checked')?.value;
|
||||
if (!file) return alert('Select a backup file.');
|
||||
const payload = { backup_source: src, backup_file: file, target };
|
||||
if (target === 'remote') {
|
||||
payload.remote_ip = el('remote-ip')?.value.trim();
|
||||
payload.remote_port = el('remote-port')?.value.trim() || '22';
|
||||
payload.remote_user = el('remote-user')?.value.trim() || 'root';
|
||||
payload.auth_method = document.querySelector('input[name="auth_method"]:checked')?.value;
|
||||
if (payload.auth_method === 'key') payload.ssh_key_path = el('ssh-key-path')?.value.trim();
|
||||
else payload.ssh_password = el('ssh-password')?.value || '';
|
||||
if (!payload.remote_ip) return alert('Enter target IP.');
|
||||
}
|
||||
if (!confirm(`Restore "${file}" now?`)) return;
|
||||
if (el('restore-log-wrapper')) el('restore-log-wrapper').style.display = '';
|
||||
if (el('restore-log')) el('restore-log').innerHTML = '';
|
||||
try {
|
||||
const res = await fetch('/restore/start', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) });
|
||||
const data = await res.json();
|
||||
if (data.error) return appendLog(`❌ ${data.error}`);
|
||||
currentJobId = data.job_id;
|
||||
pollRestore();
|
||||
} catch (e) {
|
||||
appendLog(`❌ ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
function pollRestore() {
|
||||
if (pollInterval) clearInterval(pollInterval);
|
||||
let lastLine = 0;
|
||||
pollInterval = setInterval(async () => {
|
||||
if (!currentJobId) return;
|
||||
try {
|
||||
const r = await fetch(`/restore/status/${currentJobId}`);
|
||||
const d = await r.json();
|
||||
d.log.slice(lastLine).forEach(appendLog);
|
||||
lastLine = d.log.length;
|
||||
if (el('restore-elapsed')) el('restore-elapsed').textContent = `⏱ ${d.elapsed}s`;
|
||||
if (d.status !== 'running') clearInterval(pollInterval);
|
||||
} catch (_) {}
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
function refreshAll() {
|
||||
const btn = document.querySelector('.icon-btn');
|
||||
if (btn) btn.classList.add('spinning');
|
||||
Promise.all([checkServerStatus(), refreshSystemMetrics(), refreshContainerStats(), refreshSidebarNavBadges()])
|
||||
.finally(() => { if (btn) btn.classList.remove('spinning'); });
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
checkServerStatus();
|
||||
refreshSystemMetrics();
|
||||
refreshContainerStats();
|
||||
refreshSidebarNavBadges();
|
||||
if (el('all-containers-body')) loadAllContainers();
|
||||
if (el('backup-history-list')) { refreshBackupsList(); loadBackupLog(); }
|
||||
if (el('users-grid')) loadUsers();
|
||||
if (window.restorePrefill && el('backup-file-select')) {
|
||||
const { source, file } = window.restorePrefill;
|
||||
if (source) {
|
||||
const sourceRadio = document.querySelector(`input[name="backup_source"][value="${source}"]`);
|
||||
if (sourceRadio) sourceRadio.checked = true;
|
||||
updateBackupList();
|
||||
}
|
||||
if (file) {
|
||||
const sel = el('backup-file-select');
|
||||
for (const opt of sel.options) {
|
||||
if (opt.value === file) { opt.selected = true; break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
setInterval(() => { refreshSystemMetrics(); refreshContainerStats(); refreshSidebarNavBadges(); }, 15000);
|
||||
setInterval(checkServerStatus, 30000);
|
||||
});
|
||||
Reference in New Issue
Block a user