mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-17 18:46:55 +03:00
feat: new album view (initial implementation)
This commit is contained in:
parent
d37351610a
commit
81e1a7088f
@ -34,13 +34,13 @@ const AlbumDetails = (props) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const albumRowClick = (id, basePath, record) => {
|
// const albumRowClick = (id, basePath, record) => {
|
||||||
const filter = { album: record.name, album_id: id }
|
// const filter = { album: record.name, album_id: id }
|
||||||
if (!record.compilation) {
|
// if (!record.compilation) {
|
||||||
filter.artist = record.artist
|
// filter.artist = record.artist
|
||||||
}
|
// }
|
||||||
return `/song?filter=${JSON.stringify(filter)}&order=ASC&sort=trackNumber`
|
// return `/song?filter=${JSON.stringify(filter)}&order=ASC&sort=trackNumber`
|
||||||
}
|
// }
|
||||||
|
|
||||||
const AlbumList = (props) => (
|
const AlbumList = (props) => (
|
||||||
<List
|
<List
|
||||||
@ -53,7 +53,7 @@ const AlbumList = (props) => (
|
|||||||
perPage={15}
|
perPage={15}
|
||||||
pagination={<Pagination />}
|
pagination={<Pagination />}
|
||||||
>
|
>
|
||||||
<Datagrid expand={<AlbumDetails />} rowClick={albumRowClick}>
|
<Datagrid expand={<AlbumDetails />} rowClick={'show'}>
|
||||||
<TextField source="name" />
|
<TextField source="name" />
|
||||||
<TextField source="artist" />
|
<TextField source="artist" />
|
||||||
<NumberField source="songCount" />
|
<NumberField source="songCount" />
|
||||||
|
94
ui/src/album/AlbumShow.js
Normal file
94
ui/src/album/AlbumShow.js
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { Show, SimpleList, useGetList, useGetOne, Loading } from 'react-admin'
|
||||||
|
import { PlayButton, Title } from '../common'
|
||||||
|
import { addTrack } from '../player'
|
||||||
|
import { DurationField } from '../common'
|
||||||
|
import AddIcon from '@material-ui/icons/Add'
|
||||||
|
import { Typography, Paper } from '@material-ui/core'
|
||||||
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
|
|
||||||
|
const AlbumTitle = ({ record }) => {
|
||||||
|
return <Title subTitle={`Album: ${record ? record.name : ''}`} />
|
||||||
|
}
|
||||||
|
|
||||||
|
const useStyles = makeStyles({
|
||||||
|
container: { minWidth: '35em', padding: '1em' },
|
||||||
|
rightAlignedCell: { textAlign: 'right' },
|
||||||
|
boldCell: { fontWeight: 'bold' }
|
||||||
|
})
|
||||||
|
|
||||||
|
const AlbumDetail = (props) => {
|
||||||
|
const classes = useStyles()
|
||||||
|
const { data, loading, error } = useGetOne('album', props.id)
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return <Loading />
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return <p>ERROR: {error}</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
let genreDate = []
|
||||||
|
if (data.genre) {
|
||||||
|
genreDate.push(data.genre)
|
||||||
|
}
|
||||||
|
if (data.year) {
|
||||||
|
genreDate.push(data.year)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Paper className={classes.container} elevation={2}>
|
||||||
|
<Typography variant="h5">{data.name}</Typography>
|
||||||
|
<Typography variant="h6">{data.albumArtist || data.artist}</Typography>
|
||||||
|
<Typography variant="h7">{genreDate.join(' - ')}</Typography>
|
||||||
|
<Typography variant="body2"></Typography>
|
||||||
|
</Paper>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const AlbumSongs = (props) => {
|
||||||
|
const { record } = props
|
||||||
|
const { data, total, loading, error } = useGetList(
|
||||||
|
'song',
|
||||||
|
{ page: 0, perPage: 100 },
|
||||||
|
{ field: 'album', order: 'ASC' },
|
||||||
|
{ album_id: record.id }
|
||||||
|
)
|
||||||
|
if (error) {
|
||||||
|
return <p>ERROR: {error}</p>
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<SimpleList
|
||||||
|
data={data}
|
||||||
|
ids={Object.keys(data)}
|
||||||
|
loading={loading}
|
||||||
|
total={total}
|
||||||
|
primaryText={(r) => (
|
||||||
|
<>
|
||||||
|
<PlayButton record={r} />
|
||||||
|
<PlayButton record={r} action={addTrack} icon={<AddIcon />} />
|
||||||
|
{r.trackNumber + '. ' + r.title}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
secondaryText={(r) =>
|
||||||
|
r.albumArtist && r.artist !== r.albumArtist ? r.artist : ''
|
||||||
|
}
|
||||||
|
tertiaryText={(r) => <DurationField record={r} source={'duration'} />}
|
||||||
|
linkType={false}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const AlbumShow = (props) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<AlbumDetail {...props} />
|
||||||
|
<Show title={<AlbumTitle />} {...props}>
|
||||||
|
<AlbumSongs {...props} />
|
||||||
|
</Show>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AlbumShow
|
@ -1,7 +1,9 @@
|
|||||||
import AlbumIcon from '@material-ui/icons/Album'
|
import AlbumIcon from '@material-ui/icons/Album'
|
||||||
import AlbumList from './AlbumList'
|
import AlbumList from './AlbumList'
|
||||||
|
import AlbumShow from './AlbumShow'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
list: AlbumList,
|
list: AlbumList,
|
||||||
|
show: AlbumShow,
|
||||||
icon: AlbumIcon
|
icon: AlbumIcon
|
||||||
}
|
}
|
||||||
|
@ -2,5 +2,6 @@ import Title from './Title'
|
|||||||
import DurationField from './DurationField'
|
import DurationField from './DurationField'
|
||||||
import BitrateField from './BitrateField'
|
import BitrateField from './BitrateField'
|
||||||
import Pagination from './Pagination'
|
import Pagination from './Pagination'
|
||||||
|
import PlayButton from './PlayButton'
|
||||||
|
|
||||||
export { Title, DurationField, BitrateField, Pagination }
|
export { Title, DurationField, BitrateField, Pagination, PlayButton }
|
||||||
|
@ -26,18 +26,14 @@ const AddToQueueButton = ({ selectedIds }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button color="secondary" onClick={addToQueue}>
|
||||||
color="secondary"
|
|
||||||
label={
|
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={translate('resources.song.bulk.addToQueue')}
|
title={translate('resources.song.bulk.addToQueue')}
|
||||||
placement="right"
|
placement="right"
|
||||||
>
|
>
|
||||||
<AddToQueueIcon />
|
<AddToQueueIcon />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
}
|
</Button>
|
||||||
onClick={addToQueue}
|
|
||||||
/>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import {
|
|||||||
import { useMediaQuery } from '@material-ui/core'
|
import { useMediaQuery } from '@material-ui/core'
|
||||||
import { BitrateField, DurationField, Pagination, Title } from '../common'
|
import { BitrateField, DurationField, Pagination, Title } from '../common'
|
||||||
import AddToQueueButton from './AddToQueueButton'
|
import AddToQueueButton from './AddToQueueButton'
|
||||||
import PlayButton from './PlayButton'
|
import { PlayButton } from '../common'
|
||||||
import { useDispatch } from 'react-redux'
|
import { useDispatch } from 'react-redux'
|
||||||
import { setTrack, addTrack } from '../player'
|
import { setTrack, addTrack } from '../player'
|
||||||
import AddIcon from '@material-ui/icons/Add'
|
import AddIcon from '@material-ui/icons/Add'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user