606 lines
28 KiB
HTML
606 lines
28 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Model Manager — Nexus One AI</title>
|
|
<link rel="stylesheet" href="style.css?v=4">
|
|
<style>
|
|
.mm-tabs { display:flex; gap:4px; margin-bottom:24px; background:rgba(255,255,255,.03); border:1px solid var(--bdr); border-radius:10px; padding:4px; width:fit-content; }
|
|
.mm-tab { padding:7px 18px; border-radius:7px; font-size:13px; font-weight:600; cursor:pointer; color:var(--lt); border:none; background:none; font-family:inherit; transition:all .15s; }
|
|
.mm-tab.active { background:var(--navy2); color:var(--ink); box-shadow:0 1px 4px rgba(0,0,0,.1); }
|
|
|
|
.mm-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(300px, 1fr)); gap:16px; }
|
|
.mm-card { background:var(--navy2); border:1px solid var(--bdr); border-radius:12px; padding:18px 20px; position:relative; }
|
|
.mm-card.installed { border-color:rgba(134,239,172,.2); background:rgba(34,197,94,.08); }
|
|
.mm-card-name { font-size:15px; font-weight:700; color:var(--ink); margin-bottom:4px; }
|
|
.mm-card-use { font-size:12px; color:var(--lt); margin-bottom:12px; line-height:1.4; }
|
|
.mm-card-meta { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
|
|
.mm-tag { font-size:11px; font-weight:600; padding:3px 8px; border-radius:6px; background:rgba(255,255,255,.03); color:var(--med); border:1px solid var(--bdr); }
|
|
.mm-tag.vram { background:rgba(59,130,246,.1); color:#1D4ED8; border-color:rgba(96,165,250,.25); }
|
|
.mm-tag.size { background:#F5F3FF; color:#6D28D9; border-color:#5B21B6; }
|
|
|
|
.mm-card-actions { display:flex; gap:8px; }
|
|
.mm-btn { padding:7px 14px; border-radius:7px; font-size:12px; font-weight:600; cursor:pointer; border:none; font-family:inherit; transition:all .15s; }
|
|
.mm-btn.pull { background:var(--purple); color:var(--ink); }
|
|
.mm-btn.pull:hover { background:#6D28D9; }
|
|
.mm-btn.del { background:rgba(185,28,28,.08); color:#B91C1C; border:1px solid rgba(239,68,68,.25); }
|
|
.mm-btn.del:hover { background:#DC2626; color:var(--ink); }
|
|
.mm-btn:disabled { opacity:.5; cursor:not-allowed; }
|
|
|
|
.installed-badge { position:absolute; top:14px; right:14px; background:#22C55E; color:var(--ink); font-size:10px; font-weight:800; padding:2px 8px; border-radius:10px; text-transform:uppercase; letter-spacing:.4px; }
|
|
.running-badge { position:absolute; top:14px; right:14px; background:var(--purple); color:var(--ink); font-size:10px; font-weight:800; padding:2px 8px; border-radius:10px; letter-spacing:.4px; }
|
|
|
|
.mm-pull-notice { background:rgba(251,191,36,.08); border:1px solid #FED7AA; border-radius:8px; padding:10px 14px; font-size:13px; color:#92400E; margin-bottom:20px; display:none; }
|
|
.mm-pull-notice.show { display:block; }
|
|
|
|
.vram-bar-wrap { height:5px; background:var(--bdr); border-radius:3px; margin-top:10px; overflow:hidden; }
|
|
.vram-bar { height:100%; background:var(--purple); border-radius:3px; }
|
|
|
|
/* Installed list */
|
|
.mm-installed-row { display:flex; align-items:center; gap:14px; padding:13px 18px; border-bottom:1px solid var(--bdr); }
|
|
.mm-installed-row:last-child { border-bottom:none; }
|
|
.mm-installed-name { font-size:14px; font-weight:700; flex:1; color:var(--ink); }
|
|
.mm-installed-size { font-size:12px; color:var(--lt); font-family:monospace; }
|
|
.mm-installed-date { font-size:12px; color:var(--lt); }
|
|
|
|
.mm-section-wrap { background:var(--navy2); border:1px solid var(--bdr); border-radius:14px; overflow:hidden; }
|
|
|
|
/* ── Upload tab ── */
|
|
.mm-connectivity { display:flex; align-items:center; gap:10px; padding:11px 16px; border-radius:10px; border:1px solid var(--bdr); background:var(--navy2); margin-bottom:20px; font-size:13px; }
|
|
.mm-conn-dot { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
|
|
.mm-conn-dot.online { background:#22C55E; box-shadow:0 0 0 3px #DCFCE7; }
|
|
.mm-conn-dot.offline { background:#EF4444; box-shadow:0 0 0 3px #FEE2E2; }
|
|
.mm-conn-dot.checking { background:#F59E0B; }
|
|
|
|
.upload-zone { border:2px dashed var(--bdr); border-radius:12px; padding:32px 24px; text-align:center; background:rgba(255,255,255,.03); cursor:pointer; transition:all .2s; margin-bottom:20px; }
|
|
.upload-zone:hover, .upload-zone.dragover { border-color:var(--purple); background:rgba(124,58,237,.12); }
|
|
.upload-zone input[type=file] { display:none; }
|
|
.upload-zone-icon { font-size:32px; margin-bottom:8px; }
|
|
.upload-zone-label { font-size:14px; font-weight:600; color:var(--ink); margin-bottom:4px; }
|
|
.upload-zone-hint { font-size:12px; color:var(--lt); }
|
|
|
|
.upload-form { background:var(--navy2); border:1px solid var(--bdr); border-radius:14px; padding:24px; margin-bottom:20px; }
|
|
.upload-form label { display:block; font-size:13px; font-weight:600; color:var(--med); margin-bottom:5px; }
|
|
.upload-form input[type=text] { width:100%; padding:9px 12px; border:1.5px solid var(--bdr); border-radius:8px; font-size:14px; font-family:inherit; color:var(--ink); outline:none; box-sizing:border-box; margin-bottom:14px; }
|
|
.upload-form input:focus { border-color:var(--purple); }
|
|
|
|
.upload-progress-wrap { display:none; margin-bottom:16px; }
|
|
.upload-progress-wrap.show { display:block; }
|
|
.upload-progress-bar-bg { height:8px; background:var(--bdr); border-radius:4px; overflow:hidden; margin-bottom:6px; }
|
|
.upload-progress-bar { height:100%; width:0; background:var(--purple); border-radius:4px; transition:width .15s; }
|
|
.upload-progress-label { font-size:12px; color:var(--med); display:flex; justify-content:space-between; }
|
|
|
|
.upload-file-selected { background:rgba(59,130,246,.1); border:1px solid rgba(96,165,250,.2); border-radius:8px; padding:10px 14px; font-size:13px; color:#1D4ED8; margin-bottom:14px; display:none; }
|
|
.upload-file-selected.show { display:block; }
|
|
|
|
.upload-btn { background:var(--purple); color:var(--ink); border:none; border-radius:8px; padding:10px 22px; font-size:13px; font-weight:700; cursor:pointer; font-family:inherit; }
|
|
.upload-btn:hover { background:#6D28D9; }
|
|
.upload-btn:disabled { opacity:.5; cursor:not-allowed; }
|
|
|
|
.upload-msg { border-radius:8px; padding:10px 14px; font-size:13px; margin-bottom:14px; display:none; }
|
|
.upload-msg.show { display:block; }
|
|
.upload-msg.ok { background:rgba(34,197,94,.08); border:1px solid #86EFAC; color:#15803D; }
|
|
.upload-msg.err { background:rgba(185,28,28,.08); border:1px solid rgba(239,68,68,.25); color:#B91C1C; }
|
|
|
|
/* Uploaded files list */
|
|
.uf-row { display:flex; align-items:center; gap:12px; padding:11px 16px; border-bottom:1px solid var(--bdr); }
|
|
.uf-row:last-child { border-bottom:none; }
|
|
.uf-name { font-size:13px; font-weight:600; flex:1; color:var(--ink); font-family:monospace; }
|
|
.uf-size { font-size:12px; color:var(--lt); }
|
|
.uf-load-btn { background:var(--purple); color:var(--ink); border:none; border-radius:6px; padding:5px 12px; font-size:11px; font-weight:700; cursor:pointer; font-family:inherit; }
|
|
.uf-del-btn { background:rgba(185,28,28,.08); color:#B91C1C; border:1px solid rgba(239,68,68,.25); border-radius:6px; padding:5px 10px; font-size:11px; cursor:pointer; font-family:inherit; }
|
|
</style>
|
|
</head>
|
|
<body data-role="admin">
|
|
|
|
<header class="topnav">
|
|
<a href="index.html" class="brand">Nexus One <span>AI</span></a>
|
|
<nav>
|
|
<a href="index.html">Home</a>
|
|
<a href="quickstart.html">Quick Start</a>
|
|
<a href="prompts.html">Prompt Library</a>
|
|
<a href="usecases.html">Use Cases</a>
|
|
<span class="nav-sep"></span>
|
|
<div class="nav-dropdown">
|
|
<button class="nav-drop-btn">Help ▾</button>
|
|
<div class="nav-drop-menu">
|
|
<span class="nav-drop-cat">LEARN /</span>
|
|
<a href="quickstart.html">Quick Start</a>
|
|
<a href="models.html">Models</a>
|
|
<span class="nav-drop-cat">SUPPORT /</span>
|
|
<a href="troubleshooting.html">Troubleshoot</a>
|
|
<a href="faq.html">FAQ</a>
|
|
<span class="nav-drop-cat">MORE /</span>
|
|
<a href="glossary.html">Glossary</a>
|
|
<a href="whats-new.html">What's New</a>
|
|
</div>
|
|
</div>
|
|
<div class="nav-dropdown">
|
|
<button class="nav-drop-btn active">Admin ▾</button>
|
|
<div class="nav-drop-menu nav-drop-menu-wide">
|
|
<span class="nav-drop-cat">DOCS /</span>
|
|
<a href="security.html">Security & Privacy</a>
|
|
<a href="admin.html">Admin Guide</a>
|
|
<span class="nav-drop-cat">MONITOR /</span>
|
|
<a href="dashboard.html">Dashboard</a>
|
|
<a href="analytics.html">Usage Analytics</a>
|
|
<a href="audit.html">Audit Log</a>
|
|
<a href="feedback.html">Feedback & Ratings</a>
|
|
<span class="nav-drop-cat">MANAGE /</span>
|
|
<a href="users.html">Users</a>
|
|
<a href="teams.html">Teams</a>
|
|
<a href="models-admin.html" class="active">Model Manager</a>
|
|
<a href="training.html">Training</a>
|
|
<a href="knowledge.html">Knowledge Base</a>
|
|
<span class="nav-drop-cat">TOOLS /</span>
|
|
<a href="apikeys.html">API Keys</a>
|
|
<a href="benchmark.html">Benchmarking</a>
|
|
<a href="model-compare.html">Model Compare</a>
|
|
<a href="api-playground.html">API Playground</a>
|
|
<a href="guardrails.html">Guardrails</a>
|
|
<a href="rag-quality.html">RAG Quality</a>
|
|
<a href="router.html">Model Router</a>
|
|
<a href="connectors.html">Connectors</a>
|
|
<span class="nav-drop-cat">SYSTEM /</span>
|
|
<a href="console.html">Console</a>
|
|
<a href="settings.html">Settings</a>
|
|
</div>
|
|
</div>
|
|
<div class="nav-dropdown">
|
|
<button class="nav-drop-btn">AI Tools ▾</button>
|
|
<div class="nav-drop-menu">
|
|
<span class="nav-drop-cat">INTELLIGENCE /</span>
|
|
<a href="documents.html">Document Intelligence</a>
|
|
<a href="chat-multi.html">Multimodal Chat</a>
|
|
<a href="prompt-studio.html">Prompt Studio</a>
|
|
<a href="meeting.html">Meeting Assistant</a>
|
|
<span class="nav-drop-cat">AUTOMATION /</span>
|
|
<a href="agents.html">Agent Builder</a>
|
|
<a href="schedules.html">Scheduled Jobs</a>
|
|
<a href="workflows.html">Workflow Automation</a>
|
|
<span class="nav-drop-cat">QUALITY /</span>
|
|
<a href="evals.html">AI Eval Suite</a>
|
|
<a href="chatrooms.html">Chat Rooms</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
<a href="notifications.html" style="position:relative">🔔</a>
|
|
<span class="badge" data-brand="tier">Basic Tier</span>
|
|
<div id="nav-org-logo" class="nav-org-logo"></div>
|
|
</header>
|
|
|
|
<div class="page-hero">
|
|
<div class="label">Admin · Model Manager</div>
|
|
<h1>AI Model Management</h1>
|
|
<p>View installed models, pull new ones, and remove models to free VRAM. RTX Pro 6000 — 96 GB VRAM available.</p>
|
|
</div>
|
|
|
|
<div class="content">
|
|
|
|
<div class="mm-pull-notice" id="pull-notice"></div>
|
|
|
|
<div class="mm-tabs">
|
|
<button class="mm-tab active" onclick="switchTab('installed', this)">Installed</button>
|
|
<button class="mm-tab" onclick="switchTab('available', this)">Pull from Registry</button>
|
|
<button class="mm-tab" onclick="switchTab('upload', this)">📁 Upload / Offline</button>
|
|
</div>
|
|
|
|
<!-- INSTALLED -->
|
|
<div id="tab-installed">
|
|
<div class="mm-section-wrap" id="installed-list">
|
|
<div style="padding:24px;color:var(--lt)">Loading installed models…</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- AVAILABLE -->
|
|
<div id="tab-available" style="display:none">
|
|
<div class="mm-grid" id="available-grid">
|
|
<div style="color:var(--lt);padding:16px">Loading…</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- UPLOAD / OFFLINE -->
|
|
<div id="tab-upload" style="display:none">
|
|
|
|
<!-- Connectivity indicator -->
|
|
<div class="mm-connectivity">
|
|
<div class="mm-conn-dot checking" id="conn-dot"></div>
|
|
<div>
|
|
<strong id="conn-label" style="font-size:13px">Checking internet…</strong>
|
|
<span id="conn-hint" style="color:var(--lt);font-size:12px;margin-left:8px"></span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Upload new file -->
|
|
<div class="upload-form">
|
|
<div style="font-size:15px;font-weight:700;color:var(--ink);margin-bottom:4px">Upload a GGUF Model File</div>
|
|
<div style="font-size:13px;color:var(--lt);margin-bottom:18px">Transfer a <code>.gguf</code> file from your workstation to the Cezen node. Works fully offline — no internet required.</div>
|
|
|
|
<div class="upload-msg" id="upload-msg"></div>
|
|
|
|
<div class="upload-zone" id="upload-zone" onclick="document.getElementById('gguf-file').click()">
|
|
<input type="file" id="gguf-file" accept=".gguf" onchange="onFileSelected(this)">
|
|
<div class="upload-zone-icon">📦</div>
|
|
<div class="upload-zone-label">Click to select a .gguf file</div>
|
|
<div class="upload-zone-hint">Or drag and drop here · Files can be multi-GB — allow time to transfer</div>
|
|
</div>
|
|
|
|
<div class="upload-file-selected" id="file-selected-info"></div>
|
|
|
|
<label>Model Name (how it will appear in Ollama)</label>
|
|
<input type="text" id="upload-model-name" placeholder="e.g. llama3-8b-local" autocomplete="off">
|
|
|
|
<div class="upload-progress-wrap" id="upload-progress-wrap">
|
|
<div class="upload-progress-bar-bg">
|
|
<div class="upload-progress-bar" id="upload-progress-bar"></div>
|
|
</div>
|
|
<div class="upload-progress-label">
|
|
<span id="upload-progress-pct">0%</span>
|
|
<span id="upload-progress-speed"></span>
|
|
<span id="upload-progress-eta"></span>
|
|
</div>
|
|
</div>
|
|
|
|
<button class="upload-btn" id="upload-btn" onclick="doUpload()" disabled>Upload & Register Model</button>
|
|
</div>
|
|
|
|
<!-- Files already on server -->
|
|
<div class="section-title">Files Already on Server</div>
|
|
<div class="mm-section-wrap" id="uploads-list">
|
|
<div style="padding:20px;color:var(--lt);font-size:13px">Loading…</div>
|
|
</div>
|
|
|
|
<!-- Load modal -->
|
|
<div class="modal-overlay" id="modal-load">
|
|
<div class="modal">
|
|
<div class="modal-title">Register as Ollama Model</div>
|
|
<div class="modal-sub">Assign a name — this is how you'll reference the model in Open WebUI and API calls.</div>
|
|
<div class="modal-error" id="load-err"></div>
|
|
<div class="modal-field">
|
|
<label class="modal-label">Model Name</label>
|
|
<input class="modal-input" id="load-model-name" type="text" placeholder="e.g. llama3-local" autocomplete="off">
|
|
</div>
|
|
<div style="font-size:11px;color:var(--lt);margin-bottom:14px">File: <code id="load-filename-lbl"></code></div>
|
|
<div class="modal-actions">
|
|
<button class="um-btn ghost" onclick="document.getElementById('modal-load').classList.remove('open')">Cancel</button>
|
|
<button class="um-btn primary" onclick="doLoad()">Register Model</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<footer>
|
|
<p>Nexus One AI · Powered by Cezen · Basic Tier</p>
|
|
</footer>
|
|
|
|
<script>
|
|
const _API = '/api';
|
|
|
|
const MOCK_INSTALLED = [
|
|
{name:'llama3:70b', size:39_000_000_000, status:'loaded', modified_at:'2026-06-01T08:00:00Z', details:{parameter_size:'70B', quantization_level:'Q4_K_M'}},
|
|
{name:'llama3:8b', size:4_700_000_000, status:'loaded', modified_at:'2026-06-05T10:00:00Z', details:{parameter_size:'8B', quantization_level:'Q4_K_M'}},
|
|
{name:'mistral:7b', size:4_100_000_000, status:'idle', modified_at:'2026-05-20T12:00:00Z', details:{parameter_size:'7B', quantization_level:'Q4_0'}},
|
|
{name:'codellama:34b',size:19_000_000_000, status:'idle', modified_at:'2026-05-25T09:00:00Z', details:{parameter_size:'34B', quantization_level:'Q4_K_M'}},
|
|
{name:'llava:13b', size:8_000_000_000, status:'idle', modified_at:'2026-06-10T11:00:00Z', details:{parameter_size:'13B', quantization_level:'Q4_K_M'}},
|
|
{name:'nomic-embed-text', size:270_000_000, status:'loaded', modified_at:'2026-06-01T08:00:00Z', details:{parameter_size:'137M',quantization_level:'F16'}},
|
|
];
|
|
|
|
let installedNames = new Set();
|
|
|
|
function switchTab(name, btn) {
|
|
document.querySelectorAll('.mm-tab').forEach(t => t.classList.remove('active'));
|
|
btn.classList.add('active');
|
|
document.getElementById('tab-installed').style.display = name === 'installed' ? '' : 'none';
|
|
document.getElementById('tab-available').style.display = name === 'available' ? '' : 'none';
|
|
document.getElementById('tab-upload').style.display = name === 'upload' ? '' : 'none';
|
|
if (name === 'available') loadAvailable();
|
|
if (name === 'upload') { checkConnectivity(); loadUploads(); }
|
|
}
|
|
|
|
function fmtSize(bytes) {
|
|
if (!bytes) return '—';
|
|
return (bytes / 1e9).toFixed(1) + ' GB';
|
|
}
|
|
|
|
function fmtDate(iso) {
|
|
if (!iso) return '—';
|
|
return new Date(iso).toLocaleDateString();
|
|
}
|
|
|
|
async function loadInstalled() {
|
|
let data;
|
|
try {
|
|
const res = await fetch(`${_API}/models`, { credentials:'include' });
|
|
if (!res.ok) throw new Error();
|
|
data = await res.json();
|
|
if (!data.models?.length) throw new Error('empty');
|
|
} catch(e) {
|
|
data = { models: MOCK_INSTALLED, installed_names: MOCK_INSTALLED.map(m=>m.name) };
|
|
}
|
|
installedNames = new Set(data.installed_names || []);
|
|
const el = document.getElementById('installed-list');
|
|
if (!data.models || !data.models.length) {
|
|
el.innerHTML = '<div style="padding:24px;color:var(--lt)">No models installed yet. Go to "Available to Pull" to download your first model.</div>';
|
|
return;
|
|
}
|
|
el.innerHTML = data.models.map(m => {
|
|
const statusColor = m.status==='loaded' ? '#15803D' : '#6B7280';
|
|
const statusLabel = m.status==='loaded' ? '● loaded' : '○ idle';
|
|
const qLevel = m.details?.quantization_level || '';
|
|
const paramSize = m.details?.parameter_size || '';
|
|
return `
|
|
<div class="mm-installed-row">
|
|
<div>
|
|
<div class="mm-installed-name">${m.name}</div>
|
|
<div style="font-size:11px;color:var(--lt);margin-top:2px;display:flex;gap:8px">
|
|
${paramSize ? `<span>${paramSize}</span>` : ''}
|
|
${qLevel ? `<span>${qLevel}</span>` : ''}
|
|
<span style="color:${statusColor};font-weight:600">${statusLabel}</span>
|
|
</div>
|
|
</div>
|
|
<div class="mm-installed-size">${fmtSize(m.size)}</div>
|
|
<div class="mm-installed-date">${fmtDate(m.modified_at)}</div>
|
|
<button class="mm-btn del" onclick="deleteModel('${m.name}', this)">Remove</button>
|
|
</div>
|
|
`; }).join('');
|
|
}
|
|
|
|
async function loadAvailable() {
|
|
const models = await fetch(`${_API}/models/available`, { credentials:'include' }).then(r => r.json());
|
|
const grid = document.getElementById('available-grid');
|
|
grid.innerHTML = models.map(m => `
|
|
<div class="mm-card ${m.installed ? 'installed' : ''}">
|
|
${m.installed ? '<div class="installed-badge">✓ Installed</div>' : ''}
|
|
<div class="mm-card-name">${m.label}</div>
|
|
<div class="mm-card-use">${m.use}</div>
|
|
<div class="mm-card-meta">
|
|
<span class="mm-tag size">💾 ${m.size_gb} GB download</span>
|
|
<span class="mm-tag vram">🎮 ~${m.vram_gb} GB VRAM</span>
|
|
</div>
|
|
<div class="vram-bar-wrap"><div class="vram-bar" style="width:${Math.round(m.vram_gb/96*100)}%"></div></div>
|
|
<div style="font-size:10px;color:var(--lt);margin:4px 0 12px;text-align:right">${m.vram_gb} of 96 GB VRAM</div>
|
|
<div class="mm-card-actions">
|
|
${m.installed
|
|
? `<button class="mm-btn del" onclick="deleteModel('${m.name}', this)">Remove</button>`
|
|
: `<button class="mm-btn pull" onclick="pullModel('${m.name}', this)">Pull Model</button>`
|
|
}
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
async function pullModel(name, btn) {
|
|
btn.disabled = true;
|
|
btn.textContent = 'Pulling…';
|
|
const notice = document.getElementById('pull-notice');
|
|
try {
|
|
const res = await fetch(`${_API}/models/pull`, {
|
|
method:'POST', credentials:'include',
|
|
headers:{'Content-Type':'application/json'},
|
|
body: JSON.stringify({model: name})
|
|
});
|
|
const data = await res.json();
|
|
notice.textContent = `⏳ ${data.message}`;
|
|
notice.classList.add('show');
|
|
setTimeout(() => { notice.classList.remove('show'); loadInstalled(); }, 8000);
|
|
} catch(e) {
|
|
notice.textContent = 'Failed to start pull. Is Ollama running?';
|
|
notice.classList.add('show');
|
|
}
|
|
btn.disabled = false;
|
|
btn.textContent = 'Pull Model';
|
|
}
|
|
|
|
async function deleteModel(name, btn) {
|
|
if (!confirm(`Remove model "${name}"? It will be deleted from disk.`)) return;
|
|
btn.disabled = true;
|
|
btn.textContent = 'Removing…';
|
|
try {
|
|
await fetch(`${_API}/models/${encodeURIComponent(name)}`, { method:'DELETE', credentials:'include' });
|
|
loadInstalled();
|
|
loadAvailable();
|
|
} catch(e) {
|
|
alert('Failed to remove model.');
|
|
}
|
|
btn.disabled = false;
|
|
btn.textContent = 'Remove';
|
|
}
|
|
|
|
// ── Upload tab ────────────────────────────────────────────────────────────────
|
|
let selectedFile = null;
|
|
let loadTargetFile = null;
|
|
|
|
async function checkConnectivity() {
|
|
const dot = document.getElementById('conn-dot');
|
|
const label = document.getElementById('conn-label');
|
|
const hint = document.getElementById('conn-hint');
|
|
dot.className = 'mm-conn-dot checking';
|
|
try {
|
|
await fetch('https://registry.ollama.ai', { method:'HEAD', mode:'no-cors', signal: AbortSignal.timeout(4000) });
|
|
dot.className = 'mm-conn-dot online';
|
|
label.textContent = 'Internet available';
|
|
hint.textContent = 'You can pull models directly or upload a file below';
|
|
} catch {
|
|
dot.className = 'mm-conn-dot offline';
|
|
label.textContent = 'No internet / Air-gapped';
|
|
hint.textContent = 'Use the upload below to load models from a local file';
|
|
}
|
|
}
|
|
|
|
function onFileSelected(input) {
|
|
selectedFile = input.files[0];
|
|
if (!selectedFile) return;
|
|
const info = document.getElementById('file-selected-info');
|
|
info.textContent = `📦 ${selectedFile.name} (${(selectedFile.size / 1e9).toFixed(2)} GB)`;
|
|
info.classList.add('show');
|
|
const nameInput = document.getElementById('upload-model-name');
|
|
if (!nameInput.value)
|
|
nameInput.value = selectedFile.name.replace(/\.gguf$/i,'').replace(/[^a-zA-Z0-9_-]/g,'-').toLowerCase();
|
|
document.getElementById('upload-btn').disabled = false;
|
|
}
|
|
|
|
// Drag-and-drop
|
|
const zone = document.getElementById('upload-zone');
|
|
if (zone) {
|
|
zone.addEventListener('dragover', e => { e.preventDefault(); zone.classList.add('dragover'); });
|
|
zone.addEventListener('dragleave', () => zone.classList.remove('dragover'));
|
|
zone.addEventListener('drop', e => {
|
|
e.preventDefault(); zone.classList.remove('dragover');
|
|
const f = e.dataTransfer.files[0];
|
|
if (f && f.name.endsWith('.gguf')) {
|
|
const dt = new DataTransfer(); dt.items.add(f);
|
|
const fi = document.getElementById('gguf-file'); fi.files = dt.files;
|
|
onFileSelected(fi);
|
|
}
|
|
});
|
|
}
|
|
|
|
function doUpload() {
|
|
if (!selectedFile) return;
|
|
const modelName = document.getElementById('upload-model-name').value.trim();
|
|
if (!modelName) { showUploadMsg('Enter a model name before uploading.', 'err'); return; }
|
|
|
|
const btn = document.getElementById('upload-btn');
|
|
const prog = document.getElementById('upload-progress-wrap');
|
|
const bar = document.getElementById('upload-progress-bar');
|
|
const pct = document.getElementById('upload-progress-pct');
|
|
const spd = document.getElementById('upload-progress-speed');
|
|
const eta = document.getElementById('upload-progress-eta');
|
|
btn.disabled = true; prog.classList.add('show'); showUploadMsg('','');
|
|
|
|
const fd = new FormData();
|
|
fd.append('file', selectedFile, selectedFile.name);
|
|
|
|
const xhr = new XMLHttpRequest();
|
|
let startTime = Date.now();
|
|
|
|
xhr.upload.addEventListener('progress', e => {
|
|
if (!e.lengthComputable) return;
|
|
const p = Math.round(e.loaded / e.total * 100);
|
|
bar.style.width = p + '%'; pct.textContent = p + '%';
|
|
const elapsed = Math.max((Date.now() - startTime) / 1000, 0.1);
|
|
const speed = e.loaded / elapsed;
|
|
spd.textContent = (speed / 1e6).toFixed(1) + ' MB/s';
|
|
const rem = (e.total - e.loaded) / (speed || 1);
|
|
eta.textContent = rem > 3 ? `~${Math.floor(rem/60)}m ${Math.floor(rem%60)}s left` : '';
|
|
});
|
|
|
|
xhr.addEventListener('load', async () => {
|
|
prog.classList.remove('show');
|
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
showUploadMsg(`✓ File uploaded. Registering "${modelName}" with Ollama…`, 'ok');
|
|
btn.disabled = true;
|
|
try {
|
|
const res = await fetch(`${_API}/models/load`, {
|
|
method:'POST', credentials:'include',
|
|
headers:{'Content-Type':'application/json'},
|
|
body: JSON.stringify({ filename: selectedFile.name, model_name: modelName })
|
|
});
|
|
if (res.ok) {
|
|
showUploadMsg(`✓ Model "${modelName}" is ready to use!`, 'ok');
|
|
loadInstalled(); loadUploads();
|
|
} else {
|
|
const d = await res.json().catch(()=>({}));
|
|
showUploadMsg('Upload succeeded but registration failed: ' + (d.detail||'unknown'), 'err');
|
|
}
|
|
} catch(e) { showUploadMsg('Could not reach backend to register: ' + e, 'err'); }
|
|
} else {
|
|
showUploadMsg('Upload failed (HTTP ' + xhr.status + ')', 'err');
|
|
}
|
|
btn.disabled = false;
|
|
});
|
|
|
|
xhr.addEventListener('error', () => {
|
|
prog.classList.remove('show');
|
|
showUploadMsg('Upload failed — network error.', 'err');
|
|
btn.disabled = false;
|
|
});
|
|
|
|
xhr.open('POST', `/api/models/upload`);
|
|
xhr.withCredentials = true;
|
|
xhr.send(fd);
|
|
}
|
|
|
|
function showUploadMsg(text, type) {
|
|
const el = document.getElementById('upload-msg');
|
|
el.textContent = text;
|
|
el.className = 'upload-msg' + (type ? ' show ' + type : '');
|
|
}
|
|
|
|
async function loadUploads() {
|
|
const list = document.getElementById('uploads-list');
|
|
try {
|
|
const files = await fetch(`${_API}/models/uploads`, { credentials:'include' }).then(r=>r.json());
|
|
if (!files.length) {
|
|
list.innerHTML = '<div style="padding:20px;color:var(--lt);font-size:13px">No files uploaded yet.</div>';
|
|
return;
|
|
}
|
|
list.innerHTML = files.map(f => `
|
|
<div class="uf-row">
|
|
<div class="uf-name">${f.filename}</div>
|
|
<div class="uf-size">${f.size_gb} GB</div>
|
|
<button class="uf-load-btn" onclick="openLoadModal('${f.filename}')">Register →</button>
|
|
<button class="uf-del-btn" onclick="deleteUpload('${f.filename}', this)">✕</button>
|
|
</div>
|
|
`).join('');
|
|
} catch {
|
|
list.innerHTML = '<div style="padding:20px;color:var(--lt)">Could not load file list.</div>';
|
|
}
|
|
}
|
|
|
|
function openLoadModal(filename) {
|
|
loadTargetFile = filename;
|
|
document.getElementById('load-filename-lbl').textContent = filename;
|
|
document.getElementById('load-model-name').value = filename.replace(/\.gguf$/i,'').replace(/[^a-zA-Z0-9_-]/g,'-').toLowerCase();
|
|
document.getElementById('load-err').classList.remove('show');
|
|
document.getElementById('modal-load').classList.add('open');
|
|
}
|
|
|
|
async function doLoad() {
|
|
const name = document.getElementById('load-model-name').value.trim();
|
|
const errEl = document.getElementById('load-err');
|
|
if (!name) { errEl.textContent='Enter a model name.'; errEl.classList.add('show'); return; }
|
|
errEl.classList.remove('show');
|
|
const btn = document.querySelector('#modal-load .um-btn.primary');
|
|
btn.disabled = true; btn.textContent = 'Registering…';
|
|
try {
|
|
const res = await fetch(`${_API}/models/load`, {
|
|
method:'POST', credentials:'include',
|
|
headers:{'Content-Type':'application/json'},
|
|
body: JSON.stringify({ filename: loadTargetFile, model_name: name })
|
|
});
|
|
if (res.ok) {
|
|
document.getElementById('modal-load').classList.remove('open');
|
|
loadInstalled();
|
|
} else {
|
|
const d = await res.json().catch(()=>({}));
|
|
errEl.textContent = d.detail||'Registration failed.'; errEl.classList.add('show');
|
|
}
|
|
} catch(e) {
|
|
errEl.textContent = 'Network error: ' + e; errEl.classList.add('show');
|
|
}
|
|
btn.disabled = false; btn.textContent = 'Register Model';
|
|
}
|
|
|
|
async function deleteUpload(filename, btn) {
|
|
if (!confirm(`Delete uploaded file "${filename}"?`)) return;
|
|
btn.disabled = true;
|
|
await fetch(`${_API}/models/uploads/${encodeURIComponent(filename)}`, { method:'DELETE', credentials:'include' });
|
|
loadUploads();
|
|
}
|
|
|
|
document.getElementById('modal-load')?.addEventListener('click', e => {
|
|
if (e.target === document.getElementById('modal-load')) document.getElementById('modal-load').classList.remove('open');
|
|
});
|
|
|
|
loadInstalled();
|
|
</script>
|
|
<script src="auth.js"></script>
|
|
<script src="branding.js"></script>
|
|
</body>
|
|
</html>
|