1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Fix date column label and formatting

This commit is contained in:
Bill Thornton 2025-01-30 17:36:56 -05:00
parent 38ffbd06e3
commit bd328b9202
2 changed files with 8 additions and 4 deletions

View file

@ -5,6 +5,8 @@ import Box from '@mui/material/Box/Box';
import Button from '@mui/material/Button/Button'; import Button from '@mui/material/Button/Button';
import IconButton from '@mui/material/IconButton/IconButton'; import IconButton from '@mui/material/IconButton/IconButton';
import Tooltip from '@mui/material/Tooltip/Tooltip'; import Tooltip from '@mui/material/Tooltip/Tooltip';
import format from 'date-fns/format';
import parseISO from 'date-fns/parseISO';
import { type MRT_ColumnDef, useMaterialReactTable } from 'material-react-table'; import { type MRT_ColumnDef, useMaterialReactTable } from 'material-react-table';
import React, { useCallback, useMemo, useState } from 'react'; import React, { useCallback, useMemo, useState } from 'react';
@ -17,9 +19,9 @@ import DeviceNameCell from 'apps/dashboard/features/devices/components/DeviceNam
import type { DeviceInfoCell } from 'apps/dashboard/features/devices/types/deviceInfoCell'; import type { DeviceInfoCell } from 'apps/dashboard/features/devices/types/deviceInfoCell';
import ConfirmDialog from 'components/ConfirmDialog'; import ConfirmDialog from 'components/ConfirmDialog';
import { useApi } from 'hooks/useApi'; import { useApi } from 'hooks/useApi';
import { useLocale } from 'hooks/useLocale';
import { type UsersRecords, useUsersDetails } from 'hooks/useUsers'; import { type UsersRecords, useUsersDetails } from 'hooks/useUsers';
import globalize from 'lib/globalize'; import globalize from 'lib/globalize';
import { parseISO8601Date, toLocaleString } from 'scripts/datetime';
const getUserCell = (users: UsersRecords) => function UserCell({ renderedCellValue, row }: DeviceInfoCell) { const getUserCell = (users: UsersRecords) => function UserCell({ renderedCellValue, row }: DeviceInfoCell) {
return ( return (
@ -36,6 +38,7 @@ const getUserCell = (users: UsersRecords) => function UserCell({ renderedCellVal
export const Component = () => { export const Component = () => {
const { api } = useApi(); const { api } = useApi();
const { data: devices, isLoading: isDevicesLoading } = useDevices({}); const { data: devices, isLoading: isDevicesLoading } = useDevices({});
const { dateFnsLocale } = useLocale();
const { usersById: users, names: userNames, isLoading: isUsersLoading } = useUsersDetails(); const { usersById: users, names: userNames, isLoading: isUsersLoading } = useUsersDetails();
const [ isDeleteConfirmOpen, setIsDeleteConfirmOpen ] = useState(false); const [ isDeleteConfirmOpen, setIsDeleteConfirmOpen ] = useState(false);
@ -99,10 +102,10 @@ export const Component = () => {
const columns = useMemo<MRT_ColumnDef<DeviceInfoDto>[]>(() => [ const columns = useMemo<MRT_ColumnDef<DeviceInfoDto>[]>(() => [
{ {
id: 'DateLastActivity', id: 'DateLastActivity',
accessorFn: row => parseISO8601Date(row.DateLastActivity), accessorFn: row => row.DateLastActivity ? parseISO(row.DateLastActivity) : undefined,
header: globalize.translate('LabelTime'), header: globalize.translate('LastActive'),
size: 160, size: 160,
Cell: ({ cell }) => toLocaleString(cell.getValue<Date>()), Cell: ({ cell }) => format(cell.getValue<Date>(), 'Ppp', { locale: dateFnsLocale }),
filterVariant: 'datetime-range', filterVariant: 'datetime-range',
enableEditing: false enableEditing: false
}, },

View file

@ -1007,6 +1007,7 @@
"LanNetworksHelp": "Comma separated list of IP addresses or IP/netmask entries for networks that will be considered on local network when enforcing bandwidth restrictions. If set, all other IP addresses will be considered to be on the external network and will be subject to the external bandwidth restrictions. If left blank, only the server's subnet is considered to be on the local network.", "LanNetworksHelp": "Comma separated list of IP addresses or IP/netmask entries for networks that will be considered on local network when enforcing bandwidth restrictions. If set, all other IP addresses will be considered to be on the external network and will be subject to the external bandwidth restrictions. If left blank, only the server's subnet is considered to be on the local network.",
"Large": "Large", "Large": "Large",
"Larger": "Larger", "Larger": "Larger",
"LastActive": "Last active",
"LastSeen": "Last activity {0}", "LastSeen": "Last activity {0}",
"LatestFromLibrary": "Recently Added in {0}", "LatestFromLibrary": "Recently Added in {0}",
"LearnHowYouCanContribute": "Learn how you can contribute.", "LearnHowYouCanContribute": "Learn how you can contribute.",