Skip to content

Commit

Permalink
Add option to change max playlists shown in UI's sidebar, `MaxSidebar…
Browse files Browse the repository at this point in the history
…Playlists`. Fix #2077
  • Loading branch information
deluan committed Feb 1, 2023
1 parent d683297 commit 128b626
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
6 changes: 4 additions & 2 deletions conf/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type configOptions struct {
SessionTimeout time.Duration
BaseURL string
UILoginBackgroundURL string
UIWelcomeMessage string
MaxSidebarPlaylists int
EnableTranscodingConfig bool
EnableDownloads bool
EnableExternalServices bool
Expand All @@ -47,7 +49,6 @@ type configOptions struct {
ProbeCommand string
CoverArtPriority string
CoverJpegQuality int
UIWelcomeMessage string
EnableGravatar bool
EnableFavourites bool
EnableStarRating bool
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions server/serve_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions server/serve_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions ui/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions ui/src/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
5 changes: 3 additions & 2 deletions ui/src/layout/PlaylistsSubMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -56,7 +57,7 @@ const PlaylistsSubMenu = ({ state, setState, sidebarIsOpen, dense }) => {
payload: {
pagination: {
page: 0,
perPage: MAX_SIDEBAR_PLAYLISTS,
perPage: config.maxSidebarPlaylists,
},
sort: { field: 'name' },
},
Expand Down

0 comments on commit 128b626

Please sign in to comment.