Spaces:
Running
feat(webui): Enhance dashboard, global styles, and settings module
Browse files## 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>
- .gitignore +4 -0
- package-lock.json +18 -2
- public/app.js +10 -6
- public/css/style.css +0 -0
- public/index.html +46 -32
- public/js/app-init.js +2 -2
- public/js/components/account-manager.js +33 -27
- public/js/components/claude-config.js +2 -2
- public/js/components/dashboard.js +538 -35
- public/js/data-store.js +2 -1
- public/js/settings-store.js +2 -1
- public/js/store.js +148 -3
- public/js/utils.js +8 -2
- public/views/accounts.html +20 -22
- public/views/dashboard.html +183 -12
- public/views/logs.html +13 -10
- public/views/settings.html +430 -116
- src/account-manager/rate-limits.js +3 -0
- src/account-manager/selection.js +3 -0
- src/account-manager/storage.js +2 -0
- src/config.js +2 -0
- src/modules/usage-stats.js +175 -0
- src/server.js +21 -17
- src/webui/index.js +150 -13
|
@@ -16,6 +16,10 @@ log.txt
|
|
| 16 |
|
| 17 |
# Local config (may contain tokens)
|
| 18 |
.claude/
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# Test artifacts
|
| 21 |
tests/utils/*.png
|
|
|
|
| 16 |
|
| 17 |
# Local config (may contain tokens)
|
| 18 |
.claude/
|
| 19 |
+
.deepvcode/
|
| 20 |
+
|
| 21 |
+
# Runtime data
|
| 22 |
+
data/
|
| 23 |
|
| 24 |
# Test artifacts
|
| 25 |
tests/utils/*.png
|
|
@@ -1,14 +1,15 @@
|
|
| 1 |
{
|
| 2 |
"name": "antigravity-claude-proxy",
|
| 3 |
-
"version": "1.
|
| 4 |
"lockfileVersion": 3,
|
| 5 |
"requires": true,
|
| 6 |
"packages": {
|
| 7 |
"": {
|
| 8 |
"name": "antigravity-claude-proxy",
|
| 9 |
-
"version": "1.
|
| 10 |
"license": "MIT",
|
| 11 |
"dependencies": {
|
|
|
|
| 12 |
"better-sqlite3": "^12.5.0",
|
| 13 |
"cors": "^2.8.5",
|
| 14 |
"express": "^4.18.2"
|
|
@@ -39,6 +40,15 @@
|
|
| 39 |
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
|
| 40 |
"license": "MIT"
|
| 41 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
"node_modules/base64-js": {
|
| 43 |
"version": "1.5.1",
|
| 44 |
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
|
@@ -1304,6 +1314,12 @@
|
|
| 1304 |
"node": ">=0.6"
|
| 1305 |
}
|
| 1306 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1307 |
"node_modules/tunnel-agent": {
|
| 1308 |
"version": "0.6.0",
|
| 1309 |
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "antigravity-claude-proxy",
|
| 3 |
+
"version": "1.2.6",
|
| 4 |
"lockfileVersion": 3,
|
| 5 |
"requires": true,
|
| 6 |
"packages": {
|
| 7 |
"": {
|
| 8 |
"name": "antigravity-claude-proxy",
|
| 9 |
+
"version": "1.2.6",
|
| 10 |
"license": "MIT",
|
| 11 |
"dependencies": {
|
| 12 |
+
"async-mutex": "^0.5.0",
|
| 13 |
"better-sqlite3": "^12.5.0",
|
| 14 |
"cors": "^2.8.5",
|
| 15 |
"express": "^4.18.2"
|
|
|
|
| 40 |
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
|
| 41 |
"license": "MIT"
|
| 42 |
},
|
| 43 |
+
"node_modules/async-mutex": {
|
| 44 |
+
"version": "0.5.0",
|
| 45 |
+
"resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.5.0.tgz",
|
| 46 |
+
"integrity": "sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA==",
|
| 47 |
+
"license": "MIT",
|
| 48 |
+
"dependencies": {
|
| 49 |
+
"tslib": "^2.4.0"
|
| 50 |
+
}
|
| 51 |
+
},
|
| 52 |
"node_modules/base64-js": {
|
| 53 |
"version": "1.5.1",
|
| 54 |
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
|
|
|
| 1314 |
"node": ">=0.6"
|
| 1315 |
}
|
| 1316 |
},
|
| 1317 |
+
"node_modules/tslib": {
|
| 1318 |
+
"version": "2.8.1",
|
| 1319 |
+
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
| 1320 |
+
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
| 1321 |
+
"license": "0BSD"
|
| 1322 |
+
},
|
| 1323 |
"node_modules/tunnel-agent": {
|
| 1324 |
"version": "0.6.0",
|
| 1325 |
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
|
@@ -63,8 +63,8 @@ document.addEventListener('alpine:init', () => {
|
|
| 63 |
|
| 64 |
// Chart Defaults
|
| 65 |
if (typeof Chart !== 'undefined') {
|
| 66 |
-
Chart.defaults.color = '
|
| 67 |
-
Chart.defaults.borderColor = '
|
| 68 |
Chart.defaults.font.family = '"JetBrains Mono", monospace';
|
| 69 |
}
|
| 70 |
|
|
@@ -111,8 +111,12 @@ document.addEventListener('alpine:init', () => {
|
|
| 111 |
|
| 112 |
const messageHandler = (event) => {
|
| 113 |
if (event.data?.type === 'oauth-success') {
|
| 114 |
-
const
|
| 115 |
-
Alpine.store('global').
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
Alpine.store('data').fetchData();
|
| 117 |
document.getElementById('add_account_modal')?.close();
|
| 118 |
}
|
|
@@ -120,10 +124,10 @@ document.addEventListener('alpine:init', () => {
|
|
| 120 |
window.addEventListener('message', messageHandler);
|
| 121 |
setTimeout(() => window.removeEventListener('message', messageHandler), 300000);
|
| 122 |
} else {
|
| 123 |
-
Alpine.store('global').showToast(data.error || '
|
| 124 |
}
|
| 125 |
} catch (e) {
|
| 126 |
-
Alpine.store('global').showToast('
|
| 127 |
}
|
| 128 |
}
|
| 129 |
}));
|
|
|
|
| 63 |
|
| 64 |
// Chart Defaults
|
| 65 |
if (typeof Chart !== 'undefined') {
|
| 66 |
+
Chart.defaults.color = window.utils.getThemeColor('--color-text-dim');
|
| 67 |
+
Chart.defaults.borderColor = window.utils.getThemeColor('--color-space-border');
|
| 68 |
Chart.defaults.font.family = '"JetBrains Mono", monospace';
|
| 69 |
}
|
| 70 |
|
|
|
|
| 111 |
|
| 112 |
const messageHandler = (event) => {
|
| 113 |
if (event.data?.type === 'oauth-success') {
|
| 114 |
+
const actionKey = reAuthEmail ? 'reauthenticated' : 'added';
|
| 115 |
+
const action = Alpine.store('global').t(actionKey);
|
| 116 |
+
const successfully = Alpine.store('global').t('successfully');
|
| 117 |
+
const msg = `${Alpine.store('global').t('accounts')} ${event.data.email} ${action} ${successfully}`;
|
| 118 |
+
|
| 119 |
+
Alpine.store('global').showToast(msg, 'success');
|
| 120 |
Alpine.store('data').fetchData();
|
| 121 |
document.getElementById('add_account_modal')?.close();
|
| 122 |
}
|
|
|
|
| 124 |
window.addEventListener('message', messageHandler);
|
| 125 |
setTimeout(() => window.removeEventListener('message', messageHandler), 300000);
|
| 126 |
} else {
|
| 127 |
+
Alpine.store('global').showToast(data.error || Alpine.store('global').t('failedToGetAuthUrl'), 'error');
|
| 128 |
}
|
| 129 |
} catch (e) {
|
| 130 |
+
Alpine.store('global').showToast(Alpine.store('global').t('failedToStartOAuth') + ': ' + e.message, 'error');
|
| 131 |
}
|
| 132 |
}
|
| 133 |
}));
|
|
Binary files a/public/css/style.css and b/public/css/style.css differ
|
|
|
|
@@ -1,5 +1,5 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
<html lang="en" data-theme="
|
| 3 |
|
| 4 |
<head>
|
| 5 |
<meta charset="UTF-8">
|
|
@@ -26,18 +26,36 @@
|
|
| 26 |
colors: {
|
| 27 |
// Deep Space Palette
|
| 28 |
space: {
|
| 29 |
-
950: '
|
| 30 |
-
900: '
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 33 |
},
|
| 34 |
neon: {
|
| 35 |
-
purple: '
|
| 36 |
-
cyan: '
|
| 37 |
-
green: '
|
|
|
|
|
|
|
| 38 |
}
|
| 39 |
}
|
| 40 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
}
|
| 42 |
}
|
| 43 |
</script>
|
|
@@ -96,8 +114,8 @@
|
|
| 96 |
class="w-8 h-8 rounded bg-gradient-to-br from-neon-purple to-blue-600 flex items-center justify-center text-white font-bold shadow-[0_0_15px_rgba(168,85,247,0.4)]">
|
| 97 |
AG</div>
|
| 98 |
<div class="flex flex-col">
|
| 99 |
-
<span class="text-sm font-bold tracking-wide text-white">ANTIGRAVITY</span>
|
| 100 |
-
<span class="text-[10px] text-gray-500 font-mono tracking-wider">CLAUDE PROXY SYSTEM</span>
|
| 101 |
</div>
|
| 102 |
</div>
|
| 103 |
|
|
@@ -111,14 +129,14 @@
|
|
| 111 |
:class="connectionStatus === 'connected' ? 'bg-neon-green shadow-[0_0_8px_rgba(34,197,94,0.6)]' : (connectionStatus === 'connecting' ? 'bg-yellow-500 animate-pulse' : 'bg-red-500')">
|
| 112 |
</div>
|
| 113 |
<span
|
| 114 |
-
x-text="connectionStatus === 'connected' ? '
|
| 115 |
</div>
|
| 116 |
|
| 117 |
<div class="h-4 w-px bg-space-border"></div>
|
| 118 |
|
| 119 |
<!-- Refresh Button -->
|
| 120 |
<button class="btn btn-ghost btn-xs btn-square text-gray-400 hover:text-white hover:bg-white/5"
|
| 121 |
-
@click="fetchData" :disabled="loading" title="
|
| 122 |
<svg class="w-4 h-4" :class="{'animate-spin': loading}" fill="none" stroke="currentColor"
|
| 123 |
viewBox="0 0 24 24">
|
| 124 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
@@ -133,7 +151,7 @@
|
|
| 133 |
|
| 134 |
<!-- Sidebar -->
|
| 135 |
<div class="w-64 bg-space-900 border-r border-space-border flex flex-col pt-6 pb-4">
|
| 136 |
-
<div class="px-4 mb-2 text-xs font-bold text-gray-600 uppercase tracking-widest">Main</div>
|
| 137 |
<nav class="flex flex-col gap-1">
|
| 138 |
<button
|
| 139 |
class="nav-item flex items-center gap-3 px-6 py-3 text-sm font-medium text-gray-400 hover:text-white hover:bg-white/5"
|
|
@@ -157,7 +175,7 @@
|
|
| 157 |
</button>
|
| 158 |
</nav>
|
| 159 |
|
| 160 |
-
<div class="px-4 mt-8 mb-2 text-xs font-bold text-gray-600 uppercase tracking-widest">System</div>
|
| 161 |
<nav class="flex flex-col gap-1">
|
| 162 |
<button
|
| 163 |
class="nav-item flex items-center gap-3 px-6 py-3 text-sm font-medium text-gray-400 hover:text-white hover:bg-white/5"
|
|
@@ -193,7 +211,7 @@
|
|
| 193 |
</div>
|
| 194 |
|
| 195 |
<!-- Main Content -->
|
| 196 |
-
<div class="flex-1 overflow-auto bg-space-950
|
| 197 |
|
| 198 |
<!-- Views Container -->
|
| 199 |
<!-- Dashboard -->
|
|
@@ -220,37 +238,33 @@
|
|
| 220 |
<!-- Add Account Modal -->
|
| 221 |
<dialog id="add_account_modal" class="modal backdrop-blur-sm">
|
| 222 |
<div class="modal-box bg-space-900 border border-space-border text-gray-300 shadow-[0_0_50px_rgba(0,0,0,0.5)]">
|
| 223 |
-
<h3 class="font-bold text-lg text-white" x-text="t('addNode')">Add New Account</h3>
|
| 224 |
|
| 225 |
<div class="py-6 flex flex-col gap-4">
|
| 226 |
-
<p class="text-sm text-gray-400">Connect a Google Workspace account to increase your API quota limit.
|
| 227 |
The account will be used to proxy Claude requests via Antigravity.</p>
|
| 228 |
|
| 229 |
<button
|
| 230 |
-
class="btn btn-primary
|
| 231 |
@click="addAccountWeb">
|
| 232 |
-
<svg class="w-5 h-5" viewBox="0 0 24 24">
|
| 233 |
<path
|
| 234 |
-
d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"
|
| 235 |
-
fill="#4285F4"></path>
|
| 236 |
<path
|
| 237 |
-
d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"
|
| 238 |
-
fill="#34A853"></path>
|
| 239 |
<path
|
| 240 |
-
d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"
|
| 241 |
-
fill="#FBBC05"></path>
|
| 242 |
<path
|
| 243 |
-
d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
|
| 244 |
-
fill="#EA4335"></path>
|
| 245 |
</svg>
|
| 246 |
-
<span x-text="t('connectGoogle')">Connect Google Account</span>
|
| 247 |
</button>
|
| 248 |
|
| 249 |
-
<div class="divider text-xs text-gray-600">OR</div>
|
| 250 |
|
| 251 |
<div class="collapse collapse-arrow bg-space-800 border border-space-border/50">
|
| 252 |
<input type="checkbox" />
|
| 253 |
-
<div class="collapse-title text-sm font-medium text-gray-400">
|
| 254 |
Use CLI Command
|
| 255 |
</div>
|
| 256 |
<div class="collapse-content">
|
|
@@ -263,12 +277,12 @@
|
|
| 263 |
|
| 264 |
<div class="modal-action">
|
| 265 |
<form method="dialog">
|
| 266 |
-
<button class="btn btn-ghost hover:bg-white/10">Close</button>
|
| 267 |
</form>
|
| 268 |
</div>
|
| 269 |
</div>
|
| 270 |
<form method="dialog" class="modal-backdrop">
|
| 271 |
-
<button>close</button>
|
| 272 |
</form>
|
| 273 |
</dialog>
|
| 274 |
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
+
<html lang="en" data-theme="antigravity" class="dark">
|
| 3 |
|
| 4 |
<head>
|
| 5 |
<meta charset="UTF-8">
|
|
|
|
| 26 |
colors: {
|
| 27 |
// Deep Space Palette
|
| 28 |
space: {
|
| 29 |
+
950: 'var(--color-space-950)', // Deep background
|
| 30 |
+
900: 'var(--color-space-900)', // Panel background
|
| 31 |
+
850: 'var(--color-space-850)', // Hover states
|
| 32 |
+
800: 'var(--color-space-800)', // UI elements
|
| 33 |
+
border: 'var(--color-space-border)'
|
| 34 |
},
|
| 35 |
neon: {
|
| 36 |
+
purple: 'var(--color-neon-purple)',
|
| 37 |
+
cyan: 'var(--color-neon-cyan)',
|
| 38 |
+
green: 'var(--color-neon-green)',
|
| 39 |
+
yellow: 'var(--color-neon-yellow)',
|
| 40 |
+
red: 'var(--color-neon-red)'
|
| 41 |
}
|
| 42 |
}
|
| 43 |
}
|
| 44 |
+
},
|
| 45 |
+
daisyui: {
|
| 46 |
+
themes: [{
|
| 47 |
+
antigravity: {
|
| 48 |
+
"primary": "var(--color-neon-purple)", // Neon Purple
|
| 49 |
+
"secondary": "var(--color-neon-green)", // Neon Green
|
| 50 |
+
"accent": "var(--color-neon-cyan)", // Neon Cyan
|
| 51 |
+
"neutral": "var(--color-space-800)", // space-800
|
| 52 |
+
"base-100": "var(--color-space-950)", // space-950
|
| 53 |
+
"info": "var(--color-neon-cyan)",
|
| 54 |
+
"success": "var(--color-neon-green)",
|
| 55 |
+
"warning": "var(--color-neon-yellow)",
|
| 56 |
+
"error": "var(--color-neon-red)",
|
| 57 |
+
}
|
| 58 |
+
}]
|
| 59 |
}
|
| 60 |
}
|
| 61 |
</script>
|
|
|
|
| 114 |
class="w-8 h-8 rounded bg-gradient-to-br from-neon-purple to-blue-600 flex items-center justify-center text-white font-bold shadow-[0_0_15px_rgba(168,85,247,0.4)]">
|
| 115 |
AG</div>
|
| 116 |
<div class="flex flex-col">
|
| 117 |
+
<span class="text-sm font-bold tracking-wide text-white" x-text="$store.global.t('systemName')">ANTIGRAVITY</span>
|
| 118 |
+
<span class="text-[10px] text-gray-500 font-mono tracking-wider" x-text="$store.global.t('systemDesc')">CLAUDE PROXY SYSTEM</span>
|
| 119 |
</div>
|
| 120 |
</div>
|
| 121 |
|
|
|
|
| 129 |
:class="connectionStatus === 'connected' ? 'bg-neon-green shadow-[0_0_8px_rgba(34,197,94,0.6)]' : (connectionStatus === 'connecting' ? 'bg-yellow-500 animate-pulse' : 'bg-red-500')">
|
| 130 |
</div>
|
| 131 |
<span
|
| 132 |
+
x-text="$store.global.connectionStatus === 'connected' ? $store.global.t('online') : ($store.global.connectionStatus === 'disconnected' ? $store.global.t('offline') : $store.global.t('connecting'))"></span>
|
| 133 |
</div>
|
| 134 |
|
| 135 |
<div class="h-4 w-px bg-space-border"></div>
|
| 136 |
|
| 137 |
<!-- Refresh Button -->
|
| 138 |
<button class="btn btn-ghost btn-xs btn-square text-gray-400 hover:text-white hover:bg-white/5"
|
| 139 |
+
@click="fetchData" :disabled="loading" :title="$store.global.t('refreshData')">
|
| 140 |
<svg class="w-4 h-4" :class="{'animate-spin': loading}" fill="none" stroke="currentColor"
|
| 141 |
viewBox="0 0 24 24">
|
| 142 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
|
|
| 151 |
|
| 152 |
<!-- Sidebar -->
|
| 153 |
<div class="w-64 bg-space-900 border-r border-space-border flex flex-col pt-6 pb-4">
|
| 154 |
+
<div class="px-4 mb-2 text-xs font-bold text-gray-600 uppercase tracking-widest" x-text="$store.global.t('main')">Main</div>
|
| 155 |
<nav class="flex flex-col gap-1">
|
| 156 |
<button
|
| 157 |
class="nav-item flex items-center gap-3 px-6 py-3 text-sm font-medium text-gray-400 hover:text-white hover:bg-white/5"
|
|
|
|
| 175 |
</button>
|
| 176 |
</nav>
|
| 177 |
|
| 178 |
+
<div class="px-4 mt-8 mb-2 text-xs font-bold text-gray-600 uppercase tracking-widest" x-text="$store.global.t('system')">System</div>
|
| 179 |
<nav class="flex flex-col gap-1">
|
| 180 |
<button
|
| 181 |
class="nav-item flex items-center gap-3 px-6 py-3 text-sm font-medium text-gray-400 hover:text-white hover:bg-white/5"
|
|
|
|
| 211 |
</div>
|
| 212 |
|
| 213 |
<!-- Main Content -->
|
| 214 |
+
<div class="flex-1 overflow-auto bg-space-950 relative">
|
| 215 |
|
| 216 |
<!-- Views Container -->
|
| 217 |
<!-- Dashboard -->
|
|
|
|
| 238 |
<!-- Add Account Modal -->
|
| 239 |
<dialog id="add_account_modal" class="modal backdrop-blur-sm">
|
| 240 |
<div class="modal-box bg-space-900 border border-space-border text-gray-300 shadow-[0_0_50px_rgba(0,0,0,0.5)]">
|
| 241 |
+
<h3 class="font-bold text-lg text-white" x-text="$store.global.t('addNode')">Add New Account</h3>
|
| 242 |
|
| 243 |
<div class="py-6 flex flex-col gap-4">
|
| 244 |
+
<p class="text-sm text-gray-400" x-text="$store.global.t('connectGoogleDesc')">Connect a Google Workspace account to increase your API quota limit.
|
| 245 |
The account will be used to proxy Claude requests via Antigravity.</p>
|
| 246 |
|
| 247 |
<button
|
| 248 |
+
class="btn btn-primary flex items-center justify-center gap-3 h-12"
|
| 249 |
@click="addAccountWeb">
|
| 250 |
+
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="currentColor">
|
| 251 |
<path
|
| 252 |
+
d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"></path>
|
|
|
|
| 253 |
<path
|
| 254 |
+
d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"></path>
|
|
|
|
| 255 |
<path
|
| 256 |
+
d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"></path>
|
|
|
|
| 257 |
<path
|
| 258 |
+
d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"></path>
|
|
|
|
| 259 |
</svg>
|
| 260 |
+
<span x-text="$store.global.t('connectGoogle')">Connect Google Account</span>
|
| 261 |
</button>
|
| 262 |
|
| 263 |
+
<div class="divider text-xs text-gray-600 uppercase" x-text="$store.global.t('or')">OR</div>
|
| 264 |
|
| 265 |
<div class="collapse collapse-arrow bg-space-800 border border-space-border/50">
|
| 266 |
<input type="checkbox" />
|
| 267 |
+
<div class="collapse-title text-sm font-medium text-gray-400" x-text="$store.global.t('useCliCommand')">
|
| 268 |
Use CLI Command
|
| 269 |
</div>
|
| 270 |
<div class="collapse-content">
|
|
|
|
| 277 |
|
| 278 |
<div class="modal-action">
|
| 279 |
<form method="dialog">
|
| 280 |
+
<button class="btn btn-ghost hover:bg-white/10" x-text="$store.global.t('close')">Close</button>
|
| 281 |
</form>
|
| 282 |
</div>
|
| 283 |
</div>
|
| 284 |
<form method="dialog" class="modal-backdrop">
|
| 285 |
+
<button x-text="$store.global.t('close')">close</button>
|
| 286 |
</form>
|
| 287 |
</dialog>
|
| 288 |
|
|
@@ -25,8 +25,8 @@ document.addEventListener('alpine:init', () => {
|
|
| 25 |
|
| 26 |
// Chart Defaults
|
| 27 |
if (typeof Chart !== 'undefined') {
|
| 28 |
-
Chart.defaults.color = '
|
| 29 |
-
Chart.defaults.borderColor = '
|
| 30 |
Chart.defaults.font.family = '"JetBrains Mono", monospace';
|
| 31 |
}
|
| 32 |
|
|
|
|
| 25 |
|
| 26 |
// Chart Defaults
|
| 27 |
if (typeof Chart !== 'undefined') {
|
| 28 |
+
Chart.defaults.color = window.utils.getThemeColor('--color-text-dim');
|
| 29 |
+
Chart.defaults.borderColor = window.utils.getThemeColor('--color-space-border');
|
| 30 |
Chart.defaults.font.family = '"JetBrains Mono", monospace';
|
| 31 |
}
|
| 32 |
|
|
@@ -6,99 +6,105 @@ window.Components = window.Components || {};
|
|
| 6 |
|
| 7 |
window.Components.accountManager = () => ({
|
| 8 |
async refreshAccount(email) {
|
| 9 |
-
Alpine.store('global')
|
| 10 |
-
|
|
|
|
| 11 |
try {
|
| 12 |
const { response, newPassword } = await window.utils.request(`/api/accounts/${encodeURIComponent(email)}/refresh`, { method: 'POST' }, password);
|
| 13 |
-
if (newPassword)
|
| 14 |
|
| 15 |
const data = await response.json();
|
| 16 |
if (data.status === 'ok') {
|
| 17 |
-
|
| 18 |
Alpine.store('data').fetchData();
|
| 19 |
} else {
|
| 20 |
-
|
| 21 |
}
|
| 22 |
} catch (e) {
|
| 23 |
-
|
| 24 |
}
|
| 25 |
},
|
| 26 |
|
| 27 |
async toggleAccount(email, enabled) {
|
| 28 |
-
const
|
|
|
|
| 29 |
try {
|
| 30 |
const { response, newPassword } = await window.utils.request(`/api/accounts/${encodeURIComponent(email)}/toggle`, {
|
| 31 |
method: 'POST',
|
| 32 |
headers: { 'Content-Type': 'application/json' },
|
| 33 |
body: JSON.stringify({ enabled })
|
| 34 |
}, password);
|
| 35 |
-
if (newPassword)
|
| 36 |
|
| 37 |
const data = await response.json();
|
| 38 |
if (data.status === 'ok') {
|
| 39 |
-
|
|
|
|
| 40 |
Alpine.store('data').fetchData();
|
| 41 |
} else {
|
| 42 |
-
|
| 43 |
}
|
| 44 |
} catch (e) {
|
| 45 |
-
|
| 46 |
}
|
| 47 |
},
|
| 48 |
|
| 49 |
async fixAccount(email) {
|
| 50 |
-
Alpine.store('global')
|
| 51 |
-
|
|
|
|
| 52 |
try {
|
| 53 |
const urlPath = `/api/auth/url?email=${encodeURIComponent(email)}`;
|
| 54 |
const { response, newPassword } = await window.utils.request(urlPath, {}, password);
|
| 55 |
-
if (newPassword)
|
| 56 |
|
| 57 |
const data = await response.json();
|
| 58 |
if (data.status === 'ok') {
|
| 59 |
window.open(data.url, 'google_oauth', 'width=600,height=700,scrollbars=yes');
|
| 60 |
} else {
|
| 61 |
-
|
| 62 |
}
|
| 63 |
} catch (e) {
|
| 64 |
-
|
| 65 |
}
|
| 66 |
},
|
| 67 |
|
| 68 |
async deleteAccount(email) {
|
| 69 |
-
|
| 70 |
-
|
|
|
|
| 71 |
try {
|
| 72 |
const { response, newPassword } = await window.utils.request(`/api/accounts/${encodeURIComponent(email)}`, { method: 'DELETE' }, password);
|
| 73 |
-
if (newPassword)
|
| 74 |
|
| 75 |
const data = await response.json();
|
| 76 |
if (data.status === 'ok') {
|
| 77 |
-
|
| 78 |
Alpine.store('data').fetchData();
|
| 79 |
} else {
|
| 80 |
-
|
| 81 |
}
|
| 82 |
} catch (e) {
|
| 83 |
-
|
| 84 |
}
|
| 85 |
},
|
| 86 |
|
| 87 |
async reloadAccounts() {
|
| 88 |
-
const
|
|
|
|
| 89 |
try {
|
| 90 |
const { response, newPassword } = await window.utils.request('/api/accounts/reload', { method: 'POST' }, password);
|
| 91 |
-
if (newPassword)
|
| 92 |
|
| 93 |
const data = await response.json();
|
| 94 |
if (data.status === 'ok') {
|
| 95 |
-
|
| 96 |
Alpine.store('data').fetchData();
|
| 97 |
} else {
|
| 98 |
-
|
| 99 |
}
|
| 100 |
} catch (e) {
|
| 101 |
-
|
| 102 |
}
|
| 103 |
}
|
| 104 |
});
|
|
|
|
| 6 |
|
| 7 |
window.Components.accountManager = () => ({
|
| 8 |
async refreshAccount(email) {
|
| 9 |
+
const store = Alpine.store('global');
|
| 10 |
+
store.showToast(store.t('refreshingAccount', { email }), 'info');
|
| 11 |
+
const password = store.webuiPassword;
|
| 12 |
try {
|
| 13 |
const { response, newPassword } = await window.utils.request(`/api/accounts/${encodeURIComponent(email)}/refresh`, { method: 'POST' }, password);
|
| 14 |
+
if (newPassword) store.webuiPassword = newPassword;
|
| 15 |
|
| 16 |
const data = await response.json();
|
| 17 |
if (data.status === 'ok') {
|
| 18 |
+
store.showToast(store.t('refreshedAccount', { email }), 'success');
|
| 19 |
Alpine.store('data').fetchData();
|
| 20 |
} else {
|
| 21 |
+
store.showToast(data.error || store.t('refreshFailed'), 'error');
|
| 22 |
}
|
| 23 |
} catch (e) {
|
| 24 |
+
store.showToast(store.t('refreshFailed') + ': ' + e.message, 'error');
|
| 25 |
}
|
| 26 |
},
|
| 27 |
|
| 28 |
async toggleAccount(email, enabled) {
|
| 29 |
+
const store = Alpine.store('global');
|
| 30 |
+
const password = store.webuiPassword;
|
| 31 |
try {
|
| 32 |
const { response, newPassword } = await window.utils.request(`/api/accounts/${encodeURIComponent(email)}/toggle`, {
|
| 33 |
method: 'POST',
|
| 34 |
headers: { 'Content-Type': 'application/json' },
|
| 35 |
body: JSON.stringify({ enabled })
|
| 36 |
}, password);
|
| 37 |
+
if (newPassword) store.webuiPassword = newPassword;
|
| 38 |
|
| 39 |
const data = await response.json();
|
| 40 |
if (data.status === 'ok') {
|
| 41 |
+
const status = enabled ? store.t('enabledStatus') : store.t('disabledStatus');
|
| 42 |
+
store.showToast(store.t('accountToggled', { email, status }), 'success');
|
| 43 |
Alpine.store('data').fetchData();
|
| 44 |
} else {
|
| 45 |
+
store.showToast(data.error || store.t('toggleFailed'), 'error');
|
| 46 |
}
|
| 47 |
} catch (e) {
|
| 48 |
+
store.showToast(store.t('toggleFailed') + ': ' + e.message, 'error');
|
| 49 |
}
|
| 50 |
},
|
| 51 |
|
| 52 |
async fixAccount(email) {
|
| 53 |
+
const store = Alpine.store('global');
|
| 54 |
+
store.showToast(store.t('reauthenticating', { email }), 'info');
|
| 55 |
+
const password = store.webuiPassword;
|
| 56 |
try {
|
| 57 |
const urlPath = `/api/auth/url?email=${encodeURIComponent(email)}`;
|
| 58 |
const { response, newPassword } = await window.utils.request(urlPath, {}, password);
|
| 59 |
+
if (newPassword) store.webuiPassword = newPassword;
|
| 60 |
|
| 61 |
const data = await response.json();
|
| 62 |
if (data.status === 'ok') {
|
| 63 |
window.open(data.url, 'google_oauth', 'width=600,height=700,scrollbars=yes');
|
| 64 |
} else {
|
| 65 |
+
store.showToast(data.error || store.t('authUrlFailed'), 'error');
|
| 66 |
}
|
| 67 |
} catch (e) {
|
| 68 |
+
store.showToast(store.t('authUrlFailed') + ': ' + e.message, 'error');
|
| 69 |
}
|
| 70 |
},
|
| 71 |
|
| 72 |
async deleteAccount(email) {
|
| 73 |
+
const store = Alpine.store('global');
|
| 74 |
+
if (!confirm(store.t('confirmDelete'))) return;
|
| 75 |
+
const password = store.webuiPassword;
|
| 76 |
try {
|
| 77 |
const { response, newPassword } = await window.utils.request(`/api/accounts/${encodeURIComponent(email)}`, { method: 'DELETE' }, password);
|
| 78 |
+
if (newPassword) store.webuiPassword = newPassword;
|
| 79 |
|
| 80 |
const data = await response.json();
|
| 81 |
if (data.status === 'ok') {
|
| 82 |
+
store.showToast(store.t('deletedAccount', { email }), 'success');
|
| 83 |
Alpine.store('data').fetchData();
|
| 84 |
} else {
|
| 85 |
+
store.showToast(data.error || store.t('deleteFailed'), 'error');
|
| 86 |
}
|
| 87 |
} catch (e) {
|
| 88 |
+
store.showToast(store.t('deleteFailed') + ': ' + e.message, 'error');
|
| 89 |
}
|
| 90 |
},
|
| 91 |
|
| 92 |
async reloadAccounts() {
|
| 93 |
+
const store = Alpine.store('global');
|
| 94 |
+
const password = store.webuiPassword;
|
| 95 |
try {
|
| 96 |
const { response, newPassword } = await window.utils.request('/api/accounts/reload', { method: 'POST' }, password);
|
| 97 |
+
if (newPassword) store.webuiPassword = newPassword;
|
| 98 |
|
| 99 |
const data = await response.json();
|
| 100 |
if (data.status === 'ok') {
|
| 101 |
+
store.showToast(store.t('accountsReloaded'), 'success');
|
| 102 |
Alpine.store('data').fetchData();
|
| 103 |
} else {
|
| 104 |
+
store.showToast(data.error || store.t('reloadFailed'), 'error');
|
| 105 |
}
|
| 106 |
} catch (e) {
|
| 107 |
+
store.showToast(store.t('reloadFailed') + ': ' + e.message, 'error');
|
| 108 |
}
|
| 109 |
}
|
| 110 |
});
|
|
@@ -44,9 +44,9 @@ window.Components.claudeConfig = () => ({
|
|
| 44 |
if (newPassword) Alpine.store('global').webuiPassword = newPassword;
|
| 45 |
|
| 46 |
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
| 47 |
-
Alpine.store('global').showToast('
|
| 48 |
} catch (e) {
|
| 49 |
-
Alpine.store('global').showToast('
|
| 50 |
} finally {
|
| 51 |
this.loading = false;
|
| 52 |
}
|
|
|
|
| 44 |
if (newPassword) Alpine.store('global').webuiPassword = newPassword;
|
| 45 |
|
| 46 |
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
| 47 |
+
Alpine.store('global').showToast(Alpine.store('global').t('claudeConfigSaved'), 'success');
|
| 48 |
} catch (e) {
|
| 49 |
+
Alpine.store('global').showToast(Alpine.store('global').t('saveConfigFailed') + ': ' + e.message, 'error');
|
| 50 |
} finally {
|
| 51 |
this.loading = false;
|
| 52 |
}
|
|
@@ -4,17 +4,50 @@
|
|
| 4 |
*/
|
| 5 |
window.Components = window.Components || {};
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
window.Components.dashboard = () => ({
|
| 8 |
-
stats: { total: 0, active: 0, limited: 0, overallHealth: 0 },
|
| 9 |
-
charts: { quotaDistribution: null },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
init() {
|
|
|
|
|
|
|
|
|
|
| 12 |
// Update stats when dashboard becomes active
|
| 13 |
this.$watch('$store.global.activeTab', (val) => {
|
| 14 |
if (val === 'dashboard') {
|
| 15 |
this.$nextTick(() => {
|
| 16 |
this.updateStats();
|
| 17 |
this.updateCharts();
|
|
|
|
| 18 |
});
|
| 19 |
}
|
| 20 |
});
|
|
@@ -32,22 +65,456 @@ window.Components.dashboard = () => ({
|
|
| 32 |
this.$nextTick(() => {
|
| 33 |
this.updateStats();
|
| 34 |
this.updateCharts();
|
|
|
|
| 35 |
});
|
| 36 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
},
|
| 38 |
|
| 39 |
updateStats() {
|
| 40 |
const accounts = Alpine.store('data').accounts;
|
| 41 |
let active = 0, limited = 0;
|
|
|
|
|
|
|
|
|
|
| 42 |
accounts.forEach(acc => {
|
| 43 |
if (acc.status === 'ok') {
|
| 44 |
-
const
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
} else {
|
| 47 |
limited++;
|
| 48 |
}
|
| 49 |
});
|
| 50 |
-
this.stats =
|
|
|
|
|
|
|
| 51 |
},
|
| 52 |
|
| 53 |
updateCharts() {
|
|
@@ -59,32 +526,70 @@ window.Components.dashboard = () => ({
|
|
| 59 |
}
|
| 60 |
|
| 61 |
const rows = Alpine.store('data').quotaRows;
|
| 62 |
-
const familyStats = { claude: { sum: 0, count: 0 }, gemini: { sum: 0, count: 0 }, other: { sum: 0, count: 0 } };
|
| 63 |
-
|
| 64 |
-
// Calculate overall system health
|
| 65 |
-
let totalHealthSum = 0;
|
| 66 |
-
let totalModelCount = 0;
|
| 67 |
|
|
|
|
|
|
|
| 68 |
rows.forEach(row => {
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
this.charts.quotaDistribution = new Chart(ctx, {
|
| 90 |
type: 'doughnut',
|
|
@@ -92,24 +597,22 @@ window.Components.dashboard = () => ({
|
|
| 92 |
labels: labels,
|
| 93 |
datasets: [{
|
| 94 |
data: data,
|
| 95 |
-
backgroundColor:
|
| 96 |
-
borderColor: '
|
| 97 |
borderWidth: 2,
|
| 98 |
hoverOffset: 0,
|
| 99 |
-
borderRadius:
|
| 100 |
}]
|
| 101 |
},
|
| 102 |
options: {
|
| 103 |
responsive: true,
|
| 104 |
maintainAspectRatio: false,
|
| 105 |
-
cutout: '85%',
|
|
|
|
|
|
|
| 106 |
plugins: {
|
| 107 |
-
legend: {
|
| 108 |
-
|
| 109 |
-
},
|
| 110 |
-
tooltip: {
|
| 111 |
-
enabled: false // Disable tooltip for cleaner look, or style it? Let's keep it simple.
|
| 112 |
-
},
|
| 113 |
title: { display: false }
|
| 114 |
},
|
| 115 |
animation: {
|
|
|
|
| 4 |
*/
|
| 5 |
window.Components = window.Components || {};
|
| 6 |
|
| 7 |
+
// Helper to get CSS variable values (alias to window.utils.getThemeColor)
|
| 8 |
+
const getThemeColor = (name) => window.utils.getThemeColor(name);
|
| 9 |
+
|
| 10 |
+
// Color palette for different families and models
|
| 11 |
+
const FAMILY_COLORS = {
|
| 12 |
+
get claude() { return getThemeColor('--color-neon-purple'); },
|
| 13 |
+
get gemini() { return getThemeColor('--color-neon-green'); },
|
| 14 |
+
get other() { return getThemeColor('--color-neon-cyan'); }
|
| 15 |
+
};
|
| 16 |
+
|
| 17 |
+
const MODEL_COLORS = Array.from({ length: 16 }, (_, i) => getThemeColor(`--color-chart-${i + 1}`));
|
| 18 |
+
|
| 19 |
window.Components.dashboard = () => ({
|
| 20 |
+
stats: { total: 0, active: 0, limited: 0, overallHealth: 0, hasTrendData: false },
|
| 21 |
+
charts: { quotaDistribution: null, usageTrend: null },
|
| 22 |
+
|
| 23 |
+
// Usage stats
|
| 24 |
+
usageStats: { total: 0, today: 0, thisHour: 0 },
|
| 25 |
+
historyData: {},
|
| 26 |
+
|
| 27 |
+
// Hierarchical model tree: { claude: ['opus-4-5', 'sonnet-4-5'], gemini: ['3-flash'] }
|
| 28 |
+
modelTree: {},
|
| 29 |
+
families: [], // ['claude', 'gemini']
|
| 30 |
+
|
| 31 |
+
// Display mode: 'family' or 'model'
|
| 32 |
+
displayMode: 'model',
|
| 33 |
+
|
| 34 |
+
// Selection state
|
| 35 |
+
selectedFamilies: [],
|
| 36 |
+
selectedModels: {}, // { claude: ['opus-4-5'], gemini: ['3-flash'] }
|
| 37 |
+
|
| 38 |
+
showModelFilter: false,
|
| 39 |
|
| 40 |
init() {
|
| 41 |
+
// Load saved preferences from localStorage
|
| 42 |
+
this.loadPreferences();
|
| 43 |
+
|
| 44 |
// Update stats when dashboard becomes active
|
| 45 |
this.$watch('$store.global.activeTab', (val) => {
|
| 46 |
if (val === 'dashboard') {
|
| 47 |
this.$nextTick(() => {
|
| 48 |
this.updateStats();
|
| 49 |
this.updateCharts();
|
| 50 |
+
this.fetchHistory();
|
| 51 |
});
|
| 52 |
}
|
| 53 |
});
|
|
|
|
| 65 |
this.$nextTick(() => {
|
| 66 |
this.updateStats();
|
| 67 |
this.updateCharts();
|
| 68 |
+
this.fetchHistory();
|
| 69 |
});
|
| 70 |
}
|
| 71 |
+
|
| 72 |
+
// Refresh history every 5 minutes
|
| 73 |
+
setInterval(() => {
|
| 74 |
+
if (this.$store.global.activeTab === 'dashboard') {
|
| 75 |
+
this.fetchHistory();
|
| 76 |
+
}
|
| 77 |
+
}, 300000);
|
| 78 |
+
},
|
| 79 |
+
|
| 80 |
+
loadPreferences() {
|
| 81 |
+
try {
|
| 82 |
+
const saved = localStorage.getItem('dashboard_chart_prefs');
|
| 83 |
+
if (saved) {
|
| 84 |
+
const prefs = JSON.parse(saved);
|
| 85 |
+
this.displayMode = prefs.displayMode || 'model';
|
| 86 |
+
this.selectedFamilies = prefs.selectedFamilies || [];
|
| 87 |
+
this.selectedModels = prefs.selectedModels || {};
|
| 88 |
+
}
|
| 89 |
+
} catch (e) {
|
| 90 |
+
console.error('Failed to load dashboard preferences:', e);
|
| 91 |
+
}
|
| 92 |
+
},
|
| 93 |
+
|
| 94 |
+
savePreferences() {
|
| 95 |
+
try {
|
| 96 |
+
localStorage.setItem('dashboard_chart_prefs', JSON.stringify({
|
| 97 |
+
displayMode: this.displayMode,
|
| 98 |
+
selectedFamilies: this.selectedFamilies,
|
| 99 |
+
selectedModels: this.selectedModels
|
| 100 |
+
}));
|
| 101 |
+
} catch (e) {
|
| 102 |
+
console.error('Failed to save dashboard preferences:', e);
|
| 103 |
+
}
|
| 104 |
+
},
|
| 105 |
+
|
| 106 |
+
async fetchHistory() {
|
| 107 |
+
try {
|
| 108 |
+
const password = Alpine.store('global').webuiPassword;
|
| 109 |
+
const { response, newPassword } = await window.utils.request('/api/stats/history', {}, password);
|
| 110 |
+
if (newPassword) Alpine.store('global').webuiPassword = newPassword;
|
| 111 |
+
|
| 112 |
+
if (response.ok) {
|
| 113 |
+
const history = await response.json();
|
| 114 |
+
this.historyData = history;
|
| 115 |
+
this.processHistory(history);
|
| 116 |
+
this.stats.hasTrendData = true;
|
| 117 |
+
}
|
| 118 |
+
} catch (error) {
|
| 119 |
+
console.error('Failed to fetch usage history:', error);
|
| 120 |
+
this.stats.hasTrendData = true;
|
| 121 |
+
}
|
| 122 |
+
},
|
| 123 |
+
|
| 124 |
+
processHistory(history) {
|
| 125 |
+
// Build model tree from hierarchical data
|
| 126 |
+
const tree = {};
|
| 127 |
+
let total = 0, today = 0, thisHour = 0;
|
| 128 |
+
|
| 129 |
+
const now = new Date();
|
| 130 |
+
const todayStart = new Date(now);
|
| 131 |
+
todayStart.setHours(0, 0, 0, 0);
|
| 132 |
+
const currentHour = new Date(now);
|
| 133 |
+
currentHour.setMinutes(0, 0, 0);
|
| 134 |
+
|
| 135 |
+
Object.entries(history).forEach(([iso, hourData]) => {
|
| 136 |
+
const timestamp = new Date(iso);
|
| 137 |
+
|
| 138 |
+
// Process each family in the hour data
|
| 139 |
+
Object.entries(hourData).forEach(([key, value]) => {
|
| 140 |
+
// Skip metadata keys
|
| 141 |
+
if (key === '_total' || key === 'total') return;
|
| 142 |
+
|
| 143 |
+
// Handle hierarchical format: { claude: { "opus-4-5": 10, "_subtotal": 10 } }
|
| 144 |
+
if (typeof value === 'object' && value !== null) {
|
| 145 |
+
if (!tree[key]) tree[key] = new Set();
|
| 146 |
+
|
| 147 |
+
Object.keys(value).forEach(modelName => {
|
| 148 |
+
if (modelName !== '_subtotal') {
|
| 149 |
+
tree[key].add(modelName);
|
| 150 |
+
}
|
| 151 |
+
});
|
| 152 |
+
}
|
| 153 |
+
// Skip old flat format keys (claude, gemini as numbers)
|
| 154 |
+
});
|
| 155 |
+
|
| 156 |
+
// Calculate totals
|
| 157 |
+
const hourTotal = hourData._total || hourData.total || 0;
|
| 158 |
+
total += hourTotal;
|
| 159 |
+
|
| 160 |
+
if (timestamp >= todayStart) {
|
| 161 |
+
today += hourTotal;
|
| 162 |
+
}
|
| 163 |
+
if (timestamp.getTime() === currentHour.getTime()) {
|
| 164 |
+
thisHour = hourTotal;
|
| 165 |
+
}
|
| 166 |
+
});
|
| 167 |
+
|
| 168 |
+
this.usageStats = { total, today, thisHour };
|
| 169 |
+
|
| 170 |
+
// Convert Sets to sorted arrays
|
| 171 |
+
this.modelTree = {};
|
| 172 |
+
Object.entries(tree).forEach(([family, models]) => {
|
| 173 |
+
this.modelTree[family] = Array.from(models).sort();
|
| 174 |
+
});
|
| 175 |
+
this.families = Object.keys(this.modelTree).sort();
|
| 176 |
+
|
| 177 |
+
// Auto-select new families/models that haven't been configured
|
| 178 |
+
this.autoSelectNew();
|
| 179 |
+
|
| 180 |
+
this.updateTrendChart();
|
| 181 |
+
},
|
| 182 |
+
|
| 183 |
+
autoSelectNew() {
|
| 184 |
+
// If no preferences saved, select all
|
| 185 |
+
if (this.selectedFamilies.length === 0 && Object.keys(this.selectedModels).length === 0) {
|
| 186 |
+
this.selectedFamilies = [...this.families];
|
| 187 |
+
this.families.forEach(family => {
|
| 188 |
+
this.selectedModels[family] = [...(this.modelTree[family] || [])];
|
| 189 |
+
});
|
| 190 |
+
this.savePreferences();
|
| 191 |
+
return;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
// Add new families/models that appeared
|
| 195 |
+
this.families.forEach(family => {
|
| 196 |
+
if (!this.selectedFamilies.includes(family)) {
|
| 197 |
+
this.selectedFamilies.push(family);
|
| 198 |
+
}
|
| 199 |
+
if (!this.selectedModels[family]) {
|
| 200 |
+
this.selectedModels[family] = [];
|
| 201 |
+
}
|
| 202 |
+
(this.modelTree[family] || []).forEach(model => {
|
| 203 |
+
if (!this.selectedModels[family].includes(model)) {
|
| 204 |
+
this.selectedModels[family].push(model);
|
| 205 |
+
}
|
| 206 |
+
});
|
| 207 |
+
});
|
| 208 |
+
},
|
| 209 |
+
|
| 210 |
+
autoSelectTopN(n = 5) {
|
| 211 |
+
// Calculate usage for each model over past 24 hours
|
| 212 |
+
const usage = {};
|
| 213 |
+
const now = Date.now();
|
| 214 |
+
const dayAgo = now - 24 * 60 * 60 * 1000;
|
| 215 |
+
|
| 216 |
+
Object.entries(this.historyData).forEach(([iso, hourData]) => {
|
| 217 |
+
const timestamp = new Date(iso).getTime();
|
| 218 |
+
if (timestamp < dayAgo) return;
|
| 219 |
+
|
| 220 |
+
Object.entries(hourData).forEach(([family, familyData]) => {
|
| 221 |
+
if (typeof familyData === 'object' && family !== '_total') {
|
| 222 |
+
Object.entries(familyData).forEach(([model, count]) => {
|
| 223 |
+
if (model !== '_subtotal') {
|
| 224 |
+
const key = `${family}:${model}`;
|
| 225 |
+
usage[key] = (usage[key] || 0) + count;
|
| 226 |
+
}
|
| 227 |
+
});
|
| 228 |
+
}
|
| 229 |
+
});
|
| 230 |
+
});
|
| 231 |
+
|
| 232 |
+
// Sort by usage and take top N
|
| 233 |
+
const sorted = Object.entries(usage)
|
| 234 |
+
.sort((a, b) => b[1] - a[1])
|
| 235 |
+
.slice(0, n);
|
| 236 |
+
|
| 237 |
+
// Clear current selection
|
| 238 |
+
this.selectedFamilies = [];
|
| 239 |
+
this.selectedModels = {};
|
| 240 |
+
|
| 241 |
+
// Select top N models
|
| 242 |
+
sorted.forEach(([key]) => {
|
| 243 |
+
const [family, model] = key.split(':');
|
| 244 |
+
if (!this.selectedFamilies.includes(family)) {
|
| 245 |
+
this.selectedFamilies.push(family);
|
| 246 |
+
}
|
| 247 |
+
if (!this.selectedModels[family]) {
|
| 248 |
+
this.selectedModels[family] = [];
|
| 249 |
+
}
|
| 250 |
+
this.selectedModels[family].push(model);
|
| 251 |
+
});
|
| 252 |
+
|
| 253 |
+
this.savePreferences();
|
| 254 |
+
this.refreshChart();
|
| 255 |
+
},
|
| 256 |
+
|
| 257 |
+
// Toggle display mode between family and model level
|
| 258 |
+
setDisplayMode(mode) {
|
| 259 |
+
this.displayMode = mode;
|
| 260 |
+
this.savePreferences();
|
| 261 |
+
this.updateTrendChart();
|
| 262 |
+
},
|
| 263 |
+
|
| 264 |
+
// Toggle family selection
|
| 265 |
+
toggleFamily(family) {
|
| 266 |
+
const index = this.selectedFamilies.indexOf(family);
|
| 267 |
+
if (index > -1) {
|
| 268 |
+
this.selectedFamilies.splice(index, 1);
|
| 269 |
+
} else {
|
| 270 |
+
this.selectedFamilies.push(family);
|
| 271 |
+
}
|
| 272 |
+
this.savePreferences();
|
| 273 |
+
this.updateTrendChart();
|
| 274 |
+
},
|
| 275 |
+
|
| 276 |
+
// Toggle model selection within a family
|
| 277 |
+
toggleModel(family, model) {
|
| 278 |
+
if (!this.selectedModels[family]) {
|
| 279 |
+
this.selectedModels[family] = [];
|
| 280 |
+
}
|
| 281 |
+
const index = this.selectedModels[family].indexOf(model);
|
| 282 |
+
if (index > -1) {
|
| 283 |
+
this.selectedModels[family].splice(index, 1);
|
| 284 |
+
} else {
|
| 285 |
+
this.selectedModels[family].push(model);
|
| 286 |
+
}
|
| 287 |
+
this.savePreferences();
|
| 288 |
+
this.updateTrendChart();
|
| 289 |
+
},
|
| 290 |
+
|
| 291 |
+
// Check if family is selected
|
| 292 |
+
isFamilySelected(family) {
|
| 293 |
+
return this.selectedFamilies.includes(family);
|
| 294 |
+
},
|
| 295 |
+
|
| 296 |
+
// Check if model is selected
|
| 297 |
+
isModelSelected(family, model) {
|
| 298 |
+
return this.selectedModels[family]?.includes(model) || false;
|
| 299 |
+
},
|
| 300 |
+
|
| 301 |
+
// Select all families and models
|
| 302 |
+
selectAll() {
|
| 303 |
+
this.selectedFamilies = [...this.families];
|
| 304 |
+
this.families.forEach(family => {
|
| 305 |
+
this.selectedModels[family] = [...(this.modelTree[family] || [])];
|
| 306 |
+
});
|
| 307 |
+
this.savePreferences();
|
| 308 |
+
this.updateTrendChart();
|
| 309 |
+
},
|
| 310 |
+
|
| 311 |
+
// Deselect all
|
| 312 |
+
deselectAll() {
|
| 313 |
+
this.selectedFamilies = [];
|
| 314 |
+
this.selectedModels = {};
|
| 315 |
+
this.savePreferences();
|
| 316 |
+
this.updateTrendChart();
|
| 317 |
+
},
|
| 318 |
+
|
| 319 |
+
// Get color for family
|
| 320 |
+
getFamilyColor(family) {
|
| 321 |
+
return FAMILY_COLORS[family] || FAMILY_COLORS.other;
|
| 322 |
+
},
|
| 323 |
+
|
| 324 |
+
// Get color for model (with index for variation within family)
|
| 325 |
+
getModelColor(family, modelIndex) {
|
| 326 |
+
const baseIndex = family === 'claude' ? 0 : (family === 'gemini' ? 4 : 8);
|
| 327 |
+
return MODEL_COLORS[(baseIndex + modelIndex) % MODEL_COLORS.length];
|
| 328 |
+
},
|
| 329 |
+
|
| 330 |
+
// Get count of selected items for display
|
| 331 |
+
getSelectedCount() {
|
| 332 |
+
if (this.displayMode === 'family') {
|
| 333 |
+
return `${this.selectedFamilies.length}/${this.families.length}`;
|
| 334 |
+
}
|
| 335 |
+
let selected = 0, total = 0;
|
| 336 |
+
this.families.forEach(family => {
|
| 337 |
+
const models = this.modelTree[family] || [];
|
| 338 |
+
total += models.length;
|
| 339 |
+
selected += (this.selectedModels[family] || []).length;
|
| 340 |
+
});
|
| 341 |
+
return `${selected}/${total}`;
|
| 342 |
+
},
|
| 343 |
+
|
| 344 |
+
updateTrendChart() {
|
| 345 |
+
const ctx = document.getElementById('usageTrendChart');
|
| 346 |
+
if (!ctx || typeof Chart === 'undefined') return;
|
| 347 |
+
|
| 348 |
+
if (this.charts.usageTrend) {
|
| 349 |
+
this.charts.usageTrend.destroy();
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
const history = this.historyData;
|
| 353 |
+
const labels = [];
|
| 354 |
+
const datasets = [];
|
| 355 |
+
|
| 356 |
+
if (this.displayMode === 'family') {
|
| 357 |
+
// Aggregate by family
|
| 358 |
+
const dataByFamily = {};
|
| 359 |
+
this.selectedFamilies.forEach(family => {
|
| 360 |
+
dataByFamily[family] = [];
|
| 361 |
+
});
|
| 362 |
+
|
| 363 |
+
Object.entries(history).forEach(([iso, hourData]) => {
|
| 364 |
+
const date = new Date(iso);
|
| 365 |
+
labels.push(date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }));
|
| 366 |
+
|
| 367 |
+
this.selectedFamilies.forEach(family => {
|
| 368 |
+
const familyData = hourData[family];
|
| 369 |
+
const count = familyData?._subtotal || 0;
|
| 370 |
+
dataByFamily[family].push(count);
|
| 371 |
+
});
|
| 372 |
+
});
|
| 373 |
+
|
| 374 |
+
// Build datasets for families
|
| 375 |
+
this.selectedFamilies.forEach(family => {
|
| 376 |
+
const color = this.getFamilyColor(family);
|
| 377 |
+
const familyKey = 'family' + family.charAt(0).toUpperCase() + family.slice(1);
|
| 378 |
+
const label = Alpine.store('global').t(familyKey);
|
| 379 |
+
datasets.push(this.createDataset(
|
| 380 |
+
label,
|
| 381 |
+
dataByFamily[family],
|
| 382 |
+
color,
|
| 383 |
+
ctx
|
| 384 |
+
));
|
| 385 |
+
});
|
| 386 |
+
} else {
|
| 387 |
+
// Show individual models
|
| 388 |
+
const dataByModel = {};
|
| 389 |
+
|
| 390 |
+
// Initialize data arrays
|
| 391 |
+
this.families.forEach(family => {
|
| 392 |
+
(this.selectedModels[family] || []).forEach(model => {
|
| 393 |
+
const key = `${family}:${model}`;
|
| 394 |
+
dataByModel[key] = [];
|
| 395 |
+
});
|
| 396 |
+
});
|
| 397 |
+
|
| 398 |
+
Object.entries(history).forEach(([iso, hourData]) => {
|
| 399 |
+
const date = new Date(iso);
|
| 400 |
+
labels.push(date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }));
|
| 401 |
+
|
| 402 |
+
this.families.forEach(family => {
|
| 403 |
+
const familyData = hourData[family] || {};
|
| 404 |
+
(this.selectedModels[family] || []).forEach(model => {
|
| 405 |
+
const key = `${family}:${model}`;
|
| 406 |
+
dataByModel[key].push(familyData[model] || 0);
|
| 407 |
+
});
|
| 408 |
+
});
|
| 409 |
+
});
|
| 410 |
+
|
| 411 |
+
// Build datasets for models
|
| 412 |
+
this.families.forEach(family => {
|
| 413 |
+
(this.selectedModels[family] || []).forEach((model, modelIndex) => {
|
| 414 |
+
const key = `${family}:${model}`;
|
| 415 |
+
const color = this.getModelColor(family, modelIndex);
|
| 416 |
+
datasets.push(this.createDataset(model, dataByModel[key], color, ctx));
|
| 417 |
+
});
|
| 418 |
+
});
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
this.charts.usageTrend = new Chart(ctx, {
|
| 422 |
+
type: 'line',
|
| 423 |
+
data: { labels, datasets },
|
| 424 |
+
options: {
|
| 425 |
+
responsive: true,
|
| 426 |
+
maintainAspectRatio: false,
|
| 427 |
+
interaction: {
|
| 428 |
+
mode: 'index',
|
| 429 |
+
intersect: false,
|
| 430 |
+
},
|
| 431 |
+
plugins: {
|
| 432 |
+
legend: { display: false },
|
| 433 |
+
tooltip: {
|
| 434 |
+
backgroundColor: getThemeColor('--color-space-950') || 'rgba(24, 24, 27, 0.9)',
|
| 435 |
+
titleColor: getThemeColor('--color-text-main'),
|
| 436 |
+
bodyColor: getThemeColor('--color-text-bright'),
|
| 437 |
+
borderColor: getThemeColor('--color-space-border'),
|
| 438 |
+
borderWidth: 1,
|
| 439 |
+
padding: 10,
|
| 440 |
+
displayColors: true,
|
| 441 |
+
callbacks: {
|
| 442 |
+
label: function(context) {
|
| 443 |
+
return context.dataset.label + ': ' + context.parsed.y;
|
| 444 |
+
}
|
| 445 |
+
}
|
| 446 |
+
}
|
| 447 |
+
},
|
| 448 |
+
scales: {
|
| 449 |
+
x: {
|
| 450 |
+
display: true,
|
| 451 |
+
grid: { display: false },
|
| 452 |
+
ticks: { color: getThemeColor('--color-text-muted'), font: { size: 10 } }
|
| 453 |
+
},
|
| 454 |
+
y: {
|
| 455 |
+
display: true,
|
| 456 |
+
beginAtZero: true,
|
| 457 |
+
grid: { display: true, color: getThemeColor('--color-space-border') + '1a' || 'rgba(255,255,255,0.05)' },
|
| 458 |
+
ticks: { color: getThemeColor('--color-text-muted'), font: { size: 10 } }
|
| 459 |
+
}
|
| 460 |
+
}
|
| 461 |
+
}
|
| 462 |
+
});
|
| 463 |
+
},
|
| 464 |
+
|
| 465 |
+
createDataset(label, data, color, ctx) {
|
| 466 |
+
const gradient = ctx.getContext('2d').createLinearGradient(0, 0, 0, 200);
|
| 467 |
+
gradient.addColorStop(0, this.hexToRgba(color, 0.3));
|
| 468 |
+
gradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
|
| 469 |
+
|
| 470 |
+
return {
|
| 471 |
+
label,
|
| 472 |
+
data,
|
| 473 |
+
borderColor: color,
|
| 474 |
+
backgroundColor: gradient,
|
| 475 |
+
borderWidth: 2,
|
| 476 |
+
tension: 0.4,
|
| 477 |
+
fill: true,
|
| 478 |
+
pointRadius: 3,
|
| 479 |
+
pointHoverRadius: 5,
|
| 480 |
+
pointBackgroundColor: color
|
| 481 |
+
};
|
| 482 |
+
},
|
| 483 |
+
|
| 484 |
+
hexToRgba(hex, alpha) {
|
| 485 |
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
| 486 |
+
if (result) {
|
| 487 |
+
return `rgba(${parseInt(result[1], 16)}, ${parseInt(result[2], 16)}, ${parseInt(result[3], 16)}, ${alpha})`;
|
| 488 |
+
}
|
| 489 |
+
return hex;
|
| 490 |
},
|
| 491 |
|
| 492 |
updateStats() {
|
| 493 |
const accounts = Alpine.store('data').accounts;
|
| 494 |
let active = 0, limited = 0;
|
| 495 |
+
|
| 496 |
+
const isCore = (id) => /sonnet|opus|pro|flash/i.test(id);
|
| 497 |
+
|
| 498 |
accounts.forEach(acc => {
|
| 499 |
if (acc.status === 'ok') {
|
| 500 |
+
const limits = Object.entries(acc.limits || {});
|
| 501 |
+
let hasActiveCore = limits.some(([id, l]) => l && l.remainingFraction > 0.05 && isCore(id));
|
| 502 |
+
|
| 503 |
+
if (!hasActiveCore) {
|
| 504 |
+
const hasAnyCore = limits.some(([id]) => isCore(id));
|
| 505 |
+
if (!hasAnyCore) {
|
| 506 |
+
hasActiveCore = limits.some(([_, l]) => l && l.remainingFraction > 0.05);
|
| 507 |
+
}
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
if (hasActiveCore) active++; else limited++;
|
| 511 |
} else {
|
| 512 |
limited++;
|
| 513 |
}
|
| 514 |
});
|
| 515 |
+
this.stats.total = accounts.length;
|
| 516 |
+
this.stats.active = active;
|
| 517 |
+
this.stats.limited = limited;
|
| 518 |
},
|
| 519 |
|
| 520 |
updateCharts() {
|
|
|
|
| 526 |
}
|
| 527 |
|
| 528 |
const rows = Alpine.store('data').quotaRows;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
|
| 530 |
+
// Dynamic family aggregation (supports any model family)
|
| 531 |
+
const familyStats = {};
|
| 532 |
rows.forEach(row => {
|
| 533 |
+
if (!familyStats[row.family]) {
|
| 534 |
+
familyStats[row.family] = { used: 0, total: 0 };
|
| 535 |
+
}
|
| 536 |
+
row.quotaInfo.forEach(info => {
|
| 537 |
+
familyStats[row.family].used += info.pct;
|
| 538 |
+
familyStats[row.family].total += 100;
|
| 539 |
+
});
|
| 540 |
+
});
|
| 541 |
|
| 542 |
+
// Calculate global health
|
| 543 |
+
const globalTotal = Object.values(familyStats).reduce((sum, f) => sum + f.total, 0);
|
| 544 |
+
const globalUsed = Object.values(familyStats).reduce((sum, f) => sum + f.used, 0);
|
| 545 |
+
this.stats.overallHealth = globalTotal > 0 ? Math.round((globalUsed / globalTotal) * 100) : 0;
|
| 546 |
|
| 547 |
+
// Generate chart data dynamically
|
| 548 |
+
const familyColors = {
|
| 549 |
+
'claude': getThemeColor('--color-neon-purple'),
|
| 550 |
+
'gemini': getThemeColor('--color-neon-green'),
|
| 551 |
+
'other': getThemeColor('--color-neon-cyan'),
|
| 552 |
+
'unknown': '#666666'
|
| 553 |
+
};
|
| 554 |
+
|
| 555 |
+
const families = Object.keys(familyStats).sort();
|
| 556 |
+
const segmentSize = families.length > 0 ? 100 / families.length : 100;
|
| 557 |
+
|
| 558 |
+
const data = [];
|
| 559 |
+
const colors = [];
|
| 560 |
+
const labels = [];
|
| 561 |
|
| 562 |
+
families.forEach(family => {
|
| 563 |
+
const stats = familyStats[family];
|
| 564 |
+
const health = stats.total > 0 ? Math.round((stats.used / stats.total) * 100) : 0;
|
| 565 |
+
const activeVal = (health / 100) * segmentSize;
|
| 566 |
+
const inactiveVal = segmentSize - activeVal;
|
| 567 |
|
| 568 |
+
const familyColor = familyColors[family] || familyColors['unknown'];
|
| 569 |
+
|
| 570 |
+
// Get translation keys if available, otherwise capitalize
|
| 571 |
+
const familyName = family.charAt(0).toUpperCase() + family.slice(1);
|
| 572 |
+
const store = Alpine.store('global');
|
| 573 |
+
|
| 574 |
+
// Labels using translations if possible
|
| 575 |
+
const activeLabel = family === 'claude' ? store.t('claudeActive') :
|
| 576 |
+
family === 'gemini' ? store.t('geminiActive') :
|
| 577 |
+
`${familyName} Active`;
|
| 578 |
+
|
| 579 |
+
const depletedLabel = family === 'claude' ? store.t('claudeEmpty') :
|
| 580 |
+
family === 'gemini' ? store.t('geminiEmpty') :
|
| 581 |
+
`${familyName} Depleted`;
|
| 582 |
+
|
| 583 |
+
// Active segment
|
| 584 |
+
data.push(activeVal);
|
| 585 |
+
colors.push(familyColor);
|
| 586 |
+
labels.push(activeLabel);
|
| 587 |
+
|
| 588 |
+
// Inactive segment
|
| 589 |
+
data.push(inactiveVal);
|
| 590 |
+
colors.push(this.hexToRgba(familyColor, 0.1));
|
| 591 |
+
labels.push(depletedLabel);
|
| 592 |
+
});
|
| 593 |
|
| 594 |
this.charts.quotaDistribution = new Chart(ctx, {
|
| 595 |
type: 'doughnut',
|
|
|
|
| 597 |
labels: labels,
|
| 598 |
datasets: [{
|
| 599 |
data: data,
|
| 600 |
+
backgroundColor: colors,
|
| 601 |
+
borderColor: getThemeColor('--color-space-950'),
|
| 602 |
borderWidth: 2,
|
| 603 |
hoverOffset: 0,
|
| 604 |
+
borderRadius: 0
|
| 605 |
}]
|
| 606 |
},
|
| 607 |
options: {
|
| 608 |
responsive: true,
|
| 609 |
maintainAspectRatio: false,
|
| 610 |
+
cutout: '85%',
|
| 611 |
+
rotation: -90,
|
| 612 |
+
circumference: 360,
|
| 613 |
plugins: {
|
| 614 |
+
legend: { display: false },
|
| 615 |
+
tooltip: { enabled: false },
|
|
|
|
|
|
|
|
|
|
|
|
|
| 616 |
title: { display: false }
|
| 617 |
},
|
| 618 |
animation: {
|
|
@@ -59,7 +59,8 @@ document.addEventListener('alpine:init', () => {
|
|
| 59 |
} catch (error) {
|
| 60 |
console.error('Fetch error:', error);
|
| 61 |
this.connectionStatus = 'disconnected';
|
| 62 |
-
Alpine.store('global')
|
|
|
|
| 63 |
} finally {
|
| 64 |
this.loading = false;
|
| 65 |
}
|
|
|
|
| 59 |
} catch (error) {
|
| 60 |
console.error('Fetch error:', error);
|
| 61 |
this.connectionStatus = 'disconnected';
|
| 62 |
+
const store = Alpine.store('global');
|
| 63 |
+
store.showToast(store.t('connectionLost'), 'error');
|
| 64 |
} finally {
|
| 65 |
this.loading = false;
|
| 66 |
}
|
|
@@ -44,7 +44,8 @@ document.addEventListener('alpine:init', () => {
|
|
| 44 |
localStorage.setItem('antigravity_settings', JSON.stringify(toSave));
|
| 45 |
|
| 46 |
if (!silent) {
|
| 47 |
-
Alpine.store('global')
|
|
|
|
| 48 |
}
|
| 49 |
|
| 50 |
// Trigger updates
|
|
|
|
| 44 |
localStorage.setItem('antigravity_settings', JSON.stringify(toSave));
|
| 45 |
|
| 46 |
if (!silent) {
|
| 47 |
+
const store = Alpine.store('global');
|
| 48 |
+
store.showToast(store.t('configSaved'), 'success');
|
| 49 |
}
|
| 50 |
|
| 51 |
// Trigger updates
|
|
@@ -56,7 +56,14 @@ document.addEventListener('alpine:init', () => {
|
|
| 56 |
delete: "Delete",
|
| 57 |
confirmDelete: "Are you sure you want to remove this account?",
|
| 58 |
connectGoogle: "Connect Google Account",
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
// Tabs
|
| 61 |
tabInterface: "Interface",
|
| 62 |
tabClaude: "Claude CLI",
|
|
@@ -104,6 +111,68 @@ document.addEventListener('alpine:init', () => {
|
|
| 104 |
authToken: "Auth Token",
|
| 105 |
saveConfig: "Save to ~/.claude/settings.json",
|
| 106 |
envVar: "Env",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
},
|
| 108 |
zh: {
|
| 109 |
dashboard: "仪表盘",
|
|
@@ -148,6 +217,14 @@ document.addEventListener('alpine:init', () => {
|
|
| 148 |
delete: "删除",
|
| 149 |
confirmDelete: "确定要移除此账号吗?",
|
| 150 |
connectGoogle: "连接 Google 账号",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
manualReload: "重新加载配置",
|
| 152 |
// Tabs
|
| 153 |
tabInterface: "界面设置",
|
|
@@ -196,14 +273,82 @@ document.addEventListener('alpine:init', () => {
|
|
| 196 |
authToken: "认证令牌",
|
| 197 |
saveConfig: "保存到 ~/.claude/settings.json",
|
| 198 |
envVar: "环境变量",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
}
|
| 200 |
},
|
| 201 |
|
| 202 |
// Toast Messages
|
| 203 |
toast: null,
|
| 204 |
|
| 205 |
-
t(key) {
|
| 206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
},
|
| 208 |
|
| 209 |
setLang(l) {
|
|
|
|
| 56 |
delete: "Delete",
|
| 57 |
confirmDelete: "Are you sure you want to remove this account?",
|
| 58 |
connectGoogle: "Connect Google Account",
|
| 59 |
+
reauthenticated: "re-authenticated",
|
| 60 |
+
added: "added",
|
| 61 |
+
successfully: "successfully",
|
| 62 |
+
failedToGetAuthUrl: "Failed to get auth URL",
|
| 63 |
+
failedToStartOAuth: "Failed to start OAuth flow",
|
| 64 |
+
family: "Family",
|
| 65 |
+
model: "Model",
|
| 66 |
+
activeSuffix: "Active",
|
| 67 |
// Tabs
|
| 68 |
tabInterface: "Interface",
|
| 69 |
tabClaude: "Claude CLI",
|
|
|
|
| 111 |
authToken: "Auth Token",
|
| 112 |
saveConfig: "Save to ~/.claude/settings.json",
|
| 113 |
envVar: "Env",
|
| 114 |
+
// New Keys
|
| 115 |
+
systemName: "ANTIGRAVITY",
|
| 116 |
+
systemDesc: "CLAUDE PROXY SYSTEM",
|
| 117 |
+
connectGoogleDesc: "Connect a Google Workspace account to increase your API quota limit. The account will be used to proxy Claude requests via Antigravity.",
|
| 118 |
+
useCliCommand: "Use CLI Command",
|
| 119 |
+
close: "Close",
|
| 120 |
+
requestVolume: "Request Volume",
|
| 121 |
+
filter: "Filter",
|
| 122 |
+
all: "All",
|
| 123 |
+
none: "None",
|
| 124 |
+
noDataTracked: "No data tracked yet",
|
| 125 |
+
selectFamilies: "Select families to display",
|
| 126 |
+
selectModels: "Select models to display",
|
| 127 |
+
noLogsMatch: "No logs match filter",
|
| 128 |
+
connecting: "CONNECTING",
|
| 129 |
+
main: "Main",
|
| 130 |
+
system: "System",
|
| 131 |
+
refreshData: "Refresh Data",
|
| 132 |
+
connectionLost: "Connection Lost",
|
| 133 |
+
lastUpdated: "Last Updated",
|
| 134 |
+
grepLogs: "grep logs...",
|
| 135 |
+
noMatchingModels: "No matching models",
|
| 136 |
+
typeToSearch: "Type to search or select...",
|
| 137 |
+
or: "OR",
|
| 138 |
+
refreshingAccount: "Refreshing {email}...",
|
| 139 |
+
refreshedAccount: "Refreshed {email}",
|
| 140 |
+
refreshFailed: "Refresh failed",
|
| 141 |
+
accountToggled: "Account {email} {status}",
|
| 142 |
+
toggleFailed: "Toggle failed",
|
| 143 |
+
reauthenticating: "Re-authenticating {email}...",
|
| 144 |
+
authUrlFailed: "Failed to get auth URL",
|
| 145 |
+
deletedAccount: "Deleted {email}",
|
| 146 |
+
deleteFailed: "Delete failed",
|
| 147 |
+
accountsReloaded: "Accounts reloaded",
|
| 148 |
+
reloadFailed: "Reload failed",
|
| 149 |
+
claudeConfigSaved: "Claude configuration saved",
|
| 150 |
+
saveConfigFailed: "Failed to save configuration",
|
| 151 |
+
claudeActive: "Claude Active",
|
| 152 |
+
claudeEmpty: "Claude Empty",
|
| 153 |
+
geminiActive: "Gemini Active",
|
| 154 |
+
geminiEmpty: "Gemini Empty",
|
| 155 |
+
fix: "FIX",
|
| 156 |
+
synced: "SYNCED",
|
| 157 |
+
syncing: "SYNCING...",
|
| 158 |
+
// Additional
|
| 159 |
+
reloading: "Reloading...",
|
| 160 |
+
reloaded: "Reloaded",
|
| 161 |
+
lines: "lines",
|
| 162 |
+
enabledSeeLogs: "Enabled (See Logs)",
|
| 163 |
+
production: "Production",
|
| 164 |
+
configSaved: "Configuration Saved",
|
| 165 |
+
enterPassword: "Enter Web UI Password:",
|
| 166 |
+
ready: "READY",
|
| 167 |
+
familyClaude: "Claude",
|
| 168 |
+
familyGemini: "Gemini",
|
| 169 |
+
familyOther: "Other",
|
| 170 |
+
enabledStatus: "enabled",
|
| 171 |
+
disabledStatus: "disabled",
|
| 172 |
+
logLevelInfo: "INFO",
|
| 173 |
+
logLevelSuccess: "SUCCESS",
|
| 174 |
+
logLevelWarn: "WARN",
|
| 175 |
+
logLevelError: "ERR",
|
| 176 |
},
|
| 177 |
zh: {
|
| 178 |
dashboard: "仪表盘",
|
|
|
|
| 217 |
delete: "删除",
|
| 218 |
confirmDelete: "确定要移除此账号吗?",
|
| 219 |
connectGoogle: "连接 Google 账号",
|
| 220 |
+
reauthenticated: "已重新认证",
|
| 221 |
+
added: "已添加",
|
| 222 |
+
successfully: "成功",
|
| 223 |
+
failedToGetAuthUrl: "获取认证链接失败",
|
| 224 |
+
failedToStartOAuth: "启动 OAuth 流程失败",
|
| 225 |
+
family: "系列",
|
| 226 |
+
model: "模型",
|
| 227 |
+
activeSuffix: "活跃",
|
| 228 |
manualReload: "重新加载配置",
|
| 229 |
// Tabs
|
| 230 |
tabInterface: "界面设置",
|
|
|
|
| 273 |
authToken: "认证令牌",
|
| 274 |
saveConfig: "保存到 ~/.claude/settings.json",
|
| 275 |
envVar: "环境变量",
|
| 276 |
+
// New Keys
|
| 277 |
+
systemName: "ANTIGRAVITY",
|
| 278 |
+
systemDesc: "CLAUDE 代理系��",
|
| 279 |
+
connectGoogleDesc: "连接 Google Workspace 账号以增加 API 配额。该账号将用于通过 Antigravity 代理 Claude 请求。",
|
| 280 |
+
useCliCommand: "使用命令行",
|
| 281 |
+
close: "关闭",
|
| 282 |
+
requestVolume: "请求量",
|
| 283 |
+
filter: "筛选",
|
| 284 |
+
all: "全选",
|
| 285 |
+
none: "清空",
|
| 286 |
+
noDataTracked: "暂无追踪数据",
|
| 287 |
+
selectFamilies: "选择要显示的系列",
|
| 288 |
+
selectModels: "选择要显示的模型",
|
| 289 |
+
noLogsMatch: "没有符合过滤条件的日志",
|
| 290 |
+
connecting: "正在连接",
|
| 291 |
+
main: "主菜单",
|
| 292 |
+
system: "系统",
|
| 293 |
+
refreshData: "刷新数据",
|
| 294 |
+
connectionLost: "连接已断开",
|
| 295 |
+
lastUpdated: "最后更新",
|
| 296 |
+
grepLogs: "过滤日志...",
|
| 297 |
+
noMatchingModels: "没有匹配的模型",
|
| 298 |
+
typeToSearch: "输入以搜索或选择...",
|
| 299 |
+
or: "或",
|
| 300 |
+
refreshingAccount: "正在刷新 {email}...",
|
| 301 |
+
refreshedAccount: "已完成刷新 {email}",
|
| 302 |
+
refreshFailed: "刷新失败",
|
| 303 |
+
accountToggled: "账号 {email} 已{status}",
|
| 304 |
+
toggleFailed: "切换失败",
|
| 305 |
+
reauthenticating: "正在重新认证 {email}...",
|
| 306 |
+
authUrlFailed: "获取认证链接失败",
|
| 307 |
+
deletedAccount: "已删除 {email}",
|
| 308 |
+
deleteFailed: "删除失败",
|
| 309 |
+
accountsReloaded: "账号配置已重载",
|
| 310 |
+
reloadFailed: "重载失败",
|
| 311 |
+
claudeConfigSaved: "Claude 配置已保存",
|
| 312 |
+
saveConfigFailed: "保存配置失败",
|
| 313 |
+
claudeActive: "Claude 活跃",
|
| 314 |
+
claudeEmpty: "Claude 耗尽",
|
| 315 |
+
geminiActive: "Gemini 活跃",
|
| 316 |
+
geminiEmpty: "Gemini 耗尽",
|
| 317 |
+
fix: "修复",
|
| 318 |
+
synced: "已同步",
|
| 319 |
+
syncing: "正在同步...",
|
| 320 |
+
// Additional
|
| 321 |
+
reloading: "正在重载...",
|
| 322 |
+
reloaded: "已重载",
|
| 323 |
+
lines: "行",
|
| 324 |
+
enabledSeeLogs: "已启用 (见日志)",
|
| 325 |
+
production: "生产环境",
|
| 326 |
+
configSaved: "配置已保存",
|
| 327 |
+
enterPassword: "请输入 Web UI 密码:",
|
| 328 |
+
ready: "就绪",
|
| 329 |
+
familyClaude: "Claude 系列",
|
| 330 |
+
familyGemini: "Gemini 系列",
|
| 331 |
+
familyOther: "其他系列",
|
| 332 |
+
enabledStatus: "已启用",
|
| 333 |
+
disabledStatus: "已禁用",
|
| 334 |
+
logLevelInfo: "信息",
|
| 335 |
+
logLevelSuccess: "成功",
|
| 336 |
+
logLevelWarn: "警告",
|
| 337 |
+
logLevelError: "错误",
|
| 338 |
}
|
| 339 |
},
|
| 340 |
|
| 341 |
// Toast Messages
|
| 342 |
toast: null,
|
| 343 |
|
| 344 |
+
t(key, params = {}) {
|
| 345 |
+
let str = this.translations[this.lang][key] || key;
|
| 346 |
+
if (typeof str === 'string') {
|
| 347 |
+
Object.keys(params).forEach(p => {
|
| 348 |
+
str = str.replace(`{${p}}`, params[p]);
|
| 349 |
+
});
|
| 350 |
+
}
|
| 351 |
+
return str;
|
| 352 |
},
|
| 353 |
|
| 354 |
setLang(l) {
|
|
@@ -13,7 +13,8 @@ window.utils = {
|
|
| 13 |
let response = await fetch(url, options);
|
| 14 |
|
| 15 |
if (response.status === 401) {
|
| 16 |
-
const
|
|
|
|
| 17 |
if (password) {
|
| 18 |
// Return new password so caller can update state
|
| 19 |
// This implies we need a way to propagate the new password back
|
|
@@ -31,11 +32,16 @@ window.utils = {
|
|
| 31 |
},
|
| 32 |
|
| 33 |
formatTimeUntil(isoTime) {
|
|
|
|
| 34 |
const diff = new Date(isoTime) - new Date();
|
| 35 |
-
if (diff <= 0) return 'READY';
|
| 36 |
const mins = Math.floor(diff / 60000);
|
| 37 |
const hrs = Math.floor(mins / 60);
|
| 38 |
if (hrs > 0) return `${hrs}H ${mins % 60}M`;
|
| 39 |
return `${mins}M`;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
}
|
| 41 |
};
|
|
|
|
| 13 |
let response = await fetch(url, options);
|
| 14 |
|
| 15 |
if (response.status === 401) {
|
| 16 |
+
const store = Alpine.store('global');
|
| 17 |
+
const password = prompt(store ? store.t('enterPassword') : 'Enter Web UI Password:');
|
| 18 |
if (password) {
|
| 19 |
// Return new password so caller can update state
|
| 20 |
// This implies we need a way to propagate the new password back
|
|
|
|
| 32 |
},
|
| 33 |
|
| 34 |
formatTimeUntil(isoTime) {
|
| 35 |
+
const store = Alpine.store('global');
|
| 36 |
const diff = new Date(isoTime) - new Date();
|
| 37 |
+
if (diff <= 0) return store ? store.t('ready') : 'READY';
|
| 38 |
const mins = Math.floor(diff / 60000);
|
| 39 |
const hrs = Math.floor(mins / 60);
|
| 40 |
if (hrs > 0) return `${hrs}H ${mins % 60}M`;
|
| 41 |
return `${mins}M`;
|
| 42 |
+
},
|
| 43 |
+
|
| 44 |
+
getThemeColor(name) {
|
| 45 |
+
return getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
| 46 |
}
|
| 47 |
};
|
|
@@ -1,14 +1,14 @@
|
|
| 1 |
-
<div x-data="accountManager" class="
|
| 2 |
-
<div class="
|
| 3 |
<div>
|
| 4 |
-
<h2 class="
|
| 5 |
-
Access
|
| 6 |
-
|
| 7 |
-
<p class="
|
| 8 |
-
and session
|
| 9 |
-
|
| 10 |
</div>
|
| 11 |
-
<button class="btn btn-
|
| 12 |
onclick="document.getElementById('add_account_modal').showModal()">
|
| 13 |
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 14 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
|
|
@@ -18,8 +18,8 @@
|
|
| 18 |
</div>
|
| 19 |
|
| 20 |
<div class="glass-panel rounded-xl overflow-hidden">
|
| 21 |
-
<table class="
|
| 22 |
-
<thead
|
| 23 |
<tr>
|
| 24 |
<th class="pl-6 w-24" x-text="$store.global.t('enabled')">Enabled</th>
|
| 25 |
<th x-text="$store.global.t('identity')">Identity (Email)</th>
|
|
@@ -28,17 +28,14 @@
|
|
| 28 |
<th class="text-right pr-6" x-text="$store.global.t('operations')">Operations</th>
|
| 29 |
</tr>
|
| 30 |
</thead>
|
| 31 |
-
<tbody
|
| 32 |
<template x-for="acc in $store.data.accounts" :key="acc.email">
|
| 33 |
-
<tr
|
| 34 |
<td class="pl-6">
|
| 35 |
-
<
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
class="w-9 h-5 bg-space-800 border border-space-border peer-focus:outline-none peer-focus:ring-1 peer-focus:ring-neon-purple rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-gray-400 after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-neon-green/20 peer-checked:border-neon-green peer-checked:after:bg-neon-green peer-checked:after:shadow-[0_0_8px_rgba(34,197,94,0.8)]">
|
| 40 |
-
</div>
|
| 41 |
-
</label>
|
| 42 |
</td>
|
| 43 |
<td class="font-medium text-gray-200" x-text="acc.email"></td>
|
| 44 |
<td class="font-mono text-xs text-gray-400" x-text="acc.projectId || '-'"></td>
|
|
@@ -52,11 +49,12 @@
|
|
| 52 |
<!-- Fix Button -->
|
| 53 |
<button x-show="acc.status === 'invalid'"
|
| 54 |
class="btn btn-xs bg-yellow-500/10 text-yellow-500 hover:bg-yellow-500/20 border-none mr-1 px-2 font-mono"
|
| 55 |
-
@click="fixAccount(acc.email)"
|
|
|
|
| 56 |
FIX
|
| 57 |
</button>
|
| 58 |
<button class="btn btn-xs btn-square btn-ghost text-gray-400 hover:text-white"
|
| 59 |
-
@click="refreshAccount(acc.email)" title="
|
| 60 |
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 61 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 62 |
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
|
|
|
|
| 1 |
+
<div x-data="accountManager" class="view-container">
|
| 2 |
+
<div class="section-header">
|
| 3 |
<div>
|
| 4 |
+
<h2 class="section-title" x-text="$store.global.t('accessCredentials')">
|
| 5 |
+
Access Credentials
|
| 6 |
+
</h2>
|
| 7 |
+
<p class="section-desc" x-text="$store.global.t('manageTokens')">
|
| 8 |
+
Manage OAuth tokens and session states
|
| 9 |
+
</p>
|
| 10 |
</div>
|
| 11 |
+
<button class="btn btn-primary btn-sm gap-2"
|
| 12 |
onclick="document.getElementById('add_account_modal').showModal()">
|
| 13 |
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 14 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
|
|
|
|
| 18 |
</div>
|
| 19 |
|
| 20 |
<div class="glass-panel rounded-xl overflow-hidden">
|
| 21 |
+
<table class="standard-table">
|
| 22 |
+
<thead>
|
| 23 |
<tr>
|
| 24 |
<th class="pl-6 w-24" x-text="$store.global.t('enabled')">Enabled</th>
|
| 25 |
<th x-text="$store.global.t('identity')">Identity (Email)</th>
|
|
|
|
| 28 |
<th class="text-right pr-6" x-text="$store.global.t('operations')">Operations</th>
|
| 29 |
</tr>
|
| 30 |
</thead>
|
| 31 |
+
<tbody>
|
| 32 |
<template x-for="acc in $store.data.accounts" :key="acc.email">
|
| 33 |
+
<tr>
|
| 34 |
<td class="pl-6">
|
| 35 |
+
<input type="checkbox"
|
| 36 |
+
class="toggle toggle-success toggle-sm"
|
| 37 |
+
:checked="acc.enabled !== false"
|
| 38 |
+
@change="toggleAccount(acc.email, $el.checked)">
|
|
|
|
|
|
|
|
|
|
| 39 |
</td>
|
| 40 |
<td class="font-medium text-gray-200" x-text="acc.email"></td>
|
| 41 |
<td class="font-mono text-xs text-gray-400" x-text="acc.projectId || '-'"></td>
|
|
|
|
| 49 |
<!-- Fix Button -->
|
| 50 |
<button x-show="acc.status === 'invalid'"
|
| 51 |
class="btn btn-xs bg-yellow-500/10 text-yellow-500 hover:bg-yellow-500/20 border-none mr-1 px-2 font-mono"
|
| 52 |
+
@click="fixAccount(acc.email)"
|
| 53 |
+
x-text="$store.global.t('fix')">
|
| 54 |
FIX
|
| 55 |
</button>
|
| 56 |
<button class="btn btn-xs btn-square btn-ghost text-gray-400 hover:text-white"
|
| 57 |
+
@click="refreshAccount(acc.email)" :title="$store.global.t('refreshData')">
|
| 58 |
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 59 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 60 |
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
|
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
<div x-data="dashboard" class="
|
| 2 |
<!-- Stats Grid -->
|
| 3 |
<div class="grid grid-cols-1 md:grid-cols-4 gap-6">
|
| 4 |
<div
|
|
@@ -14,7 +14,7 @@
|
|
| 14 |
<div class="stat-title text-gray-500 font-mono text-xs uppercase tracking-wider"
|
| 15 |
x-text="$store.global.t('totalAccounts')"></div>
|
| 16 |
<div class="stat-value text-white font-mono text-3xl" x-text="stats.total"></div>
|
| 17 |
-
<div class="stat-desc text-gray-600 text-[10px] mt-1">Registered Nodes</div>
|
| 18 |
</div>
|
| 19 |
|
| 20 |
<div
|
|
@@ -61,8 +61,7 @@
|
|
| 61 |
<!-- Legend / Info -->
|
| 62 |
<div class="flex flex-col justify-center gap-2 flex-grow min-w-0 z-10">
|
| 63 |
<div class="flex items-center justify-between">
|
| 64 |
-
<span class="text-[10px] text-gray-500 uppercase tracking-wider font-mono">Global Quota</span>
|
| 65 |
-
<!-- <span class="text-xs font-bold text-neon-purple" x-text="stats.overallHealth + '%'"></span> -->
|
| 66 |
</div>
|
| 67 |
|
| 68 |
<!-- Custom Legend -->
|
|
@@ -72,7 +71,6 @@
|
|
| 72 |
<div class="w-1.5 h-1.5 rounded-full bg-neon-purple shadow-[0_0_4px_rgba(168,85,247,0.4)]"></div>
|
| 73 |
<span>Claude</span>
|
| 74 |
</div>
|
| 75 |
-
<!-- <span class="font-mono text-gray-600">--</span> -->
|
| 76 |
</div>
|
| 77 |
<div class="flex items-center justify-between text-[10px] text-gray-400">
|
| 78 |
<div class="flex items-center gap-1.5">
|
|
@@ -88,6 +86,180 @@
|
|
| 88 |
</div>
|
| 89 |
</div>
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
<!-- Controls -->
|
| 92 |
<div class="flex items-center justify-between gap-4 glass-panel p-2 rounded-lg h-16">
|
| 93 |
<div class="flex items-center gap-4 h-full">
|
|
@@ -141,9 +313,8 @@
|
|
| 141 |
|
| 142 |
<!-- Main Table -->
|
| 143 |
<div class="glass-panel rounded-xl overflow-hidden min-h-[400px]">
|
| 144 |
-
<table class="
|
| 145 |
-
<thead
|
| 146 |
-
class="bg-space-900/50 text-gray-500 font-mono text-xs uppercase tracking-wider border-b border-space-border">
|
| 147 |
<tr>
|
| 148 |
<th class="w-8 py-3 pl-4" x-text="$store.global.t('stat')">Stat</th>
|
| 149 |
<th class="py-3" x-text="$store.global.t('modelIdentity')">Model Identity</th>
|
|
@@ -153,9 +324,9 @@
|
|
| 153 |
Distribution</th>
|
| 154 |
</tr>
|
| 155 |
</thead>
|
| 156 |
-
<tbody class="
|
| 157 |
<template x-for="row in $store.data.quotaRows" :key="row.modelId">
|
| 158 |
-
<tr class="
|
| 159 |
<td class="pl-4">
|
| 160 |
<div class="w-2 h-2 rounded-full transition-all duration-500"
|
| 161 |
: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 @@
|
|
| 204 |
<td colspan="5" class="h-64 text-center">
|
| 205 |
<div class="flex flex-col items-center justify-center gap-3">
|
| 206 |
<span class="loading loading-bars loading-md text-neon-purple"></span>
|
| 207 |
-
<span class="text-xs font-mono text-gray-600 animate-pulse">ESTABLISHING
|
| 208 |
UPLINK...</span>
|
| 209 |
</div>
|
| 210 |
</td>
|
| 211 |
</tr>
|
| 212 |
<!-- Empty -->
|
| 213 |
<tr x-show="!$store.data.loading && $store.data.quotaRows.length === 0">
|
| 214 |
-
<td colspan="5" class="h-64 text-center text-gray-600 font-mono text-xs">
|
| 215 |
NO SIGNAL DETECTED
|
| 216 |
</td>
|
| 217 |
</tr>
|
|
|
|
| 1 |
+
<div x-data="dashboard" class="view-container">
|
| 2 |
<!-- Stats Grid -->
|
| 3 |
<div class="grid grid-cols-1 md:grid-cols-4 gap-6">
|
| 4 |
<div
|
|
|
|
| 14 |
<div class="stat-title text-gray-500 font-mono text-xs uppercase tracking-wider"
|
| 15 |
x-text="$store.global.t('totalAccounts')"></div>
|
| 16 |
<div class="stat-value text-white font-mono text-3xl" x-text="stats.total"></div>
|
| 17 |
+
<div class="stat-desc text-gray-600 text-[10px] mt-1" x-text="$store.global.t('registeredNodes')">Registered Nodes</div>
|
| 18 |
</div>
|
| 19 |
|
| 20 |
<div
|
|
|
|
| 61 |
<!-- Legend / Info -->
|
| 62 |
<div class="flex flex-col justify-center gap-2 flex-grow min-w-0 z-10">
|
| 63 |
<div class="flex items-center justify-between">
|
| 64 |
+
<span class="text-[10px] text-gray-500 uppercase tracking-wider font-mono" x-text="$store.global.t('globalQuota')">Global Quota</span>
|
|
|
|
| 65 |
</div>
|
| 66 |
|
| 67 |
<!-- Custom Legend -->
|
|
|
|
| 71 |
<div class="w-1.5 h-1.5 rounded-full bg-neon-purple shadow-[0_0_4px_rgba(168,85,247,0.4)]"></div>
|
| 72 |
<span>Claude</span>
|
| 73 |
</div>
|
|
|
|
| 74 |
</div>
|
| 75 |
<div class="flex items-center justify-between text-[10px] text-gray-400">
|
| 76 |
<div class="flex items-center gap-1.5">
|
|
|
|
| 86 |
</div>
|
| 87 |
</div>
|
| 88 |
|
| 89 |
+
<!-- Usage Trend Chart -->
|
| 90 |
+
<div class="glass-panel p-4 rounded-lg">
|
| 91 |
+
<!-- Header with Stats and Filter -->
|
| 92 |
+
<div class="flex items-center justify-between mb-3">
|
| 93 |
+
<div class="flex items-center gap-4">
|
| 94 |
+
<div class="flex items-center gap-2">
|
| 95 |
+
<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">
|
| 96 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"></path>
|
| 97 |
+
</svg>
|
| 98 |
+
<h3 class="text-xs font-mono text-gray-400 uppercase tracking-widest" x-text="$store.global.t('requestVolume')">Request Volume</h3>
|
| 99 |
+
</div>
|
| 100 |
+
|
| 101 |
+
<!-- Usage Stats Pills -->
|
| 102 |
+
<div class="flex gap-2 text-[10px] font-mono">
|
| 103 |
+
<div class="px-2 py-1 rounded bg-space-800 border border-space-border/50">
|
| 104 |
+
<span class="text-gray-500">Total:</span>
|
| 105 |
+
<span class="text-white ml-1" x-text="usageStats.total"></span>
|
| 106 |
+
</div>
|
| 107 |
+
<div class="px-2 py-1 rounded bg-space-800 border border-space-border/50">
|
| 108 |
+
<span class="text-gray-500">Today:</span>
|
| 109 |
+
<span class="text-neon-cyan ml-1" x-text="usageStats.today"></span>
|
| 110 |
+
</div>
|
| 111 |
+
<div class="px-2 py-1 rounded bg-space-800 border border-space-border/50">
|
| 112 |
+
<span class="text-gray-500">1H:</span>
|
| 113 |
+
<span class="text-neon-green ml-1" x-text="usageStats.thisHour"></span>
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
+
|
| 118 |
+
<!-- Display Mode Toggle -->
|
| 119 |
+
<div class="join">
|
| 120 |
+
<button @click="setDisplayMode('family')"
|
| 121 |
+
class="join-item btn btn-xs px-3 border-space-border/50 bg-space-800 text-gray-400 hover:text-white transition-all"
|
| 122 |
+
:class="{'bg-neon-purple/20 text-neon-purple border-neon-purple/50': displayMode === 'family'}"
|
| 123 |
+
x-text="$store.global.t('family')">
|
| 124 |
+
</button>
|
| 125 |
+
<button @click="setDisplayMode('model')"
|
| 126 |
+
class="join-item btn btn-xs px-3 border-space-border/50 bg-space-800 text-gray-400 hover:text-white transition-all"
|
| 127 |
+
:class="{'bg-neon-purple/20 text-neon-purple border-neon-purple/50': displayMode === 'model'}"
|
| 128 |
+
x-text="$store.global.t('model')">
|
| 129 |
+
</button>
|
| 130 |
+
</div>
|
| 131 |
+
|
| 132 |
+
<!-- Filter Dropdown -->
|
| 133 |
+
<div class="relative">
|
| 134 |
+
<button @click="showModelFilter = !showModelFilter"
|
| 135 |
+
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">
|
| 136 |
+
<svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 137 |
+
<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" />
|
| 138 |
+
</svg>
|
| 139 |
+
<span>Filter (<span x-text="getSelectedCount()"></span>)</span>
|
| 140 |
+
<svg class="w-3 h-3 transition-transform" :class="{'rotate-180': showModelFilter}" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 141 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
| 142 |
+
</svg>
|
| 143 |
+
</button>
|
| 144 |
+
|
| 145 |
+
<!-- Dropdown Menu -->
|
| 146 |
+
<div x-show="showModelFilter" @click.outside="showModelFilter = false"
|
| 147 |
+
x-transition:enter="transition ease-out duration-100"
|
| 148 |
+
x-transition:enter-start="opacity-0 scale-95"
|
| 149 |
+
x-transition:enter-end="opacity-100 scale-100"
|
| 150 |
+
x-transition:leave="transition ease-in duration-75"
|
| 151 |
+
x-transition:leave-start="opacity-100 scale-100"
|
| 152 |
+
x-transition:leave-end="opacity-0 scale-95"
|
| 153 |
+
class="absolute right-0 mt-1 w-72 bg-space-900 border border-space-border rounded-lg shadow-xl z-50 overflow-hidden"
|
| 154 |
+
style="display: none;">
|
| 155 |
+
|
| 156 |
+
<!-- Header -->
|
| 157 |
+
<div class="flex items-center justify-between px-3 py-2 border-b border-space-border/50 bg-space-800/50">
|
| 158 |
+
<span class="text-[10px] font-mono text-gray-500 uppercase" x-text="displayMode === 'family' ? $store.global.t('selectFamilies') : $store.global.t('selectModels')"></span>
|
| 159 |
+
<div class="flex gap-1">
|
| 160 |
+
<button @click="autoSelectTopN(5)" class="text-[10px] text-neon-purple hover:underline" title="Select Top 5 most used models (24h)">
|
| 161 |
+
<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>
|
| 162 |
+
Smart
|
| 163 |
+
</button>
|
| 164 |
+
<span class="text-gray-600">|</span>
|
| 165 |
+
<button @click="selectAll()" class="text-[10px] text-neon-cyan hover:underline" x-text="$store.global.t('all')">All</button>
|
| 166 |
+
<span class="text-gray-600">|</span>
|
| 167 |
+
<button @click="deselectAll()" class="text-[10px] text-gray-500 hover:underline" x-text="$store.global.t('none')">None</button>
|
| 168 |
+
</div>
|
| 169 |
+
</div>
|
| 170 |
+
|
| 171 |
+
<!-- Hierarchical List -->
|
| 172 |
+
<div class="max-h-64 overflow-y-auto p-2 space-y-2">
|
| 173 |
+
<template x-for="family in families" :key="family">
|
| 174 |
+
<div class="space-y-1">
|
| 175 |
+
<!-- Family Header -->
|
| 176 |
+
<label class="flex items-center gap-2 px-2 py-1.5 rounded hover:bg-white/5 cursor-pointer group"
|
| 177 |
+
x-show="displayMode === 'family'">
|
| 178 |
+
<input type="checkbox"
|
| 179 |
+
:checked="isFamilySelected(family)"
|
| 180 |
+
@change="toggleFamily(family)"
|
| 181 |
+
class="checkbox checkbox-xs checkbox-primary">
|
| 182 |
+
<div class="w-2 h-2 rounded-full flex-shrink-0" :style="'background-color:' + getFamilyColor(family)"></div>
|
| 183 |
+
<span class="text-xs text-gray-300 font-medium capitalize group-hover:text-white" x-text="family"></span>
|
| 184 |
+
<span class="text-[10px] text-gray-600 ml-auto" x-text="'(' + (modelTree[family] || []).length + ')'"></span>
|
| 185 |
+
</label>
|
| 186 |
+
|
| 187 |
+
<!-- Family Section Header (Model Mode) -->
|
| 188 |
+
<div class="flex items-center gap-2 px-2 py-1 text-[10px] text-gray-500 uppercase font-bold"
|
| 189 |
+
x-show="displayMode === 'model'">
|
| 190 |
+
<div class="w-1.5 h-1.5 rounded-full" :style="'background-color:' + getFamilyColor(family)"></div>
|
| 191 |
+
<span x-text="family"></span>
|
| 192 |
+
</div>
|
| 193 |
+
|
| 194 |
+
<!-- Models in Family -->
|
| 195 |
+
<template x-if="displayMode === 'model'">
|
| 196 |
+
<div class="ml-4 space-y-0.5">
|
| 197 |
+
<template x-for="(model, modelIndex) in (modelTree[family] || [])" :key="family + ':' + model">
|
| 198 |
+
<label class="flex items-center gap-2 px-2 py-1 rounded hover:bg-white/5 cursor-pointer group">
|
| 199 |
+
<input type="checkbox"
|
| 200 |
+
:checked="isModelSelected(family, model)"
|
| 201 |
+
@change="toggleModel(family, model)"
|
| 202 |
+
class="checkbox checkbox-xs checkbox-primary">
|
| 203 |
+
<div class="w-2 h-2 rounded-full flex-shrink-0" :style="'background-color:' + getModelColor(family, modelIndex)"></div>
|
| 204 |
+
<span class="text-xs text-gray-400 truncate group-hover:text-white" x-text="model"></span>
|
| 205 |
+
</label>
|
| 206 |
+
</template>
|
| 207 |
+
</div>
|
| 208 |
+
</template>
|
| 209 |
+
</div>
|
| 210 |
+
</template>
|
| 211 |
+
|
| 212 |
+
<!-- Empty State -->
|
| 213 |
+
<div x-show="families.length === 0" class="text-center py-4 text-gray-600 text-xs" x-text="$store.global.t('noDataTracked')">
|
| 214 |
+
No data tracked yet
|
| 215 |
+
</div>
|
| 216 |
+
</div>
|
| 217 |
+
</div>
|
| 218 |
+
</div>
|
| 219 |
+
</div>
|
| 220 |
+
|
| 221 |
+
<!-- Dynamic Legend -->
|
| 222 |
+
<div class="flex flex-wrap gap-3 mb-3" x-show="displayMode === 'family' ? selectedFamilies.length > 0 : Object.values(selectedModels).flat().length > 0">
|
| 223 |
+
<!-- Family Mode Legend -->
|
| 224 |
+
<template x-if="displayMode === 'family'">
|
| 225 |
+
<template x-for="family in selectedFamilies" :key="family">
|
| 226 |
+
<div class="flex items-center gap-1.5 text-[10px] font-mono">
|
| 227 |
+
<div class="w-2 h-2 rounded-full" :style="'background-color:' + getFamilyColor(family)"></div>
|
| 228 |
+
<span class="text-gray-400 capitalize" x-text="family"></span>
|
| 229 |
+
</div>
|
| 230 |
+
</template>
|
| 231 |
+
</template>
|
| 232 |
+
<!-- Model Mode Legend -->
|
| 233 |
+
<template x-if="displayMode === 'model'">
|
| 234 |
+
<template x-for="family in families" :key="'legend-' + family">
|
| 235 |
+
<template x-for="(model, modelIndex) in (selectedModels[family] || [])" :key="family + ':' + model">
|
| 236 |
+
<div class="flex items-center gap-1.5 text-[10px] font-mono">
|
| 237 |
+
<div class="w-2 h-2 rounded-full" :style="'background-color:' + getModelColor(family, modelIndex)"></div>
|
| 238 |
+
<span class="text-gray-400" x-text="model"></span>
|
| 239 |
+
</div>
|
| 240 |
+
</template>
|
| 241 |
+
</template>
|
| 242 |
+
</template>
|
| 243 |
+
</div>
|
| 244 |
+
|
| 245 |
+
<!-- Chart -->
|
| 246 |
+
<div class="h-48 w-full relative">
|
| 247 |
+
<canvas id="usageTrendChart"></canvas>
|
| 248 |
+
<!-- Loading/Empty State -->
|
| 249 |
+
<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;">
|
| 250 |
+
<div class="text-xs font-mono text-gray-500 flex items-center gap-2">
|
| 251 |
+
<span class="loading loading-spinner loading-xs"></span>
|
| 252 |
+
<span x-text="$store.global.t('syncing')">SYNCING...</span>
|
| 253 |
+
</div>
|
| 254 |
+
</div>
|
| 255 |
+
<!-- No Selection -->
|
| 256 |
+
<div x-show="stats.hasTrendData && (displayMode === 'family' ? selectedFamilies.length === 0 : Object.values(selectedModels).flat().length === 0)"
|
| 257 |
+
class="absolute inset-0 flex items-center justify-center bg-space-900/30 z-10">
|
| 258 |
+
<div class="text-xs font-mono text-gray-500" x-text="displayMode === 'family' ? $store.global.t('selectFamilies') : $store.global.t('selectModels')"></div>
|
| 259 |
+
</div>
|
| 260 |
+
</div>
|
| 261 |
+
</div>
|
| 262 |
+
|
| 263 |
<!-- Controls -->
|
| 264 |
<div class="flex items-center justify-between gap-4 glass-panel p-2 rounded-lg h-16">
|
| 265 |
<div class="flex items-center gap-4 h-full">
|
|
|
|
| 313 |
|
| 314 |
<!-- Main Table -->
|
| 315 |
<div class="glass-panel rounded-xl overflow-hidden min-h-[400px]">
|
| 316 |
+
<table class="standard-table" :class="{'table-xs': $store.settings.compact, 'table-sm': !$store.settings.compact}">
|
| 317 |
+
<thead>
|
|
|
|
| 318 |
<tr>
|
| 319 |
<th class="w-8 py-3 pl-4" x-text="$store.global.t('stat')">Stat</th>
|
| 320 |
<th class="py-3" x-text="$store.global.t('modelIdentity')">Model Identity</th>
|
|
|
|
| 324 |
Distribution</th>
|
| 325 |
</tr>
|
| 326 |
</thead>
|
| 327 |
+
<tbody class="text-sm">
|
| 328 |
<template x-for="row in $store.data.quotaRows" :key="row.modelId">
|
| 329 |
+
<tr class="group">
|
| 330 |
<td class="pl-4">
|
| 331 |
<div class="w-2 h-2 rounded-full transition-all duration-500"
|
| 332 |
: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)]'">
|
|
|
|
| 375 |
<td colspan="5" class="h-64 text-center">
|
| 376 |
<div class="flex flex-col items-center justify-center gap-3">
|
| 377 |
<span class="loading loading-bars loading-md text-neon-purple"></span>
|
| 378 |
+
<span class="text-xs font-mono text-gray-600 animate-pulse" x-text="$store.global.t('establishingUplink')">ESTABLISHING
|
| 379 |
UPLINK...</span>
|
| 380 |
</div>
|
| 381 |
</td>
|
| 382 |
</tr>
|
| 383 |
<!-- Empty -->
|
| 384 |
<tr x-show="!$store.data.loading && $store.data.quotaRows.length === 0">
|
| 385 |
+
<td colspan="5" class="h-64 text-center text-gray-600 font-mono text-xs" x-text="$store.global.t('noSignal')">
|
| 386 |
NO SIGNAL DETECTED
|
| 387 |
</td>
|
| 388 |
</tr>
|
|
@@ -1,6 +1,7 @@
|
|
| 1 |
-
<div x-data="logsViewer" class="h-full flex flex-col
|
| 2 |
-
<
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
<!-- Left: Decor & Title -->
|
| 6 |
<div class="flex items-center gap-3 shrink-0">
|
|
@@ -21,23 +22,23 @@
|
|
| 21 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
| 22 |
</svg>
|
| 23 |
</div>
|
| 24 |
-
<input type="text" x-model="searchQuery" placeholder="
|
| 25 |
class="w-full h-7 bg-space-950 border border-space-border rounded text-xs font-mono pl-7 pr-2 focus:border-neon-purple focus:outline-none transition-colors placeholder-gray-700 text-gray-300">
|
| 26 |
</div>
|
| 27 |
|
| 28 |
<!-- Filters -->
|
| 29 |
<div class="hidden md:flex gap-3 text-[10px] font-mono font-bold uppercase select-none">
|
| 30 |
<label class="flex items-center gap-1.5 cursor-pointer text-blue-400 opacity-50 hover:opacity-100 transition-opacity" :class="{'opacity-100': filters.INFO}">
|
| 31 |
-
<input type="checkbox" class="checkbox checkbox-xs checkbox-info rounded-[2px] w-3 h-3 border-blue-400/50" x-model="filters.INFO"> INFO
|
| 32 |
</label>
|
| 33 |
<label class="flex items-center gap-1.5 cursor-pointer text-neon-green opacity-50 hover:opacity-100 transition-opacity" :class="{'opacity-100': filters.SUCCESS}">
|
| 34 |
-
<input type="checkbox" class="checkbox checkbox-xs checkbox-success rounded-[2px] w-3 h-3 border-neon-green/50" x-model="filters.SUCCESS"> SUCCESS
|
| 35 |
</label>
|
| 36 |
<label class="flex items-center gap-1.5 cursor-pointer text-yellow-400 opacity-50 hover:opacity-100 transition-opacity" :class="{'opacity-100': filters.WARN}">
|
| 37 |
-
<input type="checkbox" class="checkbox checkbox-xs checkbox-warning rounded-[2px] w-3 h-3 border-yellow-400/50" x-model="filters.WARN"> WARN
|
| 38 |
</label>
|
| 39 |
<label class="flex items-center gap-1.5 cursor-pointer text-red-500 opacity-50 hover:opacity-100 transition-opacity" :class="{'opacity-100': filters.ERROR}">
|
| 40 |
-
<input type="checkbox" class="checkbox checkbox-xs checkbox-error rounded-[2px] w-3 h-3 border-red-500/50" x-model="filters.ERROR"> ERR
|
| 41 |
</label>
|
| 42 |
</div>
|
| 43 |
</div>
|
|
@@ -61,7 +62,7 @@
|
|
| 61 |
</div>
|
| 62 |
|
| 63 |
<!-- Log Content -->
|
| 64 |
-
<div id="logs-container" class="flex-1 overflow-auto p-4 font-mono text-xs space-y-0.5 bg-
|
| 65 |
<template x-for="(log, idx) in filteredLogs" :key="idx">
|
| 66 |
<div class="hover:bg-white/5 rounded px-2 py-0.5 -mx-2 break-words leading-tight flex gap-3 group">
|
| 67 |
<span class="text-gray-600 w-16 shrink-0 select-none group-hover:text-gray-500"
|
|
@@ -78,8 +79,10 @@
|
|
| 78 |
</template>
|
| 79 |
<!-- Blinking Cursor -->
|
| 80 |
<div class="h-4 w-2 bg-gray-500 animate-pulse mt-1 inline-block" x-show="filteredLogs.length === logs.length && !searchQuery"></div>
|
| 81 |
-
<div x-show="filteredLogs.length === 0 && logs.length > 0" class="text-gray-600 italic mt-4 text-center"
|
|
|
|
| 82 |
No logs match filter
|
| 83 |
</div>
|
| 84 |
</div>
|
|
|
|
| 85 |
</div>
|
|
|
|
| 1 |
+
<div x-data="logsViewer" class="view-container h-full flex flex-col">
|
| 2 |
+
<div class="glass-panel rounded-xl overflow-hidden border-space-border flex flex-col flex-1 min-h-0">
|
| 3 |
+
<!-- Toolbar -->
|
| 4 |
+
<div class="bg-space-900 flex flex-wrap gap-y-2 justify-between items-center p-2 px-4 border-b border-space-border select-none min-h-[48px] shrink-0">
|
| 5 |
|
| 6 |
<!-- Left: Decor & Title -->
|
| 7 |
<div class="flex items-center gap-3 shrink-0">
|
|
|
|
| 22 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
| 23 |
</svg>
|
| 24 |
</div>
|
| 25 |
+
<input type="text" x-model="searchQuery" :placeholder="$store.global.t('grepLogs')"
|
| 26 |
class="w-full h-7 bg-space-950 border border-space-border rounded text-xs font-mono pl-7 pr-2 focus:border-neon-purple focus:outline-none transition-colors placeholder-gray-700 text-gray-300">
|
| 27 |
</div>
|
| 28 |
|
| 29 |
<!-- Filters -->
|
| 30 |
<div class="hidden md:flex gap-3 text-[10px] font-mono font-bold uppercase select-none">
|
| 31 |
<label class="flex items-center gap-1.5 cursor-pointer text-blue-400 opacity-50 hover:opacity-100 transition-opacity" :class="{'opacity-100': filters.INFO}">
|
| 32 |
+
<input type="checkbox" class="checkbox checkbox-xs checkbox-info rounded-[2px] w-3 h-3 border-blue-400/50" x-model="filters.INFO"> <span x-text="$store.global.t('logLevelInfo')">INFO</span>
|
| 33 |
</label>
|
| 34 |
<label class="flex items-center gap-1.5 cursor-pointer text-neon-green opacity-50 hover:opacity-100 transition-opacity" :class="{'opacity-100': filters.SUCCESS}">
|
| 35 |
+
<input type="checkbox" class="checkbox checkbox-xs checkbox-success rounded-[2px] w-3 h-3 border-neon-green/50" x-model="filters.SUCCESS"> <span x-text="$store.global.t('logLevelSuccess')">SUCCESS</span>
|
| 36 |
</label>
|
| 37 |
<label class="flex items-center gap-1.5 cursor-pointer text-yellow-400 opacity-50 hover:opacity-100 transition-opacity" :class="{'opacity-100': filters.WARN}">
|
| 38 |
+
<input type="checkbox" class="checkbox checkbox-xs checkbox-warning rounded-[2px] w-3 h-3 border-yellow-400/50" x-model="filters.WARN"> <span x-text="$store.global.t('logLevelWarn')">WARN</span>
|
| 39 |
</label>
|
| 40 |
<label class="flex items-center gap-1.5 cursor-pointer text-red-500 opacity-50 hover:opacity-100 transition-opacity" :class="{'opacity-100': filters.ERROR}">
|
| 41 |
+
<input type="checkbox" class="checkbox checkbox-xs checkbox-error rounded-[2px] w-3 h-3 border-red-500/50" x-model="filters.ERROR"> <span x-text="$store.global.t('logLevelError')">ERR</span>
|
| 42 |
</label>
|
| 43 |
</div>
|
| 44 |
</div>
|
|
|
|
| 62 |
</div>
|
| 63 |
|
| 64 |
<!-- Log Content -->
|
| 65 |
+
<div id="logs-container" class="flex-1 overflow-auto p-4 font-mono text-xs space-y-0.5 bg-space-950">
|
| 66 |
<template x-for="(log, idx) in filteredLogs" :key="idx">
|
| 67 |
<div class="hover:bg-white/5 rounded px-2 py-0.5 -mx-2 break-words leading-tight flex gap-3 group">
|
| 68 |
<span class="text-gray-600 w-16 shrink-0 select-none group-hover:text-gray-500"
|
|
|
|
| 79 |
</template>
|
| 80 |
<!-- Blinking Cursor -->
|
| 81 |
<div class="h-4 w-2 bg-gray-500 animate-pulse mt-1 inline-block" x-show="filteredLogs.length === logs.length && !searchQuery"></div>
|
| 82 |
+
<div x-show="filteredLogs.length === 0 && logs.length > 0" class="text-gray-600 italic mt-4 text-center"
|
| 83 |
+
x-text="$store.global.t('noLogsMatch')">
|
| 84 |
No logs match filter
|
| 85 |
</div>
|
| 86 |
</div>
|
| 87 |
+
</div>
|
| 88 |
</div>
|
|
@@ -1,7 +1,36 @@
|
|
| 1 |
-
<div x-data="{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
<!-- Header & Tabs -->
|
| 3 |
-
<div class="
|
| 4 |
-
<div class="
|
|
|
|
| 5 |
<h3 class="text-xl font-bold text-white flex items-center gap-2">
|
| 6 |
<svg class="w-5 h-5 text-neon-purple" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 7 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
@@ -13,30 +42,30 @@
|
|
| 13 |
</h3>
|
| 14 |
</div>
|
| 15 |
|
| 16 |
-
<div class="flex gap-6">
|
| 17 |
<button @click="activeTab = 'ui'"
|
| 18 |
-
class="pb-3 border-b-2 transition-colors font-medium text-sm flex items-center gap-2"
|
| 19 |
:class="activeTab === 'ui' ? 'border-neon-purple text-white' : 'border-transparent text-gray-500 hover:text-gray-300'">
|
| 20 |
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21a4 4 0 01-4-4V5a2 2 0 012-2h4a2 2 0 012 2v12a4 4 0 01-4 4zm0 0h12a2 2 0 002-2v-4a2 2 0 00-2-2h-2.343M11 7.343l1.657-1.657a2 2 0 012.828 0l2.829 2.829a2 2 0 010 2.828l-8.486 8.485M7 17h.01" /></svg>
|
| 21 |
<span x-text="$store.global.t('tabInterface')">Interface</span>
|
| 22 |
</button>
|
| 23 |
<button @click="activeTab = 'claude'"
|
| 24 |
-
class="pb-3 border-b-2 transition-colors font-medium text-sm flex items-center gap-2"
|
| 25 |
:class="activeTab === 'claude' ? 'border-neon-purple text-white' : 'border-transparent text-gray-500 hover:text-gray-300'">
|
| 26 |
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>
|
| 27 |
<span x-text="$store.global.t('tabClaude')">Claude CLI</span>
|
| 28 |
</button>
|
| 29 |
<button @click="activeTab = 'models'"
|
| 30 |
-
class="pb-3 border-b-2 transition-colors font-medium text-sm flex items-center gap-2"
|
| 31 |
:class="activeTab === 'models' ? 'border-neon-purple text-white' : 'border-transparent text-gray-500 hover:text-gray-300'">
|
| 32 |
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" /></svg>
|
| 33 |
<span x-text="$store.global.t('tabModels')">Models</span>
|
| 34 |
</button>
|
| 35 |
<button @click="activeTab = 'server'"
|
| 36 |
-
class="pb-3 border-b-2 transition-colors font-medium text-sm flex items-center gap-2"
|
| 37 |
:class="activeTab === 'server' ? 'border-neon-purple text-white' : 'border-transparent text-gray-500 hover:text-gray-300'">
|
| 38 |
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01" /></svg>
|
| 39 |
-
<span x-text="$store.global.t('tabServer')">Server
|
| 40 |
</button>
|
| 41 |
</div>
|
| 42 |
</div>
|
|
@@ -74,8 +103,7 @@
|
|
| 74 |
</label>
|
| 75 |
<input type="range" min="10" max="300" class="range range-xs range-primary"
|
| 76 |
x-model="$store.settings.refreshInterval"
|
| 77 |
-
@change="$store.settings.saveSettings(true)"
|
| 78 |
-
style="--range-shdw: #a855f7">
|
| 79 |
<div class="w-full flex justify-between text-xs px-2 mt-2 text-gray-600 font-mono">
|
| 80 |
<span>10s</span>
|
| 81 |
<span>300s</span>
|
|
@@ -87,12 +115,11 @@
|
|
| 87 |
<label class="label">
|
| 88 |
<span class="label-text text-gray-300" x-text="$store.global.t('logBufferSize')">Log Buffer Size</span>
|
| 89 |
<span class="label-text-alt font-mono text-neon-purple"
|
| 90 |
-
x-text="$store.settings.logLimit + ' lines'"></span>
|
| 91 |
</label>
|
| 92 |
<input type="range" min="500" max="5000" step="500" class="range range-xs range-secondary"
|
| 93 |
x-model="$store.settings.logLimit"
|
| 94 |
-
@change="$store.settings.saveSettings(true)"
|
| 95 |
-
style="--range-shdw: #22c55e">
|
| 96 |
<div class="w-full flex justify-between text-xs px-2 mt-2 text-gray-600 font-mono">
|
| 97 |
<span>500</span>
|
| 98 |
<span>5000</span>
|
|
@@ -141,12 +168,12 @@
|
|
| 141 |
<div x-show="activeTab === 'claude'" x-data="claudeConfig" class="space-y-6 max-w-3xl animate-fade-in">
|
| 142 |
<div class="alert bg-space-900/50 border-space-border text-sm shadow-none">
|
| 143 |
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-info shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
| 144 |
-
<span class="text-gray-400">Settings below directly modify <code class="text-neon-cyan font-mono">~/.claude/settings.json</code>. Restart Claude CLI to apply.</span>
|
| 145 |
</div>
|
| 146 |
|
| 147 |
<!-- Base URL -->
|
| 148 |
<div class="card bg-space-900/30 border border-space-border/50 p-5">
|
| 149 |
-
<label class="label text-xs uppercase text-gray-500 font-semibold mb-2">Proxy Connection</label>
|
| 150 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 151 |
<div>
|
| 152 |
<div class="text-[11px] text-gray-400 mb-1 font-mono">ANTHROPIC_BASE_URL</div>
|
|
@@ -163,18 +190,18 @@
|
|
| 163 |
|
| 164 |
<!-- Models Selection -->
|
| 165 |
<div class="card bg-space-900/30 border border-space-border/50 p-5">
|
| 166 |
-
<label class="label text-xs uppercase text-gray-500 font-semibold mb-2">Model Selection</label>
|
| 167 |
|
| 168 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
|
| 169 |
<!-- Primary -->
|
| 170 |
<div class="form-control">
|
| 171 |
-
<label class="label pt-0 pb-1 text-[11px] text-gray-400 font-bold tracking-wider">Primary Model</label>
|
| 172 |
<div class="relative w-full" x-data="{ open: false }">
|
| 173 |
<input type="text" x-model="config.env.ANTHROPIC_MODEL"
|
| 174 |
@focus="open = true"
|
| 175 |
@click.away="open = false"
|
| 176 |
class="input input-sm w-full font-mono text-xs bg-space-800/50 border-space-border text-white focus:bg-space-800 focus:border-neon-cyan pr-8 placeholder-gray-600"
|
| 177 |
-
placeholder="
|
| 178 |
<div class="absolute right-2 top-1.5 cursor-pointer text-gray-500 hover:text-white transition-colors" @click="open = !open; if(open) $el.previousElementSibling.focus()" @mousedown.prevent>▼</div>
|
| 179 |
|
| 180 |
<ul x-show="open"
|
|
@@ -185,14 +212,15 @@
|
|
| 185 |
<template x-for="modelId in $store.data.models.filter(m => m.toLowerCase().includes(config.env.ANTHROPIC_MODEL?.toLowerCase() || ''))" :key="modelId">
|
| 186 |
<li>
|
| 187 |
<a @mousedown.prevent="config.env.ANTHROPIC_MODEL = modelId; open = false"
|
| 188 |
-
class="font-mono text-xs py-2 hover:bg-space-800
|
| 189 |
:class="config.env.ANTHROPIC_MODEL === modelId ? 'text-neon-cyan bg-space-800/50' : 'text-gray-300'">
|
|
|
|
| 190 |
<span x-text="modelId"></span>
|
| 191 |
</a>
|
| 192 |
</li>
|
| 193 |
</template>
|
| 194 |
<li x-show="$store.data.models.filter(m => m.toLowerCase().includes(config.env.ANTHROPIC_MODEL?.toLowerCase() || '')).length === 0">
|
| 195 |
-
<span class="text-xs text-gray-500 italic py-2">No matching models</span>
|
| 196 |
</li>
|
| 197 |
</ul>
|
| 198 |
</div>
|
|
@@ -201,13 +229,13 @@
|
|
| 201 |
|
| 202 |
<!-- Sub-agent -->
|
| 203 |
<div class="form-control">
|
| 204 |
-
<label class="label pt-0 pb-1 text-[11px] text-gray-400 font-bold tracking-wider">Sub-agent Model</label>
|
| 205 |
<div class="relative w-full" x-data="{ open: false }">
|
| 206 |
<input type="text" x-model="config.env.CLAUDE_CODE_SUBAGENT_MODEL"
|
| 207 |
@focus="open = true"
|
| 208 |
@click.away="open = false"
|
| 209 |
class="input input-sm w-full font-mono text-xs bg-space-800/50 border-space-border text-white focus:bg-space-800 focus:border-neon-purple pr-8 placeholder-gray-600"
|
| 210 |
-
placeholder="
|
| 211 |
<div class="absolute right-2 top-1.5 cursor-pointer text-gray-500 hover:text-white transition-colors" @click="open = !open; if(open) $el.previousElementSibling.focus()" @mousedown.prevent>▼</div>
|
| 212 |
|
| 213 |
<ul x-show="open"
|
|
@@ -218,14 +246,15 @@
|
|
| 218 |
<template x-for="modelId in $store.data.models.filter(m => m.toLowerCase().includes(config.env.CLAUDE_CODE_SUBAGENT_MODEL?.toLowerCase() || ''))" :key="modelId">
|
| 219 |
<li>
|
| 220 |
<a @mousedown.prevent="config.env.CLAUDE_CODE_SUBAGENT_MODEL = modelId; open = false"
|
| 221 |
-
class="font-mono text-xs py-2 hover:bg-space-800
|
| 222 |
:class="config.env.CLAUDE_CODE_SUBAGENT_MODEL === modelId ? 'text-neon-purple bg-space-800/50' : 'text-gray-300'">
|
|
|
|
| 223 |
<span x-text="modelId"></span>
|
| 224 |
</a>
|
| 225 |
</li>
|
| 226 |
</template>
|
| 227 |
<li x-show="$store.data.models.filter(m => m.toLowerCase().includes(config.env.CLAUDE_CODE_SUBAGENT_MODEL?.toLowerCase() || '')).length === 0">
|
| 228 |
-
<span class="text-xs text-gray-500 italic py-2">No matching models</span>
|
| 229 |
</li>
|
| 230 |
</ul>
|
| 231 |
</div>
|
|
@@ -233,19 +262,19 @@
|
|
| 233 |
</div>
|
| 234 |
</div>
|
| 235 |
|
| 236 |
-
<div class="divider text-xs font-mono text-gray-600 my-2">ALIAS OVERRIDES</div>
|
| 237 |
|
| 238 |
<!-- Overrides -->
|
| 239 |
<div class="space-y-4">
|
| 240 |
<!-- Opus -->
|
| 241 |
<div class="form-control">
|
| 242 |
-
<label class="label pt-0 pb-1 text-[10px] text-gray-500 uppercase font-bold">Opus Alias</label>
|
| 243 |
<div class="relative w-full" x-data="{ open: false }">
|
| 244 |
<input type="text" x-model="config.env.ANTHROPIC_DEFAULT_OPUS_MODEL"
|
| 245 |
@focus="open = true"
|
| 246 |
@click.away="open = false"
|
| 247 |
class="input input-sm w-full font-mono text-xs bg-space-800/50 border-space-border text-gray-300 focus:bg-space-800 focus:border-neon-cyan pr-8 placeholder-gray-600"
|
| 248 |
-
placeholder="
|
| 249 |
<div class="absolute right-2 top-1.5 cursor-pointer text-gray-500 hover:text-white transition-colors" @click="open = !open; if(open) $el.previousElementSibling.focus()" @mousedown.prevent>▼</div>
|
| 250 |
<ul x-show="open"
|
| 251 |
x-transition:enter="transition ease-out duration-100"
|
|
@@ -255,8 +284,9 @@
|
|
| 255 |
<template x-for="modelId in $store.data.models.filter(m => m.toLowerCase().includes(config.env.ANTHROPIC_DEFAULT_OPUS_MODEL?.toLowerCase() || ''))" :key="modelId">
|
| 256 |
<li>
|
| 257 |
<a @mousedown.prevent="config.env.ANTHROPIC_DEFAULT_OPUS_MODEL = modelId; open = false"
|
| 258 |
-
class="font-mono text-xs py-1 hover:bg-space-800
|
| 259 |
:class="config.env.ANTHROPIC_DEFAULT_OPUS_MODEL === modelId ? 'text-neon-cyan bg-space-800/50' : 'text-gray-300'">
|
|
|
|
| 260 |
<span x-text="modelId"></span>
|
| 261 |
</a>
|
| 262 |
</li>
|
|
@@ -266,13 +296,13 @@
|
|
| 266 |
</div>
|
| 267 |
<!-- Sonnet -->
|
| 268 |
<div class="form-control">
|
| 269 |
-
<label class="label pt-0 pb-1 text-[10px] text-gray-500 uppercase font-bold">Sonnet Alias</label>
|
| 270 |
<div class="relative w-full" x-data="{ open: false }">
|
| 271 |
<input type="text" x-model="config.env.ANTHROPIC_DEFAULT_SONNET_MODEL"
|
| 272 |
@focus="open = true"
|
| 273 |
@click.away="open = false"
|
| 274 |
class="input input-sm w-full font-mono text-xs bg-space-800/50 border-space-border text-gray-300 focus:bg-space-800 focus:border-neon-cyan pr-8 placeholder-gray-600"
|
| 275 |
-
placeholder="
|
| 276 |
<div class="absolute right-2 top-1.5 cursor-pointer text-gray-500 hover:text-white transition-colors" @click="open = !open; if(open) $el.previousElementSibling.focus()" @mousedown.prevent>▼</div>
|
| 277 |
<ul x-show="open"
|
| 278 |
x-transition:enter="transition ease-out duration-100"
|
|
@@ -282,8 +312,9 @@
|
|
| 282 |
<template x-for="modelId in $store.data.models.filter(m => m.toLowerCase().includes(config.env.ANTHROPIC_DEFAULT_SONNET_MODEL?.toLowerCase() || ''))" :key="modelId">
|
| 283 |
<li>
|
| 284 |
<a @mousedown.prevent="config.env.ANTHROPIC_DEFAULT_SONNET_MODEL = modelId; open = false"
|
| 285 |
-
class="font-mono text-xs py-1 hover:bg-space-800
|
| 286 |
:class="config.env.ANTHROPIC_DEFAULT_SONNET_MODEL === modelId ? 'text-neon-cyan bg-space-800/50' : 'text-gray-300'">
|
|
|
|
| 287 |
<span x-text="modelId"></span>
|
| 288 |
</a>
|
| 289 |
</li>
|
|
@@ -293,13 +324,13 @@
|
|
| 293 |
</div>
|
| 294 |
<!-- Haiku -->
|
| 295 |
<div class="form-control">
|
| 296 |
-
<label class="label pt-0 pb-1 text-[10px] text-gray-500 uppercase font-bold">Haiku Alias</label>
|
| 297 |
<div class="relative w-full" x-data="{ open: false }">
|
| 298 |
<input type="text" x-model="config.env.ANTHROPIC_DEFAULT_HAIKU_MODEL"
|
| 299 |
@focus="open = true"
|
| 300 |
@click.away="open = false"
|
| 301 |
class="input input-sm w-full font-mono text-xs bg-space-800/50 border-space-border text-gray-300 focus:bg-space-800 focus:border-neon-cyan pr-8 placeholder-gray-600"
|
| 302 |
-
placeholder="
|
| 303 |
<div class="absolute right-2 top-1.5 cursor-pointer text-gray-500 hover:text-white transition-colors" @click="open = !open; if(open) $el.previousElementSibling.focus()" @mousedown.prevent>▼</div>
|
| 304 |
<ul x-show="open"
|
| 305 |
x-transition:enter="transition ease-out duration-100"
|
|
@@ -309,8 +340,9 @@
|
|
| 309 |
<template x-for="modelId in $store.data.models.filter(m => m.toLowerCase().includes(config.env.ANTHROPIC_DEFAULT_HAIKU_MODEL?.toLowerCase() || ''))" :key="modelId">
|
| 310 |
<li>
|
| 311 |
<a @mousedown.prevent="config.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = modelId; open = false"
|
| 312 |
-
class="font-mono text-xs py-1 hover:bg-space-800
|
| 313 |
:class="config.env.ANTHROPIC_DEFAULT_HAIKU_MODEL === modelId ? 'text-neon-cyan bg-space-800/50' : 'text-gray-300'">
|
|
|
|
| 314 |
<span x-text="modelId"></span>
|
| 315 |
</a>
|
| 316 |
</li>
|
|
@@ -325,7 +357,7 @@
|
|
| 325 |
<button class="btn btn-sm bg-neon-purple hover:bg-purple-600 border-none text-white px-6 gap-2"
|
| 326 |
@click="saveClaudeConfig" :disabled="loading">
|
| 327 |
<svg x-show="!loading" class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4" /></svg>
|
| 328 |
-
<span x-show="!loading">Write to Config</span>
|
| 329 |
<span x-show="loading" class="loading loading-spinner loading-xs"></span>
|
| 330 |
</button>
|
| 331 |
</div>
|
|
@@ -334,31 +366,34 @@
|
|
| 334 |
<!-- Tab 2.5: Models Configuration -->
|
| 335 |
<div x-show="activeTab === 'models'" class="space-y-6 max-w-3xl animate-fade-in">
|
| 336 |
<div class="flex items-center justify-between">
|
| 337 |
-
<div class="text-sm text-gray-400">Manage visibility and ordering of models in the dashboard.</div>
|
| 338 |
<div class="form-control">
|
| 339 |
<label class="label cursor-pointer gap-2">
|
| 340 |
-
<span class="label-text text-xs text-gray-500">Show Hidden Models</span>
|
| 341 |
<input type="checkbox" class="toggle toggle-xs toggle-primary" x-model="$store.settings.showHiddenModels" @change="$store.settings.saveSettings(true)">
|
| 342 |
</label>
|
| 343 |
</div>
|
| 344 |
</div>
|
| 345 |
|
| 346 |
<!-- Models List -->
|
| 347 |
-
<div class="
|
| 348 |
-
<table class="
|
| 349 |
-
<thead
|
| 350 |
<tr>
|
| 351 |
-
<th class="pl-4">Model ID</th>
|
| 352 |
-
<th>Alias</th>
|
| 353 |
-
<th
|
|
|
|
| 354 |
</tr>
|
| 355 |
</thead>
|
| 356 |
-
<tbody
|
| 357 |
<template x-for="modelId in $store.data.models" :key="modelId">
|
| 358 |
<tr class="hover:bg-white/5 transition-colors group"
|
| 359 |
x-data="{
|
| 360 |
-
|
|
|
|
| 361 |
newAlias: '',
|
|
|
|
| 362 |
// Use getters for reactivity - accessing store directly ensures updates are reflected immediately
|
| 363 |
get config() { return $store.data.modelConfig[modelId] || {} },
|
| 364 |
get isPinned() { return !!this.config.pinned },
|
|
@@ -369,40 +404,50 @@
|
|
| 369 |
return (family === 'other' || family === 'unknown');
|
| 370 |
}
|
| 371 |
}"
|
| 372 |
-
x-init="newAlias = config.alias || ''"
|
| 373 |
>
|
| 374 |
<td class="pl-4 font-mono text-xs text-gray-300" x-text="modelId"></td>
|
| 375 |
<td>
|
| 376 |
-
<div x-show="!
|
| 377 |
<span x-text="config.alias || '-'" :class="{'text-gray-600 italic': !config.alias}"></span>
|
| 378 |
<svg class="w-3 h-3 text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" /></svg>
|
| 379 |
</div>
|
| 380 |
-
<div x-show="
|
| 381 |
<input type="text" x-model="newAlias"
|
| 382 |
-
class="input input-xs bg-space-800 border-space-border text-white focus:outline-none focus:border-neon-purple w-
|
| 383 |
@keydown.enter="
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
method: 'POST',
|
| 387 |
-
headers: {'Content-Type': 'application/json'},
|
| 388 |
-
body: JSON.stringify({ modelId, config: { alias: newAlias } })
|
| 389 |
-
});
|
| 390 |
-
isEditing = false;
|
| 391 |
-
$store.data.computeQuotaRows();
|
| 392 |
"
|
| 393 |
-
@keydown.escape="
|
| 394 |
>
|
| 395 |
<button class="btn btn-xs btn-ghost btn-square text-green-500" @click="
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
method: 'POST',
|
| 399 |
-
headers: {'Content-Type': 'application/json'},
|
| 400 |
-
body: JSON.stringify({ modelId, config: { alias: newAlias } })
|
| 401 |
-
});
|
| 402 |
-
isEditing = false;
|
| 403 |
-
$store.data.computeQuotaRows();
|
| 404 |
"><svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" /></svg></button>
|
| 405 |
-
<button class="btn btn-xs btn-ghost btn-square text-gray-500" @click="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
</div>
|
| 407 |
</td>
|
| 408 |
<td class="text-right pr-4">
|
|
@@ -410,18 +455,8 @@
|
|
| 410 |
<!-- Pin Toggle -->
|
| 411 |
<button class="btn btn-xs btn-circle transition-colors"
|
| 412 |
:class="isPinned ? 'bg-neon-purple/20 text-neon-purple border-neon-purple/50 hover:bg-neon-purple/30' : 'btn-ghost text-gray-600 hover:text-gray-300'"
|
| 413 |
-
@click="
|
| 414 |
-
|
| 415 |
-
// Optimistic update
|
| 416 |
-
$store.data.modelConfig[modelId] = { ...config, pinned: newVal };
|
| 417 |
-
fetch('/api/models/config', {
|
| 418 |
-
method: 'POST',
|
| 419 |
-
headers: {'Content-Type': 'application/json'},
|
| 420 |
-
body: JSON.stringify({ modelId, config: { pinned: newVal } })
|
| 421 |
-
});
|
| 422 |
-
$store.data.computeQuotaRows();
|
| 423 |
-
"
|
| 424 |
-
title="Pin to top">
|
| 425 |
<!-- Solid Icon when Pinned -->
|
| 426 |
<svg x-show="isPinned" xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" viewBox="0 0 20 20" fill="currentColor">
|
| 427 |
<path d="M5 4a2 2 0 012-2h6a2 2 0 012 2v14l-5-2.5L5 18V4z" />
|
|
@@ -435,19 +470,8 @@
|
|
| 435 |
<!-- Hide Toggle -->
|
| 436 |
<button class="btn btn-xs btn-circle transition-colors"
|
| 437 |
:class="isHidden ? 'bg-red-500/20 text-red-400 border-red-500/50 hover:bg-red-500/30' : 'btn-ghost text-gray-400 hover:text-white'"
|
| 438 |
-
@click="
|
| 439 |
-
|
| 440 |
-
const newVal = !currentHidden;
|
| 441 |
-
// Optimistic update
|
| 442 |
-
$store.data.modelConfig[modelId] = { ...config, hidden: newVal };
|
| 443 |
-
fetch('/api/models/config', {
|
| 444 |
-
method: 'POST',
|
| 445 |
-
headers: {'Content-Type': 'application/json'},
|
| 446 |
-
body: JSON.stringify({ modelId, config: { hidden: newVal } })
|
| 447 |
-
});
|
| 448 |
-
$store.data.computeQuotaRows();
|
| 449 |
-
"
|
| 450 |
-
title="Toggle Visibility">
|
| 451 |
<svg x-show="!isHidden" xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 452 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
| 453 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
|
|
@@ -462,7 +486,7 @@
|
|
| 462 |
</template>
|
| 463 |
<!-- Empty State -->
|
| 464 |
<tr x-show="!$store.data.models.length">
|
| 465 |
-
<td colspan="3" class="text-center py-8 text-gray-600 text-xs font-mono">
|
| 466 |
NO MODELS DETECTED
|
| 467 |
</td>
|
| 468 |
</tr>
|
|
@@ -471,46 +495,336 @@
|
|
| 471 |
</div>
|
| 472 |
</div>
|
| 473 |
|
| 474 |
-
<!-- Tab 3: Server Info -->
|
| 475 |
-
<div x-show="activeTab === 'server'"
|
| 476 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 477 |
<div>
|
| 478 |
-
<div class="text-xs text-gray-500 mb-1">Port</div>
|
| 479 |
<div class="text-sm font-mono text-neon-cyan" x-text="$store.settings.port || '-'"></div>
|
| 480 |
</div>
|
| 481 |
<div>
|
| 482 |
-
<div class="text-xs text-gray-500 mb-1">UI Version</div>
|
| 483 |
<div class="text-sm font-mono text-neon-cyan" x-text="$store.global.version"></div>
|
| 484 |
</div>
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 488 |
</div>
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
</div>
|
| 493 |
</div>
|
| 494 |
|
| 495 |
<div class="alert bg-blue-500/10 border-blue-500/20 text-xs">
|
| 496 |
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-blue-400 shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
| 497 |
<div class="text-blue-200">
|
| 498 |
-
|
| 499 |
</div>
|
| 500 |
</div>
|
| 501 |
|
| 502 |
-
<!--
|
| 503 |
<div class="pt-6 border-t border-space-border/30">
|
| 504 |
-
<h4 class="text-sm font-bold text-white mb-4">Danger Zone / Advanced</h4>
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 509 |
</div>
|
| 510 |
-
<button class="btn btn-sm btn-outline border-space-border hover:bg-white hover:text-black hover:border-white text-gray-400"
|
| 511 |
-
@click="Alpine.store('global').showToast('Reloading...', 'info'); fetch('/api/accounts/reload', {method: 'POST'}).then(() => Alpine.store('global').showToast('Reloaded', 'success'))">
|
| 512 |
-
Reload
|
| 513 |
-
</button>
|
| 514 |
</div>
|
| 515 |
</div>
|
| 516 |
</div>
|
|
|
|
| 1 |
+
<div x-data="{
|
| 2 |
+
activeTab: 'ui',
|
| 3 |
+
// Helper function to update model config with authentication
|
| 4 |
+
async updateModelConfig(modelId, configUpdates) {
|
| 5 |
+
const store = Alpine.store('global');
|
| 6 |
+
try {
|
| 7 |
+
const { response, newPassword } = await window.utils.request('/api/models/config', {
|
| 8 |
+
method: 'POST',
|
| 9 |
+
headers: {'Content-Type': 'application/json'},
|
| 10 |
+
body: JSON.stringify({ modelId, config: configUpdates })
|
| 11 |
+
}, store.webuiPassword);
|
| 12 |
+
|
| 13 |
+
if (newPassword) store.webuiPassword = newPassword;
|
| 14 |
+
|
| 15 |
+
if (!response.ok) {
|
| 16 |
+
throw new Error('Failed to update model config');
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
// Optimistic update
|
| 20 |
+
Alpine.store('data').modelConfig[modelId] = {
|
| 21 |
+
...Alpine.store('data').modelConfig[modelId],
|
| 22 |
+
...configUpdates
|
| 23 |
+
};
|
| 24 |
+
Alpine.store('data').computeQuotaRows();
|
| 25 |
+
} catch (e) {
|
| 26 |
+
store.showToast('Failed to update model config: ' + e.message, 'error');
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
}" class="view-container">
|
| 30 |
<!-- Header & Tabs -->
|
| 31 |
+
<div class="glass-panel rounded-xl border border-space-border flex flex-col overflow-hidden">
|
| 32 |
+
<div class="bg-space-900/50 border-b border-space-border px-8 pt-8 pb-0 shrink-0">
|
| 33 |
+
<div class="flex items-center justify-between mb-6">
|
| 34 |
<h3 class="text-xl font-bold text-white flex items-center gap-2">
|
| 35 |
<svg class="w-5 h-5 text-neon-purple" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 36 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
|
|
| 42 |
</h3>
|
| 43 |
</div>
|
| 44 |
|
| 45 |
+
<div class="flex gap-6 overflow-x-auto">
|
| 46 |
<button @click="activeTab = 'ui'"
|
| 47 |
+
class="pb-3 border-b-2 transition-colors font-medium text-sm flex items-center gap-2 whitespace-nowrap"
|
| 48 |
:class="activeTab === 'ui' ? 'border-neon-purple text-white' : 'border-transparent text-gray-500 hover:text-gray-300'">
|
| 49 |
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21a4 4 0 01-4-4V5a2 2 0 012-2h4a2 2 0 012 2v12a4 4 0 01-4 4zm0 0h12a2 2 0 002-2v-4a2 2 0 00-2-2h-2.343M11 7.343l1.657-1.657a2 2 0 012.828 0l2.829 2.829a2 2 0 010 2.828l-8.486 8.485M7 17h.01" /></svg>
|
| 50 |
<span x-text="$store.global.t('tabInterface')">Interface</span>
|
| 51 |
</button>
|
| 52 |
<button @click="activeTab = 'claude'"
|
| 53 |
+
class="pb-3 border-b-2 transition-colors font-medium text-sm flex items-center gap-2 whitespace-nowrap"
|
| 54 |
:class="activeTab === 'claude' ? 'border-neon-purple text-white' : 'border-transparent text-gray-500 hover:text-gray-300'">
|
| 55 |
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>
|
| 56 |
<span x-text="$store.global.t('tabClaude')">Claude CLI</span>
|
| 57 |
</button>
|
| 58 |
<button @click="activeTab = 'models'"
|
| 59 |
+
class="pb-3 border-b-2 transition-colors font-medium text-sm flex items-center gap-2 whitespace-nowrap"
|
| 60 |
:class="activeTab === 'models' ? 'border-neon-purple text-white' : 'border-transparent text-gray-500 hover:text-gray-300'">
|
| 61 |
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" /></svg>
|
| 62 |
<span x-text="$store.global.t('tabModels')">Models</span>
|
| 63 |
</button>
|
| 64 |
<button @click="activeTab = 'server'"
|
| 65 |
+
class="pb-3 border-b-2 transition-colors font-medium text-sm flex items-center gap-2 whitespace-nowrap"
|
| 66 |
:class="activeTab === 'server' ? 'border-neon-purple text-white' : 'border-transparent text-gray-500 hover:text-gray-300'">
|
| 67 |
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01" /></svg>
|
| 68 |
+
<span x-text="$store.global.t('tabServer')">Server</span>
|
| 69 |
</button>
|
| 70 |
</div>
|
| 71 |
</div>
|
|
|
|
| 103 |
</label>
|
| 104 |
<input type="range" min="10" max="300" class="range range-xs range-primary"
|
| 105 |
x-model="$store.settings.refreshInterval"
|
| 106 |
+
@change="$store.settings.saveSettings(true)">
|
|
|
|
| 107 |
<div class="w-full flex justify-between text-xs px-2 mt-2 text-gray-600 font-mono">
|
| 108 |
<span>10s</span>
|
| 109 |
<span>300s</span>
|
|
|
|
| 115 |
<label class="label">
|
| 116 |
<span class="label-text text-gray-300" x-text="$store.global.t('logBufferSize')">Log Buffer Size</span>
|
| 117 |
<span class="label-text-alt font-mono text-neon-purple"
|
| 118 |
+
x-text="$store.settings.logLimit + ' ' + $store.global.t('lines')"></span>
|
| 119 |
</label>
|
| 120 |
<input type="range" min="500" max="5000" step="500" class="range range-xs range-secondary"
|
| 121 |
x-model="$store.settings.logLimit"
|
| 122 |
+
@change="$store.settings.saveSettings(true)">
|
|
|
|
| 123 |
<div class="w-full flex justify-between text-xs px-2 mt-2 text-gray-600 font-mono">
|
| 124 |
<span>500</span>
|
| 125 |
<span>5000</span>
|
|
|
|
| 168 |
<div x-show="activeTab === 'claude'" x-data="claudeConfig" class="space-y-6 max-w-3xl animate-fade-in">
|
| 169 |
<div class="alert bg-space-900/50 border-space-border text-sm shadow-none">
|
| 170 |
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-info shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
| 171 |
+
<span class="text-gray-400" x-text="$store.global.t('claudeSettingsAlert')">Settings below directly modify <code class="text-neon-cyan font-mono">~/.claude/settings.json</code>. Restart Claude CLI to apply.</span>
|
| 172 |
</div>
|
| 173 |
|
| 174 |
<!-- Base URL -->
|
| 175 |
<div class="card bg-space-900/30 border border-space-border/50 p-5">
|
| 176 |
+
<label class="label text-xs uppercase text-gray-500 font-semibold mb-2" x-text="$store.global.t('proxyConnection')">Proxy Connection</label>
|
| 177 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 178 |
<div>
|
| 179 |
<div class="text-[11px] text-gray-400 mb-1 font-mono">ANTHROPIC_BASE_URL</div>
|
|
|
|
| 190 |
|
| 191 |
<!-- Models Selection -->
|
| 192 |
<div class="card bg-space-900/30 border border-space-border/50 p-5">
|
| 193 |
+
<label class="label text-xs uppercase text-gray-500 font-semibold mb-2" x-text="$store.global.t('modelSelection')">Model Selection</label>
|
| 194 |
|
| 195 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
|
| 196 |
<!-- Primary -->
|
| 197 |
<div class="form-control">
|
| 198 |
+
<label class="label pt-0 pb-1 text-[11px] text-gray-400 font-bold tracking-wider" x-text="$store.global.t('primaryModel')">Primary Model</label>
|
| 199 |
<div class="relative w-full" x-data="{ open: false }">
|
| 200 |
<input type="text" x-model="config.env.ANTHROPIC_MODEL"
|
| 201 |
@focus="open = true"
|
| 202 |
@click.away="open = false"
|
| 203 |
class="input input-sm w-full font-mono text-xs bg-space-800/50 border-space-border text-white focus:bg-space-800 focus:border-neon-cyan pr-8 placeholder-gray-600"
|
| 204 |
+
:placeholder="$store.global.t('typeToSearch')">
|
| 205 |
<div class="absolute right-2 top-1.5 cursor-pointer text-gray-500 hover:text-white transition-colors" @click="open = !open; if(open) $el.previousElementSibling.focus()" @mousedown.prevent>▼</div>
|
| 206 |
|
| 207 |
<ul x-show="open"
|
|
|
|
| 212 |
<template x-for="modelId in $store.data.models.filter(m => m.toLowerCase().includes(config.env.ANTHROPIC_MODEL?.toLowerCase() || ''))" :key="modelId">
|
| 213 |
<li>
|
| 214 |
<a @mousedown.prevent="config.env.ANTHROPIC_MODEL = modelId; open = false"
|
| 215 |
+
class="font-mono text-xs py-2 hover:bg-space-800 border-b border-space-border/30 last:border-0 flex items-center gap-2"
|
| 216 |
:class="config.env.ANTHROPIC_MODEL === modelId ? 'text-neon-cyan bg-space-800/50' : 'text-gray-300'">
|
| 217 |
+
<span class="w-1.5 h-1.5 rounded-full" :class="$store.data.getModelFamily(modelId) === 'claude' ? 'bg-neon-purple shadow-[0_0_5px_rgba(168,85,247,0.5)]' : ($store.data.getModelFamily(modelId) === 'gemini' ? 'bg-neon-green shadow-[0_0_5px_rgba(34,197,94,0.5)]' : 'bg-gray-600')"></span>
|
| 218 |
<span x-text="modelId"></span>
|
| 219 |
</a>
|
| 220 |
</li>
|
| 221 |
</template>
|
| 222 |
<li x-show="$store.data.models.filter(m => m.toLowerCase().includes(config.env.ANTHROPIC_MODEL?.toLowerCase() || '')).length === 0">
|
| 223 |
+
<span class="text-xs text-gray-500 italic py-2" x-text="$store.global.t('noMatchingModels')">No matching models</span>
|
| 224 |
</li>
|
| 225 |
</ul>
|
| 226 |
</div>
|
|
|
|
| 229 |
|
| 230 |
<!-- Sub-agent -->
|
| 231 |
<div class="form-control">
|
| 232 |
+
<label class="label pt-0 pb-1 text-[11px] text-gray-400 font-bold tracking-wider" x-text="$store.global.t('subAgentModel')">Sub-agent Model</label>
|
| 233 |
<div class="relative w-full" x-data="{ open: false }">
|
| 234 |
<input type="text" x-model="config.env.CLAUDE_CODE_SUBAGENT_MODEL"
|
| 235 |
@focus="open = true"
|
| 236 |
@click.away="open = false"
|
| 237 |
class="input input-sm w-full font-mono text-xs bg-space-800/50 border-space-border text-white focus:bg-space-800 focus:border-neon-purple pr-8 placeholder-gray-600"
|
| 238 |
+
:placeholder="$store.global.t('typeToSearch')">
|
| 239 |
<div class="absolute right-2 top-1.5 cursor-pointer text-gray-500 hover:text-white transition-colors" @click="open = !open; if(open) $el.previousElementSibling.focus()" @mousedown.prevent>▼</div>
|
| 240 |
|
| 241 |
<ul x-show="open"
|
|
|
|
| 246 |
<template x-for="modelId in $store.data.models.filter(m => m.toLowerCase().includes(config.env.CLAUDE_CODE_SUBAGENT_MODEL?.toLowerCase() || ''))" :key="modelId">
|
| 247 |
<li>
|
| 248 |
<a @mousedown.prevent="config.env.CLAUDE_CODE_SUBAGENT_MODEL = modelId; open = false"
|
| 249 |
+
class="font-mono text-xs py-2 hover:bg-space-800 border-b border-space-border/30 last:border-0 flex items-center gap-2"
|
| 250 |
:class="config.env.CLAUDE_CODE_SUBAGENT_MODEL === modelId ? 'text-neon-purple bg-space-800/50' : 'text-gray-300'">
|
| 251 |
+
<span class="w-1.5 h-1.5 rounded-full" :class="$store.data.getModelFamily(modelId) === 'claude' ? 'bg-neon-purple shadow-[0_0_5px_rgba(168,85,247,0.5)]' : ($store.data.getModelFamily(modelId) === 'gemini' ? 'bg-neon-green shadow-[0_0_5px_rgba(34,197,94,0.5)]' : 'bg-gray-600')"></span>
|
| 252 |
<span x-text="modelId"></span>
|
| 253 |
</a>
|
| 254 |
</li>
|
| 255 |
</template>
|
| 256 |
<li x-show="$store.data.models.filter(m => m.toLowerCase().includes(config.env.CLAUDE_CODE_SUBAGENT_MODEL?.toLowerCase() || '')).length === 0">
|
| 257 |
+
<span class="text-xs text-gray-500 italic py-2" x-text="$store.global.t('noMatchingModels')">No matching models</span>
|
| 258 |
</li>
|
| 259 |
</ul>
|
| 260 |
</div>
|
|
|
|
| 262 |
</div>
|
| 263 |
</div>
|
| 264 |
|
| 265 |
+
<div class="divider text-xs font-mono text-gray-600 my-2" x-text="$store.global.t('aliasOverrides')">ALIAS OVERRIDES</div>
|
| 266 |
|
| 267 |
<!-- Overrides -->
|
| 268 |
<div class="space-y-4">
|
| 269 |
<!-- Opus -->
|
| 270 |
<div class="form-control">
|
| 271 |
+
<label class="label pt-0 pb-1 text-[10px] text-gray-500 uppercase font-bold" x-text="$store.global.t('opusAlias')">Opus Alias</label>
|
| 272 |
<div class="relative w-full" x-data="{ open: false }">
|
| 273 |
<input type="text" x-model="config.env.ANTHROPIC_DEFAULT_OPUS_MODEL"
|
| 274 |
@focus="open = true"
|
| 275 |
@click.away="open = false"
|
| 276 |
class="input input-sm w-full font-mono text-xs bg-space-800/50 border-space-border text-gray-300 focus:bg-space-800 focus:border-neon-cyan pr-8 placeholder-gray-600"
|
| 277 |
+
:placeholder="$store.global.t('searchPlaceholder')">
|
| 278 |
<div class="absolute right-2 top-1.5 cursor-pointer text-gray-500 hover:text-white transition-colors" @click="open = !open; if(open) $el.previousElementSibling.focus()" @mousedown.prevent>▼</div>
|
| 279 |
<ul x-show="open"
|
| 280 |
x-transition:enter="transition ease-out duration-100"
|
|
|
|
| 284 |
<template x-for="modelId in $store.data.models.filter(m => m.toLowerCase().includes(config.env.ANTHROPIC_DEFAULT_OPUS_MODEL?.toLowerCase() || ''))" :key="modelId">
|
| 285 |
<li>
|
| 286 |
<a @mousedown.prevent="config.env.ANTHROPIC_DEFAULT_OPUS_MODEL = modelId; open = false"
|
| 287 |
+
class="font-mono text-xs py-1 hover:bg-space-800 border-b border-space-border/30 last:border-0 flex items-center gap-2"
|
| 288 |
:class="config.env.ANTHROPIC_DEFAULT_OPUS_MODEL === modelId ? 'text-neon-cyan bg-space-800/50' : 'text-gray-300'">
|
| 289 |
+
<span class="w-1.5 h-1.5 rounded-full" :class="$store.data.getModelFamily(modelId) === 'claude' ? 'bg-neon-purple shadow-[0_0_5px_rgba(168,85,247,0.5)]' : ($store.data.getModelFamily(modelId) === 'gemini' ? 'bg-neon-green shadow-[0_0_5px_rgba(34,197,94,0.5)]' : 'bg-gray-600')"></span>
|
| 290 |
<span x-text="modelId"></span>
|
| 291 |
</a>
|
| 292 |
</li>
|
|
|
|
| 296 |
</div>
|
| 297 |
<!-- Sonnet -->
|
| 298 |
<div class="form-control">
|
| 299 |
+
<label class="label pt-0 pb-1 text-[10px] text-gray-500 uppercase font-bold" x-text="$store.global.t('sonnetAlias')">Sonnet Alias</label>
|
| 300 |
<div class="relative w-full" x-data="{ open: false }">
|
| 301 |
<input type="text" x-model="config.env.ANTHROPIC_DEFAULT_SONNET_MODEL"
|
| 302 |
@focus="open = true"
|
| 303 |
@click.away="open = false"
|
| 304 |
class="input input-sm w-full font-mono text-xs bg-space-800/50 border-space-border text-gray-300 focus:bg-space-800 focus:border-neon-cyan pr-8 placeholder-gray-600"
|
| 305 |
+
:placeholder="$store.global.t('searchPlaceholder')">
|
| 306 |
<div class="absolute right-2 top-1.5 cursor-pointer text-gray-500 hover:text-white transition-colors" @click="open = !open; if(open) $el.previousElementSibling.focus()" @mousedown.prevent>▼</div>
|
| 307 |
<ul x-show="open"
|
| 308 |
x-transition:enter="transition ease-out duration-100"
|
|
|
|
| 312 |
<template x-for="modelId in $store.data.models.filter(m => m.toLowerCase().includes(config.env.ANTHROPIC_DEFAULT_SONNET_MODEL?.toLowerCase() || ''))" :key="modelId">
|
| 313 |
<li>
|
| 314 |
<a @mousedown.prevent="config.env.ANTHROPIC_DEFAULT_SONNET_MODEL = modelId; open = false"
|
| 315 |
+
class="font-mono text-xs py-1 hover:bg-space-800 border-b border-space-border/30 last:border-0 flex items-center gap-2"
|
| 316 |
:class="config.env.ANTHROPIC_DEFAULT_SONNET_MODEL === modelId ? 'text-neon-cyan bg-space-800/50' : 'text-gray-300'">
|
| 317 |
+
<span class="w-1.5 h-1.5 rounded-full" :class="$store.data.getModelFamily(modelId) === 'claude' ? 'bg-neon-purple shadow-[0_0_5px_rgba(168,85,247,0.5)]' : ($store.data.getModelFamily(modelId) === 'gemini' ? 'bg-neon-green shadow-[0_0_5px_rgba(34,197,94,0.5)]' : 'bg-gray-600')"></span>
|
| 318 |
<span x-text="modelId"></span>
|
| 319 |
</a>
|
| 320 |
</li>
|
|
|
|
| 324 |
</div>
|
| 325 |
<!-- Haiku -->
|
| 326 |
<div class="form-control">
|
| 327 |
+
<label class="label pt-0 pb-1 text-[10px] text-gray-500 uppercase font-bold" x-text="$store.global.t('haikuAlias')">Haiku Alias</label>
|
| 328 |
<div class="relative w-full" x-data="{ open: false }">
|
| 329 |
<input type="text" x-model="config.env.ANTHROPIC_DEFAULT_HAIKU_MODEL"
|
| 330 |
@focus="open = true"
|
| 331 |
@click.away="open = false"
|
| 332 |
class="input input-sm w-full font-mono text-xs bg-space-800/50 border-space-border text-gray-300 focus:bg-space-800 focus:border-neon-cyan pr-8 placeholder-gray-600"
|
| 333 |
+
:placeholder="$store.global.t('searchPlaceholder')">
|
| 334 |
<div class="absolute right-2 top-1.5 cursor-pointer text-gray-500 hover:text-white transition-colors" @click="open = !open; if(open) $el.previousElementSibling.focus()" @mousedown.prevent>▼</div>
|
| 335 |
<ul x-show="open"
|
| 336 |
x-transition:enter="transition ease-out duration-100"
|
|
|
|
| 340 |
<template x-for="modelId in $store.data.models.filter(m => m.toLowerCase().includes(config.env.ANTHROPIC_DEFAULT_HAIKU_MODEL?.toLowerCase() || ''))" :key="modelId">
|
| 341 |
<li>
|
| 342 |
<a @mousedown.prevent="config.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = modelId; open = false"
|
| 343 |
+
class="font-mono text-xs py-1 hover:bg-space-800 border-b border-space-border/30 last:border-0 flex items-center gap-2"
|
| 344 |
:class="config.env.ANTHROPIC_DEFAULT_HAIKU_MODEL === modelId ? 'text-neon-cyan bg-space-800/50' : 'text-gray-300'">
|
| 345 |
+
<span class="w-1.5 h-1.5 rounded-full" :class="$store.data.getModelFamily(modelId) === 'claude' ? 'bg-neon-purple shadow-[0_0_5px_rgba(168,85,247,0.5)]' : ($store.data.getModelFamily(modelId) === 'gemini' ? 'bg-neon-green shadow-[0_0_5px_rgba(34,197,94,0.5)]' : 'bg-gray-600')"></span>
|
| 346 |
<span x-text="modelId"></span>
|
| 347 |
</a>
|
| 348 |
</li>
|
|
|
|
| 357 |
<button class="btn btn-sm bg-neon-purple hover:bg-purple-600 border-none text-white px-6 gap-2"
|
| 358 |
@click="saveClaudeConfig" :disabled="loading">
|
| 359 |
<svg x-show="!loading" class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4" /></svg>
|
| 360 |
+
<span x-show="!loading" x-text="$store.global.t('writeToConfig')">Write to Config</span>
|
| 361 |
<span x-show="loading" class="loading loading-spinner loading-xs"></span>
|
| 362 |
</button>
|
| 363 |
</div>
|
|
|
|
| 366 |
<!-- Tab 2.5: Models Configuration -->
|
| 367 |
<div x-show="activeTab === 'models'" class="space-y-6 max-w-3xl animate-fade-in">
|
| 368 |
<div class="flex items-center justify-between">
|
| 369 |
+
<div class="text-sm text-gray-400" x-text="$store.global.t('modelsDesc')">Manage visibility and ordering of models in the dashboard.</div>
|
| 370 |
<div class="form-control">
|
| 371 |
<label class="label cursor-pointer gap-2">
|
| 372 |
+
<span class="label-text text-xs text-gray-500" x-text="$store.global.t('showHidden')">Show Hidden Models</span>
|
| 373 |
<input type="checkbox" class="toggle toggle-xs toggle-primary" x-model="$store.settings.showHiddenModels" @change="$store.settings.saveSettings(true)">
|
| 374 |
</label>
|
| 375 |
</div>
|
| 376 |
</div>
|
| 377 |
|
| 378 |
<!-- Models List -->
|
| 379 |
+
<div class="glass-panel rounded-lg overflow-hidden">
|
| 380 |
+
<table class="standard-table">
|
| 381 |
+
<thead>
|
| 382 |
<tr>
|
| 383 |
+
<th class="pl-4" x-text="$store.global.t('modelId')">Model ID</th>
|
| 384 |
+
<th x-text="$store.global.t('alias')">Alias</th>
|
| 385 |
+
<th>Mapping (Target Model ID)</th>
|
| 386 |
+
<th class="text-right pr-4" x-text="$store.global.t('actions')">Actions</th>
|
| 387 |
</tr>
|
| 388 |
</thead>
|
| 389 |
+
<tbody>
|
| 390 |
<template x-for="modelId in $store.data.models" :key="modelId">
|
| 391 |
<tr class="hover:bg-white/5 transition-colors group"
|
| 392 |
x-data="{
|
| 393 |
+
isEditingAlias: false,
|
| 394 |
+
isEditingMapping: false,
|
| 395 |
newAlias: '',
|
| 396 |
+
newMapping: '',
|
| 397 |
// Use getters for reactivity - accessing store directly ensures updates are reflected immediately
|
| 398 |
get config() { return $store.data.modelConfig[modelId] || {} },
|
| 399 |
get isPinned() { return !!this.config.pinned },
|
|
|
|
| 404 |
return (family === 'other' || family === 'unknown');
|
| 405 |
}
|
| 406 |
}"
|
| 407 |
+
x-init="newAlias = config.alias || ''; newMapping = config.mapping || ''"
|
| 408 |
>
|
| 409 |
<td class="pl-4 font-mono text-xs text-gray-300" x-text="modelId"></td>
|
| 410 |
<td>
|
| 411 |
+
<div x-show="!isEditingAlias" class="flex items-center gap-2 group-hover:text-white transition-colors cursor-pointer" @click="isEditingAlias = true; newAlias = config.alias || ''">
|
| 412 |
<span x-text="config.alias || '-'" :class="{'text-gray-600 italic': !config.alias}"></span>
|
| 413 |
<svg class="w-3 h-3 text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" /></svg>
|
| 414 |
</div>
|
| 415 |
+
<div x-show="isEditingAlias" class="flex items-center gap-1">
|
| 416 |
<input type="text" x-model="newAlias"
|
| 417 |
+
class="input input-xs bg-space-800 border-space-border text-white focus:outline-none focus:border-neon-purple w-24"
|
| 418 |
@keydown.enter="
|
| 419 |
+
await updateModelConfig(modelId, { alias: newAlias });
|
| 420 |
+
isEditingAlias = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 421 |
"
|
| 422 |
+
@keydown.escape="isEditingAlias = false"
|
| 423 |
>
|
| 424 |
<button class="btn btn-xs btn-ghost btn-square text-green-500" @click="
|
| 425 |
+
await updateModelConfig(modelId, { alias: newAlias });
|
| 426 |
+
isEditingAlias = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
"><svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" /></svg></button>
|
| 428 |
+
<button class="btn btn-xs btn-ghost btn-square text-gray-500" @click="isEditingAlias = false"><svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg></button>
|
| 429 |
+
</div>
|
| 430 |
+
</td>
|
| 431 |
+
<td>
|
| 432 |
+
<div x-show="!isEditingMapping" class="flex items-center gap-2 group-hover:text-white transition-colors cursor-pointer" @click="isEditingMapping = true; newMapping = config.mapping || ''">
|
| 433 |
+
<span x-text="config.mapping || '-'" :class="{'text-gray-600 italic': !config.mapping}"></span>
|
| 434 |
+
<svg class="w-3 h-3 text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" /></svg>
|
| 435 |
+
</div>
|
| 436 |
+
<div x-show="isEditingMapping" class="flex items-center gap-1">
|
| 437 |
+
<input type="text" x-model="newMapping"
|
| 438 |
+
class="input input-xs bg-space-800 border-space-border text-white focus:outline-none focus:border-neon-cyan w-32"
|
| 439 |
+
placeholder="e.g. claude-3-opus-20240229"
|
| 440 |
+
@keydown.enter="
|
| 441 |
+
await updateModelConfig(modelId, { mapping: newMapping });
|
| 442 |
+
isEditingMapping = false;
|
| 443 |
+
"
|
| 444 |
+
@keydown.escape="isEditingMapping = false"
|
| 445 |
+
>
|
| 446 |
+
<button class="btn btn-xs btn-ghost btn-square text-green-500" @click="
|
| 447 |
+
await updateModelConfig(modelId, { mapping: newMapping });
|
| 448 |
+
isEditingMapping = false;
|
| 449 |
+
"><svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" /></svg></button>
|
| 450 |
+
<button class="btn btn-xs btn-ghost btn-square text-gray-500" @click="isEditingMapping = false"><svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg></button>
|
| 451 |
</div>
|
| 452 |
</td>
|
| 453 |
<td class="text-right pr-4">
|
|
|
|
| 455 |
<!-- Pin Toggle -->
|
| 456 |
<button class="btn btn-xs btn-circle transition-colors"
|
| 457 |
:class="isPinned ? 'bg-neon-purple/20 text-neon-purple border-neon-purple/50 hover:bg-neon-purple/30' : 'btn-ghost text-gray-600 hover:text-gray-300'"
|
| 458 |
+
@click="await updateModelConfig(modelId, { pinned: !isPinned })"
|
| 459 |
+
:title="$store.global.t('pinToTop')">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 460 |
<!-- Solid Icon when Pinned -->
|
| 461 |
<svg x-show="isPinned" xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" viewBox="0 0 20 20" fill="currentColor">
|
| 462 |
<path d="M5 4a2 2 0 012-2h6a2 2 0 012 2v14l-5-2.5L5 18V4z" />
|
|
|
|
| 470 |
<!-- Hide Toggle -->
|
| 471 |
<button class="btn btn-xs btn-circle transition-colors"
|
| 472 |
:class="isHidden ? 'bg-red-500/20 text-red-400 border-red-500/50 hover:bg-red-500/30' : 'btn-ghost text-gray-400 hover:text-white'"
|
| 473 |
+
@click="await updateModelConfig(modelId, { hidden: !isHidden })"
|
| 474 |
+
:title="$store.global.t('toggleVisibility')">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 475 |
<svg x-show="!isHidden" xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 476 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
| 477 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
|
|
|
|
| 486 |
</template>
|
| 487 |
<!-- Empty State -->
|
| 488 |
<tr x-show="!$store.data.models.length">
|
| 489 |
+
<td colspan="3" class="text-center py-8 text-gray-600 text-xs font-mono" x-text="$store.global.t('noModels')">
|
| 490 |
NO MODELS DETECTED
|
| 491 |
</td>
|
| 492 |
</tr>
|
|
|
|
| 495 |
</div>
|
| 496 |
</div>
|
| 497 |
|
| 498 |
+
<!-- Tab 3: Server Info & Configuration -->
|
| 499 |
+
<div x-show="activeTab === 'server'" x-data="{
|
| 500 |
+
serverConfig: {},
|
| 501 |
+
loading: false,
|
| 502 |
+
async fetchServerConfig() {
|
| 503 |
+
const password = Alpine.store('global').webuiPassword;
|
| 504 |
+
try {
|
| 505 |
+
const { response, newPassword } = await window.utils.request('/api/config', {}, password);
|
| 506 |
+
if (newPassword) Alpine.store('global').webuiPassword = newPassword;
|
| 507 |
+
if (!response.ok) throw new Error('Failed to fetch config');
|
| 508 |
+
const data = await response.json();
|
| 509 |
+
this.serverConfig = data.config || {};
|
| 510 |
+
} catch (e) {
|
| 511 |
+
console.error('Failed to fetch server config:', e);
|
| 512 |
+
}
|
| 513 |
+
},
|
| 514 |
+
async saveServerConfig() {
|
| 515 |
+
this.loading = true;
|
| 516 |
+
const store = Alpine.store('global');
|
| 517 |
+
// Ensure all numeric fields are properly typed
|
| 518 |
+
const payload = {
|
| 519 |
+
debug: !!this.serverConfig.debug,
|
| 520 |
+
maxRetries: parseInt(this.serverConfig.maxRetries || 5),
|
| 521 |
+
retryBaseMs: parseInt(this.serverConfig.retryBaseMs || 1000),
|
| 522 |
+
retryMaxMs: parseInt(this.serverConfig.retryMaxMs || 30000),
|
| 523 |
+
persistTokenCache: !!this.serverConfig.persistTokenCache,
|
| 524 |
+
defaultCooldownMs: parseInt(this.serverConfig.defaultCooldownMs || 60000),
|
| 525 |
+
maxWaitBeforeErrorMs: parseInt(this.serverConfig.maxWaitBeforeErrorMs || 120000)
|
| 526 |
+
};
|
| 527 |
+
|
| 528 |
+
try {
|
| 529 |
+
const { response, newPassword } = await window.utils.request('/api/config', {
|
| 530 |
+
method: 'POST',
|
| 531 |
+
headers: { 'Content-Type': 'application/json' },
|
| 532 |
+
body: JSON.stringify(payload)
|
| 533 |
+
}, store.webuiPassword);
|
| 534 |
+
if (newPassword) store.webuiPassword = newPassword;
|
| 535 |
+
|
| 536 |
+
if (!response.ok) throw new Error('Failed to save config');
|
| 537 |
+
store.showToast(store.t('configSaved'), 'success');
|
| 538 |
+
await this.fetchServerConfig();
|
| 539 |
+
} catch (e) {
|
| 540 |
+
store.showToast('Failed to save config: ' + e.message, 'error');
|
| 541 |
+
} finally {
|
| 542 |
+
this.loading = false;
|
| 543 |
+
}
|
| 544 |
+
}
|
| 545 |
+
}" x-init="$watch('activeTab', value => { if(value === 'server') fetchServerConfig() }); fetchServerConfig()" class="space-y-6 max-w-2xl animate-fade-in">
|
| 546 |
+
|
| 547 |
+
<!-- Read-Only Info & System Status -->
|
| 548 |
+
<div class="flex items-center justify-between mb-2">
|
| 549 |
+
<div class="text-xs uppercase text-gray-500 font-bold tracking-wider">System Information</div>
|
| 550 |
+
<button @click="fetchServerConfig()" class="btn btn-xs btn-ghost text-neon-cyan gap-1">
|
| 551 |
+
<svg xmlns="http://www.w3.org/2000/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="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" /></svg>
|
| 552 |
+
Refresh
|
| 553 |
+
</button>
|
| 554 |
+
</div>
|
| 555 |
+
<div class="grid grid-cols-2 gap-4 bg-space-900/30 p-6 rounded-lg border border-space-border/50">
|
| 556 |
<div>
|
| 557 |
+
<div class="text-xs text-gray-500 mb-1" x-text="$store.global.t('port')">Port</div>
|
| 558 |
<div class="text-sm font-mono text-neon-cyan" x-text="$store.settings.port || '-'"></div>
|
| 559 |
</div>
|
| 560 |
<div>
|
| 561 |
+
<div class="text-xs text-gray-500 mb-1" x-text="$store.global.t('uiVersion')">UI Version</div>
|
| 562 |
<div class="text-sm font-mono text-neon-cyan" x-text="$store.global.version"></div>
|
| 563 |
</div>
|
| 564 |
+
</div>
|
| 565 |
+
|
| 566 |
+
<div class="divider border-space-border/50 text-xs uppercase text-gray-500 font-semibold">Runtime Configuration</div>
|
| 567 |
+
|
| 568 |
+
<!-- Editable Configuration -->
|
| 569 |
+
<div class="space-y-6">
|
| 570 |
+
<!-- Debug Mode -->
|
| 571 |
+
<div class="form-control bg-space-900/50 p-4 rounded-lg border transition-all duration-300 hover:border-space-border cursor-pointer group"
|
| 572 |
+
:class="serverConfig.debug ? 'border-neon-purple/50 bg-neon-purple/5 shadow-[0_0_15px_rgba(168,85,247,0.1)]' : 'border-space-border/50'"
|
| 573 |
+
@click="serverConfig.debug = !serverConfig.debug">
|
| 574 |
+
<label class="label cursor-pointer pointer-events-none">
|
| 575 |
+
<div class="flex flex-col gap-1">
|
| 576 |
+
<span class="label-text font-medium transition-colors"
|
| 577 |
+
:class="serverConfig.debug ? 'text-neon-purple' : 'text-gray-300'">Debug Mode</span>
|
| 578 |
+
<span class="text-xs text-gray-500">Enable detailed logging (See Logs tab)</span>
|
| 579 |
+
</div>
|
| 580 |
+
<input type="checkbox" class="toggle toggle-primary" x-model="serverConfig.debug">
|
| 581 |
+
</label>
|
| 582 |
</div>
|
| 583 |
+
|
| 584 |
+
<!-- Retry Configuration -->
|
| 585 |
+
<div class="card bg-space-900/30 border border-space-border/50 p-5">
|
| 586 |
+
<label class="label text-xs uppercase text-gray-500 font-semibold mb-3">Network Retry Settings</label>
|
| 587 |
+
|
| 588 |
+
<div class="space-y-4">
|
| 589 |
+
<!-- Max Retries -->
|
| 590 |
+
<div class="form-control">
|
| 591 |
+
<label class="label">
|
| 592 |
+
<span class="label-text text-gray-300">Max Retries</span>
|
| 593 |
+
<span class="label-text-alt font-mono text-neon-purple" x-text="serverConfig.maxRetries || 5"></span>
|
| 594 |
+
</label>
|
| 595 |
+
<input type="range" min="1" max="20" class="range range-xs range-primary"
|
| 596 |
+
x-model="serverConfig.maxRetries">
|
| 597 |
+
<div class="w-full flex justify-between text-xs px-2 mt-2 text-gray-600 font-mono">
|
| 598 |
+
<span>1</span>
|
| 599 |
+
<span>20</span>
|
| 600 |
+
</div>
|
| 601 |
+
</div>
|
| 602 |
+
|
| 603 |
+
<!-- Retry Base Ms -->
|
| 604 |
+
<div class="form-control">
|
| 605 |
+
<label class="label">
|
| 606 |
+
<span class="label-text text-gray-300">Retry Base Delay (ms)</span>
|
| 607 |
+
<span class="label-text-alt font-mono text-neon-cyan" x-text="(serverConfig.retryBaseMs || 1000) + 'ms'"></span>
|
| 608 |
+
</label>
|
| 609 |
+
<input type="range" min="100" max="10000" step="100" class="range range-xs range-secondary"
|
| 610 |
+
x-model="serverConfig.retryBaseMs">
|
| 611 |
+
<div class="w-full flex justify-between text-xs px-2 mt-2 text-gray-600 font-mono">
|
| 612 |
+
<span>100ms</span>
|
| 613 |
+
<span>10s</span>
|
| 614 |
+
</div>
|
| 615 |
+
</div>
|
| 616 |
+
|
| 617 |
+
<!-- Retry Max Ms -->
|
| 618 |
+
<div class="form-control">
|
| 619 |
+
<label class="label">
|
| 620 |
+
<span class="label-text text-gray-300">Retry Max Delay (ms)</span>
|
| 621 |
+
<span class="label-text-alt font-mono text-neon-green" x-text="(serverConfig.retryMaxMs || 30000) + 'ms'"></span>
|
| 622 |
+
</label>
|
| 623 |
+
<input type="range" min="1000" max="120000" step="1000" class="range range-xs range-accent"
|
| 624 |
+
x-model="serverConfig.retryMaxMs">
|
| 625 |
+
<div class="w-full flex justify-between text-xs px-2 mt-2 text-gray-600 font-mono">
|
| 626 |
+
<span>1s</span>
|
| 627 |
+
<span>120s</span>
|
| 628 |
+
</div>
|
| 629 |
+
</div>
|
| 630 |
+
</div>
|
| 631 |
+
</div>
|
| 632 |
+
|
| 633 |
+
<!-- Token Cache Persistence -->
|
| 634 |
+
<div class="form-control bg-space-900/50 p-4 rounded-lg border transition-all duration-300 hover:border-space-border cursor-pointer group"
|
| 635 |
+
:class="serverConfig.persistTokenCache ? 'border-neon-green/50 bg-neon-green/5 shadow-[0_0_15px_rgba(34,197,94,0.1)]' : 'border-space-border/50'"
|
| 636 |
+
@click="serverConfig.persistTokenCache = !serverConfig.persistTokenCache">
|
| 637 |
+
<label class="label cursor-pointer pointer-events-none">
|
| 638 |
+
<div class="flex flex-col gap-1">
|
| 639 |
+
<span class="label-text font-medium transition-colors"
|
| 640 |
+
:class="serverConfig.persistTokenCache ? 'text-neon-green' : 'text-gray-300'">Persist Token Cache</span>
|
| 641 |
+
<span class="text-xs text-gray-500">Save OAuth tokens to disk for faster restarts</span>
|
| 642 |
+
</div>
|
| 643 |
+
<input type="checkbox" class="toggle toggle-secondary" x-model="serverConfig.persistTokenCache">
|
| 644 |
+
</label>
|
| 645 |
+
</div>
|
| 646 |
+
|
| 647 |
+
<!-- Account Cooldown & Limits -->
|
| 648 |
+
<div class="card bg-space-900/30 border border-space-border/50 p-5">
|
| 649 |
+
<label class="label text-xs uppercase text-gray-500 font-semibold mb-3">Account Rate Limiting & Timeouts</label>
|
| 650 |
+
<div class="space-y-6">
|
| 651 |
+
<div class="form-control">
|
| 652 |
+
<label class="label">
|
| 653 |
+
<span class="label-text text-gray-300">Default Cooldown Time</span>
|
| 654 |
+
<span class="label-text-alt font-mono text-neon-cyan" x-text="Math.round((serverConfig.defaultCooldownMs || 60000) / 1000) + 's'"></span>
|
| 655 |
+
</label>
|
| 656 |
+
<input type="range" min="1000" max="300000" step="1000" class="range range-xs range-accent"
|
| 657 |
+
x-model="serverConfig.defaultCooldownMs">
|
| 658 |
+
<div class="w-full flex justify-between text-xs px-2 mt-2 text-gray-600 font-mono">
|
| 659 |
+
<span>1s</span>
|
| 660 |
+
<span>5min</span>
|
| 661 |
+
</div>
|
| 662 |
+
</div>
|
| 663 |
+
|
| 664 |
+
<div class="form-control">
|
| 665 |
+
<label class="label">
|
| 666 |
+
<span class="label-text text-gray-300">Max Wait Threshold (Sticky)</span>
|
| 667 |
+
<span class="label-text-alt font-mono text-neon-purple" x-text="Math.round((serverConfig.maxWaitBeforeErrorMs || 120000) / 1000) + 's'"></span>
|
| 668 |
+
</label>
|
| 669 |
+
<input type="range" min="0" max="600000" step="10000" class="range range-xs range-primary"
|
| 670 |
+
x-model="serverConfig.maxWaitBeforeErrorMs">
|
| 671 |
+
<div class="w-full flex justify-between text-xs px-2 mt-2 text-gray-600 font-mono">
|
| 672 |
+
<span>0s</span>
|
| 673 |
+
<span>10min</span>
|
| 674 |
+
</div>
|
| 675 |
+
<p class="text-[10px] text-gray-600 mt-2">Maximum time to wait for a sticky account to reset before failing or switching.</p>
|
| 676 |
+
</div>
|
| 677 |
+
</div>
|
| 678 |
+
</div>
|
| 679 |
+
|
| 680 |
+
<!-- Save Button -->
|
| 681 |
+
<div class="flex justify-end pt-2">
|
| 682 |
+
<button class="btn btn-sm bg-neon-purple hover:bg-purple-600 border-none text-white px-6 gap-2"
|
| 683 |
+
@click="saveServerConfig()" :disabled="loading">
|
| 684 |
+
<svg x-show="!loading" class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4" /></svg>
|
| 685 |
+
<span x-show="!loading">Save Configuration</span>
|
| 686 |
+
<span x-show="loading" class="loading loading-spinner loading-xs"></span>
|
| 687 |
+
</button>
|
| 688 |
</div>
|
| 689 |
</div>
|
| 690 |
|
| 691 |
<div class="alert bg-blue-500/10 border-blue-500/20 text-xs">
|
| 692 |
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-blue-400 shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
| 693 |
<div class="text-blue-200">
|
| 694 |
+
Some changes may require server restart. Config is saved to <code class="font-mono bg-blue-500/20 px-1 rounded">~/.config/antigravity-proxy/config.json</code>
|
| 695 |
</div>
|
| 696 |
</div>
|
| 697 |
|
| 698 |
+
<!-- Security & Advanced -->
|
| 699 |
<div class="pt-6 border-t border-space-border/30">
|
| 700 |
+
<h4 class="text-sm font-bold text-white mb-4" x-text="$store.global.t('dangerZone')">Danger Zone / Advanced</h4>
|
| 701 |
+
|
| 702 |
+
<div class="space-y-4">
|
| 703 |
+
<!-- Change Password -->
|
| 704 |
+
<div class="flex items-center justify-between p-4 border border-space-border/50 rounded-lg bg-space-900/20"
|
| 705 |
+
x-data="{
|
| 706 |
+
showPasswordDialog: false,
|
| 707 |
+
oldPassword: '',
|
| 708 |
+
newPassword: '',
|
| 709 |
+
confirmPassword: '',
|
| 710 |
+
async changePassword() {
|
| 711 |
+
const store = Alpine.store('global');
|
| 712 |
+
if (this.newPassword !== this.confirmPassword) {
|
| 713 |
+
store.showToast('Passwords do not match', 'error');
|
| 714 |
+
return;
|
| 715 |
+
}
|
| 716 |
+
if (this.newPassword.length < 6) {
|
| 717 |
+
store.showToast('Password must be at least 6 characters', 'error');
|
| 718 |
+
return;
|
| 719 |
+
}
|
| 720 |
+
try {
|
| 721 |
+
const { response, newPassword: updatedPassword } = await window.utils.request('/api/config/password', {
|
| 722 |
+
method: 'POST',
|
| 723 |
+
headers: { 'Content-Type': 'application/json' },
|
| 724 |
+
body: JSON.stringify({
|
| 725 |
+
oldPassword: this.oldPassword,
|
| 726 |
+
newPassword: this.newPassword
|
| 727 |
+
})
|
| 728 |
+
}, store.webuiPassword);
|
| 729 |
+
|
| 730 |
+
if (!response.ok) {
|
| 731 |
+
const data = await response.json();
|
| 732 |
+
throw new Error(data.error || 'Failed to change password');
|
| 733 |
+
}
|
| 734 |
+
|
| 735 |
+
// Update stored password
|
| 736 |
+
store.webuiPassword = this.newPassword;
|
| 737 |
+
store.showToast('Password changed successfully', 'success');
|
| 738 |
+
this.showPasswordDialog = false;
|
| 739 |
+
this.oldPassword = '';
|
| 740 |
+
this.newPassword = '';
|
| 741 |
+
this.confirmPassword = '';
|
| 742 |
+
} catch (e) {
|
| 743 |
+
store.showToast('Failed to change password: ' + e.message, 'error');
|
| 744 |
+
}
|
| 745 |
+
}
|
| 746 |
+
}">
|
| 747 |
+
<div>
|
| 748 |
+
<div class="font-medium text-gray-300 text-sm">Change WebUI Password</div>
|
| 749 |
+
<div class="text-xs text-gray-500">Update the password for accessing this dashboard</div>
|
| 750 |
+
</div>
|
| 751 |
+
<button class="btn btn-sm btn-outline border-space-border hover:bg-yellow-500 hover:text-black hover:border-yellow-500 text-gray-400"
|
| 752 |
+
@click="showPasswordDialog = true">
|
| 753 |
+
Change Password
|
| 754 |
+
</button>
|
| 755 |
+
|
| 756 |
+
<!-- Password Dialog -->
|
| 757 |
+
<div x-show="showPasswordDialog" class="fixed inset-0 bg-black/50 flex items-center justify-center z-[9999]" @click.self="showPasswordDialog = false">
|
| 758 |
+
<div class="bg-space-900 border border-space-border rounded-lg p-6 max-w-md w-full mx-4" @click.stop>
|
| 759 |
+
<h3 class="text-lg font-bold text-white mb-4">Change WebUI Password</h3>
|
| 760 |
+
|
| 761 |
+
<div class="space-y-4">
|
| 762 |
+
<div class="form-control">
|
| 763 |
+
<label class="label">
|
| 764 |
+
<span class="label-text text-gray-300">Current Password</span>
|
| 765 |
+
</label>
|
| 766 |
+
<input type="password" x-model="oldPassword"
|
| 767 |
+
class="input input-sm input-bordered bg-space-800 border-space-border text-white w-full"
|
| 768 |
+
placeholder="Leave empty if no password set">
|
| 769 |
+
</div>
|
| 770 |
+
|
| 771 |
+
<div class="form-control">
|
| 772 |
+
<label class="label">
|
| 773 |
+
<span class="label-text text-gray-300">New Password</span>
|
| 774 |
+
</label>
|
| 775 |
+
<input type="password" x-model="newPassword"
|
| 776 |
+
class="input input-sm input-bordered bg-space-800 border-space-border text-white w-full"
|
| 777 |
+
placeholder="At least 6 characters">
|
| 778 |
+
</div>
|
| 779 |
+
|
| 780 |
+
<div class="form-control">
|
| 781 |
+
<label class="label">
|
| 782 |
+
<span class="label-text text-gray-300">Confirm New Password</span>
|
| 783 |
+
</label>
|
| 784 |
+
<input type="password" x-model="confirmPassword"
|
| 785 |
+
class="input input-sm input-bordered bg-space-800 border-space-border text-white w-full"
|
| 786 |
+
placeholder="Re-enter new password"
|
| 787 |
+
@keydown.enter="changePassword()">
|
| 788 |
+
</div>
|
| 789 |
+
</div>
|
| 790 |
+
|
| 791 |
+
<div class="flex justify-end gap-2 mt-6">
|
| 792 |
+
<button class="btn btn-sm btn-ghost text-gray-400" @click="showPasswordDialog = false; oldPassword = ''; newPassword = ''; confirmPassword = ''">Cancel</button>
|
| 793 |
+
<button class="btn btn-sm bg-neon-purple hover:bg-purple-600 border-none text-white" @click="changePassword()">
|
| 794 |
+
Change Password
|
| 795 |
+
</button>
|
| 796 |
+
</div>
|
| 797 |
+
</div>
|
| 798 |
+
</div>
|
| 799 |
+
</div>
|
| 800 |
+
|
| 801 |
+
<!-- Reload Config -->
|
| 802 |
+
<div class="flex items-center justify-between p-4 border border-space-border/50 rounded-lg bg-space-900/20">
|
| 803 |
+
<div>
|
| 804 |
+
<div class="font-medium text-gray-300 text-sm" x-text="$store.global.t('reloadConfigTitle')">Reload Account Config</div>
|
| 805 |
+
<div class="text-xs text-gray-500" x-text="$store.global.t('reloadConfigDesc')">Force reload accounts.json from disk</div>
|
| 806 |
+
</div>
|
| 807 |
+
<button class="btn btn-sm btn-outline border-space-border hover:bg-white hover:text-black hover:border-white text-gray-400"
|
| 808 |
+
@click="async () => {
|
| 809 |
+
const store = Alpine.store('global');
|
| 810 |
+
store.showToast(store.t('reloading'), 'info');
|
| 811 |
+
try {
|
| 812 |
+
const { response, newPassword } = await window.utils.request('/api/accounts/reload', { method: 'POST' }, store.webuiPassword);
|
| 813 |
+
if (newPassword) store.webuiPassword = newPassword;
|
| 814 |
+
if (response.ok) {
|
| 815 |
+
store.showToast(store.t('reloaded'), 'success');
|
| 816 |
+
Alpine.store('data').fetchData();
|
| 817 |
+
} else {
|
| 818 |
+
throw new Error('Failed to reload');
|
| 819 |
+
}
|
| 820 |
+
} catch (e) {
|
| 821 |
+
store.showToast(store.t('reloadFailed') + ': ' + e.message, 'error');
|
| 822 |
+
}
|
| 823 |
+
}"
|
| 824 |
+
x-text="$store.global.t('reload')">
|
| 825 |
+
Reload
|
| 826 |
+
</button>
|
| 827 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 828 |
</div>
|
| 829 |
</div>
|
| 830 |
</div>
|
|
@@ -39,6 +39,9 @@ export function getAvailableAccounts(accounts, modelId = null) {
|
|
| 39 |
return accounts.filter(acc => {
|
| 40 |
if (acc.isInvalid) return false;
|
| 41 |
|
|
|
|
|
|
|
|
|
|
| 42 |
if (modelId && acc.modelRateLimits && acc.modelRateLimits[modelId]) {
|
| 43 |
const limit = acc.modelRateLimits[modelId];
|
| 44 |
if (limit.isRateLimited && limit.resetTime > Date.now()) {
|
|
|
|
| 39 |
return accounts.filter(acc => {
|
| 40 |
if (acc.isInvalid) return false;
|
| 41 |
|
| 42 |
+
// WebUI: Skip disabled accounts
|
| 43 |
+
if (acc.enabled === false) return false;
|
| 44 |
+
|
| 45 |
if (modelId && acc.modelRateLimits && acc.modelRateLimits[modelId]) {
|
| 46 |
const limit = acc.modelRateLimits[modelId];
|
| 47 |
if (limit.isRateLimited && limit.resetTime > Date.now()) {
|
|
@@ -19,6 +19,9 @@ import { clearExpiredLimits, getAvailableAccounts } from './rate-limits.js';
|
|
| 19 |
function isAccountUsable(account, modelId) {
|
| 20 |
if (!account || account.isInvalid) return false;
|
| 21 |
|
|
|
|
|
|
|
|
|
|
| 22 |
if (modelId && account.modelRateLimits && account.modelRateLimits[modelId]) {
|
| 23 |
const limit = account.modelRateLimits[modelId];
|
| 24 |
if (limit.isRateLimited && limit.resetTime > Date.now()) {
|
|
|
|
| 19 |
function isAccountUsable(account, modelId) {
|
| 20 |
if (!account || account.isInvalid) return false;
|
| 21 |
|
| 22 |
+
// WebUI: Skip disabled accounts
|
| 23 |
+
if (account.enabled === false) return false;
|
| 24 |
+
|
| 25 |
if (modelId && account.modelRateLimits && account.modelRateLimits[modelId]) {
|
| 26 |
const limit = account.modelRateLimits[modelId];
|
| 27 |
if (limit.isRateLimited && limit.resetTime > Date.now()) {
|
|
@@ -27,6 +27,7 @@ export async function loadAccounts(configPath = ACCOUNT_CONFIG_PATH) {
|
|
| 27 |
const accounts = (config.accounts || []).map(acc => ({
|
| 28 |
...acc,
|
| 29 |
lastUsed: acc.lastUsed || null,
|
|
|
|
| 30 |
// Reset invalid flag on startup - give accounts a fresh chance to refresh
|
| 31 |
isInvalid: false,
|
| 32 |
invalidReason: null,
|
|
@@ -107,6 +108,7 @@ export async function saveAccounts(configPath, accounts, settings, activeIndex)
|
|
| 107 |
accounts: accounts.map(acc => ({
|
| 108 |
email: acc.email,
|
| 109 |
source: acc.source,
|
|
|
|
| 110 |
dbPath: acc.dbPath || null,
|
| 111 |
refreshToken: acc.source === 'oauth' ? acc.refreshToken : undefined,
|
| 112 |
apiKey: acc.source === 'manual' ? acc.apiKey : undefined,
|
|
|
|
| 27 |
const accounts = (config.accounts || []).map(acc => ({
|
| 28 |
...acc,
|
| 29 |
lastUsed: acc.lastUsed || null,
|
| 30 |
+
enabled: acc.enabled !== false, // Default to true if not specified
|
| 31 |
// Reset invalid flag on startup - give accounts a fresh chance to refresh
|
| 32 |
isInvalid: false,
|
| 33 |
invalidReason: null,
|
|
|
|
| 108 |
accounts: accounts.map(acc => ({
|
| 109 |
email: acc.email,
|
| 110 |
source: acc.source,
|
| 111 |
+
enabled: acc.enabled !== false, // Persist enabled state
|
| 112 |
dbPath: acc.dbPath || null,
|
| 113 |
refreshToken: acc.source === 'oauth' ? acc.refreshToken : undefined,
|
| 114 |
apiKey: acc.source === 'manual' ? acc.apiKey : undefined,
|
|
@@ -12,6 +12,8 @@ const DEFAULT_CONFIG = {
|
|
| 12 |
retryBaseMs: 1000,
|
| 13 |
retryMaxMs: 30000,
|
| 14 |
persistTokenCache: false,
|
|
|
|
|
|
|
| 15 |
modelMapping: {}
|
| 16 |
};
|
| 17 |
|
|
|
|
| 12 |
retryBaseMs: 1000,
|
| 13 |
retryMaxMs: 30000,
|
| 14 |
persistTokenCache: false,
|
| 15 |
+
defaultCooldownMs: 60000, // 1 minute
|
| 16 |
+
maxWaitBeforeErrorMs: 120000, // 2 minutes
|
| 17 |
modelMapping: {}
|
| 18 |
};
|
| 19 |
|
|
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import fs from 'fs';
|
| 2 |
+
import path from 'path';
|
| 3 |
+
|
| 4 |
+
// Persistence path
|
| 5 |
+
const DATA_DIR = path.join(process.cwd(), 'data');
|
| 6 |
+
const HISTORY_FILE = path.join(DATA_DIR, 'usage-history.json');
|
| 7 |
+
|
| 8 |
+
// In-memory storage
|
| 9 |
+
// Structure: { "YYYY-MM-DDTHH:00:00.000Z": { "claude": { "model-name": count, "_subtotal": count }, "_total": count } }
|
| 10 |
+
let history = {};
|
| 11 |
+
let isDirty = false;
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Extract model family from model ID
|
| 15 |
+
* @param {string} modelId - The model identifier (e.g., "claude-opus-4-5-thinking")
|
| 16 |
+
* @returns {string} The family name (claude, gemini, or other)
|
| 17 |
+
*/
|
| 18 |
+
function getFamily(modelId) {
|
| 19 |
+
const lower = (modelId || '').toLowerCase();
|
| 20 |
+
if (lower.includes('claude')) return 'claude';
|
| 21 |
+
if (lower.includes('gemini')) return 'gemini';
|
| 22 |
+
return 'other';
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Extract short model name (without family prefix)
|
| 27 |
+
* @param {string} modelId - The model identifier
|
| 28 |
+
* @param {string} family - The model family
|
| 29 |
+
* @returns {string} Short model name
|
| 30 |
+
*/
|
| 31 |
+
function getShortName(modelId, family) {
|
| 32 |
+
if (family === 'other') return modelId;
|
| 33 |
+
// Remove family prefix (e.g., "claude-opus-4-5" -> "opus-4-5")
|
| 34 |
+
return modelId.replace(new RegExp(`^${family}-`, 'i'), '');
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* Ensure data directory exists and load history
|
| 39 |
+
*/
|
| 40 |
+
function load() {
|
| 41 |
+
try {
|
| 42 |
+
if (!fs.existsSync(DATA_DIR)) {
|
| 43 |
+
fs.mkdirSync(DATA_DIR, { recursive: true });
|
| 44 |
+
}
|
| 45 |
+
if (fs.existsSync(HISTORY_FILE)) {
|
| 46 |
+
const data = fs.readFileSync(HISTORY_FILE, 'utf8');
|
| 47 |
+
history = JSON.parse(data);
|
| 48 |
+
}
|
| 49 |
+
} catch (err) {
|
| 50 |
+
console.error('[UsageStats] Failed to load history:', err);
|
| 51 |
+
history = {};
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Save history to disk
|
| 57 |
+
*/
|
| 58 |
+
function save() {
|
| 59 |
+
if (!isDirty) return;
|
| 60 |
+
try {
|
| 61 |
+
fs.writeFileSync(HISTORY_FILE, JSON.stringify(history, null, 2));
|
| 62 |
+
isDirty = false;
|
| 63 |
+
} catch (err) {
|
| 64 |
+
console.error('[UsageStats] Failed to save history:', err);
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Prune old data (keep last 30 days)
|
| 70 |
+
*/
|
| 71 |
+
function prune() {
|
| 72 |
+
const now = new Date();
|
| 73 |
+
const cutoff = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000);
|
| 74 |
+
|
| 75 |
+
let pruned = false;
|
| 76 |
+
Object.keys(history).forEach(key => {
|
| 77 |
+
if (new Date(key) < cutoff) {
|
| 78 |
+
delete history[key];
|
| 79 |
+
pruned = true;
|
| 80 |
+
}
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
if (pruned) isDirty = true;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* Track a request by model ID using hierarchical structure
|
| 88 |
+
* @param {string} modelId - The specific model identifier
|
| 89 |
+
*/
|
| 90 |
+
function track(modelId) {
|
| 91 |
+
const now = new Date();
|
| 92 |
+
// Round down to nearest hour
|
| 93 |
+
now.setMinutes(0, 0, 0);
|
| 94 |
+
const key = now.toISOString();
|
| 95 |
+
|
| 96 |
+
if (!history[key]) {
|
| 97 |
+
history[key] = { _total: 0 };
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
const hourData = history[key];
|
| 101 |
+
const family = getFamily(modelId);
|
| 102 |
+
const shortName = getShortName(modelId, family);
|
| 103 |
+
|
| 104 |
+
// Initialize family object if needed
|
| 105 |
+
if (!hourData[family]) {
|
| 106 |
+
hourData[family] = { _subtotal: 0 };
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
// Increment model-specific count
|
| 110 |
+
hourData[family][shortName] = (hourData[family][shortName] || 0) + 1;
|
| 111 |
+
|
| 112 |
+
// Increment family subtotal
|
| 113 |
+
hourData[family]._subtotal = (hourData[family]._subtotal || 0) + 1;
|
| 114 |
+
|
| 115 |
+
// Increment global total
|
| 116 |
+
hourData._total = (hourData._total || 0) + 1;
|
| 117 |
+
|
| 118 |
+
isDirty = true;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* Setup Express Middleware
|
| 123 |
+
* @param {import('express').Application} app
|
| 124 |
+
*/
|
| 125 |
+
function setupMiddleware(app) {
|
| 126 |
+
load();
|
| 127 |
+
|
| 128 |
+
// Auto-save every minute
|
| 129 |
+
setInterval(() => {
|
| 130 |
+
save();
|
| 131 |
+
prune();
|
| 132 |
+
}, 60 * 1000);
|
| 133 |
+
|
| 134 |
+
// Save on exit
|
| 135 |
+
process.on('SIGINT', () => { save(); process.exit(); });
|
| 136 |
+
process.on('SIGTERM', () => { save(); process.exit(); });
|
| 137 |
+
|
| 138 |
+
// Request interceptor
|
| 139 |
+
// Track both Anthropic (/v1/messages) and OpenAI compatible (/v1/chat/completions) endpoints
|
| 140 |
+
const TRACKED_PATHS = ['/v1/messages', '/v1/chat/completions'];
|
| 141 |
+
|
| 142 |
+
app.use((req, res, next) => {
|
| 143 |
+
if (req.method === 'POST' && TRACKED_PATHS.includes(req.path)) {
|
| 144 |
+
const model = req.body?.model;
|
| 145 |
+
if (model) {
|
| 146 |
+
track(model);
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
next();
|
| 150 |
+
});
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/**
|
| 154 |
+
* Setup API Routes
|
| 155 |
+
* @param {import('express').Application} app
|
| 156 |
+
*/
|
| 157 |
+
function setupRoutes(app) {
|
| 158 |
+
app.get('/api/stats/history', (req, res) => {
|
| 159 |
+
// Sort keys to ensure chronological order
|
| 160 |
+
const sortedKeys = Object.keys(history).sort();
|
| 161 |
+
const sortedData = {};
|
| 162 |
+
sortedKeys.forEach(key => {
|
| 163 |
+
sortedData[key] = history[key];
|
| 164 |
+
});
|
| 165 |
+
res.json(sortedData);
|
| 166 |
+
});
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
export default {
|
| 170 |
+
setupMiddleware,
|
| 171 |
+
setupRoutes,
|
| 172 |
+
track,
|
| 173 |
+
getFamily,
|
| 174 |
+
getShortName
|
| 175 |
+
};
|
|
@@ -10,6 +10,7 @@ import path from 'path';
|
|
| 10 |
import { fileURLToPath } from 'url';
|
| 11 |
import { sendMessage, sendMessageStream, listModels, getModelQuotas } from './cloudcode/index.js';
|
| 12 |
import { mountWebUI } from './webui/index.js';
|
|
|
|
| 13 |
|
| 14 |
const __filename = fileURLToPath(import.meta.url);
|
| 15 |
const __dirname = path.dirname(__filename);
|
|
@@ -18,6 +19,7 @@ import { REQUEST_BODY_LIMIT } from './constants.js';
|
|
| 18 |
import { AccountManager } from './account-manager/index.js';
|
| 19 |
import { formatDuration } from './utils/helpers.js';
|
| 20 |
import { logger } from './utils/logger.js';
|
|
|
|
| 21 |
|
| 22 |
// Parse fallback flag directly from command line args to avoid circular dependency
|
| 23 |
const args = process.argv.slice(2);
|
|
@@ -63,6 +65,9 @@ async function ensureInitialized() {
|
|
| 63 |
app.use(cors());
|
| 64 |
app.use(express.json({ limit: REQUEST_BODY_LIMIT }));
|
| 65 |
|
|
|
|
|
|
|
|
|
|
| 66 |
// Mount WebUI (optional web interface for account management)
|
| 67 |
mountWebUI(app, __dirname, accountManager);
|
| 68 |
|
|
@@ -132,11 +137,11 @@ app.get('/health', async (req, res) => {
|
|
| 132 |
try {
|
| 133 |
await ensureInitialized();
|
| 134 |
const start = Date.now();
|
| 135 |
-
|
| 136 |
// Get high-level status first
|
| 137 |
const status = accountManager.getStatus();
|
| 138 |
const allAccounts = accountManager.getAllAccounts();
|
| 139 |
-
|
| 140 |
// Fetch quotas for each account in parallel to get detailed model info
|
| 141 |
const accountDetails = await Promise.allSettled(
|
| 142 |
allAccounts.map(async (account) => {
|
|
@@ -423,6 +428,7 @@ app.get('/account-limits', async (req, res) => {
|
|
| 423 |
timestamp: new Date().toLocaleString(),
|
| 424 |
totalAccounts: allAccounts.length,
|
| 425 |
models: sortedModels,
|
|
|
|
| 426 |
accounts: accountLimits.map(acc => ({
|
| 427 |
email: acc.email,
|
| 428 |
status: acc.status,
|
|
@@ -535,23 +541,19 @@ app.post('/v1/messages', async (req, res) => {
|
|
| 535 |
await ensureInitialized();
|
| 536 |
|
| 537 |
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
top_k,
|
| 549 |
-
temperature
|
| 550 |
-
} = req.body;
|
| 551 |
|
| 552 |
// Optimistic Retry: If ALL accounts are rate-limited for this model, reset them to force a fresh check.
|
| 553 |
// If we have some available accounts, we try them first.
|
| 554 |
-
const modelId = model || 'claude-3-5-sonnet-20241022';
|
| 555 |
if (accountManager.isAllRateLimited(modelId)) {
|
| 556 |
logger.warn(`[Server] All accounts rate-limited for ${modelId}. Resetting state for optimistic retry.`);
|
| 557 |
accountManager.resetAllRateLimits();
|
|
@@ -570,7 +572,7 @@ app.post('/v1/messages', async (req, res) => {
|
|
| 570 |
|
| 571 |
// Build the request object
|
| 572 |
const request = {
|
| 573 |
-
model:
|
| 574 |
messages,
|
| 575 |
max_tokens: max_tokens || 4096,
|
| 576 |
stream,
|
|
@@ -676,6 +678,8 @@ app.post('/v1/messages', async (req, res) => {
|
|
| 676 |
/**
|
| 677 |
* Catch-all for unsupported endpoints
|
| 678 |
*/
|
|
|
|
|
|
|
| 679 |
app.use('*', (req, res) => {
|
| 680 |
if (logger.isDebugEnabled) {
|
| 681 |
logger.debug(`[API] 404 Not Found: ${req.method} ${req.originalUrl}`);
|
|
|
|
| 10 |
import { fileURLToPath } from 'url';
|
| 11 |
import { sendMessage, sendMessageStream, listModels, getModelQuotas } from './cloudcode/index.js';
|
| 12 |
import { mountWebUI } from './webui/index.js';
|
| 13 |
+
import { config } from './config.js';
|
| 14 |
|
| 15 |
const __filename = fileURLToPath(import.meta.url);
|
| 16 |
const __dirname = path.dirname(__filename);
|
|
|
|
| 19 |
import { AccountManager } from './account-manager/index.js';
|
| 20 |
import { formatDuration } from './utils/helpers.js';
|
| 21 |
import { logger } from './utils/logger.js';
|
| 22 |
+
import usageStats from './modules/usage-stats.js';
|
| 23 |
|
| 24 |
// Parse fallback flag directly from command line args to avoid circular dependency
|
| 25 |
const args = process.argv.slice(2);
|
|
|
|
| 65 |
app.use(cors());
|
| 66 |
app.use(express.json({ limit: REQUEST_BODY_LIMIT }));
|
| 67 |
|
| 68 |
+
// Setup usage statistics middleware
|
| 69 |
+
usageStats.setupMiddleware(app);
|
| 70 |
+
|
| 71 |
// Mount WebUI (optional web interface for account management)
|
| 72 |
mountWebUI(app, __dirname, accountManager);
|
| 73 |
|
|
|
|
| 137 |
try {
|
| 138 |
await ensureInitialized();
|
| 139 |
const start = Date.now();
|
| 140 |
+
|
| 141 |
// Get high-level status first
|
| 142 |
const status = accountManager.getStatus();
|
| 143 |
const allAccounts = accountManager.getAllAccounts();
|
| 144 |
+
|
| 145 |
// Fetch quotas for each account in parallel to get detailed model info
|
| 146 |
const accountDetails = await Promise.allSettled(
|
| 147 |
allAccounts.map(async (account) => {
|
|
|
|
| 428 |
timestamp: new Date().toLocaleString(),
|
| 429 |
totalAccounts: allAccounts.length,
|
| 430 |
models: sortedModels,
|
| 431 |
+
modelConfig: config.modelMapping || {},
|
| 432 |
accounts: accountLimits.map(acc => ({
|
| 433 |
email: acc.email,
|
| 434 |
status: acc.status,
|
|
|
|
| 541 |
await ensureInitialized();
|
| 542 |
|
| 543 |
|
| 544 |
+
// Resolve model mapping if configured
|
| 545 |
+
let requestedModel = model || 'claude-3-5-sonnet-20241022';
|
| 546 |
+
const modelMapping = config.modelMapping || {};
|
| 547 |
+
if (modelMapping[requestedModel] && modelMapping[requestedModel].mapping) {
|
| 548 |
+
const targetModel = modelMapping[requestedModel].mapping;
|
| 549 |
+
logger.info(`[Server] Mapping model ${requestedModel} -> ${targetModel}`);
|
| 550 |
+
requestedModel = targetModel;
|
| 551 |
+
}
|
| 552 |
+
|
| 553 |
+
const modelId = requestedModel;
|
|
|
|
|
|
|
|
|
|
| 554 |
|
| 555 |
// Optimistic Retry: If ALL accounts are rate-limited for this model, reset them to force a fresh check.
|
| 556 |
// If we have some available accounts, we try them first.
|
|
|
|
| 557 |
if (accountManager.isAllRateLimited(modelId)) {
|
| 558 |
logger.warn(`[Server] All accounts rate-limited for ${modelId}. Resetting state for optimistic retry.`);
|
| 559 |
accountManager.resetAllRateLimits();
|
|
|
|
| 572 |
|
| 573 |
// Build the request object
|
| 574 |
const request = {
|
| 575 |
+
model: modelId,
|
| 576 |
messages,
|
| 577 |
max_tokens: max_tokens || 4096,
|
| 578 |
stream,
|
|
|
|
| 678 |
/**
|
| 679 |
* Catch-all for unsupported endpoints
|
| 680 |
*/
|
| 681 |
+
usageStats.setupRoutes(app);
|
| 682 |
+
|
| 683 |
app.use('*', (req, res) => {
|
| 684 |
if (logger.isDebugEnabled) {
|
| 685 |
logger.debug(`[API] 404 Not Found: ${req.method} ${req.originalUrl}`);
|
|
@@ -15,14 +15,87 @@
|
|
| 15 |
import path from 'path';
|
| 16 |
import express from 'express';
|
| 17 |
import { getPublicConfig, saveConfig, config } from '../config.js';
|
| 18 |
-
import { DEFAULT_PORT } from '../constants.js';
|
| 19 |
import { readClaudeConfig, updateClaudeConfig, getClaudeConfigPath } from '../utils/claude-config.js';
|
| 20 |
import { logger } from '../utils/logger.js';
|
| 21 |
import { getAuthorizationUrl, completeOAuthFlow } from '../auth/oauth.js';
|
|
|
|
| 22 |
|
| 23 |
// OAuth state storage (state -> { verifier, timestamp })
|
| 24 |
const pendingOAuthStates = new Map();
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
/**
|
| 27 |
* Auth Middleware - Optional password protection for WebUI
|
| 28 |
* Password can be set via WEBUI_PASSWORD env var or config.json
|
|
@@ -114,7 +187,11 @@ export function mountWebUI(app, dirname, accountManager) {
|
|
| 114 |
return res.status(400).json({ status: 'error', error: 'enabled must be a boolean' });
|
| 115 |
}
|
| 116 |
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
res.json({
|
| 119 |
status: 'ok',
|
| 120 |
message: `Account ${email} ${enabled ? 'enabled' : 'disabled'}`
|
|
@@ -130,7 +207,11 @@ export function mountWebUI(app, dirname, accountManager) {
|
|
| 130 |
app.delete('/api/accounts/:email', async (req, res) => {
|
| 131 |
try {
|
| 132 |
const { email } = req.params;
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
res.json({
|
| 135 |
status: 'ok',
|
| 136 |
message: `Account ${email} removed`
|
|
@@ -145,7 +226,9 @@ export function mountWebUI(app, dirname, accountManager) {
|
|
| 145 |
*/
|
| 146 |
app.post('/api/accounts/reload', async (req, res) => {
|
| 147 |
try {
|
| 148 |
-
|
|
|
|
|
|
|
| 149 |
const status = accountManager.getStatus();
|
| 150 |
res.json({
|
| 151 |
status: 'ok',
|
|
@@ -183,7 +266,7 @@ export function mountWebUI(app, dirname, accountManager) {
|
|
| 183 |
*/
|
| 184 |
app.post('/api/config', (req, res) => {
|
| 185 |
try {
|
| 186 |
-
const { debug, logLevel, maxRetries, retryBaseMs, retryMaxMs, persistTokenCache } = req.body;
|
| 187 |
|
| 188 |
// Only allow updating specific fields (security)
|
| 189 |
const updates = {};
|
|
@@ -203,6 +286,12 @@ export function mountWebUI(app, dirname, accountManager) {
|
|
| 203 |
if (typeof persistTokenCache === 'boolean') {
|
| 204 |
updates.persistTokenCache = persistTokenCache;
|
| 205 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
if (Object.keys(updates).length === 0) {
|
| 208 |
return res.status(400).json({
|
|
@@ -232,6 +321,48 @@ export function mountWebUI(app, dirname, accountManager) {
|
|
| 232 |
}
|
| 233 |
});
|
| 234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
/**
|
| 236 |
* GET /api/settings - Get runtime settings
|
| 237 |
*/
|
|
@@ -427,24 +558,28 @@ export function mountWebUI(app, dirname, accountManager) {
|
|
| 427 |
const accountData = await completeOAuthFlow(code, storedState.verifier);
|
| 428 |
|
| 429 |
// Add or update the account
|
| 430 |
-
|
| 431 |
email: accountData.email,
|
| 432 |
refreshToken: accountData.refreshToken,
|
| 433 |
projectId: accountData.projectId,
|
| 434 |
source: 'oauth'
|
| 435 |
});
|
| 436 |
|
|
|
|
|
|
|
|
|
|
| 437 |
// Return a simple HTML page that closes itself or redirects
|
| 438 |
res.send(`
|
| 439 |
<!DOCTYPE html>
|
| 440 |
<html>
|
| 441 |
<head>
|
| 442 |
<title>Authentication Successful</title>
|
|
|
|
| 443 |
<style>
|
| 444 |
body {
|
| 445 |
-
font-family:
|
| 446 |
-
background:
|
| 447 |
-
color:
|
| 448 |
display: flex;
|
| 449 |
justify-content: center;
|
| 450 |
align-items: center;
|
|
@@ -452,7 +587,7 @@ export function mountWebUI(app, dirname, accountManager) {
|
|
| 452 |
margin: 0;
|
| 453 |
flex-direction: column;
|
| 454 |
}
|
| 455 |
-
h1 { color:
|
| 456 |
</style>
|
| 457 |
</head>
|
| 458 |
<body>
|
|
@@ -479,14 +614,16 @@ export function mountWebUI(app, dirname, accountManager) {
|
|
| 479 |
<html>
|
| 480 |
<head>
|
| 481 |
<title>Authentication Failed</title>
|
|
|
|
| 482 |
<style>
|
| 483 |
body {
|
| 484 |
-
font-family:
|
| 485 |
-
background:
|
| 486 |
-
color:
|
| 487 |
text-align: center;
|
| 488 |
padding: 50px;
|
| 489 |
}
|
|
|
|
| 490 |
</style>
|
| 491 |
</head>
|
| 492 |
<body>
|
|
|
|
| 15 |
import path from 'path';
|
| 16 |
import express from 'express';
|
| 17 |
import { getPublicConfig, saveConfig, config } from '../config.js';
|
| 18 |
+
import { DEFAULT_PORT, ACCOUNT_CONFIG_PATH } from '../constants.js';
|
| 19 |
import { readClaudeConfig, updateClaudeConfig, getClaudeConfigPath } from '../utils/claude-config.js';
|
| 20 |
import { logger } from '../utils/logger.js';
|
| 21 |
import { getAuthorizationUrl, completeOAuthFlow } from '../auth/oauth.js';
|
| 22 |
+
import { loadAccounts, saveAccounts } from '../account-manager/storage.js';
|
| 23 |
|
| 24 |
// OAuth state storage (state -> { verifier, timestamp })
|
| 25 |
const pendingOAuthStates = new Map();
|
| 26 |
|
| 27 |
+
/**
|
| 28 |
+
* WebUI Helper Functions - Direct account manipulation
|
| 29 |
+
* These functions work around AccountManager's limited API by directly
|
| 30 |
+
* manipulating the accounts.json config file (non-invasive approach for PR)
|
| 31 |
+
*/
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Set account enabled/disabled state
|
| 35 |
+
*/
|
| 36 |
+
async function setAccountEnabled(email, enabled) {
|
| 37 |
+
const { accounts, settings, activeIndex } = await loadAccounts(ACCOUNT_CONFIG_PATH);
|
| 38 |
+
const account = accounts.find(a => a.email === email);
|
| 39 |
+
if (!account) {
|
| 40 |
+
throw new Error(`Account ${email} not found`);
|
| 41 |
+
}
|
| 42 |
+
account.enabled = enabled;
|
| 43 |
+
await saveAccounts(ACCOUNT_CONFIG_PATH, accounts, settings, activeIndex);
|
| 44 |
+
logger.info(`[WebUI] Account ${email} ${enabled ? 'enabled' : 'disabled'}`);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Remove account from config
|
| 49 |
+
*/
|
| 50 |
+
async function removeAccount(email) {
|
| 51 |
+
const { accounts, settings, activeIndex } = await loadAccounts(ACCOUNT_CONFIG_PATH);
|
| 52 |
+
const index = accounts.findIndex(a => a.email === email);
|
| 53 |
+
if (index === -1) {
|
| 54 |
+
throw new Error(`Account ${email} not found`);
|
| 55 |
+
}
|
| 56 |
+
accounts.splice(index, 1);
|
| 57 |
+
// Adjust activeIndex if needed
|
| 58 |
+
const newActiveIndex = activeIndex >= accounts.length ? Math.max(0, accounts.length - 1) : activeIndex;
|
| 59 |
+
await saveAccounts(ACCOUNT_CONFIG_PATH, accounts, settings, newActiveIndex);
|
| 60 |
+
logger.info(`[WebUI] Account ${email} removed`);
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
/**
|
| 64 |
+
* Add new account to config
|
| 65 |
+
*/
|
| 66 |
+
async function addAccount(accountData) {
|
| 67 |
+
const { accounts, settings, activeIndex } = await loadAccounts(ACCOUNT_CONFIG_PATH);
|
| 68 |
+
|
| 69 |
+
// Check if account already exists
|
| 70 |
+
const existingIndex = accounts.findIndex(a => a.email === accountData.email);
|
| 71 |
+
if (existingIndex !== -1) {
|
| 72 |
+
// Update existing account
|
| 73 |
+
accounts[existingIndex] = {
|
| 74 |
+
...accounts[existingIndex],
|
| 75 |
+
...accountData,
|
| 76 |
+
enabled: true,
|
| 77 |
+
isInvalid: false,
|
| 78 |
+
invalidReason: null,
|
| 79 |
+
addedAt: accounts[existingIndex].addedAt || new Date().toISOString()
|
| 80 |
+
};
|
| 81 |
+
logger.info(`[WebUI] Account ${accountData.email} updated`);
|
| 82 |
+
} else {
|
| 83 |
+
// Add new account
|
| 84 |
+
accounts.push({
|
| 85 |
+
...accountData,
|
| 86 |
+
enabled: true,
|
| 87 |
+
isInvalid: false,
|
| 88 |
+
invalidReason: null,
|
| 89 |
+
modelRateLimits: {},
|
| 90 |
+
lastUsed: null,
|
| 91 |
+
addedAt: new Date().toISOString()
|
| 92 |
+
});
|
| 93 |
+
logger.info(`[WebUI] Account ${accountData.email} added`);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
await saveAccounts(ACCOUNT_CONFIG_PATH, accounts, settings, activeIndex);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
/**
|
| 100 |
* Auth Middleware - Optional password protection for WebUI
|
| 101 |
* Password can be set via WEBUI_PASSWORD env var or config.json
|
|
|
|
| 187 |
return res.status(400).json({ status: 'error', error: 'enabled must be a boolean' });
|
| 188 |
}
|
| 189 |
|
| 190 |
+
await setAccountEnabled(email, enabled);
|
| 191 |
+
|
| 192 |
+
// Reload AccountManager to pick up changes
|
| 193 |
+
await accountManager.initialize();
|
| 194 |
+
|
| 195 |
res.json({
|
| 196 |
status: 'ok',
|
| 197 |
message: `Account ${email} ${enabled ? 'enabled' : 'disabled'}`
|
|
|
|
| 207 |
app.delete('/api/accounts/:email', async (req, res) => {
|
| 208 |
try {
|
| 209 |
const { email } = req.params;
|
| 210 |
+
await removeAccount(email);
|
| 211 |
+
|
| 212 |
+
// Reload AccountManager to pick up changes
|
| 213 |
+
await accountManager.initialize();
|
| 214 |
+
|
| 215 |
res.json({
|
| 216 |
status: 'ok',
|
| 217 |
message: `Account ${email} removed`
|
|
|
|
| 226 |
*/
|
| 227 |
app.post('/api/accounts/reload', async (req, res) => {
|
| 228 |
try {
|
| 229 |
+
// Reload AccountManager from disk
|
| 230 |
+
await accountManager.initialize();
|
| 231 |
+
|
| 232 |
const status = accountManager.getStatus();
|
| 233 |
res.json({
|
| 234 |
status: 'ok',
|
|
|
|
| 266 |
*/
|
| 267 |
app.post('/api/config', (req, res) => {
|
| 268 |
try {
|
| 269 |
+
const { debug, logLevel, maxRetries, retryBaseMs, retryMaxMs, persistTokenCache, defaultCooldownMs, maxWaitBeforeErrorMs } = req.body;
|
| 270 |
|
| 271 |
// Only allow updating specific fields (security)
|
| 272 |
const updates = {};
|
|
|
|
| 286 |
if (typeof persistTokenCache === 'boolean') {
|
| 287 |
updates.persistTokenCache = persistTokenCache;
|
| 288 |
}
|
| 289 |
+
if (typeof defaultCooldownMs === 'number' && defaultCooldownMs >= 1000 && defaultCooldownMs <= 300000) {
|
| 290 |
+
updates.defaultCooldownMs = defaultCooldownMs;
|
| 291 |
+
}
|
| 292 |
+
if (typeof maxWaitBeforeErrorMs === 'number' && maxWaitBeforeErrorMs >= 0 && maxWaitBeforeErrorMs <= 600000) {
|
| 293 |
+
updates.maxWaitBeforeErrorMs = maxWaitBeforeErrorMs;
|
| 294 |
+
}
|
| 295 |
|
| 296 |
if (Object.keys(updates).length === 0) {
|
| 297 |
return res.status(400).json({
|
|
|
|
| 321 |
}
|
| 322 |
});
|
| 323 |
|
| 324 |
+
/**
|
| 325 |
+
* POST /api/config/password - Change WebUI password
|
| 326 |
+
*/
|
| 327 |
+
app.post('/api/config/password', (req, res) => {
|
| 328 |
+
try {
|
| 329 |
+
const { oldPassword, newPassword } = req.body;
|
| 330 |
+
|
| 331 |
+
// Validate input
|
| 332 |
+
if (!newPassword || typeof newPassword !== 'string') {
|
| 333 |
+
return res.status(400).json({
|
| 334 |
+
status: 'error',
|
| 335 |
+
error: 'New password is required'
|
| 336 |
+
});
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
// If current password exists, verify old password
|
| 340 |
+
if (config.webuiPassword && config.webuiPassword !== oldPassword) {
|
| 341 |
+
return res.status(403).json({
|
| 342 |
+
status: 'error',
|
| 343 |
+
error: 'Invalid current password'
|
| 344 |
+
});
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
// Save new password
|
| 348 |
+
const success = saveConfig({ webuiPassword: newPassword });
|
| 349 |
+
|
| 350 |
+
if (success) {
|
| 351 |
+
// Update in-memory config
|
| 352 |
+
config.webuiPassword = newPassword;
|
| 353 |
+
res.json({
|
| 354 |
+
status: 'ok',
|
| 355 |
+
message: 'Password changed successfully'
|
| 356 |
+
});
|
| 357 |
+
} else {
|
| 358 |
+
throw new Error('Failed to save password to config file');
|
| 359 |
+
}
|
| 360 |
+
} catch (error) {
|
| 361 |
+
logger.error('[WebUI] Error changing password:', error);
|
| 362 |
+
res.status(500).json({ status: 'error', error: error.message });
|
| 363 |
+
}
|
| 364 |
+
});
|
| 365 |
+
|
| 366 |
/**
|
| 367 |
* GET /api/settings - Get runtime settings
|
| 368 |
*/
|
|
|
|
| 558 |
const accountData = await completeOAuthFlow(code, storedState.verifier);
|
| 559 |
|
| 560 |
// Add or update the account
|
| 561 |
+
await addAccount({
|
| 562 |
email: accountData.email,
|
| 563 |
refreshToken: accountData.refreshToken,
|
| 564 |
projectId: accountData.projectId,
|
| 565 |
source: 'oauth'
|
| 566 |
});
|
| 567 |
|
| 568 |
+
// Reload AccountManager to pick up the new account
|
| 569 |
+
await accountManager.initialize();
|
| 570 |
+
|
| 571 |
// Return a simple HTML page that closes itself or redirects
|
| 572 |
res.send(`
|
| 573 |
<!DOCTYPE html>
|
| 574 |
<html>
|
| 575 |
<head>
|
| 576 |
<title>Authentication Successful</title>
|
| 577 |
+
<link rel="stylesheet" href="/css/style.css">
|
| 578 |
<style>
|
| 579 |
body {
|
| 580 |
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
| 581 |
+
background-color: var(--color-space-950);
|
| 582 |
+
color: var(--color-text-main);
|
| 583 |
display: flex;
|
| 584 |
justify-content: center;
|
| 585 |
align-items: center;
|
|
|
|
| 587 |
margin: 0;
|
| 588 |
flex-direction: column;
|
| 589 |
}
|
| 590 |
+
h1 { color: var(--color-neon-green); }
|
| 591 |
</style>
|
| 592 |
</head>
|
| 593 |
<body>
|
|
|
|
| 614 |
<html>
|
| 615 |
<head>
|
| 616 |
<title>Authentication Failed</title>
|
| 617 |
+
<link rel="stylesheet" href="/css/style.css">
|
| 618 |
<style>
|
| 619 |
body {
|
| 620 |
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
| 621 |
+
background-color: var(--color-space-950);
|
| 622 |
+
color: var(--color-text-main);
|
| 623 |
text-align: center;
|
| 624 |
padding: 50px;
|
| 625 |
}
|
| 626 |
+
h1 { color: var(--color-neon-red); }
|
| 627 |
</style>
|
| 628 |
</head>
|
| 629 |
<body>
|