Spaces:
Running
Running
Download frontend/src/features/admin-console/services/adminService.ts from Shadowfilebot/Bot: direct link, hf CLI and curl.
- Browser
- Download file 3.34 kB
-
https://huggingface.co/spaces/Shadowfilebot/Bot/resolve/main/frontend/src/features/admin-console/services/adminService.ts
- Command line
-
hf download hf://spaces/Shadowfilebot/Bot/frontend/src/features/admin-console/services/adminService.ts
-
curl -L -o adminService.ts https://huggingface.co/spaces/Shadowfilebot/Bot/resolve/main/frontend/src/features/admin-console/services/adminService.ts
3.34 kB
| import { requestJson } from '@/shared/lib/httpClient'; | |
| import { | |
| AdminContactListResponse, | |
| AdminContactMessage, | |
| AdminOverview, | |
| AdminSettings, | |
| AdminSiteInfo, | |
| AdminTelemetry, | |
| AdminUserRow, | |
| AdminZonesResponse, | |
| BypassRunResult, | |
| BypassStatus, | |
| BypassSyncResult, | |
| } from '../types/adminTypes'; | |
| export const adminService = { | |
| getOverview: () => requestJson<AdminOverview>('/api/admin/overview'), | |
| getTelemetry: () => requestJson<AdminTelemetry>('/api/admin/telemetry'), | |
| getBypassStatus: () => requestJson<BypassStatus>('/api/admin/bypass/status'), | |
| runBypassAction: (endpoint: string, body?: Record<string, unknown>) => | |
| requestJson<BypassRunResult>(endpoint, { | |
| method: 'POST', | |
| body: body ? JSON.stringify(body) : undefined, | |
| }), | |
| syncBypassEnv: () => requestJson<BypassSyncResult>('/api/admin/bypass/sync', { method: 'POST' }), | |
| getBypassLog: () => requestJson<{ log: string }>('/api/admin/bypass/log'), | |
| getSettings: () => requestJson<AdminSettings>('/api/admin/settings'), | |
| saveSettings: (payload: Record<string, unknown>) => | |
| requestJson('/api/admin/settings', { method: 'POST', body: JSON.stringify(payload) }), | |
| getSiteInfo: () => requestJson<Partial<AdminSiteInfo>>('/api/site/info', { cache: 'no-store' }, false), | |
| updateSiteInfo: (payload: Partial<AdminSiteInfo>) => | |
| requestJson<{ ok: boolean; site: AdminSiteInfo }>('/api/admin/site-info', { | |
| method: 'PUT', | |
| body: JSON.stringify(payload), | |
| }), | |
| changePassword: (currentPassword: string, newPassword: string) => | |
| requestJson<{ ok: boolean }>('/api/admin/change-password', { | |
| method: 'POST', | |
| body: JSON.stringify({ current_password: currentPassword, new_password: newPassword }), | |
| }), | |
| listUsers: () => requestJson<AdminUserRow[]>('/api/admin/users'), | |
| updateUserRole: (userId: string, role: 'admin' | 'user') => | |
| requestJson(`/api/admin/users/${encodeURIComponent(userId)}/role`, { | |
| method: 'PATCH', | |
| body: JSON.stringify({ role }), | |
| }), | |
| deleteUser: (userId: string) => | |
| requestJson(`/api/admin/users/${encodeURIComponent(userId)}`, { method: 'DELETE' }), | |
| listZones: () => requestJson<AdminZonesResponse>('/api/admin/zones'), | |
| reassignZoneOwner: (zoneName: string, ownerId: string) => | |
| requestJson(`/api/admin/zones/${encodeURIComponent(zoneName)}/owner`, { | |
| method: 'PATCH', | |
| body: JSON.stringify({ owner_id: ownerId }), | |
| }), | |
| createZoneForUser: (name: string, description: string, ownerId?: string) => { | |
| const form = new FormData(); | |
| form.append('name', name); | |
| form.append('description', description); | |
| if (ownerId) form.append('owner_id', ownerId); | |
| return requestJson('/api/zones', { method: 'POST', body: form }); | |
| }, | |
| deleteZoneByName: (zoneName: string) => | |
| requestJson(`/api/zones/${encodeURIComponent(zoneName)}`, { method: 'DELETE' }), | |
| listContacts: () => requestJson<AdminContactListResponse>('/api/admin/contacts'), | |
| replyContact: (msgId: string, reply: string) => | |
| requestJson<{ ok: boolean; item: AdminContactMessage }>( | |
| `/api/admin/contacts/${encodeURIComponent(msgId)}/reply`, | |
| { method: 'POST', body: JSON.stringify({ reply }) }, | |
| ), | |
| deleteContact: (msgId: string) => | |
| requestJson<{ ok: boolean }>(`/api/admin/contacts/${encodeURIComponent(msgId)}`, { | |
| method: 'DELETE', | |
| }), | |
| }; | |