Proxy fixes, streaming support, Admin-UI overhaul
Backend: - Fix Content-Length mismatch by not forwarding client headers to Ollama - Proxy /v1/chat/completions directly to Ollama's OpenAI-compatible endpoint (eliminates manual Ollama↔OpenAI format conversion, fixes tool use) - Add streaming support via SSE passthrough - Fix ollama_url /v1 suffix stripped on save - Replace BaseHTTPMiddleware with FastAPI global dependency (fixes double logging) - Add rotating usage log (8 KB, logs key name + model + token estimate + prompt preview) - Add httpx timeout 300s - Add activate and delete endpoints for API keys - Return usage data (tokens/requests) in GET /api/api-keys Frontend: - Admin table: remove ID column, status as icon, icon-only action buttons with CSS tooltips - Add activate + delete buttons; edit available for inactive keys too - Quota columns: fixed equal width, progress bars with k-unit formatting - Create form: structured layout matching edit form style - Edit form: token inputs in k units (÷1000 display, ×1000 on save) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
c62cafc202
commit
dd8f69ecb6
6 files changed
+2687
-167
No files matched your search
+223
-21
@@ -92,30 +92,37 @@ tr:hover {
|
||||
|
||||
.create-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.create-form .edit-form {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.create-name {
|
||||
flex: 0 0 auto !important;
|
||||
}
|
||||
|
||||
.create-name input {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.create-date {
|
||||
flex: 0 0 auto !important;
|
||||
}
|
||||
|
||||
.create-date input[type="date"] {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.create-btn-wrap {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.create-form input {
|
||||
padding: 8px 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
flex: 1 1 160px;
|
||||
}
|
||||
|
||||
.create-form button {
|
||||
padding: 8px 20px;
|
||||
background: #27ae60;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.create-form button:disabled {
|
||||
.create-form .btn-save:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
@@ -218,3 +225,198 @@ tr:hover {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* Quota progress bars */
|
||||
.th-quota {
|
||||
width: 90px;
|
||||
}
|
||||
|
||||
.quota-cell {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.quota-label {
|
||||
font-size: 12px;
|
||||
color: #555;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.quota-unlimited {
|
||||
color: #aaa;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 4px;
|
||||
background: #e2e8f0;
|
||||
border-radius: 2px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
border-radius: 2px;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
/* Edit form */
|
||||
.td-status {
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.status-active { color: #27ae60; font-size: 12px; }
|
||||
.status-inactive { color: #bdc3c7; font-size: 12px; }
|
||||
|
||||
.btn-icon {
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
padding: 2px 4px;
|
||||
margin-right: 2px;
|
||||
border-radius: 3px;
|
||||
line-height: 1;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.btn-icon:hover {
|
||||
background: rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.btn-icon-edit { color: #2980b9; }
|
||||
.btn-icon-warn { color: #e67e22; }
|
||||
.btn-icon-ok { color: #27ae60; }
|
||||
.btn-icon-danger { color: #e74c3c; }
|
||||
|
||||
.btn-icon::after {
|
||||
content: attr(data-tooltip);
|
||||
position: absolute;
|
||||
bottom: calc(100% + 8px);
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: #2c3e50;
|
||||
color: white;
|
||||
padding: 5px 10px;
|
||||
border-radius: 5px;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
white-space: nowrap;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.15s;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.btn-icon::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: calc(100% + 2px);
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
border: 5px solid transparent;
|
||||
border-top-color: #2c3e50;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.15s;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.btn-icon:hover::after,
|
||||
.btn-icon:hover::before {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.action-cell {
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.row-editing {
|
||||
background: #eaf4fb !important;
|
||||
}
|
||||
|
||||
.edit-section {
|
||||
margin-top: 20px;
|
||||
padding: 16px 20px;
|
||||
background: #f0f7ff;
|
||||
border: 1px solid #3498db;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.edit-section h3 {
|
||||
margin: 0 0 14px;
|
||||
font-size: 15px;
|
||||
color: #2c3e50;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.edit-section h3 em {
|
||||
font-style: normal;
|
||||
color: #2980b9;
|
||||
}
|
||||
|
||||
.edit-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 14px;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.edit-form label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #34495e;
|
||||
}
|
||||
|
||||
.edit-form label small {
|
||||
font-weight: 400;
|
||||
color: #999;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.edit-form input {
|
||||
padding: 6px 8px;
|
||||
border: 1px solid #bdc3c7;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
width: 130px;
|
||||
}
|
||||
|
||||
.edit-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
padding: 6px 18px;
|
||||
background: #27ae60;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.btn-save:hover {
|
||||
background: #219a52;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
padding: 6px 18px;
|
||||
background: #95a5a6;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.btn-cancel:hover {
|
||||
background: #7f8c8d;
|
||||
}
|
||||
Reference in new issue
Block a user