mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 04:57:37 +03:00
Add more options to Players list
This commit is contained in:
parent
84ed3eb427
commit
c9bcb333ae
3 changed files with 23 additions and 2 deletions
|
@ -19,6 +19,9 @@ func NewPlayerRepository(ctx context.Context, o orm.Ormer) model.PlayerRepositor
|
|||
r.ctx = ctx
|
||||
r.ormer = o
|
||||
r.tableName = "player"
|
||||
r.filterMappings = map[string]filterFunc{
|
||||
"name": containsFilter,
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,10 @@ func startsWithFilter(field string, value interface{}) Sqlizer {
|
|||
return Like{field: fmt.Sprintf("%s%%", value)}
|
||||
}
|
||||
|
||||
func containsFilter(field string, value interface{}) Sqlizer {
|
||||
return Like{field: fmt.Sprintf("%%%s%%", value)}
|
||||
}
|
||||
|
||||
func booleanFilter(field string, value interface{}) Sqlizer {
|
||||
v := strings.ToLower(value.(string))
|
||||
return Eq{field: strings.ToLower(v) == "true"}
|
||||
|
|
|
@ -5,14 +5,27 @@ import {
|
|||
DateField,
|
||||
FunctionField,
|
||||
ReferenceField,
|
||||
Filter,
|
||||
SearchInput,
|
||||
} from 'react-admin'
|
||||
import { useMediaQuery } from '@material-ui/core'
|
||||
import { SimpleList, List } from '../common'
|
||||
|
||||
const PlayerList = (props) => {
|
||||
const PlayerFilter = (props) => (
|
||||
<Filter {...props}>
|
||||
<SearchInput source="name" alwaysOn />
|
||||
</Filter>
|
||||
)
|
||||
|
||||
const PlayerList = ({ permissions, ...props }) => {
|
||||
const isXsmall = useMediaQuery((theme) => theme.breakpoints.down('xs'))
|
||||
return (
|
||||
<List exporter={false} {...props}>
|
||||
<List
|
||||
{...props}
|
||||
sort={{ field: 'lastSeen', order: 'DESC' }}
|
||||
exporter={false}
|
||||
filters={<PlayerFilter />}
|
||||
>
|
||||
{isXsmall ? (
|
||||
<SimpleList
|
||||
primaryText={(r) => r.client}
|
||||
|
@ -22,6 +35,7 @@ const PlayerList = (props) => {
|
|||
) : (
|
||||
<Datagrid rowClick="edit">
|
||||
<TextField source="name" />
|
||||
{permissions === 'admin' && <TextField source="userName" />}
|
||||
<ReferenceField source="transcodingId" reference="transcoding">
|
||||
<TextField source="name" />
|
||||
</ReferenceField>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue