From 5159c2864ac2687acecf8edda6c3e78bf23130ce Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Wed, 20 May 2026 23:07:36 +0000 Subject: [PATCH] feat(ui): add usageApi.getMySources/getAdminSources + i18n strings Refs: #9862 Signed-off-by: Ettore Di Giacinto --- .../react-ui/public/locales/en/admin.json | 24 ++++++++++++++++++- core/http/react-ui/src/utils/api.js | 8 +++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/core/http/react-ui/public/locales/en/admin.json b/core/http/react-ui/public/locales/en/admin.json index a76ef8df1..4b5ce0bb0 100644 --- a/core/http/react-ui/public/locales/en/admin.json +++ b/core/http/react-ui/public/locales/en/admin.json @@ -53,7 +53,29 @@ }, "usage": { "title": "Usage", - "subtitle": "API token usage statistics" + "subtitle": "API token usage statistics", + "sources": { + "tab": "Sources", + "mixTitle": "Source mix", + "ribbonAria": "{{apikey}}% API keys, {{web}}% Web UI, {{legacy}}% Legacy", + "topSources": "Top sources over time", + "searchPlaceholder": "Search by name or prefix", + "sortBy": "Sort", + "sortTokens": "Tokens", + "sortRequests": "Requests", + "sortLastUsed": "Last used", + "sortName": "Name", + "webUI": "Web UI", + "legacy": "Legacy", + "revoked": "revoked", + "filteredTo": "Filtered to: {{name}}", + "clearFilter": "Clear filter", + "other": "Other ({{count}})", + "noTrafficShort": "No requests in this period.", + "noKeysYet": "Once requests come in, you'll see them broken down here.", + "createKey": "Create your first API key", + "truncatedWarning": "Showing top 200 keys. Apply a filter to narrow further." + } }, "explorer": { "title": "Explorer", diff --git a/core/http/react-ui/src/utils/api.js b/core/http/react-ui/src/utils/api.js index 78f0b4f68..a8ffa2f04 100644 --- a/core/http/react-ui/src/utils/api.js +++ b/core/http/react-ui/src/utils/api.js @@ -422,6 +422,14 @@ export const usageApi = { if (userId) url += `&user_id=${encodeURIComponent(userId)}` return fetchJSON(url) }, + getMySources: (period) => + fetchJSON(`/api/auth/usage/sources?period=${period || 'month'}`), + getAdminSources: (period, userId, apiKeyId) => { + let url = `/api/auth/admin/usage/sources?period=${period || 'month'}` + if (userId) url += `&user_id=${encodeURIComponent(userId)}` + if (apiKeyId) url += `&api_key_id=${encodeURIComponent(apiKeyId)}` + return fetchJSON(url) + }, getMyQuotas: () => fetchJSON('/api/auth/quota'), }