2021-08-27 01:32:05 +02:00
|
|
|
import Vue from 'vue'
|
2021-08-18 00:01:11 +02:00
|
|
|
|
|
|
|
export const state = () => ({
|
2021-09-05 02:58:39 +02:00
|
|
|
serverSettings: null,
|
2021-08-18 00:01:11 +02:00
|
|
|
streamAudiobook: null,
|
2021-09-06 21:13:01 +02:00
|
|
|
editModalTab: 'details',
|
2021-08-18 00:01:11 +02:00
|
|
|
showEditModal: false,
|
|
|
|
selectedAudiobook: null,
|
|
|
|
playOnLoad: false,
|
|
|
|
isScanning: false,
|
2021-08-25 03:24:40 +02:00
|
|
|
isScanningCovers: false,
|
2021-08-23 21:08:54 +02:00
|
|
|
scanProgress: null,
|
2021-08-25 03:24:40 +02:00
|
|
|
coverScanProgress: null,
|
2021-08-27 01:32:05 +02:00
|
|
|
developerMode: false,
|
|
|
|
selectedAudiobooks: [],
|
|
|
|
processingBatch: false
|
2021-08-18 00:01:11 +02:00
|
|
|
})
|
|
|
|
|
2021-08-27 01:32:05 +02:00
|
|
|
export const getters = {
|
|
|
|
getIsAudiobookSelected: state => audiobookId => {
|
|
|
|
return !!state.selectedAudiobooks.includes(audiobookId)
|
|
|
|
},
|
|
|
|
getNumAudiobooksSelected: state => state.selectedAudiobooks.length
|
|
|
|
}
|
2021-08-18 00:01:11 +02:00
|
|
|
|
2021-09-05 02:58:39 +02:00
|
|
|
export const actions = {
|
|
|
|
updateServerSettings({ commit }, payload) {
|
|
|
|
var updatePayload = {
|
|
|
|
...payload
|
|
|
|
}
|
|
|
|
return this.$axios.$patch('/api/serverSettings', updatePayload).then((result) => {
|
|
|
|
if (result.success) {
|
|
|
|
commit('setServerSettings', result.settings)
|
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}).catch((error) => {
|
|
|
|
console.error('Failed to update server settings', error)
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2021-08-18 00:01:11 +02:00
|
|
|
|
|
|
|
export const mutations = {
|
2021-09-05 02:58:39 +02:00
|
|
|
setServerSettings(state, settings) {
|
|
|
|
state.serverSettings = settings
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
setStreamAudiobook(state, audiobook) {
|
|
|
|
state.playOnLoad = true
|
|
|
|
state.streamAudiobook = audiobook
|
|
|
|
},
|
|
|
|
setStream(state, stream) {
|
|
|
|
state.playOnLoad = false
|
|
|
|
state.streamAudiobook = stream ? stream.audiobook : null
|
|
|
|
},
|
|
|
|
clearStreamAudiobook(state, audiobookId) {
|
|
|
|
if (state.streamAudiobook && state.streamAudiobook.id === audiobookId) {
|
|
|
|
state.playOnLoad = false
|
|
|
|
state.streamAudiobook = null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setPlayOnLoad(state, val) {
|
|
|
|
state.playOnLoad = val
|
|
|
|
},
|
|
|
|
showEditModal(state, audiobook) {
|
2021-09-06 21:13:01 +02:00
|
|
|
state.editModalTab = 'details'
|
2021-08-18 00:01:11 +02:00
|
|
|
state.selectedAudiobook = audiobook
|
|
|
|
state.showEditModal = true
|
|
|
|
},
|
2021-09-06 21:13:01 +02:00
|
|
|
showEditModalOnTab(state, { audiobook, tab }) {
|
|
|
|
state.editModalTab = tab
|
|
|
|
state.selectedAudiobook = audiobook
|
|
|
|
state.showEditModal = true
|
|
|
|
},
|
|
|
|
setEditModalTab(state, tab) {
|
|
|
|
state.editModalTab = tab
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
setShowEditModal(state, val) {
|
|
|
|
state.showEditModal = val
|
|
|
|
},
|
|
|
|
setIsScanning(state, isScanning) {
|
|
|
|
state.isScanning = isScanning
|
|
|
|
},
|
2021-08-25 03:24:40 +02:00
|
|
|
setScanProgress(state, scanProgress) {
|
|
|
|
if (scanProgress && scanProgress.progress > 0) state.isScanning = true
|
|
|
|
state.scanProgress = scanProgress
|
|
|
|
},
|
|
|
|
setIsScanningCovers(state, isScanningCovers) {
|
|
|
|
state.isScanningCovers = isScanningCovers
|
|
|
|
},
|
|
|
|
setCoverScanProgress(state, coverScanProgress) {
|
|
|
|
if (coverScanProgress && coverScanProgress.progress > 0) state.isScanningCovers = true
|
|
|
|
state.coverScanProgress = coverScanProgress
|
2021-08-23 21:08:54 +02:00
|
|
|
},
|
|
|
|
setDeveloperMode(state, val) {
|
|
|
|
state.developerMode = val
|
2021-08-27 01:32:05 +02:00
|
|
|
},
|
|
|
|
setSelectedAudiobooks(state, audiobooks) {
|
|
|
|
state.selectedAudiobooks = audiobooks
|
|
|
|
},
|
|
|
|
toggleAudiobookSelected(state, audiobookId) {
|
|
|
|
if (state.selectedAudiobooks.includes(audiobookId)) {
|
|
|
|
state.selectedAudiobooks = state.selectedAudiobooks.filter(a => a !== audiobookId)
|
|
|
|
} else {
|
|
|
|
state.selectedAudiobooks.push(audiobookId)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setProcessingBatch(state, val) {
|
|
|
|
state.processingBatch = val
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
}
|