UNPKG

uomlibraryapps-card-scanner-hybrid-local

Version:

Library Node.js app for UoM card scanning (hybrid-local)

1 lines 16.3 kB
function _defineProperties(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}function _possibleConstructorReturn(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?_assertThisInitialized(e):t}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{pkyO:function(e,t,n){"use strict";n.r(t);var i=n("8Y7J"),o=function e(){_classCallCheck(this,e)},r=n("pMnS"),l=n("A9Ix"),a=n("8Nsy"),s=n("RD68"),c=n("PE8+"),u=n("hIhI"),d=n("aoTd"),h=n("frcY"),b=n("8Ouj"),v=n("cUpR"),p=n("lcbv"),f=n("KoWe"),m=n("mrSG"),g=n("GJ2u"),S=n("YGig"),y=function(e){function t(e,n,o,r){var l;return _classCallCheck(this,t),(l=_possibleConstructorReturn(this,_getPrototypeOf(t).call(this))).delayedService=e,l.snackService=n,l.restMediaService=o,l.restHybridLocalService=r,l.onImported=new i.m(!0),l.busy=!1,l.files=[],l}return _inherits(t,e),_createClass(t,[{key:"doMediaChanged",value:function(e){return m.a(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.media=e,this.files=[],this.file=void 0,!this.media){t.next=10;break}return t.next=6,this.restMediaService.listFiles(this.media,"json");case 6:t.t1=function(e){return{filename:e}},t.t0=t.sent.map(t.t1),t.next=11;break;case 10:t.t0=[];case 11:this.files=t.t0;case 12:case"end":return t.stop()}}),t,this)})))}},{key:"doImport",value:function(){return m.a(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.media||(void 0===this.file||this.file>=this.files.length)){e.next=16;break}return this.delayedService.delayed("import"),this.busy=!0,e.prev=2,e.next=5,this.restHybridLocalService.importEventSession(this.media,this.files[this.file].filename);case 5:this.delayedService.done("import"),this.snackService.success("Imported event successfully"),this.onImported.emit(),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(2),this.delayedService.fail("import"),this.snackService.error(e.t0 instanceof S.a?"That event session already exists":"Unable to import from file");case 13:return e.prev=13,this.busy=!1,e.finish(13);case 16:case"end":return e.stop()}}),e,this,[[2,10,13,16]])})))}}]),t}(g.a),w=n("eBf0"),k=n("+o9E"),x=i.ob({encapsulation:0,styles:[[".buttons[_ngcontent-%COMP%]{margin-top:20px}"]],data:{}});function C(e){return i.Lb(0,[(e()(),i.qb(0,0,null,null,9,"pi-kiosk-media-drawer",[],null,[[null,"onMediaChanged"],[null,"onBusy"]],(function(e,t,n){var i=!0,o=e.component;return"onMediaChanged"===t&&(i=!1!==o.doMediaChanged(n)&&i),"onBusy"===t&&(i=!1!==(o.busy=n)&&i),i}),u.d,u.b)),i.pb(1,4440064,null,0,d.e,[c.q,c.k,d.b],{name:[0,"name"],title:[1,"title"]},{onMediaChanged:"onMediaChanged",onBusy:"onBusy"}),(e()(),i.qb(2,0,null,0,3,"table",[["commons-table",""]],[[2,"theme-light",null],[2,"theme-dark",null]],[[null,"selectedChange"]],(function(e,t,n){var i=!0;return"selectedChange"===t&&(i=!1!==(e.component.file=n)&&i),i}),h.b,h.a)),i.pb(3,4964352,null,0,b.b,[v.b,p.i],{header:[0,"header"],data:[1,"data"],rowSelectable:[2,"rowSelectable"],selected:[3,"selected"],maxHeight:[4,"maxHeight"]},{selectedChange:"selectedChange"}),i.Eb(4,{name:0,caption:1,width:2}),i.Cb(5,1),(e()(),i.qb(6,0,null,0,3,"section",[["class","buttons"]],null,null,null,null,null)),(e()(),i.qb(7,0,null,null,2,"button",[["class","filled"],["commons-button",""]],[[8,"disabled",0],[2,"theme-light",null],[2,"theme-dark",null]],[[null,"click"]],(function(e,t,n){var i=!0;return"click"===t&&(i=!1!==e.component.doImport()&&i),i}),f.d,f.a)),i.pb(8,4440064,null,0,p.b,[p.i],null,null),(e()(),i.Jb(-1,0,["Import"]))],(function(e,t){var n=t.component;e(t,1,0,"import","Import from USB pen drive");var i=e(t,5,0,e(t,4,0,"filename","Available files","100%"));e(t,3,0,i,n.files,!n.busy,n.file,4),e(t,8,0)}),(function(e,t){var n=t.component;e(t,2,0,i.Bb(t,3).isThemeLight,i.Bb(t,3).isThemeDark),e(t,7,0,n.busy||void 0===n.media||void 0===n.file,i.Bb(t,8).isThemeLight,i.Bb(t,8).isThemeDark)}))}var E=n("tgeb"),z=n("Bkf3"),_=n("IJyt"),A=n("WB8P"),R=function(e){function t(e,n,i,o){var r;return _classCallCheck(this,t),(r=_possibleConstructorReturn(this,_getPrototypeOf(t).call(this))).delayedService=e,r.snackService=n,r.drawerService=i,r.restHybridLocalService=o,r.busy=!1,r}return _inherits(t,e),_createClass(t,[{key:"ngOnInit",value:function(){var e=this;this.subscribe(this.drawerService.showObservable(),(function(t){return m.a(e,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:"export"===t&&(this.filename="".concat(A.CommonsDate.dateTodmYHi(new Date).replace(/[\/:]/g,"-").replace(" ","_"),".csv"));case 1:case"end":return e.stop()}}),e,this)})))}))}},{key:"doMediaChanged",value:function(e){return m.a(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.media=e;case 1:case"end":return t.stop()}}),t,this)})))}},{key:"doExport",value:function(){return m.a(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.media&&this.filename&&this.eventSession)){e.next=15;break}return this.delayedService.delayed("export"),this.busy=!0,e.prev=2,e.next=5,this.restHybridLocalService.exportEventSession(this.media,this.eventSession,this.filename);case 5:this.delayedService.done("export"),this.snackService.success("Exported event successfully"),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),this.delayedService.fail("export"),this.snackService.error("Unable to export to file");case 12:return e.prev=12,this.busy=!1,e.finish(12);case 15:case"end":return e.stop()}}),e,this,[[2,9,12,15]])})))}}]),t}(g.a),O=i.ob({encapsulation:0,styles:[[""]],data:{}});function B(e){return i.Lb(0,[(e()(),i.qb(0,0,null,null,7,"pi-kiosk-media-drawer",[],null,[[null,"onMediaChanged"],[null,"onBusy"]],(function(e,t,n){var i=!0,o=e.component;return"onMediaChanged"===t&&(i=!1!==o.doMediaChanged(n)&&i),"onBusy"===t&&(i=!1!==(o.busy=n)&&i),i}),u.d,u.b)),i.pb(1,4440064,null,0,d.e,[c.q,c.k,d.b],{name:[0,"name"],title:[1,"title"]},{onMediaChanged:"onMediaChanged",onBusy:"onBusy"}),(e()(),i.qb(2,0,null,0,1,"commons-textbox",[],[[2,"theme-light",null],[2,"theme-dark",null],[2,"forefront",null]],null,null,E.f,E.c)),i.pb(3,4440064,null,0,z.e,[p.i,_.r],{placeholder:[0,"placeholder"],editable:[1,"editable"],clearable:[2,"clearable"],value:[3,"value"]},null),(e()(),i.qb(4,0,null,0,3,"section",[["class","buttons"]],null,null,null,null,null)),(e()(),i.qb(5,0,null,null,2,"button",[["class","filled"],["commons-button",""]],[[8,"disabled",0],[2,"theme-light",null],[2,"theme-dark",null]],[[null,"click"]],(function(e,t,n){var i=!0;return"click"===t&&(i=!1!==e.component.doExport()&&i),i}),f.d,f.a)),i.pb(6,4440064,null,0,p.b,[p.i],null,null),(e()(),i.Jb(-1,0,["Export"]))],(function(e,t){var n=t.component;e(t,1,0,"export","Export to USB pen drive"),e(t,3,0,"File name",!1,!1,n.filename),e(t,6,0)}),(function(e,t){var n=t.component;e(t,2,0,i.Bb(t,3).isThemeLight,i.Bb(t,3).isThemeDark,i.Bb(t,3).forefront),e(t,5,0,n.busy||void 0===n.media||void 0===n.filename,i.Bb(t,6).isThemeLight,i.Bb(t,6).isThemeDark)}))}var I=function(e){function t(e,n,i,o,r,l,a,s,c,u){var d;return _classCallCheck(this,t),(d=_possibleConstructorReturn(this,_getPrototypeOf(t).call(this))).router=e,d.activatedRoute=n,d.delayedService=i,d.dialogService=o,d.drawerService=r,d.snackService=l,d.restEventsService=a,d.restHybridService=s,d.allowScanningService=c,d.eventTitleService=u,d.eventSessionHybrids=[],d.allowAdditional=!1,d.allowSignout=!1,d.allowSignoutEnabled=!1,d}return _inherits(t,e),_createClass(t,[{key:"ngOnInit",value:function(){var e=this;this.subscribe(this.activatedRoute.data,(function(t){e.eventSessionHybrids=t.eventSessionHybrids,e.activeEventSession=t.activeEventSession,e.allowAdditional=t.allowAdditional,e.allowSignout=t.allowSignout,e.allowSignoutEnabled=t.allowSignoutEnabled}))}},{key:"doRefresh",value:function(){this.router.navigate(["/events"])}},{key:"doSelect",value:function(e){this.activeEventSession=e}},{key:"getActions",value:function(){return[{action:"import",icon:"import",iconSet:p.j.MDI,main:!1},{action:"export",icon:"export",iconSet:p.j.MDI,disabled:!this.eventSessionHybrids||0===this.eventSessionHybrids.length||void 0===this.activeEventSession,main:!1},{action:"delete",icon:"delete",disabled:!this.eventSessionHybrids||0===this.eventSessionHybrids.length||void 0===this.activeEventSession,main:!1},{action:"select",icon:"check",main:!0,disabled:!this.eventSessionHybrids||0===this.eventSessionHybrids.length||void 0===this.activeEventSession}]}},{key:"doActionButton",value:function(e){return m.a(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e,t.next="import"===t.t0?3:"export"===t.t0?5:"select"===t.t0?7:"delete"===t.t0?15:18;break;case 3:return this.drawerService.show("import"),t.abrupt("break",18);case 5:return this.drawerService.show("export"),t.abrupt("break",18);case 7:if(this.activeEventSession){t.next=9;break}return t.abrupt("return");case 9:return t.next=11,this.restEventsService.setActiveEventSession(this.activeEventSession);case 11:return this.allowScanningService.allowScanning(!0),this.eventTitleService.eventTitle(this.activeEventSession.title),this.router.navigate(["/scan"],{relativeTo:this.activatedRoute}),t.abrupt("break",18);case 15:if(this.activeEventSession){t.next=17;break}return t.abrupt("return");case 17:this.doDelete();case 18:case"end":return t.stop()}}),t,this)})))}},{key:"doAllowAdditional",value:function(){return m.a(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("Setting allow additional to",this.allowAdditional),e.next=3,this.restEventsService.setAllowAdditional(this.allowAdditional);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"doAllowSignout",value:function(){return m.a(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.restEventsService.setAllowSignout(this.allowSignout);case 2:case"end":return e.stop()}}),e,this)})))}},{key:"doDelete",value:function(){var e=this;this.dialogService.confirm("Delete event","Delete event and its detections from this scanner?",(function(){return m.a(e,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.activeEventSession){e.next=13;break}return console.log("deleting"),this.delayedService.delayed("delete"),e.prev=2,e.next=5,this.restHybridService.deleteEventSession(this.activeEventSession);case 5:this.delayedService.done("delete"),this.snackService.success("Deleted event successfully"),this.doRefresh(),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(2),this.delayedService.fail("delete"),this.snackService.error("Unable to delete event and session");case 13:case"end":return e.stop()}}),e,this,[[2,10]])})))}),(function(){}))}}]),t}(g.a),q=n("iInd"),M=n("pGnk"),T=i.ob({encapsulation:0,styles:[["@charset 'utf8';commons-wait-rotate[_ngcontent-%COMP%]{position:fixed;top:130px;right:290px;width:220px;height:220px}"]],data:{}});function H(e){return i.Lb(0,[(e()(),i.qb(0,0,null,null,1,"events-options",[],null,[[null,"allowAdditionalChange"],[null,"allowSignoutChange"]],(function(e,t,n){var i=!0,o=e.component;return"allowAdditionalChange"===t&&(i=!1!==(o.allowAdditional=n)&&i),"allowAdditionalChange"===t&&(i=!1!==o.doAllowAdditional()&&i),"allowSignoutChange"===t&&(i=!1!==(o.allowSignout=n)&&i),"allowSignoutChange"===t&&(i=!1!==o.doAllowSignout()&&i),i}),l.e,l.b)),i.pb(1,4440064,null,0,a.k,[],{allowSignoutEnabled:[0,"allowSignoutEnabled"],allowAdditional:[1,"allowAdditional"],allowSignout:[2,"allowSignout"]},{allowAdditionalChange:"allowAdditionalChange",allowSignoutChange:"allowSignoutChange"}),(e()(),i.qb(2,0,null,null,1,"events-event-table",[],null,[[null,"selectedChange"]],(function(e,t,n){var i=!0,o=e.component;return"selectedChange"===t&&(i=!1!==(o.activeEventSession=n)&&i),"selectedChange"===t&&(i=!1!==o.doSelect(n)&&i),i}),l.d,l.a)),i.pb(3,4964352,null,0,a.h,[],{eventSessions:[0,"eventSessions"],hasDetections:[1,"hasDetections"],selected:[2,"selected"]},{selectedChange:"selectedChange"}),(e()(),i.qb(4,0,null,null,1,"commons-bottom-action-buttons",[],null,[[null,"onAction"]],(function(e,t,n){var i=!0;return"onAction"===t&&(i=!1!==e.component.doActionButton(n)&&i),i}),s.o,s.a)),i.pb(5,4440064,null,0,c.c,[],{actions:[0,"actions"]},{onAction:"onAction"}),(e()(),i.qb(6,0,null,null,1,"app-import",[],null,[[null,"onImported"]],(function(e,t,n){var i=!0;return"onImported"===t&&(i=!1!==e.component.doRefresh()&&i),i}),C,x)),i.pb(7,4440064,null,0,y,[w.b,c.q,d.b,k.a],null,{onImported:"onImported"}),(e()(),i.qb(8,0,null,null,1,"app-export",[],null,null,null,B,O)),i.pb(9,4440064,null,0,R,[w.b,c.q,c.k,k.a],{eventSession:[0,"eventSession"]},null)],(function(e,t){var n=t.component;e(t,1,0,n.allowSignoutEnabled,n.allowAdditional,n.allowSignout),e(t,3,0,n.eventSessionHybrids,!0,n.activeEventSession),e(t,5,0,n.getActions()),e(t,7,0),e(t,9,0,n.activeEventSession)}),null)}var P=i.mb("ng-component",I,(function(e){return i.Lb(0,[(e()(),i.qb(0,0,null,null,1,"ng-component",[],null,null,null,H,T)),i.pb(1,4440064,null,0,I,[q.o,q.a,w.b,_.g,c.k,c.q,a.l,M.d,a.d,a.i],null,null)],(function(e,t){e(t,1,0)}),null)}),{},{},[]),j=n("SVse"),D=n("IheW"),L=n("s7LF"),J=n("lawv"),U=n("nInh"),F=n("+Bp1"),G=n("o0aZ"),W=n("6Thp"),K=n("dkw+"),N=n("UMOW"),X=n("GWMK"),Y=n("p6ht"),V=n("SxSA"),Z=function e(){_classCallCheck(this,e)};n.d(t,"EventsModuleNgFactory",(function(){return Q}));var Q=i.nb(o,[],(function(e){return i.yb([i.zb(512,i.j,i.X,[[8,[r.a,P]],[3,i.j],i.v]),i.zb(4608,j.l,j.k,[i.s,[2,j.v]]),i.zb(4608,D.j,D.p,[j.c,i.z,D.n]),i.zb(4608,D.q,D.q,[D.j,D.o]),i.zb(5120,D.a,(function(e){return[e]}),[D.q]),i.zb(4608,D.m,D.m,[]),i.zb(6144,D.k,null,[D.m]),i.zb(4608,D.i,D.i,[D.k]),i.zb(6144,D.b,null,[D.i]),i.zb(4608,D.g,D.l,[D.b,i.p]),i.zb(4608,D.c,D.c,[D.g]),i.zb(4608,L.i,L.i,[]),i.zb(1073742336,j.b,j.b,[]),i.zb(1073742336,g.d,g.d,[]),i.zb(1073742336,D.e,D.e,[]),i.zb(1073742336,D.d,D.d,[]),i.zb(1073742336,w.e,w.e,[]),i.zb(1073742336,J.b,J.b,[]),i.zb(1073742336,U.g,U.g,[]),i.zb(1073742336,p.k,p.k,[]),i.zb(1073742336,L.h,L.h,[]),i.zb(1073742336,L.c,L.c,[]),i.zb(1073742336,F.b,F.b,[]),i.zb(1073742336,_.A,_.A,[]),i.zb(1073742336,c.E,c.E,[]),i.zb(1073742336,z.f,z.f,[]),i.zb(1073742336,b.c,b.c,[]),i.zb(1073742336,G.h,G.h,[]),i.zb(1073742336,W.l,W.l,[]),i.zb(1073742336,d.a,d.a,[]),i.zb(1073742336,K.e,K.e,[]),i.zb(1073742336,N.a,N.a,[]),i.zb(1073742336,S.d,S.d,[]),i.zb(1073742336,X.b,X.b,[]),i.zb(1073742336,Y.a,Y.a,[]),i.zb(1073742336,V.h,V.h,[]),i.zb(1073742336,a.j,a.j,[]),i.zb(1073742336,q.s,q.s,[[2,q.x],[2,q.o]]),i.zb(1073742336,Z,Z,[]),i.zb(1073742336,o,o,[]),i.zb(256,D.n,"XSRF-TOKEN",[]),i.zb(256,D.o,"X-XSRF-TOKEN",[]),i.zb(1024,q.m,(function(){return[[{path:"",component:I,runGuardsAndResolvers:"always",resolve:{eventSessionHybrids:M.b,activeEventSession:a.b,allowAdditional:a.c,allowSignout:a.f,allowSignoutEnabled:a.e}}]]}),[])])}))}}]);