feat(audit): add audit log support for APIs and WebUI dashboard

This commit is contained in:
yiling
2026-08-01 10:39:31 +08:00
parent 7a83f7d406
commit 118107ebc9
58 changed files with 4298 additions and 23 deletions
@@ -0,0 +1,387 @@
import { useEffect, useState } from 'react'
import { useInfiniteQuery, useQuery } from '@tanstack/react-query'
import { useInView } from 'react-intersection-observer'
import { client } from '@/ui/api/client'
import { m } from '@/ui/paraglide/messages.js'
import { AuditAction } from '@shumai/dtos'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/ui/components/ui/card'
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from '@/ui/components/ui/table'
import { Avatar, AvatarFallback, AvatarImage } from '@/ui/components/ui/avatar'
import { Badge } from '@/ui/components/ui/badge'
import { Input } from '@/ui/components/ui/input'
import { Button } from '@/ui/components/ui/button'
import { Popover, PopoverContent, PopoverTrigger } from '@/ui/components/ui/popover'
import { Checkbox } from '@/ui/components/ui/checkbox'
import { Loader2, Search, Filter, Activity, X } from 'lucide-react'
import { formatTimeAgo } from '@/ui/lib/time'
const ALL_AUDIT_ACTIONS = Object.values(AuditAction)
interface MemberInfo {
id: string
userId?: string
name?: string
image?: string
user?: {
id: string
name?: string
image?: string
}
}
interface AuditLogsDashboardProps {
teamId: string
}
export function AuditLogsDashboard({ teamId }: AuditLogsDashboardProps) {
const [selectedActions, setSelectedActions] = useState<AuditAction[]>([])
const [selectedUserIds, setSelectedUserIds] = useState<string[]>([])
const [itemIdFilter, setItemIdFilter] = useState<string>('')
const { ref: loadMoreRef, inView } = useInView()
// Fetch team members for user filter options
const { data: membersData } = useQuery({
queryKey: ['teams', teamId, 'members'],
queryFn: async () => {
const res = await client.api.teams[':teamId'].members.$get({
param: { teamId },
query: {},
})
if (!res.ok) return []
return (await res.json()) as MemberInfo[]
},
enabled: !!teamId,
})
const teamMembers = membersData || []
// Infinite query for audit logs
const { data, isLoading, isError, fetchNextPage, hasNextPage, isFetchingNextPage } =
useInfiniteQuery({
queryKey: ['teams', teamId, 'audit-logs', selectedActions, selectedUserIds, itemIdFilter],
queryFn: async ({ pageParam }) => {
const res = await client.api.teams[':teamId']['audit-logs'].$get({
param: { teamId },
query: {
first: '20',
after: pageParam ? String(pageParam) : undefined,
actions: selectedActions.length > 0 ? selectedActions : undefined,
userIds: selectedUserIds.length > 0 ? selectedUserIds : undefined,
itemId: itemIdFilter.trim() || undefined,
},
})
if (!res.ok) throw new Error('Failed to fetch audit logs')
return await res.json()
},
initialPageParam: '',
getNextPageParam: (lastPage) => lastPage.pageInfo.endCursor || undefined,
enabled: !!teamId,
})
useEffect(() => {
if (inView && hasNextPage && !isFetchingNextPage) {
fetchNextPage()
}
}, [inView, hasNextPage, isFetchingNextPage, fetchNextPage])
const allLogs = data?.pages.flatMap((page) => page.nodes) || []
const totalCount = data?.pages[0]?.total ?? 0
const toggleAction = (action: AuditAction) => {
setSelectedActions((prev) =>
prev.includes(action) ? prev.filter((a) => a !== action) : [...prev, action],
)
}
const toggleUser = (userId: string) => {
setSelectedUserIds((prev) =>
prev.includes(userId) ? prev.filter((u) => u !== userId) : [...prev, userId],
)
}
const getActionBadge = (action: string) => {
if (action.includes('delete') || action.includes('remove') || action.includes('revoke')) {
return (
<Badge
variant="outline"
className="bg-destructive/10 text-destructive border-destructive/20 font-mono text-xs"
>
{action}
</Badge>
)
}
if (action.includes('create') || action.includes('add')) {
return (
<Badge
variant="outline"
className="bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 font-mono text-xs"
>
{action}
</Badge>
)
}
if (action.includes('update') || action.includes('reparent') || action.includes('copy')) {
return (
<Badge
variant="outline"
className="bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 font-mono text-xs"
>
{action}
</Badge>
)
}
return (
<Badge
variant="outline"
className="bg-muted text-muted-foreground border-border font-mono text-xs"
>
{action}
</Badge>
)
}
const memberMap = new Map(teamMembers.map((m) => [m.userId || m.id, m]))
return (
<div className="space-y-6">
<Card className="border border-border/50 shadow-xs">
<CardHeader className="pb-4">
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4">
<div>
<CardTitle className="text-xl font-bold flex items-center gap-2">
<Activity className="h-5 w-5 text-primary" />
{m.audit_logs()}
</CardTitle>
<CardDescription className="mt-1">{m.audit_logs_description()}</CardDescription>
</div>
{totalCount > 0 && (
<Badge variant="secondary" className="w-fit text-xs font-normal">
{totalCount} {m.audit_logs()}
</Badge>
)}
</div>
{/* Filter Bar */}
<div className="mt-4 flex flex-wrap items-center gap-3 pt-4 border-t border-border/40">
{/* Action Multi-select */}
<Popover>
<PopoverTrigger asChild>
<Button variant="outline" size="sm" className="h-9 gap-2 text-xs border-dashed">
<Filter className="h-3.5 w-3.5" />
{m.filter_by_action()}
{selectedActions.length > 0 && (
<Badge variant="secondary" className="ml-1 px-1.5 py-0 text-[10px]">
{selectedActions.length}
</Badge>
)}
</Button>
</PopoverTrigger>
<PopoverContent className="w-64 p-2" align="start">
<div className="text-xs font-semibold text-muted-foreground px-2 py-1 mb-1">
{m.select_actions()}
</div>
<div className="max-h-60 overflow-y-auto space-y-1 pr-1">
{ALL_AUDIT_ACTIONS.map((act) => (
<label
key={act}
className="flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs"
>
<Checkbox
checked={selectedActions.includes(act)}
onCheckedChange={() => toggleAction(act)}
/>
<span className="font-mono">{act}</span>
</label>
))}
</div>
{selectedActions.length > 0 && (
<Button
variant="ghost"
size="sm"
className="w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground"
onClick={() => setSelectedActions([])}
>
Clear Actions
</Button>
)}
</PopoverContent>
</Popover>
{/* User Multi-select */}
<Popover>
<PopoverTrigger asChild>
<Button variant="outline" size="sm" className="h-9 gap-2 text-xs border-dashed">
<Filter className="h-3.5 w-3.5" />
{m.filter_by_user()}
{selectedUserIds.length > 0 && (
<Badge variant="secondary" className="ml-1 px-1.5 py-0 text-[10px]">
{selectedUserIds.length}
</Badge>
)}
</Button>
</PopoverTrigger>
<PopoverContent className="w-64 p-2" align="start">
<div className="text-xs font-semibold text-muted-foreground px-2 py-1 mb-1">
{m.select_users()}
</div>
<div className="max-h-60 overflow-y-auto space-y-1 pr-1">
{teamMembers.map((member) => {
const uId = member.userId || member.user?.id || member.id
const uName = member.user?.name || member.name || uId
const uImage = member.user?.image || member.image
return (
<label
key={uId}
className="flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs"
>
<Checkbox
checked={selectedUserIds.includes(uId)}
onCheckedChange={() => toggleUser(uId)}
/>
<Avatar className="h-5 w-5">
<AvatarImage src={uImage || undefined} />
<AvatarFallback className="text-[10px]">
{uName.slice(0, 2).toUpperCase()}
</AvatarFallback>
</Avatar>
<span className="truncate">{uName}</span>
</label>
)
})}
</div>
{selectedUserIds.length > 0 && (
<Button
variant="ghost"
size="sm"
className="w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground"
onClick={() => setSelectedUserIds([])}
>
Clear Users
</Button>
)}
</PopoverContent>
</Popover>
{/* Item ID Input */}
<div className="relative flex-1 min-w-[200px] max-w-xs">
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
<Input
type="text"
placeholder={m.search_item_id()}
value={itemIdFilter}
onChange={(e) => setItemIdFilter(e.target.value)}
className="pl-8 pr-8 h-9 text-xs"
/>
{itemIdFilter && (
<button
onClick={() => setItemIdFilter('')}
className="absolute right-2.5 top-2.5 text-muted-foreground hover:text-foreground"
>
<X className="h-4 w-4" />
</button>
)}
</div>
{/* Reset All Filters */}
{(selectedActions.length > 0 || selectedUserIds.length > 0 || itemIdFilter) && (
<Button
variant="ghost"
size="sm"
className="h-9 px-2 text-xs text-muted-foreground hover:text-foreground"
onClick={() => {
setSelectedActions([])
setSelectedUserIds([])
setItemIdFilter('')
}}
>
Clear all
</Button>
)}
</div>
</CardHeader>
<CardContent className="p-0">
{isLoading ? (
<div className="flex h-64 items-center justify-center">
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
</div>
) : isError ? (
<div className="p-8 text-center text-sm text-destructive">
Failed to load audit logs.
</div>
) : allLogs.length === 0 ? (
<div className="p-12 text-center text-sm text-muted-foreground">
{m.no_audit_logs()}
</div>
) : (
<Table>
<TableHeader>
<TableRow className="hover:bg-transparent border-b border-border/50">
<TableHead className="w-[180px] text-xs font-semibold">{m.action()}</TableHead>
<TableHead className="w-[200px] text-xs font-semibold">{m.user()}</TableHead>
<TableHead className="text-xs font-semibold">{m.item_id()}</TableHead>
<TableHead className="text-xs font-semibold">{m.project_id()}</TableHead>
<TableHead className="w-[160px] text-right text-xs font-semibold">
{m.timestamp()}
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{allLogs.map((log) => {
const member = log.userId ? memberMap.get(log.userId) : null
const userName = member?.user?.name || member?.name || log.userId || 'System'
const userImage = member?.user?.image || member?.image
return (
<TableRow key={log.id} className="hover:bg-muted/40 transition-colors">
<TableCell className="py-3 font-medium">
{getActionBadge(log.action)}
</TableCell>
<TableCell className="py-3">
<div className="flex items-center gap-2">
<Avatar className="h-6 w-6">
<AvatarImage src={userImage || undefined} />
<AvatarFallback className="text-[10px]">
{userName.slice(0, 2).toUpperCase()}
</AvatarFallback>
</Avatar>
<span className="text-xs font-medium text-foreground truncate max-w-[140px]">
{userName}
</span>
</div>
</TableCell>
<TableCell className="py-3 text-xs font-mono text-muted-foreground">
{log.itemId || '-'}
</TableCell>
<TableCell className="py-3 text-xs font-mono text-muted-foreground">
{log.projectId || '-'}
</TableCell>
<TableCell className="py-3 text-right text-xs text-muted-foreground">
{formatTimeAgo(log.createdAt)}
</TableCell>
</TableRow>
)
})}
</TableBody>
</Table>
)}
{/* Infinite Scroll sentinel */}
<div ref={loadMoreRef} className="py-4 flex justify-center">
{isFetchingNextPage && (
<Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
)}
</div>
</CardContent>
</Card>
</div>
)
}
+16 -1
View File
@@ -896,5 +896,20 @@
"session_type_comment": "Comment",
"session_type_chat": "Chat",
"session_type_naming": "Naming",
"untitled_session": "Untitled Session"
"untitled_session": "Untitled Session",
"team_category": "Team",
"audit_logs": "Audit Logs",
"audit_logs_description": "View and monitor all audit logs of team actions.",
"filter_by_action": "Filter by Action",
"filter_by_user": "Filter by User",
"filter_by_item_id": "Filter by Item ID",
"action": "Action",
"user": "User",
"item_id": "Item ID",
"project_id": "Project ID",
"timestamp": "Timestamp",
"no_audit_logs": "No audit logs found",
"search_item_id": "Search Item ID...",
"select_actions": "Select Actions",
"select_users": "Select Users"
}
+16 -1
View File
@@ -896,5 +896,20 @@
"session_type_comment": "评论",
"session_type_chat": "对话",
"session_type_naming": "命名",
"untitled_session": "未命名会话"
"untitled_session": "未命名会话",
"team_category": "团队",
"audit_logs": "审计日志",
"audit_logs_description": "查看并监控团队操作的所有审计日志。",
"filter_by_action": "按操作筛选",
"filter_by_user": "按用户筛选",
"filter_by_item_id": "按项目/条目 ID 筛选",
"action": "操作",
"user": "用户",
"item_id": "条目 ID",
"project_id": "项目 ID",
"timestamp": "时间戳",
"no_audit_logs": "未找到审计日志",
"search_item_id": "搜索条目 ID...",
"select_actions": "选择操作",
"select_users": "选择用户"
}
+15
View File
@@ -842,4 +842,19 @@ export * from "./session_type_comment.js";
export * from "./session_type_chat.js";
export * from "./session_type_naming.js";
export * from "./untitled_session.js";
export * from "./team_category.js";
export * from "./audit_logs.js";
export * from "./audit_logs_description.js";
export * from "./filter_by_action.js";
export * from "./filter_by_user.js";
export * from "./filter_by_item_id.js";
export * from "./action.js";
export * from "./user.js";
export * from "./item_id.js";
export * from "./project_id.js";
export * from "./timestamp.js";
export * from "./no_audit_logs.js";
export * from "./search_item_id.js";
export * from "./select_actions.js";
export * from "./select_users.js";
export type LocalizedString = import("../runtime.js").LocalizedString;
+16 -1
View File
@@ -843,4 +843,19 @@ export * from './no_sessions_found.js'
export * from './session_type_comment.js'
export * from './session_type_chat.js'
export * from './session_type_naming.js'
export * from './untitled_session.js'
export * from './untitled_session.js'
export * from './team_category.js'
export * from './audit_logs.js'
export * from './audit_logs_description.js'
export * from './filter_by_action.js'
export * from './filter_by_user.js'
export * from './filter_by_item_id.js'
export * from './action.js'
export * from './user.js'
export * from './item_id.js'
export * from './project_id.js'
export * from './timestamp.js'
export * from './no_audit_logs.js'
export * from './search_item_id.js'
export * from './select_actions.js'
export * from './select_users.js'
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Action" |
*
* @param {ActionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const action: ((inputs?: ActionInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<ActionInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type ActionInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} ActionInputs */
const en_action = /** @type {(inputs: ActionInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Action`)
};
const zh_action = /** @type {(inputs: ActionInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`操作`)
};
/**
* | output |
* | --- |
* | "Action" |
*
* @param {ActionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const action = /** @type {((inputs?: ActionInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<ActionInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_action(inputs)
return zh_action(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Audit Logs" |
*
* @param {Audit_LogsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const audit_logs: ((inputs?: Audit_LogsInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Audit_LogsInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Audit_LogsInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Audit_LogsInputs */
const en_audit_logs = /** @type {(inputs: Audit_LogsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Audit Logs`)
};
const zh_audit_logs = /** @type {(inputs: Audit_LogsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`审计日志`)
};
/**
* | output |
* | --- |
* | "Audit Logs" |
*
* @param {Audit_LogsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const audit_logs = /** @type {((inputs?: Audit_LogsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Audit_LogsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_audit_logs(inputs)
return zh_audit_logs(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "View and monitor all audit logs of team actions." |
*
* @param {Audit_Logs_DescriptionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const audit_logs_description: ((inputs?: Audit_Logs_DescriptionInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Audit_Logs_DescriptionInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Audit_Logs_DescriptionInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Audit_Logs_DescriptionInputs */
const en_audit_logs_description = /** @type {(inputs: Audit_Logs_DescriptionInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`View and monitor all audit logs of team actions.`)
};
const zh_audit_logs_description = /** @type {(inputs: Audit_Logs_DescriptionInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`查看并监控团队操作的所有审计日志。`)
};
/**
* | output |
* | --- |
* | "View and monitor all audit logs of team actions." |
*
* @param {Audit_Logs_DescriptionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const audit_logs_description = /** @type {((inputs?: Audit_Logs_DescriptionInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Audit_Logs_DescriptionInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_audit_logs_description(inputs)
return zh_audit_logs_description(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Filter by Action" |
*
* @param {Filter_By_ActionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const filter_by_action: ((inputs?: Filter_By_ActionInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Filter_By_ActionInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Filter_By_ActionInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Filter_By_ActionInputs */
const en_filter_by_action = /** @type {(inputs: Filter_By_ActionInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Filter by Action`)
};
const zh_filter_by_action = /** @type {(inputs: Filter_By_ActionInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`按操作筛选`)
};
/**
* | output |
* | --- |
* | "Filter by Action" |
*
* @param {Filter_By_ActionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const filter_by_action = /** @type {((inputs?: Filter_By_ActionInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Filter_By_ActionInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_filter_by_action(inputs)
return zh_filter_by_action(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Filter by Item ID" |
*
* @param {Filter_By_Item_IdInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const filter_by_item_id: ((inputs?: Filter_By_Item_IdInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Filter_By_Item_IdInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Filter_By_Item_IdInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Filter_By_Item_IdInputs */
const en_filter_by_item_id = /** @type {(inputs: Filter_By_Item_IdInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Filter by Item ID`)
};
const zh_filter_by_item_id = /** @type {(inputs: Filter_By_Item_IdInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`按项目/条目 ID 筛选`)
};
/**
* | output |
* | --- |
* | "Filter by Item ID" |
*
* @param {Filter_By_Item_IdInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const filter_by_item_id = /** @type {((inputs?: Filter_By_Item_IdInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Filter_By_Item_IdInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_filter_by_item_id(inputs)
return zh_filter_by_item_id(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Filter by User" |
*
* @param {Filter_By_UserInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const filter_by_user: ((inputs?: Filter_By_UserInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Filter_By_UserInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Filter_By_UserInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Filter_By_UserInputs */
const en_filter_by_user = /** @type {(inputs: Filter_By_UserInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Filter by User`)
};
const zh_filter_by_user = /** @type {(inputs: Filter_By_UserInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`按用户筛选`)
};
/**
* | output |
* | --- |
* | "Filter by User" |
*
* @param {Filter_By_UserInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const filter_by_user = /** @type {((inputs?: Filter_By_UserInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Filter_By_UserInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_filter_by_user(inputs)
return zh_filter_by_user(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Item ID" |
*
* @param {Item_IdInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const item_id: ((inputs?: Item_IdInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Item_IdInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Item_IdInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Item_IdInputs */
const en_item_id = /** @type {(inputs: Item_IdInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Item ID`)
};
const zh_item_id = /** @type {(inputs: Item_IdInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`条目 ID`)
};
/**
* | output |
* | --- |
* | "Item ID" |
*
* @param {Item_IdInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const item_id = /** @type {((inputs?: Item_IdInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Item_IdInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_item_id(inputs)
return zh_item_id(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "No audit logs found" |
*
* @param {No_Audit_LogsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const no_audit_logs: ((inputs?: No_Audit_LogsInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<No_Audit_LogsInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type No_Audit_LogsInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} No_Audit_LogsInputs */
const en_no_audit_logs = /** @type {(inputs: No_Audit_LogsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`No audit logs found`)
};
const zh_no_audit_logs = /** @type {(inputs: No_Audit_LogsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`未找到审计日志`)
};
/**
* | output |
* | --- |
* | "No audit logs found" |
*
* @param {No_Audit_LogsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const no_audit_logs = /** @type {((inputs?: No_Audit_LogsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<No_Audit_LogsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_no_audit_logs(inputs)
return zh_no_audit_logs(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Project ID" |
*
* @param {Project_IdInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const project_id: ((inputs?: Project_IdInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Project_IdInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Project_IdInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Project_IdInputs */
const en_project_id = /** @type {(inputs: Project_IdInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Project ID`)
};
const zh_project_id = /** @type {(inputs: Project_IdInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`项目 ID`)
};
/**
* | output |
* | --- |
* | "Project ID" |
*
* @param {Project_IdInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const project_id = /** @type {((inputs?: Project_IdInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Project_IdInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_project_id(inputs)
return zh_project_id(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Search Item ID..." |
*
* @param {Search_Item_IdInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const search_item_id: ((inputs?: Search_Item_IdInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Search_Item_IdInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Search_Item_IdInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Search_Item_IdInputs */
const en_search_item_id = /** @type {(inputs: Search_Item_IdInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Search Item ID...`)
};
const zh_search_item_id = /** @type {(inputs: Search_Item_IdInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`搜索条目 ID...`)
};
/**
* | output |
* | --- |
* | "Search Item ID..." |
*
* @param {Search_Item_IdInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const search_item_id = /** @type {((inputs?: Search_Item_IdInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Search_Item_IdInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_search_item_id(inputs)
return zh_search_item_id(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Select Actions" |
*
* @param {Select_ActionsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const select_actions: ((inputs?: Select_ActionsInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Select_ActionsInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Select_ActionsInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Select_ActionsInputs */
const en_select_actions = /** @type {(inputs: Select_ActionsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Select Actions`)
};
const zh_select_actions = /** @type {(inputs: Select_ActionsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`选择操作`)
};
/**
* | output |
* | --- |
* | "Select Actions" |
*
* @param {Select_ActionsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const select_actions = /** @type {((inputs?: Select_ActionsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Select_ActionsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_select_actions(inputs)
return zh_select_actions(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Select Users" |
*
* @param {Select_UsersInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const select_users: ((inputs?: Select_UsersInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Select_UsersInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Select_UsersInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Select_UsersInputs */
const en_select_users = /** @type {(inputs: Select_UsersInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Select Users`)
};
const zh_select_users = /** @type {(inputs: Select_UsersInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`选择用户`)
};
/**
* | output |
* | --- |
* | "Select Users" |
*
* @param {Select_UsersInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const select_users = /** @type {((inputs?: Select_UsersInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Select_UsersInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_select_users(inputs)
return zh_select_users(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Team" |
*
* @param {Team_CategoryInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const team_category: ((inputs?: Team_CategoryInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Team_CategoryInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Team_CategoryInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Team_CategoryInputs */
const en_team_category = /** @type {(inputs: Team_CategoryInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Team`)
};
const zh_team_category = /** @type {(inputs: Team_CategoryInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`团队`)
};
/**
* | output |
* | --- |
* | "Team" |
*
* @param {Team_CategoryInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const team_category = /** @type {((inputs?: Team_CategoryInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Team_CategoryInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_team_category(inputs)
return zh_team_category(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Timestamp" |
*
* @param {TimestampInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const timestamp: ((inputs?: TimestampInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<TimestampInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type TimestampInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} TimestampInputs */
const en_timestamp = /** @type {(inputs: TimestampInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Timestamp`)
};
const zh_timestamp = /** @type {(inputs: TimestampInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`时间戳`)
};
/**
* | output |
* | --- |
* | "Timestamp" |
*
* @param {TimestampInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const timestamp = /** @type {((inputs?: TimestampInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<TimestampInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_timestamp(inputs)
return zh_timestamp(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "User" |
*
* @param {UserInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const user: ((inputs?: UserInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<UserInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type UserInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} UserInputs */
const en_user = /** @type {(inputs: UserInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`User`)
};
const zh_user = /** @type {(inputs: UserInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`用户`)
};
/**
* | output |
* | --- |
* | "User" |
*
* @param {UserInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const user = /** @type {((inputs?: UserInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<UserInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_user(inputs)
return zh_user(inputs)
});
@@ -6,13 +6,14 @@ import { cn } from '@/ui/lib/utils'
import { m } from '@/ui/paraglide/messages.js'
import { AiUsageDashboard } from '@/ui/components/dashboard/AiUsageDashboard'
import { AgentSessionsDashboard } from '@/ui/components/dashboard/AgentSessionsDashboard'
import { BarChart2, Loader2, MessagesSquare, ShieldAlert } from 'lucide-react'
import { AuditLogsDashboard } from '@/ui/components/dashboard/AuditLogsDashboard'
import { Activity, BarChart2, Loader2, MessagesSquare, ShieldAlert } from 'lucide-react'
type DashboardTab = 'ai-usage' | 'ai-sessions'
type DashboardTab = 'audit-logs' | 'ai-usage' | 'ai-sessions'
function TeamDashboardPage() {
const { teamId } = Route.useParams()
const [activeTab, setActiveTab] = useState<DashboardTab>('ai-usage')
const [activeTab, setActiveTab] = useState<DashboardTab>('audit-logs')
const { data: me, isLoading: isMeLoading } = useQuery({
queryKey: ['teams', teamId, 'me'],
@@ -54,6 +55,28 @@ function TeamDashboardPage() {
{m.dashboard()}
</div>
{/* Team Category (Above AI Category) */}
<div className="mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border">
{m.team_category()}
</div>
<button
onClick={() => setActiveTab('audit-logs')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'audit-logs'
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
)}
>
<Activity className="w-5 h-5" />
{m.audit_logs()}
{activeTab === 'audit-logs' && (
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
)}
</button>
{/* AI Category */}
<div className="mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border">
{m.ai()}
</div>
@@ -95,6 +118,7 @@ function TeamDashboardPage() {
{/* Main Content Area */}
<div className="flex-1 overflow-y-auto p-4 md:p-8">
<div className="max-w-6xl mx-auto space-y-8">
{activeTab === 'audit-logs' && <AuditLogsDashboard teamId={teamId} />}
{activeTab === 'ai-usage' && <AiUsageDashboard teamId={teamId} />}
{activeTab === 'ai-sessions' && <AgentSessionsDashboard teamId={teamId} />}
</div>