text: (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["Inputs"],{"3fb9":function(t,e,a){"use strict";var s=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"toast toast-error"},[a("button",{staticClass:"btn btn-clear float-right",on:{click:function(e){return t.$emit("close-err")}}}),""!==t.errorMessage&&null!==t.errorMessage?a("span",[t._v(" "+t._s(t.errorMessage)+" ")]):t._e(),t.errorArray.length&&null!==t.errorArray?a("ul",t._l(t.errorArray,(function(e,s){return a("li",{key:s},[t._v(t._s(e))])})),0):t._e()])},i=[],o={name:"Error",props:{errorMessage:{type:String,required:!1},errorArray:{default:()=>[],type:Array,required:!1}}},r=o,l=a("2877"),n=Object(l["a"])(r,s,i,!1,null,null,null);e["a"]=n.exports},"49a3":function(t,e,a){"use strict";var s=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("div",{staticClass:"panel"},[a("div",{staticClass:"panel-header"},[t._m(0),null!==t.$route.meta.error?a("Error",{attrs:{"error-message":t.$route.meta.error},on:{"close-err":function(e){t.$route.meta.error=null,t.$forceUpdate()}}}):t._e()],1),a("div",{staticClass:"panel-nav"},[a("div",{staticClass:"input-group filter"},[a("input",{directives:[{name:"model",rawName:"v-model",value:t.dateFrom,expression:"dateFrom"}],staticClass:"form-input input-sm",attrs:{type:"date",placeholder:"Date from"},domProps:{value:t.dateFrom},on:{input:function(e){e.target.composing||(t.dateFrom=e.target.value)}}}),a("input",{directives:[{name:"model",rawName:"v-model",value:t.dateTo,expression:"dateTo"}],staticClass:"form-input input-sm",attrs:{type:"date",placeholder:"Date to"},domProps:{value:t.dateTo},on:{input:function(e){e.target.composing||(t.dateTo=e.target.value)}}}),a("button",{staticClass:"btn input-group-btn btn-sm",on:{click:function(e){return t.getHistory()}}},[a("i",{staticClass:"icon icon-refresh centered"})])])]),a("div",{staticClass:"panel-body"},[t.history.length?a("table",{staticClass:"table table-striped"},[t._m(1),a("tbody",t._l(t.history,(function(e){return a("tr",{key:e.id},[a("td",[t._v(t._s(e.date))]),a("td",[t._v(t._s(e.name))]),a("td",[t._v(t._s(e.state))]),a("td",[t._v(t._s(e.by))])])})),0)]):a("div",{staticClass:"empty centered"},[t._m(2),a("p",{staticClass:"empty-title h5"},[t._v("There are is no data in the selected range")])])]),a("div",{staticClass:"panel-footer"},[a("span",{staticClass:"text-secondary"},[t._v("Last update: "+t._s(t.updateDate))]),a("div",{staticClass:"float-right tooltip tooltip-left",attrs:{"data-tooltip":"Auto refresh time (s)"}},[a("input",{directives:[{name:"model",rawName:"v-model",value:t.autoRefreshTime,expression:"autoRefreshTime"}],staticClass:"form-input input-sm",attrs:{type:"number",id:"autorefresh"},domProps:{value:t.autoRefreshTime},on:{change:function(e){return t.autoRefresh()},input:function(e){e.target.composing||(t.autoRefreshTime=e.target.value)}}})])])])])},i=[function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"panel-title"},[a("h3",[t._v("History")])])},function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("thead",[a("tr",[a("th",[t._v("Date")]),a("th",[t._v("Name")]),a("th",[t._v("Action")]),a("th",[t._v("By")])])])},function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"empty-icon"},[a("i",{staticClass:"icon icon-4x icon-cross"})])}],o=a("3fb9"),r={name:"History",data(){return{history:[],refreshInterval:"",updateDate:"",autoRefreshTime:5,dateFrom:"",dateTo:""}},props:["category"],created(){this.dateFrom=this.$moment().subtract(7,"days").format("YYYY-MM-DD"),this.dateTo=this.$moment().add(1,"days").format("YYYY-MM-DD"),this.getHistory(),this.$cookies.isKey("hr_arTime")&&(this.autoRefreshTime=parseInt(this.$cookies.get("hr_arTime"))),this.autoRefresh()},beforeDestroy(){clearTimeout(this.refreshInterval)},methods:{autoRefresh(){this.$cookies.set("hr_arTime",this.autoRefreshTime,-1),clearTimeout(this.refreshInterval),this.autoRefreshTime>0&&(this.refreshInterval=setTimeout(()=>{this.getHistory(),this.autoRefresh()},1e3*this.autoRefreshTime))},getHistory(){this.dateFrom&&this.dateTo&&this.doPost("HR_selByCat;"+this.$moment(this.dateFrom,"YYYY-MM-DD").utc().format("YYYY-MM-DD")+";"+this.$moment(this.dateTo+" 23:59:59","YYYY-MM-DD HH:mm:ss").utc().format("YYYY-MM-DD")+";"+this.category).then(t=>{this.$route.meta.error=null,this.history=[];for(var e=2;e<t.length-1;e+=5)this.history.push({id:parseInt(t[e]),date:this.$moment.utc(t[e+1],"YYYY-MM-DD HH:mm:ss").local().format("YYYY-MM-DD HH:mm:ss"),by:t[e+2],name:t[e+3],state:t[e+4]});this.updateDate=this.$moment().format("YYYY-MM-DD HH:mm:ss.SSS")}).catch(t=>{this.$route.meta.error=t.message,this.$forceUpdate()})}},components:{Error:o["a"]}},l=r,n=a("2877"),c=Object(n["a"])(l,s,i,!1,null,null,null);e["a"]=c.exports},"71ea":function(t,e,a){"use strict";a.r(e);var s=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"Inputs"},[null!==t.$route.meta.error?a("Error",{attrs:{"error-message":t.$route.meta.error},on:{"close-err":function(e){t.$route.meta.error=null,t.$forceUpdate()}}}):a("div",{staticClass:"container"},[a("div",{staticClass:"columns"},[a("GPIO_Input",{staticClass:"column col-8 col-md-12"}),a("History",{staticClass:"column col-4 col-md-12",attrs:{category:"i/o"}})],1)])],1)},i=[],o=a("3fb9"),r=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("div",{staticClass:"panel"},[a("div",{staticClass:"panel-header"},[t._m(0),null!==t.$route.meta.error?a("Error",{attrs:{"error-message":t.$route.meta.error},on:{"close-err":function(e){t.$route.meta.error=null,t.$forceUpdate()}}}):t._e()],1),a("div",{staticClass:"panel-nav"},[a("div",{staticClass:"btn-group btn-group-block float-right"},[a("button",{staticClass:"btn",on:{click:function(e){return t.getInputs()}}},[a("i",{staticClass:"icon icon-refresh centered"})]),a("button",{staticClass:"btn",on:{click:function(e){return t.openModal("Add new input","","",!1,"inloop",-1,1,.05)}}},[a("i",{staticClass:"icon icon-plus centered"})])])]),a("div",{staticClass:"panel-body"},[a("div",{staticClass:"modal",class:{active:t.modalData.active}},[a("a",{staticClass:"modal-overlay",attrs:{"aria-label":"Close"},on:{click:function(e){t.modalData.active=!1}}}),a("div",{staticClass:"modal-container"},[a("div",{staticClass:"modal-header"},[a("a",{staticClass:"btn btn-clear float-right",attrs:{"aria-label":"Close"},on:{click:function(e){t.modalData.active=!1}}}),a("div",{staticClass:"modal-title h5"},[t._v(t._s(t.modalData.title))]),t.modalData.errors.length?a("Error",{attrs:{"error-array":t.modalData.errors},on:{"close-err":function(e){t.modalData.errors=[]}}}):t._e()],1),a("div",{staticClass:"modal-body"},[a("div",{staticClass:"content"},[a("form",{staticClass:"form-horizontal"},[a("div",{staticClass:"form-group"},[t._m(1),a("div",{staticClass:"col-9 col-sm-12"},[a("input",{directives:[{name:"model",rawName:"v-model",value:t.modalData.name,expression:"modalData.name"}],staticClass:"form-input",attrs:{type:"text",id:"name",placeholder:"Name"},domProps:{value:t.modalData.name},on:{input:function(e){e.target.composing||t.$set(t.modalData,"name",e.target.value)}}})])]),a("div",{staticClass:"form-group"},[t._m(2),a("div",{staticClass:"col-9 col-sm-12"},[a("input",{directives:[{name:"model",rawName:"v-model",value:t.modalData.gpio,expression:"modalData.gpio"}],staticClass:"form-input",attrs:{type:"number",id:"gpio",placeholder:"Single GPIO BCM number"},domProps:{value:t.modalData.gpio},on:{input:function(e){e.target.composing||t.$set(t.modalData,"gpio",e.target.value)}}})])]),a("div",{staticClass:"form-group"},[a("label",{staticClass:"form-switch"},[a("input",{directives:[{name:"model",rawName:"v-model",value:t.modalData.reverse,expression:"modalData.reverse"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.modalData.reverse)?t._i(t.modalData.reverse,null)>-1:t.modalData.reverse},on:{change:function(e){var a=t.modalData.reverse,s=e.target,i=!!s.checked;if(Array.isArray(a)){var o=null,r=t._i(a,o);s.checked?r<0&&t.$set(t.modalData,"reverse",a.concat([o])):r>-1&&t.$set(t.modalData,"reverse",a.slice(0,r).concat(a.slice(r+1)))}else t.$set(t.modalData,"reverse",i)}}}),a("i",{staticClass:"form-icon"}),t._v("Reverse ")])]),a("div",{staticClass:"form-group"},[t._m(3),a("div",{staticClass:"col-9 col-sm-12"},[a("select",{directives:[{name:"model",rawName:"v-model",value:t.modalData.resistor,expression:"modalData.resistor"}],staticClass:"form-select",attrs:{id:"type"},on:{change:function(e){var a=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){var e="_value"in t?t._value:t.value;return e}));t.$set(t.modalData,"resistor",e.target.multiple?a:a[0])}}},[a("option",{attrs:{value:"1"}},[t._v("Pull up")]),a("option",{attrs:{value:"2"}},[t._v("Pull down")]),a("option",{attrs:{value:"0"}},[t._v("None")])])])]),a("div",{staticClass:"form-group"},[t._m(4),a("div",{staticClass:"col-9 col-sm-12"},[a("select",{directives:[{name:"model",rawName:"v-model",value:t.modalData.method,expression:"modalData.method"}],staticClass:"form-select",attrs:{id:"type"},on:{change:function(e){var a=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){var e="_value"in t?t._value:t.value;return e}));t.$set(t.modalData,"method",e.target.multiple?a:a[0])}}},[a("option",{attrs:{value:"inloop"}},[t._v("Loop monitoring")]),a("option",{attrs:{value:"ined"}},[t._v("Edge detection")])])])]),a("div",{staticClass:"form-group"},[a("div",{staticClass:"col-3 col-sm-12"},["inloop"==t.modalData.method?a("label",{staticClass:"form-label",attrs:{for:"rr"}},[t._v("CPU rest time (s)")]):a("label",{staticClass:"form-label",attrs:{for:"rr"}},[t._v("Bounce time (s)")])]),a("div",{staticClass:"col-9 col-sm-12"},[a("input",{directives:[{name:"model",rawName:"v-model",value:t.modalData.time,expression:"modalData.time"}],staticClass:"form-input",attrs:{type:"number",step:"0.01",id:"rr",min:"0.01"},domProps:{value:t.modalData.time},on:{input:function(e){e.target.composing||t.$set(t.modalData,"time",e.target.value)}}}),"inloop"==t.modalData.method?a("p",{staticClass:"text-gray text-italic"},[t._v("The smaller the value, the faster the response, but the greater the CPU demand.")]):a("p",{staticClass:"text-gray text-italic"},[t._v("Software debouncing for switch bounce.")])])])])])]),a("div",{staticClass:"modal-footer"},[a("button",{directives:[{name:"show",rawName:"v-show",value:-1!==t.modalData.id,expression:"modalData.id !== -1"}],staticClass:"btn btn-code float-left",attrs:{disabled:this.loading},on:{click:function(e){return t.modalAction(!0)}}},[a("i",{staticClass:"icon icon-delete"}),t._v(" Delete")]),a("button",{staticClass:"btn btn-primary",attrs:{disabled:this.loading},on:{click:function(e){return t.modalAction(!1)}}},[a("i",{staticClass:"icon icon-check"}),t._v(" Confirm")])])])]),a("div",{staticClass:"container"},[t.inputs.length||t.loading?a("div",{staticClass:"columns"},t._l(t.inputs,(function(e){return a("div",{key:e.id,staticClass:"column",class:[t.col]},[a("div",{staticClass:"tile tile-centered"},[a("div",{staticClass:"tile-icon"},[a("button",{staticClass:"btn btn-action btn-lg unclickable",class:[t.stateButton(e.state,e.reverse)]},[a("i",{staticClass:"icon icon-flag centered"})])]),a("div",{staticClass:"tile-content"},[a("div",{staticClass:"tile-title"},[t._v(t._s(e.name))]),a("div",{staticClass:"tile-subtitle text-gray"},[t._v(t._s(t.inputDisc(e.gpio,e.reverse,e.method)))])]),a("div",{staticClass:"tile-action"},[a("button",{staticClass:"btn btn-link",on:{click:function(a){return t.openModal("Edit: "+e.name,e.name,e.gpio,!!e.reverse,e.method,e.id,e.resistor,e.time)}}},[a("i",{staticClass:"icon icon-edit"})])])])])})),0):a("div",{staticClass:"empty centered"},[t._m(5),a("p",{staticClass:"empty-title h5"},[t._v("There are no inputs configured")]),a("p",{staticClass:"empty-subtitle"},[t._v("Click the button to configure new")]),a("div",{staticClass:"empty-action"},[a("button",{staticClass:"btn btn-primary",on:{click:function(e){return t.openModal("Add new input","","",!1,"inloop",-1,1,.05)}}},[a("i",{staticClass:"icon icon-plus centered"})])])])])]),a("div",{staticClass:"panel-footer"},[a("span",{staticClass:"text-secondary"},[t._v("Last update: "+t._s(t.updateDate))]),a("div",{staticClass:"float-right tooltip tooltip-left",attrs:{"data-tooltip":"Auto refresh time (s)"}},[a("input",{directives:[{name:"model",rawName:"v-model",value:t.autoRefreshTime,expression:"autoRefreshTime"}],staticClass:"form-input input-sm",attrs:{type:"number",id:"autorefresh"},domProps:{value:t.autoRefreshTime},on:{change:function(e){return t.autoRefresh()},input:function(e){e.target.composing||(t.autoRefreshTime=e.target.value)}}})])])])])},l=[function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"panel-title"},[a("h3",[t._v("GPIO Inputs")])])},function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"col-3 col-sm-12"},[a("label",{staticClass:"form-label",attrs:{for:"name"}},[t._v("Name")])])},function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"col-3 col-sm-12"},[a("label",{staticClass:"form-label",attrs:{for:"gpio"}},[t._v("GPIO(BCM)")])])},function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"col-3 col-sm-12"},[a("label",{staticClass:"form-label",attrs:{for:"type"}},[t._v("Resistor")])])},function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"col-3 col-sm-12"},[a("label",{staticClass:"form-label",attrs:{for:"type"}},[t._v("Method")])])},function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"empty-icon"},[a("i",{staticClass:"icon icon-4x icon-cross"})])}],n={name:"GPIO_Input",data(){return{inputs:[],refreshInterval:"",updateDate:"",autoRefreshTime:5,modalData:{active:!1,id:-1,title:"New input",name:"",gpio:"",prevsGpios:"",reverse:!1,resistor:"1",method:"inloop",time:.05,errors:[],allUsedPins:[],outputs:[]}}},props:{col:{type:String,default:"col-4 col-lg-6 col-sm-12"}},created(){this.getInputs(),this.$cookies.isKey("in_arTime")&&(this.autoRefreshTime=parseInt(this.$cookies.get("in_arTime"))),this.autoRefresh()},beforeDestroy(){clearTimeout(this.refreshInterval)},methods:{autoRefresh(){this.$cookies.set("in_arTime",this.autoRefreshTime,-1),clearTimeout(this.refreshInterval),this.autoRefreshTime>0&&(this.refreshInterval=setTimeout(()=>{this.modalData.active||this.getInputs(),this.autoRefresh()},1e3*this.autoRefreshTime))},openModal(t,e,a,s,i,o,r,l){this.modalData.active=!0,this.modalData.title=t,this.modalData.name=e,this.modalData.gpio=a,this.modalData.prevsGpios=a,this.modalData.reverse=s,this.modalData.method=i,this.modalData.resistor=r,this.modalData.time=l,this.modalData.id=o,this.modalData.allUsedPins=[],this.modalData.errors=[],this.modalData.outputs=[],this.doPosts([this.doQPost("AllUsedPins_GPIO;in;"+o).then(t=>{for(var e=2;e<t.length-1;e++)this.modalData.allUsedPins.push(t[e])})]).catch(t=>{this.modalData.errors.push(t.message)})},modalAction(t){if(this.modalData.errors=[],!t)if(this.modalData.name||this.modalData.errors.push("Name required !"),isNaN(this.modalData.gpio)||""==this.modalData.gpio||null==this.modalData.gpio)this.modalData.errors.push("GPIO must be a number !");else{let t=this.modalData.gpio.toString().split(",");var e=this.isGPIOnumber(t);if(-1!=e)this.modalData.errors.push(e+" is not a GPIO BCM number !");else for(let e=0;e<t.length;e++)this.modalData.allUsedPins.indexOf(t[e])>-1&&this.modalData.errors.push(t[e]+" allready in use !")}if(!this.modalData.errors.length){let e="";e=t?"Delete_GPIO_out;"+this.modalData.id+";"+this.modalData.gpio+";"+this.modalData.name+";"+this.modalData.method:-1===this.modalData.id?"Add_GPIO_in;"+this.modalData.gpio+";"+this.modalData.name+";"+this.$moment.utc().format("YYYY-MM-DD HH:mm:ss.SSS")+";"+ +this.modalData.reverse+";"+this.modalData.time+";"+this.modalData.resistor+";"+this.modalData.method:"Edit_GPIO_in;"+this.modalData.id+";"+this.modalData.gpio+";"+this.modalData.name+";"+this.$moment.utc().format("YYYY-MM-DD HH:mm:ss.SSS")+";"+ +this.modalData.reverse+";"+this.modalData.time+";"+this.modalData.resistor+";"+this.modalData.prevsGpios+";"+this.modalData.method,this.doPost(e).then(()=>{this.getInputs(),this.modalData.active=!1}).catch(t=>{this.modalData.errors.push(t.message)})}},inputDisc(t,e,a){let s="GPIO: "+t;return"inloop"==a?s+="(l)":"ined"==a&&(s+="(e)"),e&&(s+="(r)"),s},getInputs(){this.doPost("GPIO_Ilist").then(t=>{this.$route.meta.error=null,this.inputs=[];for(var e=2;e<t.length-1;e+=8)this.inputs.push({id:parseInt(t[e]),gpio:parseInt(t[e+1]),state:parseInt(t[e+2]),name:t[e+3],reverse:parseInt(t[e+4]),time:parseFloat(t[e+5])/1e3,resistor:parseInt(t[e+6]),method:t[e+7]});this.updateDate=this.$moment().format("YYYY-MM-DD HH:mm:ss.SSS")}).catch(t=>{this.$route.meta.error=t.message,this.$forceUpdate()})}},components:{Error:o["a"]}},c=n,m=a("2877"),d=Object(m["a"])(c,r,l,!1,null,null,null),u=d.exports,h=a("49a3"),p={name:"Inputs",components:{Error:o["a"],GPIO_Input:u,History:h["a"]}},v=p,f=Object(m["a"])(v,s,i,!1,null,null,null);e["default"]=f.exports}}]);