ui: remove provider monitoring section
This commit is contained in:
@@ -1,20 +1,6 @@
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import api from '@/services/api'
|
||||
|
||||
interface ProviderRow {
|
||||
account_id: number
|
||||
provider: string
|
||||
label: string
|
||||
usage_pct: number | null
|
||||
status: string
|
||||
error?: string | null
|
||||
fetched_at?: string | null
|
||||
reset_at?: string | null
|
||||
window?: string | null
|
||||
used?: number | null
|
||||
limit?: number | null
|
||||
}
|
||||
|
||||
interface ServerRow {
|
||||
server_id: number
|
||||
identifier: string
|
||||
@@ -36,7 +22,6 @@ interface OverviewData {
|
||||
processed_issues_24h: number
|
||||
computed_at: string
|
||||
}
|
||||
providers: ProviderRow[]
|
||||
servers: ServerRow[]
|
||||
generated_at: string
|
||||
}
|
||||
@@ -46,14 +31,6 @@ interface AdminUser {
|
||||
is_admin: boolean
|
||||
}
|
||||
|
||||
interface ProviderAccountItem {
|
||||
id: number
|
||||
provider: string
|
||||
label: string
|
||||
is_enabled: boolean
|
||||
credential_masked: string
|
||||
}
|
||||
|
||||
interface ServerItem {
|
||||
server_id: number
|
||||
identifier: string
|
||||
@@ -65,11 +42,8 @@ export default function MonitorPage() {
|
||||
const [data, setData] = useState<OverviewData | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [isAdmin, setIsAdmin] = useState(false)
|
||||
const [providerAccounts, setProviderAccounts] = useState<ProviderAccountItem[]>([])
|
||||
const [servers, setServers] = useState<ServerItem[]>([])
|
||||
|
||||
const [providerForm, setProviderForm] = useState({ provider: 'openai', label: '', credential: '' })
|
||||
const [providerTestMsg, setProviderTestMsg] = useState('')
|
||||
const [serverForm, setServerForm] = useState({ identifier: '', display_name: '' })
|
||||
|
||||
const canAdmin = useMemo(() => !!localStorage.getItem('token') && isAdmin, [isAdmin])
|
||||
@@ -96,11 +70,7 @@ export default function MonitorPage() {
|
||||
|
||||
const loadAdminData = async () => {
|
||||
if (!canAdmin) return
|
||||
const [p, s] = await Promise.all([
|
||||
api.get<ProviderAccountItem[]>('/monitor/admin/providers/accounts'),
|
||||
api.get<ServerItem[]>('/monitor/admin/servers'),
|
||||
])
|
||||
setProviderAccounts(p.data)
|
||||
const s = await api.get<ServerItem[]>('/monitor/admin/servers')
|
||||
setServers(s.data)
|
||||
}
|
||||
|
||||
@@ -114,25 +84,6 @@ export default function MonitorPage() {
|
||||
loadAdminData()
|
||||
}, [canAdmin])
|
||||
|
||||
const testProvider = async () => {
|
||||
const r = await api.post<{ ok: boolean; message: string }>('/monitor/admin/providers/test', {
|
||||
provider: providerForm.provider,
|
||||
credential: providerForm.credential,
|
||||
})
|
||||
setProviderTestMsg((r.data.ok ? '✅ ' : '❌ ') + r.data.message)
|
||||
}
|
||||
|
||||
const addProvider = async () => {
|
||||
await api.post('/monitor/admin/providers/accounts', providerForm)
|
||||
setProviderForm({ ...providerForm, label: '', credential: '' })
|
||||
await loadAdminData()
|
||||
}
|
||||
|
||||
const deleteProvider = async (id: number) => {
|
||||
await api.delete('/monitor/admin/providers/accounts/' + id)
|
||||
await loadAdminData()
|
||||
}
|
||||
|
||||
const addServer = async () => {
|
||||
await api.post('/monitor/admin/servers', serverForm)
|
||||
setServerForm({ identifier: '', display_name: '' })
|
||||
@@ -171,43 +122,6 @@ export default function MonitorPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="section">
|
||||
<div className="page-header">
|
||||
<h3>Provider Usage</h3>
|
||||
<span className="text-dim">Updated at {data.generated_at}</span>
|
||||
</div>
|
||||
{data.providers.length === 0 ? <p className="empty">No provider accounts</p> : (
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Provider</th>
|
||||
<th>Label</th>
|
||||
<th>Usage</th>
|
||||
<th>Window</th>
|
||||
<th>Reset</th>
|
||||
<th>Status</th>
|
||||
<th>Updated</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data.providers.map((p) => (
|
||||
<tr key={p.account_id}>
|
||||
<td>{p.provider}</td>
|
||||
<td>{p.label}</td>
|
||||
<td>{p.usage_pct !== null ? p.usage_pct + '%' : '-'}</td>
|
||||
<td>{p.window || '-'}</td>
|
||||
<td>{p.reset_at || '-'}</td>
|
||||
<td><span className={
|
||||
'badge ' + (p.status === 'ok' ? 'status-ok' : p.status === 'error' ? 'status-error' : 'status-pending')
|
||||
}>{p.status}</span></td>
|
||||
<td>{p.fetched_at || '-'}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="section">
|
||||
<h3>Server Monitoring</h3>
|
||||
{data.servers.length === 0 ? <p className="empty">No monitored servers</p> : (
|
||||
@@ -237,29 +151,6 @@ export default function MonitorPage() {
|
||||
<h3>Admin</h3>
|
||||
|
||||
<div className="monitor-admin">
|
||||
<div className="monitor-card">
|
||||
<h4>Provider Accounts</h4>
|
||||
<div className="inline-form">
|
||||
<select value={providerForm.provider} onChange={(e) => setProviderForm({ ...providerForm, provider: e.target.value })}>
|
||||
<option value='openai'>openai</option>
|
||||
<option value='anthropic'>anthropic</option>
|
||||
<option value='minimax'>minimax</option>
|
||||
<option value='kimi'>kimi</option>
|
||||
<option value='qwen'>qwen</option>
|
||||
</select>
|
||||
<input placeholder='label' value={providerForm.label} onChange={(e) => setProviderForm({ ...providerForm, label: e.target.value })} />
|
||||
<input placeholder='credential' value={providerForm.credential} onChange={(e) => setProviderForm({ ...providerForm, credential: e.target.value })} />
|
||||
<button className="btn-primary" onClick={testProvider}>Test Connection</button>
|
||||
<button className="btn-primary" onClick={addProvider}>Add Account</button>
|
||||
</div>
|
||||
{providerTestMsg && <p className="text-dim">{providerTestMsg}</p>}
|
||||
<ul>
|
||||
{providerAccounts.map((p) => (
|
||||
<li key={p.id}>{p.provider} / {p.label} / {p.credential_masked} <button className="btn-danger" onClick={() => deleteProvider(p.id)}>Delete</button></li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="monitor-card">
|
||||
<h4>Servers</h4>
|
||||
<div className="inline-form">
|
||||
|
||||
Reference in New Issue
Block a user