mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-27 15:45:56 -05:00
2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
import{_ as S,o as a,c as u,a as o,t as h,z as P,a3 as B,e as W,r as c,h as d,j as F,Z as G,d as m,F as f,f as k,g as n,w as r,k as _,b as v,m as H}from"./index.js";import{C as R,T as Z}from"./TabsSearch.js";import{C as j}from"./ContentWithHeading.js";import{C as U}from"./CoverArtwork.js";import{L as J}from"./ListItemAlbumSpotify.js";import{L as K}from"./ListItemPlaylistSpotify.js";import{L as O,M as Q}from"./ModalDialogTrackSpotify.js";import{M as X}from"./ModalDialogAlbumSpotify.js";import{M as Y}from"./ModalDialogArtistSpotify.js";import{M as $}from"./ModalDialogPlaylistSpotify.js";import{S as tt}from"./spotify-web-api.js";import{G as st}from"./vue-eternal-loading.js";const et={name:"ListItemArtistSpotify",props:["artist"],methods:{open_artist(){this.$router.push({name:"music-spotify-artist",params:{id:this.artist.id}})}}},it={class:"media is-align-items-center"},lt=["textContent"],ot={class:"media-right"};function at(t,s,w,x,e,l){return a(),u("div",it,[o("div",{class:"media-content is-clickable is-clipped",onClick:s[0]||(s[0]=(...p)=>l.open_artist&&l.open_artist(...p))},[o("h1",{class:"title is-6",textContent:h(w.artist.name)},null,8,lt)]),o("div",ot,[P(t.$slots,"actions")])])}const rt=S(et,[["render",at]]),b=50,nt={name:"PageSearchSpotify",components:{ContentText:R,ContentWithHeading:j,CoverArtwork:U,ListItemAlbumSpotify:J,ListItemArtistSpotify:rt,ListItemPlaylistSpotify:K,ListItemTrackSpotify:O,ModalDialogAlbumSpotify:X,ModalDialogArtistSpotify:Y,ModalDialogPlaylistSpotify:$,ModalDialogTrackSpotify:Q,TabsSearch:Z,VueEternalLoading:st},data(){return{albums:{items:[],total:0},artists:{items:[],total:0},playlists:{items:[],total:0},query:{},search_param:{},search_query:"",selected_album:{},selected_artist:{},selected_playlist:{},selected_track:{},show_album_details_modal:!1,show_artist_details_modal:!1,show_playlist_details_modal:!1,show_track_details_modal:!1,tracks:{items:[],total:0},validSearchTypes:["track","artist","album","playlist"]}},computed:{is_visible_artwork(){return this.$store.getters.settings_option("webinterface","show_cover_artwork_in_album_lists").value},recent_searches(){return this.$store.state.recent_searches.filter(t=>!t.startsWith("query:"))},show_albums(){return this.$route.query.type&&this.$route.query.type.includes("album")},show_all_albums_button(){return this.albums.total>this.albums.items.length},show_all_artists_button(){return this.artists.total>this.artists.items.length},show_all_playlists_button(){return this.playlists.total>this.playlists.items.length},show_all_tracks_button(){return this.tracks.total>this.tracks.items.length},show_artists(){return this.$route.query.type&&this.$route.query.type.includes("artist")},show_playlists(){return this.$route.query.type&&this.$route.query.type.includes("playlist")},show_tracks(){return this.$route.query.type&&this.$route.query.type.includes("track")}},watch:{$route(t,s){this.query=t.query,this.search()}},mounted(){this.query=this.$route.query,this.search()},methods:{artwork_url(t){return t.images&&t.images.length>0?t.images[0].url:""},new_search(){this.search_query&&(this.$router.push({name:"search-spotify",query:{limit:3,offset:0,query:this.search_query,type:"track,artist,album,playlist,audiobook,podcast"}}),this.$refs.search_field.blur())},open_album(t){this.$router.push({name:"music-spotify-album",params:{id:t.id}})},open_album_dialog(t){this.selected_album=t,this.show_album_details_modal=!0},open_artist_dialog(t){this.selected_artist=t,this.show_artist_details_modal=!0},open_playlist_dialog(t){this.selected_playlist=t,this.show_playlist_details_modal=!0},open_recent_search(t){this.search_query=t,this.new_search()},open_search_albums(){this.$router.push({name:"search-spotify",query:{query:this.$route.query.query,type:"album"}})},open_search_artists(){this.$router.push({name:"search-spotify",query:{query:this.$route.query.query,type:"artist"}})},open_search_playlists(){this.$router.push({name:"search-spotify",query:{query:this.$route.query.query,type:"playlist"}})},open_search_tracks(){this.$router.push({name:"search-spotify",query:{query:this.$route.query.query,type:"track"}})},open_track_dialog(t){this.selected_track=t,this.show_track_details_modal=!0},reset(){this.tracks={items:[],total:0},this.artists={items:[],total:0},this.albums={items:[],total:0},this.playlists={items:[],total:0}},search(){if(this.reset(),!this.query.query||this.query.query===""||this.query.query.startsWith("query:")){this.search_query="",this.$refs.search_field.focus();return}this.search_query=this.query.query,this.search_param.limit=this.query.limit?this.query.limit:b,this.search_param.offset=this.query.offset?this.query.offset:0,this.$store.commit(B,this.query.query),this.search_all()},search_albums_next({loaded:t}){this.spotify_search().then(s=>{this.albums.items=this.albums.items.concat(s.albums.items),this.albums.total=s.albums.total,this.search_param.offset+=s.albums.limit,t(s.albums.items.length,b)})},search_all(){this.spotify_search().then(t=>{this.tracks=t.tracks?t.tracks:{items:[],total:0},this.artists=t.artists?t.artists:{items:[],total:0},this.albums=t.albums?t.albums:{items:[],total:0},this.playlists=t.playlists?t.playlists:{items:[],total:0}})},search_artists_next({loaded:t}){this.spotify_search().then(s=>{this.artists.items=this.artists.items.concat(s.artists.items),this.artists.total=s.artists.total,this.search_param.offset+=s.artists.limit,t(s.artists.items.length,b)})},search_playlists_next({loaded:t}){this.spotify_search().then(s=>{this.playlists.items=this.playlists.items.concat(s.playlists.items),this.playlists.total=s.playlists.total,this.search_param.offset+=s.playlists.limit,t(s.playlists.items.length,b)})},search_tracks_next({loaded:t}){this.spotify_search().then(s=>{this.tracks.items=this.tracks.items.concat(s.tracks.items),this.tracks.total=s.tracks.total,this.search_param.offset+=s.tracks.limit,t(s.tracks.items.length,b)})},spotify_search(){return W.spotify().then(({data:t})=>{this.search_param.market=t.webapi_country;const s=new tt;s.setAccessToken(t.webapi_token);const w=this.query.type.split(",").filter(x=>this.validSearchTypes.includes(x));return s.search(this.query.query,w,this.search_param)})}}},_t={class:"section pb-0"},ct={class:"container"},ht={class:"columns is-centered"},ut={class:"column is-four-fifths"},mt={class:"field"},pt={class:"control is-expanded has-icons-left"},yt=["placeholder"],dt={class:"tags mt-4"},ft=["onClick","textContent"],kt=["textContent"],bt=["onClick"],wt={key:0,class:"level"},gt={class:"level-item"},qt=["textContent"],Ct=["textContent"],vt=["textContent"],xt=["onClick"],St={key:0,class:"level"},At={class:"level-item"},Lt=["textContent"],Tt=["textContent"],Mt=["textContent"],Et=["onClick"],Dt={key:0,class:"level"},Vt={class:"level-item"},zt=["textContent"],It=["textContent"],Nt=["textContent"],Pt=["onClick"],Bt={key:0,class:"level"},Wt={class:"level-item"},Ft=["textContent"],Gt=["textContent"];function Ht(t,s,w,x,e,l){const p=c("mdicon"),A=c("tabs-search"),L=c("list-item-track-spotify"),g=c("VueEternalLoading"),T=c("modal-dialog-track-spotify"),q=c("content-with-heading"),C=c("content-text"),M=c("list-item-artist-spotify"),E=c("modal-dialog-artist-spotify"),D=c("cover-artwork"),V=c("list-item-album-spotify"),z=c("modal-dialog-album-spotify"),I=c("list-item-playlist-spotify"),N=c("modal-dialog-playlist-spotify");return a(),u("div",null,[o("section",_t,[o("div",ct,[o("div",ht,[o("div",ut,[o("form",{onSubmit:s[1]||(s[1]=d((...i)=>l.new_search&&l.new_search(...i),["prevent"]))},[o("div",mt,[o("p",pt,[F(o("input",{ref:"search_field","onUpdate:modelValue":s[0]||(s[0]=i=>e.search_query=i),class:"input is-rounded is-shadowless",type:"text",placeholder:t.$t("page.spotify.search.placeholder"),autocomplete:"off"},null,8,yt),[[G,e.search_query]]),m(p,{class:"icon is-left",name:"magnify",size:"16"})])])],32),o("div",dt,[(a(!0),u(f,null,k(l.recent_searches,i=>(a(),u("a",{key:i,class:"tag",onClick:y=>l.open_recent_search(i),textContent:h(i)},null,8,ft))),128))])])])])]),m(A,{query:e.search_query},null,8,["query"]),l.show_tracks&&e.tracks.total?(a(),n(q,{key:0,class:"pt-0"},{"heading-left":r(()=>[o("p",{class:"title is-4",textContent:h(t.$t("page.spotify.search.tracks"))},null,8,kt)]),content:r(()=>[(a(!0),u(f,null,k(e.tracks.items,i=>(a(),n(L,{key:i.id,track:i,position:0,context_uri:i.uri},{actions:r(()=>[o("a",{onClick:d(y=>l.open_track_dialog(i),["prevent","stop"])},[m(p,{class:"icon has-text-dark",name:"dots-vertical",size:"16"})],8,bt)]),_:2},1032,["track","context_uri"]))),128)),e.query.type==="track"?(a(),n(g,{key:0,load:l.search_tracks_next},{"no-more":r(()=>[v(" . ")]),_:1},8,["load"])):_("",!0),m(T,{show:e.show_track_details_modal,track:e.selected_track,album:e.selected_track.album,onClose:s[2]||(s[2]=i=>e.show_track_details_modal=!1)},null,8,["show","track","album"])]),footer:r(()=>[l.show_all_tracks_button?(a(),u("nav",wt,[o("p",gt,[o("a",{class:"button is-light is-small is-rounded",onClick:s[3]||(s[3]=(...i)=>l.open_search_tracks&&l.open_search_tracks(...i)),textContent:h(t.$t("page.spotify.search.show-all-tracks",e.tracks.total,{count:t.$filters.number(e.tracks.total)}))},null,8,qt)])])):_("",!0)]),_:1})):_("",!0),l.show_tracks&&!e.tracks.total?(a(),n(C,{key:1,class:"pt-0"},{content:r(()=>[o("p",null,[o("i",{textContent:h(t.$t("page.spotify.search.no-tracks"))},null,8,Ct)])]),_:1})):_("",!0),l.show_artists&&e.artists.total?(a(),n(q,{key:2},{"heading-left":r(()=>[o("p",{class:"title is-4",textContent:h(t.$t("page.spotify.search.artists"))},null,8,vt)]),content:r(()=>[(a(!0),u(f,null,k(e.artists.items,i=>(a(),n(M,{key:i.id,artist:i},{actions:r(()=>[o("a",{onClick:d(y=>l.open_artist_dialog(i),["prevent","stop"])},[m(p,{class:"icon has-text-dark",name:"dots-vertical",size:"16"})],8,xt)]),_:2},1032,["artist"]))),128)),e.query.type==="artist"?(a(),n(g,{key:0,load:l.search_artists_next},{"no-more":r(()=>[v(" . ")]),_:1},8,["load"])):_("",!0),m(E,{show:e.show_artist_details_modal,artist:e.selected_artist,onClose:s[4]||(s[4]=i=>e.show_artist_details_modal=!1)},null,8,["show","artist"])]),footer:r(()=>[l.show_all_artists_button?(a(),u("nav",St,[o("p",At,[o("a",{class:"button is-light is-small is-rounded",onClick:s[5]||(s[5]=(...i)=>l.open_search_artists&&l.open_search_artists(...i)),textContent:h(t.$t("page.spotify.search.show-all-artists",e.artists.total,{count:t.$filters.number(e.artists.total)}))},null,8,Lt)])])):_("",!0)]),_:1})):_("",!0),l.show_artists&&!e.artists.total?(a(),n(C,{key:3},{content:r(()=>[o("p",null,[o("i",{textContent:h(t.$t("page.spotify.search.no-artists"))},null,8,Tt)])]),_:1})):_("",!0),l.show_albums&&e.albums.total?(a(),n(q,{key:4},{"heading-left":r(()=>[o("p",{class:"title is-4",textContent:h(t.$t("page.spotify.search.albums"))},null,8,Mt)]),content:r(()=>[(a(!0),u(f,null,k(e.albums.items,i=>(a(),n(V,{key:i.id,album:i,onClick:y=>l.open_album(i)},H({actions:r(()=>[o("a",{onClick:d(y=>l.open_album_dialog(i),["prevent","stop"])},[m(p,{class:"icon has-text-dark",name:"dots-vertical",size:"16"})],8,Et)]),_:2},[l.is_visible_artwork?{name:"artwork",fn:r(()=>[m(D,{artwork_url:l.artwork_url(i),artist:i.artist,album:i.name,class:"is-clickable fd-has-shadow fd-cover fd-cover-small-image",maxwidth:64,maxheight:64},null,8,["artwork_url","artist","album"])]),key:"0"}:void 0]),1032,["album","onClick"]))),128)),e.query.type==="album"?(a(),n(g,{key:0,load:l.search_albums_next},{"no-more":r(()=>[v(" . ")]),_:1},8,["load"])):_("",!0),m(z,{show:e.show_album_details_modal,album:e.selected_album,onClose:s[6]||(s[6]=i=>e.show_album_details_modal=!1)},null,8,["show","album"])]),footer:r(()=>[l.show_all_albums_button?(a(),u("nav",Dt,[o("p",Vt,[o("a",{class:"button is-light is-small is-rounded",onClick:s[7]||(s[7]=(...i)=>l.open_search_albums&&l.open_search_albums(...i)),textContent:h(t.$t("page.spotify.search.show-all-albums",e.albums.total,{count:t.$filters.number(e.albums.total)}))},null,8,zt)])])):_("",!0)]),_:1})):_("",!0),l.show_albums&&!e.albums.total?(a(),n(C,{key:5},{content:r(()=>[o("p",null,[o("i",{textContent:h(t.$t("page.spotify.search.no-albums"))},null,8,It)])]),_:1})):_("",!0),l.show_playlists&&e.playlists.total?(a(),n(q,{key:6},{"heading-left":r(()=>[o("p",{class:"title is-4",textContent:h(t.$t("page.spotify.search.playlists"))},null,8,Nt)]),content:r(()=>[(a(!0),u(f,null,k(e.playlists.items,i=>(a(),n(I,{key:i.id,playlist:i},{actions:r(()=>[o("a",{onClick:d(y=>l.open_playlist_dialog(i),["prevent","stop"])},[m(p,{class:"icon has-text-dark",name:"dots-vertical",size:"16"})],8,Pt)]),_:2},1032,["playlist"]))),128)),e.query.type==="playlist"?(a(),n(g,{key:0,load:l.search_playlists_next},{"no-more":r(()=>[v(" . ")]),_:1},8,["load"])):_("",!0),m(N,{show:e.show_playlist_details_modal,playlist:e.selected_playlist,onClose:s[8]||(s[8]=i=>e.show_playlist_details_modal=!1)},null,8,["show","playlist"])]),footer:r(()=>[l.show_all_playlists_button?(a(),u("nav",Bt,[o("p",Wt,[o("a",{class:"button is-light is-small is-rounded",onClick:s[9]||(s[9]=(...i)=>l.open_search_playlists&&l.open_search_playlists(...i)),textContent:h(t.$t("page.spotify.search.show-all-playlists",e.playlists.total,{count:t.$filters.number(e.playlists.total)}))},null,8,Ft)])])):_("",!0)]),_:1})):_("",!0),l.show_playlists&&!e.playlists.total?(a(),n(C,{key:7},{content:r(()=>[o("p",null,[o("i",{textContent:h(t.$t("page.spotify.search.no-playlists"))},null,8,Gt)])]),_:1})):_("",!0)])}const ss=S(nt,[["render",Ht]]);export{ss as default};
|