Initial support for artist browsing from UI. Also add linking between resources
This commit is contained in:
@@ -7,6 +7,7 @@ import { Login, Layout } from './layout'
|
||||
import user from './user'
|
||||
import song from './song'
|
||||
import album from './album'
|
||||
import artist from './artist'
|
||||
|
||||
const App = () => (
|
||||
<Admin
|
||||
@@ -17,6 +18,7 @@ const App = () => (
|
||||
>
|
||||
<Resource name="song" {...song} options={{ subMenu: 'library' }} />
|
||||
<Resource name="album" {...album} options={{ subMenu: 'library' }} />
|
||||
<Resource name="artist" {...artist} options={{ subMenu: 'library' }} />
|
||||
<Resource name="user" {...user} />
|
||||
</Admin>
|
||||
)
|
||||
|
||||
@@ -34,6 +34,9 @@ const AlbumDetails = (props) => {
|
||||
)
|
||||
}
|
||||
|
||||
const albumRowClick = (id, basePath, record) =>
|
||||
`/song?filter={"album_id":"${record.id}"}&order=ASC&sort=trackNumber`
|
||||
|
||||
const AlbumList = (props) => (
|
||||
<List
|
||||
{...props}
|
||||
@@ -44,7 +47,7 @@ const AlbumList = (props) => (
|
||||
filters={<AlbumFilter />}
|
||||
perPage={15}
|
||||
>
|
||||
<Datagrid expand={<AlbumDetails />}>
|
||||
<Datagrid expand={<AlbumDetails />} rowClick={albumRowClick}>
|
||||
<TextField source="name" />
|
||||
<TextField source="artist" />
|
||||
<NumberField source="songCount" />
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import React from 'react'
|
||||
import {
|
||||
Datagrid,
|
||||
Filter,
|
||||
List,
|
||||
NumberField,
|
||||
SearchInput,
|
||||
TextField
|
||||
} from 'react-admin'
|
||||
import { Title } from '../common'
|
||||
|
||||
const ArtistFilter = (props) => (
|
||||
<Filter {...props}>
|
||||
<SearchInput source="name" alwaysOn />
|
||||
</Filter>
|
||||
)
|
||||
|
||||
const artistRowClick = (id, basePath, record) =>
|
||||
`/album?filter={"artist_id":"${record.id}"}&order=ASC&sort=year`
|
||||
|
||||
const ArtistList = (props) => (
|
||||
<List
|
||||
{...props}
|
||||
title={<Title subTitle={'Artists'} />}
|
||||
sort={{ field: 'name', order: 'ASC' }}
|
||||
exporter={false}
|
||||
bulkActionButtons={false}
|
||||
filters={<ArtistFilter />}
|
||||
perPage={15}
|
||||
>
|
||||
<Datagrid rowClick={artistRowClick}>
|
||||
<TextField source="name" />
|
||||
<NumberField source="albumCount" />
|
||||
</Datagrid>
|
||||
</List>
|
||||
)
|
||||
|
||||
export default ArtistList
|
||||
@@ -0,0 +1,7 @@
|
||||
import MicIcon from '@material-ui/icons/Mic'
|
||||
import ArtistList from './ArtistList'
|
||||
|
||||
export default {
|
||||
list: ArtistList,
|
||||
icon: MicIcon
|
||||
}
|
||||
Reference in New Issue
Block a user