owntone-server/htdocs/assets/PagePodcasts.js
2023-12-14 20:00:28 +00:00

2 lines
5.7 KiB
JavaScript

import{_ as k,e as h,r as p,o as _,c as u,d as n,w as c,a as e,h as $,t as l,j as x,Z as P,k as w,T as z,$ as D,S as A,g as L}from"./index.js";import{C as T}from"./ContentWithHeading.js";import{G as C}from"./GroupByList.js";import{L as B}from"./ListAlbums.js";import{L as E}from"./ListTracks.js";import"./CoverArtwork.js";import"./ModalDialogAlbum.js";import"./spotify-web-api.js";const N={name:"ModalDialogAddRss",props:["show"],emits:["close","podcast-added"],data(){return{url:"",loading:!1}},watch:{show(){this.show&&(this.loading=!1,setTimeout(()=>{this.$refs.url_field.focus()},10))}},methods:{add_stream(){this.loading=!0,h.library_add(this.url).then(()=>{this.$emit("close"),this.$emit("podcast-added"),this.url=""}).catch(()=>{this.loading=!1})}}},S={key:0,class:"modal is-active"},G={class:"modal-content fd-modal-card"},M={class:"card-content"},O=["textContent"],R={class:"field"},U={class:"control is-expanded has-icons-left"},V=["placeholder","disabled"],I=["textContent"],j={key:0,class:"card-footer"},H={class:"card-footer-item has-text-dark"},W=["textContent"],q={key:1,class:"card-footer is-clipped"},K=["textContent"],Z=["textContent"];function F(t,s,m,g,a,o){const r=p("mdicon");return _(),u("div",null,[n(z,{name:"fade"},{default:c(()=>[m.show?(_(),u("div",S,[e("div",{class:"modal-background",onClick:s[0]||(s[0]=d=>t.$emit("close"))}),e("div",G,[e("form",{class:"card",onSubmit:s[4]||(s[4]=$((...d)=>o.add_stream&&o.add_stream(...d),["prevent"]))},[e("div",M,[e("p",{class:"title is-4",textContent:l(t.$t("dialog.add.rss.title"))},null,8,O),e("div",R,[e("p",U,[x(e("input",{ref:"url_field","onUpdate:modelValue":s[1]||(s[1]=d=>a.url=d),class:"input is-shadowless",type:"url",pattern:"http[s]?://.*",required:"",placeholder:t.$t("dialog.add.rss.placeholder"),disabled:a.loading},null,8,V),[[P,a.url]]),n(r,{class:"icon is-left",name:"rss",size:"16"})]),e("p",{class:"help",textContent:l(t.$t("dialog.add.rss.help"))},null,8,I)])]),a.loading?(_(),u("footer",j,[e("a",H,[n(r,{class:"icon",name:"web",size:"16"}),e("span",{class:"is-size-7",textContent:l(t.$t("dialog.add.rss.processing"))},null,8,W)])])):(_(),u("footer",q,[e("a",{class:"card-footer-item has-text-dark",onClick:s[2]||(s[2]=d=>t.$emit("close"))},[n(r,{class:"icon",name:"cancel",size:"16"}),e("span",{class:"is-size-7",textContent:l(t.$t("dialog.add.rss.cancel"))},null,8,K)]),e("a",{class:"card-footer-item has-background-info has-text-white has-text-weight-bold",onClick:s[3]||(s[3]=(...d)=>o.add_stream&&o.add_stream(...d))},[n(r,{class:"icon",name:"playlist-plus",size:"16"}),e("span",{class:"is-size-7",textContent:l(t.$t("dialog.add.rss.add"))},null,8,Z)])]))],32)]),e("button",{class:"modal-close is-large","aria-label":"close",onClick:s[5]||(s[5]=d=>t.$emit("close"))})])):w("",!0)]),_:1})])}const J=k(N,[["render",F]]),f={load(t){return Promise.all([h.library_albums("podcast"),h.library_podcasts_new_episodes()])},set(t,s){t.albums=new C(s[0].data),t.new_episodes=new C(s[1].data.tracks)}},Q={name:"PagePodcasts",components:{ContentWithHeading:T,ListTracks:E,ListAlbums:B,ModalDialogAddRss:J},beforeRouteEnter(t,s,m){f.load(t).then(g=>{m(a=>f.set(a,g))})},beforeRouteUpdate(t,s,m){const g=this;f.load(t).then(a=>{f.set(g,a),m()})},data(){return{albums:[],new_episodes:{items:[]},show_url_modal:!1}},computed:{rss(){return this.$store.state.rss_count}},methods:{mark_all_played(){this.new_episodes.items.forEach(t=>{h.library_track_update(t.id,{play_count:"increment"})}),this.new_episodes.items={}},open_add_podcast_dialog(t){this.show_url_modal=!0},reload_new_episodes(){h.library_podcasts_new_episodes().then(({data:t})=>{this.new_episodes=new C(t.tracks)})},reload_podcasts(){h.library_albums("podcast").then(({data:t})=>{this.albums=new C(t),this.reload_new_episodes()})},update_rss(){this.$store.commit(D,"rss"),this.$store.commit(A,!0)}}},X=["textContent"],Y={class:"buttons is-centered"},ss=["textContent"],ts=["textContent"],es=["textContent"],os={class:"buttons is-centered"},as=["textContent"],ns=["textContent"];function ls(t,s,m,g,a,o){const r=p("mdicon"),d=p("list-tracks"),b=p("content-with-heading"),y=p("list-albums"),v=p("modal-dialog-add-rss");return _(),u("div",null,[a.new_episodes.items.length>0?(_(),L(b,{key:0},{"heading-left":c(()=>[e("p",{class:"title is-4",textContent:l(t.$t("page.podcasts.new-episodes"))},null,8,X)]),"heading-right":c(()=>[e("div",Y,[e("a",{class:"button is-small",onClick:s[0]||(s[0]=(...i)=>o.mark_all_played&&o.mark_all_played(...i))},[n(r,{class:"icon",name:"pencil",size:"16"}),e("span",{textContent:l(t.$t("page.podcasts.mark-all-played"))},null,8,ss)])])]),content:c(()=>[n(d,{tracks:a.new_episodes,show_progress:!0,onPlayCountChanged:o.reload_new_episodes},null,8,["tracks","onPlayCountChanged"])]),_:1})):w("",!0),n(b,null,{"heading-left":c(()=>[e("p",{class:"title is-4",textContent:l(t.$t("page.podcasts.title"))},null,8,ts),e("p",{class:"heading",textContent:l(t.$t("page.podcasts.count",{count:a.albums.total}))},null,8,es)]),"heading-right":c(()=>[e("div",os,[o.rss.tracks>0?(_(),u("a",{key:0,class:"button is-small",onClick:s[1]||(s[1]=(...i)=>o.update_rss&&o.update_rss(...i))},[n(r,{class:"icon",name:"refresh",size:"16"}),e("span",{textContent:l(t.$t("page.podcasts.update"))},null,8,as)])):w("",!0),e("a",{class:"button is-small",onClick:s[2]||(s[2]=(...i)=>o.open_add_podcast_dialog&&o.open_add_podcast_dialog(...i))},[n(r,{class:"icon",name:"rss",size:"16"}),e("span",{textContent:l(t.$t("page.podcasts.add"))},null,8,ns)])])]),content:c(()=>[n(y,{albums:a.albums,onPlayCountChanged:s[3]||(s[3]=i=>o.reload_new_episodes()),onPodcastDeleted:s[4]||(s[4]=i=>o.reload_podcasts())},null,8,["albums"]),n(v,{show:a.show_url_modal,onClose:s[5]||(s[5]=i=>a.show_url_modal=!1),onPodcastAdded:s[6]||(s[6]=i=>o.reload_podcasts())},null,8,["show"])]),_:1})])}const hs=k(Q,[["render",ls]]);export{hs as default};