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

2 lines
5.6 KiB
JavaScript

import{C}from"./ContentWithHeading.js";import{T as y}from"./TabsSettings.js";import{_ as v,e as p,r as g,o as i,c as l,d as c,w as d,a as t,t as o,k as a,q as x,j as u,Z as h,h as b}from"./index.js";const w={name:"PageSettingsOnlineServices",components:{ContentWithHeading:C,TabsSettings:y},data(){return{lastfm_login:{errors:{error:"",password:"",user:""},password:"",user:""}}},computed:{lastfm(){return this.$store.state.lastfm},spotify(){return this.$store.state.spotify},spotify_missing_scope(){return this.spotify.webapi_token_valid&&this.spotify.webapi_granted_scope&&this.spotify.webapi_required_scope?this.spotify.webapi_required_scope.split(" ").filter(s=>this.spotify.webapi_granted_scope.indexOf(s)<0):[]},spotify_required_scope(){return this.spotify.webapi_required_scope?this.spotify.webapi_required_scope.split(" "):[]}},methods:{login_lastfm(){p.lastfm_login(this.lastfm_login).then(s=>{this.lastfm_login.user="",this.lastfm_login.password="",this.lastfm_login.errors.user="",this.lastfm_login.errors.password="",this.lastfm_login.errors.error="",s.data.success||(this.lastfm_login.errors.user=s.data.errors.user,this.lastfm_login.errors.password=s.data.errors.password,this.lastfm_login.errors.error=s.data.errors.error)})},logoutLastfm(){p.lastfm_logout()},logout_spotify(){p.spotify_logout()}}},k={class:"fd-page-with-tabs"},q=["textContent"],S={key:0,class:"notification is-size-7"},z=["textContent"],V={key:1},j={class:"notification is-size-7"},B=["textContent"],L={class:"mt-5"},N=["textContent"],O={key:0},T=["textContent"],D=["textContent"],M={key:1,class:"help is-danger"},P=["textContent"],U=["textContent"],E={class:"field mt-5"},H={class:"control"},W=["href","textContent"],Z={class:"help"},A=["textContent"],F=["textContent"],G={key:2,class:"field mt-5"},I={class:"control"},J=["textContent"],K=["textContent"],Q={key:0,class:"notification is-size-7"},R=["textContent"],X={key:1},Y=["textContent"],$={key:0},tt=["textContent"],st={key:1},et={class:"field is-grouped"},ot={class:"control is-expanded"},nt=["placeholder"],it=["textContent"],lt={class:"control is-expanded"},rt=["placeholder"],at=["textContent"],_t={class:"control"},dt=["textContent"],pt=["textContent"],ct=["textContent"];function ft(s,n,gt,ut,_,e){const m=g("tabs-settings"),f=g("content-with-heading");return i(),l("div",k,[c(m),c(f,null,{"heading-left":d(()=>[t("div",{class:"title is-4",textContent:o(s.$t("page.settings.services.spotify.title"))},null,8,q)]),content:d(()=>[e.spotify.spotify_installed?a("",!0):(i(),l("div",S,[t("p",{textContent:o(s.$t("page.settings.services.spotify.no-support"))},null,8,z)])),e.spotify.spotify_installed?(i(),l("div",V,[t("div",j,[t("span",{textContent:o(s.$t("page.settings.services.spotify.requirements"))},null,8,B)]),t("div",L,[t("p",{class:"content",textContent:o(s.$t("page.settings.services.spotify.grant-access"))},null,8,N),e.spotify.webapi_token_valid?(i(),l("p",O,[t("span",{textContent:o(s.$t("page.settings.services.spotify.user"))},null,8,T),t("code",{textContent:o(e.spotify.webapi_user)},null,8,D)])):a("",!0),e.spotify_missing_scope.length>0?(i(),l("p",M,[t("span",{textContent:o(s.$t("page.settings.services.spotify.reauthorize"))},null,8,P),t("code",{textContent:o(e.spotify_missing_scope.join())},null,8,U)])):a("",!0),t("div",E,[t("div",H,[t("a",{class:x(["button",{"is-info":!e.spotify.webapi_token_valid||e.spotify_missing_scope.length>0}]),href:e.spotify.oauth_uri,textContent:o(s.$t("page.settings.services.spotify.authorize"))},null,10,W)])]),t("p",Z,[t("span",{textContent:o(s.$t("page.settings.services.spotify.scopes"))},null,8,A),t("code",{textContent:o(e.spotify_required_scope.join(", "))},null,8,F)]),e.spotify.webapi_token_valid?(i(),l("div",G,[t("div",I,[t("a",{class:"button is-danger",onClick:n[0]||(n[0]=(...r)=>e.logout_spotify&&e.logout_spotify(...r)),textContent:o(s.$t("page.settings.services.logout"))},null,8,J)])])):a("",!0)])])):a("",!0)]),_:1}),c(f,null,{"heading-left":d(()=>[t("div",{class:"title is-4",textContent:o(s.$t("page.settings.services.lastfm.title"))},null,8,K)]),content:d(()=>[e.lastfm.enabled?a("",!0):(i(),l("div",Q,[t("p",{textContent:o(s.$t("page.settings.services.lastfm.no-support"))},null,8,R)])),e.lastfm.enabled?(i(),l("div",X,[t("p",{class:"content",textContent:o(s.$t("page.settings.services.lastfm.grant-access"))},null,8,Y),e.lastfm.scrobbling_enabled?(i(),l("div",$,[t("a",{class:"button",onClick:n[1]||(n[1]=(...r)=>e.logoutLastfm&&e.logoutLastfm(...r)),textContent:o(s.$t("page.settings.services.lastfm.stop-scrobbling"))},null,8,tt)])):a("",!0),e.lastfm.scrobbling_enabled?a("",!0):(i(),l("div",st,[t("form",{onSubmit:n[4]||(n[4]=b((...r)=>e.login_lastfm&&e.login_lastfm(...r),["prevent"]))},[t("div",et,[t("div",ot,[u(t("input",{"onUpdate:modelValue":n[2]||(n[2]=r=>_.lastfm_login.user=r),class:"input",type:"text",placeholder:s.$t("page.settings.services.username")},null,8,nt),[[h,_.lastfm_login.user]]),t("p",{class:"help is-danger",textContent:o(_.lastfm_login.errors.user)},null,8,it)]),t("div",lt,[u(t("input",{"onUpdate:modelValue":n[3]||(n[3]=r=>_.lastfm_login.password=r),class:"input",type:"password",placeholder:s.$t("page.settings.services.password")},null,8,rt),[[h,_.lastfm_login.password]]),t("p",{class:"help is-danger",textContent:o(_.lastfm_login.errors.password)},null,8,at)]),t("div",_t,[t("button",{class:"button is-info",type:"submit",textContent:o(s.$t("page.settings.services.login"))},null,8,dt)])]),t("p",{class:"help is-danger",textContent:o(_.lastfm_login.errors.error)},null,8,pt),t("p",{class:"help",textContent:o(s.$t("page.settings.services.lastfm.info"))},null,8,ct)],32)]))])):a("",!0)]),_:1})])}const yt=v(w,[["render",ft]]);export{yt as default};