2 lines
53 KiB
JavaScript
2 lines
53 KiB
JavaScript
(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)();i.publishEntity=e=>{i.emit("entity-update",e)},i.onEntity=e=>{i.on("entity-update",e)},i.publishNotification=e=>{i.emit("notification-create",e)},i.onNotification=e=>{i.on("notification-create",e)}},3718: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"],b=["innerHTML"],y=["textContent"],v=["innerHTML"];function w(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,b)):(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,y)):(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,v)):(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",w],["__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 T=I,S=s(6813);function U(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("div")}var N=s(5250),P={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(){N.$.on("subscribe",this.subscribe),N.$.on("unsubscribe",this.unsubscribe),this.init()}};const j=(0,_.Z)(P,[["render",U]]);var M=j;const $={class:"assistant-modal"},q={class:"icon"},O={key:0,class:"fa fa-bell"},Z={key:1,class:"fa fa-volume-up"},E={key:2,class:"fa fa-comment-dots"},W={key:3,class:"fa fa-microphone"},z={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",$,[(0,i.Wm)(r,{ref:"assistantModal"},{default:(0,i.w5)((()=>[(0,i._)("div",q,[a.state.alerting?((0,i.wg)(),(0,i.iD)("i",O)):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",W))]),(0,i._)("div",z,[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:[S.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:[S.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:[S.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:[S.Z],components:{Pushbullet:oe,Ntfy:se,Notifications:T,Events:M,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(){N.$.onNotification(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(2262),pe=s(1232);function fe(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 me={name:"Row",props:{class:{type:String,required:!1,default:""},style:{type:String,required:!1,default:""}},computed:{classes(){return this.class}}};const ge=(0,_.Z)(me,[["render",fe],["__scopeId","data-v-1b4663f2"]]);var be=ge;function ye(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 ve={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 we=(0,_.Z)(ve,[["render",ye],["__scopeId","data-v-5df52982"]]);var ke=we,_e={name:"Dashboard",mixins:[S.Z],components:{Widget:ke,Loading:pe.Z,Row:be},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,he.XI)((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.notifyError(`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 xe=(0,_.Z)(_e,[["render",ue],["__scopeId","data-v-54e0248a"]]);var Ce=xe;function De(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("h1",null,"Object not found")}var Ie={name:"NotFound"};const Te=(0,_.Z)(Ie,[["render",De]]);var Se=Te;const Ue=e=>((0,i.dD)("data-v-16cef6aa"),e=e(),(0,i.Cn)(),e),Ne={class:"login-container"},Pe={class:"login",method:"POST"},je=(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),Me={key:0,class:"row"},$e=Ue((()=>(0,i._)("label",null,[(0,i._)("input",{type:"password",name:"confirm_password",placeholder:"Confirm password"})],-1))),qe=[$e],Oe={class:"row buttons"},Ze=["value"],Ee=Ue((()=>(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 We(e,t,s,n,a,o){return(0,i.wg)(),(0,i.iD)("div",Ne,[(0,i._)("form",Pe,[je,o._register?((0,i.wg)(),(0,i.iD)("div",Me,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,Ze)]),Ee])])}var ze={name:"Login",mixins:[S.Z],props:{register:{type:Boolean,required:!1,default:!1}},computed:{_register(){return this.parseBoolean(this.register)}}};const Re=(0,_.Z)(ze,[["render",We],["__scopeId","data-v-16cef6aa"]]);var Le=Re;function Ae(e,t,s,n,a,o){const r=(0,i.up)("Login");return(0,i.wg)(),(0,i.j4)(r,{register:!0})}var Ve={name:"Register",mixins:[Le],components:{Login:Le},props:{register:{type:Boolean,required:!1,default:!0}}};const He=(0,_.Z)(Ve,[["render",Ae]]);var Fe=He;const Be={key:2,class:"canvas"},Ye={class:"panel"},Ke={key:3,class:"canvas"};function Ge(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",Be,[(0,i._)("div",Ye,[(0,i.Wm)(d)])])):((0,i.wg)(),(0,i.iD)("div",Ke,[((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 Je=e=>((0,i.dD)("data-v-d9ea25f0"),e=e(),(0,i.Cn)(),e),Xe=Je((()=>(0,i._)("i",{class:"fas fa-bars"},null,-1))),Qe=["textContent"],et={class:"plugins"},tt=["title","onClick"],st=["href"],nt={class:"icon"},it=["src"],at={key:2,class:"fas fa-puzzle-piece"},ot=["textContent"],rt={class:"footer"},lt={href:"/#settings"},ct=Je((()=>(0,i._)("span",{class:"icon"},[(0,i._)("i",{class:"fa fa-cog"})],-1))),dt={key:0,class:"name"},ut={href:"/logout"},ht=Je((()=>(0,i._)("span",{class:"icon"},[(0,i._)("i",{class:"fas fa-sign-out-alt"})],-1))),pt={key:0,class:"name"};function ft(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)},[Xe,s.hostname?((0,i.wg)(),(0,i.iD)("span",{key:0,class:"hostname",textContent:(0,l.zw)(s.hostname)},null,8,Qe)):(0,i.kq)("",!0)]),(0,i._)("ul",et,[((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",nt,[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,it)):((0,i.wg)(),(0,i.iD)("i",at))]),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,ot))],8,st)],10,tt)))),128))]),(0,i._)("ul",rt,[(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",lt,[ct,a.collapsed?(0,i.kq)("",!0):((0,i.wg)(),(0,i.iD)("span",dt,"Settings"))])],2),(0,i._)("li",{title:"Logout",onClick:t[2]||(t[2]=e=>o.onItemClick("logout"))},[(0,i._)("a",ut,[ht,a.collapsed?(0,i.kq)("",!0):((0,i.wg)(),(0,i.iD)("span",pt,"Logout"))])])])],2)}var mt=s(1359),gt={name:"Nav",emits:["select"],mixins:[S.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()},collapsedDefault(){return!(!this.isMobile()&&!this.isTablet())}},methods:{onItemClick(e){this.$emit("select",e),this.collapsed=!!this.isMobile()||this.collapsedDefault}},data(){return{collapsed:!0,icons:mt,host:null}},mounted(){this.collapsed=this.collapsedDefault}};const bt=(0,_.Z)(gt,[["render",ft],["__scopeId","data-v-d9ea25f0"]]);var yt=bt,vt=s(2715),wt={name:"Panel",mixins:[S.Z],components:{Settings:vt["default"],Nav:yt,Loading:pe.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,he.XI)((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 kt=(0,_.Z)(wt,[["render",Ge],["__scopeId","data-v-fbc09254"]]);var _t=kt;const xt={key:1,class:"canvas"};function Ct(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",xt,[((0,i.wg)(),(0,i.j4)((0,i.LL)(a.component),{config:a.config,"plugin-name":o.pluginName},null,8,["config","plugin-name"]))]))])}var Dt={name:"Panel",mixins:[S.Z],components:{Settings:vt["default"],Nav:yt,Loading:pe.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,he.XI)((0,i.RC)((async()=>t))),this.$options.components[e]=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 It=(0,_.Z)(Dt,[["render",Ct],["__scopeId","data-v-e339182c"]]);var Tt=It;const St=[{path:"/",name:"Panel",component:_t},{path:"/dashboard/:name",name:"Dashboard",component:Ce},{path:"/plugin/:plugin",name:"Plugin",component:Tt},{path:"/login",name:"Login",component:Le},{path:"/register",name:"Register",component:Fe},{path:"/:catchAll(.*)",component:Se}],Ut=(0,de.p7)({history:(0,de.PO)(),routes:St});var Nt=Ut;const Pt=(0,n.ri)(ce);Pt.config.globalProperties._config=window.config,Pt.use(Nt).mount("#app")},6813:function(e,t,s){"use strict";s.d(t,{Z:function(){return j}});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 b=g,y={name:"Notification",methods:{notify(e){f.$.publishNotification(e)},notifyWarning(e){this.notify({text:e,warning:!0})},notifyError(e){throw this.notify({text:e,error:!0}),e}}};const v=y;var w=v,k={name:"Screen",methods:{isMobile(){return window.matchMedia("only screen and (max-width: 768px)").matches},isTablet(){return!this.isMobile()&&window.matchMedia("only screen and (max-width: 1023px)").matches},isDesktop(){return window.matchMedia("only screen and (min-width: 1024px)").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,T={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}`},convertTime(e){const t={},s=[];if(e=parseFloat(e),t.d=parseInt(e/86400),t.h=parseInt(e/3600-24*t.d),t.m=parseInt(e/60-(24*t.d+60*t.h)),t.s=Math.round(e-(24*t.d+3600*t.h+60*t.m),1),parseInt(t.d)){let e=t.d+" day";t.d>1&&(e+="s"),s.push(e)}if(parseInt(t.h)){let e=t.h+" hour";t.h>1&&(e+="s"),s.push(e)}if(parseInt(t.m)){let e=t.m+" minute";t.m>1&&(e+="s"),s.push(e)}let n=t.s+" second";return t.s>1&&(n+="s"),s.push(n),s.join(" ")},objectsEqual(e,t){if("object"!==typeof e||"object"!==typeof t)return!1;if(null==e||null==t)return null==e&&null==t;for(const s of Object.keys(e||{}))switch(typeof e[s]){case"object":if(!this.objectsEqual(e[s],t[s]))return!1;break;case"function":if(e[s].toString()!=t[s]?.toString())return!1;break;default:if(e[s]!=t[s])return!1;break}for(const s of Object.keys(t||{}))if(null==e[s]&&null!=t[s])return!1;return!0}}};const S=T;var U=S,N={name:"Utils",mixins:[r,d,w,b,p,x,I,U]};const P=N;var j=P},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},2684: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-2 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-10":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:{}},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-2cfe8014"]]);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},2715:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return _e}});var n=s(6252);const i={class:"settings-container"},a={class:"col-8"},o={class:"col-4 pull-right"},r=(0,n._)("i",{class:"fa fa-plus"},null,-1),l=[r];function c(e,t,s,r,c,d){const u=(0,n.up)("DropdownItem"),h=(0,n.up)("Dropdown"),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.Wm)(h,{title:"Select a category","icon-class":"fa fa-ellipsis-h"},{default:(0,n.w5)((()=>[(0,n.Wm)(u,{text:"Users","icon-class":"fa fa-user","item-class":{selected:"users"===c.selectedView},onClick:t[0]||(t[0]=e=>c.selectedView="users")},null,8,["item-class"]),(0,n.Wm)(u,{text:"Generate a token","icon-class":"fa fa-key","item-class":{selected:"token"===c.selectedView},onClick:t[1]||(t[1]=e=>c.selectedView="token")},null,8,["item-class"])])),_:1})]),(0,n._)("div",o,["users"===c.selectedView?((0,n.wg)(),(0,n.iD)("button",{key:0,title:"Add User",onClick:t[2]||(t[2]=t=>e.$refs.usersView.$refs.addUserModal.show())},l)):(0,n.kq)("",!0)])]),(0,n._)("main",null,["users"===c.selectedView?((0,n.wg)(),(0,n.j4)(p,{key:0,"session-token":c.sessionToken,"current-user":c.currentUser,ref:"usersView"},null,8,["session-token","current-user"])):"token"===c.selectedView?((0,n.wg)(),(0,n.j4)(f,{key:1,"session-token":c.sessionToken,"current-user":c.currentUser,ref:"tokenView"},null,8,["session-token","current-user"])):(0,n.kq)("",!0)])])}var d=s(5771),u=s(2684),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."),b=(0,n._)("br",null,null,-1),y=(0,n.Uk)(" Also, make sure to save it - it WILL NOT be displayed again. "),v=["textContent"],w={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),T=(0,n.Uk)("Specify it on the "),S=(0,n.Uk)("Authorization: Bearer"),U=(0,n.Uk)(" header;"),N=(0,n.Uk)("Specify it on the "),P=(0,n.Uk)("X-Token"),j=(0,n.Uk)(" header;"),M=(0,n.Uk)("Specify it as a URL parameter: "),$=(0,n.Uk)("http://site:8008/execute?token=..."),q=(0,n.Uk)(";"),O=(0,n.Uk)("Specify it on the body of your JSON request: "),Z=(0,n.Uk)('{"type":"request", "action", "...", "token":"..."}'),E=(0,n.Uk)("."),W=(0,n.Uk)(" Confirm your credentials in order to generate a new token. "),z={class:"form-container"},R=(0,n._)("span",null,"Username",-1),L=["value"],A=(0,n._)("label",null,[(0,n._)("span",null,"Confirm password"),(0,n._)("span",null,[(0,n._)("input",{type:"password",name:"password"})])],-1),V=(0,n._)("label",null,[(0,n._)("span",null,"Token validity in days"),(0,n._)("span",null,[(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._)("label",null,[(0,n._)("input",{type:"submit",class:"btn btn-primary",value:"Generate token"})],-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,b,y,(0,n._)("textarea",{class:"token",textContent:(0,h.zw)(a.token),onFocus:t[0]||(t[0]=(...e)=>o.onTokenSelect&&o.onTokenSelect(...e))},null,40,v)])])])),_:1},512),(0,n._)("div",w,[(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,[T,(0,n.Wm)(c,null,{default:(0,n.w5)((()=>[S])),_:1}),U]),(0,n._)("li",null,[N,(0,n.Wm)(c,null,{default:(0,n.w5)((()=>[P])),_:1}),j]),(0,n._)("li",null,[M,(0,n.Wm)(c,null,{default:(0,n.w5)((()=>[$])),_:1}),q]),(0,n._)("li",null,[O,(0,n.Wm)(c,null,{default:(0,n.w5)((()=>[Z])),_:1}),E])]),W]),(0,n._)("div",z,[(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._)("span",null,[(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._)("label",null,[(0,n._)("input",{type:"submit",class:"btn btn-primary",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._)("label",null,[(0,n._)("input",{type:"submit",class:"btn btn-primary",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 be={name:"Users",components:{DropdownItem:u.Z,Loading:K.Z,Modal:J.Z,Dropdown:d.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 ve=ye,we={name:"Settings",components:{Dropdown:d.Z,DropdownItem:u.Z,Users:ve,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 ke=(0,Q.Z)(we,[["render",c]]);var _e=ke},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":[4881,8774],"./Execute/Index":[7643,7643],"./Light/Index":[5199,7782,3490,5199],"./LightHue/Index":[3724,7782,3490,5199,3724],"./Media/Index":[4196,7782,9978,8589,4196],"./MediaMplayer/Index":[6509,7782,9978,8589,4196,6509],"./MediaMpv/Index":[5895,7782,9978,8589,4196,5895],"./MediaOmxplayer/Index":[9633,7782,9978,8589,4196,9633],"./MediaVlc/Index":[767,7782,9978,8589,4196,767],"./Music/Index":[6833,7782,9978,6833],"./MusicMpd/Index":[3249,7782,9978,6833,3249],"./MusicSnapcast/Index":[2790,7782,3490,2790],"./MusicSpotify/Index":[9369,7782,9978,6833,9369],"./Rtorrent/Index":[2820,8589,6899,2820],"./Settings/Index":[2715],"./Sound/Index":[5193,5193],"./Torrent/Index":[9299,8589,6899,9299],"./Tts/Index":[2466,4021,2466],"./TtsGoogle/Index":[1938,4021,1938],"./TvSamsungWs/Index":[615,615],"./ZigbeeMqtt/Index":[4848,7782,3490,4848],"./Zwave/Index":[6027,7782,3490,906,6027],"./ZwaveMqtt/Index":[2362,7782,3490,906,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,7782,3490,5824],"./DateTime/Index":[1595,9575,1595],"./DateTimeWeather/Index":[3498,1798,9575,3498],"./ImageCarousel/Index":[6003,1798,9575,6003],"./Music/Index":[6013,6013],"./Plugin/Index":[1818,1818],"./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('{"arduino":{"class":"fas fa-microchip"},"bluetooth":{"class":"fab fa-bluetooth"},"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"},"linode":{"class":"fas fa-cloud"},"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"},"sensor.bme280":{"class":"fas fa-microchip"},"sensor.dht":{"class":"fas fa-microchip"},"sensor.envirophat":{"class":"fas fa-microchip"},"sensor.ltr559":{"class":"fas fa-microchip"},"sensor.mcp3008":{"class":"fas fa-microchip"},"sensor.pmw3901":{"class":"fas fa-microchip"},"sensor.vl53l1x":{"class":"fas fa-microchip"},"serial":{"class":"fab fa-usb"},"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"},"system":{"class":"fas fa-microchip"},"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",359:"632020b4",615:"25a0ebcb",699:"cf8f2194",703:"486d1f81",767:"32c26b46",906:"d255cc8e",1595:"cf573de8",1798:"2ea76630",1818:"d8f79120",1897:"8d867f67",1938:"1dc95872",2088:"8e5eb07a",2306:"c228cea9",2315:"a8bb3dcf",2346:"9a487752",2362:"620095dd",2466:"633bb83f",2745:"46efa5fb",2790:"88b4b105",2806:"75424f01",2820:"07ee3664",2989:"fa06c8b8",3249:"a2010c2d",3303:"8db3e72e",3490:"d482e29b",3498:"c77d3b8c",3724:"a557791e",4021:"a3380d38",4196:"e7c93da6",4548:"686dd66b",4848:"bc3cc45e",4981:"c4835180",5111:"d348fed1",5193:"1de6bb98",5199:"03545ba6",5207:"b6625280",5225:"698f54a7",5498:"d492303f",5528:"f33f80c6",5824:"d14935bb",5895:"bc039cca",5915:"ae6b382e",6003:"c76e25e0",6013:"5c85c65a",6027:"e3b113ee",6164:"3e04d6d9",6509:"9ca36429",6739:"14f222c1",6833:"6271c6b5",6899:"0b97dc52",7420:"e53d9d48",7549:"3f5e0e96",7643:"48f991b1",7782:"724314a6",8126:"49e7385e",8184:"6859ae89",8444:"b455dc95",8589:"21ae83d2",8625:"c482263f",8774:"7bb9144e",9299:"710819a1",9369:"f7907b71",9575:"fb8eab70",9633:"23b95cb0",9651:"5535826c",9705:"360b4baf",9767:"6a30d401",9895:"f9b70895",9978:"f8ee0318"}[e]+".js"}}(),function(){s.miniCssF=function(e){return"static/css/"+e+"."+{65:"5579e7e1",345:"19cf9d0d",359:"0422d129",615:"8b95243c",703:"3b966188",906:"cb3bce26",1798:"d0061372",1818:"8baa291c",1897:"13c6d0d4",2088:"82a608f4",2306:"c73437bb",2315:"abbbc376",2346:"d171e8f5",2745:"025dead2",2790:"19201b3b",2806:"1b470dc1",2989:"0f93a679",3303:"65b20784",3490:"a327ba57",3498:"cde559da",3724:"0fc70dd7",4021:"fff19b0b",4196:"ea56d2c9",4848:"c9eab7f4",4981:"94bc04e2",5193:"37da0a16",5199:"fe9cee1a",5207:"2b89418c",5225:"fa14e62b",5498:"1f796505",5824:"c1f06cf8",6003:"986b3ae1",6013:"d0054b15",6164:"17e6ad88",6739:"11bad71d",6833:"b5d8115c",6899:"748a42fd",7420:"f8b46177",7549:"4ed7f125",7643:"6c07b819",7782:"a9f0ac90",8126:"40e29e36",8444:"63cd9a1a",8589:"e7924cac",8625:"d3f40ac1",8774:"96103f24",9575:"21327597",9651:"ef16a74e",9705:"65deaccf",9767:"8d4f8e9e",9978:"b34577f7"}[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,359:1,615:1,703:1,906:1,1798:1,1818:1,1897:1,2088:1,2306:1,2315:1,2346:1,2745:1,2790:1,2806:1,2989:1,3303:1,3490:1,3498:1,3724:1,4021:1,4196:1,4848:1,4981:1,5193:1,5199:1,5207:1,5225:1,5498:1,5824:1,6003:1,6013:1,6164:1,6739:1,6833:1,6899:1,7420:1,7549:1,7643:1,7782:1,8126:1,8444:1,8589:1,8625:1,8774:1,9575:1,9651:1,9705:1,9767: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|3490|4021|4981|7782|9575|9705)$/.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(3718)}));n=s.O(n)})();
|
||
//# sourceMappingURL=app.43713bf2.js.map
|