diff --git a/public/js/bundle.js b/public/js/bundle.js index 681f7b5..4410ca7 100644 --- a/public/js/bundle.js +++ b/public/js/bundle.js @@ -2507,7 +2507,7 @@ a { `;styleInject(css_248z$2);class CustomSocket extends WebSocket{constructor(a){super(a);this.listeners={}}emit(a,n){if(this.readyState!==WebSocket.OPEN)return!1;this.send(JSON.stringify({key:a,data:n}))}on(a,n){Object.keys(this.listeners).includes(a)||(console.log("on:",a),this.listeners[a]=n,this.addEventListener("message",r=>{const i=JSON.parse(r.data);i.key===a&&n(i.data)}))}off(a){Object.keys(this.listeners).includes(a)&&(console.log("off:",a),this.removeEventListener("message",this.listeners[a]),delete this.listeners[a])}}const socket=new CustomSocket("ws://"+location.host+"/");var __vue_render__$w=function(e,a){var n=a._c;return n("div",{directives:[{name:"show",rawName:"v-show",value:!a.props.hidden,expression:"!props.hidden"}],staticClass:"flex justify-center items-center flex-col flex-1 h-full",class:a.props.additionalClasses},[n("span",{staticClass:"mb-5"},[a._v(a._s(a.props.text||"Loading..."))]),a._v(" "),a._m(0)])},__vue_staticRenderFns__$w=[function(e,a){var n=a._c;return n("div",{staticClass:"lds-ring"},[n("div"),a._v(" "),n("div"),a._v(" "),n("div"),a._v(" "),n("div")])}];const __vue_inject_styles__$w=function(e){!e||e("data-v-4e4e821e_0",{source:".lds-ring[data-v-4e4e821e]{display:inline-block;position:relative;width:80px;height:80px}.lds-ring div[data-v-4e4e821e]{box-sizing:border-box;display:block;position:absolute;width:64px;height:64px;margin:8px;border:8px solid #fff;border-radius:50%;animation:lds-ring-data-v-4e4e821e 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#fff transparent transparent transparent}.lds-ring div[data-v-4e4e821e]:nth-child(1){animation-delay:-.45s}.lds-ring div[data-v-4e4e821e]:nth-child(2){animation-delay:-.3s}.lds-ring div[data-v-4e4e821e]:nth-child(3){animation-delay:-.15s}@keyframes lds-ring-data-v-4e4e821e{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",map:void 0,media:void 0})},__vue_scope_id__$w="data-v-4e4e821e",__vue_module_identifier__$d=void 0,__vue_is_functional_template__$w=!0;function __vue_normalize__$w(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};o.__file="BaseLoadingPlaceholder.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r;{let u;if(a&&(u=function(d){a.call(this,l(d))}),u!==void 0)if(o.functional){const d=o.render;o.render=function(h,m){return u.call(m),d(h,m)}}else{const d=o.beforeCreate;o.beforeCreate=d?[].concat(d,u):[u]}}return o}function __vue_create_injector__$d(){const e=document.head||document.getElementsByTagName("head")[0],a=__vue_create_injector__$d.styles||(__vue_create_injector__$d.styles={}),n=typeof navigator!="undefined"&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(i,s){if(document.querySelector('style[data-vue-ssr-id~="'+i+'"]'))return;const l=n?s.media||"default":i,c=a[l]||(a[l]={ids:[],parts:[],element:void 0});if(!c.ids.includes(i)){let o=s.source,u=c.ids.length;if(c.ids.push(i),s.map&&(o+=` /*# sourceURL=`+s.map.sources[0]+" */",o+=` /*# sourceMappingURL=data:application/json;base64,`+btoa(unescape(encodeURIComponent(JSON.stringify(s.map))))+" */"),n&&(c.element=c.element||document.querySelector("style[data-group="+l+"]")),!c.element){const d=c.element=document.createElement("style");d.type="text/css",s.media&&d.setAttribute("media",s.media),n&&(d.setAttribute("data-group",l),d.setAttribute("data-next-index","0")),e.appendChild(d)}if(n&&(u=parseInt(c.element.getAttribute("data-next-index")),c.element.setAttribute("data-next-index",u+1)),c.element.styleSheet)c.parts.push(o),c.element.styleSheet.cssText=c.parts.filter(Boolean).join(` -`);else{const d=document.createTextNode(o),f=c.element.childNodes;f[u]&&c.element.removeChild(f[u]),f.length?c.element.insertBefore(d,f[u]):c.element.appendChild(d)}}}}var BaseLoadingPlaceholder=__vue_normalize__$w({render:__vue_render__$w,staticRenderFns:__vue_staticRenderFns__$w},__vue_inject_styles__$w,{},__vue_scope_id__$w,__vue_is_functional_template__$w,__vue_module_identifier__$d,__vue_create_injector__$d);function fetchData(e,a={},n="GET"){const r=new URL(`${window.location.origin}/api/${e}`);return Object.keys(a).forEach(i=>{r.searchParams.append(i,a[i])}),fetch(r.href,{method:n}).then(i=>i.json()).catch(()=>{})}const postToServer=(e,a)=>{const n=new URL(`${window.location.origin}/api/${e}`);fetch(n,{body:JSON.stringify(a),headers:{"Content-Type":"application/json"},method:"POST"}).catch(console.error)};function sendAddToQueue(e,a=null){if(!e)throw new Error("No URL given to sendAddToQueue function!");fetchData("addToQueue",{url:e,bitrate:a},"POST")}function aggregateDownloadLinks(e){const a=[];return e.forEach(n=>{a.push(n.link)}),a.join(";")}function generatePath(e){if(!e)throw new Error("No element passed to the generatePath function!");const a=[e];for(;(e=e.parentNode)&&e!==document;)a.push(e);return a}function isValidURL(e){const a=e.toLowerCase();if(a.startsWith("http")){if(a.includes("deezer.com")||a.includes("deezer.page.link")||a.includes("open.spotify.com")||a.includes("link.tospotify.com"))return!0}else if(a.startsWith("spotify:"))return!0;return!1}function convertDuration(e){let a,n;return a=Math.floor(e/60),n=e-a*60,n<10&&(n="0"+n),a+":"+n}function convertDurationSeparated(e){let a,n,r;return n=Math.floor(e/60),a=Math.floor(n/60),r=e-n*60,n-=a*60,[a,n,r]}function numberWithDots(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,".")}function debounce$1(e,a,n){let r;return function(){const i=this,s=arguments,l=function(){r=null,n||e.apply(i,s)},c=n&&!r;clearTimeout(r),r=setTimeout(l,a),c&&e.apply(i,s)}}function copyToClipboard(e){const a=document.createElement("input");document.body.appendChild(a),a.setAttribute("type","text"),a.setAttribute("value",e),a.select(),a.setSelectionRange(0,99999),document.execCommand("copy"),a.remove()}function getPropertyWithFallback(e,...a){for(const n of a){const i=/\./.test(n)?n.split(".").reduce((s,l)=>{if(s)return s[l]},e):e[n];if(typeof i!="undefined")return i}return null}var Utils={isValidURL,convertDuration,convertDurationSeparated,numberWithDots,debounce:debounce$1};const downloadQualities=[{objName:"flac",label:"FLAC",value:9},{objName:"320kbps",label:"MP3 320kbps",value:3},{objName:"128kbps",label:"MP3 128kbps",value:1},{objName:"realityAudioHQ",label:"360 Reality Audio [HQ]",value:15},{objName:"realityAudioMQ",label:"360 Reality Audio [MQ]",value:14},{objName:"realityAudioLQ",label:"360 Reality Audio [LQ]",value:13}];var script$u={data(){return{menuOpen:!1,xPos:0,yPos:0,deezerHref:"",generalHref:"",imgSrc:""}},computed:{options(){const e={cut:{label:this.$t("globals.cut"),show:!1,position:1,action:()=>{document.execCommand("Cut")}},copy:{label:this.$t("globals.copy"),show:!1,position:2,action:()=>{document.execCommand("Copy")}},copyLink:{label:this.$t("globals.copyLink"),show:!1,position:3,action:()=>{copyToClipboard(this.generalHref)}},copyImageLink:{label:this.$t("globals.copyImageLink"),show:!1,position:4,action:()=>{copyToClipboard(this.imgSrc)}},copyDeezerLink:{label:this.$t("globals.copyDeezerLink"),show:!1,position:5,action:()=>{copyToClipboard(this.deezerHref)}},paste:{label:this.$t("globals.paste"),show:!1,position:6,action:()=>{clipboard in navigator?navigator.clipboard.readText().then(n=>{document.execCommand("insertText",void 0,n)}):document.execCommand("paste")}}},a=Object.values(e).length+1;return downloadQualities.forEach((n,r)=>{e[n.objName]={label:`${this.$t("globals.download",{thing:n.label})}`,show:!1,position:a+r,action:sendAddToQueue.bind(null,this.deezerHref,n.value)}}),e},sortedOptions(){return Object.values(this.options).sort((e,a)=>e.position{this.menuOpen=!1,this.options.copyLink.show=!1,this.options.copyDeezerLink.show=!1,this.options.copyImageLink.show=!1,downloadQualities.forEach(e=>{this.options[e.objName].show=!1})}).catch(e=>{console.error(e)})},positionMenu(e,a){this.xPos=`${e}px`,this.yPos=`${a}px`,this.$nextTick().then(()=>{const{innerHeight:n,innerWidth:r}=window,i=e+this.$refs.contextMenu.getBoundingClientRect().width,s=a+this.$refs.contextMenu.getBoundingClientRect().height;if(i>r){const l=i-r+15;this.xPos=`${e-l}px`}if(s>n){const l=s-n+15;this.yPos=`${a-l}px`}})},showDeezerOptions(e){e||(this.options.copyDeezerLink.show=!0),downloadQualities.forEach(a=>{this.options[a.objName].show=!0})}}};const __vue_script__$u=script$u;var __vue_render__$v=function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("div",{directives:[{name:"show",rawName:"v-show",value:e.menuOpen,expression:"menuOpen"}],ref:"contextMenu",staticClass:"context-menu",style:{top:e.yPos,left:e.xPos}},e._l(e.sortedOptions,function(r){return n("button",{directives:[{name:"show",rawName:"v-show",value:r.show,expression:"option.show"}],key:r.label,staticClass:"btn menu-option",on:{click:function(i){return i.preventDefault(),r.action(i)}}},[n("span",{staticClass:"menu-option__text"},[e._v(e._s(r.label))])])}),0)},__vue_staticRenderFns__$v=[];const __vue_inject_styles__$v=function(e){!e||e("data-v-4fdee10f_0",{source:".context-menu[data-v-4fdee10f]{position:absolute;top:0;left:0;min-width:100px;border-radius:7px;background:var(--secondary-background);box-shadow:4px 10px 18px 0 rgba(0,0,0,.15);overflow:hidden;z-index:10000}.menu-option[data-v-4fdee10f]{display:flex;align-items:center;width:100%;height:40px;padding-left:10px;padding-right:10px;color:var(--foreground);cursor:pointer}.menu-option[data-v-4fdee10f]:hover{background:var(--table-highlight);filter:brightness(150%)}.menu-option__text[data-v-4fdee10f]{text-transform:capitalize}button[data-v-4fdee10f]{color:var(--primary-text);color:unset;background-color:var(--primary-color);background-color:unset;min-width:unset;position:unset;border:unset;border-radius:unset;font-family:unset;font-weight:unset;font-size:unset;padding:unset;margin-right:unset;height:unset;text-transform:unset;cursor:unset;transition:unset}button[data-v-4fdee10f]:focus{outline:0}button[data-v-4fdee10f]:active{background-color:unset;transform:unset}button[data-v-4fdee10f]:hover{background:unset;border:unset}",map:void 0,media:void 0})},__vue_scope_id__$v="data-v-4fdee10f",__vue_module_identifier__$c=void 0,__vue_is_functional_template__$v=!1;function __vue_normalize__$v(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};o.__file="TheContextMenu.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r;{let u;if(a&&(u=function(d){a.call(this,l(d))}),u!==void 0)if(o.functional){const d=o.render;o.render=function(h,m){return u.call(m),d(h,m)}}else{const d=o.beforeCreate;o.beforeCreate=d?[].concat(d,u):[u]}}return o}function __vue_create_injector__$c(){const e=document.head||document.getElementsByTagName("head")[0],a=__vue_create_injector__$c.styles||(__vue_create_injector__$c.styles={}),n=typeof navigator!="undefined"&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(i,s){if(document.querySelector('style[data-vue-ssr-id~="'+i+'"]'))return;const l=n?s.media||"default":i,c=a[l]||(a[l]={ids:[],parts:[],element:void 0});if(!c.ids.includes(i)){let o=s.source,u=c.ids.length;if(c.ids.push(i),s.map&&(o+=` +`);else{const d=document.createTextNode(o),f=c.element.childNodes;f[u]&&c.element.removeChild(f[u]),f.length?c.element.insertBefore(d,f[u]):c.element.appendChild(d)}}}}var BaseLoadingPlaceholder=__vue_normalize__$w({render:__vue_render__$w,staticRenderFns:__vue_staticRenderFns__$w},__vue_inject_styles__$w,{},__vue_scope_id__$w,__vue_is_functional_template__$w,__vue_module_identifier__$d,__vue_create_injector__$d);function fetchData(e,a={},n="GET"){const r=new URL(`${window.location.origin}/api/${e}`);return Object.keys(a).forEach(i=>{r.searchParams.append(i,a[i])}),fetch(r.href,{method:n}).then(i=>{if(!i.ok)throw new Error("Network response was not ok");return i.json()}).catch(i=>{console.error("There has been a problem with your fetch operation:",i)})}const postToServer=(e,a)=>{const n=new URL(`${window.location.origin}/api/${e}`);return fetch(n,{body:JSON.stringify(a),headers:{"Content-Type":"application/json"},method:"POST"}).then(r=>{if(!r.ok)throw new Error("Network response was not ok");return r.json()}).catch(r=>{console.error("There has been a problem with your fetch operation:",r)})};function sendAddToQueue(e,a=null){if(!e)throw new Error("No URL given to sendAddToQueue function!");fetchData("addToQueue",{url:e,bitrate:a},"POST")}function aggregateDownloadLinks(e){const a=[];return e.forEach(n=>{a.push(n.link)}),a.join(";")}function generatePath(e){if(!e)throw new Error("No element passed to the generatePath function!");const a=[e];for(;(e=e.parentNode)&&e!==document;)a.push(e);return a}function isValidURL(e){const a=e.toLowerCase();if(a.startsWith("http")){if(a.includes("deezer.com")||a.includes("deezer.page.link")||a.includes("open.spotify.com")||a.includes("link.tospotify.com"))return!0}else if(a.startsWith("spotify:"))return!0;return!1}function convertDuration(e){let a,n;return a=Math.floor(e/60),n=e-a*60,n<10&&(n="0"+n),a+":"+n}function convertDurationSeparated(e){let a,n,r;return n=Math.floor(e/60),a=Math.floor(n/60),r=e-n*60,n-=a*60,[a,n,r]}function numberWithDots(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,".")}function debounce$1(e,a,n){let r;return function(){const i=this,s=arguments,l=function(){r=null,n||e.apply(i,s)},c=n&&!r;clearTimeout(r),r=setTimeout(l,a),c&&e.apply(i,s)}}function copyToClipboard(e){const a=document.createElement("input");document.body.appendChild(a),a.setAttribute("type","text"),a.setAttribute("value",e),a.select(),a.setSelectionRange(0,99999),document.execCommand("copy"),a.remove()}function getPropertyWithFallback(e,...a){for(const n of a){const i=/\./.test(n)?n.split(".").reduce((s,l)=>{if(s)return s[l]},e):e[n];if(typeof i!="undefined")return i}return null}var Utils={isValidURL,convertDuration,convertDurationSeparated,numberWithDots,debounce:debounce$1};const downloadQualities=[{objName:"flac",label:"FLAC",value:9},{objName:"320kbps",label:"MP3 320kbps",value:3},{objName:"128kbps",label:"MP3 128kbps",value:1},{objName:"realityAudioHQ",label:"360 Reality Audio [HQ]",value:15},{objName:"realityAudioMQ",label:"360 Reality Audio [MQ]",value:14},{objName:"realityAudioLQ",label:"360 Reality Audio [LQ]",value:13}];var script$u={data(){return{menuOpen:!1,xPos:0,yPos:0,deezerHref:"",generalHref:"",imgSrc:""}},computed:{options(){const e={cut:{label:this.$t("globals.cut"),show:!1,position:1,action:()=>{document.execCommand("Cut")}},copy:{label:this.$t("globals.copy"),show:!1,position:2,action:()=>{document.execCommand("Copy")}},copyLink:{label:this.$t("globals.copyLink"),show:!1,position:3,action:()=>{copyToClipboard(this.generalHref)}},copyImageLink:{label:this.$t("globals.copyImageLink"),show:!1,position:4,action:()=>{copyToClipboard(this.imgSrc)}},copyDeezerLink:{label:this.$t("globals.copyDeezerLink"),show:!1,position:5,action:()=>{copyToClipboard(this.deezerHref)}},paste:{label:this.$t("globals.paste"),show:!1,position:6,action:()=>{clipboard in navigator?navigator.clipboard.readText().then(n=>{document.execCommand("insertText",void 0,n)}):document.execCommand("paste")}}},a=Object.values(e).length+1;return downloadQualities.forEach((n,r)=>{e[n.objName]={label:`${this.$t("globals.download",{thing:n.label})}`,show:!1,position:a+r,action:sendAddToQueue.bind(null,this.deezerHref,n.value)}}),e},sortedOptions(){return Object.values(this.options).sort((e,a)=>e.position{this.menuOpen=!1,this.options.copyLink.show=!1,this.options.copyDeezerLink.show=!1,this.options.copyImageLink.show=!1,downloadQualities.forEach(e=>{this.options[e.objName].show=!1})}).catch(e=>{console.error(e)})},positionMenu(e,a){this.xPos=`${e}px`,this.yPos=`${a}px`,this.$nextTick().then(()=>{const{innerHeight:n,innerWidth:r}=window,i=e+this.$refs.contextMenu.getBoundingClientRect().width,s=a+this.$refs.contextMenu.getBoundingClientRect().height;if(i>r){const l=i-r+15;this.xPos=`${e-l}px`}if(s>n){const l=s-n+15;this.yPos=`${a-l}px`}})},showDeezerOptions(e){e||(this.options.copyDeezerLink.show=!0),downloadQualities.forEach(a=>{this.options[a.objName].show=!0})}}};const __vue_script__$u=script$u;var __vue_render__$v=function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("div",{directives:[{name:"show",rawName:"v-show",value:e.menuOpen,expression:"menuOpen"}],ref:"contextMenu",staticClass:"context-menu",style:{top:e.yPos,left:e.xPos}},e._l(e.sortedOptions,function(r){return n("button",{directives:[{name:"show",rawName:"v-show",value:r.show,expression:"option.show"}],key:r.label,staticClass:"btn menu-option",on:{click:function(i){return i.preventDefault(),r.action(i)}}},[n("span",{staticClass:"menu-option__text"},[e._v(e._s(r.label))])])}),0)},__vue_staticRenderFns__$v=[];const __vue_inject_styles__$v=function(e){!e||e("data-v-4fdee10f_0",{source:".context-menu[data-v-4fdee10f]{position:absolute;top:0;left:0;min-width:100px;border-radius:7px;background:var(--secondary-background);box-shadow:4px 10px 18px 0 rgba(0,0,0,.15);overflow:hidden;z-index:10000}.menu-option[data-v-4fdee10f]{display:flex;align-items:center;width:100%;height:40px;padding-left:10px;padding-right:10px;color:var(--foreground);cursor:pointer}.menu-option[data-v-4fdee10f]:hover{background:var(--table-highlight);filter:brightness(150%)}.menu-option__text[data-v-4fdee10f]{text-transform:capitalize}button[data-v-4fdee10f]{color:var(--primary-text);color:unset;background-color:var(--primary-color);background-color:unset;min-width:unset;position:unset;border:unset;border-radius:unset;font-family:unset;font-weight:unset;font-size:unset;padding:unset;margin-right:unset;height:unset;text-transform:unset;cursor:unset;transition:unset}button[data-v-4fdee10f]:focus{outline:0}button[data-v-4fdee10f]:active{background-color:unset;transform:unset}button[data-v-4fdee10f]:hover{background:unset;border:unset}",map:void 0,media:void 0})},__vue_scope_id__$v="data-v-4fdee10f",__vue_module_identifier__$c=void 0,__vue_is_functional_template__$v=!1;function __vue_normalize__$v(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};o.__file="TheContextMenu.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r;{let u;if(a&&(u=function(d){a.call(this,l(d))}),u!==void 0)if(o.functional){const d=o.render;o.render=function(h,m){return u.call(m),d(h,m)}}else{const d=o.beforeCreate;o.beforeCreate=d?[].concat(d,u):[u]}}return o}function __vue_create_injector__$c(){const e=document.head||document.getElementsByTagName("head")[0],a=__vue_create_injector__$c.styles||(__vue_create_injector__$c.styles={}),n=typeof navigator!="undefined"&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(i,s){if(document.querySelector('style[data-vue-ssr-id~="'+i+'"]'))return;const l=n?s.media||"default":i,c=a[l]||(a[l]={ids:[],parts:[],element:void 0});if(!c.ids.includes(i)){let o=s.source,u=c.ids.length;if(c.ids.push(i),s.map&&(o+=` /*# sourceURL=`+s.map.sources[0]+" */",o+=` /*# sourceMappingURL=data:application/json;base64,`+btoa(unescape(encodeURIComponent(JSON.stringify(s.map))))+" */"),n&&(c.element=c.element||document.querySelector("style[data-group="+l+"]")),!c.element){const d=c.element=document.createElement("style");d.type="text/css",s.media&&d.setAttribute("media",s.media),n&&(d.setAttribute("data-group",l),d.setAttribute("data-next-index","0")),e.appendChild(d)}if(n&&(u=parseInt(c.element.getAttribute("data-next-index")),c.element.setAttribute("data-next-index",u+1)),c.element.styleSheet)c.parts.push(o),c.element.styleSheet.cssText=c.parts.filter(Boolean).join(` `);else{const d=document.createTextNode(o),f=c.element.childNodes;f[u]&&c.element.removeChild(f[u]),f.length?c.element.insertBefore(d,f[u]):c.element.appendChild(d)}}}}var TheContextMenu=__vue_normalize__$v({render:__vue_render__$v,staticRenderFns:__vue_staticRenderFns__$v},__vue_inject_styles__$v,__vue_script__$u,__vue_scope_id__$v,__vue_is_functional_template__$v,__vue_module_identifier__$c,__vue_create_injector__$c);/*! @@ -4845,7 +4845,7 @@ a { /*# sourceMappingURL=data:application/json;base64,`+btoa(unescape(encodeURIComponent(JSON.stringify(s.map))))+" */"),n&&(c.element=c.element||document.querySelector("style[data-group="+l+"]")),!c.element){const d=c.element=document.createElement("style");d.type="text/css",s.media&&d.setAttribute("media",s.media),n&&(d.setAttribute("data-group",l),d.setAttribute("data-next-index","0")),e.appendChild(d)}if(n&&(u=parseInt(c.element.getAttribute("data-next-index")),c.element.setAttribute("data-next-index",u+1)),c.element.styleSheet)c.parts.push(o),c.element.styleSheet.cssText=c.parts.filter(Boolean).join(` `);else{const d=document.createTextNode(o),f=c.element.childNodes;f[u]&&c.element.removeChild(f[u]),f.length?c.element.insertBefore(d,f[u]):c.element.appendChild(d)}}}}var BaseAccordion=__vue_normalize__$3({render:__vue_render__$3,staticRenderFns:__vue_staticRenderFns__$3},__vue_inject_styles__$3,__vue_script__$3,__vue_scope_id__$3,__vue_is_functional_template__$3,__vue_module_identifier__$1,__vue_create_injector__$1),script$2={components:{BaseAccordion},props:{templateVariables:{type:Array,required:!0}}};const __vue_script__$2=script$2;var __vue_render__$2=function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("BaseAccordion",{staticStyle:{"--arrow-v-align":"baseline","margin-bottom":"3rem"},scopedSlots:e._u([{key:"title",fn:function(){return[e._t("title")]},proxy:!0}],null,!0)},[e._v(" "),n("div",{staticClass:"flex flex-wrap p-4 space-x-2 rounded-2xl bg-background-secondary"},e._l(e.templateVariables,function(r){return n("span",{staticClass:"inline-block p-2 mt-2 tracking-wider rounded cursor-pointer bg-panels-bg first:ml-2 hover:shadow-outline",on:{click:function(i){return e.$emit("variable-click",r)}}},[e._v(` `+e._s(r)+` - `)])}),0)])},__vue_staticRenderFns__$2=[];const __vue_inject_styles__$2=void 0,__vue_scope_id__$2=void 0,__vue_is_functional_template__$2=!1;function __vue_normalize__$2(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};return o.__file="TemplateVariablesList.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r,o}var TemplateVariablesList=__vue_normalize__$2({render:__vue_render__$2,staticRenderFns:__vue_staticRenderFns__$2},__vue_inject_styles__$2,__vue_script__$2,__vue_scope_id__$2,__vue_is_functional_template__$2);const getFormItem=e=>a=>{const n=e.elements.namedItem(a);return{[a]:n.value}};var script$1={components:{BaseAccordion,TemplateVariablesList},data(){return{flags,currentLocale:this.$i18n.locale,locales:this.$i18n.availableLocales,settings:{tags:{}},lastSettings:{},spotifyFeatures:{},lastCredentials:{},defaultSettings:{},lastUser:"",spotifyUser:"",accountNum:0,accounts:[],trackTemplateVariables}},computed:{...mapGetters({arl:"getARL",user:"getUser",isLoggedIn:"isLoggedIn",clientMode:"getClientMode",previewVolume:"getPreviewVolume",hasSlimDownloads:"getSlimDownloads",hasSlimSidebar:"getSlimSidebar"}),needToWait(){return Object.keys(this.getSettings).length===0},modelVolume:{get(){return this.previewVolume},set:debounce(function(e){this.setPreviewVolume(e)},20)},modelSlimDownloads:{get(){return this.hasSlimDownloads},set(e){this.setSlimDownloads(e)}},modelSlimSidebar:{get(){return this.hasSlimSidebar},set(e){this.setSlimSidebar(e)}},pictureHref(){return`https://e-cdns-images.dzcdn.net/images/user/${this.user.picture}/125x125-000000-80-0-0.jpg`}},async mounted(){const{settingsData:e,defaultSettingsData:a,spotifyCredentials:n}=await getSettingsData();this.defaultSettings=a,this.initSettings(e,n);const r=localStorage.getItem("accountNum");r&&(this.accountNum=r);const i=localStorage.getItem("spotifyUser");i&&(this.lastUser=i,this.spotifyUser=i,socket.emit("update_userSpotifyPlaylists",i)),socket.on("updateSettings",this.updateSettings),socket.on("accountChanged",this.accountChanged),socket.on("familyAccounts",this.initAccounts),socket.on("downloadFolderSelected",this.downloadFolderSelected),socket.on("applogin_arl",this.loggedInViaDeezer),this.$on("hook:destroyed",()=>{socket.off("updateSettings"),socket.off("accountChanged"),socket.off("familyAccounts"),socket.off("downloadFolderSelected"),socket.off("applogin_arl")})},methods:{...mapActions({dispatchARL:"setARL",setPreviewVolume:"setPreviewVolume",setSlimDownloads:"setSlimDownloads",setSlimSidebar:"setSlimSidebar"}),onTemplateVariableClick(e){copyToClipboard(e),toast(`Copied ${e} to clipboard!`)},revertSettings(){this.settings=JSON.parse(JSON.stringify(this.lastSettings))},revertCredentials(){this.spotifyCredentials=JSON.parse(JSON.stringify(this.lastCredentials)),this.spotifyUser=(" "+this.lastUser).slice(1)},copyARLtoClipboard(){const e=this.$refs.loginInput;e.setAttribute("type","text"),e.select(),e.setSelectionRange(0,99999),document.execCommand("copy"),e.setAttribute("type","password"),toast(this.$t("settings.toasts.ARLcopied"),"assignment")},changeLocale(e){this.$i18n.locale=e,this.currentLocale=e,localStorage.setItem("locale",e)},saveSettings(){this.lastSettings=JSON.parse(JSON.stringify(this.settings)),this.lastCredentials=JSON.parse(JSON.stringify(this.spotifyFeatures));let e=!1;this.lastUser!=this.spotifyUser&&(this.lastUser=(" "+this.spotifyUser).slice(1),localStorage.setItem("spotifyUser",this.lastUser),e=!0),socket.emit("saveSettings",{settings:this.lastSettings,spotifySettings:this.lastCredentials,spotifyUser:e?this.lastUser:!1})},selectDownloadFolder(){socket.emit("selectDownloadFolder")},downloadFolderSelected(e){this.$set(this.settings,"downloadLocation",e)},loadSettings(e){this.lastSettings=JSON.parse(JSON.stringify(e)),this.settings=JSON.parse(JSON.stringify(e))},loadCredentials(e){this.lastCredentials=JSON.parse(JSON.stringify(e)),this.spotifyFeatures=JSON.parse(JSON.stringify(e))},async loggedInViaDeezer(e){this.dispatchARL({arl:e})},async login(){const e=this.$refs.loginInput.value.trim();if(e&&e!==this.arl){const a=await fetchData("login-arl",{arl:e,force:!0,child:this.accountNum},"POST");this.loggedInViaDeezer(a.arl)}},loginWithCredentials(){const e=getFormItem(this.$refs.loginWithCredentialsForm),{username:a}=e("username"),{password:n}=e("password");postToServer("loginWithCredentials",{username:a,password:n})},appLogin(){socket.emit("applogin")},changeAccount(){socket.emit("changeAccount",this.accountNum)},accountChanged(e,a){this.$refs.username.innerText=e.name,this.$refs.userpicture.src=`https://e-cdns-images.dzcdn.net/images/user/${e.picture}/125x125-000000-80-0-0.jpg`,this.accountNum=a,localStorage.setItem("accountNum",this.accountNum)},initAccounts(e){this.accounts=e},logout(){socket.emit("logout")},initSettings(e,a){this.loadSettings(e),this.loadCredentials(a),toast(this.$t("settings.toasts.init"),"settings")},updateSettings(e){const{settings:a,spotifySettings:n}=e;this.loadSettings(a),this.loadCredentials(n),toast(this.$t("settings.toasts.update"),"settings")},resetToDefault(){!confirm(this.$t("settings.resetMessage"))||(this.settings=JSON.parse(JSON.stringify(this.defaultSettings)),toast(this.$t("settings.toasts.reset"),"settings"))}}};const __vue_script__$1=script$1;var __vue_render__$1=function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("div",{staticClass:"fixed-footer"},[n("h1",{staticClass:"mb-8 text-5xl"},[e._v(e._s(e.$t("settings.title")))]),e._v(" "),e.isLoggedIn?n("div",{ref:"loggedInInfo",attrs:{id:"logged_in_info"}},[n("img",{ref:"userpicture",staticClass:"w-32 h-32 rounded-full",attrs:{id:"settings_picture",src:e.pictureHref,alt:"Profile Picture"}}),e._v(" "),n("i18n",{attrs:{path:"settings.login.loggedIn",tag:"p"},scopedSlots:e._u([{key:"username",fn:function(){return[n("strong",{ref:"username",attrs:{id:"settings_username"}},[e._v(e._s(e.user.name||"not logged"))])]},proxy:!0}],null,!1,2821744753)}),e._v(" "),n("button",{staticClass:"btn btn-primary",on:{click:e.logout}},[e._v(` + `)])}),0)])},__vue_staticRenderFns__$2=[];const __vue_inject_styles__$2=void 0,__vue_scope_id__$2=void 0,__vue_is_functional_template__$2=!1;function __vue_normalize__$2(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};return o.__file="TemplateVariablesList.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r,o}var TemplateVariablesList=__vue_normalize__$2({render:__vue_render__$2,staticRenderFns:__vue_staticRenderFns__$2},__vue_inject_styles__$2,__vue_script__$2,__vue_scope_id__$2,__vue_is_functional_template__$2);const getFormItem=e=>a=>{const n=e.elements.namedItem(a);return{[a]:n.value}};var script$1={components:{BaseAccordion,TemplateVariablesList},data(){return{flags,currentLocale:this.$i18n.locale,locales:this.$i18n.availableLocales,settings:{tags:{}},lastSettings:{},spotifyFeatures:{},lastCredentials:{},defaultSettings:{},lastUser:"",spotifyUser:"",accountNum:0,accounts:[],trackTemplateVariables}},computed:{...mapGetters({arl:"getARL",user:"getUser",isLoggedIn:"isLoggedIn",clientMode:"getClientMode",previewVolume:"getPreviewVolume",hasSlimDownloads:"getSlimDownloads",hasSlimSidebar:"getSlimSidebar"}),needToWait(){return Object.keys(this.getSettings).length===0},modelVolume:{get(){return this.previewVolume},set:debounce(function(e){this.setPreviewVolume(e)},20)},modelSlimDownloads:{get(){return this.hasSlimDownloads},set(e){this.setSlimDownloads(e)}},modelSlimSidebar:{get(){return this.hasSlimSidebar},set(e){this.setSlimSidebar(e)}},pictureHref(){return`https://e-cdns-images.dzcdn.net/images/user/${this.user.picture}/125x125-000000-80-0-0.jpg`}},async mounted(){const{settingsData:e,defaultSettingsData:a,spotifyCredentials:n}=await getSettingsData();this.defaultSettings=a,this.initSettings(e,n);const r=localStorage.getItem("accountNum");r&&(this.accountNum=r);const i=localStorage.getItem("spotifyUser");i&&(this.lastUser=i,this.spotifyUser=i,socket.emit("update_userSpotifyPlaylists",i)),socket.on("updateSettings",this.updateSettings),socket.on("accountChanged",this.accountChanged),socket.on("familyAccounts",this.initAccounts),socket.on("downloadFolderSelected",this.downloadFolderSelected),socket.on("applogin_arl",this.loggedInViaDeezer),this.$on("hook:destroyed",()=>{socket.off("updateSettings"),socket.off("accountChanged"),socket.off("familyAccounts"),socket.off("downloadFolderSelected"),socket.off("applogin_arl")})},methods:{...mapActions({dispatchARL:"setARL",setPreviewVolume:"setPreviewVolume",setSlimDownloads:"setSlimDownloads",setSlimSidebar:"setSlimSidebar"}),onTemplateVariableClick(e){copyToClipboard(e),toast(`Copied ${e} to clipboard!`)},revertSettings(){this.settings=JSON.parse(JSON.stringify(this.lastSettings))},revertCredentials(){this.spotifyCredentials=JSON.parse(JSON.stringify(this.lastCredentials)),this.spotifyUser=(" "+this.lastUser).slice(1)},copyARLtoClipboard(){const e=this.$refs.loginInput;e.setAttribute("type","text"),e.select(),e.setSelectionRange(0,99999),document.execCommand("copy"),e.setAttribute("type","password"),toast(this.$t("settings.toasts.ARLcopied"),"assignment")},changeLocale(e){this.$i18n.locale=e,this.currentLocale=e,localStorage.setItem("locale",e)},saveSettings(){this.lastSettings=JSON.parse(JSON.stringify(this.settings)),this.lastCredentials=JSON.parse(JSON.stringify(this.spotifyFeatures));let e=!1;this.lastUser!=this.spotifyUser&&(this.lastUser=(" "+this.spotifyUser).slice(1),localStorage.setItem("spotifyUser",this.lastUser),e=!0),socket.emit("saveSettings",{settings:this.lastSettings,spotifySettings:this.lastCredentials,spotifyUser:e?this.lastUser:!1})},selectDownloadFolder(){socket.emit("selectDownloadFolder")},downloadFolderSelected(e){this.$set(this.settings,"downloadLocation",e)},loadSettings(e){this.lastSettings=JSON.parse(JSON.stringify(e)),this.settings=JSON.parse(JSON.stringify(e))},loadCredentials(e){this.lastCredentials=JSON.parse(JSON.stringify(e)),this.spotifyFeatures=JSON.parse(JSON.stringify(e))},async loggedInViaDeezer(e){this.dispatchARL({arl:e})},async login(){const e=this.$refs.loginInput.value.trim();if(e&&e!==this.arl){const a=await fetchData("login-arl",{arl:e,force:!0,child:this.accountNum},"POST");this.loggedInViaDeezer(a.arl)}},async loginWithCredentials(){const e=getFormItem(this.$refs.loginWithCredentialsForm),{username:a}=e("username"),{password:n}=e("password"),r=await postToServer("loginWithCredentials",{username:a,password:n});console.log({response:r})},appLogin(){socket.emit("applogin")},changeAccount(){socket.emit("changeAccount",this.accountNum)},accountChanged(e,a){this.$refs.username.innerText=e.name,this.$refs.userpicture.src=`https://e-cdns-images.dzcdn.net/images/user/${e.picture}/125x125-000000-80-0-0.jpg`,this.accountNum=a,localStorage.setItem("accountNum",this.accountNum)},initAccounts(e){this.accounts=e},logout(){socket.emit("logout")},initSettings(e,a){this.loadSettings(e),this.loadCredentials(a),toast(this.$t("settings.toasts.init"),"settings")},updateSettings(e){const{settings:a,spotifySettings:n}=e;this.loadSettings(a),this.loadCredentials(n),toast(this.$t("settings.toasts.update"),"settings")},resetToDefault(){!confirm(this.$t("settings.resetMessage"))||(this.settings=JSON.parse(JSON.stringify(this.defaultSettings)),toast(this.$t("settings.toasts.reset"),"settings"))}}};const __vue_script__$1=script$1;var __vue_render__$1=function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("div",{staticClass:"fixed-footer"},[n("h1",{staticClass:"mb-8 text-5xl"},[e._v(e._s(e.$t("settings.title")))]),e._v(" "),e.isLoggedIn?n("div",{ref:"loggedInInfo",attrs:{id:"logged_in_info"}},[n("img",{ref:"userpicture",staticClass:"w-32 h-32 rounded-full",attrs:{id:"settings_picture",src:e.pictureHref,alt:"Profile Picture"}}),e._v(" "),n("i18n",{attrs:{path:"settings.login.loggedIn",tag:"p"},scopedSlots:e._u([{key:"username",fn:function(){return[n("strong",{ref:"username",attrs:{id:"settings_username"}},[e._v(e._s(e.user.name||"not logged"))])]},proxy:!0}],null,!1,2821744753)}),e._v(" "),n("button",{staticClass:"btn btn-primary",on:{click:e.logout}},[e._v(` `+e._s(e.$t("settings.login.logout"))+` `)]),e._v(" "),e.accounts.length>1?n("select",{directives:[{name:"model",rawName:"v-model",value:e.accountNum,expression:"accountNum"}],attrs:{id:"family_account"},on:{change:[function(r){var i=Array.prototype.filter.call(r.target.options,function(s){return s.selected}).map(function(s){var l="_value"in s?s._value:s.value;return l});e.accountNum=r.target.multiple?i:i[0]},e.changeAccount]}},e._l(e.accounts,function(r,i){return n("option",{key:r,domProps:{value:i.toString()}},[e._v(` `+e._s(r.name)+` @@ -4888,7 +4888,7 @@ a { `+e._s(e.$t("settings.spotify.title"))+` `)])]},proxy:!0}])},[e._v(" "),n("RouterLink",{attrs:{to:{name:"Spotify Features"}}},[e._v(` `+e._s(e.$t("settings.spotify.question"))+` - `)]),e._v(" "),n("div",{staticClass:"input-group"},[n("p",{staticClass:"input-group-text"},[e._v(e._s(e.$t("settings.spotify.clientID")))]),e._v(" "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.spotifyFeatures.clientId,expression:"spotifyFeatures.clientId"}],attrs:{type:"text"},domProps:{value:e.spotifyFeatures.clientId},on:{input:function(r){r.target.composing||e.$set(e.spotifyFeatures,"clientId",r.target.value)}}})]),e._v(" "),n("div",{staticClass:"input-group"},[n("p",{staticClass:"input-group-text"},[e._v(e._s(e.$t("settings.spotify.clientSecret")))]),e._v(" "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.spotifyFeatures.clientSecret,expression:"spotifyFeatures.clientSecret"}],attrs:{type:"password"},domProps:{value:e.spotifyFeatures.clientSecret},on:{input:function(r){r.target.composing||e.$set(e.spotifyFeatures,"clientSecret",r.target.value)}}})]),e._v(" "),n("div",{staticClass:"input-group"},[n("p",{staticClass:"input-group-text"},[e._v(e._s(e.$t("settings.spotify.username")))]),e._v(" "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.spotifyUser,expression:"spotifyUser"}],attrs:{type:"text"},domProps:{value:e.spotifyUser},on:{input:function(r){r.target.composing||(e.spotifyUser=r.target.value)}}})])],1),e._v(" "),n("footer",{staticClass:"bg-background-main"},[n("button",{staticClass:"mr-2 btn btn-primary",on:{click:e.resetToDefault}},[e._v(e._s(e.$t("settings.reset")))]),e._v(" "),n("button",{staticClass:"btn btn-primary",on:{click:e.saveSettings}},[e._v(e._s(e.$t("settings.save")))])])],1)},__vue_staticRenderFns__$1=[function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("label",[n("span",[e._v("Username")]),e._v(" "),n("input",{attrs:{type:"text",name:"username"}})])},function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("label",[n("span",[e._v("Password")]),e._v(" "),n("input",{attrs:{type:"password",name:"password"}})])}];const __vue_inject_styles__$1=function(e){!e||e("data-v-fe986c72_0",{source:"#logged_in_info[data-v-fe986c72]{display:flex;align-items:center;flex-direction:column;justify-content:space-evenly;height:250px}.locale-flag[data-v-fe986c72]{justify-content:center;cursor:pointer;width:60px}.locale-flag[data-v-fe986c72]:not(:last-child){margin-right:10px}.locale-flag.locale-flag--current[data-v-fe986c72] svg{filter:brightness(1)!important}.locale-flag[data-v-fe986c72] svg{width:40px!important;height:40px!important;filter:brightness(.5)}.settings-group[data-v-fe986c72]{border-top-width:1px;border-color:gray}.settings-group__header[data-v-fe986c72]{display:inline-flex;align-items:center;padding-top:2rem;padding-bottom:2rem;font-size:1.5rem}.settings-group__header i.material-icons[data-v-fe986c72]{margin-right:1rem}.settings-container[data-v-fe986c72]{display:flex}.settings-container__half[data-v-fe986c72]{width:50%}.settings-container__third[data-v-fe986c72]{width:33%}.settings-container__third--only-checkbox[data-v-fe986c72]{display:flex;align-items:start;flex-direction:column;justify-content:center}.settings-container__half>*[data-v-fe986c72],.settings-container__third>*[data-v-fe986c72]{margin-bottom:1rem}.with-checkbox[data-v-fe986c72]{display:flex;align-items:center}.with-checkbox [type=checkbox][data-v-fe986c72]{cursor:pointer}.with-checkbox .checkbox-text[data-v-fe986c72]{margin-left:10px;cursor:pointer;user-select:none}.input-group .input-group-text[data-v-fe986c72]{margin-bottom:.5rem}",map:void 0,media:void 0})},__vue_scope_id__$1="data-v-fe986c72",__vue_module_identifier__=void 0,__vue_is_functional_template__$1=!1;function __vue_normalize__$1(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};o.__file="Settings.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r;{let u;if(a&&(u=function(d){a.call(this,l(d))}),u!==void 0)if(o.functional){const d=o.render;o.render=function(h,m){return u.call(m),d(h,m)}}else{const d=o.beforeCreate;o.beforeCreate=d?[].concat(d,u):[u]}}return o}function __vue_create_injector__(){const e=document.head||document.getElementsByTagName("head")[0],a=__vue_create_injector__.styles||(__vue_create_injector__.styles={}),n=typeof navigator!="undefined"&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(i,s){if(document.querySelector('style[data-vue-ssr-id~="'+i+'"]'))return;const l=n?s.media||"default":i,c=a[l]||(a[l]={ids:[],parts:[],element:void 0});if(!c.ids.includes(i)){let o=s.source,u=c.ids.length;if(c.ids.push(i),s.map&&(o+=` + `)]),e._v(" "),n("div",{staticClass:"input-group"},[n("p",{staticClass:"input-group-text"},[e._v(e._s(e.$t("settings.spotify.clientID")))]),e._v(" "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.spotifyFeatures.clientId,expression:"spotifyFeatures.clientId"}],attrs:{type:"text"},domProps:{value:e.spotifyFeatures.clientId},on:{input:function(r){r.target.composing||e.$set(e.spotifyFeatures,"clientId",r.target.value)}}})]),e._v(" "),n("div",{staticClass:"input-group"},[n("p",{staticClass:"input-group-text"},[e._v(e._s(e.$t("settings.spotify.clientSecret")))]),e._v(" "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.spotifyFeatures.clientSecret,expression:"spotifyFeatures.clientSecret"}],attrs:{type:"password"},domProps:{value:e.spotifyFeatures.clientSecret},on:{input:function(r){r.target.composing||e.$set(e.spotifyFeatures,"clientSecret",r.target.value)}}})]),e._v(" "),n("div",{staticClass:"input-group"},[n("p",{staticClass:"input-group-text"},[e._v(e._s(e.$t("settings.spotify.username")))]),e._v(" "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.spotifyUser,expression:"spotifyUser"}],attrs:{type:"text"},domProps:{value:e.spotifyUser},on:{input:function(r){r.target.composing||(e.spotifyUser=r.target.value)}}})])],1),e._v(" "),n("footer",{staticClass:"bg-background-main"},[n("button",{staticClass:"mr-2 btn btn-primary",on:{click:e.resetToDefault}},[e._v(e._s(e.$t("settings.reset")))]),e._v(" "),n("button",{staticClass:"btn btn-primary",on:{click:e.saveSettings}},[e._v(e._s(e.$t("settings.save")))])])],1)},__vue_staticRenderFns__$1=[function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("label",[n("span",[e._v("Username")]),e._v(" "),n("input",{attrs:{type:"text",name:"username"}})])},function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("label",[n("span",[e._v("Password")]),e._v(" "),n("input",{attrs:{type:"password",name:"password"}})])}];const __vue_inject_styles__$1=function(e){!e||e("data-v-67af3a66_0",{source:"#logged_in_info[data-v-67af3a66]{display:flex;align-items:center;flex-direction:column;justify-content:space-evenly;height:250px}.locale-flag[data-v-67af3a66]{justify-content:center;cursor:pointer;width:60px}.locale-flag[data-v-67af3a66]:not(:last-child){margin-right:10px}.locale-flag.locale-flag--current[data-v-67af3a66] svg{filter:brightness(1)!important}.locale-flag[data-v-67af3a66] svg{width:40px!important;height:40px!important;filter:brightness(.5)}.settings-group[data-v-67af3a66]{border-top-width:1px;border-color:gray}.settings-group__header[data-v-67af3a66]{display:inline-flex;align-items:center;padding-top:2rem;padding-bottom:2rem;font-size:1.5rem}.settings-group__header i.material-icons[data-v-67af3a66]{margin-right:1rem}.settings-container[data-v-67af3a66]{display:flex}.settings-container__half[data-v-67af3a66]{width:50%}.settings-container__third[data-v-67af3a66]{width:33%}.settings-container__third--only-checkbox[data-v-67af3a66]{display:flex;align-items:start;flex-direction:column;justify-content:center}.settings-container__half>*[data-v-67af3a66],.settings-container__third>*[data-v-67af3a66]{margin-bottom:1rem}.with-checkbox[data-v-67af3a66]{display:flex;align-items:center}.with-checkbox [type=checkbox][data-v-67af3a66]{cursor:pointer}.with-checkbox .checkbox-text[data-v-67af3a66]{margin-left:10px;cursor:pointer;user-select:none}.input-group .input-group-text[data-v-67af3a66]{margin-bottom:.5rem}",map:void 0,media:void 0})},__vue_scope_id__$1="data-v-67af3a66",__vue_module_identifier__=void 0,__vue_is_functional_template__$1=!1;function __vue_normalize__$1(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};o.__file="Settings.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r;{let u;if(a&&(u=function(d){a.call(this,l(d))}),u!==void 0)if(o.functional){const d=o.render;o.render=function(h,m){return u.call(m),d(h,m)}}else{const d=o.beforeCreate;o.beforeCreate=d?[].concat(d,u):[u]}}return o}function __vue_create_injector__(){const e=document.head||document.getElementsByTagName("head")[0],a=__vue_create_injector__.styles||(__vue_create_injector__.styles={}),n=typeof navigator!="undefined"&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(i,s){if(document.querySelector('style[data-vue-ssr-id~="'+i+'"]'))return;const l=n?s.media||"default":i,c=a[l]||(a[l]={ids:[],parts:[],element:void 0});if(!c.ids.includes(i)){let o=s.source,u=c.ids.length;if(c.ids.push(i),s.map&&(o+=` /*# sourceURL=`+s.map.sources[0]+" */",o+=` /*# sourceMappingURL=data:application/json;base64,`+btoa(unescape(encodeURIComponent(JSON.stringify(s.map))))+" */"),n&&(c.element=c.element||document.querySelector("style[data-group="+l+"]")),!c.element){const d=c.element=document.createElement("style");d.type="text/css",s.media&&d.setAttribute("media",s.media),n&&(d.setAttribute("data-group",l),d.setAttribute("data-next-index","0")),e.appendChild(d)}if(n&&(u=parseInt(c.element.getAttribute("data-next-index")),c.element.setAttribute("data-next-index",u+1)),c.element.styleSheet)c.parts.push(o),c.element.styleSheet.cssText=c.parts.filter(Boolean).join(` `);else{const d=document.createTextNode(o),f=c.element.childNodes;f[u]&&c.element.removeChild(f[u]),f.length?c.element.insertBefore(d,f[u]):c.element.appendChild(d)}}}}var Settings=__vue_normalize__$1({render:__vue_render__$1,staticRenderFns:__vue_staticRenderFns__$1},__vue_inject_styles__$1,__vue_script__$1,__vue_scope_id__$1,__vue_is_functional_template__$1,__vue_module_identifier__,__vue_create_injector__),script={data(){return{title:"",metadata:"",release_date:"",label:"",explicit:!1,image:"",type:"empty",link:"",body:[]}},mounted(){EventBus.$on("showAlbum",this.showAlbum),EventBus.$on("showPlaylist",this.showPlaylist),EventBus.$on("showSpotifyPlaylist",this.showSpotifyPlaylist)},methods:{playPausePreview,reset(){this.title="Loading...",this.image="",this.metadata="",this.label="",this.release_date="",this.explicit=!1,this.type="empty",this.body=[]},addToQueue(e){sendAddToQueue(e.currentTarget.dataset.link)},toggleAll(e){this.body.forEach(a=>{a.type==="track"&&(a.selected=e.currentTarget.checked)})},selectedLinks(){const e=[];return this.body&&this.body.forEach(a=>{a.type==="track"&&a.selected&&e.push(this.type==="spotifyPlaylist"?a.uri:a.link)}),e.join(";")},convertDuration:Utils.convertDuration,showAlbum(e){this.reset();const{id:a,title:n,explicit_lyrics:r,label:i,artist:{name:s},tracks:l,tracks:{length:c},release_date:o,cover_xl:u}=e;this.type="album",this.link=`https://www.deezer.com/album/${a}`,this.title=n,this.explicit=r,this.label=i,this.metadata=`${s} \u2022 ${this.$tc("globals.listTabs.trackN",c)}`,this.release_date=o.substring(0,10),this.image=u,isEmpty(l)?this.body=null:this.body=l},showPlaylist(e){this.reset();const{id:a,title:n,picture_xl:r,creation_date:i,creator:{name:s},tracks:l,tracks:{length:c}}=e;this.type="playlist",this.link=`https://www.deezer.com/playlist/${a}`,this.title=n,this.image=r,this.release_date=i.substring(0,10),this.metadata=`${this.$t("globals.by",{artist:s})} \u2022 ${this.$tc("globals.listTabs.trackN",c)}`,isEmpty(l)?this.body=null:this.body=l},showSpotifyPlaylist(e){this.reset();const{uri:a,name:n,images:r,images:{length:i},owner:{display_name:s},tracks:l,tracks:{length:c}}=e;this.type="spotifyPlaylist",this.link=a,this.title=n,this.image=i?r[0].url:"https://e-cdns-images.dzcdn.net/images/cover/d41d8cd98f00b204e9800998ecf8427e/1000x1000-000000-80-0-0.jpg",this.release_date="",this.metadata=`${this.$t("globals.by",{artist:s})} \u2022 ${this.$tc("globals.listTabs.trackN",c)}`,isEmpty(l)?this.body=null:this.body=l},selectRow(e,a){a.selected=!a.selected}}};const __vue_script__=script;var __vue_render__=function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("div",{ref:"root",staticClass:"relative fixed-footer bg-background-main image-header"},[n("header",{style:{"background-image":"linear-gradient(to bottom, transparent 0%, var(--main-background) 100%), url('"+e.image+"')"}},[n("h1",{staticClass:"flex items-center m-0 text-5xl"},[e._v(` diff --git a/src/components/pages/Settings.vue b/src/components/pages/Settings.vue index a8fc326..b3a433e 100644 --- a/src/components/pages/Settings.vue +++ b/src/components/pages/Settings.vue @@ -987,13 +987,14 @@ export default { this.loggedInViaDeezer(res.arl) } }, - loginWithCredentials() { + async loginWithCredentials() { const fromLoginForm = getFormItem(this.$refs.loginWithCredentialsForm) const { username } = fromLoginForm('username') const { password } = fromLoginForm('password') - postToServer('loginWithCredentials', { username, password }) + const response = await postToServer('loginWithCredentials', { username, password }) + console.log({ response }) }, appLogin() { socket.emit('applogin') diff --git a/src/utils/api.js b/src/utils/api.js index 63a901d..1f61d11 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -6,8 +6,15 @@ export function fetchData(key, data = {}, method = 'GET') { }) return fetch(url.href, { method }) - .then(response => response.json()) - .catch(() => {}) + .then(response => { + if (!response.ok) { + throw new Error('Network response was not ok') + } + return response.json() + }) + .catch(error => { + console.error('There has been a problem with your fetch operation:', error) + }) } export function sendToServer(key, data) { @@ -17,17 +24,28 @@ export function sendToServer(key, data) { url.searchParams.append(key, data[key]) }) - fetch(url.href).catch(console.error) + fetch(url.href).catch(error => { + console.error('There has been a problem with your fetch operation:', error) + }) } export const postToServer = (endpoint, data) => { const url = new URL(`${window.location.origin}/api/${endpoint}`) - fetch(url, { + return fetch(url, { body: JSON.stringify(data), headers: { 'Content-Type': 'application/json' }, method: 'POST' - }).catch(console.error) + }) + .then(response => { + if (!response.ok) { + throw new Error('Network response was not ok') + } + return response.json() + }) + .catch(error => { + console.error('There has been a problem with your fetch operation:', error) + }) }