Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite devices dashboard page in react #6489

Merged
merged 14 commits into from
Feb 13, 2025
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { UserDto } from '@jellyfin/sdk/lib/generated-client/models/user-dto';
import type { SxProps, Theme } from '@mui/material';
import IconButton from '@mui/material/IconButton/IconButton';
import React, { type FC } from 'react';
import { Link } from 'react-router-dom';
Expand All @@ -7,14 +8,21 @@ import UserAvatar from 'components/UserAvatar';

interface UserAvatarButtonProps {
user?: UserDto
sx?: SxProps<Theme>
}

const UserAvatarButton: FC<UserAvatarButtonProps> = ({ user }) => (
const UserAvatarButton: FC<UserAvatarButtonProps> = ({
user,
sx
}) => (
user?.Id ? (
<IconButton
size='large'
color='inherit'
sx={{ padding: 0 }}
sx={{
padding: 0,
...sx
}}
title={user.Name || undefined}
component={Link}
to={`/dashboard/users/profile?userId=${user.Id}`}
Expand Down
17 changes: 17 additions & 0 deletions src/apps/dashboard/components/table/DateTimeCell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import format from 'date-fns/format';
import type { MRT_Cell, MRT_RowData } from 'material-react-table';
import { FC } from 'react';

import { useLocale } from 'hooks/useLocale';

interface CellProps {
cell: MRT_Cell<MRT_RowData>
}

const DateTimeCell: FC<CellProps> = ({ cell }) => {
const { dateFnsLocale } = useLocale();

return format(cell.getValue<Date>(), 'Pp', { locale: dateFnsLocale });
};

export default DateTimeCell;
63 changes: 63 additions & 0 deletions src/apps/dashboard/components/table/TablePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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>
}

export const DEFAULT_TABLE_OPTIONS = {
// Enable custom features
enableColumnPinning: true,
enableColumnResizing: true,

// Sticky header/footer
enableStickyFooter: true,
enableStickyHeader: true,
muiTableContainerProps: {
sx: {
maxHeight: 'calc(100% - 7rem)' // 2 x 3.5rem for header and footer
}
}
};

const TablePage = <T extends MRT_RowData>({
title,
table,
children,
...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>
{children}
</Page>
);
};

export default TablePage;
23 changes: 0 additions & 23 deletions src/apps/dashboard/controllers/devices/device.html

This file was deleted.

54 changes: 0 additions & 54 deletions src/apps/dashboard/controllers/devices/device.js

This file was deleted.

21 changes: 0 additions & 21 deletions src/apps/dashboard/controllers/devices/devices.html

This file was deleted.

171 changes: 0 additions & 171 deletions src/apps/dashboard/controllers/devices/devices.js

This file was deleted.

Loading
Loading