Can now list federated tracks

This commit is contained in:
Eliot Berriot 2018-04-14 16:08:29 +02:00
parent 2e71ddbffc
commit 74f5907156
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
6 changed files with 85 additions and 14 deletions

View File

@ -6,7 +6,7 @@
<table v-if="result" class="ui compact very basic single line unstackable table"> <table v-if="result" class="ui compact very basic single line unstackable table">
<thead> <thead>
<tr> <tr>
<th colspan="1"> <th>
<div class="ui checkbox"> <div class="ui checkbox">
<input <input
type="checkbox" type="checkbox"
@ -18,6 +18,7 @@
<th>Artist</th> <th>Artist</th>
<th>Album</th> <th>Album</th>
<th>Published date</th> <th>Published date</th>
<th v-if="showLibrary">Library</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -34,28 +35,47 @@
</div> </div>
</td> </td>
<td> <td>
{{ track.title }} <span :title="track.title">{{ track.title|truncate(30) }}</span>
</td> </td>
<td> <td>
{{ track.artist_name }} <span :title="track.artist_name">{{ track.artist_name|truncate(30) }}</span>
</td> </td>
<td> <td>
{{ track.album_title }} <span :title="track.album_title">{{ track.album_title|truncate(20) }}</span>
</td> </td>
<td> <td>
<human-date :date="track.published_date"></human-date> <human-date :date="track.published_date"></human-date>
</td> </td>
<td v-if="showLibrary">
{{ track.library.actor.domain }}
</td>
</tr> </tr>
</tbody> </tbody>
<tfoot class="full-width"> <tfoot class="full-width">
<tr> <tr>
<th colspan="5"> <th>
<pagination
v-if="result && result.results.length > 0"
@page-changed="selectPage"
:compact="true"
:current="page"
:paginate-by="paginateBy"
:total="result.count"
></pagination>
</th>
<th>Showing results {{ ((page-1) * paginateBy) + 1 }}-{{ ((page-1) * paginateBy) + result.results.length }} on {{ result.count }}</th>
<th>
<button <button
@click="launchImport" @click="launchImport"
:disabled="checked.length === 0 || isImporting" :disabled="checked.length === 0 || isImporting"
:class="['ui', 'green', {loading: isImporting}, 'button']">Import {{ checked.length }} tracks :class="['ui', 'green', {loading: isImporting}, 'button']">Import {{ checked.length }} tracks
</button> </button>
</th> </th>
<th></th>
<th></th>
<th></th>
<th v-if="showLibrary"></th>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
@ -66,14 +86,22 @@
import axios from 'axios' import axios from 'axios'
import _ from 'lodash' import _ from 'lodash'
import Pagination from '@/components/Pagination'
export default { export default {
props: ['filters'], props: {
filters: {type: Object, required: false},
showLibrary: {type: Boolean, default: false}
},
components: {
Pagination
},
data () { data () {
return { return {
isLoading: false, isLoading: false,
result: null, result: null,
page: 1, page: 1,
paginateBy: 50, paginateBy: 25,
search: '', search: '',
checked: {}, checked: {},
isImporting: false isImporting: false
@ -86,7 +114,7 @@ export default {
fetchData () { fetchData () {
let params = _.merge({ let params = _.merge({
'page': this.page, 'page': this.page,
'paginate_by': this.paginateBy, 'page_size': this.paginateBy,
'q': this.search 'q': this.search
}, this.filters) }, this.filters)
let self = this let self = this
@ -107,7 +135,6 @@ export default {
library_tracks: this.checked library_tracks: this.checked
} }
axios.post('/submit/federation/', payload).then((response) => { axios.post('/submit/federation/', payload).then((response) => {
console.log('Triggered import', response.data)
self.isImporting = false self.isImporting = false
self.fetchData() self.fetchData()
}, error => { }, error => {
@ -120,7 +147,9 @@ export default {
// we uncheck // we uncheck
this.checked = [] this.checked = []
} else { } else {
this.checked = this.result.results.map(t => { return t.id }) this.checked = this.result.results.filter(t => {
return t.local_track_file === null
}).map(t => { return t.id })
} }
}, },
toggleCheck (id) { toggleCheck (id) {
@ -130,6 +159,9 @@ export default {
} else { } else {
this.checked.push(id) this.checked.push(id)
} }
},
selectPage: function (page) {
this.page = page
} }
}, },
watch: { watch: {
@ -137,6 +169,9 @@ export default {
if (newValue.length > 0) { if (newValue.length > 0) {
this.fetchData() this.fetchData()
} }
},
page () {
this.fetchData()
} }
} }
} }

View File

@ -29,6 +29,7 @@ import FederationBase from '@/views/federation/Base'
import FederationScan from '@/views/federation/Scan' import FederationScan from '@/views/federation/Scan'
import FederationLibraryDetail from '@/views/federation/LibraryDetail' import FederationLibraryDetail from '@/views/federation/LibraryDetail'
import FederationLibraryList from '@/views/federation/LibraryList' import FederationLibraryList from '@/views/federation/LibraryList'
import FederationTrackList from '@/views/federation/LibraryTrackList'
Vue.use(Router) Vue.use(Router)
@ -106,6 +107,17 @@ export default new Router({
defaultPage: route.query.page defaultPage: route.query.page
}) })
}, },
{
path: 'tracks',
name: 'federation.tracks.list',
component: FederationTrackList,
props: (route) => ({
defaultOrdering: route.query.ordering,
defaultQuery: route.query.query,
defaultPaginateBy: route.query.paginateBy,
defaultPage: route.query.page
})
},
{ path: 'libraries/:id', name: 'federation.libraries.detail', component: FederationLibraryDetail, props: true } { path: 'libraries/:id', name: 'federation.libraries.detail', component: FederationLibraryDetail, props: true }
] ]
}, },
@ -113,7 +125,7 @@ export default new Router({
path: '/library', path: '/library',
component: Library, component: Library,
children: [ children: [
{ path: 'scan', component: LibraryHome }, { path: '', component: LibraryHome },
{ {
path: 'artists/', path: 'artists/',
name: 'library.artists.browse', name: 'library.artists.browse',

View File

@ -4,6 +4,9 @@
<router-link <router-link
class="ui item" class="ui item"
:to="{name: 'federation.libraries.list'}">Libraries</router-link> :to="{name: 'federation.libraries.list'}">Libraries</router-link>
<router-link
class="ui item"
:to="{name: 'federation.tracks.list'}">Tracks</router-link>
</div> </div>
<router-view :key="$route.fullPath"></router-view> <router-view :key="$route.fullPath"></router-view>
</div> </div>

View File

@ -102,8 +102,6 @@
<div class="ui vertical stripe segment"> <div class="ui vertical stripe segment">
<h2>Tracks available in this library</h2> <h2>Tracks available in this library</h2>
<library-track-table :filters="{library: id}"></library-track-table> <library-track-table :filters="{library: id}"></library-track-table>
<div class="ui stackable doubling three column grid">
</div>
</div> </div>
</template> </template>
</div> </div>

View File

@ -1,5 +1,5 @@
<template> <template>
<div v-title="'Artists'"> <div v-title="'Libraries'">
<div class="ui vertical stripe segment"> <div class="ui vertical stripe segment">
<h2 class="ui header">Browsing libraries</h2> <h2 class="ui header">Browsing libraries</h2>
<router-link <router-link

View File

@ -0,0 +1,23 @@
<template>
<div v-title="'Federated tracks'">
<div class="ui vertical stripe segment">
<h2 class="ui header">Browsing federated tracks</h2>
<div class="ui hidden divider"></div>
<library-track-table :show-library="true"></library-track-table>
</div>
</div>
</template>
<script>
import LibraryTrackTable from '@/components/federation/LibraryTrackTable'
export default {
components: {
LibraryTrackTable
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>