UNPKG

zwave-js-ui

Version:

Z-Wave Control Panel and MQTT Gateway

3 lines (2 loc) 17.6 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./StatisticsArrows-CqPYeYu2.js","./index-DwzE-W2i.js","./index-B2zoqM3Y.css","./StatisticsArrows-Bzojvm2s.css","./BgRssiChart-CAx0Q6so.js","./BgRssiChart-D1GxaB_c.css","./DialogHealthCheck-H6rYDNQ9.js","./VDataTable-D8DZXD9Y.js","./sort-C8HQTCiq.js","./VTable-Cxuwit5L.js","./VTable-BsI6FsWH.css","./VDataTable-CLcLRj9B.css","./DialogLinkReliability-DZGcvrNn.js","./VNumberInput-CPMgIbm4.js","./VNumberInput-C8IBMqyK.css","./DialogLinkReliability-BQ_HIZzk.css"])))=>i.map(i=>d[i]); import{_ as F,bZ as L,aw as T,a as E,bT as N,az as D,d as V,I as B,s as S,q as O,v as j,e as f,z as a,w as s,h as p,b as n,f as w,N as x,k as i,l as R,ac as q,c as v,R as h,H as u,t as c,i as m,P as A,an as W,V as U,a7 as H,ag as Z,F as K,G as M,u as G,X as _,au as Y,bW as X,bV as J,bY as Q,x as $,y as P}from"./index-DwzE-W2i.js";import{d as ee}from"./vuedraggable.umd-Df3l8PgK.js";const te={mixins:[B],components:{StatisticsArrows:V(()=>P(()=>import("./StatisticsArrows-CqPYeYu2.js"),__vite__mapDeps([0,1,2,3]),import.meta.url)),BgRssiChart:V(()=>P(()=>import("./BgRssiChart-CAx0Q6so.js"),__vite__mapDeps([4,1,2,5]),import.meta.url)),DialogHealthCheck:V(()=>P(()=>import("./DialogHealthCheck-H6rYDNQ9.js"),__vite__mapDeps([6,1,2,7,8,9,10,11]),import.meta.url)),DialogLinkReliability:V(()=>P(()=>import("./DialogLinkReliability-DZGcvrNn.js"),__vite__mapDeps([12,1,2,13,14,9,10,15]),import.meta.url)),draggable:ee},props:{modelValue:{type:Boolean,default:!1},node:{type:Object,default:()=>null},socket:{type:Object}},data:()=>({showFullscreen:!1,dialogHealth:!1,dialogLinkReliability:!1,discoverLoading:!1,routesChanged:!1,returnRoutes:[],Protocols:D,dataRateItems:[{title:"100 Kbps",value:N.ZWave_100k},{title:"40 Kbps",value:N.ZWave_40k},{title:"9.6 Kbps",value:N.ZWave_9k6}],required:t=>!!t||"This field is required"}),computed:{...E($,["nodes"]),nodeReturnRoutes(){if(!this.node)return null;const t=[...this.node.customSUCReturnRoutes||[]];return this.node.prioritySUCReturnRoute&&t.unshift({...this.node.prioritySUCReturnRoute,isPriority:!0}),t},_value:{get(){return this.modelValue},set(t){this.$emit("update:modelValue",t)}},lwr(){if(!this.node)return null;const t=this.node.statistics;return!t||!t.lwr?null:this.parseRouteStats(t.lwr)},nlwr(){if(!this.node)return null;const t=this.node.statistics;return!t||!t.nlwr?null:this.parseRouteStats(t.nlwr)},appRoute(){return this.node?.applicationRoute?this.parseRouteStats(this.node.applicationRoute):null},isLongRange(){return this.node?this.node.protocol===D.ZWaveLongRange:!1}},watch:{nodeReturnRoutes:{handler(t){this.returnRoutes=_(t),this.routesChanged=!1},immediate:!0,deep:!0},async _value(t){t&&this.node&&await this.refreshNodeNeighbors()}},methods:{getProtocol:T,zwaveDataRateToString:L,async refreshNodeNeighbors(){if(this.node)try{await this.app.apiRequest("getNodeNeighbors",[this.node.id])}catch{}},checkMove(t){const{futureIndex:e}=t.draggedContext;return!(this.returnRoutes.some(d=>d.isPriority)&&e===0)},parseRouteStats(t){const e=t.repeaterRSSI||[],o=t.repeaters?.length>0?t.repeaters.map((y,b)=>`${y}${e[b]&&!J(e[b])?` (${X(e[b])})`:""}`).join(", "):"None, direct connection",d=t.routeFailedBetween?.filter(y=>!!y[0]&&!!y[1])||[],g=d.length>0?d.map(y=>`${y[0]} --> ${y[1]}`).join(", "):"",l=t.protocolDataRate?Q(t.protocolDataRate):"",k=t.routeSpeed?L(t.routeSpeed):"";return[l?{title:"Data Rate",text:l}:null,k?{title:"Route Speed",text:k}:null,{title:"Repeaters",text:o},g?{title:"Route failed between",text:g}:null].filter(y=>!!y)},newWindow(){const t=window.open("#"+Y.controllerChart+"/#no-topbar","BG-RSSI-Chart","height=800,width=1200,status=no,toolbar:no,scrollbars:no,menubar:no");window.focus&&t.focus()},async deleteRoute(t){if(!this.node)return;let e="";switch(t){case"appRoute":e="removePriorityRoute";break;case"prioritySUCReturnRoute":case"customSUCReturnRoutes":e="deleteSUCReturnRoutes";break;default:e="";break}if(e&&await this.app.confirm("Delete","Are you sure you want to delete this route?","alert")){const o=await this.app.apiRequest(e,[this.node.id]);o.success&&(o.result?this.showSnackbar("Route deleted","success"):this.showSnackbar(`Failed delete route for node "${this.node._name}"`,"error"))}},async discoverNeighbors(){this.discoverLoading=!0;const t=await this.app.apiRequest("discoverNodeNeighbors",[this.node.id]);this.discoverLoading=!1,t.success&&(t.result?this.showSnackbar("Neighbors updated","success"):this.showSnackbar(`Failed to discover neighbors of node "${this.node._name}"`,"error"))},async getRoute(t){if(!this.node)return;let e="";switch(t){case"appRoute":e="getPriorityRoute";break;case"prioritySUCReturnRoute":e="getPrioritySUCReturnRoute";break;case"customSUCReturnRoutes":e="getCustomSUCReturnRoute";break;default:e="";break}if(!e)return;(await this.app.apiRequest(e,[this.node.id])).success&&this.showSnackbar("Route updated","success")},async promptRoute(t,e,o=!1){const d=[{type:"array",inputType:"autocomplete",list:!0,multiple:!0,prefix:t,suffix:e,key:"repeaters",label:"Repeaters",hint:"Select the nodes that should be used as repeaters starting from the closest to the controller. Empty list means direct route to controller",itemValue:"id",itemText:"_name",default:[],rules:[l=>l.length<=4||"Max 4 repeaters"],items:this.nodes.filter(l=>!l.isControllerNode&&l.isListening&&l.id!==this.node.id)},{type:"list",autocomplete:!0,key:"routeSpeed",label:"Route speed",default:N.ZWave_100k,rules:[this.required],items:this.dataRateItems}];o&&d.push({type:"boolean",key:"isPriority",label:"Priority route",hint:"If enabled, this route will always be used first",default:!1});const g=await this.app.confirm("Set route","","info",{width:500,inputs:d,confirmText:"Set"});return Object.keys(g).length===0?null:g},async getRouteReturnRoutes(){await this.getRoute("prioritySUCReturnRoute"),await this.getRoute("customSUCReturnRoutes")},deleteReturnRoute(t){this.returnRoutes.splice(this.returnRoutes.indexOf(t),1),this.routesChanged=!0},async addReturnRoute(){if(!this.node)return;const t=await this.promptRoute(`Node "${this.node._name}"`,"Controller",!0);if(!t)return;this.routesChanged=!0;const{repeaters:e,routeSpeed:o,isPriority:d}=t;if(d){const g=this.returnRoutes.find(k=>k.isPriority),l={repeaters:e,routeSpeed:o,isPriority:d};if(g){if(!await this.app.confirm("Priority route","You already have a priority route set. Do you want to replace it?","info"))return;this.returnRoutes.splice(this.returnRoutes.indexOf(g),1,l)}else l.isPriority?this.returnRoutes.unshift(l):this.returnRoutes.push(l);return}this.returnRoutes.push({repeaters:e,routeSpeed:o,isPriority:d})},resetReturnRoutes(){this.returnRoutes=_(this.nodeReturnRoutes),this.routesChanged=!1},async setReturnRoutes(){if(!this.node)return;if(this.returnRoutes.length===0){await this.deleteRoute("customSUCReturnRoutes");return}const t=this.returnRoutes.filter(d=>!d.isPriority),e=this.returnRoutes.find(d=>d.isPriority),o=[this.node.id,t.map(d=>({repeaters:d.repeaters,routeSpeed:d.routeSpeed}))];e&&o.push({repeaters:e.repeaters,routeSpeed:e.routeSpeed}),await this.setRoute("customSUCReturnRoutes",o)},async setRoute(t,e){if(!this.node)return;let o="",d="",g="";switch(t){case"appRoute":d="Controller",g=`Node "${this.node._name}"`,o="setPriorityRoute";break;case"prioritySUCReturnRoute":d=`Node "${this.node._name}"`,g="Controller",o="assignPrioritySUCReturnRoute";break;case"customSUCReturnRoutes":d=`Node "${this.node._name}"`,g="Controller",o="assignCustomSUCReturnRoutes";break;default:o="";break}if(!o)return;if(!e){const k=await this.promptRoute(d,g);if(!k)return;const{repeaters:y,routeSpeed:b}=k;switch(e=[],t){case"appRoute":case"prioritySUCReturnRoute":e=[this.node.id,y,b];break;case"customSUCReturnRoutes":{const z=this.node.customSUCReturnRoutes||[];e=[this.node.id,z]}break}}const l=await this.app.apiRequest(o,e);l.success&&(l.result?this.showSnackbar(`New route set for node "${this.node._name}"`,"success"):this.showSnackbar(`Failed to set route for node "${this.node._name}"`))}}},se={class:"align-end"},oe={class:"align-end"},ne={class:"align-end"},le={class:"align-end"},re={class:"align-end"},ie={class:"align-end"},ae={class:"align-end"},ue={class:"align-end"},de={class:"align-end"},fe={key:3},Re={key:0,class:"text-caption"},pe={class:"align-end"},me={key:1,class:"text-center"},ge={key:4},ye={key:0},ce={class:"fill-width"},he={key:1};function ke(t,e,o,d,g,l){const k=S("statistics-arrows"),y=S("draggable"),b=S("bg-rssi-chart"),z=S("dialog-health-check"),I=S("dialog-link-reliability");return O((a(),f(G,{class:"pt-0"},{default:s(()=>[l._value&&o.node?(a(),f(w,{key:0,class:"pa-0 pb-2"},{default:s(()=>[n(x,{class:"font-weight-bold",style:{position:"sticky",top:"0","z-index":"10"}},{default:s(()=>[e[25]||(e[25]=i("Node properties ",-1)),n(R,{onClick:e[0]||(e[0]=r=>l._value=!1),class:"close-btn"},{default:s(()=>[...e[24]||(e[24]=[i("clear",-1)])]),_:1})]),_:1}),n(q,{density:"compact",class:"text-start",style:{"min-width":"300px",background:"transparent"}},{default:s(()=>[n(h,{title:"ID",density:"compact"},{append:s(()=>[u("span",se,c(o.node.id),1)]),_:1}),n(h,{title:"Status",density:"compact"},{append:s(()=>[u("span",oe,c(o.node.status),1)]),_:1}),n(h,{title:"Protocol",density:"compact"},{append:s(()=>[u("span",ne,c(l.getProtocol(o.node)),1)]),_:1}),n(h,{title:"Code",density:"compact"},{append:s(()=>[u("span",le,c(o.node.productLabel),1)]),_:1}),n(h,{title:"Product",density:"compact"},{append:s(()=>[u("span",re,c(o.node.productDescription),1)]),_:1}),n(h,{title:"Manufacturer",density:"compact"},{append:s(()=>[u("span",ie,c(o.node.manufacturer),1)]),_:1}),o.node.name?(a(),f(h,{key:0,title:"Name"},{append:s(()=>[u("span",ae,c(o.node.name),1)]),_:1})):p("",!0),o.node.loc?(a(),f(h,{key:1,title:"Location"},{append:s(()=>[u("span",ue,c(o.node.loc),1)]),_:1})):p("",!0),o.node.neighbors&&!l.isLongRange?(a(),f(h,{key:2,title:"Neighbors"},{append:s(()=>[u("span",de,c(o.node.neighbors.length>0?o.node.neighbors.join(", "):"None"),1),o.node.isControllerNode?p("",!0):(a(),f(m,{key:0,class:"ml-2",variant:"flat",color:"primary",size:"x-small",loading:t.discoverLoading,onClick:e[1]||(e[1]=r=>l.discoverNeighbors())},{default:s(()=>[e[27]||(e[27]=i(" Discover ",-1)),n(R,{class:"ml-1",size:"small"},{default:s(()=>[...e[26]||(e[26]=[i("search",-1)])]),_:1})]),_:1},8,["loading"]))]),_:1})):p("",!0),n(h,{title:"Statistics",density:"compact"},{append:s(()=>[n(k,{"inactive-color":"black",node:o.node},null,8,["node"])]),_:1}),!o.node.isControllerNode&&!l.isLongRange?(a(),v("div",fe,[n(x,null,{default:s(()=>[e[34]||(e[34]=i("Priority route ",-1)),l.appRoute?(a(),f(m,{key:0,variant:"flat",class:"ml-2",color:"error",size:"x-small",onClick:e[2]||(e[2]=r=>l.deleteRoute("appRoute"))},{default:s(()=>[e[29]||(e[29]=i("Delete ",-1)),n(R,{size:"x-small"},{default:s(()=>[...e[28]||(e[28]=[i("delete",-1)])]),_:1})]),_:1})):p("",!0),n(m,{variant:"flat",class:"ml-2",color:"success",size:"x-small",onClick:e[3]||(e[3]=r=>l.getRoute("appRoute"))},{default:s(()=>[e[31]||(e[31]=i("Get ",-1)),n(R,{size:"x-small"},{default:s(()=>[...e[30]||(e[30]=[i("refresh",-1)])]),_:1})]),_:1}),n(m,{variant:"flat",class:"ml-2",color:"purple",size:"x-small",onClick:e[4]||(e[4]=r=>l.setRoute("appRoute"))},{default:s(()=>[e[33]||(e[33]=i("Set ",-1)),n(R,{size:"x-small"},{default:s(()=>[...e[32]||(e[32]=[i("route",-1)])]),_:1})]),_:1})]),_:1}),l.appRoute&&!l.isLongRange?(a(),v("div",Re,[(a(!0),v(A,null,W(l.appRoute,(r,C)=>(a(),f(h,{density:"compact",key:C},{append:s(()=>[u("span",pe,c(r.text),1)]),default:s(()=>[i(c(r.title)+" ",1)]),_:2},1024))),128))])):(a(),v("p",me,"None"))])):p("",!0),!o.node.isControllerNode&&!l.isLongRange?(a(),v("div",ge,[n(x,null,{default:s(()=>[e[43]||(e[43]=i("Return routes ",-1)),t.routesChanged?p("",!0):(a(),f(m,{key:0,variant:"flat",class:"ml-2",color:"success",size:"x-small",onClick:e[5]||(e[5]=r=>l.getRouteReturnRoutes())},{default:s(()=>[e[36]||(e[36]=i("Get ",-1)),n(R,{size:"x-small"},{default:s(()=>[...e[35]||(e[35]=[i("refresh",-1)])]),_:1})]),_:1})),n(m,{disabled:t.returnRoutes.length===4,variant:"flat",class:"ml-2",color:"purple",size:"x-small",onClick:e[6]||(e[6]=r=>l.addReturnRoute())},{default:s(()=>[e[38]||(e[38]=i("Add ",-1)),n(R,{size:"x-small"},{default:s(()=>[...e[37]||(e[37]=[i("route",-1)])]),_:1})]),_:1},8,["disabled"]),t.routesChanged?(a(),f(m,{key:1,variant:"flat",class:"ml-2",color:"success",size:"x-small",onClick:e[7]||(e[7]=r=>l.setReturnRoutes())},{default:s(()=>[e[40]||(e[40]=i("Save ",-1)),n(R,{size:"x-small"},{default:s(()=>[...e[39]||(e[39]=[i("save",-1)])]),_:1})]),_:1})):p("",!0),t.routesChanged?(a(),f(m,{key:2,variant:"flat",class:"ml-2",color:"error",size:"x-small",onClick:e[8]||(e[8]=r=>l.resetReturnRoutes())},{default:s(()=>[e[42]||(e[42]=i("Reset ",-1)),n(R,{size:"x-small"},{default:s(()=>[...e[41]||(e[41]=[i("clear",-1)])]),_:1})]),_:1})):p("",!0)]),_:1}),u("div",null,[t.returnRoutes.length>0?(a(),v("div",ye,[u("table",ce,[e[48]||(e[48]=u("thead",{class:"text-caption text-center font-weight-bold"},[u("tr",null,[u("th"),u("th",null,"Repeaters"),u("th",null,"Speed"),u("th",null,"Priority"),u("th")])],-1)),n(y,{modelValue:t.returnRoutes,"onUpdate:modelValue":e[9]||(e[9]=r=>t.returnRoutes=r),onChange:e[10]||(e[10]=r=>t.routesChanged=!0),handle:".handle",move:l.checkMove,tag:"tbody","item-key":(r,C)=>`returnRoute_${C}`},{item:s(({element:r,index:C})=>[(a(),v("tr",{key:`returnRoute_${C}`,dense:"",class:"text-caption text-center"},[u("td",null,[r.isPriority?p("",!0):(a(),f(R,{key:0,class:"handle",style:{cursor:"move"},color:"primary-lighten-2"},{default:s(()=>[...e[44]||(e[44]=[i("drag_indicator",-1)])]),_:1}))]),u("td",null,c(r.repeaters.length>0?r.repeaters.join(", "):"Direct connection"),1),u("td",null,c(l.zwaveDataRateToString(r.routeSpeed)),1),u("td",null,[r.isPriority?(a(),f(R,{key:0,color:"success",size:"small"},{default:s(()=>[...e[45]||(e[45]=[i("check",-1)])]),_:1})):p("",!0)]),u("td",null,[n(R,{color:"error",size:"small",onClick:be=>l.deleteReturnRoute(r)},{default:s(()=>[...e[46]||(e[46]=[i("delete",-1)])]),_:1},8,["onClick"])]),e[47]||(e[47]=u("td",null,null,-1))]))]),_:1},8,["modelValue","move","item-key"])])])):(a(),v("div",he,[...e[49]||(e[49]=[u("p",{class:"text-center"},"None",-1)])]))])])):p("",!0)]),_:1}),o.node.isControllerNode?(a(),f(U,{key:1,class:"mt-1",justify:"center"},{default:s(()=>[n(w,{cols:12,align:"center",class:"pa-0"},{default:s(()=>[n(m,{variant:"flat",color:"primary",size:"small",rounded:"",onClick:e[15]||(e[15]=r=>t.showFullscreen=!0)},{default:s(()=>[e[59]||(e[59]=i("Full Screen ",-1)),n(R,{size:"small"},{default:s(()=>[...e[58]||(e[58]=[i("fullscreen",-1)])]),_:1})]),_:1}),n(m,{variant:"flat",size:"small",class:"ml-2",color:"warning",rounded:"",onClick:e[16]||(e[16]=r=>l.newWindow())},{default:s(()=>[e[61]||(e[61]=i("Open ",-1)),n(R,{size:"small"},{default:s(()=>[...e[60]||(e[60]=[i("open_in_new",-1)])]),_:1})]),_:1})]),_:1}),n(w,{cols:12,class:"pa-2"},{default:s(()=>[n(b,{class:"mt-2",node:o.node},null,8,["node"])]),_:1})]),_:1})):(a(),f(U,{key:0,class:"mt-1 pa-0 text-center",justify:"center"},{default:s(()=>[n(w,{class:"pa-1"},{default:s(()=>[n(m,{variant:"flat",color:"primary",class:"fill",size:"small",rounded:"",onClick:e[11]||(e[11]=r=>t.dialogHealth=!0)},{default:s(()=>[e[51]||(e[51]=i("Diagnose ",-1)),n(R,null,{default:s(()=>[...e[50]||(e[50]=[i("monitor_heart",-1)])]),_:1})]),_:1})]),_:1}),n(w,{class:"pa-1"},{default:s(()=>[n(m,{variant:"flat",color:"purple",class:"fill",size:"small",rounded:"",onClick:e[12]||(e[12]=r=>t.dialogLinkReliability=!0)},{default:s(()=>[e[53]||(e[53]=i("Link Statistics ",-1)),n(R,null,{default:s(()=>[...e[52]||(e[52]=[i("leak_add",-1)])]),_:1})]),_:1})]),_:1}),l.isLongRange?p("",!0):(a(),f(w,{key:0,class:"pa-1"},{default:s(()=>[n(m,{variant:"flat",color:"error",class:"fill",size:"small",rounded:"",onClick:e[13]||(e[13]=r=>t.rebuildNodeRoutes(o.node))},{default:s(()=>[e[55]||(e[55]=i("Rebuild Routes ",-1)),n(R,null,{default:s(()=>[...e[54]||(e[54]=[i("heart_broken",-1)])]),_:1})]),_:1})]),_:1})),n(w,{class:"pa-1"},{default:s(()=>[n(m,{variant:"flat",color:"success",class:"fill",size:"small",rounded:"",onClick:e[14]||(e[14]=r=>t.pingNode(o.node))},{default:s(()=>[e[57]||(e[57]=i("Ping ",-1)),n(R,null,{default:s(()=>[...e[56]||(e[56]=[i("settings_ethernet",-1)])]),_:1})]),_:1})]),_:1})]),_:1}))]),_:1})):p("",!0),o.node&&!o.node.isControllerNode?(a(),f(z,{key:1,modelValue:t.dialogHealth,"onUpdate:modelValue":e[17]||(e[17]=r=>t.dialogHealth=r),onClose:e[18]||(e[18]=r=>t.dialogHealth=!1),socket:o.socket,node:o.node},null,8,["modelValue","socket","node"])):p("",!0),o.node&&!o.node.isControllerNode?(a(),f(I,{key:2,modelValue:t.dialogLinkReliability,"onUpdate:modelValue":e[19]||(e[19]=r=>t.dialogLinkReliability=r),onClose:e[20]||(e[20]=r=>t.dialogLinkReliability=!1),socket:o.socket,node:o.node},null,8,["modelValue","socket","node"])):p("",!0),n(H,{fullscreen:"",onKeydown:e[22]||(e[22]=Z(r=>t.showFullscreen=!1,["esc"])),"z-index":"9999",modelValue:t.showFullscreen,"onUpdate:modelValue":e[23]||(e[23]=r=>t.showFullscreen=r)},{default:s(()=>[o.node&&o.node.isControllerNode?(a(),f(K,{key:0},{default:s(()=>[n(M,{class:"pt-4 fill"},{default:s(()=>[n(m,{variant:"flat",style:{position:"absolute",top:"10px",right:"10px"},icon:"close",onClick:e[21]||(e[21]=r=>t.showFullscreen=!1)}),n(b,{class:"mt-3",node:o.node,"fill-size":""},null,8,["node"])]),_:1})]),_:1})):p("",!0)]),_:1},8,["modelValue"])]),_:1},512)),[[j,l._value]])}const Ce=F(te,[["render",ke],["__scopeId","data-v-ab0ee7af"]]);export{Ce as default};