[web] Lint source code

This commit is contained in:
Alain Nussbaumer 2024-03-26 15:00:17 +01:00
parent 57207c1ff4
commit 94f331cf09
13 changed files with 111 additions and 145 deletions

View File

@ -66,8 +66,8 @@ export default {
data() { data() {
return { return {
url: '', loading: false,
loading: false url: ''
} }
}, },
@ -75,7 +75,6 @@ export default {
show() { show() {
if (this.show) { if (this.show) {
this.loading = false this.loading = false
// We need to delay setting the focus to the input field until the field is part of the dom and visible // We need to delay setting the focus to the input field until the field is part of the dom and visible
setTimeout(() => { setTimeout(() => {
this.$refs.url_field.focus() this.$refs.url_field.focus()

View File

@ -69,8 +69,8 @@ export default {
data() { data() {
return { return {
url: '', loading: false,
loading: false url: ''
} }
}, },

View File

@ -344,17 +344,12 @@ export default {
}, },
methods: { methods: {
change_volume() {
webapi.player_volume(this.player.volume)
},
change_stream_volume() { change_stream_volume() {
audio.setVolume(this.stream_volume / 100) audio.setVolume(this.stream_volume / 100)
}, },
toggle_mute_volume() { change_volume() {
this.player.volume = this.player.volume > 0 ? 0 : this.old_volume webapi.player_volume(this.player.volume)
this.change_volume()
}, },
closeAudio() { closeAudio() {
audio.stop() audio.stop()
this.playing = false this.playing = false
@ -366,15 +361,12 @@ export default {
if (this.playing) { if (this.playing) {
return return
} }
const channel = '/stream.mp3'
this.loading = true this.loading = true
audio.play(channel) audio.play('/stream.mp3')
audio.setVolume(this.stream_volume / 100) audio.setVolume(this.stream_volume / 100)
}, },
setupAudio() { setupAudio() {
const a = audio.setup() const a = audio.setup()
a.addEventListener('waiting', (e) => { a.addEventListener('waiting', (e) => {
this.playing = false this.playing = false
this.loading = true this.loading = true
@ -402,9 +394,13 @@ export default {
return return
} }
if (this.playing) { if (this.playing) {
return this.closeAudio() this.closeAudio()
} }
return this.playChannel() this.playChannel()
},
toggle_mute_volume() {
this.player.volume = this.player.volume > 0 ? 0 : this.old_volume
this.change_volume()
} }
} }
} }

View File

@ -17,11 +17,11 @@ export default {
}, },
computed: { computed: {
is_active() {
return this.$store.state.lyrics.pane
},
icon_name() { icon_name() {
return this.is_active ? 'script-text-play' : 'script-text-outline' return this.is_active ? 'script-text-play' : 'script-text-outline'
},
is_active() {
return this.$store.state.lyrics.pane
} }
}, },

View File

@ -19,21 +19,9 @@ export default {
}, },
computed: { computed: {
is_playing() {
return this.$store.state.player.state === 'play'
},
is_pause_allowed() {
return (
this.$store.getters.now_playing &&
this.$store.getters.now_playing.data_kind !== 'pipe'
)
},
disabled() { disabled() {
return !this.$store.state.queue || this.$store.state.queue.count <= 0 return !this.$store.state.queue || this.$store.state.queue.count <= 0
}, },
icon_name() { icon_name() {
if (!this.is_playing) { if (!this.is_playing) {
return 'play' return 'play'
@ -41,6 +29,15 @@ export default {
return 'pause' return 'pause'
} }
return 'stop' return 'stop'
},
is_pause_allowed() {
return (
this.$store.getters.now_playing &&
this.$store.getters.now_playing.data_kind !== 'pipe'
)
},
is_playing() {
return this.$store.state.player.state === 'play'
} }
}, },
@ -50,9 +47,9 @@ export default {
if (this.show_disabled_message) { if (this.show_disabled_message) {
this.$store.dispatch('add_notification', { this.$store.dispatch('add_notification', {
text: this.$t('server.empty-queue'), text: this.$t('server.empty-queue'),
type: 'info', timeout: 2000,
topic: 'connection', topic: 'connection',
timeout: 2000 type: 'info'
}) })
} }
return return

View File

@ -19,15 +19,6 @@ export default {
}, },
computed: { computed: {
is_repeat_all() {
return this.$store.state.player.repeat === 'all'
},
is_repeat_single() {
return this.$store.state.player.repeat === 'single'
},
is_repeat_off() {
return !this.is_repeat_all && !this.is_repeat_single
},
icon_name() { icon_name() {
if (this.is_repeat_all) { if (this.is_repeat_all) {
return 'repeat' return 'repeat'
@ -35,6 +26,15 @@ export default {
return 'repeat-once' return 'repeat-once'
} }
return 'repeat-off' return 'repeat-off'
},
is_repeat_all() {
return this.$store.state.player.repeat === 'all'
},
is_repeat_off() {
return !this.is_repeat_all && !this.is_repeat_single
},
is_repeat_single() {
return this.$store.state.player.repeat === 'single'
} }
}, },

View File

@ -19,12 +19,6 @@ export default {
}, },
computed: { computed: {
now_playing() {
return this.$store.getters.now_playing
},
is_stopped() {
return this.$store.state.player.state === 'stop'
},
disabled() { disabled() {
return ( return (
!this.$store.state.queue || !this.$store.state.queue ||
@ -33,6 +27,12 @@ export default {
this.now_playing.data_kind === 'pipe' this.now_playing.data_kind === 'pipe'
) )
}, },
is_stopped() {
return this.$store.state.player.state === 'stop'
},
now_playing() {
return this.$store.getters.now_playing
},
visible() { visible() {
return ['podcast', 'audiobook'].includes(this.now_playing.media_kind) return ['podcast', 'audiobook'].includes(this.now_playing.media_kind)
} }

View File

@ -19,12 +19,6 @@ export default {
}, },
computed: { computed: {
now_playing() {
return this.$store.getters.now_playing
},
is_stopped() {
return this.$store.state.player.state === 'stop'
},
disabled() { disabled() {
return ( return (
!this.$store.state.queue || !this.$store.state.queue ||
@ -33,6 +27,12 @@ export default {
this.now_playing.data_kind === 'pipe' this.now_playing.data_kind === 'pipe'
) )
}, },
is_stopped() {
return this.$store.state.player.state === 'stop'
},
now_playing() {
return this.$store.getters.now_playing
},
visible() { visible() {
return ['podcast', 'audiobook'].includes(this.now_playing.media_kind) return ['podcast', 'audiobook'].includes(this.now_playing.media_kind)
} }

View File

@ -16,21 +16,18 @@ export default {
name: 'PlayerButtonShuffle', name: 'PlayerButtonShuffle',
props: { props: {
icon_size: { icon_size: { default: 16, type: Number }
type: Number,
default: 16
}
}, },
computed: { computed: {
is_shuffle() {
return this.$store.state.player.shuffle
},
icon_name() { icon_name() {
if (this.is_shuffle) { if (this.is_shuffle) {
return 'shuffle' return 'shuffle'
} }
return 'shuffle-disabled' return 'shuffle-disabled'
},
is_shuffle() {
return this.$store.state.player.shuffle
} }
}, },

View File

@ -40,6 +40,20 @@ export default {
}, },
computed: { computed: {
info() {
if (this.is_success) {
return this.$t('setting.saved')
} else if (this.is_error) {
return this.$t('setting.not-saved')
}
return ''
},
is_error() {
return this.statusUpdate === 'error'
},
is_success() {
return this.statusUpdate === 'success'
},
option() { option() {
const option = this.$store.getters.settings_option( const option = this.$store.getters.settings_option(
this.category_name, this.category_name,
@ -53,27 +67,16 @@ export default {
} }
} }
return option return option
},
info() {
if (this.is_success) {
return this.$t('setting.saved')
} else if (this.is_error) {
return this.$t('setting.not-saved')
}
return ''
},
is_success() {
return this.statusUpdate === 'success'
},
is_error() {
return this.statusUpdate === 'error'
} }
}, },
methods: { methods: {
clear_status() {
if (this.is_error) {
this.option.value = !this.option.value
}
this.statusUpdate = ''
},
update_setting() { update_setting() {
this.timerId = -1 this.timerId = -1
const option = { const option = {
@ -93,13 +96,6 @@ export default {
.finally(() => { .finally(() => {
this.timerId = window.setTimeout(this.clear_status, this.timerDelay) this.timerId = window.setTimeout(this.clear_status, this.timerDelay)
}) })
},
clear_status() {
if (this.is_error) {
this.option.value = !this.option.value
}
this.statusUpdate = ''
} }
} }
} }

View File

@ -41,9 +41,9 @@ export default {
data() { data() {
return { return {
statusUpdate: '',
timerDelay: 2000, timerDelay: 2000,
timerId: -1, timerId: -1
statusUpdate: ''
} }
}, },
@ -53,20 +53,6 @@ export default {
(elem) => elem.name === this.category_name (elem) => elem.name === this.category_name
) )
}, },
option() {
if (!this.category) {
return {}
}
return this.category.options.find(
(elem) => elem.name === this.option_name
)
},
value() {
return this.option.value
},
info() { info() {
if (this.statusUpdate === 'success') { if (this.statusUpdate === 'success') {
return this.$t('setting.saved') return this.$t('setting.saved')
@ -75,17 +61,29 @@ export default {
} }
return '' return ''
}, },
is_error() {
return this.statusUpdate === 'error'
},
is_success() { is_success() {
return this.statusUpdate === 'success' return this.statusUpdate === 'success'
}, },
option() {
is_error() { if (!this.category) {
return this.statusUpdate === 'error' return {}
}
return this.category.options.find(
(elem) => elem.name === this.option_name
)
},
value() {
return this.option.value
} }
}, },
methods: { methods: {
clear_status() {
this.statusUpdate = ''
},
set_update_timer() { set_update_timer() {
if (this.timerId > 0) { if (this.timerId > 0) {
window.clearTimeout(this.timerId) window.clearTimeout(this.timerId)
@ -98,16 +96,13 @@ export default {
this.timerId = window.setTimeout(this.update_setting, this.timerDelay) this.timerId = window.setTimeout(this.update_setting, this.timerDelay)
} }
}, },
update_setting() { update_setting() {
this.timerId = -1 this.timerId = -1
const newValue = this.$refs.setting.value const newValue = this.$refs.setting.value
if (newValue === this.value) { if (newValue === this.value) {
this.statusUpdate = '' this.statusUpdate = ''
return return
} }
const option = { const option = {
category: this.category.name, category: this.category.name,
name: this.option_name, name: this.option_name,
@ -126,10 +121,6 @@ export default {
.finally(() => { .finally(() => {
this.timerId = window.setTimeout(this.clear_status, this.timerDelay) this.timerId = window.setTimeout(this.clear_status, this.timerDelay)
}) })
},
clear_status() {
this.statusUpdate = ''
} }
} }
} }

View File

@ -40,9 +40,9 @@ export default {
data() { data() {
return { return {
statusUpdate: '',
timerDelay: 2000, timerDelay: 2000,
timerId: -1, timerId: -1
statusUpdate: ''
} }
}, },
@ -52,20 +52,6 @@ export default {
(elem) => elem.name === this.category_name (elem) => elem.name === this.category_name
) )
}, },
option() {
if (!this.category) {
return {}
}
return this.category.options.find(
(elem) => elem.name === this.option_name
)
},
value() {
return this.option.value
},
info() { info() {
if (this.statusUpdate === 'success') { if (this.statusUpdate === 'success') {
return this.$t('setting.saved') return this.$t('setting.saved')
@ -74,39 +60,47 @@ export default {
} }
return '' return ''
}, },
is_error() {
return this.statusUpdate === 'error'
},
is_success() { is_success() {
return this.statusUpdate === 'success' return this.statusUpdate === 'success'
}, },
option() {
is_error() { if (!this.category) {
return this.statusUpdate === 'error' return {}
}
return this.category.options.find(
(elem) => elem.name === this.option_name
)
},
value() {
return this.option.value
} }
}, },
methods: { methods: {
clear_status() {
this.statusUpdate = ''
},
set_update_timer() { set_update_timer() {
if (this.timerId > 0) { if (this.timerId > 0) {
window.clearTimeout(this.timerId) window.clearTimeout(this.timerId)
this.timerId = -1 this.timerId = -1
} }
this.statusUpdate = '' this.statusUpdate = ''
const newValue = this.$refs.setting.value const newValue = this.$refs.setting.value
if (newValue !== this.value) { if (newValue !== this.value) {
this.timerId = window.setTimeout(this.update_setting, this.timerDelay) this.timerId = window.setTimeout(this.update_setting, this.timerDelay)
} }
}, },
update_setting() { update_setting() {
this.timerId = -1 this.timerId = -1
const newValue = this.$refs.setting.value const newValue = this.$refs.setting.value
if (newValue === this.value) { if (newValue === this.value) {
this.statusUpdate = '' this.statusUpdate = ''
return return
} }
const option = { const option = {
category: this.category.name, category: this.category.name,
name: this.option_name, name: this.option_name,
@ -125,10 +119,6 @@ export default {
.finally(() => { .finally(() => {
this.timerId = window.setTimeout(this.clear_status, this.timerDelay) this.timerId = window.setTimeout(this.clear_status, this.timerDelay)
}) })
},
clear_status() {
this.statusUpdate = ''
} }
} }
} }

View File

@ -214,9 +214,9 @@ export default {
spotify_search(types) { spotify_search(types) {
return webapi.spotify().then(({ data }) => { return webapi.spotify().then(({ data }) => {
this.search_param.market = data.webapi_country this.search_param.market = data.webapi_country
const api = new SpotifyWebApi() const spotifyApi = new SpotifyWebApi()
api.setAccessToken(data.webapi_token) spotifyApi.setAccessToken(data.webapi_token)
return api.search(this.query.query, types, this.search_param) return spotifyApi.search(this.query.query, types, this.search_param)
}) })
} }
} }