diff --git a/src/pages/MonitorPage.tsx b/src/pages/MonitorPage.tsx index 72bd1f9..2f2c76b 100644 --- a/src/pages/MonitorPage.tsx +++ b/src/pages/MonitorPage.tsx @@ -7,6 +7,7 @@ interface ServerRow { display_name: string online: boolean openclaw_version?: string | null + plugin_version?: string | null cpu_pct?: number | null mem_pct?: number | null disk_pct?: number | null @@ -36,6 +37,8 @@ interface ServerItem { identifier: string display_name: string online: boolean + openclaw_version?: string | null + plugin_version?: string | null } export default function MonitorPage() { @@ -95,9 +98,21 @@ export default function MonitorPage() { await loadAdminData() } - const createChallenge = async (id: number) => { - const r = await api.post<{ identifier: string; challenge_uuid: string; expires_at: string }>('/monitor/admin/servers/' + id + '/challenge') - alert('identifier=' + r.data.identifier + ' | challenge_uuid=' + r.data.challenge_uuid + ' | expires_at=' + r.data.expires_at) + const generateApiKey = async (id: number) => { + const r = await api.post<{ server_id: number; api_key: string; message: string }>('/monitor/admin/servers/' + id + '/api-key') + const apiKey = r.data.api_key + try { + await navigator.clipboard.writeText(apiKey) + alert('API key generated and copied to clipboard:\n\n' + apiKey) + } catch { + alert('API key generated:\n\n' + apiKey + '\n\nPlease copy and store it securely. It will not be shown again.') + } + } + + const revokeApiKey = async (id: number) => { + if (!confirm('Revoke this server API key? The plugin will stop authenticating until a new key is generated.')) return + await api.delete('/monitor/admin/servers/' + id + '/api-key') + alert('API key revoked.') } if (loading) return