platypush/platypush/backend/http/webapp/dist/static/js/3398.4f840e02.js

2 lines
4.0 KiB
JavaScript

"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[3398,3459],{3459:function(e,t,l){l.r(t),l.d(t,{default:function(){return v}});var n=l(6252),a=l(3577),o=l(3540);const i={key:0,src:o,class:"loading"},s={key:1,class:"fas fa-circle-exclamation error"};function c(e,t,l,o,c,u){const r=(0,n.up)("Icon");return(0,n.wg)(),(0,n.iD)("div",{class:(0,a.C_)(["entity-icon-container",{"with-color-fill":!!u.colorFill}]),style:(0,a.j5)(u.colorFillStyle)},[l.loading?((0,n.wg)(),(0,n.iD)("img",i)):l.error?((0,n.wg)(),(0,n.iD)("i",s)):((0,n.wg)(),(0,n.j4)(r,(0,a.vs)((0,n.dG)({key:2},u.computedIconNormalized)),null,16))],6)}var u=l(1478),r={name:"EntityIcon",components:{Icon:u.Z},props:{loading:{type:Boolean,default:!1},error:{type:Boolean,default:!1},entity:{type:Object,required:!0},icon:{type:Object,default:()=>{}},hasColorFill:{type:Boolean,default:!1}},data(){return{component:null,modalVisible:!1}},computed:{computedIcon(){let e={...this.entity?.meta?.icon||{}};return Object.keys(this.icon||{}).length&&(e=this.icon),{...e}},colorFill(){return this.hasColorFill&&this.computedIcon.color},colorFillStyle(){return this.colorFill&&!this.error?{background:this.colorFill}:{}},computedIconNormalized(){const e={...this.computedIcon};return this.colorFill&&delete e.color,e},type(){let e=this.entity.type||"";return e.charAt(0).toUpperCase()+e.slice(1)}}},d=l(3744);const p=(0,d.Z)(r,[["render",c],["__scopeId","data-v-4fad24e6"]]);var v=p},3398:function(e,t,l){l.r(t),l.d(t,{default:function(){return C}});var n=l(6252),a=l(3577),o=l(9963);const i={class:"entity switch-container"},s={class:"col-1 icon"},c={class:"col-s-8 col-m-9 label"},u=["textContent"],r={class:"col-s-3 col-m-2 buttons pull-right"},d=["textContent"],p={class:"row"},v={class:"input"},h=["disabled"],y={key:0,value:"",selected:""},g=["value","selected","textContent"];function f(e,t,l,f,m,w){const k=(0,n.up)("EntityIcon");return(0,n.wg)(),(0,n.iD)("div",i,[(0,n._)("div",{class:(0,a.C_)(["head",{collapsed:e.collapsed}])},[(0,n._)("div",s,[(0,n.Wm)(k,{entity:e.value,loading:e.loading,error:e.error},null,8,["entity","loading","error"])]),(0,n._)("div",c,[(0,n._)("div",{class:"name",textContent:(0,a.zw)(e.value.name)},null,8,u)]),(0,n._)("div",r,[w.hasValues?((0,n.wg)(),(0,n.iD)("button",{key:0,onClick:t[0]||(t[0]=(0,o.iM)((t=>e.collapsed=!e.collapsed),["stop"]))},[(0,n._)("i",{class:(0,a.C_)(["fas",{"fa-angle-up":!e.collapsed,"fa-angle-down":e.collapsed}])},null,2)])):(0,n.kq)("",!0),null!=e.value?.value?((0,n.wg)(),(0,n.iD)("span",{key:1,class:"value",textContent:(0,a.zw)(e.value.values[e.value.value]||e.value.value)},null,8,d)):(0,n.kq)("",!0)])],2),e.collapsed?(0,n.kq)("",!0):((0,n.wg)(),(0,n.iD)("div",{key:0,class:"body",onClick:t[2]||(t[2]=(0,o.iM)(((...e)=>w.prevent&&w.prevent(...e)),["stop"]))},[(0,n._)("div",p,[(0,n._)("div",v,[(0,n._)("select",{onInput:t[1]||(t[1]=(...e)=>w.setValue&&w.setValue(...e)),ref:"values",disabled:e.loading},[e.value.is_write_only?((0,n.wg)(),(0,n.iD)("option",y,"--")):(0,n.kq)("",!0),((0,n.wg)(!0),(0,n.iD)(n.HY,null,(0,n.Ko)(w.displayValues,((t,l)=>((0,n.wg)(),(0,n.iD)("option",{value:l,selected:l==e.value.value,key:l,textContent:(0,a.zw)(t)},null,8,g)))),128))],40,h)])])]))])}var m=l(7909),w=l(3459),k={name:"EnumSwitch",components:{EntityIcon:w["default"]},mixins:[m["default"]],computed:{hasValues(){return!!Object.values(this?.value?.values||{}).length},displayValues(){return this.value?.values instanceof Array?this.value.values.reduce(((e,t)=>(e[t]=t,e)),{}):this.value?.values||{}}},methods:{prevent(e){return e.stopPropagation(),!1},async setValue(e){if(e.target.value?.length){if(this.$emit("loading",!0),this.value.is_write_only){const e=this;setTimeout((()=>{e.$refs.values.value=""}),1e3)}try{await this.request("entities.execute",{id:this.value.id,action:"set",value:e.target.value})}finally{this.$emit("loading",!1)}}}}},_=l(3744);const b=(0,_.Z)(k,[["render",f],["__scopeId","data-v-ba5c657c"]]);var C=b},3540:function(e,t,l){e.exports=l.p+"static/img/spinner.c0bee445.gif"}}]);
//# sourceMappingURL=3398.4f840e02.js.map