zwave-js-ui
Version:
Z-Wave Control Panel and MQTT Gateway
5 lines (4 loc) • 9.71 kB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-DGfrDeWf.js","./index-B9yS4Bcc.js","./index-Bm7DxUwf.css","./vuedraggable.umd-f8uV7t38.js","./colors-DoZdCu1D.js","./VDataTable-CKSj76XP.js","./sort-CSOGXH9I.js","./VTable-BXtGlLLl.js","./VTable-CQyv0wyO.css","./VDataTable-DNwLG7iF.css","./index-BzEBCnaN.css","./DialogAdvanced-B9I1E5QR.js","./DialogAdvanced-BEfdsoBJ.css","./StatisticsCard-yimBnRML.js","./SmartView--of_OBP4.js","./VFab-OEmwwbnb.js","./VFab-MHxCNJTw.css","./BaseFab-LOhS57gL.js","./BaseFab-BUyXt8fM.css"])))=>i.map(i=>d[i]);
import{_ as R,L as V,I as D,d as r,m as N,u,S as T,a as I,j as M,C as f,c as P,b as o,w as n,V as E,r as l,o as c,e as g,f as w,n as O,g as B,h as v,i as _,k as p,t as U,l as m,p as L,q as b,s as j,v as F,x as Z,y as W,z as d}from"./index-B9yS4Bcc.js";const y=V.get("ControlPanel"),z={name:"ControlPanel",props:{socket:Object},mixins:[D],components:{NodesTable:r(()=>d(()=>import("./index-DGfrDeWf.js").then(e=>e.i),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]),import.meta.url)),DialogAdvanced:r(()=>d(()=>import("./DialogAdvanced-B9I1E5QR.js"),__vite__mapDeps([11,1,2,12]),import.meta.url)),StatisticsCard:r(()=>d(()=>import("./StatisticsCard-yimBnRML.js"),__vite__mapDeps([13,1,2]),import.meta.url)),SmartView:r(()=>d(()=>import("./SmartView--of_OBP4.js"),__vite__mapDeps([14,1,2,4,6,15,16]),import.meta.url)),BaseFab:r(()=>d(()=>import("./BaseFab-LOhS57gL.js"),__vite__mapDeps([17,1,2,15,16,18]),import.meta.url))},computed:{...N(u,["nodes","zwave","controllerNode"]),fabItems(){const e=[];return this.selected.length===0&&e.push({icon:"all_inclusive",color:"success",tooltip:"Manage nodes",action:()=>this.showNodesManager()}),e.push({icon:"auto_fix_high",color:"purple",tooltip:"Advanced actions",action:()=>{this.advancedShowDialog=!0}}),e},timeoutMs(){return this.zwave.commandsTimeout*1e3+800},statisticsOpeningIndicator(){return this.showControllerStatistics?"arrow_drop_up":"arrow_drop_down"},compact(){return this.$vuetify.display.smAndDown||this.compactMode},compactMode:{get(){return u().ui.compactMode},set(e){u().setCompactMode(e)}},actions(){return this.selected.length===0?this.generalActions:this.selectedActions},advancedDialogTitle(){return this.selected.length===0?"General actions":`Actions for ${this.selected.length} selected node${this.selected.length>1?"s":""}`}},watch:{},data(){return{fab:!1,selected:[],settings:new T(localStorage),advancedShowDialog:!1,generalActions:[{text:"Backup",options:[{name:"Import",action:"import"},{name:"Export",action:"export"}],icon:"save",desc:"Save or load `nodes.json` file with names and locations"},{text:"Dump",options:[{name:"Export",action:"exportDump"}],icon:"bug_report",desc:"Export all nodes in a json file. Useful for debugging purposes"},{text:"Re-interview Nodes",options:[{name:"Start",action:"refreshInfo",args:{broadcast:!0}}],icon:"history",color:"warning",desc:"Clear all info about all nodes and make a new full interview. Use when nodes has wrong or missing capabilities"},{text:"Rebuild Routes",options:[{name:"Begin",action:"beginRebuildingRoutes"},{name:"Stop",action:"stopRebuildingRoutes"}],icon:"healing",color:"warning",desc:"Force nodes to establish new connections to the controller"},{text:"Hard Reset",options:[{name:"Factory Reset",action:"hardReset"}],icon:"warning",color:"error",desc:"Reset controller to factory defaults (all paired devices will be removed)"},{text:"Soft Reset",options:[{name:"Soft Reset",action:"softReset",args:{confirm:`<p>Are you sure you want to soft-reset your controller?</p>
<p>USB modules will reconnect, meaning that they might get a new address. Make sure to configure your device address in a way that prevents it from changing, e.g. by using <code>/dev/serial/by-id/...</code> on Linux.</p>
<p><strong>This method may cause problems in Docker containers with certain Z-Wave stick.</strong> If that happens, you may need to restart your host OS and docker container.</p>`}}],icon:"refresh",color:"warning",desc:"Instruct the controller to soft-reset (restart)"},{text:"Failed Nodes",options:[{name:"Remove all",action:"removeFailedNode",args:{broadcast:!0,confirm:"This action will remove all failed nodes. ATTENTION: this will skip sleeping nodes to prevent unwanted behaviours"}}],icon:"dangerous",color:"error",desc:"Manage nodes that are dead and/or marked as failed with the controller"},{text:"Driver function",options:[{name:"Write",action:"driverFunction"}],icon:"code",desc:"Write a custom JS function using the ZwaveJS Driver"},{text:"NVM Management",options:[{name:"Backup",action:"backupNVMRaw"},{name:"Restore",action:"restoreNVM"}],icon:"update",color:"warning",desc:"Backup/Restore controller's NVM (Non Volatile Memory)"},{text:"Firmware update OTW",options:[{name:"Update",action:"firmwareUpdateOTW"}],icon:"update",color:"error",desc:"Perform a firmware update OTW (Over The Wire)"},{text:"Shutdown Zwave API",options:[{name:"Shutdown",action:"shutdownZwaveAPI",args:{confirm:"Are you sure you want to shutdown the Zwave API? You will have to unplug and replug the Zwave stick manually to restart it.",confirmLevel:"warning"}}],icon:"power_off",color:"warning",desc:"Allows to shutdown the Zwave API to safely unplug the Zwave stick."}],rules:{required:e=>{let t=!1;return e instanceof Array?t=e.length>0:t=!isNaN(e)||!!e,t||"This field is required."}},selectedActions:[{text:"Re-interview Node",options:[{name:"Interview",action:"refreshInfo"}],icon:"history",desc:"Clear all info about this node and make a new full interview. Use when the node has wrong or missing capabilities"},{text:"Refresh Values",options:[{name:"Refresh",action:"refreshValues",args:{confirm:"Are you sure you want to refresh values of this node? This action increases network traffic"}}],icon:"cached",desc:"Update all CC values and metadata. Use only when many values seems stale"},{text:"Rebuild Node Routes",options:[{name:"Rebuild",action:"rebuildNodeRoutes",args:{confirm:"Rebuilding routes of a specific node. This action causes a lot of traffic, can take minutes up to hours and you can expect degraded performance while it is going on"}}],icon:"healing",color:"warning",desc:"Discover and assign new routes between a specific node to the controller and his neighbors"},{text:"Ping",options:[{name:"Ping",action:"pingNode"}],icon:"swap_horiz",desc:"Ping node to check if it is alive"}],showControllerStatistics:!1}},methods:{...I(u,["setRebuildRoutesProgress","showSnackbar"]),jsonToList:M,showNodesManager(){this.app.showNodesManager()},async onAction(e,t={}){e==="import"?this.importConfiguration():e==="export"?this.exportConfiguration():e==="exportDump"?this.exportDump():this.sendAction(e,{...t,nodes:this.selected})},async importConfiguration(){if(await this.app.confirm("Attention","This will override all existing nodes names and locations","alert"))try{const{data:e}=await this.app.importFile("json"),t=await f.importConfig({data:e});this.showSnackbar(t.message,t.success?"success":"error")}catch(e){y.error(e)}},async exportConfiguration(){try{const e=await f.exportConfig();this.showSnackbar(e.message,e.success?"success":"error"),e.success&&this.app.exportConfiguration(e.data,"nodes","json")}catch(e){y.error(e)}},exportDump(){this.app.exportConfiguration(this.nodes,"nodes_dump","json")},toggleControllerStatistics(){this.showControllerStatistics=!this.showControllerStatistics}},mounted(){this.bindEvent("rebuildRoutesProgress",this.setRebuildRoutesProgress.bind(this))},beforeUnmount(){this.socket&&this.unbindEvents()}};function q(e,t,h,G,i,s){const C=l("StatisticsCard"),S=l("nodes-table"),A=l("smart-view"),x=l("DialogAdvanced"),k=l("base-fab");return c(),P("div",null,[o(E,{fluid:"",class:"pa-4"},{default:n(()=>[o(g,{class:"py-4 align-center","no-gutters":""},{default:n(()=>[o(w,{class:O(s.compact?"text-center":"text-end")},{default:n(()=>[o(B,{multiple:""},{default:n(()=>[o(v,{active:i.showControllerStatistics,color:"primary",variant:"outlined",onClick:s.toggleControllerStatistics},{default:n(()=>[o(_,{start:""},{default:n(()=>[p(U(s.statisticsOpeningIndicator),1)]),_:1}),t[7]||(t[7]=p(" Controller statistics ")),o(_,{color:"primary",end:""},{default:n(()=>t[6]||(t[6]=[p(" multiline_chart ")])),_:1,__:[6]})]),_:1,__:[7]},8,["active","onClick"]),e.$vuetify.display.mdAndUp?(c(),m(v,{key:0,color:"primary",variant:"flat",active:s.compactMode,onClick:t[0]||(t[0]=L(a=>s.compactMode=!s.compactMode,["stop"]))},{default:n(()=>t[8]||(t[8]=[p(" Compact ")])),_:1,__:[8]},8,["active"])):b("",!0)]),_:1})]),_:1},8,["class"])]),_:1}),o(j,null,{default:n(()=>[F(o(g,null,{default:n(()=>[o(w,{class:"mb-8"},{default:n(()=>[o(W,{border:"",rounded:""},{default:n(()=>[e.controllerNode?(c(),m(C,{key:0,title:"Controller Statistics",node:this.controllerNode},null,8,["node"])):b("",!0)]),_:1})]),_:1})]),_:1},512),[[Z,i.showControllerStatistics]])]),_:1}),s.compact?(c(),m(A,{key:1,socket:h.socket,onSelected:t[2]||(t[2]=a=>i.selected=a),onAction:e.sendAction},null,8,["socket","onAction"])):(c(),m(S,{key:0,class:"pb-8",socket:h.socket,onAction:e.sendAction,onSelected:t[1]||(t[1]=a=>i.selected=a)},null,8,["socket","onAction"]))]),_:1}),o(x,{modelValue:i.advancedShowDialog,"onUpdate:modelValue":t[3]||(t[3]=a=>i.advancedShowDialog=a),onClose:t[4]||(t[4]=a=>i.advancedShowDialog=!1),actions:s.actions,onAction:s.onAction,title:s.advancedDialogTitle},null,8,["modelValue","actions","onAction","title"]),o(k,{modelValue:i.fab,"onUpdate:modelValue":t[5]||(t[5]=a=>i.fab=a),location:"bottom end",color:i.selected.length===0?"primary":"success","icon-open":"menu","icon-close":"close",items:s.fabItems},null,8,["modelValue","color","items"])])}const H=R(z,[["render",q]]);export{H as default};