platypush/platypush/backend/http/webapp/dist/static/js/app.257a2f22.js

2 lines
51 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)()},5736: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)("Ntfy"),h=(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),o.hasNtfy?((0,i.wg)(),(0,i.j4)(u,{key:3,ref:"ntfy"},null,512)):(0,i.kq)("",!0),(0,i.Wm)(h)],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"],f={key:3,class:"fa fa-exclamation"},m={key:4,class:"fa fa-times"},g=["textContent"],v=["innerHTML"],w=["textContent"],y=["innerHTML"];function b(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",f)):s.error?((0,i.wg)(),(0,i.iD)("i",m)):(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,v)):(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,w)):(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,y)):(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",b],["__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(6813);function U(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("div")}var P=s(5250),M={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 N=(0,_.Z)(M,[["render",U]]);var $=N;const q={class:"assistant-modal"},O={class:"icon"},j={key:0,class:"fa fa-bell"},Z={key:1,class:"fa fa-volume-up"},E={key:2,class:"fa fa-comment-dots"},z={key:3,class:"fa fa-microphone"},W={class:"text"},R={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",q,[(0,i.Wm)(r,{ref:"assistantModal"},{default:(0,i.w5)((()=>[(0,i._)("div",O,[a.state.alerting?((0,i.wg)(),(0,i.iD)("i",j)):a.state.responding?((0,i.wg)(),(0,i.iD)("i",Z)):a.state.speechRecognized?((0,i.wg)(),(0,i.iD)("i",E)):((0,i.wg)(),(0,i.iD)("i",z))]),(0,i._)("div",W,[a.state.listening?((0,i.wg)(),(0,i.iD)("div",R,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(8453),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:"Ntfy",mixins:[T.Z],methods:{onMessage(e){this.notify({title:e.title,text:e.message,image:{icon:"bell"}})}},mounted(){this.subscribe(this.onMessage,null,"platypush.message.event.ntfy.NotificationEvent")}};const te=(0,_.Z)(ee,[["render",Q]]);var se=te;function ne(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("div")}var ie={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 ae=(0,_.Z)(ie,[["render",ne]]);var oe=ae,re={name:"App",mixins:[T.Z],components:{Pushbullet:oe,Ntfy:se,Notifications:S,Events:$,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)},hasNtfy(){return this.hasWebsocket&&"ntfy"in this.config}},methods:{onNotification(e){this.$refs.notifications.create(e)},async initConfig(){this.config=await this.request("config.get",{},6e4,!1),this.userAuthenticated=!0}},created(){this.initConfig()},mounted(){P.$.on("notification-create",this.onNotification)}};const le=(0,_.Z)(re,[["render",a]]);var ce=le,de=s(2201);function ue(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 he=s(1232);function pe(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 fe={name:"Row",props:{class:{type:String,required:!1,default:""},style:{type:String,required:!1,default:""}},computed:{classes(){return this.class}}};const me=(0,_.Z)(fe,[["render",pe],["__scopeId","data-v-1b4663f2"]]);var ge=me;function ve(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 we={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 ye=(0,_.Z)(we,[["render",ve],["__scopeId","data-v-5df52982"]]);var be=ye,ke={name:"Dashboard",mixins:[T.Z],components:{Widget:be,Loading:he.Z,Row:ge},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 _e=(0,_.Z)(ke,[["render",ue],["__scopeId","data-v-cefcfdfc"]]);var xe=_e;function Ce(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("h1",null,"Object not found")}var De={name:"NotFound"};const Ie=(0,_.Z)(De,[["render",Ce]]);var Se=Ie;const Te=e=>((0,i.dD)("data-v-16cef6aa"),e=e(),(0,i.Cn)(),e),Ue={class:"login-container"},Pe={class:"login",method:"POST"},Me=(0,i.uE)('<div class="header" data-v-16cef6aa><span class="logo" data-v-16cef6aa></span><span class="text" data-v-16cef6aa>Platypush</span></div><div class="row" data-v-16cef6aa><label data-v-16cef6aa><input type="text" name="username" placeholder="Username" data-v-16cef6aa></label></div><div class="row" data-v-16cef6aa><label data-v-16cef6aa><input type="password" name="password" placeholder="Password" data-v-16cef6aa></label></div>',3),Ne={key:0,class:"row"},$e=Te((()=>(0,i._)("label",null,[(0,i._)("input",{type:"password",name:"confirm_password",placeholder:"Confirm password"})],-1))),qe=[$e],Oe={class:"row buttons"},je=["value"],Ze=Te((()=>(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 Ee(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("div",Ue,[(0,i._)("form",Pe,[Me,o._register?((0,i.wg)(),(0,i.iD)("div",Ne,qe)):(0,i.kq)("",!0),(0,i._)("div",Oe,[(0,i._)("input",{type:"submit",class:"btn btn-primary",value:o._register?"Register":"Login"},null,8,je)]),Ze])])}var ze={name:"Login",mixins:[T.Z],props:{register:{type:Boolean,required:!1,default:!1}},computed:{_register(){return this.parseBoolean(this.register)}}};const We=(0,_.Z)(ze,[["render",Ee],["__scopeId","data-v-16cef6aa"]]);var Re=We;function Le(e,t,s,n,a,o){const r=(0,i.up)("Login");return(0,i.wg)(),(0,i.j4)(r,{register:!0})}var Ae={name:"Register",mixins:[Re],components:{Login:Re},props:{register:{type:Boolean,required:!1,default:!0}}};const Ve=(0,_.Z)(Ae,[["render",Le]]);var He=Ve;const Fe={key:2,class:"canvas"},Be={class:"panel"},Ye={key:3,class:"canvas"};function Ke(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",Fe,[(0,i._)("div",Be,[(0,i.Wm)(d)])])):((0,i.wg)(),(0,i.iD)("div",Ye,[((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 Ge=e=>((0,i.dD)("data-v-69a507f4"),e=e(),(0,i.Cn)(),e),Je=Ge((()=>(0,i._)("i",{class:"fas fa-bars"},null,-1))),Xe=["textContent"],Qe={class:"plugins"},et=["title","onClick"],tt=["href"],st={class:"icon"},nt=["src"],it={key:2,class:"fas fa-puzzle-piece"},at=["textContent"],ot={class:"footer"},rt={href:"/#settings"},lt=Ge((()=>(0,i._)("span",{class:"icon"},[(0,i._)("i",{class:"fa fa-cog"})],-1))),ct={key:0,class:"name"},dt={href:"/logout"},ut=Ge((()=>(0,i._)("span",{class:"icon"},[(0,i._)("i",{class:"fas fa-sign-out-alt"})],-1))),ht={key:0,class:"name"};function pt(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)},[Je,s.hostname?((0,i.wg)(),(0,i.iD)("span",{key:0,class:"hostname",textContent:(0,l.zw)(s.hostname)},null,8,Xe)):(0,i.kq)("",!0)]),(0,i._)("ul",Qe,[((0,i.wg)(!0),(0,i.iD)(i.HY,null,(0,i.Ko)(o.panelNames,(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",st,[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,nt)):((0,i.wg)(),(0,i.iD)("i",it))]),a.collapsed?(0,i.kq)("",!0):((0,i.wg)(),(0,i.iD)("span",{key:0,class:"name",textContent:(0,l.zw)("entities"==e?"Home":e)},null,8,at))],8,tt)],10,et)))),128))]),(0,i._)("ul",ot,[(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",rt,[lt,a.collapsed?(0,i.kq)("",!0):((0,i.wg)(),(0,i.iD)("span",ct,"Settings"))])],2),(0,i._)("li",{title:"Logout",onClick:t[2]||(t[2]=e=>o.onItemClick("logout"))},[(0,i._)("a",dt,[ut,a.collapsed?(0,i.kq)("",!0):((0,i.wg)(),(0,i.iD)("span",ht,"Logout"))])])])],2)}var ft=s(1359),mt={name:"Nav",emits:["select"],mixins:[T.Z],props:{panels:{type:Object,required:!0},selectedPanel:{type:String},hostname:{type:String}},computed:{panelNames(){let e=Object.keys(this.panels);const t=e.indexOf("entities");return t>=0?["entities"].concat(e.slice(0,t).concat(e.slice(t+1)).sort()):e.sort()}},methods:{onItemClick(e){this.$emit("select",e),this.collapsed=!0}},data(){return{collapsed:!0,icons:ft,host:null}}};const gt=(0,_.Z)(mt,[["render",pt],["__scopeId","data-v-69a507f4"]]);var vt=gt,wt=s(5392),yt={name:"Panel",mixins:[T.Z],components:{Settings:wt["default"],Nav:vt,Loading:he.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.]+)[?]?(.*)"),t=e?e[1]:"entities";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.entities={}}},async mounted(){this.loading=!0;try{await this.parseConfig(),this.initPanels(),this.initSelectedPanel()}finally{this.loading=!1}}};const bt=(0,_.Z)(yt,[["render",Ke],["__scopeId","data-v-344b6d1a"]]);var kt=bt;const _t={key:1,class:"canvas"};function xt(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",_t,[((0,i.wg)(),(0,i.j4)((0,i.LL)(a.component),{config:a.config,"plugin-name":o.pluginName},null,8,["config","plugin-name"]))]))])}var Ct={name:"Panel",mixins:[T.Z],components:{Settings:wt["default"],Nav:vt,Loading:he.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 Dt=(0,_.Z)(Ct,[["render",xt],["__scopeId","data-v-67571c94"]]);var It=Dt;const St=[{path:"/",name:"Panel",component:kt},{path:"/dashboard/:name",name:"Dashboard",component:xe},{path:"/plugin/:plugin",name:"Plugin",component:It},{path:"/login",name:"Login",component:Re},{path:"/register",name:"Register",component:He},{path:"/:catchAll(.*)",component:Se}],Tt=(0,de.p7)({history:(0,de.PO)(),routes:St});var Ut=Tt;const Pt=(0,n.ri)(ce);Pt.config.globalProperties._config=window.config,Pt.use(Ut).mount("#app")},6813:function(e,t,s){"use strict";s.d(t,{Z:function(){return N}});var n=s(9669),i=s.n(n),a={name:"Api",methods:{execute(e,t=6e4,s=!0){const n={};return"target"in e&&e["target"]||(e["target"]="localhost"),"type"in e&&e["type"]||(e["type"]="request"),t&&(n.timeout=t),new Promise(((t,a)=>{i().post("/execute",e,n).then((e=>{if(e=e.data.response,e.errors?.length){const t=e.errors?.[0]||e;this.notify({text:t,error:!0}),a(t)}else t(e.output)})).catch((e=>{s&&this.notify({text:e,error:!0}),a(e)}))}))},request(e,t={},s=6e4,n=!0){return this.execute({type:"request",action:e,args:t},s,n)}}};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,f=(s(2801),s(5250)),m={name:"Events",computed:{_eventsReady(){return this.$root.$refs.events?.initialized}},methods:{subscribe(e,t,...s){const n=()=>{f.$.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){f.$.emit("unsubscribe",e)},generateId(){return btoa([...Array(11).keys()].map((()=>String.fromCharCode(Math.round(255*Math.random())))))}}};const g=m;var v=g,w={name:"Notification",methods:{notify(e){f.$.emit("notification-create",e)},warn(e){this.notify({text:e,warning:!0})},error(e){throw this.notify({text:e,error:!0}),e}}};const y=w;var b=y,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:"Text",methods:{capitalize(e){return e?.length?e.charAt(0).toUpperCase()+e.slice(1):e},prettify(e){return e.split("_").map((e=>this.capitalize(e))).join(" ")}}};const D=C;var I=D,S={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 T=S;var U=T,P={name:"Utils",mixins:[r,d,b,v,p,x,I,U]};const M=P;var N=M},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},8453:function(e,t,s){"use strict";s.d(t,{Z:function(){return h}});var n=s(6252),i=s(3577);const a=["id"],o=["textContent"],r={class:"body"};function l(e,t,s,l,c,d){return(0,n.wg)(),(0,n.iD)("div",{class:(0,i.C_)(["modal-container fade-in",{hidden:!c.isVisible}]),id:s.id,style:(0,i.j5)({"--z-index":d.zIndex}),onClick:t[2]||(t[2]=(...e)=>d.close&&d.close(...e))},[(0,n._)("div",{class:(0,i.C_)(["modal",e.$attrs.class])},[(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,o)):(0,n.kq)("",!0),(0,n._)("div",r,[(0,n.WI)(e.$slots,"default",{onModalClose:t[0]||(t[0]=(...e)=>d.close&&d.close(...e))},void 0,!0)])],4)],2)],14,a)}var c={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)}}},d=s(3744);const u=(0,d.Z)(c,[["render",l],["__scopeId","data-v-7d1f6e8b"]]);var h=u},5771:function(e,t,s){"use strict";s.d(t,{Z:function(){return f}});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},keepOpenOnItemClick:{type:Boolean,default:!1}},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-21bf0316"]]);var f=p},9015:function(e,t,s){"use strict";s.d(t,{Z:function(){return h}});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){const d=(0,n.up)("Icon");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?.length||s.iconUrl?.length?((0,n.wg)(),(0,n.iD)("div",a,[(0,n.Wm)(d,{class:(0,i.C_)(s.iconClass),url:s.iconUrl},null,8,["class","url"])])):(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=s(1478),c={name:"DropdownItem",components:{Icon:l.Z},props:{iconClass:{type:String},iconUrl:{type:String},text:{type:String},disabled:{type:Boolean,default:!1},itemClass:{type:String}},methods:{clicked(e){if(this.disabled)return!1;this.$parent.$emit("click",e),this.$parent.keepOpenOnItemClick||(this.$parent.visible=!1)}}},d=s(3744);const u=(0,d.Z)(c,[["render",r],["__scopeId","data-v-0a3cac88"]]);var h=u},1478:function(e,t,s){"use strict";s.d(t,{Z:function(){return u}});var n=s(6252),i=s(3577);const a={class:"icon-container"},o=["src","alt"];function r(e,t,s,r,l,c){return(0,n.wg)(),(0,n.iD)("div",a,[s.url?.length?((0,n.wg)(),(0,n.iD)("img",{key:0,class:"icon",src:s.url,alt:s.alt},null,8,o)):c.className?.length?((0,n.wg)(),(0,n.iD)("i",{key:1,class:(0,i.C_)(["icon",c.className]),style:(0,i.j5)({color:s.color})},null,6)):(0,n.kq)("",!0)])}var l={props:{class:{type:String},url:{type:String},color:{type:String,default:""},alt:{type:String,default:""}},computed:{className(){return this.class}}},c=s(3744);const d=(0,c.Z)(l,[["render",r],["__scopeId","data-v-706a3bd1"]]);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"),f=(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)(f,{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 f={class:"token-container"},m={class:"token-container"},g=(0,n.Uk)(" This is your generated token. Treat it carefully and do not share it with untrusted parties."),v=(0,n._)("br",null,null,-1),w=(0,n.Uk)(" Also, make sure to save it - it WILL NOT be displayed again. "),y=["textContent"],b={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 "),M=(0,n.Uk)("X-Token"),N=(0,n.Uk)(" header;"),$=(0,n.Uk)("Specify it as a URL parameter: "),q=(0,n.Uk)("http://site:8008/execute?token=..."),O=(0,n.Uk)(";"),j=(0,n.Uk)("Specify it on the body of your JSON request: "),Z=(0,n.Uk)('{"type":"request", "action", "...", "token":"..."}'),E=(0,n.Uk)("."),z=(0,n.Uk)(" Confirm your credentials in order to generate a new token. "),W={class:"form-container"},R=(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",f,[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",m,[(0,n._)("label",null,[g,v,w,(0,n._)("textarea",{class:"token",textContent:(0,h.zw)(a.token),onFocus:t[0]||(t[0]=(...e)=>o.onTokenSelect&&o.onTokenSelect(...e))},null,40,y)])])])),_:1},512),(0,n._)("div",b,[(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)((()=>[M])),_:1}),N]),(0,n._)("li",null,[$,(0,n.Wm)(c,null,{default:(0,n.w5)((()=>[q])),_:1}),O]),(0,n._)("li",null,[j,(0,n.Wm)(c,null,{default:(0,n.w5)((()=>[Z])),_:1}),E])]),z]),(0,n._)("div",W,[(0,n._)("form",{onSubmit:t[1]||(t[1]=(0,p.iM)(((...e)=>o.generateToken&&o.generateToken(...e)),["prevent"])),ref:"generateTokenForm"},[(0,n._)("label",null,[R,(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(6813),J=s(8453),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"],fe=["textContent"],me={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,fe),(0,n._)("div",me,[(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 ve=s(5771),we=s(9015),ye={name:"Users",components:{DropdownItem:we.Z,Loading:K.Z,Modal:J.Z,Dropdown:ve.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 be=(0,Q.Z)(ye,[["render",ge]]);var ke=be,_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],"./Entities/Index":[914,9892],"./Execute/Index":[7643,7643],"./Light/Index":[747,3490,3803,747],"./LightHue/Index":[3674,3490,3803,747,3674],"./Media/Index":[4196,3803,9978,8589,4196],"./MediaMplayer/Index":[6509,3803,9978,8589,4196,6509],"./MediaMpv/Index":[5895,3803,9978,8589,4196,5895],"./MediaOmxplayer/Index":[9633,3803,9978,8589,4196,9633],"./MediaVlc/Index":[767,3803,9978,8589,4196,767],"./Music/Index":[6833,3803,9978,6833],"./MusicMpd/Index":[3249,3803,9978,6833,3249],"./MusicSnapcast/Index":[2790,3490,3803,2790],"./MusicSpotify/Index":[9369,3803,9978,6833,9369],"./Rtorrent/Index":[2820,8589,6899,2820],"./Settings/Index":[5392],"./Sound/Index":[5193,5193],"./Switches/Index":[4276,4276],"./Switches/LightHue/Index":[2844,3490,6590,2844],"./Switches/Smartthings/Index":[9196,3490,6590,9196],"./Switches/SwitchTplink/Index":[3785,3490,6590,3785],"./Switches/SwitchWemo/Index":[5210,3490,6590,5210],"./Switches/Switchbot/Index":[9694,3490,6590,9694],"./Switches/SwitchbotBluetooth/Index":[9694,3490,6590,9694],"./Switches/ZigbeeMqtt/Index":[5466,3490,6590,5466],"./Switches/Zwave/Index":[7262,3490,6590,7262],"./Switches/ZwaveMqtt/Index":[2380,3490,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,3490,3803,4604],"./Zwave/Index":[6027,3490,3803,5810,6027],"./ZwaveMqtt/Index":[2362,3490,3803,5810,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,3490,3803,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},1359:function(e){"use strict";e.exports=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"},"entities":{"class":"fa fa-home"},"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"},"smartthings":{"imgUrl":"/icons/smartthings.png"},"switches":{"class":"fas fa-toggle-on"},"switch.switchbot":{"class":"fas fa-toggle-on"},"switch.tplink":{"class":"fas fa-toggle-on"},"switchbot":{"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"}}')}},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(){var e,t=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__};s.t=function(n,i){if(1&i&&(n=this(n)),8&i)return n;if("object"===typeof n&&n){if(4&i&&n.__esModule)return n;if(16&i&&"function"===typeof n.then)return n}var a=Object.create(null);s.r(a);var o={};e=e||[null,t({}),t([]),t(t)];for(var r=2&i&&n;"object"==typeof r&&!~e.indexOf(r);r=t(r))Object.getOwnPropertyNames(r).forEach((function(e){o[e]=function(){return n[e]}}));return o["default"]=function(){return n},s.d(a,o),a}}(),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+"."+{65:"a4e6662a",345:"8d14f37b",518:"89a856bf",615:"25a0ebcb",699:"cf8f2194",747:"5f10a676",767:"32c26b46",1155:"1d3f7c87",1595:"cf573de8",1798:"2ea76630",1938:"1dc95872",2346:"9a487752",2362:"f07ef3c1",2380:"292bff03",2466:"633bb83f",2790:"73c2ca0a",2820:"07ee3664",2844:"e8c1790f",2989:"fa06c8b8",3249:"a2010c2d",3490:"d482e29b",3499:"7b46c041",3674:"a57eb557",3785:"940990df",3803:"9202f4bf",4021:"a3380d38",4196:"cec98eba",4276:"51717631",4548:"686dd66b",4604:"78aed65e",4826:"64f0df2a",4981:"c4835180",5111:"d348fed1",5193:"1de6bb98",5207:"b6625280",5210:"d6ee4d6c",5466:"c08dda4e",5528:"f33f80c6",5779:"45aee2fa",5810:"d365373f",5824:"7f51ae20",5895:"bc039cca",6003:"c76e25e0",6013:"5c85c65a",6027:"54f532a7",6509:"9ca36429",6590:"a024a679",6739:"14f222c1",6833:"135ef1e4",6899:"d74c1b00",7262:"6193bf34",7420:"e53d9d48",7643:"48f991b1",8184:"6859ae89",8589:"21ae83d2",8729:"19ca396b",9196:"462b659b",9299:"710819a1",9369:"f7907b71",9575:"fb8eab70",9633:"23b95cb0",9694:"6487ada9",9892:"966b4879",9895:"f9b70895",9978:"e4c02542"}[e]+".js"}}(),function(){s.miniCssF=function(e){return"static/css/"+e+"."+{65:"d6cbc229",345:"0d938275",518:"44f63b6e",615:"be187f79",747:"3c45f7ef",1155:"3c072b53",1798:"5047113b",2346:"f042c092",2380:"7e6cb2ed",2790:"8a938bab",2844:"fa1de455",2989:"a4270756",3490:"3516cb6e",3785:"5ed5a4df",3803:"071120e4",4021:"0331be37",4196:"f1fcf8f5",4276:"07502cf2",4604:"34b220bc",4826:"437fa334",4981:"8830c3ce",5193:"7f3c2173",5207:"831746a7",5210:"435161f9",5466:"fb0c1b5f",5779:"b285a776",5810:"0aa0c9b4",5824:"f9f7ad29",6003:"0868fde4",6013:"2141ef7f",6590:"778aa4c7",6739:"649d4b27",6833:"c53bec53",6899:"f3d46bda",7262:"7ac2a7a5",7420:"e42d1496",7643:"e25374a8",8589:"459f0f41",8729:"f98d84da",9196:"18347c3c",9575:"eba29f96",9694:"509f8cb5",9892:"68b29dbb",9978:"13387da1"}[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={65:1,345:1,518:1,615:1,747:1,1155:1,1798:1,2346:1,2380:1,2790:1,2844:1,2989:1,3490:1,3785:1,3803:1,4021:1,4196:1,4276:1,4604:1,4826:1,4981:1,5193:1,5207:1,5210:1,5466:1,5779:1,5810:1,5824:1,6003:1,6013:1,6590:1,6739:1,6833:1,6899:1,7262:1,7420:1,7643:1,8589:1,8729:1,9196:1,9575:1,9694:1,9892: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(/^((298|858|872)9|(34|65)90|3803|4021|4981|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(5736)}));n=s.O(n)})();
//# sourceMappingURL=app.257a2f22.js.map