Skip to content
Snippets Groups Projects
Verified Commit 30eaa78e authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Merge branch 'release/0.14.1'

parents 7d6e6c6a 73785d45
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,11 @@ export default {
return url
}
if (url.startsWith('/')) {
return config.BACKEND_URL + url.substr(1)
let rootUrl = (
window.location.protocol + '//' + window.location.hostname +
(window.location.port ? ':' + window.location.port : '')
)
return rootUrl + url
} else {
return config.BACKEND_URL + url
}
......
......@@ -67,8 +67,31 @@ export default {
}
},
methods: {
getTracksPage (page, params, resolve, tracks) {
if (page > 10) {
// it's 10 * 100 tracks already, let's stop here
resolve(tracks)
}
// when fetching artists/or album tracks, sometimes, we may have to fetch
// multiple pages
let self = this
params['page_size'] = 100
params['page'] = page
tracks = tracks || []
axios.get('tracks/', {params: params}).then((response) => {
response.data.results.forEach(t => {
tracks.push(t)
})
if (response.data.next) {
self.getTracksPage(page + 1, params, resolve, tracks)
} else {
resolve(tracks)
}
})
},
getPlayableTracks () {
let self = this
this.isLoading = true
let getTracks = new Promise((resolve, reject) => {
if (self.track) {
resolve([self.track])
......@@ -82,44 +105,30 @@ export default {
}))
})
} else if (self.artist) {
let params = {
params: {'artist': self.artist, 'ordering': 'album__release_date,position'}
}
axios.get('tracks', params).then((response) => {
resolve(response.data.results)
})
let params = {'artist': self.artist, 'ordering': 'album__release_date,position'}
self.getTracksPage(1, params, resolve)
} else if (self.album) {
let params = {
params: {'album': self.album, 'ordering': 'position'}
}
axios.get('tracks', params).then((response) => {
resolve(response.data.results)
})
let params = {'album': self.album, 'ordering': 'position'}
self.getTracksPage(1, params, resolve)
}
})
return getTracks.then((tracks) => {
setTimeout(e => {
self.isLoading = false
}, 250)
return tracks.filter(e => {
return e.files.length > 0
})
})
},
triggerLoad () {
let self = this
this.isLoading = true
setTimeout(() => {
self.isLoading = false
}, 500)
},
add () {
let self = this
this.triggerLoad()
this.getPlayableTracks().then((tracks) => {
self.$store.dispatch('queue/appendMany', {tracks: tracks})
})
},
addNext (next) {
let self = this
this.triggerLoad()
let wasEmpty = this.$store.state.queue.tracks.length === 0
this.getPlayableTracks().then((tracks) => {
self.$store.dispatch('queue/appendMany', {tracks: tracks, index: self.$store.state.queue.currentIndex + 1})
......
......@@ -29,9 +29,9 @@
</template>
<script>
import _ from 'lodash'
import axios from 'axios'
import logger from '@/logging'
import backend from '@/audio/backend'
import AlbumCard from '@/components/audio/album/Card'
import ArtistCard from '@/components/audio/artist/Card'
......@@ -50,7 +50,6 @@ export default {
albums: [],
artists: []
},
backend: backend,
isLoading: false
}
},
......@@ -61,7 +60,7 @@ export default {
this.search()
},
methods: {
search () {
search: _.debounce(function () {
if (this.query.length < 1) {
return
}
......@@ -77,15 +76,11 @@ export default {
self.results = self.castResults(response.data)
self.isLoading = false
})
},
}, 500),
castResults (results) {
return {
albums: results.albums.map((album) => {
return backend.Album.clean(album)
}),
artists: results.artists.map((artist) => {
return backend.Artist.clean(artist)
})
albums: results.albums,
artists: results.artists
}
}
},
......
......@@ -18,7 +18,6 @@
<script>
import {mapState} from 'vuex'
import url from '@/utils/url'
import formats from '@/audio/formats'
import _ from 'lodash'
// import logger from '@/logging'
......@@ -52,13 +51,6 @@ export default {
let sources = [
{type: file.mimetype, url: file.path}
]
formats.formats.forEach(f => {
if (f !== file.mimetype) {
let format = formats.formatsMap[f]
let url = `/api/v1/trackfiles/transcode/?track_file=${file.id}&to=${format}`
sources.push({type: f, url: url})
}
})
if (this.$store.state.auth.authenticated) {
// we need to send the token directly in url
// so authentication can be checked by the backend
......
......@@ -84,4 +84,7 @@ export default {
tr:not(:hover) .favorite-icon:not(.favorited) {
display: none;
}
pre {
overflow-x: scroll;
}
</style>
......@@ -9,7 +9,6 @@
:class="['ui', 'icon', 'left', 'floated', 'button']"
:post-action="uploadUrl"
:multiple="true"
:size="1024 * 1024 * 30"
:data="uploadData"
:drop="true"
extensions="ogg,mp3,flac"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment