508 lines
17 KiB
HTML
508 lines
17 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>GoDump</title>
|
|
<link rel="icon" type="image/png" href="/icon.png">
|
|
<style>
|
|
:root {
|
|
--bg: #0a0a0a;
|
|
--surface: #141414;
|
|
--surface-hover: #1f1f1f;
|
|
--border: #2a2a2a;
|
|
--text-primary: #f0f0f0;
|
|
--text-secondary: #888888;
|
|
--accent: #21D198;
|
|
--accent-hover: #1cb582;
|
|
--success: #21D198;
|
|
--warning: #f59e0b;
|
|
--error: #ef4444;
|
|
--font: 'Inter', system-ui, -apple-system, sans-serif;
|
|
}
|
|
|
|
body {
|
|
margin: 0;
|
|
padding: 2rem;
|
|
background-color: var(--bg);
|
|
color: var(--text-primary);
|
|
font-family: var(--font);
|
|
line-height: 1.6;
|
|
}
|
|
|
|
h1, h2, h3, h4 {
|
|
margin-top: 0;
|
|
font-weight: 500;
|
|
letter-spacing: -0.02em;
|
|
}
|
|
|
|
.header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 2.5rem;
|
|
padding-bottom: 1rem;
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
|
|
.header h1 {
|
|
margin: 0;
|
|
font-size: 2.5rem;
|
|
color: var(--text-primary);
|
|
font-weight: 700;
|
|
}
|
|
|
|
.header h1 span {
|
|
color: var(--accent);
|
|
}
|
|
|
|
.status-bar {
|
|
display: flex;
|
|
gap: 1.5rem;
|
|
margin-bottom: 3rem;
|
|
}
|
|
|
|
.stat-card {
|
|
background: var(--surface);
|
|
padding: 1.5rem 2rem;
|
|
border-radius: 8px;
|
|
flex: 1;
|
|
border: 1px solid var(--border);
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.stat-card::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0; left: 0; right: 0;
|
|
height: 2px;
|
|
background: var(--accent);
|
|
opacity: 0.5;
|
|
}
|
|
|
|
.stat-card .value {
|
|
font-size: 2.5rem;
|
|
font-weight: 300;
|
|
margin-bottom: 0.25rem;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.stat-card .label {
|
|
color: var(--text-secondary);
|
|
font-size: 0.75rem;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.1em;
|
|
}
|
|
|
|
.btn {
|
|
background: var(--accent);
|
|
color: #000;
|
|
border: 1px solid var(--accent);
|
|
padding: 0.5rem 1.25rem;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-family: inherit;
|
|
font-weight: 600;
|
|
font-size: 0.875rem;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.btn:hover:not(:disabled) {
|
|
background: var(--accent-hover);
|
|
border-color: var(--accent-hover);
|
|
box-shadow: 0 0 10px rgba(33, 209, 152, 0.3);
|
|
}
|
|
|
|
.btn:disabled {
|
|
background: var(--surface-hover);
|
|
border-color: var(--border);
|
|
color: var(--text-secondary);
|
|
cursor: not-allowed;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.btn-outline {
|
|
background: transparent;
|
|
color: var(--accent);
|
|
border: 1px solid var(--accent);
|
|
}
|
|
.btn-outline:hover:not(:disabled) {
|
|
background: rgba(33, 209, 152, 0.1);
|
|
color: var(--accent-hover);
|
|
}
|
|
|
|
.btn-danger {
|
|
background: transparent;
|
|
color: var(--error);
|
|
border: 1px solid var(--error);
|
|
}
|
|
.btn-danger:hover:not(:disabled) {
|
|
background: rgba(239, 68, 68, 0.1);
|
|
border-color: var(--error);
|
|
box-shadow: none;
|
|
}
|
|
|
|
.btn-sm {
|
|
padding: 0.25rem 0.75rem;
|
|
font-size: 0.75rem;
|
|
}
|
|
|
|
.instance-card {
|
|
background: var(--surface);
|
|
border: 1px solid var(--border);
|
|
border-radius: 8px;
|
|
padding: 2rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.instance-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: flex-start;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.instance-header h3 {
|
|
font-size: 1.5rem;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.instance-details {
|
|
display: flex;
|
|
gap: 2rem;
|
|
color: var(--text-secondary);
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
margin-top: 1rem;
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
th, td {
|
|
padding: 1rem;
|
|
text-align: left;
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
|
|
th {
|
|
color: var(--text-secondary);
|
|
font-weight: 500;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
font-size: 0.75rem;
|
|
}
|
|
|
|
tr:last-child td {
|
|
border-bottom: none;
|
|
}
|
|
|
|
tbody tr {
|
|
transition: background 0.2s;
|
|
}
|
|
|
|
tbody tr:hover {
|
|
background: rgba(255, 255, 255, 0.02);
|
|
}
|
|
|
|
.badge {
|
|
padding: 0.25rem 0.6rem;
|
|
border-radius: 4px;
|
|
font-size: 0.7rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
border: 1px solid transparent;
|
|
}
|
|
|
|
.badge.success { background: rgba(33, 209, 152, 0.1); color: var(--success); border-color: rgba(33, 209, 152, 0.3); }
|
|
.badge.failed { background: rgba(239, 68, 68, 0.1); color: var(--error); border-color: rgba(239, 68, 68, 0.3); }
|
|
.badge.running { background: rgba(59, 130, 246, 0.1); color: #60a5fa; border-color: rgba(59, 130, 246, 0.3); }
|
|
.badge.partial { background: rgba(245, 158, 11, 0.1); color: var(--warning); border-color: rgba(245, 158, 11, 0.3); }
|
|
|
|
.log-container {
|
|
background: #050505;
|
|
border-radius: 8px;
|
|
padding: 1.5rem;
|
|
margin-top: 1rem;
|
|
height: 350px;
|
|
overflow-y: auto;
|
|
font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
|
|
font-size: 0.85rem;
|
|
color: #888;
|
|
border: 1px solid var(--border);
|
|
box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
|
|
}
|
|
|
|
.log-container::-webkit-scrollbar { width: 8px; }
|
|
.log-container::-webkit-scrollbar-track { background: transparent; }
|
|
.log-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
|
|
.log-container::-webkit-scrollbar-thumb:hover { background: #444; }
|
|
|
|
.log-entry {
|
|
margin-bottom: 0.4rem;
|
|
white-space: pre-wrap;
|
|
line-height: 1.4;
|
|
}
|
|
.log-timestamp { color: #555; }
|
|
.log-info { color: var(--accent); }
|
|
.log-warn { color: var(--warning); }
|
|
.log-error { color: var(--error); }
|
|
.log-instance { color: #8b5cf6; font-weight: bold; }
|
|
|
|
.inventory-section {
|
|
margin-top: 4rem;
|
|
}
|
|
|
|
.db-inventory {
|
|
margin-bottom: 1.5rem;
|
|
padding-left: 1.5rem;
|
|
border-left: 2px solid var(--border);
|
|
}
|
|
|
|
.db-inventory:hover {
|
|
border-left-color: var(--accent);
|
|
}
|
|
|
|
.table-responsive {
|
|
width: 100%;
|
|
overflow-x: auto;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
body {
|
|
padding: 1rem;
|
|
}
|
|
.header {
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
gap: 1rem;
|
|
}
|
|
.status-bar {
|
|
flex-direction: column;
|
|
gap: 1rem;
|
|
}
|
|
.stat-card {
|
|
padding: 1rem 1.5rem;
|
|
}
|
|
.stat-card .value {
|
|
font-size: 2rem;
|
|
}
|
|
.instance-header {
|
|
flex-direction: column;
|
|
gap: 1rem;
|
|
}
|
|
.instance-details {
|
|
flex-direction: column;
|
|
gap: 0.25rem;
|
|
}
|
|
th, td {
|
|
padding: 0.75rem 0.5rem;
|
|
font-size: 0.8rem;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="header">
|
|
<div style="display: flex; align-items: center;">
|
|
<img src="/icon.png" alt="" style="height: 2.5rem; margin-right: 1rem; border-radius: 4px;" onerror="this.style.display='none'">
|
|
<h1>Go<span>Dump</span></h1>
|
|
</div>
|
|
<div style="display: flex; align-items: center;">
|
|
{{if .AuthEnabled}}
|
|
<button class="btn btn-outline" style="margin-right: 1rem;" onclick="window.location.href='/logout'">Sign Out</button>
|
|
{{end}}
|
|
<button class="btn" onclick="runAll()" {{if .AnyRunning}}disabled{{end}}>Run All Now</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="status-bar">
|
|
<div class="stat-card">
|
|
<div class="value">{{.TotalInstances}}</div>
|
|
<div class="label">Managed Instances</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="value">{{.TotalDatabases}}</div>
|
|
<div class="label">Discovered Databases</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="value" style="color: {{if gt .UnreachableCount 0}}var(--error){{else}}var(--success){{end}}">{{.UnreachableCount}}</div>
|
|
<div class="label">Unreachable Instances</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="value">{{formatBytes .TotalBackupSize}}</div>
|
|
<div class="label">Total Backup Size</div>
|
|
</div>
|
|
</div>
|
|
|
|
<h2>Instances</h2>
|
|
|
|
{{range .Instances}}
|
|
<div class="instance-card">
|
|
<div class="instance-header">
|
|
<div>
|
|
<h3>{{.Name}} <span class="badge {{if .IsRunning}}running{{else}}{{.OverallResult}}{{end}}">{{if .IsRunning}}Running{{else}}{{if .OverallResult}}{{.OverallResult}}{{else}}Pending{{end}}{{end}}</span></h3>
|
|
<div class="instance-details">
|
|
<span>Host: {{.Host}}</span>
|
|
<span>Last Run: {{formatTime .LastRunTime}}</span>
|
|
<span>Next Run: {{formatTime .NextRunTime}}</span>
|
|
</div>
|
|
</div>
|
|
<button class="btn" onclick="runInstance('{{.Name}}')" {{if .IsRunning}}disabled{{end}}>Run Now</button>
|
|
</div>
|
|
|
|
{{if .Databases}}
|
|
<details>
|
|
<summary style="cursor: pointer; outline: none; color: var(--text-secondary); font-weight: 500;">Show Databases ({{len .Databases}})</summary>
|
|
<div class="table-responsive" style="margin-top: 1rem;">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Database</th>
|
|
<th>First Discovered</th>
|
|
<th>Last Backup Time</th>
|
|
<th>Size</th>
|
|
<th>Result</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{range .Databases}}
|
|
<tr>
|
|
<td>{{.Name}}</td>
|
|
<td>{{formatTime .FirstDiscovered}}</td>
|
|
<td>{{formatTime .LastBackupTime}}</td>
|
|
<td>{{if gt .LastBackupSize 0}}{{formatBytes .LastBackupSize}}{{else}}-{{end}}</td>
|
|
<td>
|
|
{{if .LastBackupResult}}
|
|
<span class="badge {{.LastBackupResult}}">{{.LastBackupResult}}</span>
|
|
{{else}}
|
|
<span class="badge">Pending</span>
|
|
{{end}}
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</details>
|
|
{{else}}
|
|
<p style="color: var(--text-secondary); font-size: 0.875rem;">No databases discovered yet.</p>
|
|
{{end}}
|
|
</div>
|
|
{{end}}
|
|
|
|
<div class="inventory-section">
|
|
<h2>Backup Inventory</h2>
|
|
{{range .Inventory}}
|
|
<details class="instance-card" style="padding: 1rem 1.5rem; cursor: pointer;">
|
|
<summary style="font-size: 1.5rem; font-weight: 500; outline: none; list-style-position: inside;">
|
|
{{.Name}}
|
|
</summary>
|
|
<div style="cursor: default; margin-top: 1.5rem;">
|
|
{{$instName := .Name}}
|
|
{{range .Databases}}
|
|
{{$dbName := .Name}}
|
|
<details class="db-inventory" style="cursor: pointer;">
|
|
<summary style="font-size: 1.1rem; color: var(--text-secondary); margin: 0.5rem 0; outline: none; list-style-position: inside;">
|
|
{{.Name}} <span style="font-size: 0.8rem; opacity: 0.7;">({{len .Files}} files)</span>
|
|
</summary>
|
|
<div style="cursor: default; margin-top: 0.5rem;" class="table-responsive">
|
|
<table style="table-layout: fixed; width: 100%; min-width: 600px;">
|
|
<colgroup>
|
|
<col style="width: 40%;">
|
|
<col style="width: 25%;">
|
|
<col style="width: 12%;">
|
|
<col style="width: 23%;">
|
|
</colgroup>
|
|
<tbody>
|
|
{{range .Files}}
|
|
<tr>
|
|
<td style="word-break: break-all;">{{.Name}}</td>
|
|
<td>{{formatTime .Timestamp}}</td>
|
|
<td>{{formatBytes .Size}}</td>
|
|
<td style="text-align: right;">
|
|
<button class="btn btn-sm btn-outline" onclick="downloadFile('{{$instName}}', '{{$dbName}}', '{{.Name}}')">Download</button>
|
|
<button class="btn btn-sm btn-danger" onclick="deleteFile('{{$instName}}', '{{$dbName}}', '{{.Name}}')">Delete</button>
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</details>
|
|
{{end}}
|
|
</div>
|
|
</details>
|
|
{{end}}
|
|
</div>
|
|
|
|
<h2>Recent Logs</h2>
|
|
<div class="log-container" id="logs"></div>
|
|
|
|
<script>
|
|
function runAll() {
|
|
fetch('/api/run/all', { method: 'POST' }).then(() => window.location.reload());
|
|
}
|
|
|
|
function runInstance(name) {
|
|
fetch('/api/run/' + name, { method: 'POST' }).then(() => window.location.reload());
|
|
}
|
|
|
|
function downloadFile(inst, db, file) {
|
|
window.location.href = '/api/download?instance=' + encodeURIComponent(inst) + '&db=' + encodeURIComponent(db) + '&file=' + encodeURIComponent(file);
|
|
}
|
|
|
|
async function deleteFile(inst, db, file) {
|
|
if (!confirm('Are you sure you want to delete ' + file + '?')) return;
|
|
try {
|
|
const res = await fetch('/api/delete?instance=' + encodeURIComponent(inst) + '&db=' + encodeURIComponent(db) + '&file=' + encodeURIComponent(file), {
|
|
method: 'POST'
|
|
});
|
|
if (res.ok) {
|
|
window.location.reload();
|
|
} else {
|
|
alert('Failed to delete file');
|
|
}
|
|
} catch (e) {
|
|
console.error(e);
|
|
alert('Error deleting file');
|
|
}
|
|
}
|
|
|
|
async function fetchLogs() {
|
|
try {
|
|
const res = await fetch('/api/logs');
|
|
const logs = await res.json();
|
|
const container = document.getElementById('logs');
|
|
|
|
const isScrolledToBottom = container.scrollHeight - container.clientHeight <= container.scrollTop + 1;
|
|
|
|
container.innerHTML = logs.map(l => {
|
|
let levelClass = '';
|
|
if (l.level === 'INFO') levelClass = 'log-info';
|
|
if (l.level === 'WARN') levelClass = 'log-warn';
|
|
if (l.level === 'ERROR') levelClass = 'log-error';
|
|
|
|
const inst = l.instance ? `<span class="log-instance">[${l.instance}]</span> ` : '';
|
|
return `<div class="log-entry"><span class="log-timestamp">[${l.timestamp}]</span> <span class="${levelClass}">[${l.level}]</span> ${inst}${l.message}</div>`;
|
|
}).join('');
|
|
|
|
if (isScrolledToBottom) {
|
|
container.scrollTop = container.scrollHeight;
|
|
}
|
|
} catch (e) {
|
|
console.error('Failed to fetch logs:', e);
|
|
}
|
|
}
|
|
|
|
fetchLogs();
|
|
setInterval(fetchLogs, 10000);
|
|
</script>
|
|
</body>
|
|
</html>
|