mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-06 18:33:10 +03:00
Add 'download' option to album context menu
This commit is contained in:
parent
8e4b2e1c06
commit
38c19eddc3
@ -44,7 +44,9 @@
|
|||||||
"playAll": "Tocar",
|
"playAll": "Tocar",
|
||||||
"playNext": "Tocar em seguida",
|
"playNext": "Tocar em seguida",
|
||||||
"addToQueue": "Adicionar à fila",
|
"addToQueue": "Adicionar à fila",
|
||||||
"shuffle": "Aleatório"
|
"shuffle": "Aleatório",
|
||||||
|
"addToPlaylist": "Adicionar à playlist",
|
||||||
|
"download": "Baixar"
|
||||||
},
|
},
|
||||||
"lists": {
|
"lists": {
|
||||||
"all": "Todos",
|
"all": "Todos",
|
||||||
|
@ -6,11 +6,14 @@ import {
|
|||||||
} from 'react-admin'
|
} from 'react-admin'
|
||||||
import PlayArrowIcon from '@material-ui/icons/PlayArrow'
|
import PlayArrowIcon from '@material-ui/icons/PlayArrow'
|
||||||
import ShuffleIcon from '@material-ui/icons/Shuffle'
|
import ShuffleIcon from '@material-ui/icons/Shuffle'
|
||||||
|
import CloudDownloadIcon from '@material-ui/icons/CloudDownload'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useDispatch } from 'react-redux'
|
import { useDispatch } from 'react-redux'
|
||||||
import { playTracks, shuffleTracks } from '../audioplayer'
|
import { playTracks, shuffleTracks } from '../audioplayer'
|
||||||
|
import subsonic from '../subsonic'
|
||||||
|
|
||||||
const AlbumActions = ({
|
const AlbumActions = ({
|
||||||
|
albumId,
|
||||||
className,
|
className,
|
||||||
ids,
|
ids,
|
||||||
data,
|
data,
|
||||||
@ -21,6 +24,7 @@ const AlbumActions = ({
|
|||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const translate = useTranslate()
|
const translate = useTranslate()
|
||||||
|
|
||||||
|
console.log(rest)
|
||||||
return (
|
return (
|
||||||
<TopToolbar className={className} {...sanitizeListRestProps(rest)}>
|
<TopToolbar className={className} {...sanitizeListRestProps(rest)}>
|
||||||
<Button
|
<Button
|
||||||
@ -39,6 +43,14 @@ const AlbumActions = ({
|
|||||||
>
|
>
|
||||||
<ShuffleIcon />
|
<ShuffleIcon />
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
subsonic.download(albumId)
|
||||||
|
}}
|
||||||
|
label={translate('resources.album.actions.download')}
|
||||||
|
>
|
||||||
|
<CloudDownloadIcon />
|
||||||
|
</Button>
|
||||||
</TopToolbar>
|
</TopToolbar>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ const AlbumShow = (props) => {
|
|||||||
{...props}
|
{...props}
|
||||||
albumId={props.id}
|
albumId={props.id}
|
||||||
title={<Title subTitle={record.name} />}
|
title={<Title subTitle={record.name} />}
|
||||||
actions={<AlbumActions />}
|
actions={<AlbumActions albumId={props.id} />}
|
||||||
filter={{ album_id: props.id }}
|
filter={{ album_id: props.id }}
|
||||||
resource={'albumSong'}
|
resource={'albumSong'}
|
||||||
exporter={false}
|
exporter={false}
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { useDispatch } from 'react-redux'
|
import { useDispatch } from 'react-redux'
|
||||||
import IconButton from '@material-ui/core/IconButton'
|
import IconButton from '@material-ui/core/IconButton'
|
||||||
import Menu from '@material-ui/core/Menu'
|
import Menu from '@material-ui/core/Menu'
|
||||||
import MenuItem from '@material-ui/core/MenuItem'
|
import MenuItem from '@material-ui/core/MenuItem'
|
||||||
import MoreVertIcon from '@material-ui/icons/MoreVert'
|
import MoreVertIcon from '@material-ui/icons/MoreVert'
|
||||||
|
import StarIcon from '@material-ui/icons/Star'
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
import { useDataProvider, useNotify, useTranslate } from 'react-admin'
|
import { useDataProvider, useNotify, useTranslate } from 'react-admin'
|
||||||
import { addTracks, playTracks, shuffleTracks } from '../audioplayer'
|
import { addTracks, playTracks, shuffleTracks } from '../audioplayer'
|
||||||
import { openAddToPlaylist } from '../dialogs/dialogState'
|
import { openAddToPlaylist } from '../dialogs/dialogState'
|
||||||
import StarIcon from '@material-ui/icons/Star'
|
import subsonic from '../subsonic'
|
||||||
import PropTypes from 'prop-types'
|
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
const useStyles = makeStyles({
|
||||||
noWrap: {
|
noWrap: {
|
||||||
@ -35,19 +36,23 @@ const AlbumContextMenu = ({ record, discNumber, color, visible }) => {
|
|||||||
const options = {
|
const options = {
|
||||||
play: {
|
play: {
|
||||||
label: 'resources.album.actions.playAll',
|
label: 'resources.album.actions.playAll',
|
||||||
action: playTracks,
|
action: (data, ids) => dispatch(playTracks(data, ids)),
|
||||||
},
|
},
|
||||||
addToQueue: {
|
addToQueue: {
|
||||||
label: 'resources.album.actions.addToQueue',
|
label: 'resources.album.actions.addToQueue',
|
||||||
action: addTracks,
|
action: (data, ids) => dispatch(addTracks(data, ids)),
|
||||||
},
|
},
|
||||||
shuffle: {
|
shuffle: {
|
||||||
label: 'resources.album.actions.shuffle',
|
label: 'resources.album.actions.shuffle',
|
||||||
action: shuffleTracks,
|
action: (data, ids) => dispatch(shuffleTracks(data, ids)),
|
||||||
},
|
},
|
||||||
addToPlaylist: {
|
addToPlaylist: {
|
||||||
label: 'resources.song.actions.addToPlaylist',
|
label: 'resources.album.actions.addToPlaylist',
|
||||||
action: (data, ids) => openAddToPlaylist({ selectedIds: ids }),
|
action: (data, ids) => dispatch(openAddToPlaylist({ selectedIds: ids })),
|
||||||
|
},
|
||||||
|
download: {
|
||||||
|
label: 'resources.album.actions.download',
|
||||||
|
action: () => subsonic.download(record.id),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +88,7 @@ const AlbumContextMenu = ({ record, discNumber, color, visible }) => {
|
|||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
let { data, ids } = extractSongsData(response)
|
let { data, ids } = extractSongsData(response)
|
||||||
dispatch(options[key].action(data, ids))
|
options[key].action(data, ids)
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
notify('ra.page.error', 'warning')
|
notify('ra.page.error', 'warning')
|
||||||
|
@ -45,7 +45,9 @@
|
|||||||
"playAll": "Play",
|
"playAll": "Play",
|
||||||
"playNext": "Play Next",
|
"playNext": "Play Next",
|
||||||
"addToQueue": "Play Later",
|
"addToQueue": "Play Later",
|
||||||
"shuffle": "Shuffle"
|
"shuffle": "Shuffle",
|
||||||
|
"addToPlaylist": "Add to Playlist",
|
||||||
|
"download": "Download"
|
||||||
},
|
},
|
||||||
"lists": {
|
"lists": {
|
||||||
"all": "All",
|
"all": "All",
|
||||||
|
@ -26,4 +26,6 @@ const url = (command, id, options) => {
|
|||||||
const scrobble = (id, submit) =>
|
const scrobble = (id, submit) =>
|
||||||
fetchUtils.fetchJson(url('scrobble', id, { submission: submit }))
|
fetchUtils.fetchJson(url('scrobble', id, { submission: submit }))
|
||||||
|
|
||||||
export default { url, scrobble }
|
const download = (id, submit) => (window.location.href = url('download', id))
|
||||||
|
|
||||||
|
export default { url, scrobble, download }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user