[web] Cleanup of code to simplify

Useless methods have been removed and code has been partially cleaned up.
This commit is contained in:
Alain Nussbaumer
2023-06-07 21:25:54 +02:00
parent 3a1cc63e8f
commit 387e531d64
84 changed files with 355 additions and 362 deletions

View File

@@ -32,7 +32,7 @@ export default {
},
computed: {
artwork_url_with_size: function () {
artwork_url_with_size() {
if (this.maxwidth > 0 && this.maxheight > 0) {
return webapi.artwork_url_append_size_params(
this.artwork_url,
@@ -59,7 +59,7 @@ export default {
},
methods: {
dataURI: function () {
dataURI() {
return renderSVG(this.caption, this.alt_text, {
width: this.width,
height: this.height,

View File

@@ -17,7 +17,7 @@ export default {
name: 'IndexButtonList',
props: ['index'],
methods: {
nav: function (id) {
nav(id) {
this.$router.push({ hash: '#index_' + id })
}
}

View File

@@ -95,13 +95,13 @@ export default {
).value
},
media_kind_resolved: function () {
media_kind_resolved() {
return this.media_kind ? this.media_kind : this.selected_album.media_kind
}
},
methods: {
open_album: function (album) {
open_album(album) {
this.selected_album = album
if (this.media_kind_resolved === 'podcast') {
this.$router.push({ path: '/podcasts/' + album.id })
@@ -112,12 +112,12 @@ export default {
}
},
open_dialog: function (album) {
open_dialog(album) {
this.selected_album = album
this.show_details_modal = true
},
open_remove_podcast_dialog: function () {
open_remove_podcast_dialog() {
webapi
.library_album_tracks(this.selected_album.id, { limit: 1 })
.then(({ data }) => {
@@ -131,11 +131,11 @@ export default {
})
},
play_count_changed: function () {
play_count_changed() {
this.$emit('play-count-changed')
},
remove_podcast: function () {
remove_podcast() {
this.show_remove_podcast_modal = false
webapi
.library_playlist_delete(this.rss_playlist_to_remove.id)

View File

@@ -53,13 +53,13 @@ export default {
},
computed: {
media_kind_resolved: function () {
media_kind_resolved() {
return this.media_kind ? this.media_kind : this.selected_artist.media_kind
}
},
methods: {
open_artist: function (artist) {
open_artist(artist) {
this.selected_artist = artist
if (this.media_kind_resolved === 'audiobook') {
this.$router.push({ path: '/audiobooks/artists/' + artist.id })
@@ -68,7 +68,7 @@ export default {
}
},
open_dialog: function (artist) {
open_dialog(artist) {
this.selected_artist = artist
this.show_details_modal = true
}

View File

@@ -52,7 +52,7 @@ export default {
},
computed: {
media_kind_resolved: function () {
media_kind_resolved() {
return this.media_kind
? this.media_kind
: this.selected_composer.media_kind
@@ -60,7 +60,7 @@ export default {
},
methods: {
open_composer: function (composer) {
open_composer(composer) {
this.selected_composer = composer
this.$router.push({
name: 'ComposerAlbums',
@@ -68,7 +68,7 @@ export default {
})
},
open_dialog: function (composer) {
open_dialog(composer) {
this.selected_composer = composer
this.show_details_modal = true
}

View File

@@ -72,7 +72,7 @@ export default {
},
methods: {
open_parent_directory: function () {
open_parent_directory() {
const parent = this.current_directory.slice(
0,
this.current_directory.lastIndexOf('/')
@@ -95,14 +95,14 @@ export default {
}
},
open_directory: function (directory) {
open_directory(directory) {
this.$router.push({
path: '/files',
query: { directory: directory.path }
})
},
open_dialog: function (directory) {
open_dialog(directory) {
this.selected_directory = directory
this.show_details_modal = true
}

View File

@@ -48,17 +48,17 @@ export default {
},
computed: {
media_kind_resolved: function () {
media_kind_resolved() {
return this.media_kind ? this.media_kind : this.selected_genre.media_kind
}
},
methods: {
open_genre: function (genre) {
open_genre(genre) {
this.$router.push({ name: 'Genre', params: { genre: genre.name } })
},
open_dialog: function (genre) {
open_dialog(genre) {
this.selected_genre = genre
this.show_details_modal = true
}

View File

@@ -64,7 +64,7 @@ export default {
},
methods: {
play: function () {
play() {
webapi.player_play({ item_id: this.item.id })
}
}

View File

@@ -48,7 +48,7 @@ export default {
},
methods: {
open_playlist: function (playlist) {
open_playlist(playlist) {
if (playlist.type !== 'folder') {
this.$router.push({ path: '/playlists/' + playlist.id + '/tracks' })
} else {
@@ -56,12 +56,12 @@ export default {
}
},
open_dialog: function (playlist) {
open_dialog(playlist) {
this.selected_playlist = playlist
this.show_details_modal = true
},
icon_name: function (playlist) {
icon_name(playlist) {
if (playlist.type === 'folder') {
return 'folder'
} else if (playlist.type === 'rss') {

View File

@@ -72,7 +72,7 @@ export default {
},
methods: {
play_track: function (position, track) {
play_track(position, track) {
if (this.uris) {
webapi.player_play_uri(this.uris, false, position)
} else if (this.expression) {
@@ -82,7 +82,7 @@ export default {
}
},
open_dialog: function (track) {
open_dialog(track) {
this.selected_track = track
this.show_details_modal = true
}

View File

@@ -94,7 +94,7 @@ export default {
},
methods: {
add_stream: function () {
add_stream() {
this.loading = true
webapi
.library_add(this.url)

View File

@@ -100,7 +100,7 @@ export default {
},
methods: {
add_stream: function () {
add_stream() {
this.loading = true
webapi
.queue_add(this.url)
@@ -113,7 +113,7 @@ export default {
})
},
play: function () {
play() {
this.loading = true
webapi
.player_play_uri(this.url, false)

View File

@@ -134,32 +134,32 @@ export default {
},
computed: {
artwork_url: function () {
artwork_url() {
return webapi.artwork_url_append_size_params(this.album.artwork_url)
},
media_kind_resolved: function () {
media_kind_resolved() {
return this.media_kind ? this.media_kind : this.album.media_kind
}
},
methods: {
play: function () {
play() {
this.$emit('close')
webapi.player_play_uri(this.album.uri, false)
},
queue_add: function () {
queue_add() {
this.$emit('close')
webapi.queue_add(this.album.uri)
},
queue_add_next: function () {
queue_add_next() {
this.$emit('close')
webapi.queue_add_next(this.album.uri)
},
open_album: function () {
open_album() {
this.$emit('close')
if (this.media_kind_resolved === 'podcast') {
this.$router.push({ path: '/podcasts/' + this.album.id })
@@ -170,7 +170,7 @@ export default {
}
},
open_artist: function () {
open_artist() {
this.$emit('close')
if (this.media_kind_resolved === 'audiobook') {
this.$router.push({
@@ -181,7 +181,7 @@ export default {
}
},
mark_played: function () {
mark_played() {
webapi
.library_album_track_update(this.album.id, { play_count: 'played' })
.then(({ data }) => {
@@ -190,11 +190,11 @@ export default {
})
},
artwork_loaded: function () {
artwork_loaded() {
this.artwork_visible = true
},
artwork_error: function () {
artwork_error() {
this.artwork_visible = false
}
}

View File

@@ -77,22 +77,22 @@ export default {
emits: ['close'],
methods: {
play: function () {
play() {
this.$emit('close')
webapi.player_play_uri(this.artist.uri, false)
},
queue_add: function () {
queue_add() {
this.$emit('close')
webapi.queue_add(this.artist.uri)
},
queue_add_next: function () {
queue_add_next() {
this.$emit('close')
webapi.queue_add_next(this.artist.uri)
},
open_artist: function () {
open_artist() {
this.$emit('close')
this.$router.push({ path: '/music/artists/' + this.artist.id })
}

View File

@@ -79,7 +79,7 @@ export default {
emits: ['close'],
methods: {
play: function () {
play() {
this.$emit('close')
webapi.player_play_expression(
'composer is "' + this.composer.name + '" and media_kind is music',
@@ -87,21 +87,21 @@ export default {
)
},
queue_add: function () {
queue_add() {
this.$emit('close')
webapi.queue_expression_add(
'composer is "' + this.composer.name + '" and media_kind is music'
)
},
queue_add_next: function () {
queue_add_next() {
this.$emit('close')
webapi.queue_expression_add_next(
'composer is "' + this.composer.name + '" and media_kind is music'
)
},
open_albums: function () {
open_albums() {
this.$emit('close')
this.$router.push({
name: 'ComposerAlbums',
@@ -109,7 +109,7 @@ export default {
})
},
open_tracks: function () {
open_tracks() {
this.show_details_modal = false
this.$router.push({
name: 'ComposerTracks',

View File

@@ -50,7 +50,7 @@ export default {
emits: ['close'],
methods: {
play: function () {
play() {
this.$emit('close')
webapi.player_play_expression(
'path starts with "' + this.directory.path + '" order by path asc',
@@ -58,14 +58,14 @@ export default {
)
},
queue_add: function () {
queue_add() {
this.$emit('close')
webapi.queue_expression_add(
'path starts with "' + this.directory.path + '" order by path asc'
)
},
queue_add_next: function () {
queue_add_next() {
this.$emit('close')
webapi.queue_expression_add_next(
'path starts with "' + this.directory.path + '" order by path asc'

View File

@@ -70,7 +70,7 @@ export default {
emits: ['close'],
methods: {
play: function () {
play() {
this.$emit('close')
webapi.player_play_expression(
'genre is "' + this.genre.name + '" and media_kind is music',
@@ -78,21 +78,21 @@ export default {
)
},
queue_add: function () {
queue_add() {
this.$emit('close')
webapi.queue_expression_add(
'genre is "' + this.genre.name + '" and media_kind is music'
)
},
queue_add_next: function () {
queue_add_next() {
this.$emit('close')
webapi.queue_expression_add_next(
'genre is "' + this.genre.name + '" and media_kind is music'
)
},
open_genre: function () {
open_genre() {
this.$emit('close')
this.$router.push({ name: 'Genre', params: { genre: this.genre.name } })
}

View File

@@ -73,22 +73,22 @@ export default {
emits: ['close'],
methods: {
play: function () {
play() {
this.$emit('close')
webapi.player_play_uri(this.uris ? this.uris : this.playlist.uri, false)
},
queue_add: function () {
queue_add() {
this.$emit('close')
webapi.queue_add(this.uris ? this.uris : this.playlist.uri)
},
queue_add_next: function () {
queue_add_next() {
this.$emit('close')
webapi.queue_add_next(this.uris ? this.uris : this.playlist.uri)
},
open_playlist: function () {
open_playlist() {
this.$emit('close')
this.$router.push({ path: '/playlists/' + this.playlist.id + '/tracks' })
}

View File

@@ -99,7 +99,7 @@ export default {
},
methods: {
save: function () {
save() {
if (this.playlist_name.length < 1) {
return
}

View File

@@ -197,17 +197,17 @@ export default {
},
methods: {
remove: function () {
remove() {
this.$emit('close')
webapi.queue_remove(this.item.id)
},
play: function () {
play() {
this.$emit('close')
webapi.player_play({ item_id: this.item.id })
},
open_album: function () {
open_album() {
if (this.media_kind === 'podcast') {
this.$router.push({ path: '/podcasts/' + this.item.album_id })
} else if (this.media_kind === 'audiobook') {
@@ -217,22 +217,22 @@ export default {
}
},
open_album_artist: function () {
open_album_artist() {
this.$router.push({ path: '/music/artists/' + this.item.album_artist_id })
},
open_genre: function () {
open_genre() {
this.$router.push({ name: 'Genre', params: { genre: this.item.genre } })
},
open_spotify_artist: function () {
open_spotify_artist() {
this.$emit('close')
this.$router.push({
path: '/music/spotify/artists/' + this.spotify_track.artists[0].id
})
},
open_spotify_album: function () {
open_spotify_album() {
this.$emit('close')
this.$router.push({
path: '/music/spotify/albums/' + this.spotify_track.album.id

View File

@@ -229,22 +229,22 @@ export default {
},
methods: {
play_track: function () {
play_track() {
this.$emit('close')
webapi.player_play_uri(this.track.uri, false)
},
queue_add: function () {
queue_add() {
this.$emit('close')
webapi.queue_add(this.track.uri)
},
queue_add_next: function () {
queue_add_next() {
this.$emit('close')
webapi.queue_add_next(this.track.uri)
},
open_album: function () {
open_album() {
this.$emit('close')
if (this.track.media_kind === 'podcast') {
this.$router.push({ path: '/podcasts/' + this.track.album_id })
@@ -255,32 +255,32 @@ export default {
}
},
open_artist: function () {
open_artist() {
this.$emit('close')
this.$router.push({
path: '/music/artists/' + this.track.album_artist_id
})
},
open_genre: function () {
open_genre() {
this.$router.push({ name: 'Genre', params: { genre: this.track.genre } })
},
open_spotify_artist: function () {
open_spotify_artist() {
this.$emit('close')
this.$router.push({
path: '/music/spotify/artists/' + this.spotify_track.artists[0].id
})
},
open_spotify_album: function () {
open_spotify_album() {
this.$emit('close')
this.$router.push({
path: '/music/spotify/albums/' + this.spotify_track.album.id
})
},
mark_new: function () {
mark_new() {
webapi
.library_track_update(this.track.id, { play_count: 'reset' })
.then(() => {
@@ -289,7 +289,7 @@ export default {
})
},
mark_played: function () {
mark_played() {
webapi
.library_track_update(this.track.id, { play_count: 'increment' })
.then(() => {

View File

@@ -412,12 +412,12 @@ export default {
}
},
// on app mounted
// On app mounted
mounted() {
this.setupAudio()
},
// on app destroyed
// On app destroyed
unmounted() {
this.closeAudio()
},
@@ -427,11 +427,11 @@ export default {
this.show_outputs_menu = false
},
set_volume: function (newVolume) {
set_volume(newVolume) {
webapi.player_volume(newVolume)
},
toggle_mute_volume: function () {
toggle_mute_volume() {
if (this.player.volume > 0) {
this.set_volume(0)
} else {
@@ -439,7 +439,7 @@ export default {
}
},
setupAudio: function () {
setupAudio() {
const a = _audio.setupAudio()
a.addEventListener('waiting', (e) => {
@@ -465,13 +465,13 @@ export default {
})
},
// close active audio
closeAudio: function () {
// Close active audio
closeAudio() {
_audio.stopAudio()
this.playing = false
},
playChannel: function () {
playChannel() {
if (this.playing) {
return
}
@@ -482,7 +482,7 @@ export default {
_audio.setVolume(this.stream_volume / 100)
},
togglePlay: function () {
togglePlay() {
if (this.loading) {
return
}
@@ -492,7 +492,7 @@ export default {
return this.playChannel()
},
set_stream_volume: function (newVolume) {
set_stream_volume(newVolume) {
this.stream_volume = newVolume
_audio.setVolume(this.stream_volume / 100)
}

View File

@@ -47,7 +47,7 @@ export default {
},
methods: {
open_link: function () {
open_link() {
if (this.show_burger_menu) {
this.$store.commit(types.SHOW_BURGER_MENU, false)
}
@@ -57,7 +57,7 @@ export default {
this.$router.push({ path: this.to })
},
full_path: function () {
full_path() {
const resolved = this.$router.resolve(this.to)
return resolved.href
}

View File

@@ -67,15 +67,15 @@ export default {
},
methods: {
play_next: function () {
play_next() {
webapi.player_next()
},
set_volume: function (newVolume) {
set_volume(newVolume) {
webapi.player_output_volume(this.output.id, newVolume)
},
set_enabled: function () {
set_enabled() {
const values = {
selected: !this.output.selected
}

View File

@@ -37,7 +37,7 @@ export default {
},
methods: {
remove: function (notification) {
remove(notification) {
this.$store.commit(types.DELETE_NOTIFICATION, notification)
}
}

View File

@@ -29,7 +29,7 @@ export default {
},
methods: {
toggle_consume_mode: function () {
toggle_consume_mode() {
webapi.player_consume(!this.is_consume)
}
}

View File

@@ -29,7 +29,7 @@ export default {
},
methods: {
play_next: function () {
play_next() {
if (this.disabled) {
return
}

View File

@@ -50,7 +50,7 @@ export default {
},
methods: {
toggle_play_pause: function () {
toggle_play_pause() {
if (this.disabled) {
if (this.show_disabled_message) {
this.$store.dispatch('add_notification', {

View File

@@ -29,7 +29,7 @@ export default {
},
methods: {
play_previous: function () {
play_previous() {
if (this.disabled) {
return
}

View File

@@ -43,7 +43,7 @@ export default {
},
methods: {
toggle_repeat_mode: function () {
toggle_repeat_mode() {
if (this.is_repeat_all) {
webapi.player_repeat('single')
} else if (this.is_repeat_single) {

View File

@@ -43,7 +43,7 @@ export default {
},
methods: {
seek: function () {
seek() {
if (!this.disabled) {
webapi.player_seek(this.seek_ms * -1)
}

View File

@@ -43,7 +43,7 @@ export default {
},
methods: {
seek: function () {
seek() {
if (!this.disabled) {
webapi.player_seek(this.seek_ms)
}

View File

@@ -35,7 +35,7 @@ export default {
},
methods: {
toggle_shuffle_mode: function () {
toggle_shuffle_mode() {
webapi.player_shuffle(!this.is_shuffle)
}
}

View File

@@ -118,7 +118,7 @@ export default {
})
},
clear_status: function () {
clear_status() {
this.statusUpdate = ''
}
}

View File

@@ -125,7 +125,7 @@ export default {
})
},
clear_status: function () {
clear_status() {
this.statusUpdate = ''
}
}

View File

@@ -124,7 +124,7 @@ export default {
})
},
clear_status: function () {
clear_status() {
this.statusUpdate = ''
}
}

View File

@@ -15,7 +15,7 @@ export default {
props: ['artist'],
methods: {
open_artist: function () {
open_artist() {
this.$router.push({ path: '/music/spotify/artists/' + this.artist.id })
}
}

View File

@@ -16,7 +16,7 @@ export default {
props: ['playlist'],
methods: {
open_playlist: function () {
open_playlist() {
this.$router.push({
path: '/music/spotify/playlists/' + this.playlist.id
})

View File

@@ -39,7 +39,7 @@ export default {
name: 'SpotifyListItemTrack',
props: ['track', 'position', 'album', 'context_uri'],
methods: {
play: function () {
play() {
webapi.player_play_uri(this.context_uri, false, this.position)
}
}

View File

@@ -108,7 +108,7 @@ export default {
},
computed: {
artwork_url: function () {
artwork_url() {
if (this.album.images && this.album.images.length > 0) {
return this.album.images[0].url
}
@@ -117,36 +117,36 @@ export default {
},
methods: {
play: function () {
play() {
this.$emit('close')
webapi.player_play_uri(this.album.uri, false)
},
queue_add: function () {
queue_add() {
this.$emit('close')
webapi.queue_add(this.album.uri)
},
queue_add_next: function () {
queue_add_next() {
this.$emit('close')
webapi.queue_add_next(this.album.uri)
},
open_album: function () {
open_album() {
this.$router.push({ path: '/music/spotify/albums/' + this.album.id })
},
open_artist: function () {
open_artist() {
this.$router.push({
path: '/music/spotify/artists/' + this.album.artists[0].id
})
},
artwork_loaded: function () {
artwork_loaded() {
this.artwork_visible = true
},
artwork_error: function () {
artwork_error() {
this.artwork_visible = false
}
}

View File

@@ -83,22 +83,22 @@ export default {
emits: ['close'],
methods: {
play: function () {
play() {
this.$emit('close')
webapi.player_play_uri(this.artist.uri, false)
},
queue_add: function () {
queue_add() {
this.$emit('close')
webapi.queue_add(this.artist.uri)
},
queue_add_next: function () {
queue_add_next() {
this.$emit('close')
webapi.queue_add_next(this.artist.uri)
},
open_artist: function () {
open_artist() {
this.$router.push({ path: '/music/spotify/artists/' + this.artist.id })
}
}

View File

@@ -88,22 +88,22 @@ export default {
emits: ['close'],
methods: {
play: function () {
play() {
this.$emit('close')
webapi.player_play_uri(this.playlist.uri, false)
},
queue_add: function () {
queue_add() {
this.$emit('close')
webapi.queue_add(this.playlist.uri)
},
queue_add_next: function () {
queue_add_next() {
this.$emit('close')
webapi.queue_add_next(this.playlist.uri)
},
open_playlist: function () {
open_playlist() {
this.$router.push({
path: '/music/spotify/playlists/' + this.playlist.id
})

View File

@@ -118,26 +118,26 @@ export default {
emits: ['close'],
methods: {
play: function () {
play() {
this.$emit('close')
webapi.player_play_uri(this.track.uri, false)
},
queue_add: function () {
queue_add() {
this.$emit('close')
webapi.queue_add(this.track.uri)
},
queue_add_next: function () {
queue_add_next() {
this.$emit('close')
webapi.queue_add_next(this.track.uri)
},
open_album: function () {
open_album() {
this.$router.push({ path: '/music/spotify/albums/' + this.album.id })
},
open_artist: function () {
open_artist() {
this.$router.push({
path: '/music/spotify/artists/' + this.album.artists[0].id
})

View File

@@ -50,7 +50,7 @@ export default {
return this.$store.state.spotify.webapi_token_valid
},
route_query: function () {
route_query() {
if (!this.query) {
return null
}
@@ -65,7 +65,7 @@ export default {
},
methods: {
search_library: function () {
search_library() {
this.$store.commit(types.SEARCH_PATH, '/search/library')
this.$router.push({
path: this.$store.state.search_path,
@@ -73,7 +73,7 @@ export default {
})
},
search_spotify: function () {
search_spotify() {
this.$store.commit(types.SEARCH_PATH, '/search/spotify')
this.$router.push({
path: this.$store.state.search_path,