UNPKG

harperdb

Version:

HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.

1 lines 8.94 kB
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[297],{1813:(e,t,r)=>{r.r(t),r.d(t,{default:()=>C});var s=r(9950),n=r(7176),a=r(6114),o=r(625),c=r(4084),i=r(8156),l=r(5488),u=r(3452),d=r(6359),f=r(9163),p=r.n(f),h=r(6713),m=r(9435),y=r(5269),b=r(8198),v=r(8188),g=r(9561),x=r(3150),j=r(3628),A=r(2415),w=r(4414);const O=function(e){let{setLastUpdate:t}=e;const r=(0,h.O$)(y.A,(e=>e.auth)),n=(0,h.O$)(y.A,(e=>e.url)),a=(0,h.O$)(y.A,(e=>e.users)),o=(0,h.O$)(y.A,(e=>e.roles)),f=(0,h.O$)(y.A,(e=>{var t;return parseFloat(null===(t=e.registration)||void 0===t?void 0:t.version)<3})),[O,N]=(0,s.useState)({}),[S,k]=(0,s.useState)({}),C="224px";return p()((async()=>{const{submitted:e}=O;if(e){const{username:e,password:s,role:o}=S;if(e&&o&&s)if((0,g.A)(e))if(a.find((t=>t.username.toLowerCase()===e.toLowerCase())))N({error:"User already exists"});else{N({processing:!0});const a=await(0,b.A)({auth:r,role:o,username:e,password:s,url:n});-1!==a.message.indexOf("successfully")?(t(Date.now()),N({success:a.message})):N({error:a.message})}else N({error:"usernames must have only letters, numbers, hyphens, and underscores"}),setTimeout((()=>N({})),2e3);else N({error:"All fields must be filled out"});setTimeout((()=>k({})),2e3)}}),[O]),p()((()=>{N({})}),[S]),p()((()=>o&&k({...S,role:!1})),[o]),(0,s.useEffect)((()=>{(0,A.A)({auth:r,url:n})}),[r,n]),(0,w.jsxs)(m.tH,{onError:(e,t)=>(0,j.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:x.A,children:[(0,w.jsx)("span",{className:"floating-card-header",children:"add user"}),O.processing?(0,w.jsx)(v.A,{className:"my-3",height:C,status:"processing",header:"Adding User",subhead:"The Account Airedale Is A Good Boy"}):O.success?(0,w.jsx)(v.A,{className:"my-3",height:C,status:"success",header:"Success!",subhead:O.success}):O.error?(0,w.jsx)(v.A,{className:"my-3",height:C,status:"error",header:O.error,subhead:"Please try again"}):(0,w.jsx)(c.A,{className:"my-3",children:(0,w.jsxs)(i.A,{children:[(0,w.jsx)(l.A,{id:"username",type:"text",className:"mb-2 text-center",name:"username",placeholder:"username",value:S.username||"",onChange:e=>k({...S,username:e.target.value})}),(0,w.jsx)(l.A,{id:"password",type:"text",className:"mb-2 text-center",name:"password",placeholder:"password",value:S.password||"",onChange:e=>k({...S,password:e.target.value})}),(0,w.jsx)(d.Ay,{className:"react-select-container",classNamePrefix:"react-select",onChange:e=>{let{value:t}=e;return k({...S,role:t})},options:o&&o.map((e=>({label:e.role,value:f?e.id:e.role}))),value:o&&S.role&&o.find((e=>e.value===S.role)),isSearchable:!1,isClearable:!1,isLoading:!o,placeholder:"select a role",styles:{placeholder:e=>({...e,textAlign:"center",width:"100%",color:"#BCBCBC"})}}),(0,w.jsx)(u.A,{id:"addInstanceUser",color:"success",className:"mt-3",block:!0,onClick:()=>N({submitted:!0}),children:"Add User"})]})})]})};var N=r(4979);const S=(0,s.lazy)((()=>Promise.all([r.e(43),r.e(642)]).then(r.bind(r,7695)))),k=(0,s.lazy)((()=>r.e(154).then(r.bind(r,2729))));const C=function(){const{username:e}=(0,o.g)(),[t,r]=(0,s.useState)(!0);return(0,w.jsxs)(n.A,{children:[(0,w.jsx)(a.A,{xl:"3",lg:"4",md:"5",xs:"12",children:(0,w.jsx)(O,{setLastUpdate:r})}),(0,w.jsx)(a.A,{xl:"9",lg:"8",md:"7",xs:"12",className:"pb-5",children:(0,w.jsx)(s.Suspense,{fallback:(0,w.jsx)(N.A,{header:" ",spinner:!0}),children:e?(0,w.jsx)(k,{}):(0,w.jsx)(S,{lastUpdate:t,setLastUpdate:r})})})]})}},8188:(e,t,r)=>{r.d(t,{A:()=>o});r(9950);var s=r(4084),n=r(8156),a=r(4414);const o=function(e){let{header:t,subhead:r=" ",height:o,status:c,className:i}=e;return(0,a.jsx)(s.A,{className:`form-status ${i}`,children:(0,a.jsxs)(n.A,{className:"text-center",style:{height:o},children:[(0,a.jsx)("div",{className:"text-bold",children:t}),(0,a.jsx)("div",{className:"py-4",children:(0,a.jsx)("i",{className:"fa fa-lg "+("processing"===c?"fa-spinner fa-spin text-purple":"success"===c?"fa-check-circle text-purple":"fa-exclamation-triangle text-danger")})}),(0,a.jsx)("div",{className:"text-grey",children:r})]})})}},8198:(e,t,r)=>{r.d(t,{A:()=>n});var s=r(127);const n=async e=>{let{auth:t,role:r,username:n,password:a,url:o}=e;return(0,s.A)({operation:{operation:"add_user",role:r,username:n,password:a,active:!0},auth:t,url:o})}},2415:(e,t,r)=>{r.d(t,{A:()=>a});var s=r(127),n=r(5269);const a=async e=>{let{auth:t,url:r}=e;const a=await(0,s.A)({operation:{operation:"list_roles"},auth:t,url:r}),o=[...Array.isArray(a)?a:[]].sort(((e,t)=>e.role.toLowerCase()>t.role.toLowerCase()?1:-1));return n.A.update((e=>{e.roles=o})),o}},9561:(e,t,r)=>{r.d(t,{A:()=>s});const s=e=>e.match(/^[-a-zA-Z0-9_]+$/)},5488:(e,t,r)=>{r.d(t,{A:()=>x});var s=r(9950),n=r(1942),a=r.n(n),o=r(8738),c=r.n(o),i=r(1497);function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}var u=["className","cssModule","type","bsSize","valid","invalid","tag","addon","plaintext","innerRef"];function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},d.apply(this,arguments)}function f(e,t){if(null==e)return{};var r,s,n=function(e,t){if(null==e)return{};var r,s,n={},a=Object.keys(e);for(s=0;s<a.length;s++)r=a[s],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(s=0;s<a.length;s++)r=a[s],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function p(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function m(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,s=b(e);if(t){var n=b(this).constructor;r=Reflect.construct(s,arguments,n)}else r=s.apply(this,arguments);return function(e,t){if(t&&("object"===l(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return y(e)}(this,r)}}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}var v={children:a().node,type:a().string,size:a().oneOfType([a().number,a().string]),bsSize:a().string,valid:a().bool,invalid:a().bool,tag:i.Wx,innerRef:a().oneOfType([a().object,a().func,a().string]),plaintext:a().bool,addon:a().bool,className:a().string,cssModule:a().object},g=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}(o,e);var t,r,n,a=m(o);function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=a.call(this,e)).getRef=t.getRef.bind(y(t)),t.focus=t.focus.bind(y(t)),t}return t=o,(r=[{key:"getRef",value:function(e){this.props.innerRef&&this.props.innerRef(e),this.ref=e}},{key:"focus",value:function(){this.ref&&this.ref.focus()}},{key:"render",value:function(){var e=this.props,t=e.className,r=e.cssModule,n=e.type,a=void 0===n?"text":n,o=e.bsSize,l=e.valid,p=e.invalid,h=e.tag,m=e.addon,y=e.plaintext,b=e.innerRef,v=f(e,u),g=["switch","radio","checkbox"].indexOf(a)>-1,x="select"===a,j="range"===a,A=h||(x||"textarea"===a?a:"input"),w="form-control";y?(w="".concat(w,"-plaintext"),A=h||"input"):j?w="form-range":x?w="form-select":g&&(w=m?null:"form-check-input"),v.size&&/\D/g.test(v.size)&&((0,i.mc)('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),o=v.size,delete v.size);var O=(0,i.qO)(c()(t,p&&"is-invalid",l&&"is-valid",!!o&&(x?"form-select-".concat(o):"form-control-".concat(o)),w),r);return("input"===A||h&&"function"===typeof h)&&(v.type="switch"===a?"checkbox":a),v.children&&!y&&"select"!==a&&"string"===typeof A&&"select"!==A&&((0,i.mc)('Input with a type of "'.concat(a,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete v.children),s.createElement(A,d({},v,{ref:b,className:O,"aria-invalid":p}))}}])&&p(t.prototype,r),n&&p(t,n),Object.defineProperty(t,"prototype",{writable:!1}),o}(s.Component);g.propTypes=v;const x=g}}]);