bugfix on service discovery, and rework pf the dashboard

This commit is contained in:
Pierre
2026-02-02 00:02:55 +01:00
parent 9b4a802ff3
commit 7886870046
13 changed files with 923 additions and 707 deletions
+14 -25
View File
@@ -35,31 +35,6 @@ http {
listen 80;
server_name _;
# Welcome page at root
location = / {
root /app/welcome;
try_files /welcome.html =404;
}
# Redirect /stats to /stats/
location = /stats {
return 301 /stats/;
}
# VFS Statistics dashboard (React SPA)
location /stats/ {
alias /app/ui/;
index index.html;
try_files $uri $uri/ /stats/index.html;
}
# Static assets for stats dashboard
location /assets/ {
alias /app/ui/assets/;
expires 1y;
add_header Cache-Control "public, immutable";
}
# API routes
location /api/ {
proxy_pass http://api;
@@ -97,5 +72,19 @@ http {
proxy_send_timeout 300;
proxy_read_timeout 300;
}
# Static assets
location /assets/ {
alias /app/ui/assets/;
expires 1y;
add_header Cache-Control "public, immutable";
}
# React SPA at root (catch-all)
location / {
alias /app/ui/;
index index.html;
try_files $uri $uri/ /index.html;
}
}
}
-518
View File
@@ -1,518 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>meta-fuse - Virtual Filesystem</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
color: #e0e0e0;
min-height: 100vh;
padding: 40px 20px;
}
.container {
max-width: 900px;
margin: 0 auto;
}
header {
text-align: center;
margin-bottom: 50px;
}
h1 {
font-size: 3em;
background: linear-gradient(135deg, #4ecdc4, #44a08d);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 12px;
}
.subtitle {
color: #a0a0a0;
font-size: 1.2em;
}
.status-bar {
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
margin-top: 20px;
padding: 12px 24px;
background: rgba(255, 255, 255, 0.05);
border-radius: 30px;
display: inline-flex;
}
.status-item {
display: flex;
align-items: center;
gap: 8px;
font-size: 0.9em;
}
.status-dot {
width: 10px;
height: 10px;
border-radius: 50%;
background: #4ecdc4;
animation: pulse 2s infinite;
}
.status-dot.disconnected {
background: #ff6b6b;
animation: none;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.description {
background: rgba(255, 255, 255, 0.05);
border-radius: 16px;
padding: 30px;
margin-bottom: 40px;
border: 1px solid rgba(255, 255, 255, 0.1);
}
.description h2 {
color: #4ecdc4;
margin-bottom: 16px;
font-size: 1.4em;
}
.description p {
line-height: 1.8;
color: #b0b0b0;
}
.description ul {
margin: 16px 0 0 24px;
line-height: 2;
color: #b0b0b0;
}
.services {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 24px;
margin-bottom: 40px;
}
.service-card {
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 16px;
padding: 28px;
text-decoration: none;
color: inherit;
transition: all 0.3s ease;
}
.service-card:hover {
transform: translateY(-4px);
border-color: #4ecdc4;
box-shadow: 0 8px 30px rgba(78, 205, 196, 0.2);
}
.service-card .icon {
font-size: 2.5em;
margin-bottom: 16px;
}
.service-card h3 {
color: #fff;
font-size: 1.3em;
margin-bottom: 10px;
}
.service-card p {
color: #a0a0a0;
line-height: 1.6;
margin-bottom: 16px;
}
.service-url {
font-family: 'Courier New', monospace;
font-size: 0.9em;
color: #4ecdc4;
background: rgba(78, 205, 196, 0.1);
padding: 6px 12px;
border-radius: 6px;
display: inline-block;
}
/* Collapsible Setup Section */
.setup-section {
margin-bottom: 40px;
}
.setup-header {
display: flex;
align-items: center;
justify-content: space-between;
cursor: pointer;
padding: 18px 24px;
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 12px;
transition: all 0.3s ease;
user-select: none;
}
.setup-header:hover {
background: rgba(255, 255, 255, 0.08);
border-color: rgba(78, 205, 196, 0.3);
}
.setup-header h3 {
color: #a0a0a0;
font-size: 1.1em;
margin: 0;
}
.toggle-icon {
font-size: 1.2em;
color: #606060;
transition: transform 0.3s ease;
}
.toggle-icon.open {
transform: rotate(180deg);
}
.setup-content {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
}
.setup-content.open {
max-height: 2000px;
}
.setup-inner {
padding-top: 20px;
}
.info-section {
background: rgba(255, 255, 255, 0.03);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 12px;
padding: 24px;
margin-bottom: 20px;
}
.info-section h4 {
color: #4ecdc4;
margin-bottom: 12px;
font-size: 1em;
}
.info-section p {
color: #808080;
font-size: 0.9em;
margin-bottom: 16px;
line-height: 1.6;
}
.command {
background: #0d1117;
border-radius: 8px;
padding: 14px 18px;
margin-bottom: 10px;
font-family: 'Courier New', monospace;
font-size: 0.9em;
overflow-x: auto;
}
.command:last-child {
margin-bottom: 0;
}
.command strong {
color: #4ecdc4;
display: inline-block;
min-width: 80px;
}
.command code {
color: #e0e0e0;
}
footer {
text-align: center;
padding-top: 30px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
color: #606060;
font-size: 0.9em;
}
/* Services Navigation */
.services-nav {
background: rgba(0, 0, 0, 0.3);
border-radius: 12px;
padding: 0.5rem;
margin-bottom: 1.5rem;
display: flex;
align-items: center;
gap: 0.5rem;
flex-wrap: wrap;
}
.services-nav-label {
color: #888;
font-size: 0.85rem;
padding: 0.5rem 0.75rem;
white-space: nowrap;
}
.services-nav-items {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.service-link {
display: inline-flex;
align-items: center;
gap: 0.4rem;
padding: 0.5rem 1rem;
border-radius: 8px;
text-decoration: none;
font-size: 0.9rem;
font-weight: 500;
transition: all 0.2s;
color: #e8e8e8;
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
}
.service-link:hover {
background: rgba(255, 255, 255, 0.1);
border-color: rgba(78, 205, 196, 0.5);
}
.service-link.active {
background: linear-gradient(135deg, rgba(78, 205, 196, 0.3), rgba(68, 160, 141, 0.3));
border-color: rgba(78, 205, 196, 0.5);
}
.service-link .service-icon {
font-size: 1.1rem;
}
.service-link .service-status {
width: 6px;
height: 6px;
border-radius: 50%;
background: #4ecdc4;
margin-left: 0.25rem;
}
.leader-badge {
display: flex;
align-items: center;
gap: 0.3rem;
padding: 0.4rem 0.8rem;
background: rgba(78, 205, 196, 0.15);
border: 1px solid rgba(78, 205, 196, 0.3);
border-radius: 16px;
font-size: 0.75rem;
color: #4ecdc4;
margin-left: auto;
}
.leader-badge-icon {
font-size: 0.9rem;
}
</style>
<script>
function toggleSetup() {
const content = document.getElementById('setupContent');
const icon = document.getElementById('toggleIcon');
content.classList.toggle('open');
icon.classList.toggle('open');
}
</script>
</head>
<body>
<div class="container">
<!-- Services Navigation -->
<nav class="services-nav" id="servicesNav" style="display: none;">
<span class="services-nav-label">Services:</span>
<div class="services-nav-items" id="servicesNavItems">
<!-- Populated by JavaScript -->
</div>
</nav>
<header>
<h1>meta-fuse</h1>
<p class="subtitle">Virtual Filesystem Service</p>
<div class="status-bar">
<div class="status-item">
<div class="status-dot" id="statusDot"></div>
<span id="statusText">Checking...</span>
</div>
</div>
</header>
<div class="description">
<h2>What is meta-fuse?</h2>
<p>
<strong>meta-fuse</strong> is a virtual filesystem that presents your media files
in an organized structure based on metadata. It reads file information from the
KV leader (via Redis) and creates a virtual view of your library without duplicating any files.
</p>
<ul>
<li>Access files organized by title, year, series, etc.</li>
<li>Mount via FUSE (native) or WebDAV (network drive)</li>
<li>No file duplication - virtual paths point to real files</li>
<li>Automatically updates when new files are processed</li>
</ul>
</div>
<div class="services">
<a href="/webdav" class="service-card">
<div class="icon">📁</div>
<h3>WebDAV Files</h3>
<p>Browse and access your organized media library. Mount as a network drive on any device.</p>
<span class="service-url">/webdav</span>
</a>
<a href="/stats/" class="service-card">
<div class="icon">📊</div>
<h3>VFS Statistics</h3>
<p>View file counts, directory structure, connection status, and refresh metadata.</p>
<span class="service-url">/stats</span>
</a>
</div>
<div class="setup-section">
<div class="setup-header" onclick="toggleSetup()">
<h3>⚙️ Setup & Configuration</h3>
<span class="toggle-icon" id="toggleIcon">▼</span>
</div>
<div class="setup-content" id="setupContent">
<div class="setup-inner">
<div class="info-section">
<h4>🗂️ FUSE Mount (Docker)</h4>
<p>Mount the virtual filesystem directly from the container. Add this volume to your docker-compose.yml to access the organized files on your host:</p>
<div class="command">
<code>volumes:<br>&nbsp;&nbsp;- /path/on/host:/mnt/virtual:rw,shared</code>
</div>
<p style="margin-top: 12px; margin-bottom: 0;">The virtual filesystem is available inside the container at <code style="background: #0d1117; padding: 2px 6px; border-radius: 4px;">/mnt/virtual</code></p>
</div>
<div class="info-section">
<h4>🌐 WebDAV Network Drive</h4>
<p>Mount the virtual filesystem as a network drive on any device:</p>
<div class="command">
<strong>Windows:</strong>
<code>net use Z: http://&lt;host&gt;/webdav</code>
</div>
<div class="command">
<strong>macOS:</strong>
<code>Finder → Go → Connect to Server → http://&lt;host&gt;/webdav</code>
</div>
<div class="command">
<strong>Linux:</strong>
<code>sudo mount -t davfs http://&lt;host&gt;/webdav /mnt/vfs</code>
</div>
</div>
</div>
</div>
</div>
<footer>
<p>Part of the <strong>MetaMesh</strong> project</p>
<p>Discovers KV leader via shared volume and connects to Redis automatically</p>
</footer>
</div>
<script>
async function checkStatus() {
const dot = document.getElementById('statusDot');
const text = document.getElementById('statusText');
try {
const res = await fetch('/health');
const data = await res.json();
if (data.status === 'ok') {
dot.classList.remove('disconnected');
text.textContent = 'Connected to Redis';
} else {
dot.classList.add('disconnected');
text.textContent = 'Disconnected';
}
} catch (e) {
dot.classList.add('disconnected');
text.textContent = 'Service unavailable';
}
}
// Service icons mapping
const serviceIcons = {
'meta-sort': '📁',
'meta-fuse': '🗂️',
'meta-stremio': '🎬',
'meta-orbit': '🌐',
'default': '📦'
};
function formatServiceName(name) {
return name.split('-').map(word =>
word.charAt(0).toUpperCase() + word.slice(1)
).join(' ');
}
async function fetchServices() {
try {
const res = await fetch('/api/services');
const data = await res.json();
const navEl = document.getElementById('servicesNav');
const itemsEl = document.getElementById('servicesNavItems');
const leaderBadge = document.getElementById('leaderBadge');
const leaderBadgeText = document.getElementById('leaderBadgeText');
if (data.services && data.services.length > 0) {
const services = data.services.sort((a, b) => a.name.localeCompare(b.name));
itemsEl.innerHTML = services.map(svc => {
const icon = serviceIcons[svc.name] || serviceIcons.default;
const isActive = svc.name === 'meta-fuse';
const activeClass = isActive ? ' active' : '';
const href = isActive ? '#' : svc.url;
return `
<a href="${href}" class="service-link${activeClass}">
<span class="service-icon">${icon}</span>
<span>${formatServiceName(svc.name)}</span>
<span class="service-status"></span>
</a>
`;
}).join('');
navEl.style.display = 'flex';
} else {
navEl.style.display = 'none';
}
} catch (e) {
console.error('Failed to fetch services:', e);
document.getElementById('servicesNav').style.display = 'none';
}
}
checkStatus();
fetchServices();
setInterval(checkStatus, 5000);
setInterval(fetchServices, 30000);
</script>
</body>
</html>