feat(ui): add dashboard storage breakdown donut and refine browser search toolbar

This commit is contained in:
2026-10-14 15:49:41 +05:30
parent 1d8a836e50
commit fae4d304a9
+302 -34
View File
@@ -348,7 +348,7 @@ h1, h2, h3, .page-title { font-weight: 800; letter-spacing: -0.035em; color: var
.stat-card-value { font-size:36px; font-weight:800; letter-spacing:-0.035em; margin-bottom:4px; color:var(--ink-0); } .stat-card-value { font-size:36px; font-weight:800; letter-spacing:-0.035em; margin-bottom:4px; color:var(--ink-0); }
.stat-card-meta { font-size:14px; color:var(--text3); font-weight:500; } .stat-card-meta { font-size:14px; color:var(--text3); font-weight:500; }
.charts-grid { display:grid; grid-template-columns:1fr 1fr; gap:24px; padding:0 40px 40px; } .charts-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(320px, 1fr)); gap:24px; padding:0 40px 40px; }
.chart-card { .chart-card {
background: var(--surface-1); background: var(--surface-1);
backdrop-filter: blur(20px) saturate(180%); border: 1px solid var(--card-border); backdrop-filter: blur(20px) saturate(180%); border: 1px solid var(--card-border);
@@ -628,9 +628,136 @@ input:checked + .slider:before { transform: translateX(16px); }
.btn-icon { background:none; border:none; color:var(--text3); cursor:pointer; padding:8px; border-radius:8px; transition:0.2s; display:flex; align-items:center; justify-content:center; width:32px; height:32px; } .btn-icon { background:none; border:none; color:var(--text3); cursor:pointer; padding:8px; border-radius:8px; transition:0.2s; display:flex; align-items:center; justify-content:center; width:32px; height:32px; }
.btn-icon:hover { background:var(--surface3); color:var(--text); } .btn-icon:hover { background:var(--surface3); color:var(--text); }
.btn-icon.danger:hover { background:rgba(239,68,68,0.1); color:var(--red); } .btn-icon.danger:hover { background:rgba(239,68,68,0.1); color:var(--red); }
.cat-chip { padding: 4px 10px !important; font-size: 11.5px !important; font-weight: 600 !important; border-radius: 999px !important; border: 1px solid rgba(255,255,255,0.08) !important; background: rgba(255,255,255,0.03) !important; color: var(--text3) !important; transition: all 0.2s ease; cursor: pointer; } /* ─── REFINED BROWSER TOOLBAR & CATEGORY PILLS ─── */
.cat-chip:hover { background: rgba(255,255,255,0.08) !important; color: var(--text); border-color: rgba(255,255,255,0.15) !important; } .browser-toolbar {
.cat-chip.active { background: rgba(56,189,248,0.15) !important; color: #38bdf8 !important; border-color: rgba(56,189,248,0.4) !important; } display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 12px;
padding: 12px 32px;
background: rgba(15, 23, 42, 0.45);
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
backdrop-filter: blur(12px);
margin-bottom: 8px;
}
.browser-search-box {
position: relative;
width: 300px;
max-width: 100%;
}
.browser-search-box input {
width: 100%;
height: 36px;
background: rgba(255, 255, 255, 0.04);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 999px;
padding: 0 32px 0 36px;
font-size: 12.5px;
color: #fff;
outline: none;
transition: all 0.2s ease;
}
.browser-search-box input:focus {
background: rgba(255, 255, 255, 0.07);
border-color: rgba(56, 189, 248, 0.5);
box-shadow: 0 0 16px rgba(56, 189, 248, 0.2);
}
.browser-search-box .search-icon {
position: absolute;
left: 12px;
top: 11px;
color: var(--text3);
pointer-events: none;
}
.btn-clear-search {
position: absolute;
right: 10px;
top: 9px;
background: rgba(255, 255, 255, 0.1);
border: none;
color: var(--text2);
width: 18px;
height: 18px;
border-radius: 50%;
cursor: pointer;
font-size: 10px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
}
.btn-clear-search:hover {
background: rgba(239, 68, 68, 0.3);
color: #f87171;
}
.category-filter-segmented {
display: flex;
align-items: center;
gap: 4px;
background: rgba(0, 0, 0, 0.3);
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 999px;
padding: 3px 4px;
flex-wrap: wrap;
}
.cat-pill {
display: flex;
align-items: center;
gap: 6px;
background: transparent;
border: 1px solid transparent;
color: var(--text3);
padding: 5px 12px;
border-radius: 999px;
font-size: 11.5px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
user-select: none;
}
.cat-pill:hover {
background: rgba(255, 255, 255, 0.06);
color: var(--text);
}
.cat-pill.active {
background: rgba(56, 189, 248, 0.16);
color: #38bdf8;
border-color: rgba(56, 189, 248, 0.35);
box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}
.cat-pill-dot {
width: 6px;
height: 6px;
border-radius: 50%;
display: inline-block;
}
.dot-all { background: #94a3b8; }
.dot-images { background: #38bdf8; box-shadow: 0 0 6px rgba(56,189,248,0.5); }
.dot-media { background: #a855f7; box-shadow: 0 0 6px rgba(168,85,247,0.5); }
.dot-docs { background: #10b981; box-shadow: 0 0 6px rgba(16,185,129,0.5); }
.dot-code { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.5); }
.dot-archives { background: #6366f1; box-shadow: 0 0 6px rgba(99,102,241,0.5); }
@media (max-width: 800px) {
.browser-toolbar {
padding: 10px 16px;
flex-direction: column;
align-items: stretch;
}
.browser-search-box {
width: 100%;
}
.category-filter-segmented {
overflow-x: auto;
white-space: nowrap;
padding: 3px;
scrollbar-width: none;
}
.category-filter-segmented::-webkit-scrollbar {
display: none;
}
}
@media (max-width:800px) { @media (max-width:800px) {
.layout { flex-direction: column; } .layout { flex-direction: column; }
.sidebar { width: 100%; min-width: 100%; height: auto; min-height: auto; flex-shrink: 0; padding-bottom: 12px; } .sidebar { width: 100%; min-width: 100%; height: auto; min-height: auto; flex-shrink: 0; padding-bottom: 12px; }
@@ -882,6 +1009,22 @@ input:checked + .slider:before { transform: translateX(16px); }
</div> </div>
</div> </div>
</div> </div>
<!-- Storage Breakdown Donut Chart -->
<div class="chart-card" id="dash-breakdown-card">
<div class="chart-card-header" style="display:flex; justify-content:space-between; align-items:flex-start;">
<div>
<div class="chart-card-title">Storage Breakdown</div>
<div class="chart-card-sub">Capacity by file type across all buckets</div>
</div>
<div id="dash-breakdown-total" style="font-family:var(--mono); font-size:13px; color:#38bdf8; font-weight:700; background:rgba(56,189,248,0.1); border:1px solid rgba(56,189,248,0.25); padding:3px 10px; border-radius:999px;">—</div>
</div>
<div class="chart-wrap" style="height:210px; position:relative;">
<canvas id="dashStorageBreakdownChart"></canvas>
</div>
<div id="dash-breakdown-pills" style="display:flex; flex-wrap:wrap; gap:6px; justify-content:center; margin-top:14px; font-size:11.5px;"></div>
</div>
<div class="chart-card"> <div class="chart-card">
<div class="chart-card-header"> <div class="chart-card-header">
<div class="chart-card-title">Buckets</div> <div class="chart-card-title">Buckets</div>
@@ -983,8 +1126,8 @@ input:checked + .slider:before { transform: translateX(16px); }
</div> </div>
</div> </div>
<!-- Globe + Chart Row --> <!-- Globe Row -->
<div id="analytics-globe-row" style="display:grid;grid-template-columns:1fr;gap:24px;padding:0 16px 24px;" class="mobile-pad"> <div id="analytics-globe-row" style="padding:0 16px 24px;" class="mobile-pad">
<!-- Globe --> <!-- Globe -->
<div class="chart-card globe-card" style="display:flex; padding:0; overflow:hidden; min-height: 480px;"> <div class="chart-card globe-card" style="display:flex; padding:0; overflow:hidden; min-height: 480px;">
<!-- Country List Sidebar --> <!-- Country List Sidebar -->
@@ -1006,13 +1149,17 @@ input:checked + .slider:before { transform: translateX(16px); }
<canvas id="globeCanvas" width="500" height="400" style="display:block;margin:0 auto; cursor:grab;"></canvas> <canvas id="globeCanvas" width="500" height="400" style="display:block;margin:0 auto; cursor:grab;"></canvas>
</div> </div>
</div> </div>
</div>
<!-- Charts Row: Request Volume and Storage Breakdown Side-by-Side -->
<div style="display:grid; grid-template-columns:repeat(auto-fit, minmax(360px, 1fr)); gap:24px; padding:0 16px 24px;" id="analytics-charts-row">
<!-- Request Timeline --> <!-- Request Timeline -->
<div class="chart-card"> <div class="chart-card">
<div class="chart-card-header"> <div class="chart-card-header">
<div class="chart-card-title">Request Volume</div> <div class="chart-card-title">Request Volume</div>
<div class="chart-card-sub">Last 24 hours</div> <div class="chart-card-sub">Last 24 hours</div>
</div> </div>
<div class="chart-wrap"> <div class="chart-wrap" style="height:280px; position:relative;">
<canvas id="analyticsChart"></canvas> <canvas id="analyticsChart"></canvas>
</div> </div>
</div> </div>
@@ -1060,25 +1207,17 @@ input:checked + .slider:before { transform: translateX(16px); }
<!-- ─── BROWSER VIEW ─── --> <!-- ─── BROWSER VIEW ─── -->
<div class="view" id="view-browser"> <div class="view" id="view-browser">
<div class="browser-header" style="flex-wrap:wrap; gap:12px; padding:16px 24px;"> <!-- Top Action Header -->
<div style="display:flex; align-items:center; gap:12px; flex-wrap:wrap; flex:1; min-width:260px;"> <div class="browser-header">
<div style="font-weight:600; font-size:14px; white-space:nowrap;" id="browser-title">Bucket</div> <div style="display:flex; align-items:center; gap:12px;">
<!-- Live Search --> <div style="width:32px; height:32px; border-radius:8px; background:rgba(56,189,248,0.12); border:1px solid rgba(56,189,248,0.25); display:flex; align-items:center; justify-content:center; color:#38bdf8;">
<div style="position:relative; width:220px;"> <svg width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"/></svg>
<input type="text" id="browser-search-inp" class="form-control" placeholder="Search files..." style="padding-left:32px; height:32px; font-size:12px; border-radius:8px;" oninput="filterObjectsByQuery(this.value)"> </div>
<svg style="position:absolute; left:10px; top:8px; pointer-events:none; opacity:0.5;" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg> <div>
<div style="font-weight:700; font-size:16px; color:var(--ink-0); letter-spacing:-0.02em;" id="browser-title">Bucket</div>
</div> </div>
</div> </div>
<div class="browser-actions" style="flex-wrap:wrap; gap:8px;"> <div class="browser-actions">
<!-- Category Filter Pills -->
<div style="display:flex; gap:4px; margin-right:4px;" id="cat-filter-chips">
<button class="btn btn-ghost btn-sm cat-chip active" data-cat="all" onclick="filterByCategory('all')">All</button>
<button class="btn btn-ghost btn-sm cat-chip" data-cat="images" onclick="filterByCategory('images')">Images</button>
<button class="btn btn-ghost btn-sm cat-chip" data-cat="media" onclick="filterByCategory('media')">Media</button>
<button class="btn btn-ghost btn-sm cat-chip" data-cat="docs" onclick="filterByCategory('docs')">Docs</button>
<button class="btn btn-ghost btn-sm cat-chip" data-cat="code" onclick="filterByCategory('code')">Code</button>
<button class="btn btn-ghost btn-sm cat-chip" data-cat="archives" onclick="filterByCategory('archives')">Archives</button>
</div>
<button class="btn btn-ghost btn-sm" onclick="loadObjects()"> <button class="btn btn-ghost btn-sm" onclick="loadObjects()">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="13" height="13"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 11-2.12-9.36L23 10"/></svg> <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="13" height="13"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 11-2.12-9.36L23 10"/></svg>
Refresh Refresh
@@ -1104,6 +1243,35 @@ input:checked + .slider:before { transform: translateX(16px); }
</div> </div>
</div> </div>
<!-- Feature 7: Dedicated Search & Filter Toolbar -->
<div class="browser-toolbar">
<div class="browser-search-box">
<svg class="search-icon" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
<input type="text" id="browser-search-inp" placeholder="Search files & folders in bucket..." autocomplete="off" oninput="onSearchInput(this.value)">
<button id="browser-search-clear" class="btn-clear-search" style="display:none;" onclick="clearSearchInput()" title="Clear search">✕</button>
</div>
<div class="category-filter-segmented" id="cat-filter-chips">
<button class="cat-pill active" data-cat="all" onclick="filterByCategory('all')">
<span class="cat-pill-dot dot-all"></span>All
</button>
<button class="cat-pill" data-cat="images" onclick="filterByCategory('images')">
<span class="cat-pill-dot dot-images"></span>Images
</button>
<button class="cat-pill" data-cat="media" onclick="filterByCategory('media')">
<span class="cat-pill-dot dot-media"></span>Media
</button>
<button class="cat-pill" data-cat="docs" onclick="filterByCategory('docs')">
<span class="cat-pill-dot dot-docs"></span>Docs
</button>
<button class="cat-pill" data-cat="code" onclick="filterByCategory('code')">
<span class="cat-pill-dot dot-code"></span>Code
</button>
<button class="cat-pill" data-cat="archives" onclick="filterByCategory('archives')">
<span class="cat-pill-dot dot-archives"></span>Archives
</button>
</div>
</div>
<!-- Sticky Batch Action Bar (shown when 1+ checkboxes selected) --> <!-- Sticky Batch Action Bar (shown when 1+ checkboxes selected) -->
<div id="batch-action-bar" style="display:none; position:sticky; top:12px; z-index:100; margin:8px 16px; background:rgba(15,23,42,0.95); border:1px solid rgba(56,189,248,0.35); border-radius:12px; padding:10px 18px; box-shadow:0 12px 36px rgba(0,0,0,0.6); backdrop-filter:blur(16px); align-items:center; justify-content:space-between; gap:16px;"> <div id="batch-action-bar" style="display:none; position:sticky; top:12px; z-index:100; margin:8px 16px; background:rgba(15,23,42,0.95); border:1px solid rgba(56,189,248,0.35); border-radius:12px; padding:10px 18px; box-shadow:0 12px 36px rgba(0,0,0,0.6); backdrop-filter:blur(16px); align-items:center; justify-content:space-between; gap:16px;">
<div style="display:flex; align-items:center; gap:12px;"> <div style="display:flex; align-items:center; gap:12px;">
@@ -1757,14 +1925,6 @@ function switchView(name, bucket, prefix) {
const sb = document.querySelector('.sidebar'); const sb = document.querySelector('.sidebar');
if(sb) sb.classList.remove('mobile-open'); if(sb) sb.classList.remove('mobile-open');
} }
function filterFiles(query) {
query = query.toLowerCase();
const rows = document.querySelectorAll('.file-table tbody tr, .drive-item');
rows.forEach(row => {
const text = row.innerText.toLowerCase();
row.style.display = text.includes(query) ? '' : 'none';
});
}
document.querySelectorAll('.view').forEach(v => v.classList.remove('active')); document.querySelectorAll('.view').forEach(v => v.classList.remove('active'));
document.querySelectorAll('.nav-item').forEach(n => n.classList.remove('active')); document.querySelectorAll('.nav-item').forEach(n => n.classList.remove('active'));
document.querySelectorAll('.nav-bucket').forEach(n => n.classList.remove('active')); document.querySelectorAll('.nav-bucket').forEach(n => n.classList.remove('active'));
@@ -2621,6 +2781,7 @@ async function loadDashboard() {
document.getElementById('quota-label-pct').textContent = pct.toFixed(1) + '%'; document.getElementById('quota-label-pct').textContent = pct.toFixed(1) + '%';
renderUsageChart(totalSize, QUOTA - totalSize); renderUsageChart(totalSize, QUOTA - totalSize);
loadDashStorageBreakdown();
const bl = document.getElementById('dash-bucket-list'); const bl = document.getElementById('dash-bucket-list');
if (state.buckets.length === 0) { if (state.buckets.length === 0) {
@@ -2663,6 +2824,92 @@ function renderUsageChart(used, free) {
}); });
} }
let dashBreakdownChartInst = null;
async function loadDashStorageBreakdown() {
const canv = document.getElementById('dashStorageBreakdownChart');
if (!canv) return;
const pillsEl = document.getElementById('dash-breakdown-pills');
const totalEl = document.getElementById('dash-breakdown-total');
try {
const r = await api('/oort/api/storage/breakdown?bucket=all');
if (!r || !r.categories) return;
const cats = r.categories;
const catMeta = [
{ key: 'images', label: 'Images', color: '#38bdf8' },
{ key: 'videos', label: 'Videos', color: '#a855f7' },
{ key: 'audio', label: 'Audio', color: '#ec4899' },
{ key: 'documents', label: 'Docs', color: '#10b981' },
{ key: 'code', label: 'Code', color: '#f59e0b' },
{ key: 'archives', label: 'Archives', color: '#6366f1' },
{ key: 'other', label: 'Other', color: '#64748b' }
];
const labels = catMeta.map(c => c.label);
const data = catMeta.map(c => cats[c.key] || 0);
const colors = catMeta.map(c => c.color);
const totalBytes = data.reduce((a, b) => a + b, 0);
if (totalEl) {
totalEl.textContent = fmtBytes(totalBytes);
}
if (dashBreakdownChartInst) {
dashBreakdownChartInst.destroy();
dashBreakdownChartInst = null;
}
dashBreakdownChartInst = new Chart(canv, {
type: 'doughnut',
data: {
labels: labels,
datasets: [{
data: totalBytes === 0 ? [1] : data,
backgroundColor: totalBytes === 0 ? ['rgba(255,255,255,0.06)'] : colors,
borderWidth: 2,
borderColor: '#0b0f17'
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
cutout: '72%',
plugins: {
legend: { display: false },
tooltip: {
callbacks: {
label: function(ctx) {
if (totalBytes === 0) return ' No files yet';
const val = data[ctx.dataIndex];
const pct = totalBytes > 0 ? ((val / totalBytes) * 100).toFixed(1) : 0;
return ` ${ctx.label}: ${fmtBytes(val)} (${pct}%)`;
}
}
}
}
}
});
if (pillsEl) {
if (totalBytes === 0) {
pillsEl.innerHTML = '<span style="color:var(--text3);font-size:11.5px;">No stored files yet</span>';
} else {
pillsEl.innerHTML = catMeta.filter(c => (cats[c.key] || 0) > 0).map(c => {
const val = cats[c.key] || 0;
const pct = ((val / totalBytes) * 100).toFixed(0);
return `<span style="display:inline-flex;align-items:center;gap:5px;padding:3px 8px;border-radius:999px;background:rgba(255,255,255,0.04);border:1px solid rgba(255,255,255,0.07);color:var(--text2);font-size:11px;">
<span style="width:6px;height:6px;border-radius:50%;background:${c.color};display:inline-block;"></span>
${c.label} <strong style="color:#fff;">${pct}%</strong>
</span>`;
}).join('');
}
}
} catch(e) {
console.error('Error loading dashboard storage breakdown:', e);
}
}
/* ─── OBJECTS / FILE BROWSER ──────────────────────────────────────── */ /* ─── OBJECTS / FILE BROWSER ──────────────────────────────────────── */
let uiMode = 'drive'; let uiMode = 'drive';
@@ -3226,9 +3473,28 @@ function getFileCategory(name) {
return 'other'; return 'other';
} }
function onSearchInput(val) {
const clearBtn = document.getElementById('browser-search-clear');
if (clearBtn) {
clearBtn.style.display = val ? 'flex' : 'none';
}
filterObjectsByQuery(val);
}
function clearSearchInput() {
const inp = document.getElementById('browser-search-inp');
if (inp) {
inp.value = '';
inp.focus();
}
const clearBtn = document.getElementById('browser-search-clear');
if (clearBtn) clearBtn.style.display = 'none';
filterObjectsByQuery('');
}
function filterByCategory(cat) { function filterByCategory(cat) {
state.activeCategory = cat; state.activeCategory = cat;
document.querySelectorAll('.cat-chip').forEach(el => { document.querySelectorAll('.cat-pill, .cat-chip').forEach(el => {
el.classList.toggle('active', el.dataset.cat === cat); el.classList.toggle('active', el.dataset.cat === cat);
}); });
renderFilteredObjects(); renderFilteredObjects();
@@ -3244,7 +3510,9 @@ function clearFilters() {
state.activeCategory = 'all'; state.activeCategory = 'all';
const inp = document.getElementById('browser-search-inp'); const inp = document.getElementById('browser-search-inp');
if (inp) inp.value = ''; if (inp) inp.value = '';
document.querySelectorAll('.cat-chip').forEach(el => { const clearBtn = document.getElementById('browser-search-clear');
if (clearBtn) clearBtn.style.display = 'none';
document.querySelectorAll('.cat-pill, .cat-chip').forEach(el => {
el.classList.toggle('active', el.dataset.cat === 'all'); el.classList.toggle('active', el.dataset.cat === 'all');
}); });
renderFilteredObjects(); renderFilteredObjects();