* Update AlbumGridView.js * Update AlbumDetails.js * Update AlbumDetails.js * Create DoubleRangeField.js * Update and rename DoubleRangeField.js to RangeFieldDouble.js * Update RangeFieldDouble.js * Update AlbumGridView.js * Update AlbumDetails.js * Update RangeFieldDouble.js * Update index.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update AlbumDetails.js * Update RangeFieldDouble.js * Update AlbumDetails.js * Update RangeFieldDouble.js * Update AlbumDetails.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update AlbumDetails.js * Update AlbumDetails.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update AlbumDetails.js * Update RangeFieldDouble.js * Update AlbumDetails.js * Update en.json * Update en.json * Update AlbumDetails.js * Update RangeFieldDouble.js * Update AlbumGridView.js * Update AlbumDetails.js * Update AlbumSongs.js * Update ContextMenus.js * Update SongDatagrid.js * Update AlbumSongs.js * Update SongDatagrid.js * Update SongDatagrid.js * Update SongDatagrid.js * Update AlbumSongs.js * Update SongList.js * Update playlist_track_repository.go * Update 20230113000000_release_year.go * Update PlayButton.js * Update mediafile_repository.go * Update album.go * Update playlist_track_repository.go * Update playlist_track_repository.go * Update SongDatagrid.js * Update 20230113000000_release_year.go * Update SongDatagrid.js * Update AlbumSongs.js * Update SongDatagrid.js * Update SongDatagrid.js * Update SongDatagrid.js * Update SongDatagrid.js * Update AlbumDetails.js * Update AlbumSongs.js * Update AlbumSongs.js * Update RangeFieldDouble.js * Update SongDatagrid.js * Update 20230113000000_release_year.go * Update 20230113000000_release_year.go * Update 20230113000000_release_year.go * Update 20230113000000_release_year.go * Update AlbumSongs.js * Update AlbumSongs.js * Update mapping.go * Update RangeFieldDouble.js * Update AlbumGridView.js * Update AlbumSongs.js * Update en.json * Update SongDatagrid.js * Update SongDatagrid.js * Update metadata.go * Update mapping.go * Update AlbumDetails.js * Update AlbumGridView.js * Update RangeFieldDouble.js * Update mapping.go * Update metadata.go * Update mapping.go * Update AlbumDetails.js * Update 20230113000000_release_year.go * Update AlbumDetails.js * Update en.json * Update configuration.go * Update mapping.go * Update configuration.go * Update mediafile.go * Update metadata.go * Update RangeFieldDouble.js * Update 20230113000000_release_year.go * Update configuration.go * Update mapping.go * Update mediafile.go * Update mapping.go * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update 20230113000000_release_year.go * Update AlbumDetails.js * Update RangeFieldDouble.js * Update mapping.go * Update metadata.go * Update album.go * Update mediafile.go * Update mediafile.go * Update album.go * Update fields.go * Update mediafile_repository.go * Update playlist_track_repository.go * Update AlbumSongs.js * Update SongDatagrid.js * Update PlayButton.js * Update SongList.js * Update ContextMenus.js * Update SongDatagrid.js * Update metadata.go * Update ArtistShow.js * Update mapping.go * Update configuration.go * Update mapping.go * Update metadata.go * Update metadata.go * Update mapping.go * Update metadata.go * Update metadata.go * Update mapping.go * Update 20230113000000_release_year.go * Update 20230113000000_release_year.go * Update mapping.go * Update metadata.go * Update metadata.go * Update album.go * Update mediafile.go * Update AlbumDetails.js * Update AlbumSongs.js * Update album.go * Update mediafile.go * Update metadata.go * Update mediafile.go * Update 20230113000000_release_year.go * Update 20230113000000_release_year.go * Update album.go * Update mediafile.go * Update RangeFieldDouble.js * Update AlbumDetails.js * Update AlbumGridView.js * Update en.json * Update AlbumGridView.js * Update RangeFieldDouble.js * Update and rename 20230113000000_release_year.go to 20230113000000_release_date.go * Update album.go * Update mediafile.go * Update fields.go * Update playlist_track_repository.go * Update mediafile_repository.go * Update mapping.go * Update metadata.go * Update mapping.go * Update SongDatagrid.js * Update RangeFieldDouble.js * Update index.js * Update ContextMenus.js * Update PlayButton.js * Create FormatDate.js * Update SongList.js * Update AlbumDetails.js * Update AlbumSongs.js * Update AlbumSongs.js * Update en.json * Update AlbumDetails.js * Update album.go fixed conflict I think? * Update mediafile.go fixed conflict * Format with goimports * Update SongDatagrid.js only show Cat # in desktop view * Update metadata_internal_test.go * Update metadata_test.go * Delete test.mp3 * Add files via upload mp3 test file with Date, Original Date and Release Date * Update metadata_test.go * Update metadata_test.go * Update metadata_test.go * Update metadata_test.go * Update taglib_test.go * Delete test.mp3 * Add files via upload file with replaygain & dates * Update AlbumGridView.js * Update AlbumDetails.js * Update AlbumSongs.js * Update ContextMenus.js * Update FormatDate.js * Update PlayButton.js * Update RangeFieldDouble.js * Update SongDatagrid.js * Update AlbumSongs.js * Update SongDatagrid.js * Update AlbumSongs.js * Fix formatting * Update mapping.go * Update AlbumSongs.js * Update SongDatagrid.js * Update SongDatagrid.js prettier * Create RangeDoubleField.js rename of RangeFieldDouble.js * Update AlbumGridView.js RangeFieldDouble -> RangeDoubleField * Update mediafile.go AllOrNothing() -> allOrNothing() * Update metadata_internal_test.go getYear -> getDate * Update AlbumDetails.js wrote suggested changes * Update en.json Editions -> Releases & fixed the field name * Update configuration.go Rename Editions -> Releases * Update 20230113000000_release_date.go Editions -> Releases * Update album.go Editions -> Releases * Update mediafile.go Editions -> Releases * Update AlbumDetails.js Editions -> Releases * Update AlbumSongs.js Editions -> Releases * Update RangeDoubleField.js Editions -> Releases * Update SongDatagrid.js Editions -> Releases * Update index.js FormatFullDate and RangeDoubleField * Rename FormatDate.js to FormatFullDate.js * Delete RangeFieldDouble.js * Update mediafile.go AllOrNothing -> allOrNothing * Update mapping.go Editions -> Releases * Update AlbumDetails.js prettier * Update SongDatagrid.js showReleaseRow -> showReleaseDivider * Update AlbumSongs.js showReleaseRow -> showReleaseDivider for clarity * Update and rename 20230113000000_release_date.go to 20230515184510_add_release_date.go - rename the migration file - fixed the import to goose/v3 - additional db fields for original date & year * Update 20230515184510_add_release_date.go * Update fields.go * Update album.go * Update mediafile.go * Update mapping.go * Update AlbumDetails.js * Update en.json * Update AlbumDetails.js * Update AlbumDetails.js now hopefully prettier * Update mapping.go --------- Co-authored-by: Deluan <deluan@navidrome.org>
215 lines
5.7 KiB
JavaScript
215 lines
5.7 KiB
JavaScript
import React, { useMemo } from 'react'
|
|
import {
|
|
BulkActionsToolbar,
|
|
ListToolbar,
|
|
TextField,
|
|
NumberField,
|
|
useVersion,
|
|
useListContext,
|
|
FunctionField,
|
|
} from 'react-admin'
|
|
import clsx from 'clsx'
|
|
import { useDispatch } from 'react-redux'
|
|
import { Card, useMediaQuery } from '@material-ui/core'
|
|
import { makeStyles } from '@material-ui/core/styles'
|
|
import FavoriteBorderIcon from '@material-ui/icons/FavoriteBorder'
|
|
import { playTracks } from '../actions'
|
|
import {
|
|
DurationField,
|
|
SongBulkActions,
|
|
SongContextMenu,
|
|
SongDatagrid,
|
|
SongInfo,
|
|
SongTitleField,
|
|
RatingField,
|
|
QualityInfo,
|
|
useSelectedFields,
|
|
useResourceRefresh,
|
|
DateField,
|
|
SizeField,
|
|
ArtistLinkField,
|
|
} from '../common'
|
|
import config from '../config'
|
|
import ExpandInfoDialog from '../dialogs/ExpandInfoDialog'
|
|
|
|
const useStyles = makeStyles(
|
|
(theme) => ({
|
|
root: {},
|
|
main: {
|
|
display: 'flex',
|
|
},
|
|
content: {
|
|
marginTop: 0,
|
|
transition: theme.transitions.create('margin-top'),
|
|
position: 'relative',
|
|
flex: '1 1 auto',
|
|
[theme.breakpoints.down('xs')]: {
|
|
boxShadow: 'none',
|
|
},
|
|
},
|
|
bulkActionsDisplayed: {
|
|
marginTop: -theme.spacing(8),
|
|
transition: theme.transitions.create('margin-top'),
|
|
},
|
|
actions: {
|
|
zIndex: 2,
|
|
display: 'flex',
|
|
justifyContent: 'flex-end',
|
|
flexWrap: 'wrap',
|
|
},
|
|
noResults: { padding: 20 },
|
|
columnIcon: {
|
|
marginLeft: '3px',
|
|
marginTop: '-2px',
|
|
verticalAlign: 'text-top',
|
|
},
|
|
toolbar: {
|
|
justifyContent: 'flex-start',
|
|
},
|
|
row: {
|
|
'&:hover': {
|
|
'& $contextMenu': {
|
|
visibility: 'visible',
|
|
},
|
|
'& $ratingField': {
|
|
visibility: 'visible',
|
|
},
|
|
},
|
|
},
|
|
contextMenu: {
|
|
visibility: (props) => (props.isDesktop ? 'hidden' : 'visible'),
|
|
},
|
|
ratingField: {
|
|
visibility: 'hidden',
|
|
},
|
|
}),
|
|
{ name: 'RaList' }
|
|
)
|
|
|
|
const AlbumSongs = (props) => {
|
|
const { data, ids } = props
|
|
const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'))
|
|
const classes = useStyles({ isDesktop })
|
|
const dispatch = useDispatch()
|
|
const version = useVersion()
|
|
useResourceRefresh('song', 'album')
|
|
|
|
const toggleableFields = useMemo(() => {
|
|
return {
|
|
trackNumber: isDesktop && (
|
|
<TextField
|
|
source="trackNumber"
|
|
sortBy="releaseDate asc, discNumber asc, trackNumber asc"
|
|
label="#"
|
|
sortable={false}
|
|
/>
|
|
),
|
|
title: (
|
|
<SongTitleField
|
|
source="title"
|
|
sortable={false}
|
|
showTrackNumbers={!isDesktop}
|
|
/>
|
|
),
|
|
artist: isDesktop && <ArtistLinkField source="artist" />,
|
|
duration: <DurationField source="duration" sortable={false} />,
|
|
year: isDesktop && (
|
|
<FunctionField
|
|
source="year"
|
|
render={(r) => r.year || ''}
|
|
sortByOrder={'DESC'}
|
|
/>
|
|
),
|
|
playCount: isDesktop && (
|
|
<NumberField source="playCount" sortable={false} />
|
|
),
|
|
playDate: <DateField source="playDate" sortable={false} showTime />,
|
|
quality: isDesktop && <QualityInfo source="quality" sortable={false} />,
|
|
size: isDesktop && <SizeField source="size" sortable={false} />,
|
|
channels: isDesktop && <NumberField source="channels" sortable={false} />,
|
|
bpm: isDesktop && <NumberField source="bpm" sortable={false} />,
|
|
rating: isDesktop && config.enableStarRating && (
|
|
<RatingField
|
|
resource={'song'}
|
|
source="rating"
|
|
sortable={false}
|
|
className={classes.ratingField}
|
|
/>
|
|
),
|
|
}
|
|
}, [isDesktop, classes.ratingField])
|
|
|
|
const columns = useSelectedFields({
|
|
resource: 'albumSong',
|
|
columns: toggleableFields,
|
|
omittedColumns: ['title'],
|
|
defaultOff: ['channels', 'bpm', 'year', 'playCount', 'playDate', 'size'],
|
|
})
|
|
|
|
const bulkActionsLabel = isDesktop
|
|
? 'ra.action.bulk_actions'
|
|
: 'ra.action.bulk_actions_mobile'
|
|
|
|
return (
|
|
<>
|
|
<ListToolbar
|
|
classes={{ toolbar: classes.toolbar }}
|
|
actions={props.actions}
|
|
{...props}
|
|
/>
|
|
<div className={classes.main}>
|
|
<Card
|
|
className={clsx(classes.content, {
|
|
[classes.bulkActionsDisplayed]: props.selectedIds.length > 0,
|
|
})}
|
|
key={version}
|
|
>
|
|
<BulkActionsToolbar {...props} label={bulkActionsLabel}>
|
|
<SongBulkActions />
|
|
</BulkActionsToolbar>
|
|
<SongDatagrid
|
|
rowClick={(id) => dispatch(playTracks(data, ids, id))}
|
|
{...props}
|
|
hasBulkActions={true}
|
|
showDiscSubtitles={true}
|
|
showReleaseDivider={true}
|
|
contextAlwaysVisible={!isDesktop}
|
|
classes={{ row: classes.row }}
|
|
>
|
|
{columns}
|
|
<SongContextMenu
|
|
source={'starred'}
|
|
sortable={false}
|
|
className={classes.contextMenu}
|
|
label={
|
|
config.enableFavourites && (
|
|
<FavoriteBorderIcon
|
|
fontSize={'small'}
|
|
className={classes.columnIcon}
|
|
/>
|
|
)
|
|
}
|
|
/>
|
|
</SongDatagrid>
|
|
</Card>
|
|
</div>
|
|
<ExpandInfoDialog content={<SongInfo />} />
|
|
</>
|
|
)
|
|
}
|
|
|
|
export const removeAlbumCommentsFromSongs = ({ album, data }) => {
|
|
if (album?.comment && data) {
|
|
Object.values(data).forEach((song) => {
|
|
song.comment = ''
|
|
})
|
|
}
|
|
}
|
|
|
|
const SanitizedAlbumSongs = (props) => {
|
|
removeAlbumCommentsFromSongs(props)
|
|
const { loaded, loading, total, ...rest } = useListContext(props)
|
|
return <>{loaded && <AlbumSongs {...rest} actions={props.actions} />}</>
|
|
}
|
|
|
|
export default SanitizedAlbumSongs
|