feat(webui): Enhance dashboard, global styles, and settings module
## Dashboard Enhancements
- Add Request Volume trend chart with Chart.js line graph
- Support Family/Model display modes for aggregation levels
- Show Total/Today/1H usage statistics
- Hierarchical filter dropdown with Smart select (Top 5 by 24h usage)
- Persist chart preferences to localStorage
- Improve account health detection logic
- Core models (sonnet/opus/pro/flash) require >5% quota to be healthy
- Dynamic quota ring chart supporting any model family
- Unify table styles with standard-table class
## Global Style Refactoring
- Add CSS variable system for theming
- Space color scale (950/900/850/800/border)
- Neon accent colors (purple/green/cyan/yellow/red)
- Text hierarchy (main/dim/muted/bright)
- Chart palette (16 colors)
- Add unified component classes
- .view-container for consistent page layouts
- .section-header/.section-title/.section-desc
- .standard-table for table styling
- Update scrollbar, nav-item, progress-bar to use theme variables
## Settings Module Extensions
- Add model mapping column in Models tab
- Enhance model selectors with family color indicators
- Support horizontal scroll for tabs on narrow screens
- Add defaultCooldownMs and maxWaitBeforeErrorMs config options
## New Module
- Add src/modules/usage-stats.js for request tracking
- Track /v1/messages and /v1/chat/completions endpoints
- Hierarchical storage: { hour: { family: { model: count } } }
- Auto-save every minute, 30-day retention
- GET /api/stats/history endpoint for dashboard chart
## Backend Changes
- Add direct account manipulation helpers (bypass AccountManager)
- Add POST /api/config/password endpoint for WebUI password change
- Auto-reload AccountManager after account operations
- Use CSS variables in OAuth callback pages
## Other
- Update .gitignore for runtime data directory
- Add i18n keys for new UI elements (EN/zh_CN)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<div x-data="dashboard" class="space-y-6 animate-fade-in">
|
||||
<div x-data="dashboard" class="view-container">
|
||||
<!-- Stats Grid -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-6">
|
||||
<div
|
||||
@@ -14,7 +14,7 @@
|
||||
<div class="stat-title text-gray-500 font-mono text-xs uppercase tracking-wider"
|
||||
x-text="$store.global.t('totalAccounts')"></div>
|
||||
<div class="stat-value text-white font-mono text-3xl" x-text="stats.total"></div>
|
||||
<div class="stat-desc text-gray-600 text-[10px] mt-1">Registered Nodes</div>
|
||||
<div class="stat-desc text-gray-600 text-[10px] mt-1" x-text="$store.global.t('registeredNodes')">Registered Nodes</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -61,8 +61,7 @@
|
||||
<!-- Legend / Info -->
|
||||
<div class="flex flex-col justify-center gap-2 flex-grow min-w-0 z-10">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-[10px] text-gray-500 uppercase tracking-wider font-mono">Global Quota</span>
|
||||
<!-- <span class="text-xs font-bold text-neon-purple" x-text="stats.overallHealth + '%'"></span> -->
|
||||
<span class="text-[10px] text-gray-500 uppercase tracking-wider font-mono" x-text="$store.global.t('globalQuota')">Global Quota</span>
|
||||
</div>
|
||||
|
||||
<!-- Custom Legend -->
|
||||
@@ -72,7 +71,6 @@
|
||||
<div class="w-1.5 h-1.5 rounded-full bg-neon-purple shadow-[0_0_4px_rgba(168,85,247,0.4)]"></div>
|
||||
<span>Claude</span>
|
||||
</div>
|
||||
<!-- <span class="font-mono text-gray-600">--</span> -->
|
||||
</div>
|
||||
<div class="flex items-center justify-between text-[10px] text-gray-400">
|
||||
<div class="flex items-center gap-1.5">
|
||||
@@ -88,6 +86,180 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Usage Trend Chart -->
|
||||
<div class="glass-panel p-4 rounded-lg">
|
||||
<!-- Header with Stats and Filter -->
|
||||
<div class="flex items-center justify-between mb-3">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="flex items-center gap-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" class="w-4 h-4 text-neon-purple">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"></path>
|
||||
</svg>
|
||||
<h3 class="text-xs font-mono text-gray-400 uppercase tracking-widest" x-text="$store.global.t('requestVolume')">Request Volume</h3>
|
||||
</div>
|
||||
|
||||
<!-- Usage Stats Pills -->
|
||||
<div class="flex gap-2 text-[10px] font-mono">
|
||||
<div class="px-2 py-1 rounded bg-space-800 border border-space-border/50">
|
||||
<span class="text-gray-500">Total:</span>
|
||||
<span class="text-white ml-1" x-text="usageStats.total"></span>
|
||||
</div>
|
||||
<div class="px-2 py-1 rounded bg-space-800 border border-space-border/50">
|
||||
<span class="text-gray-500">Today:</span>
|
||||
<span class="text-neon-cyan ml-1" x-text="usageStats.today"></span>
|
||||
</div>
|
||||
<div class="px-2 py-1 rounded bg-space-800 border border-space-border/50">
|
||||
<span class="text-gray-500">1H:</span>
|
||||
<span class="text-neon-green ml-1" x-text="usageStats.thisHour"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Display Mode Toggle -->
|
||||
<div class="join">
|
||||
<button @click="setDisplayMode('family')"
|
||||
class="join-item btn btn-xs px-3 border-space-border/50 bg-space-800 text-gray-400 hover:text-white transition-all"
|
||||
:class="{'bg-neon-purple/20 text-neon-purple border-neon-purple/50': displayMode === 'family'}"
|
||||
x-text="$store.global.t('family')">
|
||||
</button>
|
||||
<button @click="setDisplayMode('model')"
|
||||
class="join-item btn btn-xs px-3 border-space-border/50 bg-space-800 text-gray-400 hover:text-white transition-all"
|
||||
:class="{'bg-neon-purple/20 text-neon-purple border-neon-purple/50': displayMode === 'model'}"
|
||||
x-text="$store.global.t('model')">
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Filter Dropdown -->
|
||||
<div class="relative">
|
||||
<button @click="showModelFilter = !showModelFilter"
|
||||
class="flex items-center gap-2 px-3 py-1.5 text-[10px] font-mono text-gray-400 bg-space-800 border border-space-border/50 rounded hover:border-neon-purple/50 transition-colors">
|
||||
<svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z" />
|
||||
</svg>
|
||||
<span>Filter (<span x-text="getSelectedCount()"></span>)</span>
|
||||
<svg class="w-3 h-3 transition-transform" :class="{'rotate-180': showModelFilter}" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<!-- Dropdown Menu -->
|
||||
<div x-show="showModelFilter" @click.outside="showModelFilter = false"
|
||||
x-transition:enter="transition ease-out duration-100"
|
||||
x-transition:enter-start="opacity-0 scale-95"
|
||||
x-transition:enter-end="opacity-100 scale-100"
|
||||
x-transition:leave="transition ease-in duration-75"
|
||||
x-transition:leave-start="opacity-100 scale-100"
|
||||
x-transition:leave-end="opacity-0 scale-95"
|
||||
class="absolute right-0 mt-1 w-72 bg-space-900 border border-space-border rounded-lg shadow-xl z-50 overflow-hidden"
|
||||
style="display: none;">
|
||||
|
||||
<!-- Header -->
|
||||
<div class="flex items-center justify-between px-3 py-2 border-b border-space-border/50 bg-space-800/50">
|
||||
<span class="text-[10px] font-mono text-gray-500 uppercase" x-text="displayMode === 'family' ? $store.global.t('selectFamilies') : $store.global.t('selectModels')"></span>
|
||||
<div class="flex gap-1">
|
||||
<button @click="autoSelectTopN(5)" class="text-[10px] text-neon-purple hover:underline" title="Select Top 5 most used models (24h)">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="w-3 h-3 inline-block" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" /></svg>
|
||||
Smart
|
||||
</button>
|
||||
<span class="text-gray-600">|</span>
|
||||
<button @click="selectAll()" class="text-[10px] text-neon-cyan hover:underline" x-text="$store.global.t('all')">All</button>
|
||||
<span class="text-gray-600">|</span>
|
||||
<button @click="deselectAll()" class="text-[10px] text-gray-500 hover:underline" x-text="$store.global.t('none')">None</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hierarchical List -->
|
||||
<div class="max-h-64 overflow-y-auto p-2 space-y-2">
|
||||
<template x-for="family in families" :key="family">
|
||||
<div class="space-y-1">
|
||||
<!-- Family Header -->
|
||||
<label class="flex items-center gap-2 px-2 py-1.5 rounded hover:bg-white/5 cursor-pointer group"
|
||||
x-show="displayMode === 'family'">
|
||||
<input type="checkbox"
|
||||
:checked="isFamilySelected(family)"
|
||||
@change="toggleFamily(family)"
|
||||
class="checkbox checkbox-xs checkbox-primary">
|
||||
<div class="w-2 h-2 rounded-full flex-shrink-0" :style="'background-color:' + getFamilyColor(family)"></div>
|
||||
<span class="text-xs text-gray-300 font-medium capitalize group-hover:text-white" x-text="family"></span>
|
||||
<span class="text-[10px] text-gray-600 ml-auto" x-text="'(' + (modelTree[family] || []).length + ')'"></span>
|
||||
</label>
|
||||
|
||||
<!-- Family Section Header (Model Mode) -->
|
||||
<div class="flex items-center gap-2 px-2 py-1 text-[10px] text-gray-500 uppercase font-bold"
|
||||
x-show="displayMode === 'model'">
|
||||
<div class="w-1.5 h-1.5 rounded-full" :style="'background-color:' + getFamilyColor(family)"></div>
|
||||
<span x-text="family"></span>
|
||||
</div>
|
||||
|
||||
<!-- Models in Family -->
|
||||
<template x-if="displayMode === 'model'">
|
||||
<div class="ml-4 space-y-0.5">
|
||||
<template x-for="(model, modelIndex) in (modelTree[family] || [])" :key="family + ':' + model">
|
||||
<label class="flex items-center gap-2 px-2 py-1 rounded hover:bg-white/5 cursor-pointer group">
|
||||
<input type="checkbox"
|
||||
:checked="isModelSelected(family, model)"
|
||||
@change="toggleModel(family, model)"
|
||||
class="checkbox checkbox-xs checkbox-primary">
|
||||
<div class="w-2 h-2 rounded-full flex-shrink-0" :style="'background-color:' + getModelColor(family, modelIndex)"></div>
|
||||
<span class="text-xs text-gray-400 truncate group-hover:text-white" x-text="model"></span>
|
||||
</label>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div x-show="families.length === 0" class="text-center py-4 text-gray-600 text-xs" x-text="$store.global.t('noDataTracked')">
|
||||
No data tracked yet
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Dynamic Legend -->
|
||||
<div class="flex flex-wrap gap-3 mb-3" x-show="displayMode === 'family' ? selectedFamilies.length > 0 : Object.values(selectedModels).flat().length > 0">
|
||||
<!-- Family Mode Legend -->
|
||||
<template x-if="displayMode === 'family'">
|
||||
<template x-for="family in selectedFamilies" :key="family">
|
||||
<div class="flex items-center gap-1.5 text-[10px] font-mono">
|
||||
<div class="w-2 h-2 rounded-full" :style="'background-color:' + getFamilyColor(family)"></div>
|
||||
<span class="text-gray-400 capitalize" x-text="family"></span>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
<!-- Model Mode Legend -->
|
||||
<template x-if="displayMode === 'model'">
|
||||
<template x-for="family in families" :key="'legend-' + family">
|
||||
<template x-for="(model, modelIndex) in (selectedModels[family] || [])" :key="family + ':' + model">
|
||||
<div class="flex items-center gap-1.5 text-[10px] font-mono">
|
||||
<div class="w-2 h-2 rounded-full" :style="'background-color:' + getModelColor(family, modelIndex)"></div>
|
||||
<span class="text-gray-400" x-text="model"></span>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- Chart -->
|
||||
<div class="h-48 w-full relative">
|
||||
<canvas id="usageTrendChart"></canvas>
|
||||
<!-- Loading/Empty State -->
|
||||
<div x-show="!stats.hasTrendData" class="absolute inset-0 flex items-center justify-center bg-space-900/50 backdrop-blur-sm z-10" style="display: none;">
|
||||
<div class="text-xs font-mono text-gray-500 flex items-center gap-2">
|
||||
<span class="loading loading-spinner loading-xs"></span>
|
||||
<span x-text="$store.global.t('syncing')">SYNCING...</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- No Selection -->
|
||||
<div x-show="stats.hasTrendData && (displayMode === 'family' ? selectedFamilies.length === 0 : Object.values(selectedModels).flat().length === 0)"
|
||||
class="absolute inset-0 flex items-center justify-center bg-space-900/30 z-10">
|
||||
<div class="text-xs font-mono text-gray-500" x-text="displayMode === 'family' ? $store.global.t('selectFamilies') : $store.global.t('selectModels')"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Controls -->
|
||||
<div class="flex items-center justify-between gap-4 glass-panel p-2 rounded-lg h-16">
|
||||
<div class="flex items-center gap-4 h-full">
|
||||
@@ -141,9 +313,8 @@
|
||||
|
||||
<!-- Main Table -->
|
||||
<div class="glass-panel rounded-xl overflow-hidden min-h-[400px]">
|
||||
<table class="table w-full" :class="{'table-xs': $store.settings.compact, 'table-sm': !$store.settings.compact}">
|
||||
<thead
|
||||
class="bg-space-900/50 text-gray-500 font-mono text-xs uppercase tracking-wider border-b border-space-border">
|
||||
<table class="standard-table" :class="{'table-xs': $store.settings.compact, 'table-sm': !$store.settings.compact}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-8 py-3 pl-4" x-text="$store.global.t('stat')">Stat</th>
|
||||
<th class="py-3" x-text="$store.global.t('modelIdentity')">Model Identity</th>
|
||||
@@ -153,9 +324,9 @@
|
||||
Distribution</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-space-border/50 text-sm">
|
||||
<tbody class="text-sm">
|
||||
<template x-for="row in $store.data.quotaRows" :key="row.modelId">
|
||||
<tr class="hover:bg-white/5 transition-colors group">
|
||||
<tr class="group">
|
||||
<td class="pl-4">
|
||||
<div class="w-2 h-2 rounded-full transition-all duration-500"
|
||||
:class="row.avgQuota > 0 ? 'bg-neon-green shadow-[0_0_8px_rgba(34,197,94,0.6)]' : 'bg-red-500 shadow-[0_0_8px_rgba(239,68,68,0.6)]'">
|
||||
@@ -204,14 +375,14 @@
|
||||
<td colspan="5" class="h-64 text-center">
|
||||
<div class="flex flex-col items-center justify-center gap-3">
|
||||
<span class="loading loading-bars loading-md text-neon-purple"></span>
|
||||
<span class="text-xs font-mono text-gray-600 animate-pulse">ESTABLISHING
|
||||
<span class="text-xs font-mono text-gray-600 animate-pulse" x-text="$store.global.t('establishingUplink')">ESTABLISHING
|
||||
UPLINK...</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Empty -->
|
||||
<tr x-show="!$store.data.loading && $store.data.quotaRows.length === 0">
|
||||
<td colspan="5" class="h-64 text-center text-gray-600 font-mono text-xs">
|
||||
<td colspan="5" class="h-64 text-center text-gray-600 font-mono text-xs" x-text="$store.global.t('noSignal')">
|
||||
NO SIGNAL DETECTED
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user