owntone-server/htdocs/assets/PageSettingsWebinterface.js

2 lines
9.4 KiB
JavaScript
Raw Normal View History

2023-12-14 20:00:28 +00:00
import{C as I}from"./ContentWithHeading.js";import{C as T}from"./ControlDropdown.js";import{S}from"./SettingsCheckbox.js";import{_ as m,e as w,a5 as $,o as g,c as p,a as e,z as u,q as C,t as s,k as b,r as c,d as i,w as n}from"./index.js";import{T as k}from"./TabsSettings.js";const D={name:"SettingsIntfield",props:["category_name","option_name","placeholder","disabled"],data(){return{timerDelay:2e3,timerId:-1,statusUpdate:""}},computed:{category(){return this.$store.state.settings.categories.find(t=>t.name===this.category_name)},option(){return this.category?this.category.options.find(t=>t.name===this.option_name):{}},value(){return this.option.value},info(){return this.statusUpdate==="success"?this.$t("setting.saved"):this.statusUpdate==="error"?this.$t("setting.not-saved"):""},is_success(){return this.statusUpdate==="success"},is_error(){return this.statusUpdate==="error"}},methods:{set_update_timer(){this.timerId>0&&(window.clearTimeout(this.timerId),this.timerId=-1),this.statusUpdate="",this.$refs.setting.value!==this.value&&(this.timerId=window.setTimeout(this.update_setting,this.timerDelay))},update_setting(){this.timerId=-1;const t=this.$refs.setting.value;if(t===this.value){this.statusUpdate="";return}const a={category:this.category.name,name:this.option_name,value:parseInt(t,10)};w.settings_update(this.category.name,a).then(()=>{this.$store.commit($,a),this.statusUpdate="success"}).catch(()=>{this.statusUpdate="error",this.$refs.setting.value=this.value}).finally(()=>{this.timerId=window.setTimeout(this.clear_status,this.timerDelay)})},clear_status(){this.statusUpdate=""}}},V=["disabled"],z={class:"field"},N={class:"label has-text-weight-normal"},E=["textContent"],P={class:"control"},B=["placeholder","value"],L={key:0,class:"help"};function W(t,a,r,_,f,o){return g(),p("fieldset",{disabled:r.disabled},[e("div",z,[e("label",N,[u(t.$slots,"label"),e("i",{class:C(["is-size-7",{"has-text-info":o.is_success,"has-text-danger":o.is_error}]),textContent:s(o.info)},null,10,E)]),e("div",P,[e("input",{ref:"setting",class:"column input is-one-fifth",type:"number",min:"0",placeholder:r.placeholder,value:o.value,onInput:a[0]||(a[0]=(...d)=>o.set_update_timer&&o.set_update_timer(...d))},null,40,B)]),t.$slots.info?(g(),p("p",L,[u(t.$slots,"info")])):b("",!0)])],8,V)}const O=m(D,[["render",W]]),q={name:"SettingsTextfield",props:["category_name","option_name","placeholder","disabled"],data(){return{timerDelay:2e3,timerId:-1,statusUpdate:""}},computed:{category(){return this.$store.state.settings.categories.find(t=>t.name===this.category_name)},option(){return this.category?this.category.options.find(t=>t.name===this.option_name):{}},value(){return this.option.value},info(){return this.statusUpdate==="success"?this.$t("setting.saved"):this.statusUpdate==="error"?this.$t("setting.not-saved"):""},is_success(){return this.statusUpdate==="success"},is_error(){return this.statusUpdate==="error"}},methods:{set_update_timer(){this.timerId>0&&(window.clearTimeout(this.timerId),this.timerId=-1),this.statusUpdate="",this.$refs.setting.value!==this.value&&(this.timerId=window.setTimeout(this.update_setting,this.timerDelay))},update_setting(){this.timerId=-1;const t=this.$refs.setting.value;if(t===this.value){this.statusUpdate="";return}const a={category:this.category.name,name:this.option_name,value:t};w.settings_update(this.category.name,a).then(()=>{this.$store.commit($,a),this.statusUpdate="success"}).catch(()=>{this.statusUpdate="error",this.$refs.setting.value=this.value}).finally(()=>{this.timerId=window.setTimeout(this.clear_status,this.timerDelay)})},clear_status(){this.statusUpdate=""}}},A=["disabled"],G={class:"field"},H={class:"label has-text-weight-normal"},j=["textContent"],F={class:"control"},J=["placeholder","value"],K={key:0,class:"help"};function M(t,a,r,_,f,o){return g(),p("fieldset",{disabled:r.disabled},[e("div",G,[e("label",H,[u(t.$slots,"label"),e("i",{class:C(["is-size-7",{"has-text-info":o.is_success,"has-text-danger":o.is_error}]),textContent:s(o.info)},null,10,j)]),e("div",F,[e("input",{ref:"setting",class:"input",ty