From 9ab1677f1f76d88776cfaef5d2fe9832228c7737 Mon Sep 17 00:00:00 2001 From: chme Date: Sun, 7 Jul 2019 08:22:56 +0200 Subject: [PATCH] [web-src] Add a settings page to the player web interface to change web interface specific options --- web-src/src/App.vue | 7 + web-src/src/components/NavbarTop.vue | 10 +- .../src/pages/SettingsPageWebinterface.vue | 202 ++++++++++++++++++ web-src/src/router/index.js | 6 + web-src/src/store/index.js | 38 ++++ web-src/src/store/mutation_types.js | 2 + web-src/src/webapi/index.js | 8 + 7 files changed, 266 insertions(+), 7 deletions(-) create mode 100644 web-src/src/pages/SettingsPageWebinterface.vue diff --git a/web-src/src/App.vue b/web-src/src/App.vue index b84c1e18..b6a069bb 100644 --- a/web-src/src/App.vue +++ b/web-src/src/App.vue @@ -106,6 +106,7 @@ export default { vm.update_outputs() vm.update_player_status() vm.update_library_stats() + vm.update_settings() vm.update_queue() vm.update_spotify() } @@ -166,6 +167,12 @@ export default { }) }, + update_settings: function () { + webapi.settings().then(({ data }) => { + this.$store.commit(types.UPDATE_SETTINGS, data) + }) + }, + update_spotify: function () { webapi.spotify().then(({ data }) => { this.$store.commit(types.UPDATE_SPOTIFY, data) diff --git a/web-src/src/components/NavbarTop.vue b/web-src/src/components/NavbarTop.vue index 12c20907..1ce5e267 100644 --- a/web-src/src/components/NavbarTop.vue +++ b/web-src/src/components/NavbarTop.vue @@ -121,17 +121,13 @@ diff --git a/web-src/src/pages/SettingsPageWebinterface.vue b/web-src/src/pages/SettingsPageWebinterface.vue new file mode 100644 index 00000000..13c09cbc --- /dev/null +++ b/web-src/src/pages/SettingsPageWebinterface.vue @@ -0,0 +1,202 @@ + + + + + diff --git a/web-src/src/router/index.js b/web-src/src/router/index.js index cb1c9682..153067df 100644 --- a/web-src/src/router/index.js +++ b/web-src/src/router/index.js @@ -31,6 +31,7 @@ import SpotifyPageArtist from '@/pages/SpotifyPageArtist' import SpotifyPageAlbum from '@/pages/SpotifyPageAlbum' import SpotifyPagePlaylist from '@/pages/SpotifyPagePlaylist' import SpotifyPageSearch from '@/pages/SpotifyPageSearch' +import SettingsPageWebinterface from '@/pages/SettingsPageWebinterface' Vue.use(VueRouter) @@ -212,6 +213,11 @@ export const router = new VueRouter({ path: '/search/spotify', name: 'Spotify Search', component: SpotifyPageSearch + }, + { + path: '/settings/webinterface', + name: 'Settings Webinterface', + component: SettingsPageWebinterface } ], scrollBehavior (to, from, savedPosition) { diff --git a/web-src/src/store/index.js b/web-src/src/store/index.js index e274d1c2..7a38e9b8 100644 --- a/web-src/src/store/index.js +++ b/web-src/src/store/index.js @@ -11,6 +11,9 @@ export default new Vuex.Store({ 'version': '', 'buildoptions': [ ] }, + settings: { + 'categories': [] + }, library: { 'artists': 0, 'albums': 0, @@ -58,6 +61,33 @@ export default new Vuex.Store({ return item.id === state.player.item_id }) return (item === undefined) ? {} : item + }, + + settings_webinterface: state => { + if (state.settings) { + return state.settings.categories.find(elem => elem.name === 'webinterface') + } + return null + }, + + settings_option_show_composer_now_playing: (state, getters) => { + if (getters.settings_webinterface) { + const option = getters.settings_webinterface.options.find(elem => elem.name === 'show_composer_now_playing') + if (option) { + return option.value + } + } + return false + }, + + settings_option_show_composer_for_genre: (state, getters) => { + if (getters.settings_webinterface) { + const option = getters.settings_webinterface.options.find(elem => elem.name === 'show_composer_for_genre') + if (option) { + return option.value + } + } + return null } }, @@ -65,6 +95,14 @@ export default new Vuex.Store({ [types.UPDATE_CONFIG] (state, config) { state.config = config }, + [types.UPDATE_SETTINGS] (state, settings) { + state.settings = settings + }, + [types.UPDATE_SETTINGS_OPTION] (state, option) { + const settingCategory = state.settings.categories.find(elem => elem.name === option.category) + const settingOption = settingCategory.options.find(elem => elem.name === option.name) + settingOption.value = option.value + }, [types.UPDATE_LIBRARY_STATS] (state, libraryStats) { state.library = libraryStats }, diff --git a/web-src/src/store/mutation_types.js b/web-src/src/store/mutation_types.js index af556d3a..38b02e05 100644 --- a/web-src/src/store/mutation_types.js +++ b/web-src/src/store/mutation_types.js @@ -1,4 +1,6 @@ export const UPDATE_CONFIG = 'UPDATE_CONFIG' +export const UPDATE_SETTINGS = 'UPDATE_SETTINGS' +export const UPDATE_SETTINGS_OPTION = 'UPDATE_SETTINGS_OPTION' export const UPDATE_LIBRARY_STATS = 'UPDATE_LIBRARY_STATS' export const UPDATE_LIBRARY_AUDIOBOOKS_COUNT = 'UPDATE_LIBRARY_AUDIOBOOKS_COUNT' export const UPDATE_LIBRARY_PODCASTS_COUNT = 'UPDATE_LIBRARY_PODCASTS_COUNT' diff --git a/web-src/src/webapi/index.js b/web-src/src/webapi/index.js index 4b41878f..cb4cccd0 100644 --- a/web-src/src/webapi/index.js +++ b/web-src/src/webapi/index.js @@ -13,6 +13,14 @@ export default { return axios.get('/api/config') }, + settings () { + return axios.get('/api/settings') + }, + + settings_update (categoryName, option) { + return axios.put('/api/settings/' + categoryName + '/' + option.name, option) + }, + library_stats () { return axios.get('/api/library') },