Show resource link in table for requests

This commit is contained in:
Owen
2025-10-22 14:58:18 -07:00
parent f2c31d3ca6
commit 7f981f05fb
3 changed files with 25 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
import { db, requestAuditLog } from "@server/db";
import { db, requestAuditLog, resources } from "@server/db";
import { registry } from "@server/openApi";
import { NextFunction } from "express";
import { Request, Response } from "express";
@@ -68,9 +68,12 @@ export function querySites(timeStart: number, timeEnd: number, orgId: string) {
host: requestAuditLog.host,
path: requestAuditLog.path,
method: requestAuditLog.method,
tls: requestAuditLog.tls,
tls: requestAuditLog.tls,
resourceName: resources.name,
resourceNiceId: resources.niceId
})
.from(requestAuditLog)
.leftJoin(resources, eq(requestAuditLog.resourceId, resources.resourceId)) // TODO: Is this efficient?
.where(
and(
gt(requestAuditLog.timestamp, timeStart),

View File

@@ -24,6 +24,8 @@ export type QueryRequestAuditLogResponse = {
actor: string | null;
actorId: string | null;
resourceId: number | null;
resourceNiceId: string | null;
resourceName: string | null;
ip: string | null;
location: string | null;
userAgent: string | null;

View File

@@ -9,7 +9,8 @@ import { useTranslations } from "next-intl";
import { LogDataTable } from "@app/components/LogDataTable";
import { ColumnDef } from "@tanstack/react-table";
import { DateTimeValue } from "@app/components/DateTimePicker";
import { Key, RouteOff, User, Lock, Unlock } from "lucide-react";
import { Key, RouteOff, User, Lock, Unlock, ArrowUpRight } from "lucide-react";
import Link from "next/link";
export default function GeneralPage() {
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
@@ -294,7 +295,22 @@ export default function GeneralPage() {
);
}
},
{
accessorKey: "resourceName",
header: t("resource"),
cell: ({ row }) => {
return (
<Link
href={`/${row.original.orgId}/settings/resources/${row.original.resourceNiceId}`}
>
<Button variant="outline" size="sm" className="text-xs h-6">
{row.original.resourceName}
<ArrowUpRight className="ml-2 h-3 w-3" />
</Button>
</Link>
);
}
},
{
accessorKey: "host",
header: ({ column }) => {