platypush/platypush/backend/http/dist/static/js/app.6a1bcb04.js

2 lines
18 KiB
JavaScript

(function(e){function t(t){for(var r,c,s=t[0],a=t[1],u=t[2],l=0,d=[];l<s.length;l++)c=s[l],Object.prototype.hasOwnProperty.call(o,c)&&o[c]&&d.push(o[c][0]),o[c]=0;for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r]);f&&f(t);while(d.length)d.shift()();return i.push.apply(i,u||[]),n()}function n(){for(var e,t=0;t<i.length;t++){for(var n=i[t],r=!0,c=1;c<n.length;c++){var s=n[c];0!==o[s]&&(r=!1)}r&&(i.splice(t--,1),e=a(a.s=n[0]))}return e}var r={},c={app:0},o={app:0},i=[];function s(e){return a.p+"static/js/"+({}[e]||e)+"."+{"chunk-2dcde994":"af8aa6cd","chunk-4bbbb9a3":"d3030ed8","chunk-5710a9bc":"aefd4d41","chunk-f0cefcde":"8bf9c8a1","chunk-62a3d08e":"15815e60","chunk-7c2209ed":"46b43454"}[e]+".js"}function a(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.e=function(e){var t=[],n={"chunk-2dcde994":1,"chunk-4bbbb9a3":1,"chunk-5710a9bc":1,"chunk-f0cefcde":1,"chunk-62a3d08e":1,"chunk-7c2209ed":1};c[e]?t.push(c[e]):0!==c[e]&&n[e]&&t.push(c[e]=new Promise((function(t,n){for(var r="static/css/"+({}[e]||e)+"."+{"chunk-2dcde994":"9a64be0a","chunk-4bbbb9a3":"4d06e8fc","chunk-5710a9bc":"40372d79","chunk-f0cefcde":"2bd45425","chunk-62a3d08e":"46dc0c5b","chunk-7c2209ed":"a669bf94"}[e]+".css",o=a.p+r,i=document.getElementsByTagName("link"),s=0;s<i.length;s++){var u=i[s],l=u.getAttribute("data-href")||u.getAttribute("href");if("stylesheet"===u.rel&&(l===r||l===o))return t()}var d=document.getElementsByTagName("style");for(s=0;s<d.length;s++){u=d[s],l=u.getAttribute("data-href");if(l===r||l===o)return t()}var f=document.createElement("link");f.rel="stylesheet",f.type="text/css",f.onload=t,f.onerror=function(t){var r=t&&t.target&&t.target.src||o,i=new Error("Loading CSS chunk "+e+" failed.\n("+r+")");i.code="CSS_CHUNK_LOAD_FAILED",i.request=r,delete c[e],f.parentNode.removeChild(f),n(i)},f.href=o;var b=document.getElementsByTagName("head")[0];b.appendChild(f)})).then((function(){c[e]=0})));var r=o[e];if(0!==r)if(r)t.push(r[2]);else{var i=new Promise((function(t,n){r=o[e]=[t,n]}));t.push(r[2]=i);var u,l=document.createElement("script");l.charset="utf-8",l.timeout=120,a.nc&&l.setAttribute("nonce",a.nc),l.src=s(e);var d=new Error;u=function(t){l.onerror=l.onload=null,clearTimeout(f);var n=o[e];if(0!==n){if(n){var r=t&&("load"===t.type?"missing":t.type),c=t&&t.target&&t.target.src;d.message="Loading chunk "+e+" failed.\n("+r+": "+c+")",d.name="ChunkLoadError",d.type=r,d.request=c,n[1](d)}o[e]=void 0}};var f=setTimeout((function(){u({type:"timeout",target:l})}),12e4);l.onerror=l.onload=u,document.head.appendChild(l)}return Promise.all(t)},a.m=e,a.c=r,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},a.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)a.d(n,r,function(t){return e[t]}.bind(null,r));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="/",a.oe=function(e){throw console.error(e),e};var u=window["webpackJsonp"]=window["webpackJsonp"]||[],l=u.push.bind(u);u.push=t,u=u.slice();for(var d=0;d<u.length;d++)t(u[d]);var f=l;i.push([0,"chunk-vendors"]),n()})({0:function(e,t,n){e.exports=n("56d7")},1061:function(e,t,n){"use strict";n("c345")},"2d48":function(e,t,n){"use strict";n("994d")},"2e56":function(e,t,n){"use strict";n("7907")},"3a5e":function(e,t,n){"use strict";var r=n("7a23"),c=Object(r["F"])("data-v-4d9c871b");Object(r["u"])("data-v-4d9c871b");var o={class:"loading"},i={class:"icon"};Object(r["s"])();var s=c((function(e,t,n,c,s,a){return Object(r["r"])(),Object(r["e"])("div",o,[Object(r["h"])("div",i,[(Object(r["r"])(),Object(r["e"])(r["a"],null,Object(r["x"])(4,(function(e){return Object(r["h"])("div",{key:e})})),64))])])}));n("4f22");const a={};a.render=s,a.__scopeId="data-v-4d9c871b";t["a"]=a},"3e54":function(e,t,n){"use strict";n("d3b7");var r=n("bc3a"),c=n.n(r),o={name:"Api",methods:{execute:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6e4,r={};return"target"in e&&e["target"]||(e["target"]="localhost"),"type"in e&&e["type"]||(e["type"]="request"),n&&(r.timeout=n),new Promise((function(n,o){c.a.post("/execute",e,r).then((function(e){if(e=e.data.response,e.errors.length){var r=e.errors[0];t.notify({text:r,error:!0}),o(r)}else n(e.output)})).catch((function(e){t.notify({text:e,error:!0}),o(e)}))}))},request:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:6e4;return this.execute({type:"request",action:e,args:t},n)}}},i=o,s={name:"DateTime",methods:{formatDate:function(e){return e.toDateString().substring(0,10)},formatTime:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e.toTimeString().substring(0,t?8:5)}}},a=s,u=n("f5ef"),l={name:"Events",methods:{subscribe:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];u["a"].emit("subscribe",{events:n,handler:e})}}},d=l,f={name:"Notification",methods:{notify:function(e){u["a"].emit("notification-create",e)},error:function(e){throw this.notify({text:e,error:!0}),e}}},b=f,h={name:"Types",methods:{parseBoolean:function(e){return"string"===typeof e?(e=e.toLowerCase(),"true"===e||"false"!==e&&!!parseInt(e)):!!e}}},p=h,m={name:"Utils",mixins:[i,b,d,a,p]};t["a"]=m},"4f22":function(e,t,n){"use strict";n("d4c7")},"56d7":function(e,t,n){"use strict";n.r(t);n("e260"),n("e6cf"),n("cca6"),n("a79d");var r=n("7a23");function c(e,t,n,c,o,i){var s=Object(r["z"])("Events"),a=Object(r["z"])("Notifications"),u=Object(r["z"])("router-view");return Object(r["r"])(),Object(r["e"])(r["a"],null,[o.config["backend.http"]?(Object(r["r"])(),Object(r["e"])(s,{key:0,ref:"events","ws-port":o.config["backend.http"].websocket_port},null,8,["ws-port"])):Object(r["f"])("",!0),Object(r["h"])(a,{ref:"notifications"},null,512),Object(r["h"])(u)],64)}n("96cf");var o=n("1da1"),i=(n("9911"),Object(r["F"])("data-v-6dc8bebc"));Object(r["u"])("data-v-6dc8bebc");var s={class:"notifications"};Object(r["s"])();var a=i((function(e,t,n,c,o,i){var a=Object(r["z"])("Notification");return Object(r["r"])(),Object(r["e"])("div",s,[(Object(r["r"])(!0),Object(r["e"])(r["a"],null,Object(r["x"])(e.notifications,(function(e,t,n){return Object(r["r"])(),Object(r["e"])(a,{key:n,id:t,text:e.text,html:e.html,title:e.title,link:e.link,image:e.image,warning:e.warning,error:e.error,onClicked:i.destroy},null,8,["id","text","html","title","link","image","warning","error","onClicked"])})),128))])})),u=(n("a9e3"),Object(r["F"])("data-v-98b9fe3e"));Object(r["u"])("data-v-98b9fe3e");var l={class:"body"},d={key:0,class:"image col-3"},f={class:"row"},b={key:3,class:"fa fa-exclamation"},h={key:4,class:"fa fa-times"};Object(r["s"])();var p=u((function(e,t,n,c,o,i){return Object(r["r"])(),Object(r["e"])("div",{class:["notification fade-in",{warning:n.warning,error:n.error}],onClick:t[1]||(t[1]=function(){return i.clicked.apply(i,arguments)})},[n.title?(Object(r["r"])(),Object(r["e"])("div",{key:0,class:"title",textContent:Object(r["C"])(n.title)},null,8,["textContent"])):Object(r["f"])("",!0),Object(r["h"])("div",l,[n.image||n.warning||n.error?(Object(r["r"])(),Object(r["e"])("div",d,[Object(r["h"])("div",f,[n.image&&n.image.src?(Object(r["r"])(),Object(r["e"])("img",{key:0,src:n.image.src,alt:""},null,8,["src"])):n.image&&n.image.icon?(Object(r["r"])(),Object(r["e"])("i",{key:1,class:["fa","fa-"+n.image.icon],style:n.image.color?"--color: "+n.image.color:""},null,6)):n.image&&n.image.iconClass?(Object(r["r"])(),Object(r["e"])("i",{key:2,class:n.image.iconClass,style:n.image.color?"--color: "+n.image.color:""},null,6)):n.warning?(Object(r["r"])(),Object(r["e"])("i",b)):n.error?(Object(r["r"])(),Object(r["e"])("i",h)):Object(r["f"])("",!0)])])):Object(r["f"])("",!0),n.text&&n.image?(Object(r["r"])(),Object(r["e"])("div",{key:1,class:"text col-9",textContent:Object(r["C"])(n.text)},null,8,["textContent"])):Object(r["f"])("",!0),n.html&&n.image?(Object(r["r"])(),Object(r["e"])("div",{key:2,class:"text col-9",innerHTML:n.html},null,8,["innerHTML"])):Object(r["f"])("",!0),n.text&&!n.image?(Object(r["r"])(),Object(r["e"])("div",{key:3,class:"text row horizontal-center",textContent:Object(r["C"])(n.text)},null,8,["textContent"])):Object(r["f"])("",!0),n.html&&!n.image?(Object(r["r"])(),Object(r["e"])("div",{key:4,class:"text row horizontal-center",innerHTML:n.html},null,8,["innerHTML"])):Object(r["f"])("",!0)])],2)})),m={name:"Notification",props:["id","text","html","title","image","link","error","warning"],methods:{clicked:function(){this.link&&window.open(this.link,"_blank"),this.$emit("clicked",this.id)}}};n("db52");m.render=p,m.__scopeId="data-v-98b9fe3e";var v=m,g={name:"Notifications",components:{Notification:v},props:{duration:{type:Number,default:1e4}},data:function(){return{index:0,notifications:{},timeouts:{}}},methods:{create:function(e){var t=this.index++;this.notifications[t]=e,null==e.duration&&(e.duration=this.duration);var n=e.duration?parseInt(e.duration):0;n&&(this.timeouts[t]=setTimeout(this.destroy.bind(null,t),n))},destroy:function(e){delete this.notifications[e],delete this.timeouts[e]}}};n("2e56");g.render=a,g.__scopeId="data-v-6dc8bebc";var O=g,j=n("3e54"),y=(n("99af"),n("c975"),n("a434"),n("b85c")),k=n("2909"),w=n("f5ef"),x={name:"Events",props:{wsPort:{type:Number,default:8009}},data:function(){return{ws:null,pending:!1,opened:!1,timeout:null,reconnectMsecs:3e4,handlers:{}}},methods:{onWebsocketTimeout:function(){return function(){console.log("Websocket reconnection timed out, retrying"),this.pending=!1,this.close(),this.onclose()}},onMessage:function(e){var t=[];if(e=e.data,"string"===typeof e)try{e=JSON.parse(e)}catch(o){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.apply(t,Object(k["a"])(this.handlers[e.args.type]));for(var n=0,r=t;n<r.length;n++){var c=r[n];c instanceof Array&&(c=c[0]),c(e.args)}}},onOpen:function(){this.opened&&(console.log("There's already an opened websocket connection, closing the newly opened one"),this.onclose=function(){},this.close()),console.log("Websocket connection successful"),this.opened=!0,this.pending&&(this.pending=!1),this.timeout&&(clearTimeout(this.timeout),this.timeout=void 0)},onError:function(e){console.error("Websocket error"),console.error(e)},onClose:function(e){e&&console.log("Websocket closed - code: "+e.code+" - reason: "+e.reason),this.opened=!1,this.pending||(this.pending=!0,this.init())},init:function(){try{var e="https:"===location.protocol?"wss:":"ws",t="".concat(e,"://").concat(location.hostname,":").concat(this.wsPort);this.ws=new WebSocket(t)}catch(n){return console.error("Websocket initialization error"),void console.error(n)}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},subscribe:function(e){var t,n=e.handler,r=e.events.length?e.events:[null],c=Object(y["a"])(r);try{for(c.s();!(t=c.n()).done;){var o=t.value;o in this.handlers||(this.handlers[o]=[]),this.handlers[o].push(n)}}catch(i){c.e(i)}finally{c.f()}},unsubscribe:function(e){var t,n=e.handler,r=e.events.length?e.events:[null],c=Object(y["a"])(r);try{for(c.s();!(t=c.n()).done;){var o=t.value;if(o in this.handlers){var i=this.handlers[o].indexOf(n);i<0||(this.handlers[o]=this.handlers[o].splice(i,1)[1],this.handlers[o].length||delete this.handlers[o])}}}catch(s){c.e(s)}finally{c.f()}}},created:function(){w["a"].on("subscribe",this.subscribe),w["a"].on("unsubscribe",this.unsubscribe),this.init()}},C=x,_={name:"App",components:{Events:C,Notifications:O},mixins:[j["a"]],data:function(){return{config:{}}},methods:{onNotification:function(e){this.$refs.notifications.create(e)},initConfig:function(){var e=this;return Object(o["a"])(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,e.request("config.get");case 2:e.config=t.sent;case 3:case"end":return t.stop()}}),t)})))()}},created:function(){this.initConfig()},mounted:function(){w["a"].on("notification-create",this.onNotification)}};n("9cdc");_.render=c;var N=_,T=n("6c02"),S=Object(r["F"])("data-v-3d4a4554"),I=S((function(e,t,n,c,o,i){var s=Object(r["z"])("Widget"),a=Object(r["z"])("Row"),u=Object(r["z"])("Loading");return Object(r["r"])(),Object(r["e"])(r["a"],null,[Object(r["h"])("div",{id:"dashboard",class:["columns is-mobile",i.classes],style:o.style},[(Object(r["r"])(!0),Object(r["e"])(r["a"],null,Object(r["x"])(o.rows,(function(e,t){return Object(r["r"])(),Object(r["e"])(a,{key:t,class:e.class,style:e.style},{default:S((function(){return[(Object(r["r"])(!0),Object(r["e"])(r["a"],null,Object(r["x"])(e.widgets,(function(e,t){return Object(r["r"])(),Object(r["e"])(r["b"],{key:t},[Object(r["h"])(s,{style:e.style,class:e.class},{default:S((function(){return[(Object(r["r"])(),Object(r["e"])(Object(r["A"])(e.component),e.props,null,16))]})),_:2},1032,["style","class"])],1024)})),128))]})),_:2},1032,["class","style"])})),128))],6),o.loading?(Object(r["r"])(),Object(r["e"])(u,{key:0})):Object(r["f"])("",!0)],64)})),E=(n("d81d"),n("13d5"),n("b0c0"),n("b680"),n("d3b7"),n("3a5e")),P=Object(r["F"])("data-v-1b4663f2"),D=P((function(e,t,n,c,o,i){return Object(r["r"])(),Object(r["e"])("div",{class:["row",i.classes],style:n.style},[Object(r["y"])(e.$slots,"default")],6)})),M={name:"Row",props:{class:{type:String,required:!1,default:""},style:{type:String,required:!1,default:""}},computed:{classes:function(){return this.class}}};n("6682");M.render=D,M.__scopeId="data-v-1b4663f2";var L=M,W=Object(r["F"])("data-v-8c529832"),q=W((function(e,t,n,c,o,i){return Object(r["r"])(),Object(r["e"])("div",{style:n.style,class:i.classes},[Object(r["y"])(e.$slots,"default")],6)})),A=(n("ac1f"),n("1276"),{name:"Widget",props:{style:{type:String,required:!1,default:""},class:{type:String,required:!1,default:""}},computed:{classes:function(){return(this.class&&this.class.length?this.class.split(" "):["col-3"]).concat(["widget","column"])}}});n("1061");A.render=q,A.__scopeId="data-v-8c529832";var F=A,z={name:"Dashboard",mixins:[j["a"]],components:{Widget:F,Loading:E["a"],Row:L},props:{refreshSeconds:{type:Number,required:!1,default:0}},data:function(){return{rows:[],loading:!1,style:void 0,class:void 0}},computed:{classes:function(){return this.class}},methods:{parseTemplate:function(e,t){var c=(new DOMParser).parseFromString(t,"text/xml").childNodes[0],o=this;this.style=c.attributes.style?c.attributes.style.nodeValue:void 0,this.class=c.attributes.class?c.attributes.class.nodeValue:void 0,this.rows=Object(k["a"])(c.getElementsByTagName("Row")).map((function(e){return{style:e.attributes.style?e.attributes.style.nodeValue:void 0,class:e.attributes.class?e.attributes.class.nodeValue:void 0,widgets:Object(k["a"])(e.children).map((function(e){var t=Object(r["i"])((function(){return n("cdb9")("./".concat(e.nodeName,"/Index"))})),c=e.attributes.style?e.attributes.style.nodeValue:void 0,i=e.attributes.class?e.attributes.class.nodeValue:void 0,s=Object(k["a"])(e.attributes).reduce((function(e,t){return"style"!==t.nodeName&&(e[t.nodeName]=t.nodeValue),e}),{}),a={component:t,style:c,class:i,props:s||{}};return o.$options.components[e.nodeName]=t,a}))}})),this.loading=!1},refreshDashboard:function(){var e=this;return Object(o["a"])(regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return e.loading=!0,e.widgets=[],n=e.$route.params.name,t.next=5,e.request("config.get_dashboard",{name:n});case 5:r=t.sent,r||e.error("Dashboard ".concat(n," not found")),e.parseTemplate(n,r);case 8:case"end":return t.stop()}}),t)})))()}},mounted:function(){if(this.refreshDashboard(),this.refreshSeconds){var e=this;setInterval((function(){e.refreshDashboard()}),parseInt((1e3*this.refreshSeconds).toFixed(0)))}}};n("2d48");z.render=I,z.__scopeId="data-v-3d4a4554";var R=z;function V(e,t,n,c,o,i){return Object(r["r"])(),Object(r["e"])("h1",null,"Object not found")}var $={name:"NotFound"};$.render=V;var B=$,H=[{path:"/dashboard/:name",name:"Dashboard",component:R},{path:"/:catchAll(.*)",component:B}],J=Object(T["a"])({history:Object(T["b"])(),routes:H}),U=J,K=Object(r["d"])(N);K.config.globalProperties._config=window.config,K.use(U).mount("#app")},6682:function(e,t,n){"use strict";n("9430")},7907:function(e,t,n){},9430:function(e,t,n){},"994d":function(e,t,n){},"9cdc":function(e,t,n){"use strict";n("c701")},"9fb0":function(e,t,n){},c345:function(e,t,n){},c701:function(e,t,n){},cdb9:function(e,t,n){var r={"./Calendar/Index":["3c97","chunk-62a3d08e"],"./DateTime/Index":["365a","chunk-4bbbb9a3"],"./DateTimeWeather/Index":["3737","chunk-2dcde994","chunk-4bbbb9a3","chunk-5710a9bc"],"./ImageCarousel/Index":["c845","chunk-2dcde994","chunk-4bbbb9a3","chunk-f0cefcde"],"./Music/Index":["bcf7","chunk-7c2209ed"],"./Weather/Index":["5b43","chunk-2dcde994"]};function c(e){if(!n.o(r,e))return Promise.resolve().then((function(){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}));var t=r[e],c=t[0];return Promise.all(t.slice(1).map(n.e)).then((function(){return n(c)}))}c.keys=function(){return Object.keys(r)},c.id="cdb9",e.exports=c},d4c7:function(e,t,n){},db52:function(e,t,n){"use strict";n("9fb0")},f5ef:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n("14b7"),c=Object(r["a"])()}});
//# sourceMappingURL=app.6a1bcb04.js.map