(this["webpackJsonpchirpstack-application-server-ui"]=this["webpackJsonpchirpstack-application-server-ui"]||[]).push([[0],{13:function(e,t,a){"use strict";var n=a(2),i=a(3),o=a(5),r=a(4),s=a(38),c=a(42),l=a.n(c),u=a(6),p=new(function(e){Object(o.a)(a,e);var t=Object(r.a)(a);function a(){var e;return Object(n.a)(this,a),(e=t.call(this)).client=null,e.user=null,e.organizations=[],e.settings={},e.branding={},e.swagger=l()("/swagger/internal.swagger.json",e.getClientOpts()),e.swagger.then((function(t){e.client=t,null!==e.getToken()&&e.fetchProfile((function(){}))})),e}return Object(i.a)(a,[{key:"getClientOpts",value:function(){var e=this;return{requestInterceptor:function(t){return null!==e.getToken()&&(t.headers["Grpc-Metadata-Authorization"]="Bearer "+e.getToken()),t}}}},{key:"setToken",value:function(e){localStorage.setItem("jwt",e)}},{key:"getToken",value:function(){return localStorage.getItem("jwt")}},{key:"getOrganizationID",value:function(){var e=localStorage.getItem("organizationID");return""===e?null:e}},{key:"setOrganizationID",value:function(e){localStorage.setItem("organizationID",e),this.emit("organization.change")}},{key:"getRowsPerPage",value:function(){var e=localStorage.getItem("rowsPerPage");return""===e||null===e?10:JSON.parse(e)}},{key:"setRowsPerPage",value:function(e){localStorage.setItem("rowsPerPage",JSON.stringify(e))}},{key:"getUser",value:function(){return this.user}},{key:"getSettings",value:function(){return this.settings}},{key:"isAdmin",value:function(){return void 0!==this.user&&null!==this.user&&this.user.isAdmin}},{key:"isOrganizationAdmin",value:function(e){for(var t=0;t=200&&e.status<300)return e;throw e.json()}function r(e){void 0===e.response?n.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"error",message:e.message}}):16===e.response.obj.code?i.a.push("/login"):n.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"error",message:e.response.obj.error+" (code: "+e.response.obj.code+")"}})}function s(e){void 0===e.response?n.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"error",message:e.message}}):n.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"error",message:e.response.obj.error+" (code: "+e.response.obj.code+")"}})}function c(e){void 0===e.response?n.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"error",message:e.message}}):16===e.response.obj.code&&"/login"!==i.a.location.pathname?i.a.push("/login"):5!==e.response.obj.code&&n.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"error",message:e.response.obj.error+" (code: "+e.response.obj.code+")"}})}function l(e){return function(t){5===t.response.obj.code?e(null):c(t)}}},62:function(e,t,a){"use strict";(function(e){var n=a(165),i=a(2),o=a(3),r=a(5),s=a(4),c=a(456),l=a(0),u=a.n(l),p=a(126),m=a(333),h=a(171),d=a(248),g=a(172),b=a(330),v=a(457),f=a(334),E=a(453),y=a.n(E),j=a(452),O=a.n(j),w=a(123),C=a.n(w),S=a(451),k=a.n(S),D=a(159),I=a.n(D);function A(e){var t=u.a.useState(null),a=Object(c.a)(t,2),n=a[0],i=a[1],o=Boolean(n);function r(){i(null)}return u.a.createElement("div",null,u.a.createElement(h.a,{"aria-controls":"fade-menu","aria-haspopup":"true",onClick:function(e){i(e.currentTarget)},"aria-label":"Toggle key visibility"},u.a.createElement(k.a,null)),u.a.createElement(b.a,{id:"fade-menu",anchorEl:n,keepMounted:!0,open:o,onClose:r,TransitionComponent:f.a},u.a.createElement(v.a,{onClick:function(){var t=e.value.match(/[A-Fa-f0-9]{2}/g);null!==t&&navigator.clipboard.writeText(t.join("").toUpperCase()),r()}},"Hex String"),u.a.createElement(v.a,{onClick:function(){var t=e.value.match(/[A-Fa-f0-9]{2}/g);null!==t&&navigator.clipboard.writeText(t.join(", ").toUpperCase().replace(/[A-Fa-f0-9]{2}/g,"0x$&")),r()}},"Hex Array")))}var z=function(e){Object(r.a)(a,e);var t=Object(s.a)(a);function a(){return Object(i.a)(this,a),t.apply(this,arguments)}return Object(o.a)(a,[{key:"render",value:function(){var e=this.props,t=e.inputRef,a=Object(n.a)(e,["inputRef"]);return u.a.createElement(I.a,Object.assign({},a,{ref:function(e){t(e?e.inputElement:null)},mask:[/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/," ",/[A-Fa-f0-9]/,/[A-Fa-f0-9]/]}))}}]),a}(l.Component),P=function(t){Object(r.a)(n,t);var a=Object(s.a)(n);function n(){var t;return Object(i.a)(this,n),(t=a.call(this)).toggleShowPassword=function(){t.setState({showKey:!t.state.showKey})},t.toggleByteOrder=function(){t.setState({msb:!t.state.msb});var e=t.state.value.match(/[A-Fa-f0-9]{2}/g);null!==e&&t.setState({value:e.reverse().join(" ")})},t.randomKey=function(){var a=window.crypto||window.msCrypto,n=new Uint8Array(16);a.getRandomValues(n);var i=e.from(n).toString("hex");t.setState({value:i});var o="",r=i.match(/[A-Fa-f0-9]{2}/g);o=t.state.msb||null===r?null!==r?r.join(""):"":r.reverse().join(""),t.props.onChange({target:{value:o,type:"text",id:t.props.id}})},t.onChange=function(e){t.setState({value:e.target.value});var a="",n=e.target.value.match(/[A-Fa-f0-9]{2}/g);a=t.state.msb||null===n?null!==n?n.join(""):"":n.reverse().join(""),t.props.onChange({target:{value:a,type:"text",id:t.props.id}})},t.state={showKey:!1,msb:!0,value:""},t}return Object(o.a)(n,[{key:"componentDidMount",value:function(){this.setState({value:this.props.value||"",showKey:""===this.props.value})}},{key:"render",value:function(){return u.a.createElement(p.a,Object.assign({type:this.state.showKey?"text":"password",InputProps:{inputComponent:z,endAdornment:u.a.createElement(m.a,{position:"end"},this.state.showKey&&u.a.createElement(g.a,{title:"Toggle the byte order of the input. Some devices use LSB."},u.a.createElement(d.a,{"aria-label":"Toggle byte order",onClick:this.toggleByteOrder},this.state.msb?"MSB":"LSB")),this.props.random&&this.state.showKey&&!this.props.disabled&&u.a.createElement(g.a,{title:"Generate random key."},u.a.createElement(h.a,{"aria-label":"Generate random key",onClick:this.randomKey},u.a.createElement(C.a,null))),this.state.showKey&&u.a.createElement(A,{value:this.state.value}),u.a.createElement(h.a,{"aria-label":"Toggle key visibility",onClick:this.toggleShowPassword},this.state.showKey?u.a.createElement(O.a,null):u.a.createElement(y.a,null)))}},this.props,{onChange:this.onChange,value:this.state.value,disabled:this.props.disabled||!this.state.showKey}))}}]),n}(l.Component);t.a=P}).call(this,a(107).Buffer)},874:function(e,t,a){},875:function(e,t,a){"use strict";a.r(t);var n=a(0),i=a.n(n),o=a(34),r=a.n(o),s=(a(478),a(19)),c=a.n(s),l=a(2),u=a(3),p=a(7),m=a(5),h=a(4),d=a(125),g=a(227),b=a.n(g),v=a(948),f=a(949),E=a(11),y=a(885),j=a(166),O=a(14),w=a(12),C=a(921),S=a(922),k=a(171),D=a(457),I=a(330),A=a(877),z=a(333),P=a(140),T=a.n(P),N=a(955),x=a(954),L=a(435),R=a.n(L),W=a(436),U=a.n(W),G=a(439),F=a.n(G),M=a(437),B=a.n(M),q=a(438),_=a.n(q),K=a(38),H=a(42),J=a.n(H),V=a(13),Q=a(6),Z=a(28),X=new(function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).client=null,e.swagger=J()("/swagger/internal.swagger.json",V.a.getClientOpts()),e}return Object(u.a)(a,[{key:"listAPIKeys",value:function(e,t){this.swagger.then((function(a){a.apis.InternalService.ListAPIKeys(e).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"deleteAPIKey",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.InternalService.DeleteAPIKey({id:e}).then(Q.a).then((function(e){a.notify("api key has been deleted"),t(e.obj)})).catch(Q.b)}))}},{key:"createAPIKey",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.InternalService.CreateAPIKey({body:{apiKey:e}}).then(Q.a).then((function(e){a.notify("api key has been created"),t(e.obj)})).catch(Q.b)}))}},{key:"settings",value:function(e){this.swagger.then((function(t){t.apis.InternalService.Settings({}).then(Q.a).then((function(t){e(t.obj)})).catch(Q.b)}))}},{key:"getDevicesSummary",value:function(e,t){this.swagger.then((function(a){a.apis.InternalService.GetDevicesSummary({organizationID:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"getGatewaysSummary",value:function(e,t){this.swagger.then((function(a){a.apis.InternalService.GetGatewaysSummary({organizationID:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"notify",value:function(e){Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"success",message:e}})}}]),a}(K.EventEmitter)),Y={appBar:{zIndex:O.a.zIndex.drawer+1},menuButton:{marginLeft:-12,marginRight:10},hidden:{display:"none"},flex:{flex:1},logo:{height:32},search:{marginRight:3*O.a.spacing(1),color:O.a.palette.common.white,background:T.a[400],width:450,padding:5,borderRadius:3},chip:{background:T.a[600],color:O.a.palette.common.white,marginRight:O.a.spacing(1),"&:hover":{background:T.a[400]},"&:active":{background:T.a[400]}},iconButton:{color:O.a.palette.common.white,marginRight:O.a.spacing(1)}},$=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).onMenuOpen=function(t){e.setState({menuAnchor:t.currentTarget})},e.onMenuClose=function(){e.setState({menuAnchor:null})},e.onLogout=function(){!0===e.state.oidcEnabled&&""!==e.state.logoutURL?V.a.logout(!1,(function(){window.location.assign(e.state.logoutURL)})):V.a.logout(!0,(function(){e.props.history.push("/login")}))},e.handleDrawerToggle=function(){e.props.setDrawerOpen(!e.props.drawerOpen)},e.onSearchChange=function(t){e.setState({search:t.target.value})},e.onSearchSubmit=function(t){t.preventDefault(),e.props.history.push("/search?search=".concat(encodeURIComponent(e.state.search)))},e.state={menuAnchor:null,search:"",oidcEnabled:!1},e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=this;X.settings((function(t){e.setState({oidcEnabled:t.openidConnect.enabled,logoutURL:t.openidConnect.logoutURL})}))}},{key:"render",value:function(){var e;e=this.props.drawerOpen?i.a.createElement(U.a,null):i.a.createElement(R.a,null);var t=Boolean(this.state.menuAnchor);return i.a.createElement(C.a,{className:this.props.classes.appBar},i.a.createElement(S.a,null,i.a.createElement(k.a,{color:"inherit","aria-label":"toggle drawer",onClick:this.handleDrawerToggle,className:this.props.classes.menuButton},e),i.a.createElement("div",{className:this.props.classes.flex},i.a.createElement("img",{src:"/logo/logo.png",className:this.props.classes.logo,alt:"ChirpStack.io"})),i.a.createElement("form",{onSubmit:this.onSearchSubmit},i.a.createElement(A.a,{placeholder:"Search organization, application, gateway or device",className:this.props.classes.search,disableUnderline:!0,value:this.state.search||"",onChange:this.onSearchChange,startAdornment:i.a.createElement(z.a,{position:"start"},i.a.createElement(B.a,null))})),i.a.createElement("a",{href:"https://www.chirpstack.io/application-server/",target:"chirpstack-doc"},i.a.createElement(k.a,{className:this.props.classes.iconButton},i.a.createElement(_.a,null))),i.a.createElement(x.a,{avatar:i.a.createElement(N.a,null,i.a.createElement(F.a,null)),label:this.props.user.email,onClick:this.onMenuOpen,color:"primary",classes:{root:this.props.classes.chip}}),i.a.createElement(I.a,{id:"menu-appbar",anchorEl:this.state.menuAnchor,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},open:t,onClose:this.onMenuClose},!this.state.oidcEnabled&&i.a.createElement(D.a,{component:w.a,to:"/users/".concat(this.props.user.id,"/password")},"Change password"),i.a.createElement(D.a,{onClick:this.onLogout},"Logout"))))}}]),a}(n.Component),ee=Object(E.a)(Y)(Object(d.f)($)),te=a(956),ae=a(923),ne=a(880),ie=a(924),oe=a(925),re=a(926),se=a(444),ce=a.n(se),le=a(326),ue=a.n(le),pe=a(191),me=a.n(pe),he=a(443),de=a.n(he),ge=a(447),be=a.n(ge),ve=a(327),fe=a.n(ve),Ee=a(446),ye=a.n(Ee),je=a(448),Oe=a.n(je),we=a(445),Ce=a.n(we),Se=a(192),ke=a.n(Se),De=a(31),Ie=new(function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).swagger=new J.a("/swagger/organization.swagger.json",V.a.getClientOpts()),e}return Object(u.a)(a,[{key:"create",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.OrganizationService.Create({body:{organization:e}}).then(Q.a).then((function(n){a.emit("create",e),a.notify("created"),t(n.obj)})).catch(Q.b)}))}},{key:"get",value:function(e,t){this.swagger.then((function(a){a.apis.OrganizationService.Get({id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"update",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.OrganizationService.Update({"organization.id":e.id,body:{organization:e}}).then(Q.a).then((function(n){a.emit("change",e),a.notify("updated"),t(n.obj)})).catch(Q.b)}))}},{key:"delete",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.OrganizationService.Delete({id:e}).then(Q.a).then((function(n){a.emit("delete",e),a.notify("deleted"),t(n.obj)})).catch(Q.b)}))}},{key:"list",value:function(e,t,a,n){this.swagger.then((function(i){i.apis.OrganizationService.List({search:e,limit:t,offset:a}).then(Q.a).then((function(e){n(e.obj)})).catch(Q.b)}))}},{key:"addUser",value:function(e,t,a){this.swagger.then((function(n){n.apis.OrganizationService.AddUser({"organization_user.organization_id":e,body:{organizationUser:t}}).then(Q.a).then((function(e){a(e.obj)})).catch(Q.b)}))}},{key:"getUser",value:function(e,t,a){this.swagger.then((function(n){n.apis.OrganizationService.GetUser({organization_id:e,user_id:t}).then(Q.a).then((function(e){a(e.obj)})).catch(Q.b)}))}},{key:"deleteUser",value:function(e,t,a){this.swagger.then((function(n){n.apis.OrganizationService.DeleteUser({organization_id:e,user_id:t}).then(Q.a).then((function(e){a(e.obj)})).catch(Q.b)}))}},{key:"updateUser",value:function(e,t){this.swagger.then((function(a){a.apis.OrganizationService.UpdateUser({"organization_user.organization_id":e.organizationID,"organization_user.user_id":e.userID,body:{organizationUser:e}}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"listUsers",value:function(e,t,a,n){this.swagger.then((function(i){i.apis.OrganizationService.ListUsers({organization_id:e,limit:t,offset:a}).then(Q.a).then((function(e){n(e.obj)})).catch(Q.b)}))}},{key:"notify",value:function(e){Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"success",message:"organization has been "+e}})}}]),a}(K.EventEmitter)),Ae=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={admin:!1},e.setIsAdmin=e.setIsAdmin.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){V.a.on("change",this.setIsAdmin),this.setIsAdmin()}},{key:"componentWillUnmount",value:function(){V.a.removeListener("change",this.setIsAdmin)}},{key:"componentDidUpdate",value:function(e){e!==this.props&&this.setIsAdmin()}},{key:"setIsAdmin",value:function(){void 0!==this.props.organizationID?this.setState({admin:V.a.isAdmin()||V.a.isOrganizationAdmin(this.props.organizationID)}):this.setState({admin:V.a.isAdmin()})}},{key:"render",value:function(){return this.state.admin?this.props.children:null}}]),a}(n.Component),ze={drawerPaper:{position:"fixed",width:270,paddingTop:O.a.spacing(9)},select:{paddingTop:O.a.spacing(1),paddingLeft:O.a.spacing(3),paddingRight:O.a.spacing(3),paddingBottom:O.a.spacing(1)}},Pe=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={open:!0,organization:null,cacheCounter:0},e.onChange=e.onChange.bind(Object(p.a)(e)),e.getOrganizationOption=e.getOrganizationOption.bind(Object(p.a)(e)),e.getOrganizationOptions=e.getOrganizationOptions.bind(Object(p.a)(e)),e.getOrganizationFromLocation=e.getOrganizationFromLocation.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=this;V.a.on("organization.change",(function(){Ie.get(V.a.getOrganizationID(),(function(t){e.setState({organization:t.organization})}))})),Ie.on("create",(function(){e.setState({cacheCounter:e.state.cacheCounter+1})})),Ie.on("change",(function(t){null!==e.state.organization&&e.state.organization.id===t.id&&e.setState({organization:t}),e.setState({cacheCounter:e.state.cacheCounter+1})})),Ie.on("delete",(function(t){null!==e.state.organization&&e.state.organization.id===t&&e.setState({organization:null}),e.setState({cacheCounter:e.state.cacheCounter+1})})),null!==V.a.getOrganizationID()&&Ie.get(V.a.getOrganizationID(),(function(t){e.setState({organization:t.organization})})),this.getOrganizationFromLocation()}},{key:"componentDidUpdate",value:function(e){this.props!==e&&this.getOrganizationFromLocation()}},{key:"onChange",value:function(e){this.props.history.push("/organizations/".concat(e.target.value))}},{key:"getOrganizationFromLocation",value:function(){var e=/\/organizations\/(\d+)/g.exec(this.props.history.location.pathname);null===e||null!==this.state.organization&&this.state.organization.id===e[1]||V.a.setOrganizationID(e[1])}},{key:"getOrganizationOption",value:function(e,t){Ie.get(e,(function(e){t({label:e.organization.name,value:e.organization.id})}))}},{key:"getOrganizationOptions",value:function(e,t){Ie.list(e,10,0,(function(e){var a=e.result.map((function(e,t){return{label:e.name,value:e.id}}));t(a,e.totalCount)}))}},{key:"render",value:function(){var e="";return null!==this.state.organization&&(e=this.state.organization.id),i.a.createElement(te.a,{variant:"persistent",anchor:"left",open:this.props.open,classes:{paper:this.props.classes.drawerPaper}},i.a.createElement(Ae,null,i.a.createElement(ae.a,null,i.a.createElement(ne.a,{button:!0,component:w.a,to:"/dashboard"},i.a.createElement(ie.a,null,i.a.createElement(ue.a,null)),i.a.createElement(oe.a,{primary:"Dashboard"})),i.a.createElement(ne.a,{button:!0,component:w.a,to:"/network-servers"},i.a.createElement(ie.a,null,i.a.createElement(de.a,null)),i.a.createElement(oe.a,{primary:"Network-servers"})),i.a.createElement(ne.a,{button:!0,component:w.a,to:"/gateway-profiles"},i.a.createElement(ie.a,null,i.a.createElement(fe.a,null)),i.a.createElement(oe.a,{primary:"Gateway-profiles"})),i.a.createElement(ne.a,{button:!0,component:w.a,to:"/organizations"},i.a.createElement(ie.a,null,i.a.createElement(ce.a,null)),i.a.createElement(oe.a,{primary:"Organizations"})),i.a.createElement(ne.a,{button:!0,component:w.a,to:"/users"},i.a.createElement(ie.a,null,i.a.createElement(me.a,null)),i.a.createElement(oe.a,{primary:"All users"})),i.a.createElement(ne.a,{button:!0,component:w.a,to:"/api-keys"},i.a.createElement(ie.a,null,i.a.createElement(ke.a,null)),i.a.createElement(oe.a,{primary:"API keys"}))),i.a.createElement(re.a,null)),i.a.createElement("div",null,i.a.createElement(De.a,{id:"organizationID",margin:"none",value:e,onChange:this.onChange,getOption:this.getOrganizationOption,getOptions:this.getOrganizationOptions,className:this.props.classes.select,triggerReload:this.state.cacheCounter})),this.state.organization&&i.a.createElement(ae.a,null,i.a.createElement(ne.a,{button:!0,component:w.a,to:"/organizations/".concat(this.state.organization.id)},i.a.createElement(ie.a,null,i.a.createElement(ue.a,null)),i.a.createElement(oe.a,{primary:"Org. dashboard"})),i.a.createElement(Ae,{organizationID:this.state.organization.id},i.a.createElement(ne.a,{button:!0,component:w.a,to:"/organizations/".concat(this.state.organization.id,"/users")},i.a.createElement(ie.a,null,i.a.createElement(me.a,null)),i.a.createElement(oe.a,{primary:"Org. users"})),i.a.createElement(ne.a,{button:!0,component:w.a,to:"/organizations/".concat(this.state.organization.id,"/api-keys")},i.a.createElement(ie.a,null,i.a.createElement(ke.a,null)),i.a.createElement(oe.a,{primary:"Org. API keys"}))),i.a.createElement(ne.a,{button:!0,component:w.a,to:"/organizations/".concat(this.state.organization.id,"/service-profiles")},i.a.createElement(ie.a,null,i.a.createElement(Ce.a,null)),i.a.createElement(oe.a,{primary:"Service-profiles"})),i.a.createElement(ne.a,{button:!0,component:w.a,to:"/organizations/".concat(this.state.organization.id,"/device-profiles")},i.a.createElement(ie.a,null,i.a.createElement(ye.a,null)),i.a.createElement(oe.a,{primary:"Device-profiles"})),this.state.organization.canHaveGateways&&i.a.createElement(ne.a,{button:!0,component:w.a,to:"/organizations/".concat(this.state.organization.id,"/gateways")},i.a.createElement(ie.a,null,i.a.createElement(fe.a,null)),i.a.createElement(oe.a,{primary:"Gateways"})),i.a.createElement(ne.a,{button:!0,component:w.a,to:"/organizations/".concat(this.state.organization.id,"/applications")},i.a.createElement(ie.a,null,i.a.createElement(be.a,null)),i.a.createElement(oe.a,{primary:"Applications"})),i.a.createElement(ne.a,{button:!0,component:w.a,to:"/organizations/".concat(this.state.organization.id,"/multicast-groups")},i.a.createElement(ie.a,null,i.a.createElement(Oe.a,null)),i.a.createElement(oe.a,{primary:"Multicast-groups"}))))}}]),a}(n.Component),Te=Object(d.f)(Object(E.a)(ze)(Pe)),Ne=a(79),xe={footer:{paddingBottom:O.a.spacing(1),"& a":{color:O.a.palette.primary.main,textDecoration:"none"}}},Le=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={footer:null},e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=this;X.settings((function(t){""!==t.branding.footer&&e.setState({footer:t.branding.footer})}))}},{key:"render",value:function(){return null===this.state.footer?null:i.a.createElement("footer",{className:this.props.classes.footer},i.a.createElement(Ne.a,{align:"center",dangerouslySetInnerHTML:{__html:this.state.footer}}))}}]),a}(n.Component),Re=Object(E.a)(xe)(Le),We=a(952),Ue=a(84),Ge=a.n(Ue),Fe=a(48),Me=new(function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).notifications=[],e}return Object(u.a)(a,[{key:"getAll",value:function(){return this.notifications}},{key:"createNotification",value:function(e,t){var a=Date.now();this.notifications.push({id:a,type:e,message:t}),this.emit("change")}},{key:"deleteNotification",value:function(e){var t,a=null,n=Object(Fe.a)(this.notifications);try{for(n.s();!(t=n.n()).done;){var i=t.value;i.id===e&&(a=i)}}catch(o){n.e(o)}finally{n.f()}this.notifications.splice(this.notifications.indexOf(a),1),this.emit("change")}},{key:"handleActions",value:function(e){switch(e.type){case"CREATE_NOTIFICATION":this.createNotification(e.notification.type,e.notification.message);break;case"DELETE_NOTIFICATION":this.deleteNotification(e.id)}}}]),a}(K.EventEmitter));Z.a.register(Me.handleActions.bind(Me));var Be=Me,qe=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).onClose=e.onClose.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"onClose",value:function(e,t){Z.a.dispatch({type:"DELETE_NOTIFICATION",id:this.props.id})}},{key:"render",value:function(){return i.a.createElement(We.a,{anchorOrigin:{vertical:"bottom",horizontal:"left"},open:!0,message:i.a.createElement("span",null,this.props.notification.message),autoHideDuration:3e3,onClose:this.onClose,action:[i.a.createElement(k.a,{key:"close","aria-label":"Close",color:"inherit",onClick:this.onClose},i.a.createElement(Ge.a,null))]})}}]),a}(n.Component),_e=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={notifications:Be.getAll()},e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=this;Be.on("change",(function(){e.setState({notifications:Be.getAll()})}))}},{key:"render",value:function(){return this.state.notifications.map((function(e,t){return i.a.createElement(qe,{key:e.id,id:e.id,notification:e})}))}}]),a}(n.Component),Ke=Object(d.f)(_e),He=a(927),Je=a(929),Ve=a(928),Qe=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){return i.a.createElement(y.a,{item:!0,xs:!0,className:this.props.classes.clear},i.a.createElement("div",{className:this.props.classes.left},this.props.children),i.a.createElement("div",{className:this.props.classes.right},this.props.buttons))}}]),a}(n.Component),Ze=Object(E.a)({clear:{clear:"both"},left:{float:"left"},right:{float:"right"}})(Qe),Xe={title:{marginTop:O.a.spacing(1),marginBottom:O.a.spacing(1),marginRight:O.a.spacing(1),float:"left"},link:{textDecoration:"none",color:O.a.palette.primary.main}},Ye=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){var e=null,t=null;return void 0!==this.props.to?(e=w.a,t=b()(this.props.classes.title,this.props.classes.link)):t=this.props.classes.title,i.a.createElement(Ne.a,{variant:"h6",className:t,to:this.props.to,component:e},this.props.title)}}]),a}(n.Component),$e=Object(E.a)(Xe)(Ye),et=a(39),tt=a.n(et),at=a(409),nt=a(411),it=a(408),ot=a(238),rt=a.n(ot),st=a(73),ct=(a(413),a(412)),lt=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){return i.a.createElement(ct.a,{url:"//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:'\xa9 OpenStreetMap contributors'})}}]),a}(n.Component),ut=a(194),pt=a.n(ut),mt=new(function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).wsStatus=null,e.swagger=new J.a("/swagger/gateway.swagger.json",V.a.getClientOpts()),e}return Object(u.a)(a,[{key:"getWSStatus",value:function(){return this.wsStatus}},{key:"create",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.GatewayService.Create({body:{gateway:e}}).then(Q.a).then((function(e){a.notify("created"),t(e.obj)})).catch(Q.b)}))}},{key:"get",value:function(e,t){this.swagger.then((function(a){a.apis.GatewayService.Get({id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"update",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.GatewayService.Update({"gateway.id":e.id,body:{gateway:e}}).then(Q.a).then((function(e){a.notify("updated"),t(e.obj)})).catch(Q.b)}))}},{key:"delete",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.GatewayService.Delete({id:e}).then(Q.a).then((function(e){a.notify("deleted"),t(e.obj)})).catch(Q.b)}))}},{key:"generateClientCertificate",value:function(e,t){this.swagger.then((function(a){a.apis.GatewayService.GenerateGatewayClientCertificate({gateway_id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"list",value:function(e,t,a,n,i){this.swagger.then((function(o){o.apis.GatewayService.List({limit:a,offset:n,organizationID:t,search:e}).then(Q.a).then((function(e){i(e.obj)})).catch(Q.b)}))}},{key:"getStats",value:function(e,t,a,n){this.swagger.then((function(i){i.apis.GatewayService.GetStats({gateway_id:e,interval:"DAY",startTimestamp:t,endTimestamp:a}).then(Q.a).then((function(e){n(e.obj)})).catch(Q.b)}))}},{key:"getLastPing",value:function(e,t){this.swagger.then((function(a){a.apis.GatewayService.GetLastPing({gateway_id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.c)}))}},{key:"getFrameLogsConnection",value:function(e,t,a,n){var i=this,o=window.location,r=function(){if("localhost:3000"===o.host||"localhost:3001"===o.host)return"wss://localhost:8080/api/gateways/".concat(e,"/frames");var t="https:"===o.protocol?"wss:":"ws:";return"".concat(t,"//").concat(o.host,"/api/gateways/").concat(e,"/frames")}(),s=new pt.a(r,["Bearer",V.a.getToken()],{});return s.addEventListener("open",(function(){console.log("connected to",r),i.wsStatus="CONNECTED",i.emit("ws.status.change"),t()})),s.addEventListener("message",(function(e){var t=JSON.parse(e.data);void 0!==t.error?Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"error",message:t.error.message}}):void 0!==t.result&&n(t.result)})),s.addEventListener("close",(function(){console.log("closing",r),i.wsStatus=null,i.emit("ws.status.change"),a()})),s.addEventListener("error",(function(){console.log("error"),i.wsStatus="ERROR",i.emit("ws.status.change")})),s}},{key:"notify",value:function(e){Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"success",message:"gateway has been "+e}})}}]),a}(K.EventEmitter)),ht=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).loadData=function(){mt.list("",0,9999,0,(function(t){e.setState({items:t.result})}))},e.state={items:null},e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){this.loadData()}},{key:"componentDidUpdate",value:function(e){e!==this.props&&this.loadData()}},{key:"render",value:function(){if(null===this.state.items||0===this.state.items.length)return i.a.createElement(He.a,null,i.a.createElement(Ve.a,{title:"Gateways"}),i.a.createElement(Je.a,null,"No data available."));var e,t=[],a=[],n=c.a.AwesomeMarkers.icon({icon:"wifi",prefix:"fa",markerColor:"green"}),o=c.a.AwesomeMarkers.icon({icon:"wifi",prefix:"fa",markerColor:"gray"}),r=c.a.AwesomeMarkers.icon({icon:"wifi",prefix:"fa",markerColor:"red"}),s=Object(Fe.a)(this.state.items);try{for(s.s();!(e=s.n()).done;){var l=e.value,u=[l.location.latitude,l.location.longitude];t.push(u);var p=n,m="";if(void 0===l.lastSeenAt||null===l.lastSeenAt)p=o,m="Never seen online";else{var h=tt()(l.lastSeenAt);h.isBefore(tt()().subtract(5,"minutes"))&&(p=r),m=h.fromNow()}a.push(i.a.createElement(at.a,{position:u,key:"gw-".concat(l.id),icon:p},i.a.createElement(nt.a,null,i.a.createElement(w.a,{to:"/organizations/".concat(l.organizationID,"/gateways/").concat(l.id)},l.name),i.a.createElement("br",null),l.id,i.a.createElement("br",null),i.a.createElement("br",null),m)))}}catch(d){s.e(d)}finally{s.f()}return i.a.createElement(He.a,null,i.a.createElement(Ve.a,{title:"Gateways"}),i.a.createElement(Je.a,null,i.a.createElement(it.a,{bounds:t,maxZoom:19,style:{height:600},animate:!0,scrollWheelZoom:!1},i.a.createElement(lt,null),i.a.createElement(rt.a,null,a))))}}]),a}(n.Component),dt=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){var e=null;return null===this.props.summary||0===this.props.summary.activeCount&&0===this.props.summary.inactiveCount||(e={labels:["Never seen","Inactive","Active"],datasets:[{data:[this.props.summary.neverSeenCount,this.props.summary.inactiveCount,this.props.summary.activeCount],backgroundColor:[O.a.palette.warning.main,O.a.palette.error.main,O.a.palette.success.main]}]}),i.a.createElement(He.a,null,i.a.createElement(Ve.a,{title:"Active devices"}),i.a.createElement(Je.a,null,e&&i.a.createElement(st.b,{data:e}),!e&&i.a.createElement("div",null,"No data available.")))}}]),a}(n.Component),gt=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){var e=null;return null===this.props.summary||0===this.props.summary.activeCount&&0===this.props.summary.inactiveCount||(e={labels:["Never seen","Inactive","Active"],datasets:[{data:[this.props.summary.neverSeenCount,this.props.summary.inactiveCount,this.props.summary.activeCount],backgroundColor:[O.a.palette.warning.main,O.a.palette.error.main,O.a.palette.success.main]}]}),i.a.createElement(He.a,null,i.a.createElement(Ve.a,{title:"Active gateways"}),i.a.createElement(Je.a,null,e&&i.a.createElement(st.b,{data:e}),!e&&i.a.createElement("div",null,"No data available.")))}}]),a}(n.Component),bt=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;Object(l.a)(this,a);for(var n=arguments.length,i=new Array(n),o=0;o0&&e.props.history.push("/organizations/".concat(t.result[0].id))}))}},{key:"render",value:function(){return i.a.createElement("div",null)}}]),a}(n.Component),sn=Object(d.f)(rn),cn=a(450),ln=a.n(cn),un={textField:{width:"100%"},link:{"& a":{color:O.a.palette.primary.main,textDecoration:"none"}}},pn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){return void 0===this.state.object?null:i.a.createElement(Zt.a,{submitLabel:this.props.submitLabel,onSubmit:this.onSubmit},i.a.createElement(Bt.a,{id:"email",label:"Username / email",margin:"normal",value:this.state.object.email||"",onChange:this.onChange,fullWidth:!0,required:!0}),i.a.createElement(Bt.a,{id:"password",label:"Password",type:"password",margin:"normal",value:this.state.object.password||"",onChange:this.onChange,fullWidth:!0,required:!0}))}}]),a}(Qt.a),mn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){return i.a.createElement("div",null,i.a.createElement("a",{href:this.props.loginUrl},i.a.createElement(St.a,{variant:"outlined"},this.props.loginLabel)))}}]),a}(n.Component),hn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={loaded:!1,registration:"",oidcEnabled:!1,oidcLoginlabel:"",oidcLoginUrl:""},e.onSubmit=e.onSubmit.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=this;if(V.a.logout(!0,(function(){})),X.settings((function(t){e.setState({loaded:!0,registration:t.branding.registration,oidcEnabled:t.openidConnect.enabled,oidcLoginUrl:t.openidConnect.loginURL,oidcLoginLabel:t.openidConnect.loginLabel})})),""!==this.props.location.search){var t=ln.a.parse(this.props.location.search);V.a.openidConnectLogin(t.code,t.state,(function(){e.props.history.push("/")}))}}},{key:"onSubmit",value:function(e){var t=this;V.a.login(e,(function(){t.props.history.push("/")}))}},{key:"render",value:function(){return this.state.loaded?i.a.createElement(y.a,{container:!0,justify:"center"},i.a.createElement(y.a,{item:!0,xs:6,lg:4},i.a.createElement(He.a,null,i.a.createElement(Ve.a,{title:"ChirpStack Login"}),i.a.createElement(Je.a,null,!this.state.oidcEnabled&&i.a.createElement(pn,{submitLabel:"Login",onSubmit:this.onSubmit}),this.state.oidcEnabled&&i.a.createElement(mn,{loginUrl:this.state.oidcLoginUrl,loginLabel:this.state.oidcLoginLabel})),""!==this.state.registration&&i.a.createElement(Je.a,null,i.a.createElement(Ne.a,{className:this.props.classes.link,dangerouslySetInnerHTML:{__html:this.state.registration}}))))):null}}]),a}(n.Component),dn=Object(E.a)(un)(Object(d.f)(hn)),gn=new(function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).swagger=new J.a("/swagger/user.swagger.json",V.a.getClientOpts()),e}return Object(u.a)(a,[{key:"create",value:function(e,t,a,n){var i=this;this.swagger.then((function(o){o.apis.UserService.Create({body:{organizations:a,password:t,user:e}}).then(Q.a).then((function(e){i.notify("created"),n(e.obj)})).catch(Q.b)}))}},{key:"get",value:function(e,t){this.swagger.then((function(a){a.apis.UserService.Get({id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"update",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.UserService.Update({"user.id":e.id,body:{user:e}}).then(Q.a).then((function(e){a.notify("updated"),t(e.obj)})).catch(Q.b)}))}},{key:"delete",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.UserService.Delete({id:e}).then(Q.a).then((function(e){a.notify("deleted"),t(e.obj)})).catch(Q.b)}))}},{key:"updatePassword",value:function(e,t,a){var n=this;this.swagger.then((function(i){i.apis.UserService.UpdatePassword({user_id:e,body:{password:t}}).then(Q.a).then((function(e){n.notify("updated"),a(e.obj)})).catch(Q.b)}))}},{key:"list",value:function(e,t,a,n){this.swagger.then((function(i){i.apis.UserService.List({search:e,limit:t,offset:a}).then(Q.a).then((function(e){n(e.obj)})).catch(Q.b)}))}},{key:"notify",value:function(e){Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"success",message:"user has been "+e}})}}]),a}(K.EventEmitter)),bn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"getPage",value:function(e,t,a){gn.list("",e,t,a)}},{key:"getRow",value:function(e){var t=null,a=null;return a=e.isAdmin?i.a.createElement(Ra.a,null):i.a.createElement(Ge.a,null),t=e.isActive?i.a.createElement(Ra.a,null):i.a.createElement(Ge.a,null),i.a.createElement(Et.a,{key:e.id,hover:!0},i.a.createElement(Ct,{to:"/users/".concat(e.id)},e.email),i.a.createElement(ft.a,null,t),i.a.createElement(ft.a,null,a))}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(Ze,{title:"Users",buttons:[i.a.createElement(It,{key:1,label:"Create",icon:i.a.createElement(jt.a,null),to:"/users/create"})]},i.a.createElement($e,{title:"Users"})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(Ut,{header:i.a.createElement(Et.a,null,i.a.createElement(ft.a,null,"Email"),i.a.createElement(ft.a,null,"Active"),i.a.createElement(ft.a,null,"Admin")),getPage:this.getPage,getRow:this.getRow})))}}]),a}(n.Component),vn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){return void 0===this.state.object?i.a.createElement("div",null):i.a.createElement(Zt.a,{submitLabel:this.props.submitLabel,onSubmit:this.onSubmit},i.a.createElement(Bt.a,{id:"email",label:"E-mail address",margin:"normal",type:"email",value:this.state.object.email||"",onChange:this.onChange,required:!0,fullWidth:!0}),i.a.createElement(Bt.a,{id:"note",label:"Optional note",helperText:"Optional note, e.g. a phone number, address, comment...",margin:"normal",value:this.state.object.note||"",onChange:this.onChange,rows:4,fullWidth:!0,multiline:!0}),void 0===this.state.object.id&&i.a.createElement(Bt.a,{id:"password",label:"Password",type:"password",margin:"normal",value:this.state.object.password||"",onChange:this.onChange,required:!0,fullWidth:!0}),i.a.createElement(ta,{label:"Permissions"},i.a.createElement(Ht.a,null,i.a.createElement(Kt.a,{label:"Is active",control:i.a.createElement(Vt.a,{id:"isActive",checked:!!this.state.object.isActive,onChange:this.onChange,color:"primary"})}),i.a.createElement(Kt.a,{label:"Is global admin",control:i.a.createElement(Vt.a,{id:"isAdmin",checked:!!this.state.object.isAdmin,onChange:this.onChange,color:"primary"})}))))}}]),a}(Qt.a),fn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).onSubmit=e.onSubmit.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"onSubmit",value:function(e){var t=this;gn.create(e,e.password,[],(function(e){t.props.history.push("/users")}))}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(Ze,null,i.a.createElement($e,{title:"Users",to:"/Users"}),i.a.createElement($e,{title:"/"}),i.a.createElement($e,{title:"Create"})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(He.a,null,i.a.createElement(Je.a,null,i.a.createElement(vn,{submitLabel:"Create user",onSubmit:this.onSubmit})))))}}]),a}(n.Component),En=Object(d.f)(fn),yn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).onSubmit=e.onSubmit.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"onSubmit",value:function(e){var t=this;gn.update(e,(function(e){t.props.history.push("/users")}))}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(He.a,null,i.a.createElement(Je.a,null,i.a.createElement(vn,{submitLabel:"Update user",object:this.props.user,onSubmit:this.onSubmit})))))}}]),a}(n.Component),jn=Object(d.f)(yn),On=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={},e.deleteUser=e.deleteUser.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=this;gn.get(this.props.match.params.userID,(function(t){e.setState({user:t})}))}},{key:"deleteUser",value:function(){var e=this;window.confirm("Are you sure you want to delete this user?")&&gn.delete(this.props.match.params.userID,(function(){e.props.history.push("/users")}))}},{key:"render",value:function(){return void 0===this.state.user?i.a.createElement("div",null):i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(Ze,{buttons:[i.a.createElement(It,{key:1,label:"Change password",icon:i.a.createElement(ke.a,null),to:"/users/".concat(this.props.match.params.userID,"/password")}),i.a.createElement(It,{key:2,label:"Delete",icon:i.a.createElement(ra.a,null),color:"secondary",onClick:this.deleteUser})]},i.a.createElement($e,{to:"/users",title:"Users"}),i.a.createElement($e,{title:"/"}),i.a.createElement($e,{title:this.state.user.user.email})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(jn,{user:this.state.user.user})))}}]),a}(n.Component),wn=Object(d.f)(On),Cn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){return void 0===this.state.object?i.a.createElement("div",null):i.a.createElement(Zt.a,{submitLabel:this.props.submitLabel,onSubmit:this.onSubmit},i.a.createElement(Bt.a,{id:"password",label:"Password",type:"password",margin:"normal",value:this.state.object.password||"",onChange:this.onChange,required:!0,fullWidth:!0}))}}]),a}(Qt.a),Sn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={},e.onSubmit=e.onSubmit.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=this;gn.get(this.props.match.params.userID,(function(t){e.setState({user:t})}))}},{key:"onSubmit",value:function(e){var t=this;gn.updatePassword(this.props.match.params.userID,e.password,(function(e){t.props.history.push("/")}))}},{key:"render",value:function(){return void 0===this.state.user?i.a.createElement("div",null):i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(Ze,null,i.a.createElement($e,{title:"Users"}),i.a.createElement($e,{title:"/"}),i.a.createElement($e,{title:this.state.user.user.email}),i.a.createElement($e,{title:"/"}),i.a.createElement($e,{title:"Change password"})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(He.a,null,i.a.createElement(Je.a,null,i.a.createElement(Cn,{submitLabel:"Update password",onSubmit:this.onSubmit})))))}}]),a}(n.Component),kn=Object(d.f)(Sn),Dn=a(43),In=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).getPage=e.getPage.bind(Object(p.a)(e)),e.getRow=e.getRow.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"getPage",value:function(e,t,a){Dn.a.list(this.props.match.params.organizationID,0,e,t,a)}},{key:"getRow",value:function(e){return i.a.createElement(Et.a,{key:e.id,hover:!0},i.a.createElement(Ct,{to:"/organizations/".concat(this.props.match.params.organizationID,"/service-profiles/").concat(e.id)},e.name),i.a.createElement(ft.a,null,e.networkServerName))}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(Ze,{buttons:i.a.createElement(Ae,null,i.a.createElement(It,{label:"Create",icon:i.a.createElement(jt.a,null),to:"/organizations/".concat(this.props.match.params.organizationID,"/service-profiles/create")}))},i.a.createElement($e,{title:"Service-profiles"})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(Ut,{header:i.a.createElement(Et.a,null,i.a.createElement(ft.a,null,"Name"),i.a.createElement(ft.a,null,"Network Server")),getPage:this.getPage,getRow:this.getRow})))}}]),a}(n.Component),An=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).getNetworkServerOption=e.getNetworkServerOption.bind(Object(p.a)(e)),e.getNetworkServerOptions=e.getNetworkServerOptions.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"getNetworkServerOption",value:function(e,t){Ft.get(e,(function(e){t({label:e.networkServer.name,value:e.networkServer.id})}))}},{key:"getNetworkServerOptions",value:function(e,t){Ft.list(0,999,0,(function(e){var a=e.result.map((function(e,t){return{label:e.name,value:e.id}}));t(a)}))}},{key:"render",value:function(){return void 0===this.state.object?i.a.createElement("div",null):i.a.createElement(Zt.a,{submitLabel:this.props.submitLabel,onSubmit:this.onSubmit,disabled:this.props.disabled},i.a.createElement(Bt.a,{id:"name",label:"Service-profile name",margin:"normal",value:this.state.object.name||"",onChange:this.onChange,helperText:"A name to identify the service-profile.",disabled:this.props.disabled,required:!0,fullWidth:!0}),!this.props.update&&i.a.createElement(Xt.a,{fullWidth:!0,margin:"normal"},i.a.createElement(Yt.a,{required:!0},"Network-server"),i.a.createElement(De.a,{id:"networkServerID",label:"Network-server",value:this.state.object.networkServerID||null,onChange:this.onChange,getOption:this.getNetworkServerOption,getOptions:this.getNetworkServerOptions}),i.a.createElement(Jt.a,null,"The network-server on which this service-profile will be provisioned. After creating the service-profile, this value can't be changed.")),i.a.createElement(Xt.a,{fullWidth:!0,margin:"normal"},i.a.createElement(Kt.a,{label:"Add gateway meta-data",control:i.a.createElement(Vt.a,{id:"addGWMetaData",checked:!!this.state.object.addGWMetaData,onChange:this.onChange,disabled:this.props.disabled,color:"primary"})}),i.a.createElement(Jt.a,null,"GW metadata (RSSI, SNR, GW geoloc., etc.) are added to the packet sent to the application-server.")),i.a.createElement(Xt.a,{fullWidth:!0,margin:"normal"},i.a.createElement(Kt.a,{label:"Enable network geolocation",control:i.a.createElement(Vt.a,{id:"nwkGeoLoc",checked:!!this.state.object.nwkGeoLoc,onChange:this.onChange,disabled:this.props.disabled,color:"primary"})}),i.a.createElement(Jt.a,null,"When enabled, the network-server will try to resolve the location of the devices under this service-profile. Please note that you need to have gateways supporting the fine-timestamp feature and that the network-server needs to be configured in order to provide geolocation support.")),i.a.createElement(Bt.a,{id:"devStatusReqFreq",label:"Device-status request frequency",margin:"normal",type:"number",value:this.state.object.devStatusReqFreq||0,onChange:this.onChange,helperText:"Frequency to initiate an End-Device status request (request/day). Set to 0 to disable.",disabled:this.props.disabled,fullWidth:!0}),this.state.object.devStatusReqFreq>0&&i.a.createElement(Xt.a,{fullWidth:!0,margin:"normal"},i.a.createElement(Ht.a,null,i.a.createElement(Kt.a,{label:"Report device battery level to application-server",control:i.a.createElement(Vt.a,{id:"reportDevStatusBattery",checked:!!this.state.object.reportDevStatusBattery,onChange:this.onChange,disabled:this.props.disabled,color:"primary"})}),i.a.createElement(Kt.a,{label:"Report device link margin to application-server",control:i.a.createElement(Vt.a,{id:"reportDevStatusMargin",checked:!!this.state.object.reportDevStatusMargin,onChange:this.onChange,disabled:this.props.disabled,color:"primary"})}))),i.a.createElement(Bt.a,{id:"drMin",label:"Minimum allowed data-rate",margin:"normal",type:"number",value:this.state.object.drMin||0,onChange:this.onChange,helperText:"Minimum allowed data rate. Used for ADR.",disabled:this.props.disabled,fullWidth:!0,required:!0}),i.a.createElement(Bt.a,{id:"drMax",label:"Maximum allowed data-rate",margin:"normal",type:"number",value:this.state.object.drMax||0,onChange:this.onChange,helperText:"Maximum allowed data rate. Used for ADR.",disabled:this.props.disabled,fullWidth:!0,required:!0}),i.a.createElement(Xt.a,{fullWidth:!0,margin:"normal"},i.a.createElement(Kt.a,{label:"Private gateways",control:i.a.createElement(Vt.a,{id:"gwsPrivate",checked:!!this.state.object.gwsPrivate,onChange:this.onChange,disabled:this.props.disabled,color:"primary"})}),i.a.createElement(Jt.a,null,"Gateways under this service-profile are private. This means that these gateways can only be used by devices under the same service-profile.")))}}]),a}(Qt.a),zn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={nsDialog:!1},e.onSubmit=e.onSubmit.bind(Object(p.a)(e)),e.closeDialog=e.closeDialog.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=this;Ft.list(0,0,0,(function(t){"0"===t.totalCount&&e.setState({nsDialog:!0})}))}},{key:"closeDialog",value:function(){this.setState({nsDialog:!1})}},{key:"onSubmit",value:function(e){var t=this,a=e;a.organizationID=this.props.match.params.organizationID,Dn.a.create(a,(function(e){t.props.history.push("/organizations/".concat(t.props.match.params.organizationID,"/service-profiles"))}))}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(pa.a,{open:this.state.nsDialog,onClose:this.closeDialog},i.a.createElement(ga.a,null,"Add a network-server?"),i.a.createElement(ha.a,null,i.a.createElement(da.a,{paragraph:!0},"ChirpStack Application Server isn't connected to a ChirpStack Network Server network-server. Did you know that ChirpStack Application Server can connect to multiple ChirpStack Network Server instances, e.g. to support multiple regions?"),i.a.createElement(da.a,null,"Would you like to connect to a network-server now?")),i.a.createElement(ma.a,null,i.a.createElement(St.a,{color:"primary",component:w.a,to:"/network-servers/create",onClick:this.closeDialog},"Add network-server"),i.a.createElement(St.a,{color:"primary",onClick:this.closeDialog},"Dismiss"))),i.a.createElement(Ze,null,i.a.createElement($e,{title:"Service-profiles",to:"/organizations/".concat(this.props.match.params.organizationID,"/service-profiles")}),i.a.createElement($e,{title:"/"}),i.a.createElement($e,{title:"Create"})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(He.a,null,i.a.createElement(Je.a,null,i.a.createElement(An,{submitLabel:"Create service-profile",onSubmit:this.onSubmit,match:this.props.match})))))}}]),a}(n.Component),Pn=Object(d.f)(zn),Tn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).onSubmit=e.onSubmit.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"onSubmit",value:function(e){var t=this;Dn.a.update(e,(function(e){t.props.history.push("/organizations/".concat(t.props.match.params.organizationID,"/service-profiles"))}))}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(He.a,null,i.a.createElement(Je.a,null,i.a.createElement(An,{submitLabel:"Update service-profile",object:this.props.serviceProfile,onSubmit:this.onSubmit,match:this.props.match,disabled:!this.props.admin,update:!0})))))}}]),a}(n.Component),Nn=Object(d.f)(Tn),xn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={admin:!1},e.deleteServiceProfile=e.deleteServiceProfile.bind(Object(p.a)(e)),e.setIsAdmin=e.setIsAdmin.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=this;Dn.a.get(this.props.match.params.serviceProfileID,(function(t){e.setState({serviceProfile:t})})),V.a.on("change",this.setIsAdmin),this.setIsAdmin()}},{key:"componentWillUnmount",value:function(){V.a.removeListener("change",this.setIsAdmin)}},{key:"setIsAdmin",value:function(){this.setState({admin:V.a.isAdmin()})}},{key:"deleteServiceProfile",value:function(){var e=this;window.confirm("Are you sure you want to delete this service-profile?")&&Dn.a.delete(this.props.match.params.serviceProfileID,(function(t){e.props.history.push("/organizations/".concat(e.props.match.params.organizationID,"/service-profiles"))}))}},{key:"render",value:function(){return void 0===this.state.serviceProfile?i.a.createElement("div",null):i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(Ze,{buttons:i.a.createElement(Ae,null,i.a.createElement(It,{key:1,label:"Delete",icon:i.a.createElement(ra.a,null),color:"secondary",onClick:this.deleteServiceProfile}))},i.a.createElement($e,{to:"/organizations/".concat(this.props.match.params.organizationID,"/service-profiles"),title:"Service-profiles"}),i.a.createElement($e,{title:"/"}),i.a.createElement($e,{title:this.state.serviceProfile.serviceProfile.name})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(Nn,{serviceProfile:this.state.serviceProfile.serviceProfile,admin:this.state.admin})))}}]),a}(n.Component),Ln=Object(d.f)(xn),Rn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={admin:!1},e.setIsAdmin=e.setIsAdmin.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){V.a.on("change",this.setIsAdmin),this.setIsAdmin()}},{key:"componentWillUnmount",value:function(){V.a.removeListener("change",this.setIsAdmin)}},{key:"componentDidUpdate",value:function(e){e!==this.props&&this.setIsAdmin()}},{key:"setIsAdmin",value:function(){void 0!==this.props.organizationID?this.setState({admin:V.a.isAdmin()||V.a.isOrganizationDeviceAdmin(this.props.organizationID)}):this.setState({admin:V.a.isAdmin()})}},{key:"render",value:function(){return this.state.admin?this.props.children:null}}]),a}(n.Component),Wn=new(function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).swagger=new J.a("/swagger/deviceProfile.swagger.json",V.a.getClientOpts()),e}return Object(u.a)(a,[{key:"create",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.DeviceProfileService.Create({body:{deviceProfile:e}}).then(Q.a).then((function(e){a.notify("created"),t(e.obj)})).catch(Q.b)}))}},{key:"get",value:function(e,t){this.swagger.then((function(a){a.apis.DeviceProfileService.Get({id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"update",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.DeviceProfileService.Update({"device_profile.id":e.id,body:{deviceProfile:e}}).then(Q.a).then((function(e){a.notify("updated"),t(e.obj)})).catch(Q.b)}))}},{key:"delete",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.DeviceProfileService.Delete({id:e}).then(Q.a).then((function(e){a.notify("deleted"),t(e.ojb)})).catch(Q.b)}))}},{key:"list",value:function(e,t,a,n,i){this.swagger.then((function(o){o.apis.DeviceProfileService.List({organizationID:e,applicationID:t,limit:a,offset:n}).then(Q.a).then((function(e){i(e.obj)})).catch(Q.b)}))}},{key:"notify",value:function(e){Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"success",message:"device-profile has been "+e}})}}]),a}(K.EventEmitter)),Un=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).getPage=e.getPage.bind(Object(p.a)(e)),e.getRow=e.getRow.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"getPage",value:function(e,t,a){Wn.list(this.props.match.params.organizationID,0,e,t,a)}},{key:"getRow",value:function(e){return i.a.createElement(Et.a,{key:e.id,hover:!0},i.a.createElement(Ct,{to:"/organizations/".concat(this.props.match.params.organizationID,"/device-profiles/").concat(e.id)},e.name),i.a.createElement(ft.a,null,e.networkServerName))}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(Ze,{buttons:i.a.createElement(Rn,{organizationID:this.props.match.params.organizationID},i.a.createElement(It,{label:"Create",icon:i.a.createElement(jt.a,null),to:"/organizations/".concat(this.props.match.params.organizationID,"/device-profiles/create")}))},i.a.createElement($e,{title:"Device-profiles"})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(Ut,{header:i.a.createElement(Et.a,null,i.a.createElement(ft.a,null,"Name"),i.a.createElement(ft.a,null,"Network Server")),getPage:this.getPage,getRow:this.getRow})))}}]),a}(n.Component),Gn=a(124),Fn=(a(302),{formLabel:{fontSize:12},delete:{marginTop:3*O.a.spacing(1)}}),Mn=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;Object(l.a)(this,a);for(var n=arguments.length,i=new Array(n),o=0;o=-100?"#FF0000":e>=-105?"#FF7F00":e>=-110?"#FFFF00":e>=-115?"#00FF00":e>=-120?"#00FFFF":"#0000FF"}},{key:"render",value:function(){if(void 0===this.state.ping||0===this.state.ping.pingRX.length)return i.a.createElement(He.a,null,i.a.createElement(Je.a,null,i.a.createElement(Ne.a,{variant:"body1"},"No gateway discovery data is available (yet). This could mean:"),i.a.createElement(ae.a,null,i.a.createElement(ne.a,{dense:!0},i.a.createElement(Ne.a,{variant:"body1"},"no discovery 'ping' was emitted yet")),i.a.createElement(ne.a,{dense:!0},i.a.createElement(Ne.a,{variant:"body1"},"the gateway ping feature has been disabled in ChirpStack Application Server")),i.a.createElement(ne.a,{dense:!0},i.a.createElement(Ne.a,{variant:"body1"},"the discovery 'ping' was not received by any other gateways")))));var e=[0,0];void 0!==this.props.gateway.location&&void 0!==this.props.gateway.location.latitude&&void 0!==this.props.gateway.location.longitude&&(e=[this.props.gateway.location.latitude,this.props.gateway.location.longitude]);var t=[],a=[],n=[];a.push(i.a.createElement(at.a,{position:e,key:"gw-".concat(this.props.gateway.id)},i.a.createElement(nt.a,null,i.a.createElement("span",null,this.props.gateway.id,i.a.createElement("br",null),"Freq: ",this.state.ping.frequency/1e6," MHz",i.a.createElement("br",null),"DR: ",this.state.ping.dr,i.a.createElement("br",null),"Altitude: ",this.props.gateway.location.altitude," meter(s)")))),t.push(e);var o,r=Object(Fe.a)(this.state.ping.pingRX);try{for(r.s();!(o=r.n()).done;){var s=o.value,c=[s.latitude,s.longitude];a.push(i.a.createElement(at.a,{position:c,key:"gw-".concat(s.gatewayID)},i.a.createElement(nt.a,null,i.a.createElement("span",null,s.gatewayID,i.a.createElement("br",null),"RSSI: ",s.rssi," dBm",i.a.createElement("br",null),"SNR: ",s.LoRaSNR," dB",i.a.createElement("br",null),"Altitude: ",s.altitude," meter(s)")))),t.push(c),n.push(i.a.createElement(gi.a,{key:"line-".concat(s.gatewayID),positions:[e,c],color:this.getColor(s.rssi),opacity:.7,weight:3}))}}catch(l){r.e(l)}finally{r.f()}return i.a.createElement(Nt.a,null,i.a.createElement(it.a,{bounds:t,maxZoom:19,style:{height:800},animate:!0,scrollWheelZoom:!1},i.a.createElement(lt,null),a,n,i.a.createElement(Ei,{className:this.props.classes.mapLegend},i.a.createElement("ul",{className:this.props.classes.mapLegendList},i.a.createElement("li",{className:this.props.classes.mapLegendListItem},i.a.createElement("span",{className:this.props.classes.label,style:{background:this.getColor(-100)}},"\xa0")," >= -100 dBm"),i.a.createElement("li",{className:this.props.classes.mapLegendListItem},i.a.createElement("span",{className:this.props.classes.label,style:{background:this.getColor(-105)}},"\xa0")," >= -105 dBm"),i.a.createElement("li",{className:this.props.classes.mapLegendListItem},i.a.createElement("span",{className:this.props.classes.label,style:{background:this.getColor(-110)}},"\xa0")," >= -110 dBm"),i.a.createElement("li",{className:this.props.classes.mapLegendListItem},i.a.createElement("span",{className:this.props.classes.label,style:{background:this.getColor(-115)}},"\xa0")," >= -115 dBm"),i.a.createElement("li",{className:this.props.classes.mapLegendListItem},i.a.createElement("span",{className:this.props.classes.label,style:{background:this.getColor(-120)}},"\xa0")," >= -120 dBm"),i.a.createElement("li",{className:this.props.classes.mapLegendListItem},i.a.createElement("span",{className:this.props.classes.label,style:{background:this.getColor(-121)}},"\xa0")," < -120 dBm")))))}}]),a}(n.Component),Ei=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=c.a.control({position:"bottomleft"}),t=i.a.createElement("div",this.props,this.props.children);e.onAdd=function(e){var a=c.a.DomUtil.create("div","");return r.a.render(t,a),a},this.leafletElement=e}},{key:"createLeafletElement",value:function(){}}]),a}(bi.a);Ei=Object(vi.d)(Ei);var yi=Object(E.a)({mapLegend:{background:"rgba(255,255,255,0.7)",padding:10,borderRadius:5},mapLegendList:{listStyle:"none",padding:0,margin:0,opacity:1},mapLegendListItem:{fontWeight:"bold",padding:3},label:{display:"block",float:"left",marginRight:10,width:24}})(fi),ji=a(945),Oi=a(162),wi=a.n(Oi),Ci=a(161),Si=a.n(Ci),ki=a(163),Di=a.n(ki),Ii=a(164),Ai=a.n(Ii),zi=a(160),Pi=a.n(zi),Ti=a(953),Ni=a(943),xi=a(944),Li=a(242),Ri=a.n(Li),Wi=a(169),Ui={headerColumn:{marginRight:6*O.a.spacing(1)},headerColumnFixedSmall:{width:145},headerColumnFixedWide:{width:175},treeStyle:{paddingTop:0,paddingBottom:0,fontSize:12,lineHeight:1.5}},Gi=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){var e="",t="";e=void 0!==this.props.frame.uplinkMetaData?"UPLINK":"DOWNLINK";var a=tt()(this.props.frame.receivedAt).format("LTS"),n=this.props.frame.phyPayload.mhdr.mType;return void 0!==this.props.frame.phyPayload.macPayload&&(void 0!==this.props.frame.phyPayload.macPayload.devEUI&&(t=this.props.frame.phyPayload.macPayload.devEUI),void 0!==this.props.frame.phyPayload.macPayload.fhdr&&(t=this.props.frame.phyPayload.macPayload.fhdr.devAddr)),i.a.createElement(Ti.a,null,i.a.createElement(Ni.a,{expandIcon:i.a.createElement(Ri.a,null)},i.a.createElement("div",{className:this.props.classes.headerColumnFixedSmall},i.a.createElement(Ne.a,{variant:"body2"},e)),i.a.createElement("div",{className:this.props.classes.headerColumnFixedSmall},i.a.createElement(Ne.a,{variant:"body2"},a)),i.a.createElement("div",{className:this.props.classes.headerColumnFixedWide},i.a.createElement(Ne.a,{variant:"body2"},n)),i.a.createElement("div",{className:this.props.classes.headerColumn},i.a.createElement(Ne.a,{variant:"body2"},t))),i.a.createElement(xi.a,null,i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(y.a,{item:!0,xs:!0,className:this.props.classes.treeStyle},this.props.frame.uplinkMetaData&&i.a.createElement(Wi.a,{data:this.props.frame.uplinkMetaData}),this.props.frame.downlinkMetaData&&i.a.createElement(Wi.a,{data:this.props.frame.downlinkMetaData})),i.a.createElement(y.a,{item:!0,xs:!0,className:this.props.classes.treeStyle},i.a.createElement(Wi.a,{data:{phyPayload:this.props.frame.phyPayload}})))))}}]),a}(n.Component),Fi=Object(E.a)(Ui)(Gi),Mi={buttons:{textAlign:"right"},button:{marginLeft:2*O.a.spacing(1)},icon:{marginRight:O.a.spacing(1)},center:{textAlign:"center"},progress:{marginTop:4*O.a.spacing(1)}},Bi=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={connected:!1,paused:!1,frames:[],dialogOpen:!1},e.onFrame=e.onFrame.bind(Object(p.a)(e)),e.onDownload=e.onDownload.bind(Object(p.a)(e)),e.togglePause=e.togglePause.bind(Object(p.a)(e)),e.onClear=e.onClear.bind(Object(p.a)(e)),e.toggleHelpDialog=e.toggleHelpDialog.bind(Object(p.a)(e)),e.setConnected=e.setConnected.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=mt.getFrameLogsConnection(this.props.gateway.id,(function(){}),(function(){}),this.onFrame);this.setState({wsConn:e}),mt.on("ws.status.change",this.setConnected),this.setConnected()}},{key:"componentWillUnmount",value:function(){this.state.wsConn.close(),mt.removeListener("ws.status.change",this.setConnected)}},{key:"onDownload",value:function(){var e=this.state.frames.map((function(e,t){return{uplinkMetaData:e.uplinkMetaData,downlinkMetaData:e.downlinkMetaData,phyPayload:e.phyPayload}}));Pi()(JSON.stringify(e,null,4),"gateway-".concat(this.props.match.params.gatewayID,".json"))}},{key:"togglePause",value:function(){this.setState({paused:!this.state.paused})}},{key:"toggleHelpDialog",value:function(){this.setState({dialogOpen:!this.state.dialogOpen})}},{key:"onClear",value:function(){this.setState({frames:[]})}},{key:"setConnected",value:function(){this.setState({connected:mt.getWSStatus()})}},{key:"onFrame",value:function(e){if(!this.state.paused){var t=this.state.frames,a=new Date;void 0!==e.uplinkFrame&&t.unshift({id:a.getTime(),receivedAt:a,uplinkMetaData:{rxInfo:e.uplinkFrame.rxInfo,txInfo:e.uplinkFrame.txInfo},phyPayload:JSON.parse(e.uplinkFrame.phyPayloadJSON)}),void 0!==e.downlinkFrame&&(delete e.downlinkFrame.txInfo.gatewayID,t.unshift({id:a.getTime(),receivedAt:a,downlinkMetaData:{gatewayID:e.downlinkFrame.gatewayID,txInfo:e.downlinkFrame.txInfo},phyPayload:JSON.parse(e.downlinkFrame.phyPayloadJSON)})),console.log(e),this.setState({frames:t})}}},{key:"render",value:function(){var e=this.state.frames.map((function(e,t){return i.a.createElement(Fi,{key:e.id,frame:e})}));return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(y.a,{item:!0,xs:12,className:this.props.classes.buttons},i.a.createElement(pa.a,{open:this.state.dialogOpen,onClose:this.toggleHelpDialog,"aria-labelledby":"help-dialog-title","aria-describedby":"help-dialog-description"},i.a.createElement(ga.a,{id:"help-dialog-title"},"Help"),i.a.createElement(ha.a,null,i.a.createElement(da.a,{id:"help-dialog-description"},"The frames below are the raw (and encrypted) LoRaWAN PHYPayload frames as seen by the gateway(s). This data is intended for debugging only.")),i.a.createElement(ma.a,null,i.a.createElement(St.a,{onClick:this.toggleHelpDialog,color:"primary"},"Close"))),i.a.createElement(St.a,{variant:"outlined",className:this.props.classes.button,onClick:this.toggleHelpDialog},i.a.createElement(va.a,{className:this.props.classes.icon}),"Help"),!this.state.paused&&i.a.createElement(St.a,{variant:"outlined",className:this.props.classes.button,onClick:this.togglePause},i.a.createElement(Si.a,{className:this.props.classes.icon}),"Pause"),this.state.paused&&i.a.createElement(St.a,{variant:"outlined",className:this.props.classes.button,onClick:this.togglePause},i.a.createElement(wi.a,{className:this.props.classes.icon}),"Resume"),i.a.createElement(St.a,{variant:"outlined",className:this.props.classes.button,onClick:this.onDownload},i.a.createElement(Di.a,{className:this.props.classes.icon}),"Download"),i.a.createElement(St.a,{variant:"outlined",className:this.props.classes.button,color:"secondary",onClick:this.onClear},i.a.createElement(ra.a,{className:this.props.classes.icon}),"Clear")),i.a.createElement(y.a,{item:!0,xs:12},!this.state.connected&&i.a.createElement("div",{className:this.props.classes.center},i.a.createElement(x.a,{color:"secondary",label:"Not connected to Websocket API",avatar:i.a.createElement(N.a,null,i.a.createElement(Ai.a,null))})),this.state.connected&&0===e.length&&!this.state.paused&&i.a.createElement("div",{className:this.props.classes.center},i.a.createElement(ji.a,{className:this.props.classes.progress})),e.length>0&&e))}}]),a}(n.Component),qi=Object(E.a)(Mi)(Bi),_i=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).requestCertificate=function(){e.setState({buttonDisabled:!0}),mt.generateClientCertificate(e.props.match.params.gatewayID,(function(t){e.setState({tlsKey:t.tlsKey,tlsCert:t.tlsCert,caCert:t.caCert,expiresAt:tt()(t.expiresAt).format("lll")})}))},e.state={caCert:null,tlsCert:null,tlsKey:null,buttonDisabled:!1},e}return Object(u.a)(a,[{key:"render",value:function(){return i.a.createElement(He.a,null,i.a.createElement(Je.a,null,i.a.createElement(Ne.a,{gutterBottom:!0},"If required by the network, the gateway needs a client certificate in order to connect to the network. This certificate must be configured on the gateway. After generating the certificate, the certificate can only be retrieved once."),null==this.state.tlsCert&&i.a.createElement(St.a,{onClick:this.requestCertificate,disabled:this.state.buttonDisabled},"Generate certificate"),null!=this.state.tlsCert&&i.a.createElement("form",null,i.a.createElement(Bt.a,{id:"expiresAt",label:"Certificate expires at",margin:"normal",value:this.state.expiresAt,helperText:"The certificate expires at this date. Make sure to generate and configure a new certificate for your gateway before this expiration date.",disabled:!0,fullWidth:!0}),i.a.createElement(Bt.a,{id:"caCert",label:"CA certificate",margin:"normal",value:this.state.caCert,rows:10,multiline:!0,fullWidth:!0,helperText:"The CA certificate is to authenticate the certificate of the server. Store this as a text-file on your gateway, e.g. named 'ca.pem'."}),i.a.createElement(Bt.a,{id:"tlsCert",label:"TLS certificate",margin:"normal",value:this.state.tlsCert,rows:10,multiline:!0,fullWidth:!0,helperText:"Store this as a text-file on your gateway, e.g. named 'cert.pem'"}),i.a.createElement(Bt.a,{id:"tlsKey",label:"TLS key",margin:"normal",value:this.state.tlsKey,rows:10,multiline:!0,fullWidth:!0,helperText:"Store this as a text-file on your gateway, e.g. named 'key.pem'"}))))}}]),a}(n.Component),Ki={tabs:{borderBottom:"1px solid "+O.a.palette.divider,height:"48px",overflow:"visible"}},Hi=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={tab:0,admin:!1},e.deleteGateway=e.deleteGateway.bind(Object(p.a)(e)),e.onChangeTab=e.onChangeTab.bind(Object(p.a)(e)),e.locationToTab=e.locationToTab.bind(Object(p.a)(e)),e.setIsAdmin=e.setIsAdmin.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=this;mt.get(this.props.match.params.gatewayID,(function(t){e.setState({gateway:t})})),V.a.on("change",this.setIsAdmin),this.setIsAdmin(),this.locationToTab()}},{key:"componentDidUpdate",value:function(e){this.props!==e&&this.locationToTab()}},{key:"componentWillUnmount",value:function(){V.a.removeListener("change",this.setIsAdmin)}},{key:"setIsAdmin",value:function(){this.setState({admin:V.a.isAdmin()||V.a.isOrganizationGatewayAdmin(this.props.match.params.organizationID)})}},{key:"deleteGateway",value:function(){var e=this;window.confirm("Are you sure you want to delete this gateway?")&&mt.delete(this.props.match.params.gatewayID,(function(){e.props.history.push("/organizations/".concat(e.props.match.params.organizationID,"/gateways"))}))}},{key:"locationToTab",value:function(){var e=0;window.location.href.endsWith("/edit")?e=1:window.location.href.endsWith("/certificate")?e=2:window.location.href.endsWith("/discovery")?e=3:window.location.href.endsWith("/frames")&&(e=4),e>0&&!this.state.admin&&(e-=1),this.setState({tab:e})}},{key:"onChangeTab",value:function(e,t){this.setState({tab:t})}},{key:"render",value:function(){var e=this;return void 0===this.state.gateway?i.a.createElement("div",null):i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(Ze,{buttons:i.a.createElement(Xn,{organizationID:this.props.match.params.organizationID},i.a.createElement(It,{key:1,label:"Delete",icon:i.a.createElement(ra.a,null),color:"secondary",onClick:this.deleteGateway}))},i.a.createElement($e,{to:"/organizations/".concat(this.props.match.params.organizationID,"/gateways"),title:"Gateways"}),i.a.createElement($e,{title:"/"}),i.a.createElement($e,{title:this.state.gateway.gateway.name})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(qt.a,{value:this.state.tab,onChange:this.onChangeTab,indicatorColor:"primary",className:this.props.classes.tabs},i.a.createElement(_t.a,{label:"Gateway details",component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/gateways/").concat(this.props.match.params.gatewayID)}),this.state.admin&&i.a.createElement(_t.a,{label:"Gateway configuration",component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/gateways/").concat(this.props.match.params.gatewayID,"/edit")}),this.state.admin&&i.a.createElement(_t.a,{label:"Certificate",component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/gateways/").concat(this.props.match.params.gatewayID,"/certificate")}),i.a.createElement(_t.a,{label:"Gateway discovery",disabled:!this.state.gateway.gateway.discoveryEnabled,component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/gateways/").concat(this.props.match.params.gatewayID,"/discovery")}),i.a.createElement(_t.a,{label:"Live LoRaWAN frames",component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/gateways/").concat(this.props.match.params.gatewayID,"/frames")}))),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(d.c,null,i.a.createElement(d.a,{exact:!0,path:"".concat(this.props.match.path),render:function(t){return i.a.createElement(ii,Object.assign({gateway:e.state.gateway.gateway,lastSeenAt:e.state.gateway.lastSeenAt},t))}}),i.a.createElement(d.a,{exact:!0,path:"".concat(this.props.match.path,"/edit"),render:function(t){return i.a.createElement(di,Object.assign({gateway:e.state.gateway.gateway},t))}}),i.a.createElement(d.a,{exact:!0,path:"".concat(this.props.match.path,"/certificate"),render:function(t){return i.a.createElement(_i,Object.assign({gateway:e.state.gateway.gateway},t))}}),i.a.createElement(d.a,{exact:!0,path:"".concat(this.props.match.path,"/discovery"),render:function(t){return i.a.createElement(yi,Object.assign({gateway:e.state.gateway.gateway},t))}}),i.a.createElement(d.a,{exact:!0,path:"".concat(this.props.match.path,"/frames"),render:function(t){return i.a.createElement(qi,Object.assign({gateway:e.state.gateway.gateway},t))}}))))}}]),a}(n.Component),Ji=Object(E.a)(Ki)(Object(d.f)(Hi)),Vi=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).closeDialog=function(){e.setState({spDialog:!1})},e.state={spDialog:!1},e.onSubmit=e.onSubmit.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=this;Dn.a.list(this.props.match.params.organizationID,0,0,0,(function(t){"0"===t.totalCount&&e.setState({spDialog:!0})}))}},{key:"onSubmit",value:function(e){var t=this;e.organizationID=this.props.match.params.organizationID,mt.create(e,(function(e){t.props.history.push("/organizations/".concat(t.props.match.params.organizationID,"/gateways"))}))}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(pa.a,{open:this.state.spDialog,onClose:this.closeDialog},i.a.createElement(ga.a,null,"Add a service-profile?"),i.a.createElement(ha.a,null,i.a.createElement(da.a,{paragraph:!0},"The selected organization does not have a service-profile yet. A service-profile connects an organization to a network-server and defines the features that an organization can use on this network-server."),i.a.createElement(da.a,null,"Would you like to create a service-profile?")),i.a.createElement(ma.a,null,i.a.createElement(St.a,{color:"primary",component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/service-profiles/create"),onClick:this.closeDialog},"Create service-profile"),i.a.createElement(St.a,{color:"primary",onClick:this.closeDialog},"Dismiss"))),i.a.createElement(Ze,null,i.a.createElement($e,{title:"Gateways",to:"/organizations/".concat(this.props.match.params.organizationID,"/gateways")}),i.a.createElement($e,{title:"/"}),i.a.createElement($e,{title:"Create"})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(He.a,{className:this.props.classes.card},i.a.createElement(Je.a,null,i.a.createElement(mi,{match:this.props.match,submitLabel:"Create gateway",onSubmit:this.onSubmit,object:{location:{}}})))))}}]),a}(n.Component),Qi=Object(d.f)(Object(E.a)({card:{overflow:"visible"}})(Vi)),Zi=new(function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).swagger=new J.a("/swagger/application.swagger.json",V.a.getClientOpts()),e}return Object(u.a)(a,[{key:"create",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.Create({body:{application:e}}).then(Q.a).then((function(e){a.notify("created"),t(e.obj)})).catch(Q.b)}))}},{key:"get",value:function(e,t){this.swagger.then((function(a){a.apis.ApplicationService.Get({id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"update",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.Update({"application.id":e.id,body:{application:e}}).then(Q.a).then((function(e){a.notify("updated"),t(e.obj)})).catch(Q.b)}))}},{key:"delete",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.Delete({id:e}).then(Q.a).then((function(e){a.notify("deleted"),t(e.obj)})).catch(Q.b)}))}},{key:"list",value:function(e,t,a,n,i){this.swagger.then((function(o){o.apis.ApplicationService.List({limit:a,offset:n,organizationID:t,search:e}).then(Q.a).then((function(e){i(e.obj)})).catch(Q.b)}))}},{key:"listIntegrations",value:function(e,t){this.swagger.then((function(a){a.apis.ApplicationService.ListIntegrations({application_id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"createHTTPIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.CreateHTTPIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("http","created"),t(e.obj)})).catch(Q.b)}))}},{key:"getHTTPIntegration",value:function(e,t){this.swagger.then((function(a){a.apis.ApplicationService.GetHTTPIntegration({application_id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"updateHTTPIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.UpdateHTTPIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("http","updated"),t(e.obj)})).catch(Q.b)}))}},{key:"deleteHTTPIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.DeleteHTTPIntegration({application_id:e}).then(Q.a).then((function(e){a.integrationNotification("http","deleted"),a.emit("integration.delete"),t(e.obj)})).catch(Q.b)}))}},{key:"createInfluxDBIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.CreateInfluxDBIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("InfluxDB","created"),t(e.obj)})).catch(Q.b)}))}},{key:"getInfluxDBIntegration",value:function(e,t){this.swagger.then((function(a){a.apis.ApplicationService.GetInfluxDBIntegration({application_id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"updateInfluxDBIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.UpdateInfluxDBIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("InfluxDB","updated"),t(e.obj)})).catch(Q.b)}))}},{key:"deleteInfluxDBIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.DeleteInfluxDBIntegration({application_id:e}).then(Q.a).then((function(e){a.integrationNotification("InfluxDB","deleted"),a.emit("integration.delete"),t(e.obj)})).catch(Q.b)}))}},{key:"createThingsBoardIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.CreateThingsBoardIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("ThingsBoard.io","created"),t(e.obj)})).catch(Q.b)}))}},{key:"getThingsBoardIntegration",value:function(e,t){this.swagger.then((function(a){a.apis.ApplicationService.GetThingsBoardIntegration({application_id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"updateThingsBoardIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.UpdateThingsBoardIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("ThingsBoard.io","updated"),t(e.obj)})).catch(Q.b)}))}},{key:"deleteThingsBoardIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.DeleteThingsBoardIntegration({application_id:e}).then(Q.a).then((function(e){a.integrationNotification("ThingsBoard.io","deleted"),a.emit("integration.delete"),t(e.obj)})).catch(Q.b)}))}},{key:"createMyDevicesIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.CreateMyDevicesIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("myDevices","created"),t(e.obj)})).catch(Q.b)}))}},{key:"getMyDevicesIntegration",value:function(e,t){this.swagger.then((function(a){a.apis.ApplicationService.GetMyDevicesIntegration({application_id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"updateMyDevicesIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.UpdateMyDevicesIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("myDevices","updated"),t(e.obj)})).catch(Q.b)}))}},{key:"deleteMyDevicesIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.DeleteMyDevicesIntegration({application_id:e}).then(Q.a).then((function(e){a.integrationNotification("myDevices","deleted"),a.emit("integration.delete"),t(e.obj)})).catch(Q.b)}))}},{key:"createLoRaCloudIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.CreateLoRaCloudIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("LoRa Cloud","created"),t(e.obj)})).catch(Q.b)}))}},{key:"getLoRaCloudIntegration",value:function(e,t){this.swagger.then((function(a){a.apis.ApplicationService.GetLoRaCloudIntegration({application_id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"updateLoRaCloudIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.UpdateLoRaCloudIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("LoRa Cloud","updated"),t(e.obj)})).catch(Q.b)}))}},{key:"deleteLoRaCloudIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.DeleteLoRaCloudIntegration({application_id:e}).then(Q.a).then((function(e){a.integrationNotification("LoRa Cloud","deleted"),a.emit("integration.delete"),t(e.obj)})).catch(Q.b)}))}},{key:"notify",value:function(e){Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"success",message:"application has been "+e}})}},{key:"createGCPPubSubIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.CreateGCPPubSubIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("GCP Pub/Sub","created"),t(e.obj)})).catch(Q.b)}))}},{key:"getGCPPubSubIntegration",value:function(e,t){this.swagger.then((function(a){a.apis.ApplicationService.GetGCPPubSubIntegration({application_id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"updateGCPPubSubIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.UpdateGCPPubSubIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("GCP Pub/Sub","updated"),t(e.obj)})).catch(Q.b)}))}},{key:"deleteGCPPubSubIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.DeleteGCPPubSubIntegration({application_id:e}).then(Q.a).then((function(e){a.integrationNotification("GCP Pub/Sbu","deleted"),a.emit("integration.delete"),t(e.obj)})).catch(Q.b)}))}},{key:"createAWSSNSIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.CreateAWSSNSIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("AWS SNS","created"),t(e.obj)})).catch(Q.b)}))}},{key:"getAWSSNSIntegration",value:function(e,t){this.swagger.then((function(a){a.apis.ApplicationService.GetAWSSNSIntegration({application_id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"updateAWSSNSIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.UpdateAWSSNSIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("AWS SNS","updated"),t(e.obj)})).catch(Q.b)}))}},{key:"deleteAWSSNSIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.DeleteAWSSNSIntegration({application_id:e}).then(Q.a).then((function(e){a.integrationNotification("AWS SNS","deleted"),a.emit("integration.delete"),t(e.obj)})).catch(Q.b)}))}},{key:"createAzureServiceBusIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.CreateAzureServiceBusIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("Azure Service-Bus","created"),t(e.obj)})).catch(Q.b)}))}},{key:"getAzureServiceBusIntegration",value:function(e,t){this.swagger.then((function(a){a.apis.ApplicationService.GetAzureServiceBusIntegration({application_id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"updateAzureServiceBusIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.UpdateAzureServiceBusIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("Azure Service-Bus","updated"),t(e.obj)})).catch(Q.b)}))}},{key:"deleteAzureServiceBusIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.DeleteAzureServiceBusIntegration({application_id:e}).then(Q.a).then((function(e){a.integrationNotification("Azure Service-Bus","deleted"),a.emit("integration.delete"),t(e.obj)})).catch(Q.b)}))}},{key:"createPilotThingsIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.CreatePilotThingsIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("Pilot Things","created"),t(e.obj)})).catch(Q.b)}))}},{key:"getPilotThingsIntegration",value:function(e,t){this.swagger.then((function(a){a.apis.ApplicationService.GetPilotThingsIntegration({application_id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"updatePilotThingsIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.UpdatePilotThingsIntegration({"integration.application_id":e.applicationID,body:{integration:e}}).then(Q.a).then((function(e){a.integrationNotification("Pilot Things","updated"),t(e.obj)})).catch(Q.b)}))}},{key:"deletePilotThingsIntegration",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.ApplicationService.DeletePilotThingsIntegration({application_id:e}).then(Q.a).then((function(e){a.integrationNotification("Pilot Things","deleted"),a.emit("integration.delete"),t(e.obj)})).catch(Q.b)}))}},{key:"generateMQTTIntegrationClientCertificate",value:function(e,t){this.swagger.then((function(a){a.apis.ApplicationService.GenerateMQTTIntegrationClientCertificate({application_id:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"integrationNotification",value:function(e,t){Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"success",message:e+" integration has been "+t}})}}]),a}(K.EventEmitter)),Xi=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).getPage=e.getPage.bind(Object(p.a)(e)),e.getRow=e.getRow.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"getPage",value:function(e,t,a){Zi.list("",this.props.match.params.organizationID,e,t,a)}},{key:"getRow",value:function(e){return i.a.createElement(Et.a,{key:e.id,hover:!0},i.a.createElement(ft.a,null,e.id),i.a.createElement(Ct,{to:"/organizations/".concat(this.props.match.params.organizationID,"/applications/").concat(e.id)},e.name),i.a.createElement(Ct,{to:"/organizations/".concat(this.props.match.params.organizationID,"/service-profiles/").concat(e.serviceProfileID)},e.serviceProfileName),i.a.createElement(ft.a,null,e.description))}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(Ze,{buttons:i.a.createElement(Ae,{organizationID:this.props.match.params.organizationID},i.a.createElement(It,{label:"Create",icon:i.a.createElement(jt.a,null),to:"/organizations/".concat(this.props.match.params.organizationID,"/applications/create")}))},i.a.createElement($e,{title:"Applications"})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(Ut,{header:i.a.createElement(Et.a,null,i.a.createElement(ft.a,null,"ID"),i.a.createElement(ft.a,null,"Name"),i.a.createElement(ft.a,null,"Service-profile"),i.a.createElement(ft.a,null,"Description")),getPage:this.getPage,getRow:this.getRow})))}}]),a}(n.Component),Yi=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).getServiceProfileOption=e.getServiceProfileOption.bind(Object(p.a)(e)),e.getServiceProfileOptions=e.getServiceProfileOptions.bind(Object(p.a)(e)),e.getPayloadCodecOptions=e.getPayloadCodecOptions.bind(Object(p.a)(e)),e.onCodeChange=e.onCodeChange.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"getServiceProfileOption",value:function(e,t){Dn.a.get(e,(function(e){t({label:e.serviceProfile.name,value:e.serviceProfile.id})}))}},{key:"getServiceProfileOptions",value:function(e,t){Dn.a.list(this.props.match.params.organizationID,0,999,0,(function(e){var a=e.result.map((function(e,t){return{label:e.name,value:e.id}}));t(a)}))}},{key:"getPayloadCodecOptions",value:function(e,t){t([{value:"",label:"None"},{value:"CAYENNE_LPP",label:"Cayenne LPP"},{value:"CUSTOM_JS",label:"Custom JavaScript codec functions"}])}},{key:"onCodeChange",value:function(e,t,a,n){var i=this.state.object;i[e]=n,this.setState({object:i})}},{key:"render",value:function(){if(void 0===this.state.object)return i.a.createElement("div",null);var e={lineNumbers:!0,mode:"javascript",theme:"default"},t=this.state.object.payloadEncoderScript,a=this.state.object.payloadDecoderScript;return""!==t&&void 0!==t||(t='// Encode encodes the given object into an array of bytes.\n// - fPort contains the LoRaWAN fPort number\n// - obj is an object, e.g. {"temperature": 22.5}\n// The function must return an array of bytes, e.g. [225, 230, 255, 0]\nfunction Encode(fPort, obj) {\n return [];\n}'),""!==a&&void 0!==a||(a='// Decode decodes an array of bytes into an object.\n// - fPort contains the LoRaWAN fPort number\n// - bytes is an array of bytes, e.g. [225, 230, 255, 0]\n// The function must return an object, e.g. {"temperature": 22.5}\nfunction Decode(fPort, bytes) {\n return {};\n}'),i.a.createElement(Zt.a,{submitLabel:this.props.submitLabel,onSubmit:this.onSubmit},i.a.createElement(Bt.a,{id:"name",label:"Application name",margin:"normal",value:this.state.object.name||"",onChange:this.onChange,helperText:"The name may only contain words, numbers and dashes.",fullWidth:!0,required:!0}),i.a.createElement(Bt.a,{id:"description",label:"Application description",margin:"normal",value:this.state.object.description||"",onChange:this.onChange,fullWidth:!0,required:!0}),!this.props.update&&i.a.createElement(Xt.a,{fullWidth:!0,margin:"normal"},i.a.createElement(Yt.a,{className:this.props.classes.formLabel,required:!0},"Service-profile"),i.a.createElement(De.a,{id:"serviceProfileID",label:"Select service-profile",value:this.state.object.serviceProfileID||"",onChange:this.onChange,getOption:this.getServiceProfileOption,getOptions:this.getServiceProfileOptions}),i.a.createElement(Jt.a,null,"The service-profile to which this application will be attached. Note that you can't change this value after the application has been created.")),""!==this.state.object.payloadCodec&&void 0!==this.state.object.payloadCodec&&i.a.createElement("div",null,i.a.createElement(Xt.a,{fullWidth:!0,margin:"normal"},i.a.createElement(Yt.a,{className:this.props.classes.formLabel},"Payload codec"),i.a.createElement(De.a,{id:"payloadCodec",label:"Select payload codec",value:this.state.object.payloadCodec||"",onChange:this.onChange,getOptions:this.getPayloadCodecOptions}),i.a.createElement(Jt.a,null,"By defining a payload codec, ChirpStack Application Server can encode and decode the binary device payload for you.",i.a.createElement("strong",null,"Important note"),": the payload fields have moved to the device-profile. For backward-compatibility and migration, existing codec settings are still visible. Codec settings on the device-profile have priority over the application codec settings.")),"CUSTOM_JS"===this.state.object.payloadCodec&&i.a.createElement(Xt.a,{fullWidth:!0,margin:"normal"},i.a.createElement(Gn.Controlled,{value:a,options:e,onBeforeChange:this.onCodeChange.bind(this,"payloadDecoderScript"),className:this.props.classes.codeMirror}),i.a.createElement(Jt.a,null,"The function must have the signature ",i.a.createElement("strong",null,"function Decode(fPort, bytes)")," and must return an object. ChirpStack Application Server will convert this object to JSON.")),"CUSTOM_JS"===this.state.object.payloadCodec&&i.a.createElement(Xt.a,{fullWidth:!0,margin:"normal"},i.a.createElement(Gn.Controlled,{value:t,options:e,onBeforeChange:this.onCodeChange.bind(this,"payloadEncoderScript"),className:this.props.classes.codeMirror}),i.a.createElement(Jt.a,null,"The function must have the signature ",i.a.createElement("strong",null,"function Encode(fPort, obj)")," and must return an array of bytes."))),""===this.state.object.payloadCodec&&i.a.createElement(Xt.a,{fullWidth:!0,margin:"normal"},i.a.createElement(Ne.a,{variant:"body1"},"Note: The payload codec fields have moved to the device-profile.")))}}]),a}(Qt.a),$i=Object(E.a)({codeMirror:{zIndex:1},formLabel:{fontSize:12}})(Yi),eo=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={spDialog:!1},e.onSubmit=e.onSubmit.bind(Object(p.a)(e)),e.closeDialog=e.closeDialog.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=this;Dn.a.list(this.props.match.params.organizationID,0,0,0,(function(t){"0"===t.totalCount&&e.setState({spDialog:!0})}))}},{key:"closeDialog",value:function(){this.setState({spDialog:!1})}},{key:"onSubmit",value:function(e){var t=this,a=e;a.organizationID=this.props.match.params.organizationID,Zi.create(a,(function(e){t.props.history.push("/organizations/".concat(t.props.match.params.organizationID,"/applications"))}))}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(pa.a,{open:this.state.spDialog,onClose:this.closeDialog},i.a.createElement(ga.a,null,"Add a service-profile?"),i.a.createElement(ha.a,null,i.a.createElement(da.a,{paragraph:!0},"The selected organization does not have a service-profile yet. A service-profile connects an organization to a network-server and defines the features that an organization can use on this network-server."),i.a.createElement(da.a,null,"Would you like to create a service-profile?")),i.a.createElement(ma.a,null,i.a.createElement(St.a,{color:"primary",component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/service-profiles/create"),onClick:this.closeDialog},"Create service-profile"),i.a.createElement(St.a,{color:"primary",onClick:this.closeDialog},"Dismiss"))),i.a.createElement(Ze,null,i.a.createElement($e,{title:"Applications",to:"/organizations/".concat(this.props.match.params.organizationID,"/applications")}),i.a.createElement($e,{title:"/"}),i.a.createElement($e,{title:"Create"})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(He.a,{className:this.props.classes.card},i.a.createElement(Je.a,null,i.a.createElement($i,{submitLabel:"Create application",onSubmit:this.onSubmit,match:this.props.match})))))}}]),a}(n.Component),to=Object(E.a)({card:{overflow:"visible"}})(Object(d.f)(eo)),ao=a(455),no=a.n(ao),io=new(function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).wsDataStatus=null,e.wsFramesStatus=null,e.swagger=new J.a("/swagger/device.swagger.json",V.a.getClientOpts()),e}return Object(u.a)(a,[{key:"getWSDataStatus",value:function(){return this.wsDataStatus}},{key:"getWSFramesStatus",value:function(){return this.wsFramesStatus}},{key:"create",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.DeviceService.Create({body:{device:e}}).then(Q.a).then((function(e){a.notify("created"),t(e.obj)})).catch(Q.b)}))}},{key:"get",value:function(e,t){this.swagger.then((function(a){a.apis.DeviceService.Get({dev_eui:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"update",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.DeviceService.Update({"device.dev_eui":e.devEUI,body:{device:e}}).then(Q.a).then((function(e){a.emit("update"),a.notify("updated"),t(e.obj)})).catch(Q.b)}))}},{key:"delete",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.DeviceService.Delete({dev_eui:e}).then(Q.a).then((function(e){a.notify("deleted"),t(e.obj)})).catch(Q.b)}))}},{key:"list",value:function(e,t){this.swagger.then((function(a){a.apis.DeviceService.List(e).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"getKeys",value:function(e,t){this.swagger.then((function(a){a.apis.DeviceService.GetKeys({dev_eui:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Object(Q.d)(t))}))}},{key:"createKeys",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.DeviceService.CreateKeys({"device_keys.dev_eui":e.devEUI,body:{deviceKeys:e}}).then(Q.a).then((function(e){a.notifyKeys("created"),t(e.obj)})).catch(Q.b)}))}},{key:"updateKeys",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.DeviceService.UpdateKeys({"device_keys.dev_eui":e.devEUI,body:{deviceKeys:e}}).then(Q.a).then((function(e){a.notifyKeys("updated"),t(e.obj)})).catch(Q.b)}))}},{key:"getActivation",value:function(e,t){this.swagger.then((function(a){a.apis.DeviceService.GetActivation({dev_eui:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Object(Q.d)(t))}))}},{key:"activate",value:function(e,t){this.swagger.then((function(a){a.apis.DeviceService.Activate({"device_activation.dev_eui":e.devEUI,body:{deviceActivation:e}}).then(Q.a).then((function(e){Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"success",message:"device has been (re)activated"}}),t(e.obj)})).catch(Q.b)}))}},{key:"getRandomDevAddr",value:function(e,t){this.swagger.then((function(a){a.apis.DeviceService.GetRandomDevAddr({dev_eui:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"getDataLogsConnection",value:function(e,t){var a=this,n=window.location,i=function(){if("localhost:3000"===n.host||"localhost:3001"===n.host)return"ws://localhost:8080/api/devices/".concat(e,"/events");var t="https:"===n.protocol?"wss:":"ws:";return"".concat(t,"//").concat(n.host,"/api/devices/").concat(e,"/events")}(),o=new pt.a(i,["Bearer",V.a.getToken()],{});return o.addEventListener("open",(function(){console.log("connected to",i),a.wsDataStatus="CONNECTED",a.emit("ws.status.change")})),o.addEventListener("message",(function(e){var a=JSON.parse(e.data);void 0!==a.error?Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"error",message:a.error.message}}):void 0!==a.result&&t(a.result)})),o.addEventListener("close",(function(){console.log("closing",i),a.wsDataStatus=null,a.emit("ws.status.change")})),o.addEventListener("error",(function(){console.log("error"),a.wsDataStatus="ERROR",a.emit("ws.status.change")})),o}},{key:"getFrameLogsConnection",value:function(e,t){var a=this,n=window.location,i=function(){if("localhost:3000"===n.host||"localhost:3001"===n.host)return"ws://localhost:8080/api/devices/".concat(e,"/frames");var t="https:"===n.protocol?"wss:":"ws:";return"".concat(t,"//").concat(n.host,"/api/devices/").concat(e,"/frames")}(),o=new pt.a(i,["Bearer",V.a.getToken()],{});return o.addEventListener("open",(function(){console.log("connected to",i),a.wsFramesStatus="CONNECTED",a.emit("ws.status.change")})),o.addEventListener("message",(function(e){var a=JSON.parse(e.data);void 0!==a.error?Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"error",message:a.error.message}}):void 0!==a.result&&t(a.result)})),o.addEventListener("close",(function(){console.log("closing",i),a.wsFramesStatus=null,a.emit("ws.status.change")})),o.addEventListener("error",(function(e){console.log("error",e),a.wsFramesStatus="ERROR",a.emit("ws.status.change")})),o}},{key:"notify",value:function(e){Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"success",message:"device has been "+e}})}},{key:"notifyKeys",value:function(e){Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"success",message:"device-keys have been "+e}})}}]),a}(K.EventEmitter)),oo={buttons:{textAlign:"right"},button:{marginLeft:2*O.a.spacing(1)},icon:{marginRight:O.a.spacing(1)}},ro=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).getPage=e.getPage.bind(Object(p.a)(e)),e.getRow=e.getRow.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"getPage",value:function(e,t,a){io.list({applicationID:this.props.match.params.applicationID,limit:e,offset:t},a)}},{key:"getRow",value:function(e){var t="n/a",a="n/a",n="n/a";return void 0!==e.lastSeenAt&&null!==e.lastSeenAt&&(t=tt()(e.lastSeenAt).fromNow()),e.deviceStatusExternalPowerSource||e.deviceStatusBatteryLevelUnavailable||(n="".concat(e.deviceStatusBatteryLevel,"%")),e.deviceStatusExternalPowerSource&&(n=i.a.createElement(no.a,null)),void 0!==e.deviceStatusMargin&&256!==e.deviceStatusMargin&&(a="".concat(e.deviceStatusMargin," dB")),i.a.createElement(Et.a,{key:e.devEUI,hover:!0},i.a.createElement(ft.a,null,t),i.a.createElement(Ct,{to:"/organizations/".concat(this.props.match.params.organizationID,"/applications/").concat(this.props.match.params.applicationID,"/devices/").concat(e.devEUI)},e.name),i.a.createElement(ft.a,null,e.devEUI),i.a.createElement(Ct,{to:"/organizations/".concat(this.props.match.params.organizationID,"/device-profiles/").concat(e.deviceProfileID)},e.deviceProfileName),i.a.createElement(ft.a,null,a),i.a.createElement(ft.a,null,n))}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(Rn,{organizationID:this.props.match.params.organizationID},i.a.createElement(y.a,{item:!0,xs:12,className:this.props.classes.buttons},i.a.createElement(St.a,{variant:"outlined",className:this.props.classes.button,component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/applications/").concat(this.props.match.params.applicationID,"/devices/create")},i.a.createElement(jt.a,{className:this.props.classes.icon}),"Create"))),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(Ut,{header:i.a.createElement(Et.a,null,i.a.createElement(ft.a,null,"Last seen"),i.a.createElement(ft.a,null,"Device name"),i.a.createElement(ft.a,null,"Device EUI"),i.a.createElement(ft.a,null,"Device profile"),i.a.createElement(ft.a,null,"Link margin"),i.a.createElement(ft.a,null,"Battery")),getPage:this.getPage,getRow:this.getRow})))}}]),a}(n.Component),so=Object(E.a)(oo)(ro),co=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).onSubmit=e.onSubmit.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"onSubmit",value:function(e){var t=this;Zi.update(e,(function(a){t.props.history.push("/organizations/".concat(t.props.match.params.organizationID,"/applications/").concat(e.id))}))}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(He.a,{className:this.props.classes.card},i.a.createElement(Je.a,null,i.a.createElement($i,{submitLabel:"Update application",object:this.props.application,onSubmit:this.onSubmit,update:!0})))))}}]),a}(n.Component),lo=Object(E.a)({card:{overflow:"visible"}})(Object(d.f)(co)),uo=a(947),po=a(946),mo=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;Object(l.a)(this,a);for(var n=arguments.length,i=new Array(n),o=0;o0&&e))}}]),a}(n.Component),es=Object(E.a)(Xr)($r),ts={buttons:{textAlign:"right"},button:{marginLeft:2*O.a.spacing(1)},icon:{marginRight:O.a.spacing(1)},center:{textAlign:"center"},progress:{marginTop:4*O.a.spacing(1)}},as=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={paused:!1,connected:!1,frames:[],dialogOpen:!1},e.setConnected=e.setConnected.bind(Object(p.a)(e)),e.onFrame=e.onFrame.bind(Object(p.a)(e)),e.onDownload=e.onDownload.bind(Object(p.a)(e)),e.togglePause=e.togglePause.bind(Object(p.a)(e)),e.onClear=e.onClear.bind(Object(p.a)(e)),e.toggleHelpDialog=e.toggleHelpDialog.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=io.getFrameLogsConnection(this.props.match.params.devEUI,this.onFrame);this.setState({wsConn:e}),io.on("ws.status.change",this.setConnected),this.setConnected()}},{key:"componentWillUnmount",value:function(){this.state.wsConn.close(),io.removeListener("ws.status.change",this.setConnected)}},{key:"onDownload",value:function(){var e=this.state.frames.map((function(e,t){return{uplinkMetaData:e.uplinkMetaData,downlinkMetaData:e.downlinkMetaData,phyPayload:e.phyPayload}}));Pi()(JSON.stringify(e,null,4),"gateway-".concat(this.props.match.params.gatewayID,".json"))}},{key:"togglePause",value:function(){this.setState({paused:!this.state.paused})}},{key:"toggleHelpDialog",value:function(){this.setState({dialogOpen:!this.state.dialogOpen})}},{key:"onClear",value:function(){this.setState({frames:[]})}},{key:"setConnected",value:function(){this.setState({connected:io.getWSFramesStatus()})}},{key:"onFrame",value:function(e){if(!this.state.paused){var t=this.state.frames,a=new Date;void 0!==e.uplinkFrame&&t.unshift({id:a.getTime(),receivedAt:a,uplinkMetaData:{rxInfo:e.uplinkFrame.rxInfo,txInfo:e.uplinkFrame.txInfo},phyPayload:JSON.parse(e.uplinkFrame.phyPayloadJSON)}),void 0!==e.downlinkFrame&&(delete e.downlinkFrame.txInfo.gatewayID,t.unshift({id:a.getTime(),receivedAt:a,downlinkMetaData:{gatewayID:e.downlinkFrame.gatewayID,txInfo:e.downlinkFrame.txInfo},phyPayload:JSON.parse(e.downlinkFrame.phyPayloadJSON)})),console.log(e),this.setState({frames:t})}}},{key:"render",value:function(){var e=this.state.frames.map((function(e,t){return i.a.createElement(Fi,{key:e.id,frame:e})}));return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(pa.a,{open:this.state.dialogOpen,onClose:this.toggleHelpDialog,"aria-labelledby":"help-dialog-title","aria-describedby":"help-dialog-description"},i.a.createElement(ga.a,{id:"help-dialog-title"},"Help"),i.a.createElement(ha.a,null,i.a.createElement(da.a,{id:"help-dialog-description"},"The frames below are the raw (and encrypted) LoRaWAN PHYPayload frames as seen by the gateway(s). This data is intedend for debugging only.")),i.a.createElement(ma.a,null,i.a.createElement(St.a,{onClick:this.toggleHelpDialog,color:"primary"},"Close"))),i.a.createElement(y.a,{item:!0,xs:12,className:this.props.classes.buttons},i.a.createElement(St.a,{variant:"outlined",className:this.props.classes.button,onClick:this.toggleHelpDialog},i.a.createElement(va.a,{className:this.props.classes.icon}),"Help"),!this.state.paused&&i.a.createElement(St.a,{variant:"outlined",className:this.props.classes.button,onClick:this.togglePause},i.a.createElement(Si.a,{className:this.props.classes.icon}),"Pause"),this.state.paused&&i.a.createElement(St.a,{variant:"outlined",className:this.props.classes.button,onClick:this.togglePause},i.a.createElement(wi.a,{className:this.props.classes.icon}),"Resume"),i.a.createElement(St.a,{variant:"outlined",className:this.props.classes.button,onClick:this.onDownload},i.a.createElement(Di.a,{className:this.props.classes.icon}),"Download"),i.a.createElement(St.a,{variant:"outlined",className:this.props.classes.button,color:"secondary",onClick:this.onClear},i.a.createElement(ra.a,{className:this.props.classes.icon}),"Clear")),i.a.createElement(y.a,{item:!0,xs:12},!this.state.connected&&i.a.createElement("div",{className:this.props.classes.center},i.a.createElement(x.a,{color:"secondary",label:"Not connected to Websocket API",avatar:i.a.createElement(N.a,null,i.a.createElement(Ai.a,null))})),this.state.connected&&0===e.length&&!this.state.paused&&i.a.createElement("div",{className:this.props.classes.center},i.a.createElement(ji.a,{className:this.props.classes.progress})),e.length>0&&e))}}]),a}(n.Component),ns=Object(E.a)(ts)(as),is=a(123),os=a.n(is),rs=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).onTabChange=function(t,a){e.setState({tab:a})},e.onCodeChange=function(t,a,n,i){var o=e.state.object;o[t]=i,e.setState({object:o})},e.state={tab:0},e}return Object(u.a)(a,[{key:"render",value:function(){if(void 0===this.state.object)return null;var e=this.state.object.jsonObject;return""!==e&&void 0!==e||(e="{}"),i.a.createElement(Zt.a,{submitLabel:this.props.submitLabel,onSubmit:this.onSubmit},i.a.createElement(Bt.a,{id:"fPort",label:"Port",margin:"normal",value:this.state.object.fPort||"",onChange:this.onChange,helperText:"Please note that the fPort value must be > 0.",required:!0,fullWidth:!0,type:"number"}),i.a.createElement(Xt.a,{fullWidth:!0,margin:"normal"},i.a.createElement(Kt.a,{label:"Confirmed downlink",control:i.a.createElement(Vt.a,{id:"confirmed",checked:!!this.state.object.confirmed,onChange:this.onChange,color:"primary"})})),i.a.createElement(qt.a,{value:this.state.tab,onChange:this.onTabChange,indicatorColor:"primary"},i.a.createElement(_t.a,{label:"Base64 encoded"}),i.a.createElement(_t.a,{label:"JSON object"})),0===this.state.tab&&i.a.createElement(Bt.a,{id:"data",label:"Base64 encoded string",margin:"normal",value:this.state.object.data||"",onChange:this.onChange,required:!0,fullWidth:!0}),1===this.state.tab&&i.a.createElement(Xt.a,{fullWidth:!0,margin:"normal"},i.a.createElement(Gn.Controlled,{value:e,className:this.props.classes.codeMirror,options:{lineNumbers:!0,mode:"javascript",theme:"default"},onBeforeChange:this.onCodeChange.bind(this,"jsonObject")}),i.a.createElement(Jt.a,null,"The device must be configured with a Device Profile supporting a Codec which is able to encode the given (JSON) payload.")))}}]),a}(Qt.a),ss=Object(E.a)({codeMirror:{zIndex:1}})(rs),cs=new(function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).swagger=new J.a("/swagger/deviceQueue.swagger.json",V.a.getClientOpts()),e}return Object(u.a)(a,[{key:"flush",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.DeviceQueueService.Flush({dev_eui:e}).then(Q.a).then((function(e){a.notify("device-queue has been flushed"),t(e.obj)})).catch(Q.b)}))}},{key:"list",value:function(e,t){this.swagger.then((function(a){a.apis.DeviceQueueService.List({dev_eui:e}).then(Q.a).then((function(e){t(e.obj)})).catch(Q.b)}))}},{key:"enqueue",value:function(e,t){var a=this;this.swagger.then((function(n){n.apis.DeviceQueueService.Enqueue({"device_queue_item.dev_eui":e.devEUI,body:{deviceQueueItem:e}}).then(Q.a).then((function(e){a.notify("device-queue item has been created"),a.emit("enqueue"),t(e.obj)})).catch(Q.b)}))}},{key:"notify",value:function(e){Z.a.dispatch({type:"CREATE_NOTIFICATION",notification:{type:"success",message:e}})}}]),a}(K.EventEmitter)),ls=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){return i.a.createElement(He.a,null,i.a.createElement(Ve.a,{title:"Details"}),i.a.createElement(Je.a,null,i.a.createElement(At.a,null,i.a.createElement(Pt.a,null,i.a.createElement(Et.a,null,i.a.createElement(ft.a,null,"Name"),i.a.createElement(ft.a,null,this.props.device.device.name)),i.a.createElement(Et.a,null,i.a.createElement(ft.a,null,"Description"),i.a.createElement(ft.a,null,this.props.device.device.description)),i.a.createElement(Et.a,null,i.a.createElement(ft.a,null,"Device-profile"),i.a.createElement(Ct,{to:"/organizations/".concat(this.props.match.params.organizationID,"/device-profiles/").concat(this.props.deviceProfile.deviceProfile.id)},this.props.deviceProfile.deviceProfile.name))))))}}]),a}(n.Component),us=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){var e="never",t="enabled";return null!==this.props.device.lastSeenAt&&(e=tt()(this.props.device.lastSeenAt).format("lll")),!0===this.props.device.device.isDisabled&&(t="disabled"),i.a.createElement(He.a,null,i.a.createElement(Ve.a,{title:"Status"}),i.a.createElement(Je.a,null,i.a.createElement(At.a,null,i.a.createElement(Pt.a,null,i.a.createElement(Et.a,null,i.a.createElement(ft.a,null,"Last seen at"),i.a.createElement(ft.a,null,e)),i.a.createElement(Et.a,null,i.a.createElement(ft.a,null,"State"),i.a.createElement(ft.a,null,t))))))}}]),a}(n.Component),ps=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).onSubmit=function(t){var a=t;a.devEUI=e.props.match.params.devEUI,cs.enqueue(a,(function(t){e.setState({object:{}})}))},e.state={object:{}},e}return Object(u.a)(a,[{key:"render",value:function(){return i.a.createElement(He.a,null,i.a.createElement(Ve.a,{title:"Enqueue downlink payload"}),i.a.createElement(Je.a,null,i.a.createElement(ss,{submitLabel:"Enqueue payload",onSubmit:this.onSubmit,object:this.state.object})))}}]),a}(n.Component);ps=Object(d.f)(ps);var ms=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){var e="no";return this.props.item.confirmed&&(e="yes"),i.a.createElement(Et.a,null,i.a.createElement(ft.a,null,this.props.item.fCnt),i.a.createElement(ft.a,null,this.props.item.fPort),i.a.createElement(ft.a,null,e),i.a.createElement(ft.a,null,this.props.item.data))}}]),a}(n.Component),hs=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).getQueue=function(){cs.list(e.props.match.params.devEUI,(function(t){e.setState({deviceQueueItems:t.deviceQueueItems})}))},e.flushQueue=function(){window.confirm("Are you sure you want to flush the device queue?")&&cs.flush(e.props.match.params.devEUI,(function(t){e.getQueue()}))},e.state={deviceQueueItems:[]},e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){this.getQueue(),cs.on("enqueue",this.getQueue)}},{key:"componentWillUnmount",value:function(){cs.removeListener("enqueue",this.getQueue)}},{key:"render",value:function(){var e=this.state.deviceQueueItems.map((function(e,t){return i.a.createElement(ms,{key:t,item:e})}));return i.a.createElement(He.a,null,i.a.createElement(Ve.a,{title:"Downlink queue",action:i.a.createElement("div",null,i.a.createElement(St.a,{onClick:this.getQueue},i.a.createElement(os.a,null)),i.a.createElement(St.a,{onClick:this.flushQueue,color:"secondary"},i.a.createElement(ra.a,null)))}),i.a.createElement(Je.a,null,i.a.createElement(At.a,null,i.a.createElement(Tt.a,null,i.a.createElement(Et.a,null,i.a.createElement(ft.a,null,"FCnt"),i.a.createElement(ft.a,null,"FPort"),i.a.createElement(ft.a,null,"Confirmed"),i.a.createElement(ft.a,null,"Base64 encoded payload"))),i.a.createElement(Pt.a,null,e))))}}]),a}(n.Component);hs=Object(d.f)(hs);var ds=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).setDeviceActivation=function(){void 0!==e.props.device&&io.getActivation(e.props.device.device.devEUI,(function(t){null===t?e.setState({activated:!1}):e.setState({activated:!0})}))},e.state={activated:!1},e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){this.setDeviceActivation()}},{key:"componentDidUpdate",value:function(e){e.device!==this.props.device&&this.setDeviceActivation()}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(y.a,{item:!0,xs:6},i.a.createElement(ls,{device:this.props.device,deviceProfile:this.props.deviceProfile,match:this.props.match})),i.a.createElement(y.a,{item:!0,xs:6},i.a.createElement(us,{device:this.props.device})),this.state.activated&&i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(ps,null)),this.state.activated&&i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(hs,null)))}}]),a}(n.Component),gs={tabs:{borderBottom:"1px solid "+O.a.palette.divider,height:"49px"}},bs=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).state={tab:0,admin:!1},e.onChangeTab=e.onChangeTab.bind(Object(p.a)(e)),e.deleteDevice=e.deleteDevice.bind(Object(p.a)(e)),e.locationToTab=e.locationToTab.bind(Object(p.a)(e)),e.setIsAdmin=e.setIsAdmin.bind(Object(p.a)(e)),e.getDevice=e.getDevice.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"componentDidMount",value:function(){var e=this;Zi.get(this.props.match.params.applicationID,(function(t){e.setState({application:t})})),io.on("update",this.getDevice),V.a.on("change",this.setIsAdmin),this.locationToTab(),this.setIsAdmin(),this.getDevice()}},{key:"componentWillUnmount",value:function(){V.a.removeListener("change",this.setIsAdmin),io.removeListener("update",this.getDevice)}},{key:"componentDidUpdate",value:function(e){this.props!==e&&this.locationToTab()}},{key:"getDevice",value:function(){var e=this;io.get(this.props.match.params.devEUI,(function(t){e.setState({device:t}),Wn.get(t.device.deviceProfileID,(function(t){e.setState({deviceProfile:t})}))}))}},{key:"setIsAdmin",value:function(){var e=this;this.setState({admin:V.a.isAdmin()||V.a.isOrganizationDeviceAdmin(this.props.match.params.organizationID)},(function(){e.locationToTab()}))}},{key:"onChangeTab",value:function(e,t){this.setState({tab:t})}},{key:"locationToTab",value:function(){var e=0;window.location.href.endsWith("/edit")?e=1:window.location.href.endsWith("/keys")?e=2:window.location.href.endsWith("/activation")?e=3:window.location.href.endsWith("/data")?e=4:window.location.href.endsWith("/frames")&&(e=5),e>1&&!this.state.admin&&(e-=1),this.setState({tab:e})}},{key:"deleteDevice",value:function(){var e=this;window.confirm("Are you sure you want to delete this device?")&&io.delete(this.props.match.params.devEUI,(function(t){e.props.history.push("/organizations/".concat(e.props.match.params.organizationID,"/applications/").concat(e.props.match.params.applicationID))}))}},{key:"render",value:function(){var e=this;return void 0===this.state.application||void 0===this.state.device||void 0===this.state.deviceProfile?i.a.createElement("div",null):i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(Ze,{buttons:i.a.createElement(Rn,{organizationID:this.props.match.params.organizationID},i.a.createElement(It,{label:"Delete",icon:i.a.createElement(ra.a,null),color:"secondary",onClick:this.deleteDevice}))},i.a.createElement($e,{to:"/organizations/".concat(this.props.match.params.organizationID,"/applications"),title:"Applications"}),i.a.createElement($e,{title:"/"}),i.a.createElement($e,{to:"/organizations/".concat(this.props.match.params.organizationID,"/applications/").concat(this.props.match.params.applicationID),title:this.state.application.application.name}),i.a.createElement($e,{title:"/"}),i.a.createElement($e,{to:"/organizations/".concat(this.props.match.params.organizationID,"/applications/").concat(this.props.match.params.applicationID),title:"Devices"}),i.a.createElement($e,{title:"/"}),i.a.createElement($e,{to:"/organizations/".concat(this.props.match.params.organizationID,"/applications/").concat(this.props.match.params.applicationID,"/devices/").concat(this.props.match.params.devEUI),title:this.state.device.device.name})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(qt.a,{value:this.state.tab,onChange:this.onChangeTab,indicatorColor:"primary",className:this.props.classes.tabs,variant:"scrollable",scrollButtons:"auto"},i.a.createElement(_t.a,{label:"Details",component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/applications/").concat(this.props.match.params.applicationID,"/devices/").concat(this.props.match.params.devEUI)}),i.a.createElement(_t.a,{label:"Configuration",component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/applications/").concat(this.props.match.params.applicationID,"/devices/").concat(this.props.match.params.devEUI,"/edit")}),this.state.admin&&i.a.createElement(_t.a,{label:"Keys (OTAA)",disabled:!this.state.deviceProfile.deviceProfile.supportsJoin,component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/applications/").concat(this.props.match.params.applicationID,"/devices/").concat(this.props.match.params.devEUI,"/keys")}),i.a.createElement(_t.a,{label:"Activation",component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/applications/").concat(this.props.match.params.applicationID,"/devices/").concat(this.props.match.params.devEUI,"/activation")}),i.a.createElement(_t.a,{label:"Device data",component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/applications/").concat(this.props.match.params.applicationID,"/devices/").concat(this.props.match.params.devEUI,"/data")}),i.a.createElement(_t.a,{label:"LoRaWAN Frames",component:w.a,to:"/organizations/".concat(this.props.match.params.organizationID,"/applications/").concat(this.props.match.params.applicationID,"/devices/").concat(this.props.match.params.devEUI,"/frames")}))),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(d.c,null,i.a.createElement(d.a,{exact:!0,path:"".concat(this.props.match.path),render:function(t){return i.a.createElement(ds,Object.assign({device:e.state.device,deviceProfile:e.state.deviceProfile,admin:e.state.admin},t))}}),i.a.createElement(d.a,{exact:!0,path:"".concat(this.props.match.path,"/edit"),render:function(t){return i.a.createElement(Fr,Object.assign({device:e.state.device.device,admin:e.state.admin},t))}}),i.a.createElement(d.a,{exact:!0,path:"".concat(this.props.match.path,"/keys"),render:function(t){return i.a.createElement(_r,Object.assign({device:e.state.device.device,admin:e.state.admin,deviceProfile:e.state.deviceProfile.deviceProfile},t))}}),i.a.createElement(d.a,{exact:!0,path:"".concat(this.props.match.path,"/activation"),render:function(t){return i.a.createElement(Zr,Object.assign({device:e.state.device.device,admin:e.state.admin,deviceProfile:e.state.deviceProfile.deviceProfile},t))}}),i.a.createElement(d.a,{exact:!0,path:"".concat(this.props.match.path,"/data"),render:function(t){return i.a.createElement(es,Object.assign({device:e.state.device.device,admin:e.state.admin},t))}}),i.a.createElement(d.a,{exact:!0,path:"".concat(this.props.match.path,"/frames"),render:function(t){return i.a.createElement(ns,Object.assign({device:e.state.device.device,admin:e.state.admin},t))}}))))}}]),a}(n.Component),vs=Object(E.a)(gs)(Object(d.f)(bs)),fs={link:{color:O.a.palette.primary.main,textDecoration:"none"},type:{fontWeight:"bold"}},Es=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){return i.a.createElement(Et.a,{hover:!0},i.a.createElement(ft.a,{className:this.props.classes.type},"application"),i.a.createElement(ft.a,null,i.a.createElement(w.a,{className:this.props.classes.link,to:"/organizations/".concat(this.props.result.organizationID,"/applications/").concat(this.props.result.applicationID)},this.props.result.applicationName)),i.a.createElement(ft.a,null,"organization: ",i.a.createElement(w.a,{className:this.props.classes.link,to:"/organizations/".concat(this.props.result.organizationID)},this.props.result.organizationName)),i.a.createElement(ft.a,null,this.props.result.applicationID))}}]),a}(n.Component);Es=Object(E.a)(fs)(Es);var ys=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){return i.a.createElement(Et.a,{hover:!0},i.a.createElement(ft.a,{className:this.props.classes.type},"organization"),i.a.createElement(ft.a,null,i.a.createElement(w.a,{className:this.props.classes.link,to:"/organizations/".concat(this.props.result.organizationID)},this.props.result.organizationName)),i.a.createElement(ft.a,null),i.a.createElement(ft.a,null,this.props.result.organizationID))}}]),a}(n.Component);ys=Object(E.a)(fs)(ys);var js=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){return i.a.createElement(Et.a,{hover:!0},i.a.createElement(ft.a,{className:this.props.classes.type},"device"),i.a.createElement(ft.a,null,i.a.createElement(w.a,{className:this.props.classes.link,to:"/organizations/".concat(this.props.result.organizationID,"/applications/").concat(this.props.result.applicationID,"/devices/").concat(this.props.result.deviceDevEUI)},this.props.result.deviceName)),i.a.createElement(ft.a,null,"organization: ",i.a.createElement(w.a,{className:this.props.classes.link,to:"/organizations/".concat(this.props.result.organizationID)},this.props.result.organizationName),", application: ",i.a.createElement(w.a,{className:this.props.classes.link,to:"/organizations/".concat(this.props.result.organizationID,"/applications/").concat(this.props.result.applicationID)},this.props.result.applicationName)),i.a.createElement(ft.a,null,this.props.result.deviceDevEUI))}}]),a}(n.Component);js=Object(E.a)(fs)(js);var Os=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){return Object(l.a)(this,a),t.apply(this,arguments)}return Object(u.a)(a,[{key:"render",value:function(){return i.a.createElement(Et.a,{hover:!0},i.a.createElement(ft.a,{className:this.props.classes.type},"gateway"),i.a.createElement(ft.a,null,i.a.createElement(w.a,{className:this.props.classes.link,to:"/organizations/".concat(this.props.result.organizationID,"/gateways/").concat(this.props.result.gatewayMAC)},this.props.result.gatewayName)),i.a.createElement(ft.a,null,"organization: ",i.a.createElement(w.a,{className:this.props.classes.link,to:"/organizations/".concat(this.props.result.organizationID)},this.props.result.organizationName)),i.a.createElement(ft.a,null,this.props.result.gatewayMAC))}}]),a}(n.Component);Os=Object(E.a)(fs)(Os);var ws=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;return Object(l.a)(this,a),(e=t.call(this)).getPage=e.getPage.bind(Object(p.a)(e)),e.getRow=e.getRow.bind(Object(p.a)(e)),e}return Object(u.a)(a,[{key:"getPage",value:function(e,t,a){var n=new URLSearchParams(this.props.location.search),i=null===n.get("search")?"":n.get("search");""!==i?V.a.globalSearch(i,e,t,(function(e){var t=e;t.totalCount=t.result.length,a(t)})):a({result:[],totalCount:0})}},{key:"getRow",value:function(e){switch(e.kind){case"application":return i.a.createElement(Es,{result:e});case"organization":return i.a.createElement(ys,{result:e});case"device":return i.a.createElement(js,{result:e});case"gateway":return i.a.createElement(Os,{result:e})}}},{key:"render",value:function(){return i.a.createElement(y.a,{container:!0,spacing:4},i.a.createElement(Ze,null,i.a.createElement($e,{title:"Search"})),i.a.createElement(y.a,{item:!0,xs:12},i.a.createElement(Ut,{header:i.a.createElement(Et.a,null,i.a.createElement(ft.a,null,"Kind"),i.a.createElement(ft.a,null,"Name"),i.a.createElement(ft.a,null),i.a.createElement(ft.a,null,"ID")),getPage:this.getPage,getRow:this.getRow})))}}]),a}(n.Component),Cs=function(e){Object(m.a)(a,e);var t=Object(h.a)(a);function a(){var e;Object(l.a)(this,a);for(var n=arguments.length,i=new Array(n),o=0;o