zwave-js-ui
Version:
Z-Wave Control Panel and MQTT Gateway
2 lines (1 loc) • 10.6 kB
JavaScript
import{n as v,at as s,au as i,u as r}from"./index-CtTdmJsx.js";const c={props:{value:{type:Object},disable_send:{type:Boolean},node:{type:Object}},data(){return{durations:["seconds","minutes"],menu:!1,error:null}},computed:{trueLabel(){var l,e;return this.value.type==="boolean"&&((l=this.value.states)==null?void 0:l.length)>0?(e=this.value.states.find(t=>t.value===!0))==null?void 0:e.text:null},falseLabel(){var l,e;return this.value.type==="boolean"&&((l=this.value.states)==null?void 0:l.length)>0?(e=this.value.states.find(t=>t.value===!1))==null?void 0:e.text:null},selectedItem(){const l=this.value.type==="number"?Number(this.value.newValue):this.value.newValue;return this.value.states?this.value.states.find(e=>e.value===l):null},canIdleNotification(){var l;return!this.value||this.disable_send?!1:this.value.commandClassName==="Notification"&&((l=this.value.states)==null?void 0:l.find(e=>e.value===0))},canResetConfiguration(){return!this.value||this.disable_send?!1:this.value.writeable&&this.value.commandClass===112&&this.value.commandClassVersion>3},items(){return this.selectedItem?this.value.states:[{value:this.value.newValue,text:"Custom"},...this.value.states]},label(){return"["+this.value.id+"] "+this.value.label},help(){return`${this.value.description?`${this.value.description} `:""}${this.value.default!==void 0&&!this.value.list?`(Default: ${this.value.default}${this.value.max!==void 0?`, max: ${this.value.max}`:""}${this.value.min!==void 0?`, min: ${this.value.min}`:""})`:""}`},color:{get:function(){return"#"+(this.value.newValue||"ffffff").toUpperCase()},set:function(l){this.value.newValue=l?l.substr(1,7):null}},parsedValue:{get:function(){return typeof this.value.newValue=="object"?JSON.stringify(this.value.newValue):this.value.states&&this.value.newValue!==void 0?this.itemText(this.selectedItem||this.value.newValue):this.value===null?"(unknown)":this.value===void 0?"(missing)":this.value.newValue},set:function(l){try{this.value.type==="any"?this.value.newValue=JSON.parse(l):typeof l=="string"&&this.value.type==="number"&&(this.value.newValue=Number(l)),this.error=null}catch{this.error="Value not valid"}}},pickerStyle(){return this.value.type!=="color"?null:{backgroundColor:this.color,cursor:"pointer",border:"1px solid "+(this.$vuetify.theme.dark?"white":"black"),height:"30px",width:"30px",borderRadius:this.menu?"50%":"4px",transition:"border-radius 200ms ease-in-out"}}},methods:{async resetConfig(){(await s.getInstance(i.APP).apiRequest("sendCommand",[{nodeId:this.node.id,commandClass:112},"reset",[this.value.property]])).success&&r().showSnackbar("Configuration reset","success")},async idleNotification(){(await s.getInstance(i.APP).apiRequest("manuallyIdleNotificationValue",[this.value],{infoSnack:!1,errorSnack:!0})).success&&r().showSnackbar("Notification manually idled","success")},itemText(l){return typeof l=="object"?`[${l.value}] ${l.text}${this.value.default===l.value?" (Default)":""}`:l},updateValue(l,e){var t;this.$refs.myCombo&&this.$refs.myCombo.$refs.input._value!==null&&(this.value.newValue=this.$refs.myCombo.$refs.input._value),e!==void 0&&(l.newValue=e),l.type==="boolean"&&((t=l.states)==null?void 0:t.length)===1&&(e=l.states[0].value,l.newValue=e),this.$emit("updateValue",l,e)}}};var d=function(){var u;var e=this,t=e._self._c;return t("div",{staticClass:"valueid-slot"},[t("v-subheader",{staticClass:"valueid-label"},[e._v(e._s(e.label)+" ")]),e.canResetConfiguration?t("v-btn",{attrs:{"x-small":"",color:"error"},on:{click:e.resetConfig}},[e._v("Reset")]):e._e(),e.value.writeable?t("div",{staticClass:"d-flex align-center"},[!e.value.list&&(e.value.type==="string"||e.value.type==="buffer")?t("v-text-field",{attrs:{"append-outer-icon":e.disable_send?null:"send",suffix:e.value.unit,"persistent-hint":"",hint:e.help},on:{"click:append-outer":function(a){return e.updateValue(e.value)}},model:{value:e.value.newValue,callback:function(a){e.$set(e.value,"newValue",a)},expression:"value.newValue"}}):!e.value.list&&e.value.type==="number"?t("v-text-field",{attrs:{type:"number","append-outer-icon":e.disable_send?null:"send",suffix:e.value.unit,min:e.value.min!=e.value.max?e.value.min:null,step:e.value.step||1,"persistent-hint":"",max:e.value.min!=e.value.max?e.value.max:null,hint:e.help},on:{"click:append-outer":function(a){return e.updateValue(e.value)}},model:{value:e.value.newValue,callback:function(a){e.$set(e.value,"newValue",e._n(a))},expression:"value.newValue"}}):!e.value.list&&e.value.type==="any"?t("v-text-field",{attrs:{"append-outer-icon":e.disable_send?null:"send",suffix:e.value.unit,"persistent-hint":"",error:!!e.error,"error-messages":e.error,hint:e.help},on:{"click:append-outer":function(a){return e.updateValue(e.value)}},model:{value:e.parsedValue,callback:function(a){e.parsedValue=a},expression:"parsedValue"}}):e.value.type==="duration"?t("div",{staticStyle:{display:"flex"}},[t("v-text-field",{attrs:{type:e.value.type==="number"?"number":"text",min:e.value.min!=e.value.max?e.value.min:null,step:e.value.step||1,"persistent-hint":"",readonly:e.disable_send,max:e.value.min!=e.value.max?e.value.max:null,hint:e.help},model:{value:e.value.newValue.value,callback:function(a){e.$set(e.value.newValue,"value",e._n(a))},expression:"value.newValue.value"}}),t("v-select",{staticStyle:{"margin-left":"10px","min-width":"105px",width:"135px"},attrs:{items:e.durations,readonly:e.disable_send,"persistent-hint":"","append-outer-icon":e.disable_send?null:"send"},on:{"click:append-outer":function(a){return e.updateValue(e.value)}},model:{value:e.value.newValue.unit,callback:function(a){e.$set(e.value.newValue,"unit",a)},expression:"value.newValue.unit"}})],1):e.value.type==="color"?t("v-text-field",{staticStyle:{"max-width":"250px","margin-top":"10px"},attrs:{flat:"",solo:"","persistent-hint":"","append-outer-icon":e.disable_send?null:"send",hint:e.help},on:{"click:append-outer":function(a){return e.updateValue(e.value)}},scopedSlots:e._u([{key:"append",fn:function(){return[t("v-menu",{attrs:{top:"","nudge-bottom":"105","nudge-left":"16","close-on-content-click":!1},scopedSlots:e._u([{key:"activator",fn:function({on:a}){return[t("div",e._g({style:e.pickerStyle},a))]}}]),model:{value:e.menu,callback:function(a){e.menu=a},expression:"menu"}},[t("v-card",[t("v-card-text",{staticClass:"pa-0"},[e.menu?t("v-color-picker",{attrs:{"hide-mode-switch":"",flat:""},model:{value:e.color,callback:function(a){e.color=a},expression:"color"}}):e._e()],1)],1)],1)]},proxy:!0}]),model:{value:e.color,callback:function(a){e.color=a},expression:"color"}}):e.value.list&&!e.value.allowManualEntry&&e.value.type!=="boolean"?t("v-select",{style:{"max-width":e.$vuetify.breakpoint.smAndDown?"280px":e.$vuetify.breakpoint.smOnly?"400px":"auto"},attrs:{items:e.items,hint:e.help,"persistent-hint":"","return-object":!1,"item-text":e.itemText,"item-value":"value",suffix:e.value.unit,"append-outer-icon":e.disable_send?null:"send"},on:{"click:append-outer":function(a){return e.updateValue(e.value)}},scopedSlots:e._u([{key:"selection",fn:function({item:a}){return[t("span",[e._v(" "+e._s(e.itemText(e.selectedItem||a))+" ")])]}}]),model:{value:e.value.newValue,callback:function(a){e.$set(e.value,"newValue",a)},expression:"value.newValue"}}):e.value.list&&e.value.allowManualEntry&&e.value.type!=="boolean"?t("v-combobox",{ref:"myCombo",style:{"max-width":e.$vuetify.breakpoint.smAndDown?"280px":e.$vuetify.breakpoint.smOnly?"400px":"auto"},attrs:{items:e.items,hint:e.help,"persistent-hint":"",chips:"",suffix:e.value.unit,"item-text":e.itemText,"item-value":"value",type:e.value.type==="number"?"number":"text","return-object":!1,"append-outer-icon":e.disable_send?null:"send"},on:{"click:append-outer":function(a){return e.updateValue(e.value)}},scopedSlots:e._u([{key:"selection",fn:function({attrs:a,item:n,selected:o}){return[t("v-chip",e._b({attrs:{"input-value":o}},"v-chip",a,!1),[t("span",[e._v(" "+e._s(e.itemText(e.selectedItem||n))+" ")])])]}}]),model:{value:e.value.newValue,callback:function(a){e.$set(e.value,"newValue",a)},expression:"value.newValue"}}):e.value.type==="boolean"&&(e.value.writeable&&e.value.readable||e.value.states&&e.value.states.length===2)?t("div",[t("v-btn-toggle",{staticClass:"my-2",attrs:{rounded:""},model:{value:e.value.newValue,callback:function(a){e.$set(e.value,"newValue",a)},expression:"value.newValue"}},[t("v-btn",{style:{background:e.value.newValue===!0&&!e.value.list?"#4CAF50":""},attrs:{outlined:"",height:"40px",value:!0,color:e.value.newValue===!0&&!e.value.list?"white":"green",dark:""},on:{click:function(a){return e.updateValue(e.value,!0)}}},[e.trueLabel?t("span",[e._v(e._s(e.trueLabel))]):t("v-icon",{staticStyle:{rotate:"90deg"},attrs:{color:e.value.newValue===!0&&!e.value.list?"white":"green"}},[e._v("horizontal_rule")])],1),t("v-btn",{style:{background:e.value.newValue===!1&&!e.value.list?"#f44336":""},attrs:{outlined:"",height:"40px",value:!1,color:e.value.newValue===!1&&!e.value.list?"white":"red",dark:""},on:{click:function(a){return e.updateValue(e.value,!1)}}},[e.falseLabel?t("span",[e._v(e._s(e.falseLabel))]):t("v-icon",{attrs:{color:e.value.newValue===!1&&!e.value.list?"white":"red"}},[e._v("radio_button_unchecked")])],1)],1),e.help?t("div",{staticClass:"caption mt-2 help"},[e._v(e._s(e.help))]):e._e()],1):e.value.type==="boolean"&&!e.value.readable?t("v-tooltip",{attrs:{right:""},scopedSlots:e._u([{key:"activator",fn:function({on:a}){return[t("v-btn",e._g({staticClass:"mb-2 mt-2",attrs:{"max-width":"100%",small:"",color:"primary",dark:""},on:{click:function(n){return e.updateValue(e.value)}}},a),[e._v(e._s(e.trueLabel||e.falseLabel||e.value.label))])]}}])},[t("span",{staticClass:"help"},[e._v(e._s("["+e.value.id+"] "+e.help))])]):e._e(),e.value.toUpdate?t("v-tooltip",{attrs:{bottom:""},scopedSlots:e._u([{key:"activator",fn:function({on:a}){var n;return[t("v-progress-circular",e._g({staticClass:"ml-2",attrs:{indeterminate:"",size:"20",color:((n=e.node)==null?void 0:n.status)==="Asleep"?"warning":"primary"}},a))]}}],null,!1,383696814)},[t("span",[e._v(e._s(((u=e.node)==null?void 0:u.status)==="Asleep"?"Wake up your device in order to send commands":"Set value in progress..."))])]):e._e()],1):t("div",[t("div",{staticClass:"readonly mt-5"},[e._v(" "+e._s(e.parsedValue+(e.value.unit?" "+e.value.unit:""))+" "),e.canIdleNotification?t("v-btn",{attrs:{small:"",color:"primary"},on:{click:e.idleNotification}},[e._v("Idle")]):e._e()],1),e.help?t("div",{staticClass:"caption mt-1 help"},[e._v(" "+e._s(e.help)+" ")]):e._e()])],1)},p=[],f=v(c,d,p,!1,null,"62bb7f66");const m=f.exports;export{m as default};