mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-23 00:21:28 +00:00
feat: add group filter to send logs view
- Add groupId query param to GET /api/logs endpoint - Add group filter dropdown in SendLogs component - Pass groups list and filter state from admin.vue - Update useLogs.ts to accept optional groupId parameter - Add groupId to SendRecord type - Add i18n keys and CSS for filter UI
This commit is contained in:
parent
03eef7ae89
commit
589558a20d
7 changed files with 94 additions and 16 deletions
|
|
@ -287,13 +287,15 @@ export function createAdminRoutes(): Hono<{ Bindings: Env }> {
|
|||
const s = await loadScope(c);
|
||||
if (!s) return c.json({ error: "Unauthorized" }, 401);
|
||||
const limit = Math.min(Math.max(Number(c.req.query("limit") ?? 50), 1), 100);
|
||||
if (s.scope.isSuper) {
|
||||
return c.json({ logs: await getSendLog(c.env.DB, limit) });
|
||||
}
|
||||
const logs = (await getSendLog(c.env.DB, 200))
|
||||
.filter((l) => l.groupId != null && s.scope.groupIds.has(l.groupId))
|
||||
.slice(0, limit);
|
||||
return c.json({ logs });
|
||||
const filterGroupId = c.req.query("groupId") || undefined;
|
||||
const allLogs = await getSendLog(c.env.DB, 200);
|
||||
const allowed = s.scope.isSuper
|
||||
? allLogs
|
||||
: allLogs.filter((l) => l.groupId != null && s.scope.groupIds.has(l.groupId));
|
||||
const logs = filterGroupId
|
||||
? allowed.filter((l) => l.groupId === filterGroupId)
|
||||
: allowed;
|
||||
return c.json({ logs: logs.slice(0, limit) });
|
||||
});
|
||||
|
||||
app.get("/api/logs/:id", async (c) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue