import { DialogContent, Table, TableBody, TableCell, TableHead, TableRow, Typography, } from "@mui/material"; import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { getFileActivity } from "../../../../api/api.ts"; import { ActivityEvent } from "../../../../api/dashboard.ts"; import { closeActivityDialog } from "../../../../redux/globalStateSlice.ts"; import { useAppDispatch, useAppSelector } from "../../../../redux/hooks.ts"; import AutoHeight from "../../../Common/AutoHeight.tsx"; import { StyledTableContainerPaper } from "../../../Common/StyledComponents.tsx"; import DraggableDialog from "../../../Dialogs/DraggableDialog.tsx"; import { getEventName } from "../../../Admin/Settings/Event/Events.tsx"; import TablePagination from "../../../Admin/Common/TablePagination.tsx"; const ActivityDialog = () => { const { t } = useTranslation(); const dispatch = useAppDispatch(); const open = useAppSelector((state) => state.globalState.activityDialogOpen); const target = useAppSelector((state) => state.globalState.activityDialogFile); const shareId = useAppSelector((state) => state.globalState.activityDialogShareId); const [events, setEvents] = useState(undefined); const [total, setTotal] = useState(0); const [page, setPage] = useState(1); const pageSize = 20; const uri = target?.path; useEffect(() => { if (!open || (!uri && !shareId)) { return; } setEvents(undefined); dispatch(getFileActivity(uri, page, pageSize, shareId)).then((res) => { setEvents(res.events); setTotal(res.total); }); }, [open, uri, page, shareId]); useEffect(() => { if (open) { setPage(1); } }, [open]); return ( dispatch(closeActivityDialog()), fullWidth: true, maxWidth: "md", }} > {t("application:fileManager.activityDes", { name: target?.name })} {t("dashboard:event.event")} {t("dashboard:event.initiator")} {t("dashboard:event.ip")} {t("dashboard:event.datetime")} {events?.map((event) => ( {t(`dashboard:settings.event.${getEventName(event.type)}`, getEventName(event.type))} {event.actor_name || event.actor_id || "-"} {event.ip || "-"} {new Date(event.created_at * 1000).toLocaleString()} ))} {events?.length === 0 && ( {t("dashboard:event.noEvents")} )}
{total > pageSize && ( setPage(value)} /> )}
); }; export default ActivityDialog;