platypush/platypush/backend/http/webapp/dist/static/js/app.b00986ef.js

2 lines
48 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function(){var e={5250:function(e,t,s){"use strict";s.d(t,{$:function(){return i}});var n=s(9652);const i=(0,n.Z)()},9646:function(e,t,s){"use strict";var n=s(9963),i=s(6252);function a(e,t,s,n,a,o){const r=(0,i.up)("Events"),l=(0,i.up)("Notifications"),c=(0,i.up)("VoiceAssistant"),d=(0,i.up)("Pushbullet"),u=(0,i.up)("router-view");return(0,i.wg)(),(0,i.iD)(i.HY,null,[o.hasWebsocket?((0,i.wg)(),(0,i.j4)(r,{key:0,ref:"events","ws-port":a.config["backend.http"].websocket_port},null,8,["ws-port"])):(0,i.kq)("",!0),(0,i.Wm)(l,{ref:"notifications"},null,512),o.hasAssistant?((0,i.wg)(),(0,i.j4)(c,{key:1,ref:"voice-assistant"},null,512)):(0,i.kq)("",!0),o.hasPushbullet?((0,i.wg)(),(0,i.j4)(d,{key:2,ref:"pushbullet"},null,512)):(0,i.kq)("",!0),(0,i.Wm)(u)],64)}const o={class:"notifications"};function r(e,t,s,n,a,r){const l=(0,i.up)("Notification");return(0,i.wg)(),(0,i.iD)("div",o,[((0,i.wg)(!0),(0,i.iD)(i.HY,null,(0,i.Ko)(e.notifications,((e,t,s)=>((0,i.wg)(),(0,i.j4)(l,{key:s,id:t,text:e.text,html:e.html,title:e.title,link:e.link,image:e.image,warning:e.warning,error:e.error,onClicked:r.destroy},null,8,["id","text","html","title","link","image","warning","error","onClicked"])))),128))])}var l=s(3577);const c=["textContent"],d={class:"body"},u={key:0,class:"image col-3"},h={class:"row"},p=["src"],m={key:3,class:"fa fa-exclamation"},f={key:4,class:"fa fa-times"},g=["textContent"],w=["innerHTML"],v=["textContent"],b=["innerHTML"];function y(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("div",{class:(0,l.C_)(["notification fade-in",{warning:s.warning,error:s.error}]),onClick:t[0]||(t[0]=(...e)=>o.clicked&&o.clicked(...e))},[s.title?((0,i.wg)(),(0,i.iD)("div",{key:0,class:"title",textContent:(0,l.zw)(s.title)},null,8,c)):(0,i.kq)("",!0),(0,i._)("div",d,[s.image||s.warning||s.error?((0,i.wg)(),(0,i.iD)("div",u,[(0,i._)("div",h,[s.image&&s.image.src?((0,i.wg)(),(0,i.iD)("img",{key:0,src:s.image.src,alt:""},null,8,p)):s.image&&s.image.icon?((0,i.wg)(),(0,i.iD)("i",{key:1,class:(0,l.C_)(["fa","fa-"+s.image.icon]),style:(0,l.j5)(s.image.color?"--color: "+s.image.color:"")},null,6)):s.image&&s.image.iconClass?((0,i.wg)(),(0,i.iD)("i",{key:2,class:(0,l.C_)(s.image.iconClass),style:(0,l.j5)(s.image.color?"--color: "+s.image.color:"")},null,6)):s.warning?((0,i.wg)(),(0,i.iD)("i",m)):s.error?((0,i.wg)(),(0,i.iD)("i",f)):(0,i.kq)("",!0)])])):(0,i.kq)("",!0),s.text&&s.image?((0,i.wg)(),(0,i.iD)("div",{key:1,class:"text col-9",textContent:(0,l.zw)(s.text)},null,8,g)):(0,i.kq)("",!0),s.html&&s.image?((0,i.wg)(),(0,i.iD)("div",{key:2,class:"text col-9",innerHTML:s.html},null,8,w)):(0,i.kq)("",!0),s.text&&!s.image?((0,i.wg)(),(0,i.iD)("div",{key:3,class:"text row horizontal-center",textContent:(0,l.zw)(s.text)},null,8,v)):(0,i.kq)("",!0),s.html&&!s.image?((0,i.wg)(),(0,i.iD)("div",{key:4,class:"text row horizontal-center",innerHTML:s.html},null,8,b)):(0,i.kq)("",!0)])],2)}var k={name:"Notification",props:["id","text","html","title","image","link","error","warning"],methods:{clicked(){this.link&&window.open(this.link,"_blank"),this.$emit("clicked",this.id)}}},_=s(3744);const x=(0,_.Z)(k,[["render",y],["__scopeId","data-v-7646705e"]]);var C=x,D={name:"Notifications",components:{Notification:C},props:{duration:{type:Number,default:1e4}},data:function(){return{index:0,notifications:{},timeouts:{}}},methods:{create:function(e){const t=this.index++;this.notifications[t]=e,null==e.duration&&(e.duration=this.duration);const s=e.duration?parseInt(e.duration):0;s&&(this.timeouts[t]=setTimeout(this.destroy.bind(null,t),s))},destroy:function(e){delete this.notifications[e],delete this.timeouts[e]}}};const I=(0,_.Z)(D,[["render",r],["__scopeId","data-v-6dc8bebc"]]);var S=I,T=s(2628);function U(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("div")}var P=s(5250),$={name:"Events",props:{wsPort:{type:Number,default:8009}},data(){return{ws:null,initialized:!1,pending:!1,opened:!1,timeout:null,reconnectMsecs:3e4,handlers:{},handlerNameToEventTypes:{}}},methods:{onWebsocketTimeout(){console.log("Websocket reconnection timed out, retrying"),this.pending=!1,this.ws&&this.ws.close(),this.onClose()},onMessage(e){const t=[];if(e=e.data,"string"===typeof e)try{e=JSON.parse(e)}catch(s){console.warn("Received invalid non-JSON event"),console.warn(e)}if(console.debug(e),"event"===e.type){null in this.handlers&&t.push(this.handlers[null]),e.args.type in this.handlers&&t.push(...Object.values(this.handlers[e.args.type]));for(let s of t)s&&(s instanceof Array?s=s[0]:s instanceof Object&&!(s instanceof Function)&&(s=Object.values(s)[0]),s(e.args))}},onOpen(){this.opened&&(console.log("There's already an opened websocket connection, closing the newly opened one"),this.ws&&(this.ws.onclose=()=>{},this.ws.close())),console.log("Websocket connection successful"),this.opened=!0,this.pending&&(this.pending=!1),this.timeout&&(clearTimeout(this.timeout),this.timeout=void 0)},onError(e){console.error("Websocket error"),console.error(e)},onClose(e){e&&console.log("Websocket closed - code: "+e.code+" - reason: "+e.reason),this.opened=!1,this.pending||(this.pending=!0,this.init())},init(){try{const e="https:"===location.protocol?"wss":"ws",t=`${e}://${location.hostname}:${this.wsPort}`;this.ws=new WebSocket(t)}catch(e){return console.error("Websocket initialization error"),void console.error(e)}this.pending=!0,this.timeout=setTimeout(this.onWebsocketTimeout,this.reconnectMsecs),this.ws.onmessage=this.onMessage,this.ws.onopen=this.onOpen,this.ws.onerror=this.onError,this.ws.onclose=this.onClose,this.initialized=!0},subscribe(e){const t=e.handler,s=e.events.length?e.events:[null],n=e.handlerName;for(const i of s)i in this.handlers||(this.handlers[i]={}),n in this.handlerNameToEventTypes||(this.handlerNameToEventTypes[n]=s),this.handlers[i][n]=t;return()=>{this.unsubscribe(n)}},unsubscribe(e){const t=this.handlerNameToEventTypes[e];if(t){for(const s of t)this.handlers[s]?.[e]&&(delete this.handlers[s][e],Object.keys(this.handlers[s]).length||delete this.handlers[s]);delete this.handlerNameToEventTypes[e]}}},created(){P.$.on("subscribe",this.subscribe),P.$.on("unsubscribe",this.unsubscribe),this.init()}};const M=(0,_.Z)($,[["render",U]]);var q=M;const N={class:"assistant-modal"},Z={class:"icon"},j={key:0,class:"fa fa-bell"},O={key:1,class:"fa fa-volume-up"},z={key:2,class:"fa fa-comment-dots"},E={key:3,class:"fa fa-microphone"},R={class:"text"},W={key:0,class:"listening"},L=(0,i._)("span",null,"Assistant listening",-1),A=[L],V={key:1,class:"speech-recognized"},H=["textContent"],F={key:2,class:"responding"},B=["textContent"];function Y(e,t,s,n,a,o){const r=(0,i.up)("Modal");return(0,i.wg)(),(0,i.iD)("div",N,[(0,i.Wm)(r,{ref:"assistantModal"},{default:(0,i.w5)((()=>[(0,i._)("div",Z,[a.state.alerting?((0,i.wg)(),(0,i.iD)("i",j)):a.state.responding?((0,i.wg)(),(0,i.iD)("i",O)):a.state.speechRecognized?((0,i.wg)(),(0,i.iD)("i",z)):((0,i.wg)(),(0,i.iD)("i",E))]),(0,i._)("div",R,[a.state.listening?((0,i.wg)(),(0,i.iD)("div",W,A)):a.state.speechRecognized?((0,i.wg)(),(0,i.iD)("div",V,[(0,i._)("span",{textContent:(0,l.zw)(a.phrase)},null,8,H)])):a.state.responding?((0,i.wg)(),(0,i.iD)("div",F,[(0,i._)("span",{textContent:(0,l.zw)(a.responseText)},null,8,B)])):(0,i.kq)("",!0)])])),_:1},512)])}var K=s(9642),G={name:"VoiceAssistant",components:{Modal:K.Z},mixins:[T.Z],data(){return{responseText:"",phrase:"",hideTimeout:void 0,state:{listening:!1,speechRecognized:!1,responding:!1,alerting:!1}}},methods:{reset(){this.state.listening=!1,this.state.speechRecognized=!1,this.state.responding=!1,this.state.alerting=!1,this.phrase="",this.responseText=""},conversationStart(){this.reset(),this.state.listening=!0,this.$refs.assistantModal.show(),this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=void 0)},conversationEnd(){const e=this;this.hideTimeout=setTimeout((()=>{this.reset(),e.$refs.assistantModal.close(),e.hideTimeout=void 0}),4e3)},speechRecognized(e){this.reset(),this.state.speechRecognized=!0,this.phrase=e.phrase,this.$refs.assistantModal.show()},response(e){this.reset(),this.state.responding=!0,this.responseText=e.response_text,this.$refs.assistantModal.show()},alertOn(){this.reset(),this.state.alerting=!0,this.$refs.assistantModal.show()},alertOff(){this.reset(),this.state.alerting=!1,this.$refs.assistantModal.close()},registerHandlers(){this.subscribe(this.conversationStart,null,"platypush.message.event.assistant.ConversationStartEvent"),this.subscribe(this.alertOn,null,"platypush.message.event.assistant.AlertStartedEvent"),this.subscribe(this.alertOff,null,"platypush.message.event.assistant.AlertEndEvent"),this.subscribe(this.speechRecognized,null,"platypush.message.event.assistant.SpeechRecognizedEvent"),this.subscribe(this.response,null,"platypush.message.event.assistant.ResponseEvent"),this.subscribe(this.conversationEnd,null,"platypush.message.event.assistant.ConversationEndEvent","platypush.message.event.assistant.NoResponseEvent","platypush.message.event.assistant.ConversationTimeoutEvent")}},mounted(){this.registerHandlers()}};const J=(0,_.Z)(G,[["render",Y]]);var X=J;function Q(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("div")}var ee={name:"Pushbullet",mixins:[T.Z],methods:{onMessage(e){"mirror"===e.push_type&&this.notify({title:e.title,text:e.body,image:{src:e.icon?"data:image/png;base64, "+e.icon:void 0,icon:e.icon?void 0:"bell"}})}},mounted(){this.subscribe(this.onMessage,null,"platypush.message.event.pushbullet.PushbulletEvent")}};const te=(0,_.Z)(ee,[["render",Q]]);var se=te,ne={name:"App",mixins:[T.Z],components:{Pushbullet:se,Notifications:S,Events:q,VoiceAssistant:X},data(){return{config:{},userAuthenticated:!1}},computed:{hasWebsocket(){return this.userAuthenticated&&"backend.http"in this.config},hasAssistant(){return this.hasWebsocket},hasPushbullet(){return this.hasWebsocket&&("pushbullet"in this.config||"backend.pushbullet"in this.config)}},methods:{onNotification(e){this.$refs.notifications.create(e)},async initConfig(){this.config=await this.request("config.get"),this.userAuthenticated=!0}},created(){this.initConfig()},mounted(){P.$.on("notification-create",this.onNotification)}};const ie=(0,_.Z)(ne,[["render",a]]);var ae=ie,oe=s(2119);function re(e,t,s,n,a,o){const r=(0,i.up)("Loading"),c=(0,i.up)("Widget"),d=(0,i.up)("Row");return(0,i.wg)(),(0,i.iD)(i.HY,null,[a.loading?((0,i.wg)(),(0,i.j4)(r,{key:0})):(0,i.kq)("",!0),(0,i._)("div",{id:"dashboard",class:(0,l.C_)(["col-12",o.classes]),style:(0,l.j5)(a.style)},[((0,i.wg)(!0),(0,i.iD)(i.HY,null,(0,i.Ko)(a.rows,((e,t)=>((0,i.wg)(),(0,i.j4)(d,{key:t,class:(0,l.C_)(e.class),style:(0,l.j5)(e.style)},{default:(0,i.w5)((()=>[((0,i.wg)(!0),(0,i.iD)(i.HY,null,(0,i.Ko)(e.widgets,((e,t)=>((0,i.wg)(),(0,i.j4)(i.Ob,{key:t},[(0,i.Wm)(c,{style:(0,l.j5)(e.style),class:(0,l.C_)(e.class)},{default:(0,i.w5)((()=>[((0,i.wg)(),(0,i.j4)((0,i.LL)(e.component),(0,l.vs)((0,i.F4)(o.getWidgetProps(e))),null,16))])),_:2},1032,["style","class"])],1024)))),128))])),_:2},1032,["class","style"])))),128))],6)],64)}var le=s(1232);function ce(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("div",{class:(0,l.C_)(["row",o.classes]),style:(0,l.j5)(s.style)},[(0,i.WI)(e.$slots,"default",{},void 0,!0)],6)}var de={name:"Row",props:{class:{type:String,required:!1,default:""},style:{type:String,required:!1,default:""}},computed:{classes(){return this.class}}};const ue=(0,_.Z)(de,[["render",ce],["__scopeId","data-v-1b4663f2"]]);var he=ue;function pe(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("div",{style:(0,l.j5)(s.style),class:(0,l.C_)(o.classes)},[(0,i.WI)(e.$slots,"default",{},void 0,!0)],6)}var me={name:"Widget",props:{style:{type:String,required:!1,default:""},class:{type:String,required:!1,default:""}},computed:{classes(){return(this.class?.length?this.class.split(" "):["col-3"]).concat(["widget","column"])}}};const fe=(0,_.Z)(me,[["render",pe],["__scopeId","data-v-5df52982"]]);var ge=fe,we={name:"Dashboard",mixins:[T.Z],components:{Widget:ge,Loading:le.Z,Row:he},props:{refreshSeconds:{type:Number,required:!1,default:0}},data(){return{rows:[],loading:!1,style:void 0,class:void 0}},computed:{classes(){return this.class}},methods:{getWidgetProps(e){const t={...e.props};return t.class&&delete t.class,t},parseTemplate(e,t){const n=(new DOMParser).parseFromString(t,"text/xml").childNodes[0],a=this;this.style=n.attributes.style?.nodeValue,this.class=n.attributes.class?.nodeValue,this.rows=[...n.getElementsByTagName("Row")].map((e=>({style:e.attributes.style?.nodeValue,class:e.attributes.class?.nodeValue,widgets:[...e.children].map((e=>{const t=(0,i.RC)((()=>s(6725)(`./${e.nodeName}/Index`))),n=e.attributes.style?.nodeValue,o=e.attributes.class?.nodeValue,r=[...e.attributes].reduce(((e,t)=>("style"!==t.nodeName&&(e[t.nodeName]=t.nodeValue),e)),{content:e.innerHTML}),l={component:t,style:n,class:o,props:r||{}};return a.$options.components[e.nodeName]=t,l}))}))),this.loading=!1},async refreshDashboard(){this.loading=!0,this.widgets=[];const e=this.$route.params.name,t=await this.request("config.get_dashboard",{name:e});t||this.error(`Dashboard ${e} not found`),this.parseTemplate(e,t)}},mounted(){if(this.refreshDashboard(),this.refreshSeconds){const e=this;setInterval((()=>{e.refreshDashboard()}),parseInt((1e3*this.refreshSeconds).toFixed(0)))}}};const ve=(0,_.Z)(we,[["render",re],["__scopeId","data-v-cefcfdfc"]]);var be=ve;function ye(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("h1",null,"Object not found")}var ke={name:"NotFound"};const _e=(0,_.Z)(ke,[["render",ye]]);var xe=_e;const Ce={class:"login-container"},De={class:"login",method:"POST"},Ie={class:"description"},Se=(0,i._)("div",{class:"row"},[(0,i._)("label",null,[(0,i._)("input",{type:"text",name:"username",placeholder:"Username"})])],-1),Te=(0,i._)("div",{class:"row"},[(0,i._)("label",null,[(0,i._)("input",{type:"password",name:"password",placeholder:"Password"})])],-1),Ue={key:0,class:"row"},Pe=(0,i._)("label",null,[(0,i._)("input",{type:"password",name:"confirm_password",placeholder:"Confirm password"})],-1),$e=[Pe],Me={class:"row pull-right"},qe=["value"],Ne=(0,i._)("div",{class:"row pull-right"},[(0,i._)("label",{class:"checkbox"},[(0,i._)("input",{type:"checkbox",name:"remember"}),(0,i.Uk)("  Keep me logged in on this device   ")])],-1);function Ze(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("div",Ce,[(0,i._)("form",De,[(0,i._)("div",Ie,(0,l.zw)(o._register?"Welcome":"Authenticate")+" to platypush ",1),Se,Te,o._register?((0,i.wg)(),(0,i.iD)("div",Ue,$e)):(0,i.kq)("",!0),(0,i._)("div",Me,[(0,i._)("input",{type:"submit",class:"btn btn-primary",value:o._register?"Register":"Login"},null,8,qe)]),Ne])])}var je={name:"Login",mixins:[T.Z],props:{register:{type:Boolean,required:!1,default:!1}},computed:{_register(){return this.parseBoolean(this.register)}}};const Oe=(0,_.Z)(je,[["render",Ze]]);var ze=Oe;function Ee(e,t,s,n,a,o){const r=(0,i.up)("Login");return(0,i.wg)(),(0,i.j4)(r,{register:!0})}var Re={name:"Register",mixins:[ze],components:{Login:ze},props:{register:{type:Boolean,required:!1,default:!0}}};const We=(0,_.Z)(Re,[["render",Ee]]);var Le=We;const Ae={key:2,class:"canvas"},Ve={class:"panel"},He={key:3,class:"canvas"};function Fe(e,t,s,n,a,o){const r=(0,i.up)("Loading"),c=(0,i.up)("Nav"),d=(0,i.up)("Settings");return(0,i.wg)(),(0,i.iD)("main",null,[a.loading?((0,i.wg)(),(0,i.j4)(r,{key:0})):((0,i.wg)(),(0,i.j4)(c,{key:1,panels:a.components,"selected-panel":a.selectedPanel,hostname:a.hostname,onSelect:t[0]||(t[0]=e=>a.selectedPanel=e)},null,8,["panels","selected-panel","hostname"])),"settings"===a.selectedPanel?((0,i.wg)(),(0,i.iD)("div",Ae,[(0,i._)("div",Ve,[(0,i.Wm)(d)])])):((0,i.wg)(),(0,i.iD)("div",He,[((0,i.wg)(!0),(0,i.iD)(i.HY,null,(0,i.Ko)(a.components,((e,t)=>((0,i.wg)(),(0,i.iD)("div",{class:(0,l.C_)(["panel",{hidden:t!==a.selectedPanel}]),key:t},[t===a.selectedPanel?((0,i.wg)(),(0,i.j4)((0,i.LL)(e.component),{key:0,config:e.config,"plugin-name":t},null,8,["config","plugin-name"])):(0,i.kq)("",!0)],2)))),128))]))])}const Be=e=>((0,i.dD)("data-v-6c2cfd7a"),e=e(),(0,i.Cn)(),e),Ye=Be((()=>(0,i._)("i",{class:"fas fa-bars"},null,-1))),Ke=["textContent"],Ge={class:"plugins"},Je=["title","onClick"],Xe=["href"],Qe={class:"icon"},et=["src"],tt={key:2,class:"fas fa-puzzle-piece"},st=["textContent"],nt={class:"footer"},it={href:"/#settings"},at=Be((()=>(0,i._)("span",{class:"icon"},[(0,i._)("i",{class:"fa fa-cog"})],-1))),ot={key:0,class:"name"},rt={href:"/logout"},lt=Be((()=>(0,i._)("span",{class:"icon"},[(0,i._)("i",{class:"fas fa-sign-out-alt"})],-1))),ct={key:0,class:"name"};function dt(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("nav",{class:(0,l.C_)({collapsed:a.collapsed})},[(0,i._)("div",{class:"toggler",onClick:t[0]||(t[0]=e=>a.collapsed=!a.collapsed)},[Ye,s.hostname?((0,i.wg)(),(0,i.iD)("span",{key:0,class:"hostname",textContent:(0,l.zw)(s.hostname)},null,8,Ke)):(0,i.kq)("",!0)]),(0,i._)("ul",Ge,[((0,i.wg)(!0),(0,i.iD)(i.HY,null,(0,i.Ko)(Object.keys(s.panels).sort(),(e=>((0,i.wg)(),(0,i.iD)("li",{key:e,class:(0,l.C_)(["entry",{selected:e===s.selectedPanel}]),title:e,onClick:t=>o.onItemClick(e)},[(0,i._)("a",{href:`/#${e}`},[(0,i._)("span",Qe,[a.icons[e]?.class?((0,i.wg)(),(0,i.iD)("i",{key:0,class:(0,l.C_)(a.icons[e].class)},null,2)):a.icons[e]?.imgUrl?((0,i.wg)(),(0,i.iD)("img",{key:1,src:a.icons[e].imgUrl,alt:"name"},null,8,et)):((0,i.wg)(),(0,i.iD)("i",tt))]),a.collapsed?(0,i.kq)("",!0):((0,i.wg)(),(0,i.iD)("span",{key:0,class:"name",textContent:(0,l.zw)(e)},null,8,st))],8,Xe)],10,Je)))),128))]),(0,i._)("ul",nt,[(0,i._)("li",{class:(0,l.C_)({selected:"settings"===s.selectedPanel}),title:"Settings",onClick:t[1]||(t[1]=e=>o.onItemClick("settings"))},[(0,i._)("a",it,[at,a.collapsed?(0,i.kq)("",!0):((0,i.wg)(),(0,i.iD)("span",ot,"Settings"))])],2),(0,i._)("li",{title:"Logout",onClick:t[2]||(t[2]=e=>o.onItemClick("logout"))},[(0,i._)("a",rt,[lt,a.collapsed?(0,i.kq)("",!0):((0,i.wg)(),(0,i.iD)("span",ct,"Logout"))])])])],2)}var ut=JSON.parse('{"camera.android.ipcam":{"class":"fab fa-android"},"camera.cv":{"class":"fas fa-camera"},"camera.ffmpeg":{"class":"fas fa-camera"},"camera.gstreamer":{"class":"fas fa-camera"},"camera.ir.mlx90640":{"class":"fas fa-sun"},"camera.pi":{"class":"fas fa-camera"},"execute":{"class":"fa fa-play"},"light.hue":{"class":"fas fa-lightbulb"},"media.jellyfin":{"imgUrl":"/icons/jellyfin.svg"},"media.kodi":{"imgUrl":"/icons/kodi.svg"},"media.omxplayer":{"class":"fa fa-film"},"media.mplayer":{"class":"fa fa-film"},"media.mpv":{"class":"fa fa-film"},"media.plex":{"imgUrl":"/icons/plex.svg"},"media.vlc":{"class":"fa fa-film"},"music.mpd":{"class":"fas fa-music"},"music.snapcast":{"class":"fa fa-volume-up"},"music.spotify":{"class":"fab fa-spotify"},"torrent":{"class":"fa fa-magnet"},"rtorrent":{"class":"fa fa-magnet"},"switches":{"class":"fas fa-toggle-on"},"sound":{"class":"fa fa-microphone"},"tts":{"class":"far fa-comment"},"tts.google":{"class":"fas fa-comment"},"tv.samsung.ws":{"class":"fas fa-tv"},"zigbee.mqtt":{"imgUrl":"/icons/zigbee.svg"},"zwave":{"imgUrl":"/icons/z-wave.png"},"zwave.mqtt":{"imgUrl":"/icons/z-wave.png"}}'),ht={name:"Nav",emits:["select"],mixins:[T.Z],props:{panels:{type:Object,required:!0},selectedPanel:{type:String},hostname:{type:String}},methods:{onItemClick(e){this.$emit("select",e),this.collapsed=!0}},data(){return{collapsed:!0,icons:ut,host:null}},mounted(){this.isMobile()&&!this.$root.$route.hash.length&&(this.collapsed=!1)}};const pt=(0,_.Z)(ht,[["render",dt],["__scopeId","data-v-6c2cfd7a"]]);var mt=pt,ft=s(5392),gt={name:"Panel",mixins:[T.Z],components:{Settings:ft["default"],Nav:mt,Loading:le.Z},data(){return{loading:!1,plugins:{},backends:{},procedures:{},components:{},hostname:void 0,selectedPanel:void 0}},methods:{initSelectedPanel(){const e=this.$route.hash.match("#?([a-zA-Z0-9.]+)[?]?(.*)");if(!e)return;const t=e[1];t?.length&&(this.selectedPanel=t)},initPanels(){const e=this;this.components={},Object.entries(this.plugins).forEach((async([t,n])=>{const a=t.split(".").map((e=>e[0].toUpperCase()+e.slice(1))).join("");let o=null;try{o=await s(3379)(`./${a}/Index`)}catch(l){return}const r=(0,i.RC)((async()=>o));e.$options.components[t]=r,e.components[t]={component:r,pluginName:t,config:n}}))},async parseConfig(){[this.plugins,this.backends,this.procedures,this.hostname]=await Promise.all([this.request("config.get_plugins"),this.request("config.get_backends"),this.request("config.get_procedures"),this.request("config.get_device_id")]),this.initializeDefaultViews()},initializeDefaultViews(){this.plugins.execute={},this.plugins.switches={}}},async mounted(){this.loading=!0;try{await this.parseConfig(),this.initPanels(),this.initSelectedPanel()}finally{this.loading=!1}}};const wt=(0,_.Z)(gt,[["render",Fe],["__scopeId","data-v-5ec69f95"]]);var vt=wt;const bt={key:1,class:"canvas"};function yt(e,t,s,n,a,o){const r=(0,i.up)("Loading");return(0,i.wg)(),(0,i.iD)("main",null,[a.loading?((0,i.wg)(),(0,i.j4)(r,{key:0})):((0,i.wg)(),(0,i.iD)("div",bt,[((0,i.wg)(),(0,i.j4)((0,i.LL)(a.component),{config:a.config,"plugin-name":o.pluginName},null,8,["config","plugin-name"]))]))])}var kt={name:"Panel",mixins:[T.Z],components:{Settings:ft["default"],Nav:mt,Loading:le.Z},data(){return{loading:!1,config:{},plugins:{},backends:{},procedures:{},component:void 0,hostname:void 0,selectedPanel:void 0}},computed:{pluginName(){return this.$route.params.plugin}},methods:{async initPanel(){const e=this.pluginName.split(".").map((e=>e[0].toUpperCase()+e.slice(1))).join("");let t=null;try{t=await s(3379)(`./${e}/Index`)}catch(n){return console.error(n),void this.notify({error:!0,title:`Cannot load plugin ${this.pluginName}`,text:n.toString()})}this.component=(0,i.RC)((async()=>t)),this.$options.components[name]=this.component},async initConfig(){const e=await this.request("config.get");this.config=e[this.pluginName]||{},this.hostname=await this.request("config.get_device_id")}},async mounted(){this.loading=!0;try{await this.initConfig(),await this.initPanel()}finally{this.loading=!1}}};const _t=(0,_.Z)(kt,[["render",yt],["__scopeId","data-v-67571c94"]]);var xt=_t;const Ct=[{path:"/",name:"Panel",component:vt},{path:"/dashboard/:name",name:"Dashboard",component:be},{path:"/plugin/:plugin",name:"Plugin",component:xt},{path:"/login",name:"Login",component:ze},{path:"/register",name:"Register",component:Le},{path:"/:catchAll(.*)",component:xe}],Dt=(0,oe.p7)({history:(0,oe.PO)(),routes:Ct});var It=Dt;const St=(0,n.ri)(ae);St.config.globalProperties._config=window.config,St.use(It).mount("#app")},2628:function(e,t,s){"use strict";s.d(t,{Z:function(){return U}});var n=s(9669),i=s.n(n),a={name:"Api",methods:{execute(e,t=6e4){const s={};return"target"in e&&e["target"]||(e["target"]="localhost"),"type"in e&&e["type"]||(e["type"]="request"),t&&(s.timeout=t),new Promise(((t,n)=>{i().post("/execute",e,s).then((e=>{if(e=e.data.response,e.errors?.length){const t=e.errors?.[0]||e;this.notify({text:t,error:!0}),n(t)}else t(e.output)})).catch((e=>{this.notify({text:e,error:!0}),n(e)}))}))},request(e,t={},s=6e4){return this.execute({type:"request",action:e,args:t},s)}}};const o=a;var r=o,l={name:"Cookies",methods:{getCookies(){return document.cookie.split(/;\s*/).reduce(((e,t)=>{const[s,n]=t.split("=");return e[s]=n,e}),{})}}};const c=l;var d=c,u={name:"DateTime",methods:{formatDate(e,t=!1){return"string"===typeof e&&(e=new Date(Date.parse(e))),e.toDateString().substring(0,t?15:10)},formatTime(e,t=!0){return"string"===typeof e&&(e=new Date(Date.parse(e))),e.toTimeString().substring(0,t?8:5)},formatDateTime(e,t=!1,s=!0){return"string"===typeof e&&(e=new Date(Date.parse(e))),`${this.formatDate(e,t)}, ${this.formatTime(e,s)}`}}};const h=u;var p=h,m=(s(2801),s(5250)),f={name:"Events",computed:{_eventsReady(){return this.$root.$refs.events?.initialized}},methods:{subscribe(e,t,...s){const n=()=>{m.$.emit("subscribe",{events:s,handler:e,handlerName:t||this.generateId()})};if(this._eventsReady)return void n();const i=this,a=this.$watch((()=>i._eventsReady),(e=>{e&&(n(),a())}));return a},unsubscribe(e){m.$.emit("unsubscribe",e)},generateId(){return btoa([...Array(11).keys()].map((()=>String.fromCharCode(Math.round(255*Math.random())))))}}};const g=f;var w=g,v={name:"Notification",methods:{notify(e){m.$.emit("notification-create",e)},warn(e){this.notify({text:e,warning:!0})},error(e){throw this.notify({text:e,error:!0}),e}}};const b=v;var y=b,k={name:"Screen",methods:{isMobile(){return window.matchMedia("only screen and (max-width: 760px)").matches},isTablet(){return!this.isMobile()&&window.matchMedia("only screen and (max-width: 960px)").matches},isDesktop(){return window.matchMedia("only screen and (min-width: 1152px)").matches}}};const _=k;var x=_,C={name:"Types",methods:{parseBoolean(e){return"string"===typeof e?(e=e.toLowerCase(),"true"===e||"false"!==e&&!!parseInt(e)):!!e},convertSize(e){"string"===typeof e&&(e=parseInt(e));let t=null;const s=["B","KB","MB","GB","TB"];return s.forEach(((n,i)=>{e<=1024&&null==t?t=n:e>1024&&(i===s.length-1?t=n:e/=1024)})),`${e.toFixed(2)} ${t}`}}};const D=C;var I=D,S={name:"Utils",mixins:[r,d,y,w,p,x,I]};const T=S;var U=T},1232:function(e,t,s){"use strict";s.d(t,{Z:function(){return d}});var n=s(6252);const i={class:"loading"},a={class:"icon"};function o(e,t){return(0,n.wg)(),(0,n.iD)("div",i,[(0,n._)("div",a,[((0,n.wg)(),(0,n.iD)(n.HY,null,(0,n.Ko)(4,(e=>(0,n._)("div",{key:e}))),64))])])}var r=s(3744);const l={},c=(0,r.Z)(l,[["render",o],["__scopeId","data-v-4d9c871b"]]);var d=c},9642:function(e,t,s){"use strict";s.d(t,{Z:function(){return p}});var n=s(6252),i=s(3577);const a=["id"],o={class:"modal"},r=["textContent"],l={class:"body"};function c(e,t,s,c,d,u){return(0,n.wg)(),(0,n.iD)("div",{class:(0,i.C_)(["modal-container fade-in",{hidden:!d.isVisible}]),id:s.id,style:(0,i.j5)({"--z-index":u.zIndex}),onClick:t[2]||(t[2]=(...e)=>u.close&&u.close(...e))},[(0,n._)("div",o,[(0,n._)("div",{class:"content",style:(0,i.j5)({"--width":s.width,"--height":s.height}),onClick:t[1]||(t[1]=e=>e.stopPropagation())},[s.title?((0,n.wg)(),(0,n.iD)("div",{key:0,class:"header",textContent:(0,i.zw)(s.title)},null,8,r)):(0,n.kq)("",!0),(0,n._)("div",l,[(0,n.WI)(e.$slots,"default",{onModalClose:t[0]||(t[0]=(...e)=>u.close&&u.close(...e))},void 0,!0)])],4)])],14,a)}var d={name:"Modal",emits:["close","open"],props:{id:{type:String},title:{type:String},width:{type:[Number,String]},height:{type:[Number,String]},visible:{type:Boolean,default:!1},timeout:{type:[Number,String]},level:{type:Number,default:1}},data(){return{timeoutId:void 0,prevVisible:this.visible,isVisible:this.visible}},computed:{zIndex(){return 500+this.level}},methods:{close(){this.prevVisible=this.isVisible,this.isVisible=!1},hide(){this.close()},show(){this.prevVisible=this.isVisible,this.isVisible=!0},toggle(){this.isVisible?this.close():this.show()}},mounted(){const e=this,t=t=>{t?e.$emit("open"):e.$emit("close"),e.isVisible=t};this.$watch((()=>this.visible),t),this.$watch((()=>this.isVisible),t)},updated(){if(this.prevVisible=this.isVisible,this.isVisible){let e=parseInt(getComputedStyle(this.$el).zIndex),t=[];for(const s of document.querySelectorAll(".modal-container:not(.hidden)")){const n=parseInt(getComputedStyle(s).zIndex);n>e?(e=n,t=[s]):n===e&&t.push(s)}(t.indexOf(this.$el)<0||t.length>1)&&(this.$el.style.zIndex=e+1)}if(this.isVisible&&this.timeout&&!this.timeoutId){const e=e=>()=>{e.close(),e.timeoutId=void 0};this.timeoutId=setTimeout(e(this),0+this.timeout)}}},u=s(3744);const h=(0,u.Z)(d,[["render",c],["__scopeId","data-v-010fadd6"]]);var p=h},449:function(e,t,s){"use strict";s.d(t,{Z:function(){return m}});var n=s(6252),i=s(9963),a=s(3577);const o={class:"dropdown-container",ref:"container"},r=["title"],l=["textContent"],c=["id"];function d(e,t,s,d,u,h){return(0,n.wg)(),(0,n.iD)("div",o,[(0,n._)("button",{title:s.title,ref:"button",onClick:t[0]||(t[0]=(0,i.iM)((e=>h.toggle(e)),["stop"]))},[s.iconClass?((0,n.wg)(),(0,n.iD)("i",{key:0,class:(0,a.C_)(["icon",s.iconClass])},null,2)):(0,n.kq)("",!0),s.text?((0,n.wg)(),(0,n.iD)("span",{key:1,class:"text",textContent:(0,a.zw)(s.text)},null,8,l)):(0,n.kq)("",!0)],8,r),(0,n._)("div",{class:(0,a.C_)(["dropdown fade-in",{hidden:!u.visible}]),id:s.id,ref:"dropdown"},[(0,n.WI)(e.$slots,"default",{},void 0,!0)],10,c)],512)}var u={name:"Dropdown",emits:["click"],props:{id:{type:String},items:{type:Array,default:()=>[]},iconClass:{type:String,default:"fa fa-ellipsis-h"},text:{type:String},title:{type:String}},data(){return{visible:!1}},methods:{documentClickHndl(e){if(!this.visible)return;let t=e.target;while(t){if(!this.$refs.dropdown)break;if(t===this.$refs.dropdown.element)return;t=t.parentElement}this.close()},close(){this.visible=!1,document.removeEventListener("click",this.documentClickHndl)},open(){document.addEventListener("click",this.documentClickHndl),this.visible=!0,setTimeout((()=>{const e=this.$refs.dropdown;e.style.left=0,e.style.top=parseFloat(getComputedStyle(this.$refs.button).height)+"px",e.getBoundingClientRect().left>window.innerWidth/2&&(e.style.left=-e.clientWidth+parseFloat(getComputedStyle(this.$refs.button).width)+"px"),e.getBoundingClientRect().top>window.innerHeight/2&&(e.style.top=-e.clientHeight+parseFloat(getComputedStyle(this.$refs.button).height)+"px")}),10)},toggle(e){e.stopPropagation(),this.$emit("click"),this.visible?this.close():this.open()}}},h=s(3744);const p=(0,h.Z)(u,[["render",d],["__scopeId","data-v-068c53bc"]]);var m=p},6728:function(e,t,s){"use strict";s.d(t,{Z:function(){return u}});var n=s(6252),i=s(3577);const a={key:0,class:"col-1 icon"},o=["textContent"];function r(e,t,s,r,l,c){return(0,n.wg)(),(0,n.iD)("div",{class:(0,i.C_)(["row item",s.itemClass]),onClick:t[0]||(t[0]=(...e)=>c.clicked&&c.clicked(...e))},[s.iconClass?((0,n.wg)(),(0,n.iD)("div",a,[(0,n._)("i",{class:(0,i.C_)(s.iconClass)},null,2)])):(0,n.kq)("",!0),(0,n._)("div",{class:(0,i.C_)(["text",{"col-11":null!=s.iconClass}]),textContent:(0,i.zw)(s.text)},null,10,o)],2)}var l={name:"DropdownItem",props:{iconClass:{type:String},text:{type:String},disabled:{type:Boolean,default:!1},itemClass:{type:String}},methods:{clicked(e){this.$parent.$emit("click",e),this.$parent.visible=!1}}},c=s(3744);const d=(0,c.Z)(l,[["render",r],["__scopeId","data-v-6d8973c4"]]);var u=d},5392:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return Ce}});var n=s(6252);const i={class:"settings-container"},a={class:"col-8"},o=["selected"],r=["selected"],l={class:"col-4 pull-right"},c=(0,n._)("i",{class:"fa fa-plus"},null,-1),d=[c];function u(e,t,s,c,u,h){const p=(0,n.up)("Users"),m=(0,n.up)("Token");return(0,n.wg)(),(0,n.iD)("div",i,[(0,n._)("header",null,[(0,n._)("div",a,[(0,n._)("select",{title:"View",onChange:t[0]||(t[0]=e=>u.selectedView=e.target.value)},[(0,n._)("option",{value:"users",selected:"users"===u.selectedView},"Users",8,o),(0,n._)("option",{value:"token",selected:"token"===u.selectedView},"Generate Token",8,r)],32)]),(0,n._)("div",l,["users"===u.selectedView?((0,n.wg)(),(0,n.iD)("button",{key:0,title:"Add User",onClick:t[1]||(t[1]=t=>e.$refs.usersView.$refs.addUserModal.show())},d)):(0,n.kq)("",!0)])]),(0,n._)("main",null,["users"===u.selectedView?((0,n.wg)(),(0,n.j4)(p,{key:0,"session-token":u.sessionToken,"current-user":u.currentUser,ref:"usersView"},null,8,["session-token","current-user"])):"token"===u.selectedView?((0,n.wg)(),(0,n.j4)(m,{key:1,"session-token":u.sessionToken,"current-user":u.currentUser,ref:"tokenView"},null,8,["session-token","current-user"])):(0,n.kq)("",!0)])])}var h=s(3577),p=s(9963);const m={class:"token-container"},f={class:"token-container"},g=(0,n.Uk)(" This is your generated token. Treat it carefully and do not share it with untrusted parties."),w=(0,n._)("br",null,null,-1),v=(0,n.Uk)(" Also, make sure to save it - it WILL NOT be displayed again. "),b=["textContent"],y={class:"body"},k={class:"description"},_=(0,n.Uk)("Generate a JWT authentication token that can be used for API calls to the "),x=(0,n.Uk)("/execute"),C=(0,n.Uk)(" endpoint."),D=(0,n._)("br",null,null,-1),I=(0,n._)("p",null,"You can include the token in your requests in any of the following ways:",-1),S=(0,n.Uk)("Specify it on the "),T=(0,n.Uk)("Authorization: Bearer"),U=(0,n.Uk)(" header;"),P=(0,n.Uk)("Specify it on the "),$=(0,n.Uk)("X-Token"),M=(0,n.Uk)(" header;"),q=(0,n.Uk)("Specify it as a URL parameter: "),N=(0,n.Uk)("http://site:8008/execute?token=..."),Z=(0,n.Uk)(";"),j=(0,n.Uk)("Specify it on the body of your JSON request: "),O=(0,n.Uk)('{"type":"request", "action", "...", "token":"..."}'),z=(0,n.Uk)("."),E=(0,n.Uk)(" Confirm your credentials in order to generate a new token. "),R={class:"form-container"},W=(0,n.Uk)(" Username "),L=["value"],A=(0,n._)("label",null,[(0,n.Uk)(" Password "),(0,n._)("input",{type:"password",name:"password"})],-1),V=(0,n._)("label",null,[(0,n.Uk)(" Token validity in days "),(0,n._)("input",{type:"text",name:"validityDays"}),(0,n._)("span",{class:"note"},[(0,n.Uk)(" Decimal values are also supported (e.g. "),(0,n._)("i",null,"0.5"),(0,n.Uk)(" to identify 6 hours). An empty or zero value means that the token has no expiry date. ")])],-1),H=(0,n._)("input",{type:"submit",value:"Generate token"},null,-1);function F(e,t,s,i,a,o){const r=(0,n.up)("Loading"),l=(0,n.up)("Modal"),c=(0,n.up)("tt");return(0,n.wg)(),(0,n.iD)("div",m,[a.loading?((0,n.wg)(),(0,n.j4)(r,{key:0})):(0,n.kq)("",!0),(0,n.Wm)(l,{ref:"tokenModal"},{default:(0,n.w5)((()=>[(0,n._)("div",f,[(0,n._)("label",null,[g,w,v,(0,n._)("textarea",{class:"token",textContent:(0,h.zw)(a.token),onFocus:t[0]||(t[0]=(...e)=>o.onTokenSelect&&o.onTokenSelect(...e))},null,40,b)])])])),_:1},512),(0,n._)("div",y,[(0,n._)("div",k,[(0,n._)("p",null,[_,(0,n.Wm)(c,null,{default:(0,n.w5)((()=>[x])),_:1}),C]),D,I,(0,n._)("ul",null,[(0,n._)("li",null,[S,(0,n.Wm)(c,null,{default:(0,n.w5)((()=>[T])),_:1}),U]),(0,n._)("li",null,[P,(0,n.Wm)(c,null,{default:(0,n.w5)((()=>[$])),_:1}),M]),(0,n._)("li",null,[q,(0,n.Wm)(c,null,{default:(0,n.w5)((()=>[N])),_:1}),Z]),(0,n._)("li",null,[j,(0,n.Wm)(c,null,{default:(0,n.w5)((()=>[O])),_:1}),z])]),E]),(0,n._)("div",R,[(0,n._)("form",{onSubmit:t[1]||(t[1]=(0,p.iM)(((...e)=>o.generateToken&&o.generateToken(...e)),["prevent"])),ref:"generateTokenForm"},[(0,n._)("label",null,[W,(0,n._)("input",{type:"text",name:"username",value:s.currentUser.username,disabled:""},null,8,L)]),A,V,H],544)])])])}var B=s(9669),Y=s.n(B),K=s(1232),G=s(2628),J=s(9642),X={name:"Token",components:{Modal:J.Z,Loading:K.Z},mixins:[G.Z],props:{currentUser:{type:Object,required:!0}},data(){return{loading:!1,token:null}},methods:{async generateToken(e){const t=this.currentUser.username,s=e.target.password.value;let n=e.target.validityDays?.length?parseInt(e.target.validityDays.value):0;n||(n=null),this.loading=!0;try{this.token=(await Y().post("/auth",{username:t,password:s,expiry_days:n})).data.token,this.token?.length&&this.$refs.tokenModal.show()}catch(i){console.error(i.toString()),this.notify({text:i.toString(),error:!0})}finally{this.loading=!1}},onTokenSelect(e){e.target.select(),document.execCommand("copy"),this.notify({text:"Token copied to clipboard",image:{iconClass:"fa fa-check"}})}}},Q=s(3744);const ee=(0,Q.Z)(X,[["render",F]]);var te=ee;const se=["disabled"],ne=["disabled"],ie=["disabled"],ae=["disabled"],oe=["value"],re=["disabled"],le=["disabled"],ce=["disabled"],de=["disabled"],ue={class:"body"},he={class:"users-list"},pe=["onClick"],me=["textContent"],fe={class:"actions pull-right col-4"};function ge(e,t,s,i,a,o){const r=(0,n.up)("Loading"),l=(0,n.up)("Modal"),c=(0,n.up)("DropdownItem"),d=(0,n.up)("Dropdown");return(0,n.wg)(),(0,n.iD)(n.HY,null,[a.loading?((0,n.wg)(),(0,n.j4)(r,{key:0})):(0,n.kq)("",!0),(0,n.Wm)(l,{ref:"addUserModal",title:"Add User"},{default:(0,n.w5)((()=>[(0,n._)("form",{action:"#",method:"POST",ref:"addUserForm",onSubmit:t[0]||(t[0]=(...e)=>o.createUser&&o.createUser(...e))},[(0,n._)("label",null,[(0,n._)("input",{type:"text",name:"username",placeholder:"Username",disabled:a.commandRunning},null,8,se)]),(0,n._)("label",null,[(0,n._)("input",{type:"password",name:"password",placeholder:"Password",disabled:a.commandRunning},null,8,ne)]),(0,n._)("label",null,[(0,n._)("input",{type:"password",name:"confirm_password",placeholder:"Confirm password",disabled:a.commandRunning},null,8,ie)]),(0,n._)("input",{type:"submit",value:"Create User",disabled:a.commandRunning},null,8,ae)],544)])),_:1},512),(0,n.Wm)(l,{ref:"changePasswordModal",title:"Change Password"},{default:(0,n.w5)((()=>[(0,n._)("form",{action:"#",method:"POST",ref:"changePasswordForm",onSubmit:t[1]||(t[1]=(...e)=>o.changePassword&&o.changePassword(...e))},[(0,n._)("label",null,[(0,n._)("input",{type:"text",name:"username",placeholder:"Username",value:a.selectedUser,disabled:"disabled"},null,8,oe)]),(0,n._)("label",null,[(0,n._)("input",{type:"password",name:"password",placeholder:"Current password",disabled:a.commandRunning},null,8,re)]),(0,n._)("label",null,[(0,n._)("input",{type:"password",name:"new_password",placeholder:"New password",disabled:a.commandRunning},null,8,le)]),(0,n._)("label",null,[(0,n._)("input",{type:"password",name:"confirm_new_password",placeholder:"Confirm new password",disabled:a.commandRunning},null,8,ce)]),(0,n._)("input",{type:"submit",value:"Change Password",disabled:a.commandRunning},null,8,de)],544)])),_:1},512),(0,n._)("div",ue,[(0,n._)("ul",he,[((0,n.wg)(!0),(0,n.iD)(n.HY,null,(0,n.Ko)(a.users,(t=>((0,n.wg)(),(0,n.iD)("li",{key:t.user_id,class:"item user",onClick:e=>a.selectedUser=t.username},[(0,n._)("div",{class:"name col-8",textContent:(0,h.zw)(t.username)},null,8,me),(0,n._)("div",fe,[(0,n.Wm)(d,{title:"User Actions","icon-class":"fa fa-cog"},{default:(0,n.w5)((()=>[(0,n.Wm)(c,{text:"Change Password",disabled:a.commandRunning,"icon-class":"fa fa-key",onClick:s=>{a.selectedUser=t.username,e.$refs.changePasswordModal.show()}},null,8,["disabled","onClick"]),(0,n.Wm)(c,{text:"Delete User",disabled:a.commandRunning,"icon-class":"fa fa-trash",onClick:e=>o.deleteUser(t)},null,8,["disabled","onClick"])])),_:2},1024)])],8,pe)))),128))])])],64)}var we=s(449),ve=s(6728),be={name:"Users",components:{DropdownItem:ve.Z,Loading:K.Z,Modal:J.Z,Dropdown:we.Z},mixins:[G.Z],props:{sessionToken:{type:String,required:!0},currentUser:{type:Object,required:!0}},data(){return{users:[],commandRunning:!1,loading:!1,selectedUser:null}},methods:{async refresh(){this.loading=!0;try{this.users=await this.request("user.get_users")}finally{this.loading=!1}},async createUser(e){e.preventDefault();const t=[...this.$refs.addUserForm.querySelectorAll("input[name]")].reduce(((e,t)=>(e[t.name]=t.value,e)),{});if(t.password===t.confirm_password){this.commandRunning=!0;try{await this.request("user.create_user",{username:t.username,password:t.password,session_token:this.sessionToken})}finally{this.commandRunning=!1}this.notify({text:"User "+t.username+" created",image:{iconClass:"fas fa-check"}}),this.$refs.addUserModal.close(),await this.refresh()}else this.notify({title:"Unable to create user",text:"Please check that the passwords match",error:!0,image:{iconClass:"fas fa-times"}})},async changePassword(e){e.preventDefault();const t=[...this.$refs.changePasswordForm.querySelectorAll("input[name]")].reduce(((e,t)=>(e[t.name]=t.value,e)),{});if(t.new_password!==t.confirm_new_password)return void this.notify({title:"Unable to update password",text:"Please check that the passwords match",error:!0,image:{iconClass:"fas fa-times"}});this.commandRunning=!0;let s=!1;try{s=await this.request("user.update_password",{username:t.username,old_password:t.password,new_password:t.new_password})}finally{this.commandRunning=!1}s?(this.$refs.changePasswordModal.close(),this.notify({text:"Password successfully updated",image:{iconClass:"fas fa-check"}})):this.notify({title:"Unable to update password",text:"The current password is incorrect",error:!0,image:{iconClass:"fas fa-times"}})},async deleteUser(e){if(confirm("Are you sure that you want to remove the user "+e.username+"?")){this.commandRunning=!0;try{await this.request("user.delete_user",{username:e.username,session_token:this.sessionToken})}finally{this.commandRunning=!1}this.notify({text:"User "+e.username+" removed",image:{iconClass:"fas fa-check"}}),await this.refresh()}}},mounted(){this.refresh()}};const ye=(0,Q.Z)(be,[["render",ge]]);var ke=ye,_e={name:"Settings",components:{Users:ke,Token:te},mixins:[G.Z],data(){return{selectedView:"users",currentUser:null,sessionToken:null}},methods:{async refresh(){this.sessionToken=this.getCookies()["session_token"],this.currentUser=await this.request("user.get_user_by_session",{session_token:this.sessionToken})}},mounted(){this.refresh()}};const xe=(0,Q.Z)(_e,[["render",u]]);var Ce=xe},3379:function(e,t,s){var n={"./Camera/Index":[5528,2989,5528],"./CameraAndroidIpcam/Index":[6739,6739],"./CameraCv/Index":[8184,2989,8184],"./CameraFfmpeg/Index":[5111,2989,5111],"./CameraGstreamer/Index":[699,2989,699],"./CameraIrMlx90640/Index":[9895,2989,9895],"./CameraPi/Index":[4548,2989,4548],"./Execute/Index":[7643,7643],"./Light/Index":[747,1474,8938,747],"./LightHue/Index":[3674,1474,8938,747,3674],"./Media/Index":[4196,8938,9978,8589,4196],"./MediaMplayer/Index":[6509,8938,9978,8589,4196,6509],"./MediaMpv/Index":[5895,8938,9978,8589,4196,5895],"./MediaOmxplayer/Index":[9633,8938,9978,8589,4196,9633],"./MediaVlc/Index":[767,8938,9978,8589,4196,767],"./Music/Index":[6833,8938,9978,6833],"./MusicMpd/Index":[3249,8938,9978,6833,3249],"./MusicSnapcast/Index":[2790,1474,8938,2790],"./MusicSpotify/Index":[9369,8938,9978,6833,9369],"./Rtorrent/Index":[2820,8589,6899,2820],"./Settings/Index":[5392],"./Sound/Index":[5193,5193],"./Switches/Index":[4276,4276],"./Switches/LightHue/Index":[2844,1474,6590,2844],"./Switches/Smartthings/Index":[9196,1474,6590,9196],"./Switches/SwitchTplink/Index":[3785,1474,6590,3785],"./Switches/SwitchWemo/Index":[5210,1474,6590,5210],"./Switches/Switchbot/Index":[9694,1474,6590,9694],"./Switches/SwitchbotBluetooth/Index":[9694,1474,6590,9694],"./Switches/ZigbeeMqtt/Index":[5466,1474,6590,5466],"./Switches/Zwave/Index":[7262,1474,6590,7262],"./Switches/ZwaveMqtt/Index":[2380,1474,6590,2380],"./Torrent/Index":[9299,8589,6899,9299],"./Tts/Index":[2466,4021,2466],"./TtsGoogle/Index":[1938,4021,1938],"./TvSamsungWs/Index":[615,615],"./ZigbeeMqtt/Index":[4604,1474,8938,4604],"./Zwave/Index":[6027,1474,8938,4764,6027],"./ZwaveMqtt/Index":[2362,1474,8938,4764,2362]};function i(e){if(!s.o(n,e))return Promise.resolve().then((function(){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}));var t=n[e],i=t[0];return Promise.all(t.slice(1).map(s.e)).then((function(){return s(i)}))}i.keys=function(){return Object.keys(n)},i.id=3379,e.exports=i},6725:function(e,t,s){var n={"./Calendar/Index":[345,345],"./Camera/Index":[2346,2346],"./Component/Index":[5824,1474,8938,5824],"./DateTime/Index":[1595,9575,1595],"./DateTimeWeather/Index":[5779,1798,9575,5779],"./ImageCarousel/Index":[6003,1798,9575,6003],"./Music/Index":[6013,6013],"./Plugin/Index":[4826,4826],"./RssNews/Index":[7420,7420],"./Weather/Index":[1798,1798]};function i(e){if(!s.o(n,e))return Promise.resolve().then((function(){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}));var t=n[e],i=t[0];return Promise.all(t.slice(1).map(s.e)).then((function(){return s(i)}))}i.keys=function(){return Object.keys(n)},i.id=6725,e.exports=i}},t={};function s(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,s),a.exports}s.m=e,function(){var e=[];s.O=function(t,n,i,a){if(!n){var o=1/0;for(d=0;d<e.length;d++){n=e[d][0],i=e[d][1],a=e[d][2];for(var r=!0,l=0;l<n.length;l++)(!1&a||o>=a)&&Object.keys(s.O).every((function(e){return s.O[e](n[l])}))?n.splice(l--,1):(r=!1,a<o&&(o=a));if(r){e.splice(d--,1);var c=i();void 0!==c&&(t=c)}}return t}a=a||0;for(var d=e.length;d>0&&e[d-1][2]>a;d--)e[d]=e[d-1];e[d]=[n,i,a]}}(),function(){s.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return s.d(t,{a:t}),t}}(),function(){s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}}(),function(){s.f={},s.e=function(e){return Promise.all(Object.keys(s.f).reduce((function(t,n){return s.f[n](e,t),t}),[]))}}(),function(){s.u=function(e){return"static/js/"+e+"."+{345:"668e4cb2",615:"27cc8f9e",699:"5a760926",747:"21f6bf7b",767:"c8cb94e4",1474:"cd648f8f",1595:"d3f3ba5b",1798:"e72decae",1938:"1f474567",2346:"4e0afde3",2362:"84f3ec2e",2380:"73b1a20d",2466:"575a0b76",2790:"bf6f297a",2820:"be1f76ae",2844:"357b0781",2989:"bff9282e",3249:"fd3db1b0",3674:"3c7517b4",3785:"8c572e27",4021:"56f5f27b",4196:"630e670c",4276:"728421b8",4548:"ec5c28d2",4604:"ac359b97",4764:"55084bfb",4826:"5f8aa5e8",5111:"8df28fdf",5193:"5035fdb1",5210:"fae85e4c",5466:"2c2a80df",5528:"3b6af320",5779:"a25186e7",5824:"0dd40d21",5895:"6d58227e",6003:"faab4096",6013:"0f59b66b",6027:"dc523874",6509:"a6fd64ee",6590:"e9c70586",6739:"ab19c203",6833:"cc55832d",6899:"0f42d5c8",7262:"b0ebadee",7420:"a460b393",7643:"802b7ba8",8184:"f06cf9d8",8589:"6ec60bee",8938:"64d1bec5",9196:"5e4f2f1b",9299:"cba36f7a",9369:"ab5c8c8c",9575:"2bc3a9be",9633:"5151828a",9694:"dfa28ffb",9895:"fa612682",9978:"96bd5026"}[e]+".js"}}(),function(){s.miniCssF=function(e){return"static/css/"+e+"."+{345:"39a334e8",615:"17632d8f",747:"9d7d27e7",1474:"75891517",1798:"f703a14d",2346:"dd5b7fec",2380:"a55977a1",2790:"b7703d2a",2844:"eabbb568",2989:"6de074b2",3785:"85dd63a7",4021:"f58ac074",4196:"8681eb9f",4276:"008136f7",4604:"e0765efd",4764:"837012fe",4826:"c0b8e5bf",5193:"f7c1a776",5210:"2082bfa6",5466:"68827648",5779:"0cad5256",5824:"f7a25bb6",6003:"76b4d677",6013:"e5066be6",6590:"e2b4dcb4",6739:"f5527e3f",6833:"9c099b40",6899:"85849319",7262:"e379f31b",7420:"5775e7e6",7643:"74797fcd",8589:"c4c7f81a",8938:"2bbd3b5d",9196:"006b678a",9575:"34cea1a0",9694:"20e4266c",9978:"f0a3a6c5"}[e]+".css"}}(),function(){s.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}()}(),function(){s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}(),function(){var e={},t="platypush:";s.l=function(n,i,a,o){if(e[n])e[n].push(i);else{var r,l;if(void 0!==a)for(var c=document.getElementsByTagName("script"),d=0;d<c.length;d++){var u=c[d];if(u.getAttribute("src")==n||u.getAttribute("data-webpack")==t+a){r=u;break}}r||(l=!0,r=document.createElement("script"),r.charset="utf-8",r.timeout=120,s.nc&&r.setAttribute("nonce",s.nc),r.setAttribute("data-webpack",t+a),r.src=n),e[n]=[i];var h=function(t,s){r.onerror=r.onload=null,clearTimeout(p);var i=e[n];if(delete e[n],r.parentNode&&r.parentNode.removeChild(r),i&&i.forEach((function(e){return e(s)})),t)return t(s)},p=setTimeout(h.bind(null,void 0,{type:"timeout",target:r}),12e4);r.onerror=h.bind(null,r.onerror),r.onload=h.bind(null,r.onload),l&&document.head.appendChild(r)}}}(),function(){s.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}}(),function(){s.p="/"}(),function(){var e=function(e,t,s,n){var i=document.createElement("link");i.rel="stylesheet",i.type="text/css";var a=function(a){if(i.onerror=i.onload=null,"load"===a.type)s();else{var o=a&&("load"===a.type?"missing":a.type),r=a&&a.target&&a.target.href||t,l=new Error("Loading CSS chunk "+e+" failed.\n("+r+")");l.code="CSS_CHUNK_LOAD_FAILED",l.type=o,l.request=r,i.parentNode.removeChild(i),n(l)}};return i.onerror=i.onload=a,i.href=t,document.head.appendChild(i),i},t=function(e,t){for(var s=document.getElementsByTagName("link"),n=0;n<s.length;n++){var i=s[n],a=i.getAttribute("data-href")||i.getAttribute("href");if("stylesheet"===i.rel&&(a===e||a===t))return i}var o=document.getElementsByTagName("style");for(n=0;n<o.length;n++){i=o[n],a=i.getAttribute("data-href");if(a===e||a===t)return i}},n=function(n){return new Promise((function(i,a){var o=s.miniCssF(n),r=s.p+o;if(t(o,r))return i();e(n,r,i,a)}))},i={2143:0};s.f.miniCss=function(e,t){var s={345:1,615:1,747:1,1474:1,1798:1,2346:1,2380:1,2790:1,2844:1,2989:1,3785:1,4021:1,4196:1,4276:1,4604:1,4764:1,4826:1,5193:1,5210:1,5466:1,5779:1,5824:1,6003:1,6013:1,6590:1,6739:1,6833:1,6899:1,7262:1,7420:1,7643:1,8589:1,8938:1,9196:1,9575:1,9694:1,9978:1};i[e]?t.push(i[e]):0!==i[e]&&s[e]&&t.push(i[e]=n(e).then((function(){i[e]=0}),(function(t){throw delete i[e],t})))}}(),function(){var e={2143:0};s.f.j=function(t,n){var i=s.o(e,t)?e[t]:void 0;if(0!==i)if(i)n.push(i[2]);else if(/^((29|85)89|1474|4021|6590|8938|9575)$/.test(t))e[t]=0;else{var a=new Promise((function(s,n){i=e[t]=[s,n]}));n.push(i[2]=a);var o=s.p+s.u(t),r=new Error,l=function(n){if(s.o(e,t)&&(i=e[t],0!==i&&(e[t]=void 0),i)){var a=n&&("load"===n.type?"missing":n.type),o=n&&n.target&&n.target.src;r.message="Loading chunk "+t+" failed.\n("+a+": "+o+")",r.name="ChunkLoadError",r.type=a,r.request=o,i[1](r)}};s.l(o,l,"chunk-"+t,t)}},s.O.j=function(t){return 0===e[t]};var t=function(t,n){var i,a,o=n[0],r=n[1],l=n[2],c=0;if(o.some((function(t){return 0!==e[t]}))){for(i in r)s.o(r,i)&&(s.m[i]=r[i]);if(l)var d=l(s)}for(t&&t(n);c<o.length;c++)a=o[c],s.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return s.O(d)},n=self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))}();var n=s.O(void 0,[4998],(function(){return s(9646)}));n=s.O(n)})();
//# sourceMappingURL=app.b00986ef.js.map