mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-10 05:59:45 -05:00
[web] Format web sources with prettier and run fix linting errors
This commit is contained in:
@@ -1,33 +1,49 @@
|
||||
import axios from 'axios'
|
||||
import store from '@/store'
|
||||
|
||||
axios.interceptors.response.use(function (response) {
|
||||
return response
|
||||
}, function (error) {
|
||||
if (error.request.status && error.request.responseURL) {
|
||||
store.dispatch('add_notification', { text: 'Request failed (status: ' + error.request.status + ' ' + error.request.statusText + ', url: ' + error.request.responseURL + ')', type: 'danger' })
|
||||
axios.interceptors.response.use(
|
||||
function (response) {
|
||||
return response
|
||||
},
|
||||
function (error) {
|
||||
if (error.request.status && error.request.responseURL) {
|
||||
store.dispatch('add_notification', {
|
||||
text:
|
||||
'Request failed (status: ' +
|
||||
error.request.status +
|
||||
' ' +
|
||||
error.request.statusText +
|
||||
', url: ' +
|
||||
error.request.responseURL +
|
||||
')',
|
||||
type: 'danger'
|
||||
})
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
return Promise.reject(error)
|
||||
})
|
||||
)
|
||||
|
||||
export default {
|
||||
config () {
|
||||
config() {
|
||||
return axios.get('./api/config')
|
||||
},
|
||||
|
||||
settings () {
|
||||
settings() {
|
||||
return axios.get('./api/settings')
|
||||
},
|
||||
|
||||
settings_update (categoryName, option) {
|
||||
return axios.put('./api/settings/' + categoryName + '/' + option.name, option)
|
||||
settings_update(categoryName, option) {
|
||||
return axios.put(
|
||||
'./api/settings/' + categoryName + '/' + option.name,
|
||||
option
|
||||
)
|
||||
},
|
||||
|
||||
library_stats () {
|
||||
library_stats() {
|
||||
return axios.get('./api/library')
|
||||
},
|
||||
|
||||
library_update (scanKind) {
|
||||
library_update(scanKind) {
|
||||
const params = {}
|
||||
if (scanKind) {
|
||||
params.scan_kind = scanKind
|
||||
@@ -35,7 +51,7 @@ export default {
|
||||
return axios.put('./api/update', undefined, { params: params })
|
||||
},
|
||||
|
||||
library_rescan (scanKind) {
|
||||
library_rescan(scanKind) {
|
||||
const params = {}
|
||||
if (scanKind) {
|
||||
params.scan_kind = scanKind
|
||||
@@ -43,55 +59,73 @@ export default {
|
||||
return axios.put('./api/rescan', undefined, { params: params })
|
||||
},
|
||||
|
||||
library_count (expression) {
|
||||
library_count(expression) {
|
||||
return axios.get('./api/library/count?expression=' + expression)
|
||||
},
|
||||
|
||||
queue () {
|
||||
queue() {
|
||||
return axios.get('./api/queue')
|
||||
},
|
||||
|
||||
queue_clear () {
|
||||
queue_clear() {
|
||||
return axios.put('./api/queue/clear')
|
||||
},
|
||||
|
||||
queue_remove (itemId) {
|
||||
queue_remove(itemId) {
|
||||
return axios.delete('./api/queue/items/' + itemId)
|
||||
},
|
||||
|
||||
queue_move (itemId, newPosition) {
|
||||
return axios.put('./api/queue/items/' + itemId + '?new_position=' + newPosition)
|
||||
queue_move(itemId, newPosition) {
|
||||
return axios.put(
|
||||
'./api/queue/items/' + itemId + '?new_position=' + newPosition
|
||||
)
|
||||
},
|
||||
|
||||
queue_add (uri) {
|
||||
queue_add(uri) {
|
||||
return axios.post('./api/queue/items/add?uris=' + uri).then((response) => {
|
||||
store.dispatch('add_notification', { text: response.data.count + ' tracks appended to queue', type: 'info', timeout: 2000 })
|
||||
store.dispatch('add_notification', {
|
||||
text: response.data.count + ' tracks appended to queue',
|
||||
type: 'info',
|
||||
timeout: 2000
|
||||
})
|
||||
return Promise.resolve(response)
|
||||
})
|
||||
},
|
||||
|
||||
queue_add_next (uri) {
|
||||
queue_add_next(uri) {
|
||||
let position = 0
|
||||
if (store.getters.now_playing && store.getters.now_playing.id) {
|
||||
position = store.getters.now_playing.position + 1
|
||||
}
|
||||
return axios.post('./api/queue/items/add?uris=' + uri + '&position=' + position).then((response) => {
|
||||
store.dispatch('add_notification', { text: response.data.count + ' tracks appended to queue', type: 'info', timeout: 2000 })
|
||||
return Promise.resolve(response)
|
||||
})
|
||||
return axios
|
||||
.post('./api/queue/items/add?uris=' + uri + '&position=' + position)
|
||||
.then((response) => {
|
||||
store.dispatch('add_notification', {
|
||||
text: response.data.count + ' tracks appended to queue',
|
||||
type: 'info',
|
||||
timeout: 2000
|
||||
})
|
||||
return Promise.resolve(response)
|
||||
})
|
||||
},
|
||||
|
||||
queue_expression_add (expression) {
|
||||
queue_expression_add(expression) {
|
||||
const options = {}
|
||||
options.expression = expression
|
||||
|
||||
return axios.post('./api/queue/items/add', undefined, { params: options }).then((response) => {
|
||||
store.dispatch('add_notification', { text: response.data.count + ' tracks appended to queue', type: 'info', timeout: 2000 })
|
||||
return Promise.resolve(response)
|
||||
})
|
||||
return axios
|
||||
.post('./api/queue/items/add', undefined, { params: options })
|
||||
.then((response) => {
|
||||
store.dispatch('add_notification', {
|
||||
text: response.data.count + ' tracks appended to queue',
|
||||
type: 'info',
|
||||
timeout: 2000
|
||||
})
|
||||
return Promise.resolve(response)
|
||||
})
|
||||
},
|
||||
|
||||
queue_expression_add_next (expression) {
|
||||
queue_expression_add_next(expression) {
|
||||
const options = {}
|
||||
options.expression = expression
|
||||
options.position = 0
|
||||
@@ -99,24 +133,36 @@ export default {
|
||||
options.position = store.getters.now_playing.position + 1
|
||||
}
|
||||
|
||||
return axios.post('./api/queue/items/add', undefined, { params: options }).then((response) => {
|
||||
store.dispatch('add_notification', { text: response.data.count + ' tracks appended to queue', type: 'info', timeout: 2000 })
|
||||
return Promise.resolve(response)
|
||||
})
|
||||
return axios
|
||||
.post('./api/queue/items/add', undefined, { params: options })
|
||||
.then((response) => {
|
||||
store.dispatch('add_notification', {
|
||||
text: response.data.count + ' tracks appended to queue',
|
||||
type: 'info',
|
||||
timeout: 2000
|
||||
})
|
||||
return Promise.resolve(response)
|
||||
})
|
||||
},
|
||||
|
||||
queue_save_playlist (name) {
|
||||
return axios.post('./api/queue/save', undefined, { params: { name: name } }).then((response) => {
|
||||
store.dispatch('add_notification', { text: 'Queue saved to playlist "' + name + '"', type: 'info', timeout: 2000 })
|
||||
return Promise.resolve(response)
|
||||
})
|
||||
queue_save_playlist(name) {
|
||||
return axios
|
||||
.post('./api/queue/save', undefined, { params: { name: name } })
|
||||
.then((response) => {
|
||||
store.dispatch('add_notification', {
|
||||
text: 'Queue saved to playlist "' + name + '"',
|
||||
type: 'info',
|
||||
timeout: 2000
|
||||
})
|
||||
return Promise.resolve(response)
|
||||
})
|
||||
},
|
||||
|
||||
player_status () {
|
||||
player_status() {
|
||||
return axios.get('./api/player')
|
||||
},
|
||||
|
||||
player_play_uri (uris, shuffle, position = undefined) {
|
||||
player_play_uri(uris, shuffle, position = undefined) {
|
||||
const options = {}
|
||||
options.uris = uris
|
||||
options.shuffle = shuffle ? 'true' : 'false'
|
||||
@@ -127,7 +173,7 @@ export default {
|
||||
return axios.post('./api/queue/items/add', undefined, { params: options })
|
||||
},
|
||||
|
||||
player_play_expression (expression, shuffle, position = undefined) {
|
||||
player_play_expression(expression, shuffle, position = undefined) {
|
||||
const options = {}
|
||||
options.expression = expression
|
||||
options.shuffle = shuffle ? 'true' : 'false'
|
||||
@@ -138,111 +184,119 @@ export default {
|
||||
return axios.post('./api/queue/items/add', undefined, { params: options })
|
||||
},
|
||||
|
||||
player_play (options = {}) {
|
||||
player_play(options = {}) {
|
||||
return axios.put('./api/player/play', undefined, { params: options })
|
||||
},
|
||||
|
||||
player_playpos (position) {
|
||||
player_playpos(position) {
|
||||
return axios.put('./api/player/play?position=' + position)
|
||||
},
|
||||
|
||||
player_playid (itemId) {
|
||||
player_playid(itemId) {
|
||||
return axios.put('./api/player/play?item_id=' + itemId)
|
||||
},
|
||||
|
||||
player_pause () {
|
||||
player_pause() {
|
||||
return axios.put('./api/player/pause')
|
||||
},
|
||||
|
||||
player_stop () {
|
||||
player_stop() {
|
||||
return axios.put('./api/player/stop')
|
||||
},
|
||||
|
||||
player_next () {
|
||||
player_next() {
|
||||
return axios.put('./api/player/next')
|
||||
},
|
||||
|
||||
player_previous () {
|
||||
player_previous() {
|
||||
return axios.put('./api/player/previous')
|
||||
},
|
||||
|
||||
player_shuffle (newState) {
|
||||
player_shuffle(newState) {
|
||||
const shuffle = newState ? 'true' : 'false'
|
||||
return axios.put('./api/player/shuffle?state=' + shuffle)
|
||||
},
|
||||
|
||||
player_consume (newState) {
|
||||
player_consume(newState) {
|
||||
const consume = newState ? 'true' : 'false'
|
||||
return axios.put('./api/player/consume?state=' + consume)
|
||||
},
|
||||
|
||||
player_repeat (newRepeatMode) {
|
||||
player_repeat(newRepeatMode) {
|
||||
return axios.put('./api/player/repeat?state=' + newRepeatMode)
|
||||
},
|
||||
|
||||
player_volume (volume) {
|
||||
player_volume(volume) {
|
||||
return axios.put('./api/player/volume?volume=' + volume)
|
||||
},
|
||||
|
||||
player_output_volume (outputId, outputVolume) {
|
||||
return axios.put('./api/player/volume?volume=' + outputVolume + '&output_id=' + outputId)
|
||||
player_output_volume(outputId, outputVolume) {
|
||||
return axios.put(
|
||||
'./api/player/volume?volume=' + outputVolume + '&output_id=' + outputId
|
||||
)
|
||||
},
|
||||
|
||||
player_seek_to_pos (newPosition) {
|
||||
player_seek_to_pos(newPosition) {
|
||||
return axios.put('./api/player/seek?position_ms=' + newPosition)
|
||||
},
|
||||
|
||||
player_seek (seekMs) {
|
||||
player_seek(seekMs) {
|
||||
return axios.put('./api/player/seek?seek_ms=' + seekMs)
|
||||
},
|
||||
|
||||
outputs () {
|
||||
outputs() {
|
||||
return axios.get('./api/outputs')
|
||||
},
|
||||
|
||||
output_update (outputId, output) {
|
||||
output_update(outputId, output) {
|
||||
return axios.put('./api/outputs/' + outputId, output)
|
||||
},
|
||||
|
||||
output_toggle (outputId) {
|
||||
output_toggle(outputId) {
|
||||
return axios.put('./api/outputs/' + outputId + '/toggle')
|
||||
},
|
||||
|
||||
library_artists (media_kind = undefined) {
|
||||
return axios.get('./api/library/artists', { params: { media_kind: media_kind } })
|
||||
library_artists(media_kind = undefined) {
|
||||
return axios.get('./api/library/artists', {
|
||||
params: { media_kind: media_kind }
|
||||
})
|
||||
},
|
||||
|
||||
library_artist (artistId) {
|
||||
library_artist(artistId) {
|
||||
return axios.get('./api/library/artists/' + artistId)
|
||||
},
|
||||
|
||||
library_artist_albums (artistId) {
|
||||
library_artist_albums(artistId) {
|
||||
return axios.get('./api/library/artists/' + artistId + '/albums')
|
||||
},
|
||||
|
||||
library_albums (media_kind = undefined) {
|
||||
return axios.get('./api/library/albums', { params: { media_kind: media_kind } })
|
||||
library_albums(media_kind = undefined) {
|
||||
return axios.get('./api/library/albums', {
|
||||
params: { media_kind: media_kind }
|
||||
})
|
||||
},
|
||||
|
||||
library_album (albumId) {
|
||||
library_album(albumId) {
|
||||
return axios.get('./api/library/albums/' + albumId)
|
||||
},
|
||||
|
||||
library_album_tracks (albumId, filter = { limit: -1, offset: 0 }) {
|
||||
library_album_tracks(albumId, filter = { limit: -1, offset: 0 }) {
|
||||
return axios.get('./api/library/albums/' + albumId + '/tracks', {
|
||||
params: filter
|
||||
})
|
||||
},
|
||||
|
||||
library_album_track_update (albumId, attributes) {
|
||||
return axios.put('./api/library/albums/' + albumId + '/tracks', undefined, { params: attributes })
|
||||
library_album_track_update(albumId, attributes) {
|
||||
return axios.put('./api/library/albums/' + albumId + '/tracks', undefined, {
|
||||
params: attributes
|
||||
})
|
||||
},
|
||||
|
||||
library_genres () {
|
||||
library_genres() {
|
||||
return axios.get('./api/library/genres')
|
||||
},
|
||||
|
||||
library_genre (genre) {
|
||||
library_genre(genre) {
|
||||
const genreParams = {
|
||||
type: 'albums',
|
||||
media_kind: 'music',
|
||||
@@ -253,7 +307,7 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
library_genre_tracks (genre) {
|
||||
library_genre_tracks(genre) {
|
||||
const genreParams = {
|
||||
type: 'tracks',
|
||||
media_kind: 'music',
|
||||
@@ -264,7 +318,7 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
library_radio_streams () {
|
||||
library_radio_streams() {
|
||||
const params = {
|
||||
type: 'tracks',
|
||||
media_kind: 'music',
|
||||
@@ -275,11 +329,11 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
library_composers () {
|
||||
library_composers() {
|
||||
return axios.get('./api/library/composers')
|
||||
},
|
||||
|
||||
library_composer (composer) {
|
||||
library_composer(composer) {
|
||||
const params = {
|
||||
type: 'albums',
|
||||
media_kind: 'music',
|
||||
@@ -290,7 +344,7 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
library_composer_tracks (composer) {
|
||||
library_composer_tracks(composer) {
|
||||
const params = {
|
||||
type: 'tracks',
|
||||
media_kind: 'music',
|
||||
@@ -301,7 +355,7 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
library_artist_tracks (artist) {
|
||||
library_artist_tracks(artist) {
|
||||
if (artist) {
|
||||
const artistParams = {
|
||||
type: 'tracks',
|
||||
@@ -313,108 +367,114 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
library_podcasts_new_episodes () {
|
||||
library_podcasts_new_episodes() {
|
||||
const episodesParams = {
|
||||
type: 'tracks',
|
||||
expression: 'media_kind is podcast and play_count = 0 ORDER BY time_added DESC'
|
||||
expression:
|
||||
'media_kind is podcast and play_count = 0 ORDER BY time_added DESC'
|
||||
}
|
||||
return axios.get('./api/search', {
|
||||
params: episodesParams
|
||||
})
|
||||
},
|
||||
|
||||
library_podcast_episodes (albumId) {
|
||||
library_podcast_episodes(albumId) {
|
||||
const episodesParams = {
|
||||
type: 'tracks',
|
||||
expression: 'media_kind is podcast and songalbumid is "' + albumId + '" ORDER BY date_released DESC'
|
||||
expression:
|
||||
'media_kind is podcast and songalbumid is "' +
|
||||
albumId +
|
||||
'" ORDER BY date_released DESC'
|
||||
}
|
||||
return axios.get('./api/search', {
|
||||
params: episodesParams
|
||||
})
|
||||
},
|
||||
|
||||
library_add (url) {
|
||||
library_add(url) {
|
||||
return axios.post('./api/library/add', undefined, { params: { url: url } })
|
||||
},
|
||||
|
||||
library_playlist_delete (playlistId) {
|
||||
library_playlist_delete(playlistId) {
|
||||
return axios.delete('./api/library/playlists/' + playlistId, undefined)
|
||||
},
|
||||
|
||||
library_playlists () {
|
||||
library_playlists() {
|
||||
return axios.get('./api/library/playlists')
|
||||
},
|
||||
|
||||
library_playlist_folder (playlistId = 0) {
|
||||
library_playlist_folder(playlistId = 0) {
|
||||
return axios.get('./api/library/playlists/' + playlistId + '/playlists')
|
||||
},
|
||||
|
||||
library_playlist (playlistId) {
|
||||
library_playlist(playlistId) {
|
||||
return axios.get('./api/library/playlists/' + playlistId)
|
||||
},
|
||||
|
||||
library_playlist_tracks (playlistId) {
|
||||
library_playlist_tracks(playlistId) {
|
||||
return axios.get('./api/library/playlists/' + playlistId + '/tracks')
|
||||
},
|
||||
|
||||
library_track (trackId) {
|
||||
library_track(trackId) {
|
||||
return axios.get('./api/library/tracks/' + trackId)
|
||||
},
|
||||
|
||||
library_track_playlists (trackId) {
|
||||
library_track_playlists(trackId) {
|
||||
return axios.get('./api/library/tracks/' + trackId + '/playlists')
|
||||
},
|
||||
|
||||
library_track_update (trackId, attributes = {}) {
|
||||
return axios.put('./api/library/tracks/' + trackId, undefined, { params: attributes })
|
||||
library_track_update(trackId, attributes = {}) {
|
||||
return axios.put('./api/library/tracks/' + trackId, undefined, {
|
||||
params: attributes
|
||||
})
|
||||
},
|
||||
|
||||
library_files (directory = undefined) {
|
||||
library_files(directory = undefined) {
|
||||
const filesParams = { directory: directory }
|
||||
return axios.get('./api/library/files', {
|
||||
params: filesParams
|
||||
})
|
||||
},
|
||||
|
||||
search (searchParams) {
|
||||
search(searchParams) {
|
||||
return axios.get('./api/search', {
|
||||
params: searchParams
|
||||
})
|
||||
},
|
||||
|
||||
spotify () {
|
||||
spotify() {
|
||||
return axios.get('./api/spotify')
|
||||
},
|
||||
|
||||
spotify_login (credentials) {
|
||||
spotify_login(credentials) {
|
||||
return axios.post('./api/spotify-login', credentials)
|
||||
},
|
||||
|
||||
spotify_logout () {
|
||||
spotify_logout() {
|
||||
return axios.get('./api/spotify-logout')
|
||||
},
|
||||
|
||||
lastfm () {
|
||||
lastfm() {
|
||||
return axios.get('./api/lastfm')
|
||||
},
|
||||
|
||||
lastfm_login (credentials) {
|
||||
lastfm_login(credentials) {
|
||||
return axios.post('./api/lastfm-login', credentials)
|
||||
},
|
||||
|
||||
lastfm_logout (credentials) {
|
||||
lastfm_logout(credentials) {
|
||||
return axios.get('./api/lastfm-logout')
|
||||
},
|
||||
|
||||
pairing () {
|
||||
pairing() {
|
||||
return axios.get('./api/pairing')
|
||||
},
|
||||
|
||||
pairing_kickoff (pairingReq) {
|
||||
pairing_kickoff(pairingReq) {
|
||||
return axios.post('./api/pairing', pairingReq)
|
||||
},
|
||||
|
||||
artwork_url_append_size_params (artworkUrl, maxwidth = 600, maxheight = 600) {
|
||||
artwork_url_append_size_params(artworkUrl, maxwidth = 600, maxheight = 600) {
|
||||
if (artworkUrl && artworkUrl.startsWith('/')) {
|
||||
if (artworkUrl.includes('?')) {
|
||||
return artworkUrl + '&maxwidth=' + maxwidth + '&maxheight=' + maxheight
|
||||
|
||||
Reference in New Issue
Block a user