Use defaultDownsamplingFormat in share options
This commit is contained in:
+26
-25
@@ -36,31 +36,32 @@ func serveIndex(ds model.DataStore, fs fs.FS, shareInfo *model.Share) http.Handl
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
appConfig := map[string]interface{}{
|
appConfig := map[string]interface{}{
|
||||||
"version": consts.Version,
|
"version": consts.Version,
|
||||||
"firstTime": firstTime,
|
"firstTime": firstTime,
|
||||||
"variousArtistsId": consts.VariousArtistsID,
|
"variousArtistsId": consts.VariousArtistsID,
|
||||||
"baseURL": utils.SanitizeText(strings.TrimSuffix(conf.Server.BaseURL, "/")),
|
"baseURL": utils.SanitizeText(strings.TrimSuffix(conf.Server.BaseURL, "/")),
|
||||||
"loginBackgroundURL": utils.SanitizeText(conf.Server.UILoginBackgroundURL),
|
"loginBackgroundURL": utils.SanitizeText(conf.Server.UILoginBackgroundURL),
|
||||||
"welcomeMessage": utils.SanitizeText(conf.Server.UIWelcomeMessage),
|
"welcomeMessage": utils.SanitizeText(conf.Server.UIWelcomeMessage),
|
||||||
"enableTranscodingConfig": conf.Server.EnableTranscodingConfig,
|
"enableTranscodingConfig": conf.Server.EnableTranscodingConfig,
|
||||||
"enableDownloads": conf.Server.EnableDownloads,
|
"enableDownloads": conf.Server.EnableDownloads,
|
||||||
"enableFavourites": conf.Server.EnableFavourites,
|
"enableFavourites": conf.Server.EnableFavourites,
|
||||||
"enableStarRating": conf.Server.EnableStarRating,
|
"enableStarRating": conf.Server.EnableStarRating,
|
||||||
"defaultTheme": conf.Server.DefaultTheme,
|
"defaultTheme": conf.Server.DefaultTheme,
|
||||||
"defaultLanguage": conf.Server.DefaultLanguage,
|
"defaultLanguage": conf.Server.DefaultLanguage,
|
||||||
"defaultUIVolume": conf.Server.DefaultUIVolume,
|
"defaultUIVolume": conf.Server.DefaultUIVolume,
|
||||||
"enableCoverAnimation": conf.Server.EnableCoverAnimation,
|
"enableCoverAnimation": conf.Server.EnableCoverAnimation,
|
||||||
"gaTrackingId": conf.Server.GATrackingID,
|
"gaTrackingId": conf.Server.GATrackingID,
|
||||||
"losslessFormats": strings.ToUpper(strings.Join(consts.LosslessFormats, ",")),
|
"losslessFormats": strings.ToUpper(strings.Join(consts.LosslessFormats, ",")),
|
||||||
"devActivityPanel": conf.Server.DevActivityPanel,
|
"devActivityPanel": conf.Server.DevActivityPanel,
|
||||||
"enableUserEditing": conf.Server.EnableUserEditing,
|
"enableUserEditing": conf.Server.EnableUserEditing,
|
||||||
"devEnableShare": conf.Server.DevEnableShare,
|
"devEnableShare": conf.Server.DevEnableShare,
|
||||||
"devSidebarPlaylists": conf.Server.DevSidebarPlaylists,
|
"devSidebarPlaylists": conf.Server.DevSidebarPlaylists,
|
||||||
"lastFMEnabled": conf.Server.LastFM.Enabled,
|
"lastFMEnabled": conf.Server.LastFM.Enabled,
|
||||||
"lastFMApiKey": conf.Server.LastFM.ApiKey,
|
"lastFMApiKey": conf.Server.LastFM.ApiKey,
|
||||||
"devShowArtistPage": conf.Server.DevShowArtistPage,
|
"devShowArtistPage": conf.Server.DevShowArtistPage,
|
||||||
"listenBrainzEnabled": conf.Server.ListenBrainz.Enabled,
|
"listenBrainzEnabled": conf.Server.ListenBrainz.Enabled,
|
||||||
"enableReplayGain": conf.Server.EnableReplayGain,
|
"enableReplayGain": conf.Server.EnableReplayGain,
|
||||||
|
"defaultDownsamplingFormat": conf.Server.DefaultDownsamplingFormat,
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(conf.Server.UILoginBackgroundURL, "/") {
|
if strings.HasPrefix(conf.Server.UILoginBackgroundURL, "/") {
|
||||||
appConfig["loginBackgroundURL"] = path.Join(conf.Server.BaseURL, conf.Server.UILoginBackgroundURL)
|
appConfig["loginBackgroundURL"] = path.Join(conf.Server.BaseURL, conf.Server.UILoginBackgroundURL)
|
||||||
|
|||||||
@@ -234,6 +234,16 @@ var _ = Describe("serveIndex", func() {
|
|||||||
Expect(config).To(HaveKeyWithValue("devEnableShare", false))
|
Expect(config).To(HaveKeyWithValue("devEnableShare", false))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("sets the defaultDownsamplingFormat", func() {
|
||||||
|
r := httptest.NewRequest("GET", "/index.html", nil)
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
|
||||||
|
serveIndex(ds, fs, nil)(w, r)
|
||||||
|
|
||||||
|
config := extractAppConfig(w.Body.String())
|
||||||
|
Expect(config).To(HaveKeyWithValue("defaultDownsamplingFormat", conf.Server.DefaultDownsamplingFormat))
|
||||||
|
})
|
||||||
|
|
||||||
It("sets the devSidebarPlaylists", func() {
|
It("sets the devSidebarPlaylists", func() {
|
||||||
conf.Server.DevSidebarPlaylists = true
|
conf.Server.DevSidebarPlaylists = true
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ const defaultConfig = {
|
|||||||
enableCoverAnimation: true,
|
enableCoverAnimation: true,
|
||||||
devShowArtistPage: true,
|
devShowArtistPage: true,
|
||||||
enableReplayGain: true,
|
enableReplayGain: true,
|
||||||
|
defaultDownsamplingFormat: 'opus',
|
||||||
publicBaseUrl: '/p',
|
publicBaseUrl: '/p',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,3 +20,5 @@ DraggableTypes.ALL.push(
|
|||||||
)
|
)
|
||||||
|
|
||||||
export const MAX_SIDEBAR_PLAYLISTS = 100
|
export const MAX_SIDEBAR_PLAYLISTS = 100
|
||||||
|
|
||||||
|
export const DEFAULT_SHARE_BITRATE = 128
|
||||||
|
|||||||
@@ -16,13 +16,15 @@ import {
|
|||||||
} from 'react-admin'
|
} from 'react-admin'
|
||||||
import { useMemo, useState } from 'react'
|
import { useMemo, useState } from 'react'
|
||||||
import { shareUrl } from '../utils'
|
import { shareUrl } from '../utils'
|
||||||
|
import config from '../config'
|
||||||
|
import { DEFAULT_SHARE_BITRATE } from '../consts'
|
||||||
|
|
||||||
export const ShareDialog = ({ open, close, onClose, ids, resource, title }) => {
|
export const ShareDialog = ({ open, close, onClose, ids, resource, title }) => {
|
||||||
const notify = useNotify()
|
const notify = useNotify()
|
||||||
const [format, setFormat] = useState('')
|
const [format, setFormat] = useState(config.defaultDownsamplingFormat)
|
||||||
const [maxBitRate, setMaxBitRate] = useState(0)
|
const [maxBitRate, setMaxBitRate] = useState(DEFAULT_SHARE_BITRATE)
|
||||||
const [originalFormat, setUseOriginalFormat] = useState(true)
|
const [originalFormat, setUseOriginalFormat] = useState(true)
|
||||||
const { data: formats, loading } = useGetList(
|
const { data: formats, loading: loadingFormats } = useGetList(
|
||||||
'transcoding',
|
'transcoding',
|
||||||
{
|
{
|
||||||
page: 1,
|
page: 1,
|
||||||
@@ -33,12 +35,12 @@ export const ShareDialog = ({ open, close, onClose, ids, resource, title }) => {
|
|||||||
|
|
||||||
const formatOptions = useMemo(
|
const formatOptions = useMemo(
|
||||||
() =>
|
() =>
|
||||||
loading
|
loadingFormats
|
||||||
? []
|
? []
|
||||||
: Object.values(formats).map((f) => {
|
: Object.values(formats).map((f) => {
|
||||||
return { id: f.targetFormat, name: f.targetFormat }
|
return { id: f.targetFormat, name: f.targetFormat }
|
||||||
}),
|
}),
|
||||||
[formats, loading]
|
[formats, loadingFormats]
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleOriginal = (e) => {
|
const handleOriginal = (e) => {
|
||||||
@@ -57,8 +59,8 @@ export const ShareDialog = ({ open, close, onClose, ids, resource, title }) => {
|
|||||||
{
|
{
|
||||||
resourceType: resource,
|
resourceType: resource,
|
||||||
resourceIds: ids?.join(','),
|
resourceIds: ids?.join(','),
|
||||||
format,
|
...(!originalFormat && { format }),
|
||||||
maxBitRate,
|
...(!originalFormat && { maxBitRate }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
@@ -106,8 +108,8 @@ export const ShareDialog = ({ open, close, onClose, ids, resource, title }) => {
|
|||||||
{!originalFormat && (
|
{!originalFormat && (
|
||||||
<SelectInput
|
<SelectInput
|
||||||
source="format"
|
source="format"
|
||||||
|
defaultValue={format}
|
||||||
choices={formatOptions}
|
choices={formatOptions}
|
||||||
resettable
|
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
setFormat(event.target.value)
|
setFormat(event.target.value)
|
||||||
}}
|
}}
|
||||||
@@ -115,7 +117,8 @@ export const ShareDialog = ({ open, close, onClose, ids, resource, title }) => {
|
|||||||
)}
|
)}
|
||||||
{!originalFormat && (
|
{!originalFormat && (
|
||||||
<SelectInput
|
<SelectInput
|
||||||
source="bitrate"
|
source="maxBitRate"
|
||||||
|
defaultValue={maxBitRate}
|
||||||
choices={[
|
choices={[
|
||||||
{ id: 32, name: '32' },
|
{ id: 32, name: '32' },
|
||||||
{ id: 48, name: '48' },
|
{ id: 48, name: '48' },
|
||||||
@@ -129,7 +132,6 @@ export const ShareDialog = ({ open, close, onClose, ids, resource, title }) => {
|
|||||||
{ id: 256, name: '256' },
|
{ id: 256, name: '256' },
|
||||||
{ id: 320, name: '320' },
|
{ id: 320, name: '320' },
|
||||||
]}
|
]}
|
||||||
resettable
|
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
setMaxBitRate(event.target.value)
|
setMaxBitRate(event.target.value)
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ import React from 'react'
|
|||||||
import { DateField, QualityInfo } from '../common'
|
import { DateField, QualityInfo } from '../common'
|
||||||
import { shareUrl } from '../utils'
|
import { shareUrl } from '../utils'
|
||||||
import { Link } from '@material-ui/core'
|
import { Link } from '@material-ui/core'
|
||||||
|
import config from '../config'
|
||||||
|
|
||||||
export const FormatInfo = ({ record, size }) => {
|
export const FormatInfo = ({ record, size }) => {
|
||||||
const r = { suffix: record.format, bitRate: record.maxBitRate }
|
const r = { suffix: record.format, bitRate: record.maxBitRate }
|
||||||
// TODO Get DefaultDownsamplingFormat
|
r.suffix =
|
||||||
r.suffix = r.suffix || (r.bitRate ? 'opus' : 'Original')
|
r.suffix || (r.bitRate ? config.defaultDownsamplingFormat : 'Original')
|
||||||
return <QualityInfo record={r} size={size} />
|
return <QualityInfo record={r} size={size} />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user