Initial commit: CloudOps infrastructure platform

This commit is contained in:
root
2026-04-09 19:58:57 +02:00
commit 1166a52f26
7762 changed files with 839452 additions and 0 deletions

View File

@@ -0,0 +1,645 @@
/* Modern Design System */
:root {
--primary: #2563eb;
--primary-dark: #1d4ed8;
--primary-light: #3b82f6;
--primary-soft: #eff6ff;
--secondary: #64748b;
--accent: #f59e0b;
--success: #10b981;
--warning: #f59e0b;
--danger: #ef4444;
--dark: #0f172a;
--gray-dark: #334155;
--gray: #64748b;
--gray-light: #e2e8f0;
--light: #f8fafc;
--white: #ffffff;
--sidebar-width: 280px;
--radius-sm: 8px;
--radius-md: 12px;
--radius-lg: 16px;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #f1f5f9;
color: var(--dark);
line-height: 1.5;
}
.app {
display: flex;
min-height: 100vh;
}
/* Sidebar */
.sidebar {
width: var(--sidebar-width);
background: var(--white);
position: fixed;
height: 100vh;
overflow-y: auto;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
border-right: 1px solid var(--gray-light);
z-index: 100;
}
.sidebar-header {
padding: 32px 24px;
border-bottom: 1px solid var(--gray-light);
margin-bottom: 24px;
}
.sidebar-header h2 {
font-size: 22px;
font-weight: 700;
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
margin-bottom: 6px;
}
.sidebar-header p {
font-size: 13px;
color: var(--gray);
font-weight: 500;
}
.nav-menu {
padding: 0 16px;
}
.nav-item {
padding: 12px 16px;
margin: 4px 0;
border-radius: var(--radius-md);
cursor: pointer;
transition: all 0.2s;
display: flex;
align-items: center;
gap: 12px;
color: var(--gray-dark);
font-weight: 500;
font-size: 14px;
}
.nav-item:hover {
background: var(--primary-soft);
color: var(--primary);
}
.nav-item.active {
background: var(--primary-soft);
color: var(--primary);
font-weight: 600;
}
.nav-icon {
width: 20px;
font-size: 16px;
text-align: center;
}
/* Main Content */
.main-content {
flex: 1;
margin-left: var(--sidebar-width);
padding: 32px 40px;
}
/* Top Bar */
.top-bar {
background: var(--white);
padding: 20px 28px;
border-radius: var(--radius-lg);
margin-bottom: 28px;
box-shadow: 0 1px 2px rgba(0,0,0,0.05);
border: 1px solid var(--gray-light);
display: flex;
justify-content: space-between;
align-items: center;
}
.top-bar h3 {
font-size: 20px;
font-weight: 600;
color: var(--dark);
}
.server-status {
display: flex;
align-items: center;
gap: 20px;
}
.status-indicator {
display: flex;
align-items: center;
gap: 8px;
font-size: 13px;
font-weight: 500;
color: var(--gray);
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
}
.status-dot.online {
background: var(--success);
box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}
.status-dot.offline {
background: var(--danger);
box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}
/* Buttons */
.btn {
padding: 8px 18px;
border: none;
border-radius: var(--radius-md);
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s;
display: inline-flex;
align-items: center;
gap: 8px;
}
.btn-primary {
background: var(--primary);
color: white;
}
.btn-primary:hover {
background: var(--primary-dark);
transform: translateY(-1px);
}
.btn-danger {
background: var(--danger);
color: white;
}
.btn-danger:hover {
background: #dc2626;
transform: translateY(-1px);
}
.btn-secondary {
background: var(--gray-light);
color: var(--gray-dark);
border: 1px solid transparent;
}
.btn-secondary:hover {
background: var(--white);
border-color: var(--gray-light);
}
/* Cards */
.card {
background: var(--white);
border-radius: var(--radius-lg);
padding: 24px 28px;
margin-bottom: 24px;
box-shadow: 0 1px 2px rgba(0,0,0,0.05);
border: 1px solid var(--gray-light);
transition: all 0.2s;
}
.card:hover {
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
padding-bottom: 16px;
border-bottom: 2px solid var(--gray-light);
}
.card-title {
font-size: 18px;
font-weight: 600;
color: var(--dark);
display: flex;
align-items: center;
gap: 10px;
}
/* Container Cards */
.containers-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 16px;
}
.container-card {
background: var(--light);
border-radius: var(--radius-md);
padding: 16px 20px;
transition: all 0.2s;
border: 1px solid var(--gray-light);
}
.container-card.running {
border-left: 4px solid var(--success);
}
.container-card.stopped {
border-left: 4px solid var(--danger);
}
.container-card:hover {
transform: translateY(-2px);
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
background: var(--white);
}
.container-name {
font-weight: 600;
font-size: 15px;
margin-bottom: 8px;
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
}
.container-name span {
display: flex;
align-items: center;
gap: 8px;
}
.container-status {
font-size: 12px;
color: var(--gray);
margin-top: 6px;
display: flex;
align-items: center;
gap: 6px;
}
/* Badges */
.badge {
padding: 4px 12px;
border-radius: 20px;
font-size: 11px;
font-weight: 600;
}
.badge-running {
background: rgba(16, 185, 129, 0.1);
color: var(--success);
}
.badge-stopped {
background: rgba(239, 68, 68, 0.1);
color: var(--danger);
}
/* Stats Grid */
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 16px;
}
.stat-card {
text-align: center;
padding: 20px;
background: var(--light);
border-radius: var(--radius-md);
transition: all 0.2s;
border: 1px solid var(--gray-light);
}
.stat-card:hover {
background: var(--white);
transform: translateY(-2px);
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.stat-number {
font-size: 32px;
font-weight: 700;
color: var(--primary);
margin-bottom: 8px;
}
.stat-label {
font-size: 13px;
color: var(--gray);
font-weight: 500;
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
}
/* Two Column */
.two-column {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 28px;
}
.two-column h3 {
font-size: 16px;
font-weight: 600;
margin-bottom: 12px;
color: var(--dark);
display: flex;
align-items: center;
gap: 8px;
}
.two-column p {
font-size: 13px;
color: var(--gray);
margin-bottom: 16px;
}
/* Select */
select {
padding: 10px 14px;
border: 1px solid var(--gray-light);
border-radius: var(--radius-md);
font-size: 13px;
font-weight: 500;
background: var(--white);
cursor: pointer;
width: 100%;
color: var(--dark);
margin-bottom: 16px;
}
select:hover {
border-color: var(--primary);
}
select:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
/* Backup List */
.backup-list {
max-height: 320px;
overflow-y: auto;
}
.backup-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 16px;
background: var(--light);
border-radius: var(--radius-md);
margin-bottom: 8px;
transition: all 0.2s;
border: 1px solid var(--gray-light);
}
.backup-item:hover {
background: var(--white);
border-color: var(--primary);
transform: translateX(4px);
}
.backup-date {
font-family: monospace;
font-size: 12px;
color: var(--dark);
font-weight: 500;
display: flex;
align-items: center;
gap: 8px;
}
.backup-size {
font-size: 11px;
color: var(--gray);
font-weight: 500;
background: var(--gray-light);
padding: 2px 8px;
border-radius: 20px;
display: flex;
align-items: center;
gap: 4px;
}
/* Restore Status */
.restore-status {
margin-top: 24px;
padding: 14px 20px;
border-radius: var(--radius-md);
display: none;
font-size: 13px;
font-weight: 500;
}
.restore-status.success {
background: rgba(16, 185, 129, 0.08);
color: var(--success);
border-left: 3px solid var(--success);
}
.restore-status.error {
background: rgba(239, 68, 68, 0.08);
color: var(--danger);
border-left: 3px solid var(--danger);
}
.restore-status.warning {
background: rgba(245, 158, 11, 0.08);
color: var(--accent);
border-left: 3px solid var(--accent);
}
/* Footer */
.footer {
text-align: center;
padding: 24px 0 0;
color: var(--gray);
font-size: 12px;
margin-top: 40px;
border-top: 1px solid var(--gray-light);
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
}
/* Scrollbar */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: var(--gray-light);
border-radius: 10px;
}
::-webkit-scrollbar-thumb {
background: var(--primary);
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--primary-dark);
}
/* Responsive */
@media (max-width: 768px) {
.sidebar {
transform: translateX(-100%);
}
.main-content {
margin-left: 0;
padding: 20px;
}
.two-column {
grid-template-columns: 1fr;
}
.containers-grid {
grid-template-columns: 1fr;
}
.top-bar {
flex-direction: column;
align-items: flex-start;
gap: 12px;
}
}
/* ─── Add these to your existing style.css ─────────────────────────────── */
/* Restore form layout */
.restore-form { display: flex; flex-direction: column; gap: 0; }
.form-section {
border-bottom: 1px solid var(--border, #e5e7eb);
padding: 20px 0;
}
.form-section-title {
font-size: 13px;
font-weight: 600;
letter-spacing: 0.07em;
text-transform: uppercase;
color: var(--gray, #6b7280);
margin-bottom: 14px;
}
/* Radio cards */
.radio-group {
display: flex;
gap: 12px;
flex-wrap: wrap;
}
.radio-card {
cursor: pointer;
flex: 1;
min-width: 180px;
}
.radio-card input[type="radio"] { display: none; }
.radio-body {
display: flex;
align-items: center;
gap: 12px;
padding: 14px 16px;
border: 2px solid var(--border, #e5e7eb);
border-radius: 12px;
background: var(--light, #f9fafb);
transition: border-color 0.15s, background 0.15s;
}
.radio-card input:checked + .radio-body {
border-color: var(--primary, #6366f1);
background: #eef2ff;
}
.radio-icon { font-size: 22px; }
.radio-label { font-weight: 600; font-size: 14px; }
.radio-desc { font-size: 12px; color: var(--gray, #6b7280); }
.radio-desc code { background: #e5e7eb; padding: 1px 5px; border-radius: 4px; font-size: 11px; }
/* Small radio cards (auth method) */
.radio-card.small .radio-body { padding: 10px 14px; gap: 8px; }
.radio-card.small .radio-label { font-size: 13px; }
/* Form controls */
.form-group { margin-bottom: 14px; }
.form-label {
display: block;
font-size: 13px;
font-weight: 500;
margin-bottom: 6px;
color: var(--dark, #111827);
}
.form-control {
width: 100%;
padding: 10px 14px;
border: 1px solid var(--border, #e5e7eb);
border-radius: 10px;
font-size: 14px;
background: #fff;
box-sizing: border-box;
transition: border-color 0.15s;
}
.form-control:focus {
outline: none;
border-color: var(--primary, #6366f1);
}
.form-row {
display: flex;
gap: 14px;
}
.form-row .form-group { flex: 1; }
/* Buttons */
.btn-lg { padding: 14px 28px; font-size: 15px; font-weight: 600; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
/* Log console */
.log-console {
background: #0f172a;
border-radius: 10px;
padding: 16px;
font-family: 'Courier New', monospace;
font-size: 12.5px;
line-height: 1.6;
max-height: 420px;
overflow-y: auto;
color: #e2e8f0;
}
.log-line { white-space: pre-wrap; word-break: break-all; }
/* Backup list items */
.backup-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 14px;
border-radius: 8px;
margin-bottom: 8px;
background: var(--light, #f9fafb);
gap: 10px;
flex-wrap: wrap;
}
.backup-date { font-size: 13px; font-family: monospace; word-break: break-all; }

216
platform/static/js/main.js Normal file
View File

@@ -0,0 +1,216 @@
// Navigation
document.querySelectorAll('.nav-item').forEach(item => {
item.addEventListener('click', () => {
const page = item.dataset.page;
document.querySelectorAll('.nav-item').forEach(nav => nav.classList.remove('active'));
item.classList.add('active');
document.querySelectorAll('.page').forEach(p => p.style.display = 'none');
const pageElement = document.getElementById(page + '-page');
if (pageElement) pageElement.style.display = 'block';
const titles = {'dashboard': 'Dashboard Overview', 'restore': 'Restore Actions', 'backups': 'Backup Management', 'settings': 'Platform Settings'};
const titleElement = document.getElementById('page-title');
if (titleElement) titleElement.textContent = titles[page];
});
});
function checkServerStatus() {
fetch('/server/status')
.then(res => res.json())
.then(data => {
const statusText = document.getElementById('server-status-text');
const statusDot = document.getElementById('server-status-dot');
if (statusText && statusDot) {
if (data.status === 'online') {
statusText.innerHTML = data.info;
statusDot.className = 'status-dot online';
} else {
statusText.innerHTML = 'Offline';
statusDot.className = 'status-dot offline';
}
}
})
.catch(() => {
const statusText = document.getElementById('server-status-text');
const statusDot = document.getElementById('server-status-dot');
if (statusText) statusText.innerHTML = 'Connection Failed';
if (statusDot) statusDot.className = 'status-dot offline';
});
}
// Backup functionality
let backupEventSource = null;
window.runBackupNow = function() {
if(confirm('⚠️ Run backup now? This will take a few minutes.')) {
const progressDiv = document.getElementById('backup-progress');
const progressBar = document.getElementById('backup-progress-bar');
const logDiv = document.getElementById('backup-log');
const runBtn = document.getElementById('runBackupBtn');
if (progressDiv) progressDiv.style.display = 'block';
if (runBtn) {
runBtn.disabled = true;
runBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Running Backup...';
}
if (logDiv) logDiv.innerHTML = '';
fetch('/backup/run')
.then(res => res.json())
.then(data => {
if (data.error) throw new Error(data.error);
if (backupEventSource) backupEventSource.close();
backupEventSource = new EventSource('/backup/stream');
backupEventSource.onmessage = function(event) {
const data = JSON.parse(event.data);
if (logDiv) {
const line = document.createElement('div');
line.textContent = data.line;
logDiv.appendChild(line);
logDiv.scrollTop = logDiv.scrollHeight;
}
if (data.complete) {
backupEventSource.close();
if (progressBar) progressBar.style.width = '100%';
setTimeout(() => {
if (progressDiv) progressDiv.style.display = 'none';
if (runBtn) {
runBtn.disabled = false;
runBtn.innerHTML = '<i class="fas fa-play"></i> Run Backup Now';
}
refreshStatus();
}, 2000);
}
};
})
.catch(err => {
if (logDiv) logDiv.innerHTML = `<div style="color: red;">❌ Error: ${err.message}</div>`;
if (runBtn) {
runBtn.disabled = false;
runBtn.innerHTML = '<i class="fas fa-play"></i> Run Backup Now';
}
});
}
};
window.restoreLocal = function() {
const backup = document.getElementById('local-backup');
if (!backup) return;
const backupValue = backup.value;
if(confirm('⚠️ Restore from ' + backupValue.split('/').pop() + '?\n\nThis will overwrite current data on this server!')) {
const statusDiv = document.getElementById('restore-status');
if (statusDiv) {
statusDiv.style.display = 'block';
statusDiv.className = 'restore-status warning';
statusDiv.innerHTML = '<p>🔄 Starting restore from local backup...</p>';
}
fetch('/restore/local?backup=' + encodeURIComponent(backupValue))
.then(res => res.json())
.then(data => {
if (statusDiv) {
if (data.error) {
statusDiv.className = 'restore-status error';
statusDiv.innerHTML = '<p>❌ ' + data.error + '</p>';
} else {
statusDiv.className = 'restore-status success';
statusDiv.innerHTML = '<p>✅ ' + data.status + '</p>';
}
}
})
.catch(err => {
if (statusDiv) {
statusDiv.className = 'restore-status error';
statusDiv.innerHTML = '<p>❌ Restore failed: ' + err + '</p>';
}
});
}
};
window.disasterRestore = function() {
const backupFile = document.getElementById('vm-backup-select').value;
const targetIp = document.getElementById('target-ip').value;
const targetUser = document.getElementById('target-user').value || 'root';
const targetPassword = document.getElementById('target-password').value;
if (!targetIp) {
alert('Please enter target server IP');
return;
}
if(confirm(`⚠️ DISASTER RESTORE to ${targetIp}\n\nBackup: ${backupFile.split('/').pop()}\n\nThis will OVERWRITE containers on the target server! Continue?`)) {
const statusDiv = document.getElementById('disaster-status');
if (statusDiv) {
statusDiv.style.display = 'block';
statusDiv.className = 'restore-status warning';
statusDiv.innerHTML = '<p>🔄 Starting disaster restore to ' + targetIp + '...</p>';
}
fetch('/disaster/restore', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
backup_file: backupFile,
target_ip: targetIp,
target_user: targetUser,
target_password: targetPassword
})
})
.then(res => res.json())
.then(data => {
if (statusDiv) {
if (data.error) {
statusDiv.className = 'restore-status error';
statusDiv.innerHTML = '<p>❌ ' + data.error + '</p>';
} else {
statusDiv.className = 'restore-status success';
statusDiv.innerHTML = '<p>✅ ' + data.status + '<br>Target: ' + data.target + '</p>';
}
}
})
.catch(err => {
if (statusDiv) {
statusDiv.className = 'restore-status error';
statusDiv.innerHTML = '<p>❌ Restore failed: ' + err + '</p>';
}
});
}
};
window.refreshStatus = function() { location.reload(); };
window.refreshAll = function() { fetch('/server/status').then(() => location.reload()); };
// Add backup panel to Backups page
document.addEventListener('DOMContentLoaded', () => {
checkServerStatus();
const backupsNav = document.querySelector('.nav-item[data-page="backups"]');
if (backupsNav) {
backupsNav.addEventListener('click', () => {
setTimeout(() => {
if (document.getElementById('backup-panel')) return;
const backupsPage = document.getElementById('backups-page');
if (backupsPage) {
const backupPanel = document.createElement('div');
backupPanel.id = 'backup-panel';
backupPanel.className = 'card';
backupPanel.innerHTML = `
<div class="card-header"><div class="card-title"><span>📦</span><span>Manual Backup</span></div></div>
<div style="padding: 20px; background: var(--primary-soft); border-radius: 12px;">
<h3 style="margin-bottom: 10px;">Run Backup Now</h3>
<p style="color: var(--gray); margin-bottom: 15px;">Manually trigger a backup of all containers</p>
<button id="runBackupBtn" class="btn btn-primary" onclick="runBackupNow()"><i class="fas fa-play"></i> Run Backup Now</button>
<div id="backup-progress" style="display: none; margin-top: 15px;">
<div style="background: var(--gray-light); border-radius: 10px; overflow: hidden;"><div id="backup-progress-bar" style="width: 0%; height: 20px; background: var(--success); transition: width 0.3s;"></div></div>
<div id="backup-log" style="margin-top: 10px; max-height: 200px; overflow-y: auto; background: #1e1e1e; color: #d4d4d4; padding: 10px; border-radius: 8px; font-family: monospace; font-size: 11px;"></div>
</div>
</div>
`;
backupsPage.insertBefore(backupPanel, backupsPage.firstChild);
}
}, 100);
});
}
});