Add option to change max playlists shown in UI's sidebar, `MaxSidebarPlaylists`. Fix #2077

This commit is contained in:
Deluan 2023-02-01 10:21:30 -05:00
parent d683297fa7
commit 128b626ec9
7 changed files with 21 additions and 6 deletions

View File

@ -29,6 +29,8 @@ type configOptions struct {
SessionTimeout time.Duration
BaseURL string
UILoginBackgroundURL string
UIWelcomeMessage string
MaxSidebarPlaylists int
EnableTranscodingConfig bool
EnableDownloads bool
EnableExternalServices bool
@ -47,7 +49,6 @@ type configOptions struct {
ProbeCommand string
CoverArtPriority string
CoverJpegQuality int
UIWelcomeMessage string
EnableGravatar bool
EnableFavourites bool
EnableStarRating bool
@ -224,6 +225,8 @@ func init() {
viper.SetDefault("scanschedule", "@every 1m")
viper.SetDefault("baseurl", "")
viper.SetDefault("uiloginbackgroundurl", consts.DefaultUILoginBackgroundURL)
viper.SetDefault("uiwelcomemessage", "")
viper.SetDefault("maxsidebarplaylists", consts.DefaultMaxSidebarPlaylists)
viper.SetDefault("enabletranscodingconfig", false)
viper.SetDefault("transcodingcachesize", "100MB")
viper.SetDefault("imagecachesize", "100MB")
@ -242,7 +245,6 @@ func init() {
viper.SetDefault("probecommand", "ffmpeg %s -f ffmetadata")
viper.SetDefault("coverartpriority", "cover.*, folder.*, front.*, embedded, external")
viper.SetDefault("coverjpegquality", 75)
viper.SetDefault("uiwelcomemessage", "")
viper.SetDefault("enablegravatar", false)
viper.SetDefault("enablefavourites", true)
viper.SetDefault("enablestarrating", true)

View File

@ -43,6 +43,7 @@ const (
// DefaultUILoginBackgroundOffline Background image used in case external integrations are disabled
DefaultUILoginBackgroundOffline = "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAABGdBTUEAALGPC/xhBQAAAiJJREFUeF7t0IEAAAAAw6D5Ux/khVBhwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDDwMDDVlwABBWcSrQAAAABJRU5ErkJggg=="
DefaultUILoginBackgroundURLOffline = "data:image/png;base64," + DefaultUILoginBackgroundOffline
DefaultMaxSidebarPlaylists = 100
RequestThrottleBacklogLimit = 100
RequestThrottleBacklogTimeout = time.Minute

View File

@ -44,6 +44,7 @@ func serveIndex(ds model.DataStore, fs fs.FS, shareInfo *model.Share) http.Handl
"baseURL": utils.SanitizeText(strings.TrimSuffix(conf.Server.BaseURL, "/")),
"loginBackgroundURL": utils.SanitizeText(conf.Server.UILoginBackgroundURL),
"welcomeMessage": utils.SanitizeText(conf.Server.UIWelcomeMessage),
"maxSidebarPlaylists": conf.Server.MaxSidebarPlaylists,
"enableTranscodingConfig": conf.Server.EnableTranscodingConfig,
"enableDownloads": conf.Server.EnableDownloads,
"enableFavourites": conf.Server.EnableFavourites,

View File

@ -94,6 +94,17 @@ var _ = Describe("serveIndex", func() {
Expect(config).To(HaveKeyWithValue("welcomeMessage", "Hello"))
})
It("sets the maxSidebarPlaylists", func() {
conf.Server.MaxSidebarPlaylists = 42
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("maxSidebarPlaylists", float64(42)))
})
It("sets the enableTranscodingConfig", func() {
conf.Server.EnableTranscodingConfig = true
r := httptest.NewRequest("GET", "/index.html", nil)

View File

@ -8,6 +8,7 @@ const defaultConfig = {
variousArtistsId: '03b645ef2100dfc42fa9785ea3102295', // See consts.VariousArtistsID in consts.go
// Login backgrounds from https://unsplash.com/collections/1065384/music-wallpapers
loginBackgroundURL: 'https://source.unsplash.com/collection/1065384/1600x900',
maxSidebarPlaylists: 100,
enableTranscodingConfig: true,
enableDownloads: true,
enableFavourites: true,

View File

@ -19,8 +19,6 @@ DraggableTypes.ALL.push(
DraggableTypes.ARTIST
)
export const MAX_SIDEBAR_PLAYLISTS = 100
export const DEFAULT_SHARE_BITRATE = 128
export const BITRATE_CHOICES = [

View File

@ -13,7 +13,8 @@ import { BiCog } from 'react-icons/bi'
import { useDrop } from 'react-dnd'
import SubMenu from './SubMenu'
import { canChangeTracks } from '../common'
import { DraggableTypes, MAX_SIDEBAR_PLAYLISTS } from '../consts'
import { DraggableTypes } from '../consts'
import config from '../config'
const PlaylistMenuItemLink = ({ pls, sidebarIsOpen }) => {
const dataProvider = useDataProvider()
@ -56,7 +57,7 @@ const PlaylistsSubMenu = ({ state, setState, sidebarIsOpen, dense }) => {
payload: {
pagination: {
page: 0,
perPage: MAX_SIDEBAR_PLAYLISTS,
perPage: config.maxSidebarPlaylists,
},
sort: { field: 'name' },
},