implement activity logging system for user actions and system events

This commit is contained in:
CPTN Cosmo 2026-06-19 03:35:51 +02:00
parent 81f7031555
commit 88e38535fc
5 changed files with 958 additions and 500 deletions

View file

@ -9,28 +9,94 @@
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
</head>
<body>
<!-- Global KDE Oxygen SVG Gradient & Filter Defs -->
<svg style="display: none;">
<defs>
<linearGradient id="goldGrad" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#ffe673" />
<stop offset="30%" stop-color="#ffd03b" />
<stop offset="70%" stop-color="#e6a817" />
<stop offset="100%" stop-color="#b87a00" />
</linearGradient>
<linearGradient id="silverGrad" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="#f5f5f5" />
<stop offset="50%" stop-color="#cfcfcf" />
<stop offset="100%" stop-color="#8c8c8c" />
</linearGradient>
<linearGradient id="glassShine" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.85" />
<stop offset="50%" stop-color="#ffffff" stop-opacity="0.15" />
<stop offset="51%" stop-color="#ffffff" stop-opacity="0.0" />
</linearGradient>
<linearGradient id="glassShineRed" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.9" />
<stop offset="100%" stop-color="#ffffff" stop-opacity="0.0" />
</linearGradient>
<radialGradient id="blueBall" cx="30%" cy="30%" r="70%">
<stop offset="0%" stop-color="#a4ebff" />
<stop offset="30%" stop-color="#29b6f6" />
<stop offset="75%" stop-color="#0288d1" />
<stop offset="100%" stop-color="#01579b" />
</radialGradient>
<radialGradient id="redBall" cx="30%" cy="30%" r="70%">
<stop offset="0%" stop-color="#ff9999" />
<stop offset="30%" stop-color="#ef4444" />
<stop offset="75%" stop-color="#dc2626" />
<stop offset="100%" stop-color="#991b1b" />
</radialGradient>
<radialGradient id="greenBall" cx="30%" cy="30%" r="70%">
<stop offset="0%" stop-color="#c2f0c2" />
<stop offset="30%" stop-color="#4caf50" />
<stop offset="75%" stop-color="#388e3c" />
<stop offset="100%" stop-color="#1b5e20" />
</radialGradient>
<linearGradient id="blueArrowGrad" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#9ddcff" />
<stop offset="100%" stop-color="#1d73c9" />
</linearGradient>
<linearGradient id="pencilYellow" x1="0" y1="0" x2="1" y2="0">
<stop offset="0%" stop-color="#ffe066" />
<stop offset="50%" stop-color="#ffcc00" />
<stop offset="100%" stop-color="#cc9900" />
</linearGradient>
<linearGradient id="goldKeyGrad" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="#ffe680" />
<stop offset="40%" stop-color="#ffd42a" />
<stop offset="80%" stop-color="#d4aa00" />
<stop offset="100%" stop-color="#806600" />
</linearGradient>
<linearGradient id="paperGrad" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="#ffffff" />
<stop offset="100%" stop-color="#e2e8f0" />
</linearGradient>
</defs>
</svg>
<div class="container">
<header>
<div class="logo">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
<path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
<svg class="icon-oxygen" width="32" height="32" viewBox="0 0 48 48" fill="none">
<path d="M14 20V12a10 10 0 1 1 20 0v8" stroke="url(#silverGrad)" stroke-width="6" stroke-linecap="round" />
<rect x="8" y="18" width="32" height="26" rx="4" fill="url(#goldGrad)" stroke="#8f5900" stroke-width="1.5" />
<rect x="9" y="19" width="30" height="12" rx="3" fill="url(#glassShine)" />
<circle cx="24" cy="30" r="3" fill="#201000" />
<path d="M22 30h4l2 8h-8z" fill="#201000" />
</svg>
<h1>XIVLauncher Remote OTP</h1>
</div>
<div class="header-actions">
<button id="help-btn" class="btn btn-icon" title="Firewall Help">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"></circle>
<path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path>
<line x1="12" y1="17" x2="12.01" y2="17"></line>
<svg class="icon-oxygen" width="18" height="18" viewBox="0 0 48 48" fill="none">
<circle cx="24" cy="24" r="21" fill="url(#blueBall)" stroke="#013b68" stroke-width="1.5" />
<ellipse cx="24" cy="11" rx="14" ry="7" fill="url(#glassShineRed)" />
<path d="M20 18c0-3 2-5 5-5s5 2 5 5c0 2-1 3-3 4s-2 2-2 4v1m0 3v2" stroke="#ffffff" stroke-width="4.5" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</button>
<button id="logout-btn" class="btn btn-icon btn-logout" title="Logout" style="display: none;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></path>
<polyline points="16 17 21 12 16 7"></polyline>
<line x1="21" y1="12" x2="9" y2="12"></line>
<svg class="icon-oxygen" width="18" height="18" viewBox="0 0 48 48" fill="none">
<circle cx="24" cy="24" r="21" fill="url(#redBall)" stroke="#7f1d1d" stroke-width="1.5" />
<ellipse cx="24" cy="11" rx="14" ry="7" fill="url(#glassShineRed)" />
<path d="M24 12v12m-8-8a11 11 0 1 0 16 0" stroke="#ffffff" stroke-width="4.5" stroke-linecap="round" />
</svg>
</button>
</div>
@ -50,13 +116,15 @@
<h2>Managed Instances</h2>
<div class="actions">
<button class="btn btn-primary btn-sm" id="show-add-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
<svg class="icon-oxygen" width="14" height="14" viewBox="0 0 48 48" fill="none" style="margin-right: 4px;">
<circle cx="24" cy="24" r="21" fill="url(#greenBall)" stroke="#0d3c12" stroke-width="1.5" />
<path d="M24 14v20M14 24h20" stroke="#ffffff" stroke-width="5" stroke-linecap="round" />
</svg>
Add
</button>
<button class="btn btn-icon" id="refresh-btn" title="Refresh">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="23 4 23 10 17 10"></polyline>
<path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"></path>
<svg class="icon-oxygen" width="18" height="18" viewBox="0 0 48 48" fill="none">
<path d="M38 24a14 14 0 1 1-4.1-9.9L38 18M38 10v8h-8" stroke="url(#blueArrowGrad)" stroke-width="5" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</button>
</div>
@ -72,7 +140,10 @@
<div class="instances-header">
<h2>OTP Secrets</h2>
<button class="btn btn-primary btn-sm" id="show-add-otp-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
<svg class="icon-oxygen" width="14" height="14" viewBox="0 0 48 48" fill="none" style="margin-right: 4px;">
<circle cx="24" cy="24" r="21" fill="url(#greenBall)" stroke="#0d3c12" stroke-width="1.5" />
<path d="M24 14v20M14 24h20" stroke="#ffffff" stroke-width="5" stroke-linecap="round" />
</svg>
Add Secret
</button>
</div>
@ -87,7 +158,10 @@
<div class="instances-header">
<h2>User Management</h2>
<button class="btn btn-primary btn-sm" id="show-add-user-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
<svg class="icon-oxygen" width="14" height="14" viewBox="0 0 48 48" fill="none" style="margin-right: 4px;">
<circle cx="24" cy="24" r="21" fill="url(#greenBall)" stroke="#0d3c12" stroke-width="1.5" />
<path d="M24 14v20M14 24h20" stroke="#ffffff" stroke-width="5" stroke-linecap="round" />
</svg>
Add User
</button>
</div>
@ -122,6 +196,28 @@
<div id="profile-success" class="success-msg" style="display: none;">Profile updated successfully!</div>
</div>
</div>
<div id="logs-toggle-container" class="logs-toggle-container">
<label class="switch-container">
<input type="checkbox" id="logs-toggle">
<span class="switch-slider"></span>
<span class="switch-label">Show Detailed System Logs</span>
</label>
</div>
<div id="logs-section" class="card logs-card" style="display: none;">
<div class="logs-header">
<h3>System Logs</h3>
<div class="logs-actions">
<button class="btn btn-icon btn-sm" id="logs-refresh-btn" title="Refresh Logs">
<svg class="icon-oxygen" width="14" height="14" viewBox="0 0 48 48" fill="none">
<path d="M38 24a14 14 0 1 1-4.1-9.9L38 18M38 10v8h-8" stroke="url(#blueArrowGrad)" stroke-width="5" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</button>
</div>
</div>
<div id="logs-viewer" class="logs-viewer"></div>
</div>
</main>
</div>
@ -216,7 +312,7 @@
<div class="code-wrapper">
<code id="ufw-cmd">sudo ufw allow from localhost to any port 4646 proto tcp</code>
<button class="btn-copy" onclick="copyToClipboard('ufw-cmd')" title="Copy to clipboard">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
<svg class="icon-oxygen" width="14" height="14" viewBox="0 0 48 48" fill="none"><rect x="14" y="6" width="26" height="32" rx="2" fill="url(#paperGrad)" stroke="#2e8bdc" stroke-width="2" /><rect x="8" y="12" width="26" height="32" rx="2" fill="url(#paperGrad)" stroke="#2e8bdc" stroke-width="2" /><line x1="14" y1="20" x2="28" y2="20" stroke="#94a3b8" stroke-width="2" /><line x1="14" y1="26" x2="28" y2="26" stroke="#94a3b8" stroke-width="2" /><line x1="14" y1="32" x2="24" y2="32" stroke="#94a3b8" stroke-width="2" /></svg>
</button>
</div>
</div>
@ -225,7 +321,7 @@
<div class="code-wrapper">
<code id="iptables-cmd">sudo iptables -I INPUT -p tcp -s localhost --dport 4646 -j ACCEPT</code>
<button class="btn-copy" onclick="copyToClipboard('iptables-cmd')" title="Copy to clipboard">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
<svg class="icon-oxygen" width="14" height="14" viewBox="0 0 48 48" fill="none"><rect x="14" y="6" width="26" height="32" rx="2" fill="url(#paperGrad)" stroke="#2e8bdc" stroke-width="2" /><rect x="8" y="12" width="26" height="32" rx="2" fill="url(#paperGrad)" stroke="#2e8bdc" stroke-width="2" /><line x1="14" y1="20" x2="28" y2="20" stroke="#94a3b8" stroke-width="2" /><line x1="14" y1="26" x2="28" y2="26" stroke="#94a3b8" stroke-width="2" /><line x1="14" y1="32" x2="24" y2="32" stroke="#94a3b8" stroke-width="2" /></svg>
</button>
</div>
</div>
@ -234,7 +330,7 @@
<div class="code-wrapper">
<code id="win-cmd">New-NetFirewallRule -DisplayName "XIVLauncher OTP" -Direction Inbound -RemoteAddress localhost -LocalPort 4646 -Protocol TCP -Action Allow</code>
<button class="btn-copy" onclick="copyToClipboard('win-cmd')" title="Copy to clipboard">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
<svg class="icon-oxygen" width="14" height="14" viewBox="0 0 48 48" fill="none"><rect x="14" y="6" width="26" height="32" rx="2" fill="url(#paperGrad)" stroke="#2e8bdc" stroke-width="2" /><rect x="8" y="12" width="26" height="32" rx="2" fill="url(#paperGrad)" stroke="#2e8bdc" stroke-width="2" /><line x1="14" y1="20" x2="28" y2="20" stroke="#94a3b8" stroke-width="2" /><line x1="14" y1="26" x2="28" y2="26" stroke="#94a3b8" stroke-width="2" /><line x1="14" y1="32" x2="24" y2="32" stroke="#94a3b8" stroke-width="2" /></svg>
</button>
</div>
</div>
@ -244,9 +340,12 @@
<div id="login-overlay" class="login-overlay">
<div class="login-card">
<div class="logo">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
<path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
<svg class="icon-oxygen" width="32" height="32" viewBox="0 0 48 48" fill="none">
<path d="M14 20V12a10 10 0 1 1 20 0v8" stroke="url(#silverGrad)" stroke-width="6" stroke-linecap="round" />
<rect x="8" y="18" width="32" height="26" rx="4" fill="url(#goldGrad)" stroke="#8f5900" stroke-width="1.5" />
<rect x="9" y="19" width="30" height="12" rx="3" fill="url(#glassShine)" />
<circle cx="24" cy="30" r="3" fill="#201000" />
<path d="M22 30h4l2 8h-8z" fill="#201000" />
</svg>
<h2>Login</h2>
</div>
@ -262,6 +361,23 @@
<button type="submit" class="btn btn-primary">Login</button>
</form>
<div id="login-error" class="login-error" style="display: none;">Invalid username or password</div>
<div class="divider" style="margin: 1.5rem 0;"></div>
<div class="login-firewall-section">
<h3 style="font-size: 0.875rem; font-weight: 600; margin-bottom: 0.5rem;">Firewall Connection Info</h3>
<p class="helper-text" style="font-size: 0.75rem; margin-bottom: 0.75rem;">To allow this server to send OTP codes, ensure your XIVLauncher machine allows connections from:</p>
<div class="firewall-ip-display" style="display: flex; align-items: center; justify-content: space-between; background-color: var(--bg-color); border: 1px solid var(--border-color); border-radius: 6px; padding: 0.5rem 0.75rem; margin-bottom: 0.75rem;">
<span class="ip-label" style="font-size: 0.75rem; color: var(--text-muted); font-weight: 500;">Host IP</span>
<code id="login-firewall-ip" style="font-family: monospace; font-size: 0.875rem; color: #34d399;">Loading...</code>
</div>
<button type="button" id="login-show-help-btn" class="btn btn-secondary btn-sm" style="width: 100%; display: flex; justify-content: center; align-items: center; gap: 0.375rem; font-size: 0.75rem; padding: 0.5rem;">
<svg class="icon-oxygen" width="14" height="14" viewBox="0 0 48 48" fill="none">
<circle cx="24" cy="24" r="21" fill="url(#blueBall)" stroke="#013b68" stroke-width="1.5" />
<ellipse cx="24" cy="11" rx="14" ry="7" fill="url(#glassShineRed)" />
<path d="M20 18c0-3 2-5 5-5s5 2 5 5c0 2-1 3-3 4s-2 2-2 4v1m0 3v2" stroke="#ffffff" stroke-width="4.5" stroke-linecap="round" stroke-linejoin="round" />
</svg>
Show Setup Commands
</button>
</div>
</div>
</div>