mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add TablePage component
This commit is contained in:
parent
78f9a1f4e8
commit
ad053d6656
3 changed files with 56 additions and 28 deletions
46
src/apps/dashboard/components/TablePage.tsx
Normal file
46
src/apps/dashboard/components/TablePage.tsx
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
import Box from '@mui/material/Box/Box';
|
||||||
|
import Typography from '@mui/material/Typography/Typography';
|
||||||
|
import { type MRT_RowData, type MRT_TableInstance, MaterialReactTable } from 'material-react-table';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import Page, { type PageProps } from 'components/Page';
|
||||||
|
|
||||||
|
interface TablePageProps<T extends MRT_RowData> extends PageProps {
|
||||||
|
title: string
|
||||||
|
table: MRT_TableInstance<T>
|
||||||
|
}
|
||||||
|
|
||||||
|
const TablePage = <T extends MRT_RowData>({
|
||||||
|
title,
|
||||||
|
table,
|
||||||
|
...pageProps
|
||||||
|
}: TablePageProps<T>) => {
|
||||||
|
return (
|
||||||
|
<Page
|
||||||
|
title={title}
|
||||||
|
{...pageProps}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
className='content-primary'
|
||||||
|
sx={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
height: '100%'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
marginBottom: 1
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography variant='h2'>
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<MaterialReactTable table={table} />
|
||||||
|
</Box>
|
||||||
|
</Page>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TablePage;
|
|
@ -2,11 +2,9 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import type { ActivityLogEntry } from '@jellyfin/sdk/lib/generated-client/models/activity-log-entry';
|
import type { ActivityLogEntry } from '@jellyfin/sdk/lib/generated-client/models/activity-log-entry';
|
||||||
import { LogLevel } from '@jellyfin/sdk/lib/generated-client/models/log-level';
|
import { LogLevel } from '@jellyfin/sdk/lib/generated-client/models/log-level';
|
||||||
import type { UserDto } from '@jellyfin/sdk/lib/generated-client/models/user-dto';
|
import type { UserDto } from '@jellyfin/sdk/lib/generated-client/models/user-dto';
|
||||||
import Box from '@mui/material/Box';
|
|
||||||
import ToggleButton from '@mui/material/ToggleButton';
|
import ToggleButton from '@mui/material/ToggleButton';
|
||||||
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
|
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
|
||||||
import Typography from '@mui/material/Typography';
|
import { type MRT_ColumnDef, useMaterialReactTable } from 'material-react-table';
|
||||||
import { type MRT_ColumnDef, MaterialReactTable, useMaterialReactTable } from 'material-react-table';
|
|
||||||
import { useSearchParams } from 'react-router-dom';
|
import { useSearchParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { useLogEntries } from 'apps/dashboard/features/activity/api/useLogEntries';
|
import { useLogEntries } from 'apps/dashboard/features/activity/api/useLogEntries';
|
||||||
|
@ -15,12 +13,13 @@ import LogLevelCell from 'apps/dashboard/features/activity/components/LogLevelCe
|
||||||
import OverviewCell from 'apps/dashboard/features/activity/components/OverviewCell';
|
import OverviewCell from 'apps/dashboard/features/activity/components/OverviewCell';
|
||||||
import UserAvatarButton from 'apps/dashboard/features/activity/components/UserAvatarButton';
|
import UserAvatarButton from 'apps/dashboard/features/activity/components/UserAvatarButton';
|
||||||
import type { ActivityLogEntryCell } from 'apps/dashboard/features/activity/types/ActivityLogEntryCell';
|
import type { ActivityLogEntryCell } from 'apps/dashboard/features/activity/types/ActivityLogEntryCell';
|
||||||
import Page from 'components/Page';
|
|
||||||
import { useUsers } from 'hooks/useUsers';
|
import { useUsers } from 'hooks/useUsers';
|
||||||
import { parseISO8601Date, toLocaleString } from 'scripts/datetime';
|
import { parseISO8601Date, toLocaleString } from 'scripts/datetime';
|
||||||
import globalize from 'lib/globalize';
|
import globalize from 'lib/globalize';
|
||||||
import { toBoolean } from 'utils/string';
|
import { toBoolean } from 'utils/string';
|
||||||
|
|
||||||
|
import TablePage from '../components/TablePage';
|
||||||
|
|
||||||
type UsersRecords = Record<string, UserDto>;
|
type UsersRecords = Record<string, UserDto>;
|
||||||
|
|
||||||
const DEFAULT_PAGE_SIZE = 25;
|
const DEFAULT_PAGE_SIZE = 25;
|
||||||
|
@ -229,31 +228,12 @@ const Activity = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page
|
<TablePage
|
||||||
id='serverActivityPage'
|
id='serverActivityPage'
|
||||||
title={globalize.translate('HeaderActivity')}
|
title={globalize.translate('HeaderActivity')}
|
||||||
className='mainAnimatedPage type-interior'
|
className='mainAnimatedPage type-interior'
|
||||||
>
|
table={table}
|
||||||
<Box
|
/>
|
||||||
className='content-primary'
|
|
||||||
sx={{
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
marginBottom: 1
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography variant='h2'>
|
|
||||||
{globalize.translate('HeaderActivity')}
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<MaterialReactTable table={table} />
|
|
||||||
</Box>
|
|
||||||
</Page>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React, { type FC, type PropsWithChildren, type HTMLAttributes, useEffect,
|
||||||
|
|
||||||
import viewManager from './viewManager/viewManager';
|
import viewManager from './viewManager/viewManager';
|
||||||
|
|
||||||
type PageProps = {
|
type CustomPageProps = {
|
||||||
id: string, // id is required for libraryMenu
|
id: string, // id is required for libraryMenu
|
||||||
title?: string,
|
title?: string,
|
||||||
isBackButtonEnabled?: boolean,
|
isBackButtonEnabled?: boolean,
|
||||||
|
@ -12,11 +12,13 @@ type PageProps = {
|
||||||
backDropType?: string,
|
backDropType?: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type PageProps = CustomPageProps & HTMLAttributes<HTMLDivElement>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page component that handles hiding active non-react views, triggering the required events for
|
* Page component that handles hiding active non-react views, triggering the required events for
|
||||||
* navigation and appRouter state updates, and setting the correct classes and data attributes.
|
* navigation and appRouter state updates, and setting the correct classes and data attributes.
|
||||||
*/
|
*/
|
||||||
const Page: FC<PropsWithChildren<PageProps & HTMLAttributes<HTMLDivElement>>> = ({
|
const Page: FC<PropsWithChildren<PageProps>> = ({
|
||||||
children,
|
children,
|
||||||
id,
|
id,
|
||||||
className = '',
|
className = '',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue