feat(system): expose platform audit log + polish audit drawers
The system_settings update, system admin promote/revoke, and
apply-default-storage-quota routes have been writing audit rows since
the prior commits, but with TenantID=0 (system-scope). The per-tenant
GET /tenants/:id/audit-log endpoint filters by tenant_id and never
returns them, so until now those rows existed only in the DB with no UI
surface. This commit closes the loop:
Backend:
- GET /api/v1/system/admin/audit-log: new SystemAdmin-gated endpoint
reusing AuditLogService.List with tenant_id=0. Same cursor-paged
shape and query params (after_id / limit / action / outcome / actor)
as the per-tenant feed, so the frontend reuses the same client logic.
- Wired through RegisterSystemAdminRoutes (mounted on the existing
adminRoutes group so it inherits the SystemAdmin() guard). The
handler dependency is optional: nil auditLogHandler skips the route,
mirroring RegisterTenantRoutes' /audit-log handling.
Frontend — new platform audit drawer in SystemSettings.vue:
- "审计日志" entry button in the section header opens a side drawer
(880px) listing system-scope events. Lazy-loaded on first open;
refresh is explicit via a button inside the drawer.
- Table columns: stacked date/time (so 50 events in the same minute
remain distinguishable), stacked actor/role, action tag, structured
target (subject key + diff line), outcome. The dead request column
(system actions don't go through middleware path capture) is dropped
in favour of richer target rendering.
- Per-action target formatters:
* system.setting_changed: subject = registry key, diff = `old → new`
(JSON-encoded, 80-char truncation). Reset shows `old → (空)`.
* tenant_storage_quota bulk apply: subject = "批量同步", diff =
"applied to N tenants (X GB)".
* system.admin_promoted / revoked: subject = "name (email)", diff
annotates idempotent / noop branches so an audit reader can tell
a real grant from a probe.
- Click-to-expand row reveals the full audit context: actor UUID,
target_user_id / target_type / target_id, and raw details JSON in
monospaced scroll-capped block. No psql round-trip needed for
forensic spot checks.
- Sticky thead pinned to the scroll container so column labels survive
long scrolls. Cells vertical-aligned middle to keep single-line tag
cells visually balanced against multi-line target cells. No zebra
stripes — the stacked content already provides row separation, and
stripes on top read as noise.
Frontend — same polish back-ported to TenantMembers.vue audit drawer:
- Same drawer width, stacked time / actor cells, structured target +
diff layout, expandable raw-details row, sticky thead, vertical-
align middle, no stripes. Refresh button reformulated as a text
button with label (was an outlined square icon-only).
- request_path column kept (rbac.access_denied carries meaningful
paths) but empty values render as a placeholder dash so they don't
read as broken.
- Diff line now covers rbac.invitation_sent / invitation_revoked role
in addition to the existing role_changed / access_denied details.
API:
- frontend/src/api/system/index.ts: listSystemAuditLog() reuses the
AuditLog / ListAuditLogParams types from @/api/tenant/audit-log
(re-exported) so consumers don't need to cross-import.
i18n (zh-CN / en-US / ko-KR / ru-RU):
- system.globalSettings.audit.*: full drawer copy + per-action labels
(system.setting_changed / admin_promoted / admin_revoked) + target
diff templates + expanded-row labels.
- tenantMember.audit.expanded.*: expanded-row labels added so the
shared drawer treatment renders cleanly under tenant scope.
This commit is contained in:
@@ -1709,6 +1709,56 @@ export default {
|
||||
confirmBody: 'Перезаписать квоту хранилища всех существующих тенантов значением {value} ГБ. Тенанты, чью квоту вручную правили эксплуатация, также будут перезаписаны. Продолжить?',
|
||||
success: 'Обновлена квота хранилища у {count} тенантов: {gb} ГБ',
|
||||
failed: 'Ошибка применения ко всем тенантам'
|
||||
},
|
||||
audit: {
|
||||
tabLabel: 'Журнал аудита',
|
||||
description:
|
||||
'События уровня платформы: изменения системных настроек, выдача/отзыв роли системного администратора, массовая синхронизация квот. Сортировка от новых к старым.',
|
||||
refresh: 'Обновить',
|
||||
retry: 'Повторить',
|
||||
loading: 'Загрузка…',
|
||||
end: 'Конец списка.',
|
||||
empty: 'Событий аудита платформы пока нет.',
|
||||
forbidden: 'Нет прав на просмотр журнала аудита платформы.',
|
||||
systemActor: 'Система',
|
||||
errors: {
|
||||
generic: 'Не удалось загрузить журнал аудита'
|
||||
},
|
||||
actorRole: {
|
||||
system_admin: 'Системный администратор'
|
||||
},
|
||||
columns: {
|
||||
time: 'Время',
|
||||
actor: 'Кто',
|
||||
action: 'Событие',
|
||||
target: 'Цель',
|
||||
path: 'Запрос',
|
||||
outcome: 'Результат'
|
||||
},
|
||||
action: {
|
||||
'system.setting_changed': 'Изменена системная настройка',
|
||||
'system.admin_promoted': 'Выдан системный администратор',
|
||||
'system.admin_revoked': 'Отозван системный администратор'
|
||||
},
|
||||
outcome: {
|
||||
success: 'Успешно',
|
||||
denied: 'Отказано'
|
||||
},
|
||||
target: {
|
||||
bulkQuota: 'Массовая синхронизация: квота хранилища по умолчанию',
|
||||
bulkQuotaDiff: 'Применено к {count} тенантам ({gb} ГБ)',
|
||||
promoteIdempotent: 'Уже системный администратор (идемпотентно)',
|
||||
revokeNoop: 'И так не был системным администратором (идемпотентно)',
|
||||
requiredRole: 'Требуемая роль: {role}',
|
||||
valueNull: '(не задано)'
|
||||
},
|
||||
expanded: {
|
||||
actorId: 'ID инициатора',
|
||||
targetUserId: 'ID целевого пользователя',
|
||||
targetType: 'Тип цели',
|
||||
targetId: 'ID цели',
|
||||
details: 'Сырые детали'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -4661,6 +4711,13 @@ export default {
|
||||
success: 'Успех',
|
||||
denied: 'Отказ',
|
||||
},
|
||||
expanded: {
|
||||
actorId: 'ID инициатора',
|
||||
targetUserId: 'ID целевого пользователя',
|
||||
targetType: 'Тип цели',
|
||||
targetId: 'ID цели',
|
||||
details: 'Сырые детали',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user