Restore complete admin functionality with new model structure
- Restored original admin.js with all functionality (2692 lines) - Accounts, affiliates, withdrawals management restored - All form handlers and API calls preserved - Updated state to use opencodeModels instead of providerChain - Updated element references for new OpenCode model structure - Maintained all existing functionality while applying model changes
This commit is contained in:
@@ -67,116 +67,180 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Section 1: OpenCode Models -->
|
<div class="admin-grid">
|
||||||
<div class="admin-card">
|
<!-- Public Facing Models Section -->
|
||||||
<header>
|
<div class="admin-card">
|
||||||
<h3>OpenCode Models</h3>
|
<header>
|
||||||
<div class="pill">Backend</div>
|
<h3>Add Public-Facing Model</h3>
|
||||||
</header>
|
<div class="pill">Public</div>
|
||||||
<p style="margin-top:0; color: var(--muted);">Add models from OpenCode. When rate limits are reached, the system automatically falls back to the next model in the order below.</p>
|
</header>
|
||||||
|
<p style="margin-top:0; color: var(--muted);">These models are displayed to users in the builder dropdown. They all share the same unified provider fallback chain.</p>
|
||||||
<!-- Add Model Form -->
|
<form id="public-model-form" class="admin-form">
|
||||||
<form id="opencode-model-form" class="admin-form" style="margin-bottom: 24px;">
|
|
||||||
<label>
|
|
||||||
Choose from OpenCode
|
|
||||||
<select id="opencode-model-select"></select>
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
Display name
|
|
||||||
<input id="opencode-model-label" type="text" placeholder="e.g., GPT-4 Turbo" required />
|
|
||||||
</label>
|
|
||||||
<div class="admin-grid" style="grid-template-columns: 1fr 1fr; gap: 12px;">
|
|
||||||
<label>
|
<label>
|
||||||
Tier
|
Model ID (e.g., claude-3-5-sonnet, gpt-4o)
|
||||||
<select id="opencode-model-tier">
|
<input id="public-model-name" type="text" placeholder="Model ID from OpenCode" required />
|
||||||
<option value="free">Free (1x)</option>
|
|
||||||
<option value="plus">Plus (2x)</option>
|
|
||||||
<option value="pro">Pro (3x)</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
Icon
|
Display name shown to users
|
||||||
<select id="opencode-model-icon">
|
<input id="public-model-label" type="text" placeholder="Friendly label (e.g., Claude 3.5 Sonnet)" required />
|
||||||
<option value="">No icon</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<label style="display: flex; align-items: center; gap: 8px; margin-top: 8px;">
|
|
||||||
<input id="opencode-model-media" type="checkbox" style="width: auto;" />
|
|
||||||
<span>Supports image uploads</span>
|
|
||||||
</label>
|
|
||||||
<div class="admin-actions">
|
|
||||||
<button type="submit" class="primary">Add OpenCode Model</button>
|
|
||||||
<button type="button" id="reload-opencode-models" class="ghost">Reload Models</button>
|
|
||||||
</div>
|
|
||||||
<div class="status-line" id="opencode-model-status"></div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<!-- Models List -->
|
|
||||||
<header style="margin-top: 24px; border-top: 1px solid var(--border); padding-top: 16px;">
|
|
||||||
<h3>OpenCode Models Order</h3>
|
|
||||||
<div class="pill" id="opencode-models-count">0</div>
|
|
||||||
</header>
|
|
||||||
<p class="muted" style="margin-top:0;">Arrange the order below. #1 is the primary model. When it hits rate limits, the system falls back to #2, then #3, and so on.</p>
|
|
||||||
<div id="opencode-models-list" class="admin-list"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Section 2: Public Models -->
|
|
||||||
<div class="admin-card" style="margin-top: 16px;">
|
|
||||||
<header>
|
|
||||||
<h3>Public Models</h3>
|
|
||||||
<div class="pill">User-Facing</div>
|
|
||||||
</header>
|
|
||||||
<p style="margin-top:0; color: var(--muted);">These models are displayed to users in the builder dropdown. They are completely separate from OpenCode models.</p>
|
|
||||||
|
|
||||||
<!-- Add Form -->
|
|
||||||
<form id="public-model-form" class="admin-form" style="margin-bottom: 24px;">
|
|
||||||
<div class="admin-grid" style="grid-template-columns: 1fr 1fr; gap: 12px;">
|
|
||||||
<label>
|
|
||||||
Model ID
|
|
||||||
<input id="public-model-name" type="text" placeholder="e.g., my-custom-model" required />
|
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
Display name
|
Model tier (for plan limits)
|
||||||
<input id="public-model-label" type="text" placeholder="e.g., My Custom Model" required />
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="admin-grid" style="grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px;">
|
|
||||||
<label>
|
|
||||||
Tier
|
|
||||||
<select id="public-model-tier">
|
<select id="public-model-tier">
|
||||||
<option value="free">Free (1x)</option>
|
<option value="free">Free (1x multiplier)</option>
|
||||||
<option value="plus">Plus (2x)</option>
|
<option value="plus">Plus (2x multiplier)</option>
|
||||||
<option value="pro">Pro (3x)</option>
|
<option value="pro">Pro (3x multiplier)</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
Icon
|
Icon (files in /assets)
|
||||||
<select id="public-model-icon">
|
<select id="public-model-icon">
|
||||||
<option value="">No icon</option>
|
<option value="">No icon</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
<label style="display: flex; align-items: center; gap: 8px; margin-top: 8px;">
|
||||||
<label style="display: flex; align-items: center; gap: 8px; margin-top: 12px;">
|
<input id="public-model-media" type="checkbox" style="width: auto;" />
|
||||||
<input id="public-model-media" type="checkbox" style="width: auto;" />
|
<span>Supports image uploads</span>
|
||||||
<span>Supports image uploads</span>
|
</label>
|
||||||
</label>
|
<div class="admin-actions">
|
||||||
<div class="admin-actions">
|
<button type="submit" class="primary">Add Public Model</button>
|
||||||
<button type="submit" class="primary">Add Public Model</button>
|
</div>
|
||||||
</div>
|
<div class="status-line" id="public-model-status"></div>
|
||||||
<div class="status-line" id="public-model-status"></div>
|
</form>
|
||||||
</form>
|
</div>
|
||||||
|
|
||||||
<!-- List -->
|
<!-- Provider Model Chain Section -->
|
||||||
<header style="margin-top: 24px; border-top: 1px solid var(--border); padding-top: 16px;">
|
<div class="admin-card">
|
||||||
<h3>Public Models List</h3>
|
<header>
|
||||||
<div class="pill" id="public-models-count">0</div>
|
<h3>Provider Model Chain</h3>
|
||||||
</header>
|
<div class="pill">Backend</div>
|
||||||
<p class="muted" style="margin-top:0;">These are shown to users. Use arrows to reorder.</p>
|
</header>
|
||||||
<div id="public-models-list" class="admin-list"></div>
|
<p style="margin-top:0; color: var(--muted);">This is the unified fallback chain used for ALL models. When rate limits are reached or errors occur, the system automatically falls back to the next provider in this chain.</p>
|
||||||
|
<form id="provider-chain-form" class="admin-form">
|
||||||
|
<label>
|
||||||
|
Provider
|
||||||
|
<select id="chain-provider">
|
||||||
|
<option value="openrouter">OpenRouter</option>
|
||||||
|
<option value="mistral">Mistral</option>
|
||||||
|
<option value="google">Google</option>
|
||||||
|
<option value="groq">Groq</option>
|
||||||
|
<option value="nvidia">NVIDIA</option>
|
||||||
|
<option value="chutes">Chutes</option>
|
||||||
|
<option value="cerebras">Cerebras</option>
|
||||||
|
<option value="ollama">Ollama</option>
|
||||||
|
<option value="opencode">OpenCode</option>
|
||||||
|
<option value="cohere">Cohere</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Model Name
|
||||||
|
<input id="chain-model" type="text" placeholder="e.g., anthropic/claude-3.5-sonnet" required />
|
||||||
|
</label>
|
||||||
|
<div class="admin-actions">
|
||||||
|
<button type="submit" class="primary">Add to Chain</button>
|
||||||
|
</div>
|
||||||
|
<div class="status-line" id="provider-chain-status"></div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Provider Chain List with Ordering -->
|
||||||
|
<div class="admin-card" style="margin-top: 16px;">
|
||||||
|
<header>
|
||||||
|
<h3>Unified Provider Chain Order</h3>
|
||||||
|
<div class="pill" id="provider-chain-count">0</div>
|
||||||
|
</header>
|
||||||
|
<p class="muted" style="margin-top:0;">Arrange the order of providers below. The system will try each provider in order when rate limits are reached or errors occur. The first provider is the primary.</p>
|
||||||
|
<div id="provider-chain-list" class="admin-list"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-grid" style="margin-top: 16px;">
|
||||||
|
<!-- Legacy Model Form (hidden but kept for compatibility) -->
|
||||||
|
<div class="admin-card" style="display: none;">
|
||||||
|
<header>
|
||||||
|
<h3>Add / Update Model (Legacy)</h3>
|
||||||
|
<div class="pill">Step 1</div>
|
||||||
|
</header>
|
||||||
|
<form id="model-form" class="admin-form">
|
||||||
|
<label>
|
||||||
|
Choose a model from OpenCode
|
||||||
|
<select id="available-models"></select>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Display name shown to users
|
||||||
|
<input id="display-label" type="text" placeholder="Friendly label (e.g. Fast GPT-4)" required />
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Model tier (for plan limits)
|
||||||
|
<select id="model-tier">
|
||||||
|
<option value="free">Free (1x multiplier)</option>
|
||||||
|
<option value="plus">Plus (2x multiplier)</option>
|
||||||
|
<option value="pro">Pro (3x multiplier)</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Icon (files in /assets)
|
||||||
|
<select id="icon-select">
|
||||||
|
<option value="">No icon</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Provider priority (comma separated provider:model)
|
||||||
|
<input id="provider-order" type="text" placeholder="openrouter:anthropic/claude-3.5-sonnet, mistral:mistral-large-latest" />
|
||||||
|
</label>
|
||||||
|
<label style="display: flex; align-items: center; gap: 8px; margin-top: 8px;">
|
||||||
|
<input id="supports-media" type="checkbox" style="width: auto;" />
|
||||||
|
<span>Supports image uploads</span>
|
||||||
|
</label>
|
||||||
|
<div class="admin-actions">
|
||||||
|
<button type="submit" class="primary">Save model</button>
|
||||||
|
<button type="button" id="reload-available" class="ghost">Reload available models</button>
|
||||||
|
</div>
|
||||||
|
<div class="status-line" id="admin-status"></div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-card">
|
||||||
|
<header>
|
||||||
|
<h3>System Actions</h3>
|
||||||
|
<div class="pill">Admin</div>
|
||||||
|
</header>
|
||||||
|
<p style="margin-top:0; color: var(--muted);">Emergency controls for system management.</p>
|
||||||
|
<div class="admin-actions" style="flex-direction: column; align-items: flex-start;">
|
||||||
|
<button id="cancel-all-messages" class="danger">Cancel All Running & Queued Messages</button>
|
||||||
|
<div class="status-line" id="cancel-messages-status"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-card">
|
||||||
|
<header>
|
||||||
|
<h3>Icon Library</h3>
|
||||||
|
<div class="pill">Step 0</div>
|
||||||
|
</header>
|
||||||
|
<p style="margin-top:0; color: var(--muted);">Upload icon files to <strong>/chat/public/assets</strong> and pick them here. PNG, JPG, SVG, and WEBP are supported.</p>
|
||||||
|
<div id="icon-list" class="admin-list"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-card" style="margin-top: 16px;">
|
||||||
|
<header>
|
||||||
|
<h3>OpenCode Ultimate Backup Model</h3>
|
||||||
|
<div class="pill">Fallback</div>
|
||||||
|
</header>
|
||||||
|
<p style="margin-top:0; color: var(--muted);">Configure the ultimate fallback model that will be used when all providers fail. This is the last-resort backup for reliability.</p>
|
||||||
|
<form id="opencode-backup-form" class="admin-form">
|
||||||
|
<label>
|
||||||
|
OpenCode backup model
|
||||||
|
<select id="opencode-backup"></select>
|
||||||
|
</label>
|
||||||
|
<div class="admin-actions">
|
||||||
|
<button type="submit" class="primary">Save backup model</button>
|
||||||
|
</div>
|
||||||
|
<div class="status-line" id="opencode-backup-status"></div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Section 2: Auto Model for Hobby/Free Plan -->
|
|
||||||
<div class="admin-card" style="margin-top: 16px;">
|
<div class="admin-card" style="margin-top: 16px;">
|
||||||
<header>
|
<header>
|
||||||
<h3>Auto Model for Hobby/Free Plan</h3>
|
<h3>Auto Model for Hobby/Free Plan</h3>
|
||||||
@@ -197,7 +261,6 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Section 3: Provider Limits & Usage -->
|
|
||||||
<div class="admin-grid" style="margin-top: 16px;">
|
<div class="admin-grid" style="margin-top: 16px;">
|
||||||
<div class="admin-card">
|
<div class="admin-card">
|
||||||
<header>
|
<header>
|
||||||
@@ -267,31 +330,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Section 4: Other Admin Sections -->
|
<!-- Public Models List -->
|
||||||
<div class="admin-grid" style="margin-top: 16px;">
|
<div class="admin-card" style="margin-top: 16px;">
|
||||||
<div class="admin-card">
|
<header>
|
||||||
<header>
|
<h3>Public-Facing Models</h3>
|
||||||
<h3>System Actions</h3>
|
<div class="pill" id="configured-count">0</div>
|
||||||
<div class="pill">Admin</div>
|
</header>
|
||||||
</header>
|
<p class="muted" style="margin-top:0;">These models are displayed to users in the builder. All models use the unified provider chain above for fallback.</p>
|
||||||
<p style="margin-top:0; color: var(--muted);">Emergency controls for system management.</p>
|
<div id="configured-list" class="admin-list"></div>
|
||||||
<div class="admin-actions" style="flex-direction: column; align-items: flex-start;">
|
|
||||||
<button id="cancel-all-messages" class="danger">Cancel All Running & Queued Messages</button>
|
|
||||||
<div class="status-line" id="cancel-messages-status"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="admin-card">
|
|
||||||
<header>
|
|
||||||
<h3>Icon Library</h3>
|
|
||||||
<div class="pill">Assets</div>
|
|
||||||
</header>
|
|
||||||
<p style="margin-top:0; color: var(--muted);">Upload icon files to <strong>/chat/public/assets</strong>. PNG, JPG, SVG, and WEBP are supported.</p>
|
|
||||||
<div id="icon-list" class="admin-list"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</main>
|
||||||
<script src="/admin.js"></script>
|
|
||||||
</div>
|
</div>
|
||||||
|
<script src="/admin.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
3015
chat/public/admin.js
3015
chat/public/admin.js
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user