mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-30 15:11:25 -04:00
[web] Lint source code
This commit is contained in:
parent
5c7ec031b5
commit
095d60af00
@ -67,9 +67,8 @@ export default {
|
|||||||
return 'folder'
|
return 'folder'
|
||||||
} else if (playlist.type === 'rss') {
|
} else if (playlist.type === 'rss') {
|
||||||
return 'rss'
|
return 'rss'
|
||||||
} else {
|
|
||||||
return 'music-box-multiple'
|
|
||||||
}
|
}
|
||||||
|
return 'music-box-multiple'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ export default {
|
|||||||
* Distinguish scroll event triggered by a user or programmatically
|
* Distinguish scroll event triggered by a user or programmatically
|
||||||
* Programmatically triggered event are ignored
|
* Programmatically triggered event are ignored
|
||||||
*/
|
*/
|
||||||
if (!e.screenX || e.screenX == 0 || !e.screenY || e.screenY == 0) return
|
if (!e.screenX || e.screenX == 0 || !e.screenY || e.screenY == 0) return
|
||||||
this.autoScroll = false
|
this.autoScroll = false
|
||||||
if (this.scrollTimer) clearTimeout(this.scrollTimer)
|
if (this.scrollTimer) clearTimeout(this.scrollTimer)
|
||||||
let t = this
|
let t = this
|
||||||
|
@ -64,9 +64,8 @@ export default {
|
|||||||
return 'cast'
|
return 'cast'
|
||||||
} else if (this.output.type === 'fifo') {
|
} else if (this.output.type === 'fifo') {
|
||||||
return 'pipe'
|
return 'pipe'
|
||||||
} else {
|
|
||||||
return 'server'
|
|
||||||
}
|
}
|
||||||
|
return 'server'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@ export const filters = {
|
|||||||
durationInHours(value_ms) {
|
durationInHours(value_ms) {
|
||||||
const seconds = Math.floor(value_ms / 1000)
|
const seconds = Math.floor(value_ms / 1000)
|
||||||
if (seconds > 3600) {
|
if (seconds > 3600) {
|
||||||
return Duration.fromObject({ seconds: seconds })
|
return Duration.fromObject({ seconds })
|
||||||
.shiftTo('hours', 'minutes', 'seconds')
|
.shiftTo('hours', 'minutes', 'seconds')
|
||||||
.toFormat('hh:mm:ss')
|
.toFormat('hh:mm:ss')
|
||||||
}
|
}
|
||||||
return Duration.fromObject({ seconds: seconds })
|
return Duration.fromObject({ seconds })
|
||||||
.shiftTo('minutes', 'seconds')
|
.shiftTo('minutes', 'seconds')
|
||||||
.toFormat('mm:ss')
|
.toFormat('mm:ss')
|
||||||
},
|
},
|
||||||
@ -19,18 +19,15 @@ export const filters = {
|
|||||||
durationInDays(value_ms) {
|
durationInDays(value_ms) {
|
||||||
const minutes = Math.floor(value_ms / 60000)
|
const minutes = Math.floor(value_ms / 60000)
|
||||||
if (minutes > 1440) {
|
if (minutes > 1440) {
|
||||||
// 60 * 24
|
return Duration.fromObject({ minutes })
|
||||||
return Duration.fromObject({ minutes: minutes })
|
|
||||||
.shiftTo('days', 'hours', 'minutes')
|
.shiftTo('days', 'hours', 'minutes')
|
||||||
.toHuman()
|
.toHuman()
|
||||||
} else if (minutes > 60) {
|
} else if (minutes > 60) {
|
||||||
return Duration.fromObject({ minutes: minutes })
|
return Duration.fromObject({ minutes })
|
||||||
.shiftTo('hours', 'minutes')
|
.shiftTo('hours', 'minutes')
|
||||||
.toHuman()
|
.toHuman()
|
||||||
}
|
}
|
||||||
return Duration.fromObject({ minutes: minutes })
|
return Duration.fromObject({ minutes }).shiftTo('minutes').toHuman()
|
||||||
.shiftTo('minutes')
|
|
||||||
.toHuman()
|
|
||||||
},
|
},
|
||||||
|
|
||||||
date(value) {
|
date(value) {
|
||||||
|
@ -26,9 +26,8 @@ export function byName(field, keepSortOrder = false, defaultValue = '_') {
|
|||||||
return value.toUpperCase()
|
return value.toUpperCase()
|
||||||
} else if (value.match(/\p{Number}/gu)) {
|
} else if (value.match(/\p{Number}/gu)) {
|
||||||
return '#'
|
return '#'
|
||||||
} else {
|
|
||||||
return '⌘'
|
|
||||||
}
|
}
|
||||||
|
return '⌘'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,9 +136,11 @@ export class GroupByList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Symbol.iterator]() {
|
[Symbol.iterator]() {
|
||||||
// Use a new index for each iterator. This makes multiple
|
/*
|
||||||
// iterations over the iterable safe for non-trivial cases,
|
* Use a new index for each iterator. This makes multiple
|
||||||
// such as use of break or nested looping over the same iterable.
|
* iterations over the iterable safe for non-trivial cases,
|
||||||
|
* such as use of break or nested looping over the same iterable.
|
||||||
|
*/
|
||||||
let groupIndex = -1
|
let groupIndex = -1
|
||||||
let itemIndex = -1
|
let itemIndex = -1
|
||||||
|
|
||||||
@ -148,16 +149,18 @@ export class GroupByList {
|
|||||||
if (this.isEmpty()) {
|
if (this.isEmpty()) {
|
||||||
return { done: true }
|
return { done: true }
|
||||||
} else if (groupIndex >= this.indexList.length) {
|
} else if (groupIndex >= this.indexList.length) {
|
||||||
// We reached the end of all groups and items
|
/*
|
||||||
//
|
* End of all groups and items reached
|
||||||
// This should never happen, as the we already
|
* This should never happen, as the we already
|
||||||
// return "done" after we reached the last item
|
* return "done" after we reached the last item
|
||||||
// of the last group
|
* of the last group
|
||||||
|
*/
|
||||||
return { done: true }
|
return { done: true }
|
||||||
} else if (groupIndex < 0) {
|
} else if (groupIndex < 0) {
|
||||||
// We start iterating
|
/*
|
||||||
//
|
* Start iterating
|
||||||
// Return the first group title as the next item
|
* Return the first group title as the next item
|
||||||
|
*/
|
||||||
++groupIndex
|
++groupIndex
|
||||||
itemIndex = 0
|
itemIndex = 0
|
||||||
|
|
||||||
@ -179,9 +182,10 @@ export class GroupByList {
|
|||||||
let currentGroupItems = this.itemsByGroup[currentGroupKey]
|
let currentGroupItems = this.itemsByGroup[currentGroupKey]
|
||||||
|
|
||||||
if (itemIndex < currentGroupItems.length) {
|
if (itemIndex < currentGroupItems.length) {
|
||||||
// We are in a group with items left
|
/*
|
||||||
//
|
* Within a group with remaining items
|
||||||
// Return the current item and increment the item index
|
* Return the current item and increment the item index
|
||||||
|
*/
|
||||||
const currentItem = this.itemsByGroup[currentGroupKey][itemIndex++]
|
const currentItem = this.itemsByGroup[currentGroupKey][itemIndex++]
|
||||||
return {
|
return {
|
||||||
value: {
|
value: {
|
||||||
@ -192,30 +196,29 @@ export class GroupByList {
|
|||||||
},
|
},
|
||||||
done: false
|
done: false
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
// We reached the end of the current groups item list
|
/*
|
||||||
//
|
* End of the current groups item list reached
|
||||||
// Move to the next group and return the group key/title
|
* Move to the next group and return the group key/title
|
||||||
// as the next item
|
* as the next item
|
||||||
++groupIndex
|
*/
|
||||||
itemIndex = 0
|
++groupIndex
|
||||||
|
itemIndex = 0
|
||||||
|
|
||||||
if (groupIndex < this.indexList.length) {
|
if (groupIndex < this.indexList.length) {
|
||||||
currentGroupKey = this.indexList[groupIndex]
|
currentGroupKey = this.indexList[groupIndex]
|
||||||
return {
|
return {
|
||||||
value: {
|
value: {
|
||||||
groupKey: currentGroupKey,
|
groupKey: currentGroupKey,
|
||||||
itemId: currentGroupKey,
|
itemId: currentGroupKey,
|
||||||
isItem: false,
|
isItem: false,
|
||||||
item: {}
|
item: {}
|
||||||
},
|
},
|
||||||
done: false
|
done: false
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// No group left, we are done iterating
|
|
||||||
return { done: true }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// No group left, we are done iterating
|
||||||
|
return { done: true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ function renderSVG(caption, alt_text, params) {
|
|||||||
height: params.height,
|
height: params.height,
|
||||||
textColor: text_color,
|
textColor: text_color,
|
||||||
backgroundColor: background_color,
|
backgroundColor: background_color,
|
||||||
caption: caption,
|
caption,
|
||||||
fontFamily: params.font_family,
|
fontFamily: params.font_family,
|
||||||
fontSize: params.font_size,
|
fontSize: params.font_size,
|
||||||
fontWeight: params.font_weight
|
fontWeight: params.font_weight
|
||||||
|
@ -81,7 +81,7 @@ import webapi from '@/webapi'
|
|||||||
const PAGE_SIZE = 50
|
const PAGE_SIZE = 50
|
||||||
|
|
||||||
const dataObject = {
|
const dataObject = {
|
||||||
load: function (to) {
|
load(to) {
|
||||||
const spotifyApi = new SpotifyWebApi()
|
const spotifyApi = new SpotifyWebApi()
|
||||||
spotifyApi.setAccessToken(store.state.spotify.webapi_token)
|
spotifyApi.setAccessToken(store.state.spotify.webapi_token)
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
|
@ -60,9 +60,7 @@ const dataObject = {
|
|||||||
vm.playlists = new GroupByList(response.data.playlists)
|
vm.playlists = new GroupByList(response.data.playlists)
|
||||||
vm.tracks = new GroupByList(response.data.tracks)
|
vm.tracks = new GroupByList(response.data.tracks)
|
||||||
} else {
|
} else {
|
||||||
vm.dirs = vm.$store.state.config.directories.map((dir) => {
|
vm.dirs = vm.$store.state.config.directories.map((dir) => ({ path: dir }))
|
||||||
return { path: dir }
|
|
||||||
})
|
|
||||||
vm.playlists = new GroupByList()
|
vm.playlists = new GroupByList()
|
||||||
vm.tracks = new GroupByList()
|
vm.tracks = new GroupByList()
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ const dataObject = {
|
|||||||
type: 'album',
|
type: 'album',
|
||||||
expression:
|
expression:
|
||||||
'media_kind is music having track_count > 3 order by time_added desc',
|
'media_kind is music having track_count > 3 order by time_added desc',
|
||||||
limit: limit
|
limit
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ export default {
|
|||||||
)
|
)
|
||||||
// Filters out null tracks and adds a position to the playable tracks
|
// Filters out null tracks and adds a position to the playable tracks
|
||||||
data.items.forEach((item) => {
|
data.items.forEach((item) => {
|
||||||
const track = item.track
|
const { track } = item
|
||||||
if (track) {
|
if (track) {
|
||||||
if (track.is_playable) {
|
if (track.is_playable) {
|
||||||
track.position = ++position
|
track.position = ++position
|
||||||
|
@ -298,7 +298,7 @@ export const router = createRouter({
|
|||||||
scrollBehavior(to, from, savedPosition) {
|
scrollBehavior(to, from, savedPosition) {
|
||||||
const wait_ms = 0
|
const wait_ms = 0
|
||||||
if (savedPosition) {
|
if (savedPosition) {
|
||||||
// We have saved scroll position (browser back/forward navigation), use this position
|
// Use the saved scroll position (browser back/forward navigation)
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
resolve(savedPosition)
|
resolve(savedPosition)
|
||||||
@ -307,10 +307,12 @@ export const router = createRouter({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (to.path === from.path && to.hash) {
|
if (to.path === from.path && to.hash) {
|
||||||
// We are staying on the same page and are jumping to an anchor (e. g. index nav)
|
/*
|
||||||
// We don't have a transition, so don't add a timeout!
|
* Staying on the same page and jumping to an anchor (e. g. index nav)
|
||||||
|
* As there is no transition, there is no timeout added
|
||||||
|
*/
|
||||||
const top = to.meta.has_tabs ? TOP_WITH_TABS : TOP_WITHOUT_TABS
|
const top = to.meta.has_tabs ? TOP_WITH_TABS : TOP_WITHOUT_TABS
|
||||||
return { el: to.hash, top: top, behavior: 'smooth' }
|
return { el: to.hash, top, behavior: 'smooth' }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to.hash) {
|
if (to.hash) {
|
||||||
@ -323,12 +325,14 @@ export const router = createRouter({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (to.meta.has_index) {
|
if (to.meta.has_index) {
|
||||||
// We are navigating to a page with index nav, that should be hidden automatically
|
/*
|
||||||
// Depending on wether we have a tab navigation, add an offset to the "top" anchor
|
* Navigate to a page with index nav that should be hidden automatically
|
||||||
|
* If a tab navigation exists, an offset to the "top" anchor is added
|
||||||
|
*/
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const top = to.meta.has_tabs ? TOP_WITH_TABS : TOP_WITHOUT_TABS
|
const top = to.meta.has_tabs ? TOP_WITH_TABS : TOP_WITHOUT_TABS
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
resolve({ el: '#top', top: top })
|
resolve({ el: '#top', top })
|
||||||
}, wait_ms)
|
}, wait_ms)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -79,9 +79,7 @@ export default createStore({
|
|||||||
lyrics_pane: (state) => state.lyrics.pane,
|
lyrics_pane: (state) => state.lyrics.pane,
|
||||||
|
|
||||||
now_playing: (state) => {
|
now_playing: (state) => {
|
||||||
const item = state.queue.items.find(function (item) {
|
const item = state.queue.items.find((e) => e.id === state.player.item_id)
|
||||||
return item.id === state.player.item_id
|
|
||||||
})
|
|
||||||
return item === undefined ? {} : item
|
return item === undefined ? {} : item
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -142,11 +140,8 @@ export default createStore({
|
|||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
|
|
||||||
settings_category: (state) => (categoryName) => {
|
settings_category: (state) => (categoryName) =>
|
||||||
return state.settings.categories.find(
|
state.settings.categories.find((e) => e.name === categoryName),
|
||||||
(elem) => elem.name === categoryName
|
|
||||||
)
|
|
||||||
},
|
|
||||||
|
|
||||||
settings_option: (state) => (categoryName, optionName) => {
|
settings_option: (state) => (categoryName, optionName) => {
|
||||||
const category = state.settings.categories.find(
|
const category = state.settings.categories.find(
|
||||||
@ -168,11 +163,11 @@ export default createStore({
|
|||||||
},
|
},
|
||||||
[types.UPDATE_SETTINGS_OPTION](state, option) {
|
[types.UPDATE_SETTINGS_OPTION](state, option) {
|
||||||
const settingCategory = state.settings.categories.find(
|
const settingCategory = state.settings.categories.find(
|
||||||
(elem) => elem.name === option.category
|
(e) => e.name === option.category
|
||||||
)
|
),
|
||||||
const settingOption = settingCategory.options.find(
|
settingOption = settingCategory.options.find(
|
||||||
(elem) => elem.name === option.name
|
(e) => e.name === option.name
|
||||||
)
|
)
|
||||||
settingOption.value = option.value
|
settingOption.value = option.value
|
||||||
},
|
},
|
||||||
[types.UPDATE_LIBRARY_STATS](state, libraryStats) {
|
[types.UPDATE_LIBRARY_STATS](state, libraryStats) {
|
||||||
|
@ -5,10 +5,8 @@ import i18n from '@/i18n'
|
|||||||
const { t } = i18n.global
|
const { t } = i18n.global
|
||||||
|
|
||||||
axios.interceptors.response.use(
|
axios.interceptors.response.use(
|
||||||
function (response) {
|
(response) => response,
|
||||||
return response
|
(error) => {
|
||||||
},
|
|
||||||
function (error) {
|
|
||||||
if (error.request.status && error.request.responseURL) {
|
if (error.request.status && error.request.responseURL) {
|
||||||
store.dispatch('add_notification', {
|
store.dispatch('add_notification', {
|
||||||
text: t('server.request-failed', {
|
text: t('server.request-failed', {
|
||||||
@ -45,7 +43,7 @@ export default {
|
|||||||
if (scanKind) {
|
if (scanKind) {
|
||||||
params.scan_kind = scanKind
|
params.scan_kind = scanKind
|
||||||
}
|
}
|
||||||
return axios.put('./api/update', undefined, { params: params })
|
return axios.put('./api/update', undefined, { params })
|
||||||
},
|
},
|
||||||
|
|
||||||
library_rescan(scanKind) {
|
library_rescan(scanKind) {
|
||||||
@ -53,7 +51,7 @@ export default {
|
|||||||
if (scanKind) {
|
if (scanKind) {
|
||||||
params.scan_kind = scanKind
|
params.scan_kind = scanKind
|
||||||
}
|
}
|
||||||
return axios.put('./api/rescan', undefined, { params: params })
|
return axios.put('./api/rescan', undefined, { params })
|
||||||
},
|
},
|
||||||
|
|
||||||
library_count(expression) {
|
library_count(expression) {
|
||||||
@ -148,10 +146,10 @@ export default {
|
|||||||
|
|
||||||
queue_save_playlist(name) {
|
queue_save_playlist(name) {
|
||||||
return axios
|
return axios
|
||||||
.post('./api/queue/save', undefined, { params: { name: name } })
|
.post('./api/queue/save', undefined, { params: { name } })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
store.dispatch('add_notification', {
|
store.dispatch('add_notification', {
|
||||||
text: t('server.queue-saved', { name: name }),
|
text: t('server.queue-saved', { name }),
|
||||||
type: 'info',
|
type: 'info',
|
||||||
timeout: 2000
|
timeout: 2000
|
||||||
})
|
})
|
||||||
@ -259,7 +257,7 @@ export default {
|
|||||||
|
|
||||||
library_artists(media_kind = undefined) {
|
library_artists(media_kind = undefined) {
|
||||||
return axios.get('./api/library/artists', {
|
return axios.get('./api/library/artists', {
|
||||||
params: { media_kind: media_kind }
|
params: { media_kind }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -273,7 +271,7 @@ export default {
|
|||||||
|
|
||||||
library_albums(media_kind = undefined) {
|
library_albums(media_kind = undefined) {
|
||||||
return axios.get('./api/library/albums', {
|
return axios.get('./api/library/albums', {
|
||||||
params: { media_kind: media_kind }
|
params: { media_kind }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -295,13 +293,13 @@ export default {
|
|||||||
|
|
||||||
library_genres(media_kind = undefined) {
|
library_genres(media_kind = undefined) {
|
||||||
return axios.get('./api/library/genres', {
|
return axios.get('./api/library/genres', {
|
||||||
params: { media_kind: media_kind }
|
params: { media_kind }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
library_genre(genre, media_kind = undefined) {
|
library_genre(genre, media_kind = undefined) {
|
||||||
return axios.get(`./api/library/genres/${encodeURIComponent(genre)}`, {
|
return axios.get(`./api/library/genres/${encodeURIComponent(genre)}`, {
|
||||||
params: { media_kind: media_kind }
|
params: { media_kind }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -332,13 +330,13 @@ export default {
|
|||||||
expression: 'data_kind is url and song_length = 0'
|
expression: 'data_kind is url and song_length = 0'
|
||||||
}
|
}
|
||||||
return axios.get('./api/search', {
|
return axios.get('./api/search', {
|
||||||
params: params
|
params
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
library_composers(media_kind = undefined) {
|
library_composers(media_kind = undefined) {
|
||||||
return axios.get('./api/library/composers', {
|
return axios.get('./api/library/composers', {
|
||||||
params: { media_kind: media_kind }
|
params: { media_kind }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -352,7 +350,7 @@ export default {
|
|||||||
expression: `composer is "${composer}" and media_kind is music`
|
expression: `composer is "${composer}" and media_kind is music`
|
||||||
}
|
}
|
||||||
return axios.get('./api/search', {
|
return axios.get('./api/search', {
|
||||||
params: params
|
params
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -362,7 +360,7 @@ export default {
|
|||||||
expression: `composer is "${composer}" and media_kind is music`
|
expression: `composer is "${composer}" and media_kind is music`
|
||||||
}
|
}
|
||||||
return axios.get('./api/search', {
|
return axios.get('./api/search', {
|
||||||
params: params
|
params
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -400,7 +398,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
library_add(url) {
|
library_add(url) {
|
||||||
return axios.post('./api/library/add', undefined, { params: { url: url } })
|
return axios.post('./api/library/add', undefined, { params: { url } })
|
||||||
},
|
},
|
||||||
|
|
||||||
library_playlist_delete(playlistId) {
|
library_playlist_delete(playlistId) {
|
||||||
@ -438,7 +436,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
library_files(directory = undefined) {
|
library_files(directory = undefined) {
|
||||||
const filesParams = { directory: directory }
|
const filesParams = { directory }
|
||||||
return axios.get('./api/library/files', {
|
return axios.get('./api/library/files', {
|
||||||
params: filesParams
|
params: filesParams
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user