quintodrome/ui/src/player/PlayerList.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-03-12 05:38:07 -08:00
import React from 'react'
import {
Datagrid,
TextField,
DateField,
FunctionField,
ReferenceField,
2020-06-08 11:32:14 -08:00
Filter,
SearchInput,
2020-03-12 05:38:07 -08:00
} from 'react-admin'
import { useMediaQuery } from '@material-ui/core'
2020-05-15 06:20:11 -08:00
import { SimpleList, List } from '../common'
2020-03-12 05:38:07 -08:00
2020-06-08 11:32:14 -08:00
const PlayerFilter = (props) => (
<Filter {...props} variant={'outlined'}>
2020-06-08 11:32:14 -08:00
<SearchInput source="name" alwaysOn />
</Filter>
)
const PlayerList = ({ permissions, ...props }) => {
const isXsmall = useMediaQuery((theme) => theme.breakpoints.down('xs'))
return (
2020-06-08 11:32:14 -08:00
<List
{...props}
sort={{ field: 'lastSeen', order: 'DESC' }}
exporter={false}
filters={<PlayerFilter />}
>
{isXsmall ? (
<SimpleList
primaryText={(r) => r.client}
secondaryText={(r) => r.userName}
2020-05-04 16:27:09 -08:00
tertiaryText={(r) => (r.maxBitRate ? r.maxBitRate : '-')}
/>
) : (
<Datagrid rowClick="edit">
<TextField source="name" />
2020-06-08 11:32:14 -08:00
{permissions === 'admin' && <TextField source="userName" />}
<ReferenceField source="transcodingId" reference="transcoding">
<TextField source="name" />
</ReferenceField>
<FunctionField
source="maxBitRate"
2020-05-04 16:27:09 -08:00
render={(r) => (r.maxBitRate ? r.maxBitRate : '-')}
/>
<DateField source="lastSeen" showTime sortByOrder={'DESC'} />
</Datagrid>
)}
</List>
)
}
2020-03-12 05:38:07 -08:00
export default PlayerList