Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,104 @@
|
||||
import { LoaderFunctionArgs, useLoaderData } from "react-router";
|
||||
import { useParams } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FilterablePropertyDto } from "~/application/dtos/data/FilterablePropertyDto";
|
||||
import { PaginationDto } from "~/application/dtos/data/PaginationDto";
|
||||
import { ApplicationEvents, getApplicationEventNameKey } from "~/modules/events/types/ApplicationEvent";
|
||||
import EventsTable from "~/modules/events/components/EventsTable";
|
||||
import InputFilters from "~/components/ui/input/InputFilters";
|
||||
import EditPageLayout from "~/components/ui/layouts/EditPageLayout";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import { EventWithAttempts, getEvents } from "~/modules/events/db/events.db.server";
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
import { getFiltersFromCurrentUrl, getPaginationFromCurrentUrl } from "~/utils/helpers/RowPaginationHelper";
|
||||
import { getTenantIdFromUrl } from "~/utils/services/.server/urlService";
|
||||
import { getUsersByTenant } from "~/utils/db/users.db.server";
|
||||
import Tabs from "~/components/ui/tabs/Tabs";
|
||||
|
||||
type LoaderData = {
|
||||
title: string;
|
||||
items: EventWithAttempts[];
|
||||
pagination: PaginationDto;
|
||||
filterableProperties: FilterablePropertyDto[];
|
||||
};
|
||||
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
const tenantId = await getTenantIdFromUrl(params);
|
||||
await verifyUserHasPermission(request, "app.settings.auditTrails.view", tenantId);
|
||||
const { t } = await getTranslations(request);
|
||||
|
||||
const urlSearchParams = new URL(request.url).searchParams;
|
||||
const current = getPaginationFromCurrentUrl(urlSearchParams);
|
||||
const filterableProperties: FilterablePropertyDto[] = [
|
||||
{
|
||||
name: "name",
|
||||
title: "settings.logs.events.filters.event",
|
||||
options: ApplicationEvents.filter((f) => !f.adminOnly || !params.tenant).map((item) => {
|
||||
return {
|
||||
value: item.value,
|
||||
name: t("settings.logs.events.filters.eventOption", { eventValue: item.value, eventLabel: t(getApplicationEventNameKey(item.value)) }),
|
||||
};
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "data",
|
||||
title: "settings.logs.events.filters.data",
|
||||
},
|
||||
{
|
||||
name: "userId",
|
||||
title: "models.user.object",
|
||||
options: (await getUsersByTenant(tenantId)).map((item) => {
|
||||
return {
|
||||
value: item.id,
|
||||
name: item.email,
|
||||
};
|
||||
}),
|
||||
},
|
||||
];
|
||||
const filters = getFiltersFromCurrentUrl(request, filterableProperties);
|
||||
const { items, pagination } = await getEvents({ current, filters }, tenantId);
|
||||
|
||||
const data: LoaderData = {
|
||||
title: `${t("models.event.plural")} | ${process.env.APP_NAME}`,
|
||||
items,
|
||||
pagination,
|
||||
filterableProperties,
|
||||
};
|
||||
return data;
|
||||
};
|
||||
|
||||
export default function AppEventsRoute() {
|
||||
const { t } = useTranslation();
|
||||
const data = useLoaderData<LoaderData>();
|
||||
const params = useParams();
|
||||
|
||||
return (
|
||||
<EditPageLayout>
|
||||
<div data-ui-id="ui.settings.logs.events.page" className="space-y-2">
|
||||
<div className="flex justify-between gap-2">
|
||||
<div data-ui-id="ui.settings.logs.tabs" className="grow">
|
||||
<Tabs
|
||||
tabs={[
|
||||
{
|
||||
name: t("models.log.plural"),
|
||||
routePath: UrlUtils.getModulePath(params, "logs"),
|
||||
},
|
||||
{
|
||||
name: t("models.event.plural"),
|
||||
routePath: UrlUtils.getModulePath(params, "logs/events"),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div data-ui-id="ui.settings.logs.filters">
|
||||
<InputFilters size="sm" filters={data.filterableProperties} />
|
||||
</div>
|
||||
</div>
|
||||
<div data-ui-id="ui.settings.logs.events.table">
|
||||
<EventsTable items={data.items} pagination={data.pagination} />
|
||||
</div>
|
||||
</div>
|
||||
</EditPageLayout>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user