forked from platypush/platypush
[media UI] Propagate free text filter to all the views.
This commit is contained in:
parent
ae017516c4
commit
9ed7026aaf
7 changed files with 51 additions and 13 deletions
|
@ -23,7 +23,6 @@
|
||||||
<component
|
<component
|
||||||
:is="mediaProvider"
|
:is="mediaProvider"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
ref="mediaProvider"
|
|
||||||
@back="mediaProvider = null"
|
@back="mediaProvider = null"
|
||||||
@path-change="$emit('path-change', $event)"
|
@path-change="$emit('path-change', $event)"
|
||||||
@play="$emit('play', $event)" />
|
@play="$emit('play', $event)" />
|
||||||
|
@ -64,22 +63,25 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
getMediaProviderComponent(type) {
|
registerMediaProvider(type) {
|
||||||
return shallowRef(
|
const component = shallowRef(
|
||||||
defineAsyncComponent(
|
defineAsyncComponent(
|
||||||
() => import(`@/components/panels/Media/Providers/${type}`)
|
() => import(`@/components/panels/Media/Providers/${type}`)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
this.$options.components[type] = component
|
||||||
|
this.mediaProviders[type] = component
|
||||||
},
|
},
|
||||||
|
|
||||||
async refreshMediaProviders() {
|
async refreshMediaProviders() {
|
||||||
const config = await this.request('config.get')
|
const config = await this.request('config.get')
|
||||||
this.mediaProviders = {}
|
this.mediaProviders = {}
|
||||||
// The local File provider is always enabled
|
// The local File provider is always enabled
|
||||||
this.mediaProviders['File'] = this.getMediaProviderComponent('File')
|
this.registerMediaProvider('File')
|
||||||
|
|
||||||
if (config.youtube)
|
if (config.youtube)
|
||||||
this.mediaProviders['YouTube'] = this.getMediaProviderComponent('YouTube')
|
this.registerMediaProvider('YouTube')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
:selected-result="selectedResult"
|
:selected-result="selectedResult"
|
||||||
:sources="sources"
|
:sources="sources"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
|
:filter="browserFilter"
|
||||||
@select="onResultSelect($event)"
|
@select="onResultSelect($event)"
|
||||||
@play="play"
|
@play="play"
|
||||||
@view="view"
|
@view="view"
|
||||||
|
|
|
@ -7,8 +7,10 @@
|
||||||
<NoToken v-if="!authToken" />
|
<NoToken v-if="!authToken" />
|
||||||
|
|
||||||
<div class="body" v-else>
|
<div class="body" v-else>
|
||||||
<Feed @play="$emit('play', $event)" v-if="selectedView === 'feed'" />
|
<Feed :filter="filter"
|
||||||
<Playlists :selected-playlist="selectedPlaylist"
|
@play="$emit('play', $event)" v-if="selectedView === 'feed'" />
|
||||||
|
<Playlists :filter="filter"
|
||||||
|
:selected-playlist="selectedPlaylist"
|
||||||
@play="$emit('play', $event)"
|
@play="$emit('play', $event)"
|
||||||
@select="onPlaylistSelected"
|
@select="onPlaylistSelected"
|
||||||
v-else-if="selectedView === 'playlists'" />
|
v-else-if="selectedView === 'playlists'" />
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
</NoItems>
|
</NoItems>
|
||||||
|
|
||||||
<Results :results="feed"
|
<Results :results="feed"
|
||||||
|
:filter="filter"
|
||||||
:sources="{'youtube': true}"
|
:sources="{'youtube': true}"
|
||||||
:selected-result="selectedResult"
|
:selected-result="selectedResult"
|
||||||
@select="selectedResult = $event"
|
@select="selectedResult = $event"
|
||||||
|
@ -29,6 +30,13 @@ export default {
|
||||||
Results,
|
Results,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
props: {
|
||||||
|
filter: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
feed: [],
|
feed: [],
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
<Results :results="items"
|
<Results :results="items"
|
||||||
:sources="{'youtube': true}"
|
:sources="{'youtube': true}"
|
||||||
|
:filter="filter"
|
||||||
:selected-result="selectedResult"
|
:selected-result="selectedResult"
|
||||||
@select="selectedResult = $event"
|
@select="selectedResult = $event"
|
||||||
@play="$emit('play', $event)"
|
@play="$emit('play', $event)"
|
||||||
|
@ -34,6 +35,11 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
filter: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="playlist-body" v-else>
|
<div class="playlist-body" v-else>
|
||||||
<Playlist :id="selectedPlaylist" @play="$emit('play', $event)" />
|
<Playlist :id="selectedPlaylist" :filter="filter" @play="$emit('play', $event)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -45,6 +45,11 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
filter: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
|
@ -56,7 +61,9 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
playlistsById() {
|
playlistsById() {
|
||||||
return this.playlists.reduce((acc, playlist) => {
|
return this.playlists
|
||||||
|
.filter(playlist => !this.filter || playlist.name.toLowerCase().includes(this.filter.toLowerCase()))
|
||||||
|
.reduce((acc, playlist) => {
|
||||||
acc[playlist.id] = playlist
|
acc[playlist.id] = playlist
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
|
|
|
@ -55,6 +55,11 @@ export default {
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
filter: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
|
||||||
resultIndexStep: {
|
resultIndexStep: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 25,
|
default: 25,
|
||||||
|
@ -69,7 +74,14 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
visibleResults() {
|
visibleResults() {
|
||||||
return this.results.slice(0, this.maxResultIndex)
|
return this.results
|
||||||
|
.filter((item) => {
|
||||||
|
if (!this.filter)
|
||||||
|
return true
|
||||||
|
|
||||||
|
return item.title.toLowerCase().includes(this.filter.toLowerCase())
|
||||||
|
})
|
||||||
|
.slice(0, this.maxResultIndex)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue