diff --git a/Readme.md b/Readme.md index e53c739..c02260a 100644 --- a/Readme.md +++ b/Readme.md @@ -11,3 +11,8 @@ Adress 0x21 ## 2.0 LCD The LCD display is driven on the same i2c bus as the keypad. +nterface Definition +BYTE BIT +7 (MSB) 6 5 4 3 2 1 0 (LSB) +I2C slave address L H L L A2 A1 A0 R/W +I/O data bus P7 P6 P5 P4 P3 P2 P1 P0 diff --git a/data/s/bundle.357e7.js b/data/s/bundle.357e7.js deleted file mode 100644 index 5e6bf43..0000000 --- a/data/s/bundle.357e7.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(t){return e[t]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s="/ODT")}({"/ODT":function(e,t,n){"use strict";function r(e,t){for(var n in t)e[n]=t[n];return e}function o(e){var t=e.parentNode;t&&t.removeChild(e)}function i(e,t,n){var r,o,i,l={};for(i in t)"key"==i?r=t[i]:"ref"==i?o=t[i]:l[i]=t[i];if(arguments.length>2&&(l.children=arguments.length>3?P.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(i in e.defaultProps)void 0===l[i]&&(l[i]=e.defaultProps[i]);return u(e,l,r,o,null)}function u(e,t,n,r,o){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++C:o};return null==o&&null!=x.vnode&&x.vnode(i),i}function l(e){return e.children}function c(e,t){this.props=e,this.context=t}function a(e,t){if(null==t)return e.__?a(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t0?u(v.type,v.props,v.key,null,v.__v):v)){if(v.__=n,v.__b=n.__b+1,null===(y=S[p])||y&&v.key==y.key&&v.type===y.type)S[p]=void 0;else for(b=0;b=n.__.length&&n.__.push({}),n.__[e]}function o(e){return y=1,i(f,e)}function i(e,t,n){var o=r(p++,2);return o.t=e,o.__c||(o.__=[n?n(t):f(void 0,t),function(e){var t=o.t(o.__[0],e);o.__[0]!==t&&(o.__=[t,o.__[1]],o.__c.setState({}))}],o.__c=h),o.__}function u(e,t){var n=r(p++,3);!b.options.__s&&_(n.__H,t)&&(n.__=e,n.__H=t,h.__H.__h.push(n))}function l(e){var t=h.context[e.__c],n=r(p++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(h)),t.props.value):e.__}function c(){for(var e;e=v.shift();)if(e.__P)try{e.__H.__h.forEach(a),e.__H.__h.forEach(s),e.__H.__h=[]}catch(t){e.__H.__h=[],b.options.__e(t,e.__v)}}function a(e){var t=h,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),h=t}function s(e){var t=h;e.__c=e.__(),h=t}function _(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function f(e,t){return"function"==typeof t?t(e):t}n.d(t,"d",(function(){return o})),n.d(t,"c",(function(){return i})),n.d(t,"b",(function(){return u})),n.d(t,"a",(function(){return l}));var p,h,d,b=n("hosL"),y=0,v=[],m=b.options.__b,g=b.options.__r,O=b.options.diffed,j=b.options.__c,k=b.options.unmount;b.options.__b=function(e){h=null,m&&m(e)},b.options.__r=function(e){g&&g(e),p=0;var t=(h=e.__c).__H;t&&(t.__h.forEach(a),t.__h.forEach(s),t.__h=[])},b.options.diffed=function(e){O&&O(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(1!==v.push(t)&&d===b.options.requestAnimationFrame||((d=b.options.requestAnimationFrame)||function(e){var t,n=function(){clearTimeout(r),w&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);w&&(t=requestAnimationFrame(n))})(c)),h=null},b.options.__c=function(e,t){t.some((function(e){try{e.__h.forEach(a),e.__h=e.__h.filter((function(e){return!e.__||s(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],b.options.__e(n,e.__v)}})),j&&j(e,t)},b.options.unmount=function(e){k&&k(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{a(e)}catch(e){t=e}})),t&&b.options.__e(t,n.__v))};var w="function"==typeof requestAnimationFrame},QfWi:function(e,t,n){"use strict";function r(e,t){for(var n in t)e[n]=t[n];return e}function o(e,t,n){var r,o=/(?:\?([^#]*))?(#.*)?$/,i=e.match(o),u={};if(i&&i[1])for(var c=i[1].split("&"),a=0;at.rank?-1:e.index-t.index}function u(e,t){return e.index=t,e.rank=function(e){return e.props.default?0:(t=e.props.path,l(t).map(c).join(""));var t}(e),e.props}function l(e){return e.replace(/(^\/+|\/+$)/g,"").split("/")}function c(e){return":"==e.charAt(0)?1+"*+?".indexOf(e.charAt(e.length-1))||4:5}function a(){var e;return""+((e=ne&&ne.location?ne.location:ne&&ne.getCurrentLocation?ne.getCurrentLocation():"undefined"!=typeof location?location:ie).pathname||"")+(e.search||"")}function s(e,t){return void 0===t&&(t=!1),"string"!=typeof e&&e.url&&(t=e.replace,e=e.url),function(e){for(var t=re.length;t--;)if(re[t].canRoute(e))return!0;return!1}(e)&&function(e,t){void 0===t&&(t="push"),ne&&ne[t]?ne[t](e):"undefined"!=typeof history&&history[t+"State"]&&history[t+"State"](null,null,e)}(e,t?"replace":"push"),_(e)}function _(e){for(var t=!1,n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:"azif7eqCl5",t=yield fetch("".concat(_e,"/api/userdb"),{method:"GET",mode:"cors",headers:{Authentification:e}}).then((function(e){return e.text()})).then((function(e){return w(e)}));return t})),k.apply(this,arguments)}function w(e){var t=e.split("\n"),n=[];return t.map((function(e,t){var r=v(e.split([";"]),6);n.push({line:t,uid:r[0],first_name:r[1],last_name:r[2],rfid_uid:r[3],user_pin:r[4],enabled:"1"===r[5][0]})})),n}function S(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function A(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0},t.prototype.routeTo=function(e){this.setState({url:e});var t=this.canRoute(e);return this.updating||this.forceUpdate(),t},t.prototype.componentWillMount=function(){re.push(this),this.updating=!0},t.prototype.componentDidMount=function(){var e=this;ne&&(this.unlisten=ne.listen((function(t){e.routeTo(""+(t.pathname||"")+(t.search||""))}))),this.updating=!1},t.prototype.componentWillUnmount=function(){"function"==typeof this.unlisten&&this.unlisten(),re.splice(re.indexOf(this),1)},t.prototype.componentWillUpdate=function(){this.updating=!0},t.prototype.componentDidUpdate=function(){this.updating=!1},t.prototype.getMatchingChildren=function(e,t,n){return e.filter(u).sort(i).map((function(e){var i=o(t,e.props.path,e.props);if(i){if(!1!==n){var u={url:t,matches:i};return r(u,i),delete u.ref,delete u.key,Object(ee.cloneElement)(e,u)}return e}})).filter(Boolean)},t.prototype.render=function(e,t){var n=e.children,r=e.onChange,o=t.url,i=this.getMatchingChildren(Object(ee.toChildArray)(n),o,!0),u=i[0]||null,l=this.previousUrl;return o!==l&&(this.previousUrl=o,"function"==typeof r&&r({router:this,url:o,previous:l,active:i,current:u})),u},t}(ee.Component),ce=function(e){return Object(ee.createElement)("a",r({onClick:p},e))};le.subscribers=oe,le.getCurrentUrl=a,le.route=s,le.Router=le,le.Route=function(e){return Object(ee.createElement)(e.component,e)},le.Link=ce,le.exec=o;var ae=n("QRet"),se=function(){return Object(ee.h)("div",{class:"container"},Object(ee.h)("h1",null,"Home"),Object(ee.h)("p",null,"This is the Home component."))},_e="http://192.168.4.22",fe={login:function(){return j.apply(this,arguments)},logout:function(){return"DUMMYTOKEN"},checkAuth:function(e){return"DUMMYTOKEN"===e},parsedb:w,fetchdb:function(){return k.apply(this,arguments)}},pe=function(e){for(var t=1;t2&&(l.children=arguments.length>3?U.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(i in e.defaultProps)void 0===l[i]&&(l[i]=e.defaultProps[i]);return u(e,l,r,o,null)}function u(e,t,n,r,o){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++T:o};return null==o&&null!=I.vnode&&I.vnode(i),i}function l(){return{current:null}}function c(e){return e.children}function a(e,t){this.props=e,this.context=t}function s(e,t){if(null==t)return e.__?s(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t0?u(v.type,v.props,v.key,null,v.__v):v)){if(v.__=n,v.__b=n.__b+1,null===(b=k[p])||b&&v.key==b.key&&v.type===b.type)k[p]=void 0;else for(h=0;h2&&(c.children=arguments.length>3?U.call(arguments,2):n),u(e.type,c,o||e.key,i||e.ref,null)}function D(e,t){var n={__c:t="__cC"+H++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var n,r;return this.getChildContext||(n=[],(r={})[t]=this,this.getChildContext=function(){return r},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&n.some(f)},this.sub=function(e){n.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n.splice(n.indexOf(e),1),t&&t.call(e)}}),e.children}};return n.Provider.__=n.Consumer.contextType=n}n.r(t),n.d(t,"render",(function(){return x})),n.d(t,"hydrate",(function(){return C})),n.d(t,"createElement",(function(){return i})),n.d(t,"h",(function(){return i})),n.d(t,"Fragment",(function(){return c})),n.d(t,"createRef",(function(){return l})),n.d(t,"isValidElement",(function(){return N})),n.d(t,"Component",(function(){return a})),n.d(t,"cloneElement",(function(){return E})),n.d(t,"createContext",(function(){return D})),n.d(t,"toChildArray",(function(){return b})),n.d(t,"options",(function(){return I}));var U,I,T,N,M,L,R,H,W={},F=[],$=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;U=F.slice,I={__e:function(e,t){for(var n,r,o;t=t.__;)if((n=t.__c)&&!n.__)try{if((r=n.constructor)&&null!=r.getDerivedStateFromError&&(n.setState(r.getDerivedStateFromError(e)),o=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(e),o=n.__d),o)return n.__E=n}catch(t){e=t}throw e}},T=0,N=function(e){return null!=e&&void 0===e.constructor},a.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=r({},this.state),"function"==typeof e&&(e=e(r({},n),this.props)),e&&r(n,e),null!=e&&this.__v&&(t&&this.__h.push(t),f(this))},a.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),f(this))},a.prototype.render=c,M=[],L="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,p.__r=0,H=0},z8Av:function(e,t,n){"use strict";(function(e){function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,o,i=[],u=!0,l=!1;try{for(n=n.call(e);!(u=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{u||null==n.return||n.return()}finally{if(l)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=n.__.length&&n.__.push({}),n.__[e]}function o(e){return v=1,i(p,e)}function i(e,t,n){var o=r(d++,2);return o.t=e,o.__c||(o.__=[n?n(t):p(void 0,t),function(e){var t=o.t(o.__[0],e);o.__[0]!==t&&(o.__=[t,o.__[1]],o.__c.setState({}))}],o.__c=b),o.__}function u(e,t){var n=r(d++,3);!_.options.__s&&h(n.__H,t)&&(n.__=e,n.__H=t,b.__H.__h.push(n))}function a(e,t){var n=r(d++,7);return h(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function c(e){var t=b.context[e.__c],n=r(d++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(b)),t.props.value):e.__}function l(){for(var e;e=y.shift();)if(e.__P)try{e.__H.__h.forEach(s),e.__H.__h.forEach(f),e.__H.__h=[]}catch(t){e.__H.__h=[],_.options.__e(t,e.__v)}}function s(e){var t=b,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),b=t}function f(e){var t=b;e.__c=e.__(),b=t}function h(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function p(e,t){return"function"==typeof t?t(e):t}n.d(t,"e",(function(){return o})),n.d(t,"d",(function(){return i})),n.d(t,"b",(function(){return u})),n.d(t,"c",(function(){return a})),n.d(t,"a",(function(){return c}));var d,b,m,_=n("hosL"),v=0,y=[],O=_.options.__b,g=_.options.__r,j=_.options.diffed,w=_.options.__c,S=_.options.unmount;_.options.__b=function(e){b=null,O&&O(e)},_.options.__r=function(e){g&&g(e),d=0;var t=(b=e.__c).__H;t&&(t.__h.forEach(s),t.__h.forEach(f),t.__h=[])},_.options.diffed=function(e){j&&j(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(1!==y.push(t)&&m===_.options.requestAnimationFrame||((m=_.options.requestAnimationFrame)||function(e){var t,n=function(){clearTimeout(r),k&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);k&&(t=requestAnimationFrame(n))})(l)),b=null},_.options.__c=function(e,t){t.some((function(e){try{e.__h.forEach(s),e.__h=e.__h.filter((function(e){return!e.__||f(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],_.options.__e(n,e.__v)}})),w&&w(e,t)},_.options.unmount=function(e){S&&S(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{s(e)}catch(e){t=e}})),t&&_.options.__e(t,n.__v))};var k="function"==typeof requestAnimationFrame},QfWi:function(e,t,n){"use strict";function r(e,t){for(var n in t)e[n]=t[n];return e}function o(e,t,n){var r,o=/(?:\?([^#]*))?(#.*)?$/,i=e.match(o),u={};if(i&&i[1])for(var c=i[1].split("&"),l=0;lt.rank?-1:e.index-t.index}function u(e,t){return e.index=t,e.rank=function(e){return e.props.default?0:(t=e.props.path,a(t).map(c).join(""));var t}(e),e.props}function a(e){return e.replace(/(^\/+|\/+$)/g,"").split("/")}function c(e){return":"==e.charAt(0)?1+"*+?".indexOf(e.charAt(e.length-1))||4:5}function l(){var e;return""+((e=je&&je.location?je.location:je&&je.getCurrentLocation?je.getCurrentLocation():"undefined"!=typeof location?location:ke).pathname||"")+(e.search||"")}function s(e,t){return void 0===t&&(t=!1),"string"!=typeof e&&e.url&&(t=e.replace,e=e.url),function(e){for(var t=we.length;t--;)if(we[t].canRoute(e))return!0;return!1}(e)&&function(e,t){void 0===t&&(t="push"),je&&je[t]?je[t](e):"undefined"!=typeof history&&history[t+"State"]&&history[t+"State"](null,null,e)}(e,t?"replace":"push"),f(e)}function f(e){for(var t=!1,n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:null,t=localStorage.getItem("token"),n=localStorage.getItem("username"),r=null!==t&&null!==n&&(yield I(t));return r&&null!==e&&e({type:"start",token:t,username:n}),r?{active:!0,token:t,username:n}:{active:!1}})),A.apply(this,arguments)}function N(){return x.apply(this,arguments)}function x(){return(x=k((function*(e,t){return e.token=yield t,e.type="start",console.log(e),e.permanent&&(localStorage.setItem("token",e.token),localStorage.setItem("username",e.username)),e}))).apply(this,arguments)}function P(){return(P=k((function*(e){var t=new FormData;t.append("username",e.username),t.append("password",e.password),t.append("action","login");var n={username:e.username,permanent:e.permanent},r=new AbortController;setTimeout((function(){return r.abort()}),De),yield fetch("".concat(Ee,"/api/auth"),{signal:r.signal,method:"POST",mode:"cors",body:t}).then((function(e){if(e.ok)return N(n,e.text());if(401!==e.status)throw new Error(e.error);return n.error="login_failed",n})).catch((function(){n.error="network_connection"}));return n}))).apply(this,arguments)}function C(){return(C=k((function*(e){var t=new FormData;t.append("token",e),t.append("action","logout");var n=fetch("".concat(Ee,"/api/auth"),{method:"POST",mode:"cors",body:t}).then((function(e){return e.text()}));return localStorage.clear(),n}))).apply(this,arguments)}function I(){return E.apply(this,arguments)}function E(){return(E=k((function*(e){var t=new FormData;t.append("token",e),t.append("action","check");var n=yield fetch("".concat(Ee,"/api/auth"),{method:"POST",mode:"cors",body:t}).then((function(e){return e.text()})).then((function(e){return"valid"===e}));return yield n}))).apply(this,arguments)}function D(){return D=k((function*(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"azif7eqCl5",t=yield fetch("".concat(Ee,"/api/userdb"),{method:"GET",mode:"cors",headers:{Authentification:e}}).then((function(e){return e.text()})).then((function(e){return L(e)}));return t})),D.apply(this,arguments)}function U(){return(U=k((function*(e,t){return yield fetch("".concat(Ee,"/api/user/"),{method:"POST",body:JSON.stringify(t),mode:"cors",headers:{Authentification:e}}).then((function(e){return e.json()}))}))).apply(this,arguments)}function T(){return(T=k((function*(e,t){return yield fetch("".concat(Ee,"/api/user/").concat(t.uid),{method:"DELETE",body:JSON.stringify(t),mode:"cors",headers:{Authentification:e}}).then((function(e){return e.json()}))}))).apply(this,arguments)}function z(){return(z=k((function*(e,t){return yield fetch("".concat(Ee,"/api/user/"),{method:"PUT",body:JSON.stringify(t),mode:"cors",headers:{Authentification:e}}).then((function(e){return e.json()}))}))).apply(this,arguments)}function L(e){var t=e.split("\n"),n=[];return t.map((function(e,t){var r=g(e.split([";"]),6);n.push({line:t,uid:r[0],first_name:r[1],last_name:r[2],rfid_uid:r[3],user_pin:r[4],enabled:"1"===r[5][0]})})),n}function M(){return(M=k((function*(e){return yield fetch("".concat(Ee,"/api/rfid"),{method:"GET",mode:"cors",headers:{Authentification:e}}).then((function(e){return e.json()}))}))).apply(this,arguments)}function B(){return(B=k((function*(e,t){for(var n=new FormData,r=0,o=Object.entries(t);re.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return u=e.done,e},e:function(e){a=!0,i=e},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw i}}}}function J(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,o,i=[],u=!0,a=!1;try{for(n=n.call(e);!(u=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);u=!0);}catch(e){a=!0,o=e}finally{try{u||null==n.return||n.return()}finally{if(a)throw o}}return i}(e,t)||Q(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Q(e,t){if(e){if("string"==typeof e)return Y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Y(e,t):void 0}}function Y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0},t.prototype.routeTo=function(e){this.setState({url:e});var t=this.canRoute(e);return this.updating||this.forceUpdate(),t},t.prototype.componentWillMount=function(){we.push(this),this.updating=!0},t.prototype.componentDidMount=function(){var e=this;je&&(this.unlisten=je.listen((function(t){e.routeTo(""+(t.pathname||"")+(t.search||""))}))),this.updating=!1},t.prototype.componentWillUnmount=function(){"function"==typeof this.unlisten&&this.unlisten(),we.splice(we.indexOf(this),1)},t.prototype.componentWillUpdate=function(){this.updating=!0},t.prototype.componentDidUpdate=function(){this.updating=!1},t.prototype.getMatchingChildren=function(e,t,n){return e.filter(u).sort(i).map((function(e){var i=o(t,e.props.path,e.props);if(i){if(!1!==n){var u={url:t,matches:i};return r(u,i),delete u.ref,delete u.key,Object(Oe.cloneElement)(e,u)}return e}})).filter(Boolean)},t.prototype.render=function(e,t){var n=e.children,r=e.onChange,o=t.url,i=this.getMatchingChildren(Object(Oe.toChildArray)(n),o,!0),u=i[0]||null,a=this.previousUrl;return o!==a&&(this.previousUrl=o,"function"==typeof r&&r({router:this,url:o,previous:a,active:i,current:u})),u},t}(Oe.Component),xe=function(e){return Object(Oe.createElement)("a",r({onClick:p},e))};Ne.subscribers=Se,Ne.getCurrentUrl=l,Ne.route=s,Ne.Router=Ne,Ne.Route=function(e){return Object(Oe.createElement)(e.component,e)},Ne.Link=xe,Ne.exec=o;var Pe=n("QRet"),Ce=n("YRIq"),Ie=function(){var e=m(Object(Pe.a)(Ce.b).session,1)[0];return Object(Oe.h)("div",{class:"container"},Object(Oe.h)(Qe,{items:["Startseite"]}),Object(Oe.h)("div",{className:"contentbox"},Object(Oe.h)("h2",null,"Startseite"),Object(Oe.h)("p",null,"Willkommen zurück ",e.username," "),Object(Oe.h)("div",null,Object(Oe.h)("h3",null,"Status"),Object(Oe.h)("ul",null,Object(Oe.h)("li",null,"Aktiv seit: 12.01.2022"))),Object(Oe.h)("div",null,Object(Oe.h)("p",null,"Hier können Sie den Türöffner manuell aktivieren."),Object(Oe.h)("p",null,"Um Benutzer anzulegen, öffnen sie das Menü und tippen auf ",Object(Oe.h)(xe,{href:"/newuser"},"Benutzer anlegen")," "))))},Ee="/",De=1500,Ue={login:function(){return P.apply(this,arguments)},logout:function(){return C.apply(this,arguments)},checkAuth:I,parsedb:L,fetchdb:function(){return D.apply(this,arguments)},createCsvTable:function(e){var t,n="",r=!0,o=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=j(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return u=e.done,e},e:function(e){a=!0,i=e},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw i}}}}(e);try{for(o.s();!(t=o.n()).done;){var i=t.value;r&&(r=!1),n+="".concat(!r&&"\n").concat(i.uid,",").concat(i.first_name,",").concat(i.last_name,",").concat(i.rfid_uid,",").concat(i.user_pin,",").concat(i.enabled?"1":"0")}}catch(e){o.e(e)}finally{o.f()}return n},updateUser:function(){return U.apply(this,arguments)},deleteUser:function(){return T.apply(this,arguments)},createUser:function(){return z.apply(this,arguments)},restoreSession:function(){return A.apply(this,arguments)},catchRFID:function(){return M.apply(this,arguments)},config:function(){return B.apply(this,arguments)}},Te=function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:["uid","first_name","last_name"],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=t.toLowerCase().split(" "),u=0,a=Z(i);try{for(a.s();!(n=a.n()).done;){var c,l=n.value,s=!1,f=Z(r);try{for(f.s();!(c=f.n()).done;){var h=e[c.value].toLowerCase();if(o?h==l:h.includes(l)){s=!0;break}}}catch(e){f.e(e)}finally{f.f()}if(s&&(u+=1)>=i.length)return!0}}catch(e){a.e(e)}finally{a.f()}return!1}(e,a.query)})):r}),[a.query,r]);return Object(Pe.b)((function(){c((function(e){var t=Math.ceil(l.length/e.limit);return G(G({},e),{},e.page>=t?{pages:t,page:t}:{pages:t})}))}),[l.length,a.limit]),Object(Pe.b)((function(){t&&!isNaN(t)&&c((function(e){return G(G({},e),{},{page:t})}))}),[t]),Object(Oe.h)("div",{class:"container"},Object(Oe.h)(Qe,{items:["Benutzerverwaltung","Übersicht"]}),Object(Oe.h)("div",{className:"contentbox"},Object(Oe.h)("div",null,"Suche: ",Object(Oe.h)("input",{type:"text",onInput:function(e){return c((function(t){return G(G({},t),{},{query:e.target.value})}))},value:a.query}),Object(Oe.h)("button",null,"Hinzufügen"),"Limit: ",Object(Oe.h)("select",{onChange:function(e){c((function(t){return G(G({},t),{},{limit:e.target.value})})),console.log(e.target.value),console.log(a)},value:a.limit},Object(Oe.h)("optgroup",{label:"Anzahl"},Object(Oe.h)("option",null,"10"),Object(Oe.h)("option",null,"25"),Object(Oe.h)("option",null,"50"),Object(Oe.h)("option",null,"100"),Object(Oe.h)("option",null,"200")),Object(Oe.h)("option",null,"Alle")))),Object(Oe.h)(et,$({},{start:a.limit*(a.page-1),end:a.limit*a.page},{userlist:l,deleteUser:function(e){Te.deleteUser(i.token,e).then((function(t){o({type:"delete",user:e,r:t})}))},editUser:function(e){s("/edituser/".concat(e.uid))}})),Object(Oe.h)(Ye,{start:1,end:a.pages,current:a.page,setPage:function(e){e.preventDefault(),console.log(e);var t=e.target.text;c((function(e){return G(G({},e),{},{page:t})}))}}))},qe=n("aqHq"),We=function(e){var t=e.userid,n=ne(Object(Pe.a)(Re).session,1)[0],r=Object(Pe.a)(ze),o=r.usertable,i=r.userreducer,u=ne(Object(Pe.e)({}),2),a=u[0],c=u[1],l=ne(Object(Pe.e)({active:!1,rfidscaninterval:null}),2),f=l[0],h=l[1];Object(Pe.b)((function(){null===f.rfidscaninterval&&f.active?f.rfidscaninterval=setInterval((function(){Te.catchRFID(n.token).then((function(e){e.rfid_uid&&(c((function(t){return ee(ee({},t),{},{rfid_uid:e.rfid_uid})})),h((function(e){return ee(ee({},e),{},{active:!1})})))})).catch((function(){h((function(e){return ee(ee({},e),{},{active:!1})}))}))}),1e3):null===f.rfidscaninterval||f.active||(clearInterval(f.rfidscaninterval),h((function(e){return ee(ee({},e),{},{rfidscaninterval:null})})))}),[f]),Object(Pe.b)((function(){var e=void 0!==t?o.find((function(e){return e.uid===t})):void 0;void 0!==e&&c(e)}),[t,o]);var p=function(e){e.preventDefault();var t,r=(t=a,o.reduce((function(e,n){return e+n.uid==t.uid?1:0}),0));console.log(r),void 0!==a.line?(Te.updateUser(n.token,a).then((function(e){i({type:"update",user:e})})),s("/users")):0===r?(Te.createUser(n.token,a).then((function(e){i({type:"create",user:e})})),s("/users")):alert("UID ".concat(a.uid," wurde bereits ").concat(r," mal benutzt"))};return Object(Oe.h)("div",{className:"container"},Object(Oe.h)(Qe,{items:["Benutzerverwaltung",null!=a.line?"Benutzer Bearbeiten":"Neuer Benutzer"]}),Object(Oe.h)("div",{className:"contentbox"},Object(Oe.h)("h2",null,null!=a.line?"Benutzer Bearbeiten":"Neuer Benutzer"),Object(Oe.h)("form",{onSubmit:p},Object(Oe.h)("h3",null,"Eindeutige Identifikationsnummer"),Object(Oe.h)("div",{className:"row"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{info:!0,formdata:a,formchange:c,id:"uid",label:"Benutzer-ID",maxlength:10,showavailable:!0})),Object(Oe.h)("div",{className:"column"},Object(Oe.h)("b",null,"Info"),Object(Oe.h)("span",null," Nummer muss einmalig sein"))),Object(Oe.h)("h3",null,"Persönliche Daten"),Object(Oe.h)("div",{className:"row"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{formdata:a,formchange:c,id:"first_name",label:"Vorname",maxlength:25,showavailable:!0})),Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{formdata:a,formchange:c,id:"last_name",label:"NachName",maxlength:25,showavailable:!0}))),Object(Oe.h)("h3",null,"Authentifizierung"),Object(Oe.h)("div",{className:"row"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{formdata:a,formchange:c,id:"rfid_uid",label:"RFID",maxlength:8,disabled:f.active,overridevalue:f.active&&"Scannen...",showavailable:!0})),Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.a,{onClick:function(e){e.preventDefault(),h((function(e){return ee(ee({},e),{},{active:!e.active})}))}},f.active?"Abbrechen":"Scannen"))),Object(Oe.h)("div",{className:"row"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{formdata:a,formchange:c,id:"user_pin",label:"Pin",maxlength:10,showavailable:!0})),Object(Oe.h)("div",{className:"column"},Object(Oe.h)("b",null,"Info"),Object(Oe.h)("span",null,"Achten Sie darauf, eine PIN ",Object(Oe.h)("br",null),"nicht mehrfach zu benutzen."))),Object(Oe.h)("h3",null,"Status"),Object(Oe.h)("div",{className:"row"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.b,{formdata:a,formchange:c,id:"enabled",type:"checkbox",label:"Benutzer darf sich anmelden"}))),Object(Oe.h)("div",{className:"row",style:"justify-content: space-between"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.a,{onClick:p},"Speichern")),Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.a,{onClick:function(e){e.preventDefault();var n=void 0!==t?o.find((function(e){return e.uid===t})):void 0;c(void 0!==n?n:{})}},"Zurücksetzen"))))))},$e=function(){function e(e){e.preventDefault(),Te.login(i).then((function(e){void 0!==e.error?u(e):r(e)}))}var t=oe(Object(Pe.a)(Ce.b).session,2),n=t[0],r=t[1],o=oe(Object(Pe.e)({username:"",password:"",error:null}),2),i=o[0],u=o[1];return n.active&&s("/",!0),Object(Oe.h)("div",{class:"container"},Object(Oe.h)(Qe,{items:["Login"]}),Object(Oe.h)("div",{className:"contentbox"},Object(Oe.h)("h2",null,"Anmeldung"),Object(Oe.h)("p",null,"Bitte melden Sie sich mit ihren Nutzerdaten an."),"login_failed"===i.error&&Object(Oe.h)(nt.a,{title:"Anmeldefehler"},"Ungültige Anmeldedaten.",Object(Oe.h)("br",null),"Bitte überprüfen Sie den eingebenen Benutzernamen und das Passwort."),"network_connection"===i.error&&Object(Oe.h)(nt.a,{title:"Netwerkfehler"},"Die Kommunikation mit dem Gerät ist zurzeit nicht möglich.",Object(Oe.h)("br",null),"Bitte überprüfen Sie die Netzwerkverbindung."),Object(Oe.h)("form",{id:"login_form",onSubmit:e},Object(Oe.h)("div",{className:"row"},Object(Oe.h)(qe.c,{maxlength:25,formdata:i,formchange:u,id:"username",label:"Benutzername"})),Object(Oe.h)("div",{className:"row"},Object(Oe.h)(qe.c,{maxlength:25,formdata:i,formchange:u,id:"password",label:"Passwort",type:"password"})),Object(Oe.h)("div",{className:"row"},Object(Oe.h)(qe.b,{id:"permanent",formdata:i,formchange:u,label:"Angemeldet bleiben?"})),Object(Oe.h)(qe.a,{onClick:e},"Anmelden"))))},Ke=function(){var e=ue(Object(Pe.e)(""),2),t=e[0],n=e[1],r=ue(Object(Pe.a)(Ce.b).session,2),o=r[0],i=r[1];return this.shouldComponentUpdate=function(){console.log("functional component vs closures")},o.active&&(Te.logout(o.token).then((function(e){return n("success"===e?"Sitzung beendet.":"Sitzung war bereits nicht mehr vorhanden.")})),i({type:"end"})),Object(Oe.h)("div",{class:"container"},Object(Oe.h)(Qe,{items:["Logout"]}),Object(Oe.h)("div",{className:"contentbox"},Object(Oe.h)("h2",null,"Erfolgreich abgemeldet:"),Object(Oe.h)("p",null,t,Object(Oe.h)("br",null),Object(Oe.h)(xe,{className:"button",href:"/login"},"Erneut Anmelden"))))},Ge=function(e){var t=e.split(".");if(t.length>4)return!1;var n,r=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=he(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return u=e.done,e},e:function(e){a=!0,i=e},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw i}}}}(t);try{for(r.s();!(n=r.n()).done;){var o=n.value;if(isNaN(o)||o>255||o<0||o.length>3)return!1}}catch(e){r.e(e)}finally{r.f()}return!0},Ve=function(){var e=fe(Object(Pe.a)(Ce.b).session,1)[0],t=fe(Object(Pe.e)({}),2),n=t[0],r=t[1];return Object(Pe.b)((function(){Te.config(e.token,{action:"get"}).then((function(e){return r((function(t){return le(le({},t),e)}))}))}),[e]),Object(Oe.h)("div",{className:"container"},Object(Oe.h)(Qe,{items:["Systemeinstellungen"]}),Object(Oe.h)("div",{className:"contentbox"},Object(Oe.h)("h2",null,"System"),Object(Oe.h)("form",null,Object(Oe.h)("h3",null,"Geräteeinstellungen"),Object(Oe.h)("div",{className:"row"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{info:!0,formdata:n,formchange:r,id:"mode",label:"Modus",checkInput:function(e){return!isNaN(e)&&e>=0&&e<=1},maxlength:1,showavailable:!0,hinttext:"Nur Zahlen 0 bis 1"})),Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{info:!0,formdata:n,formchange:r,id:"fail_timeout",label:"Login Timeout",checkInput:function(e){return!isNaN(e)&&e>=0&&e<=255},maxlength:3,showavailable:!0,hinttext:"Nur Zahlen 0 bis 255"})),Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{info:!0,formdata:n,formchange:r,id:"hold_time",label:"Haltezeit",checkInput:function(e){return!isNaN(e)&&e>=0&&e<=255},maxlength:3,showavailable:!0,hinttext:"Nur Zahlen 0 bis 255"}))),Object(Oe.h)("h3",null,"WiFi Setup"),Object(Oe.h)("div",{className:"row"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{info:!0,formdata:n,formchange:r,id:"SSID",label:"WiFi Name",maxlength:31,showavailable:!0})),Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{info:!0,formdata:n,formchange:r,id:"PASS",label:"WiFi Passwort",maxlength:31,showavailable:!0}))),Object(Oe.h)("div",{className:"row"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{info:!0,formdata:n,formchange:r,id:"ip",label:"IP Adresse",maxlength:15,showavailable:!0,checkInput:Ge,hinttext:"Beispiel: 192.168.20.1"})),Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{info:!0,formdata:n,formchange:r,id:"subnet",label:"Netzmaske",maxlength:15,showavailable:!0,checkInput:Ge,hinttext:"Beispiel: 255.255.255.0"})),Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{info:!0,formdata:n,formchange:r,id:"gw",label:"Gateway",maxlength:15,showavailable:!0,checkInput:Ge,hinttext:"Beispiel: 0.0.0.0"}))),Object(Oe.h)("div",{className:"row"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.a,{onClick:function(){return null}},"Speichern")),Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.a,{onClick:function(){return null}},"Neustart")),Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.a,{onClick:function(){return null}},"Zurücksetzen")))),Object(Oe.h)("form",null,Object(Oe.h)("h3",null,"Admin User"),Object(Oe.h)("div",{className:"row"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{info:!0,formdata:n,formchange:r,id:"ip",label:"Name",maxlength:15,showavailable:!0}))),Object(Oe.h)("div",{className:"row"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{info:!0,formdata:n,formchange:r,id:"subnet",label:"Passwort",maxlength:15,showavailable:!0})),Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.c,{info:!0,formdata:n,formchange:r,id:"subnet",label:"Passwort wiederholen",maxlength:15,showavailable:!0}))),Object(Oe.h)("div",{className:"row"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.a,{onClick:function(){return null}},"Speichern")),Object(Oe.h)("div",{className:"column"},Object(Oe.h)(qe.a,{onClick:function(){return null}},"Zurücksetzen")))),Object(Oe.h)("h3",null,"Datenbank Backup"),Object(Oe.h)("div",{className:"row"},Object(Oe.h)("div",{className:"column"},Object(Oe.h)("h4",null,"Backup einspielen"),Object(Oe.h)("form",null,Object(Oe.h)("input",{type:"file"}),Object(Oe.h)("input",{type:"submit",value:"Hochladen"}))),Object(Oe.h)("div",{className:"column"},Object(Oe.h)("h4",null,"Backup herunterladen"),Object(Oe.h)("button",null,"Download")))))},Ze=[{text:"Übersicht",path:"/"},{text:"Benutzer anlegen",path:"/newuser"},{text:"Benutzer verwalten",path:"/users"},{text:"System",path:"/system"},{text:"Abmelden",path:"/logout"}],Je=function(){var e=Object(Pe.d)(Me,!1),t=Object(Pe.d)(Be,{}),n=be(Object(Pe.d)(He,[]),2),r=n[0],o=n[1];be(Object(Pe.e)("/"),2),(!t[0]||t[0]&&void 0===t[0].active)&&Te.restoreSession(t[1]),Object(Pe.b)((function(){t[0]&&t[0].active&&Te.fetchdb(t[0].token).then((function(e){o({type:"import",imported:e})}))}),[t]);var i=function(){var e,n=(e=function*(){t[0].active||s("/login",!0)},function(){var t=this,n=arguments;return new Promise((function(r,o){function i(e){de(a,r,o,i,u,"next",e)}function u(e){de(a,r,o,i,u,"throw",e)}var a=e.apply(t,n);i(void 0)}))});return function(e){return n.apply(this,arguments)}}();return Object(Oe.h)(Ce.a,{value:{menu:e,session:t}},Object(Oe.h)("div",{id:"wrapper"},Object(Oe.h)(Xe.a,{title:"Doorlock"}),Object(Oe.h)("div",{class:"page"},Object(Oe.h)(tt,{items:Ze}),!e[0]&&Object(Oe.h)(Le,{value:{usertable:r,userreducer:o}},Object(Oe.h)(Ne,{onChange:i},Object(Oe.h)(Ie,{path:"/",user:"me"}),Object(Oe.h)($e,{path:"login"}),Object(Oe.h)(Ve,{path:"/system"}),Object(Oe.h)(Ke,{path:"/logout"}),Object(Oe.h)(Fe,{path:"/users/:pageid?"}),Object(Oe.h)(We,{path:"/edituser/:userid?"}),Object(Oe.h)(We,{path:"/newuser"}),Object(Oe.h)("div",{class:"container",default:!0},"Error 404")))),Object(Oe.h)("footer",null,Object(Oe.h)("div",{className:"container",style:"text-align: center; align-items: center"},Object(Oe.h)("span",null,"© Jean Jacques Avril 2022 ")))))},Qe=function(e){var t=e.items;if(t)return Object(Oe.h)("div",{class:"breadcrumb"},Object(Oe.h)("ul",null,t.map((function(e,t){return Object(Oe.h)("li",{key:t},Object(Oe.h)("a",{href:"#"},e))}))))},Ye=function(e){var t=[];if(!isNaN(e.start)&&!isNaN(e.end)&&!isNaN(e.current))for(var n=e.start;n<=e.end;n++)t.push(Object(Oe.h)("li",null,Object(Oe.h)(xe,_e({},n==e.current?{className:"active"}:{},{href:"/users/".concat(n),value:n}),n)));return Object(Oe.h)("div",{class:"page-nav-bar"},Object(Oe.h)("ul",null,t))},Xe=n("z8Av"),et=function(e){var t=e.userlist,n=e.editUser,r=e.deleteUser,o=e.start,i=e.end,u=function(e){return Object(Oe.h)("div",{key:"user".concat(e.line),class:"user-list-item"},Object(Oe.h)("div",{class:"user-attributes"},Object(Oe.h)("span",null,Object(Oe.h)("b",null,"UID:")," ",e.uid)," ",Object(Oe.h)("span",null,"(",Object(Oe.h)("b",null,e.enabled?"Aktiv":"Inaktiv"),")"),Object(Oe.h)("br",null),Object(Oe.h)("span",null,Object(Oe.h)("b",null,"Vorname:")," ",e.first_name),Object(Oe.h)("br",null),Object(Oe.h)("span",null,Object(Oe.h)("b",null,"Nachname:")," ",e.last_name),Object(Oe.h)("br",null),Object(Oe.h)("span",null,Object(Oe.h)("b",null,"RFID:")," ",e.rfid_uid),Object(Oe.h)("span",null,Object(Oe.h)("b",null,"PIN:")," ",e.user_pin)),Object(Oe.h)("div",{class:"btn-group"},Object(Oe.h)("button",{class:"btn-trash",onClick:function(){return r(e)}},"Löschen"),Object(Oe.h)("button",{class:"btn-edit",onClick:function(){return n(e)}},"Bearbeiten")))};return Object(Oe.h)("div",{className:"row"},t&&(void 0!==o&&i?t.slice(o,i).map((function(e){return u(e)})):t.map((function(e){return u(e)}))))},tt=function(e){var t=e.items,n=ve(Object(Pe.a)(Ce.b).menu,2),r=n[1];if(t){var o=function(e){e.preventDefault(),r("hide")};return n[0]?Object(Oe.h)("div",{class:"container"},Object(Oe.h)("nav",{className:"menu"},Object(Oe.h)("ul",null,t.map((function(e,t){return Object(Oe.h)("li",{key:t},Object(Oe.h)(xe,{href:e.path,onClick:o},e.text))}))))):void 0}},nt=n("3kgD"),rt=Je;Object(Oe.h)(rt,null)},YRIq:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n("hosL"),o=Object(r.createContext)({}),i=o.Provider;t.b=o},aqHq:function(e,t,n){"use strict";(function(e){function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t2&&(a.children=arguments.length>3?E.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(i in e.defaultProps)void 0===a[i]&&(a[i]=e.defaultProps[i]);return u(e,a,r,o,null)}function u(e,t,n,r,o){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++U:o};return null==o&&null!=D.vnode&&D.vnode(i),i}function a(){return{current:null}}function c(e){return e.children}function l(e,t){this.props=e,this.context=t}function s(e,t){if(null==t)return e.__?s(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t0?u(v.type,v.props,v.key,null,v.__v):v)){if(v.__=n,v.__b=n.__b+1,null===(m=w[p])||m&&v.key==m.key&&v.type===m.type)w[p]=void 0;else for(d=0;d2&&(c.children=arguments.length>3?E.call(arguments,2):n),u(e.type,c,o||e.key,i||e.ref,null)}function I(e,t){var n={__c:t="__cC"+B++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var n,r;return this.getChildContext||(n=[],(r={})[t]=this,this.getChildContext=function(){return r},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&n.some(h)},this.sub=function(e){n.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n.splice(n.indexOf(e),1),t&&t.call(e)}}),e.children}};return n.Provider.__=n.Consumer.contextType=n}n.r(t),n.d(t,"render",(function(){return x})),n.d(t,"hydrate",(function(){return P})),n.d(t,"createElement",(function(){return i})),n.d(t,"h",(function(){return i})),n.d(t,"Fragment",(function(){return c})),n.d(t,"createRef",(function(){return a})),n.d(t,"isValidElement",(function(){return T})),n.d(t,"Component",(function(){return l})),n.d(t,"cloneElement",(function(){return C})),n.d(t,"createContext",(function(){return I})),n.d(t,"toChildArray",(function(){return m})),n.d(t,"options",(function(){return D}));var E,D,U,T,z,L,M,B,H={},R=[],F=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;E=R.slice,D={__e:function(e,t){for(var n,r,o;t=t.__;)if((n=t.__c)&&!n.__)try{if((r=n.constructor)&&null!=r.getDerivedStateFromError&&(n.setState(r.getDerivedStateFromError(e)),o=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(e),o=n.__d),o)return n.__E=n}catch(t){e=t}throw e}},U=0,T=function(e){return null!=e&&void 0===e.constructor},l.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=r({},this.state),"function"==typeof e&&(e=e(r({},n),this.props)),e&&r(n,e),null!=e&&this.__v&&(t&&this.__h.push(t),h(this))},l.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),h(this))},l.prototype.render=c,z=[],L="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,p.__r=0,B=0},mdyV:function(e,t,n){"use strict";n.r(t);var r=n("hosL"),o=r.h,i=r.render,u=function(e){return e&&e.default?e.default:e};if("function"==typeof u(n("QfWi"))){var a=document.getElementById("preact_root")||document.body.firstElementChild;0,function(){var e=u(n("QfWi")),t={},r=document.querySelector('[type="__PREACT_CLI_DATA__"]');r&&(t=JSON.parse(decodeURI(r.innerHTML)).preRenderData||t);var c;t.url&&(c=t.url);i(o(e,{CLI_DATA:{preRenderData:t}}),document.body,a)}()}},z8Av:function(e,t,n){"use strict";(function(e){function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,o,i=[],u=!0,a=!1;try{for(n=n.call(e);!(u=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);u=!0);}catch(e){a=!0,o=e}finally{try{u||null==n.return||n.return()}finally{if(a)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ndoorlock_pwa \ No newline at end of file +doorlock_pwa \ No newline at end of file diff --git a/data/s/polyfills.058fb.js b/data/s/polyfills.058fb.js deleted file mode 100644 index 3ddfedd..0000000 --- a/data/s/polyfills.058fb.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:o})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(e.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var r in t)e.d(o,r,function(e){return t[e]}.bind(null,r));return o},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e(e.s="Lt8t")}({"5y5z":function(t,e,n){"use strict";function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function u(t){return Boolean(t&&void 0!==t.length)}function i(){}function f(t){if(!(this instanceof f))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],y(t,this)}function c(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,f._immediateFn((function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null!==n){var o;try{o=n(t._value)}catch(t){return void s(e.promise,t)}l(e.promise,o)}else(1===t._state?l:s)(e.promise,t._value)}))):t._deferreds.push(e)}function l(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"===r(e)||"function"==typeof e)){var n=e.then;if(e instanceof f)return t._state=3,t._value=e,void a(t);if("function"==typeof n)return void y((o=n,u=e,function(){o.apply(u,arguments)}),t)}t._state=1,t._value=e,a(t)}catch(e){s(t,e)}var o,u}function s(t,e){t._state=2,t._value=e,a(t)}function a(t){2===t._state&&0===t._deferreds.length&&f._immediateFn((function(){t._handled||f._unhandledRejectionFn(t._value)}));for(var e=0,n=t._deferreds.length;e_filepath = filepath; + return loadBin(); +} bool Config::loadBin() { - File config_file = LittleFS.open("/settings", "r"); + File config_file = LittleFS.open(_filepath, "r"); //if (buffer == nullptr) // Allocate only once // buffer = (uint8_t *)malloc(CONFIG_SIZE); if (config_file.available()) @@ -23,7 +26,6 @@ bool Config::loadBin() config_file.read(buffer, CONFIG_SIZE); buffer[OFFSET_SSID + 0x1F] = 0x00; // ensure ssid and password are terminated with a null character buffer[OFFSET_PASS + 0x1F] = 0x00; - } config_file.close(); return true; @@ -31,7 +33,7 @@ bool Config::loadBin() bool Config::saveBin() { - File config_file = LittleFS.open("/settings", "w"); + File config_file = LittleFS.open(_filepath, "w"); config_file.write(buffer, CONFIG_SIZE); delay(100); config_file.close(); diff --git a/src/Config.h b/src/Config.h index 6f28615..99c1a88 100644 --- a/src/Config.h +++ b/src/Config.h @@ -16,7 +16,7 @@ private: uint8_t *buffer = (uint8_t *)malloc(CONFIG_SIZE); public: - Config(); + Config(const char* filepath); ~Config(); const char *SSID = (char *)(buffer + OFFSET_SSID); const char *PASS = (char *)(buffer + OFFSET_PASS); @@ -26,7 +26,8 @@ public: uint8_t &mode = *(buffer + OFFSET_MODE); uint8_t &fail_timeout = *(buffer+OFFSET_FAIL_TIMEOUT); uint8_t &hold_time = *(buffer+OFFSET_HOLD_TIME); - + const char* _filepath; + bool setFilePath(const char* filepath); bool loadConfig(); bool loadBin(); bool saveBin(); diff --git a/src/Relais.cpp b/src/Relais.cpp new file mode 100644 index 0000000..4408747 --- /dev/null +++ b/src/Relais.cpp @@ -0,0 +1,26 @@ +#include "Relais.h" + +Relais::Relais(uint8_t pin) +{ + pinMode(pin, OUTPUT); + digitalWrite(_pin, 1); + _pin = pin; +} +void Relais::cylce() +{ + if (!_state) + return; + if (millis() > _call_time) + { + digitalWrite(_pin, 1); + _state = false; + Serial.println("Relay released."); + } +} +void Relais::activate(uint8_t seconds) +{ + Serial.println("Relay activated for "+String(seconds)+" Seconds."); + digitalWrite(_pin, 0); + _state = true; + _call_time = millis() + seconds * 1000; +} diff --git a/src/Relais.h b/src/Relais.h new file mode 100644 index 0000000..27fa668 --- /dev/null +++ b/src/Relais.h @@ -0,0 +1,16 @@ +#pragma once +#include +#include + +class Relais +{ +public: + Relais(uint8_t pin); + void cylce(); + void activate(uint8_t seconds); + +private: + unsigned long _call_time = 0; + bool _state = false; + uint8_t _pin; +}; \ No newline at end of file diff --git a/src/Rfid.cpp b/src/Rfid.cpp index 5656e2c..ce62340 100644 --- a/src/Rfid.cpp +++ b/src/Rfid.cpp @@ -1,8 +1,8 @@ #include "Rfid.h" #define SS_PIN D8 -#define RST_PIN D1 +#define RST_PIN D0 #define RFID_TIMEOUT 3000 -Rfid::Rfid(/* args */) : _mfrc522(SS_PIN) +Rfid::Rfid(/* args */) : _mfrc522(SS_PIN, RST_PIN) { } @@ -33,11 +33,12 @@ void Rfid::scan() { _status = 1; #ifdef DEBUG - Serial.print(this->_rfid); + _mfrc522.PICC_DumpToSerial(&(_mfrc522.uid)); #endif this->_lastRfid = this->_rfid; this->_lastRfidScan = millis(); } + } } diff --git a/src/main.cpp b/src/main.cpp index fc710a7..ef31baf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,17 +8,18 @@ #include "WebConsole.h" #include "UserDb.h" #include "Config.h" +#include "Relais.h" // File config -Config config; -userdb::UserDb userdatabase("userdb.csv"); +Config config("/settings"); +userdb::UserDb userdatabase("/userdb.csv"); webconsole::WebConsole web; // Rfid Rfid rfid; // i2C Bus #define PIN_WIRE_SDA D3 #define PIN_WIRE_SCL D4 - +Relais relay(D1); Keyboard keyboard(200); Interface iface; void setup() @@ -38,6 +39,7 @@ void setup() void loop() { + relay.cylce(); rfid.scan(); web.serve(); keyboard.scanAsync(); @@ -74,6 +76,7 @@ void loop() { iface.greetUser(login_user.first_name + " " + login_user.last_name); Serial.println("Logon from User " + login_user.toString()); + relay.activate(config.hold_time); } iface.render(); } \ No newline at end of file