UNPKG

zwave-js-ui

Version:

Z-Wave Control Panel and MQTT Gateway

3 lines (2 loc) 3.18 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ZwaveGraph-C6j0QKIk.js","./index-CtTdmJsx.js","./index-2j-kvxFz.css","./ZwaveGraph-CV956Kpy.css","./NodePanel-CS4xmdnZ.js","./vuedraggable.umd-VX2Gn67H.js","./NodePanel-NlzD7HjS.css"])))=>i.map(i=>d[i]); import{I as u,_ as a,m as h,u as l,a as p,n as f}from"./index-CtTdmJsx.js";const m={name:"Mesh",mixins:[u],props:{socket:Object},components:{ZwaveGraph:()=>a(()=>import("./ZwaveGraph-C6j0QKIk.js"),__vite__mapDeps([0,1,2,3]),import.meta.url),NodePanel:()=>a(()=>import("./NodePanel-CS4xmdnZ.js"),__vite__mapDeps([4,1,2,5,6]),import.meta.url)},computed:{...h(l,["nodes"])},documentListeners:{},data(){return{selectedNode:null,showProperties:!1}},methods:{...p(l,["showSnackbar","setNeighbors"]),setInitialPosition(e){const t=window.innerHeight,o=window.innerWidth,i=e.offsetHeight,n=e.offsetWidth;let r=(t-i)/2-50,s=(o-n)/10;r<0&&(r=10),s<0&&(s=10),e.style.top=r+"px",e.style.left=s+"px"},makeDivDraggable(){const e=document.getElementById("properties");if(!e||e.hasAttribute("data-draggable"))return;e.setAttribute("data-draggable",!0),setTimeout(()=>{this.setInitialPosition(e)},100);let t=0,o=0;e.onmousedown=i;function i(s){s=s||window.event,!s.target.classList.contains("handle")&&(s.preventDefault(),!s.target.classList.contains("u-over")&&(t=s.clientX,o=s.clientY,document.onmouseup=r,document.onmousemove=n))}function n(s){s=s||window.event,s.preventDefault();const c=t-s.clientX,d=o-s.clientY;t=s.clientX,o=s.clientY,e.style.top=e.offsetTop-d+"px",e.style.left=e.offsetLeft-c+"px"}function r(){document.onmouseup=null,document.onmousemove=null}},async nodeClick(e){this.selectedNode=this.selectedNode===e?null:e,this.showProperties=!!this.selectedNode,this.$vuetify.breakpoint.mdAndUp&&this.showProperties&&(await this.$nextTick(),this.makeDivDraggable())},debounceRefresh(){this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=setTimeout(this.refresh.bind(this),500)},async refresh(){const e=await this.app.apiRequest("refreshNeighbors",[],{infoSnack:!1,errorSnack:!1});e.success&&(this.showSnackbar("Nodes Neighbors updated","success"),this.setNeighbors(e.result))}},mounted(){this.debounceRefresh()},beforeDestroy(){this.refreshTimeout&&clearTimeout(this.refreshTimeout)}};var w=function(){var t=this,o=t._self._c;return o("v-container",{staticClass:"fill",attrs:{fluid:""}},[o("zwave-graph",{ref:"mesh",attrs:{id:"mesh",nodes:t.nodes},on:{"node-click":t.nodeClick}}),t.$vuetify.breakpoint.mdAndUp?o("node-panel",{staticClass:"details",attrs:{node:t.selectedNode,socket:t.socket,id:"properties",draggable:""},model:{value:t.showProperties,callback:function(i){t.showProperties=i},expression:"showProperties"}}):o("v-bottom-sheet",{attrs:{scrollable:""},model:{value:t.showProperties,callback:function(i){t.showProperties=i},expression:"showProperties"}},[o("v-card",{staticClass:"text-center",attrs:{scrollable:""}},[o("v-card-text",[o("node-panel",{attrs:{node:t.selectedNode,socket:t.socket},model:{value:t.showProperties,callback:function(i){t.showProperties=i},expression:"showProperties"}})],1)],1)],1)],1)},v=[],_=f(m,w,v,!1,null,"d03e012d");const g=_.exports;export{g as default};