Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+15
-31
@@ -1,17 +1,16 @@
|
||||
import type { AdminAuditLogFilters, AdminAuditLogRow } from "@hivegrid/db/logs.server";
|
||||
import { getAdminAuditLogList, serializeAdminAuditLogsCsv } from "@hivegrid/db/logs.server";
|
||||
import type { AdminAuditLogRow } from "@hivegrid/db/logs.server";
|
||||
import { getAdminAuditLogList } from "@hivegrid/db/logs.server";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { LoaderFunctionArgs, MetaFunction, useLoaderData } from "react-router";
|
||||
import AdminAuditLogToolbar from "~/components/audit/AdminAuditLogToolbar";
|
||||
import LogsTable from "~/components/app/events/LogsTable";
|
||||
import IndexPageLayout from "~/components/ui/layouts/IndexPageLayout";
|
||||
import { AdminPageHeader } from "~/components/screens/admin/AdminPageHeader";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
import { getFiltersFromCurrentUrl, getPaginationFromCurrentUrl } from "~/utils/helpers/RowPaginationHelper";
|
||||
import { PaginationDto } from "~/application/dtos/data/PaginationDto";
|
||||
import { FilterablePropertyDto } from "~/application/dtos/data/FilterablePropertyDto";
|
||||
|
||||
const CSV_EXPORT_TAKE = 500;
|
||||
import { getAdminAuditLogFiltersFromUrl } from "./audit-trails.helpers.server";
|
||||
|
||||
type LoaderData = {
|
||||
title: string;
|
||||
@@ -27,17 +26,7 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||
const filterableProperties = getAuditLogFilterableProperties();
|
||||
const filters = getFiltersFromCurrentUrl(request, filterableProperties);
|
||||
const urlSearchParams = new URL(request.url).searchParams;
|
||||
const auditLogFilters = getAuditLogFiltersFromUrl(urlSearchParams);
|
||||
|
||||
if (urlSearchParams.get("export") === "csv") {
|
||||
const { rows } = await getAdminAuditLogList({ ...auditLogFilters, take: CSV_EXPORT_TAKE, skip: 0 });
|
||||
return new Response(serializeAdminAuditLogsCsv(rows), {
|
||||
headers: {
|
||||
"Content-Type": "text/csv; charset=utf-8",
|
||||
"Content-Disposition": 'attachment; filename="admin-audit-logs.csv"',
|
||||
},
|
||||
});
|
||||
}
|
||||
const auditLogFilters = getAdminAuditLogFiltersFromUrl(urlSearchParams);
|
||||
|
||||
const currentPagination = getPaginationFromCurrentUrl(urlSearchParams);
|
||||
const pageSize = normalizePositiveInteger(currentPagination.pageSize, 10);
|
||||
@@ -93,18 +82,6 @@ function getAuditLogFilterableProperties(): FilterablePropertyDto[] {
|
||||
];
|
||||
}
|
||||
|
||||
function getAuditLogFiltersFromUrl(urlSearchParams: URLSearchParams): AdminAuditLogFilters {
|
||||
return {
|
||||
q: urlSearchParams.get("q"),
|
||||
action: urlSearchParams.get("action"),
|
||||
url: urlSearchParams.get("url"),
|
||||
tenantId: urlSearchParams.get("tenantId"),
|
||||
userId: urlSearchParams.get("userId"),
|
||||
createdAtFrom: urlSearchParams.get("createdAtFrom"),
|
||||
createdAtTo: urlSearchParams.get("createdAtTo"),
|
||||
};
|
||||
}
|
||||
|
||||
function normalizePositiveInteger(value: number | null | undefined, fallback: number): number {
|
||||
if (!Number.isFinite(value) || !value || value < 1) return fallback;
|
||||
return Math.trunc(value);
|
||||
@@ -117,8 +94,15 @@ export default function Events() {
|
||||
const data = useLoaderData<LoaderData>();
|
||||
|
||||
return (
|
||||
<IndexPageLayout title={t("models.log.plural")} buttons={<AdminAuditLogToolbar filters={data.filterableProperties} />}>
|
||||
<LogsTable withTenant={true} items={data.items} pagination={data.pagination} />
|
||||
</IndexPageLayout>
|
||||
<div className="flex w-full flex-col">
|
||||
<AdminPageHeader
|
||||
title={t("models.log.plural")}
|
||||
description={t("admin.auditTrails.pageDescription")}
|
||||
actions={<AdminAuditLogToolbar filters={data.filterableProperties} />}
|
||||
/>
|
||||
<div className="mobile:px-4 w-full space-y-2 px-6 py-6">
|
||||
<LogsTable withTenant={true} items={data.items} pagination={data.pagination} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user