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 15.4 kB
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[138],{4244:(e,s,t)=>{t.r(s),t.d(s,{default:()=>d});var r=t(9950),a=t(625),n=t(4414);const o=(0,r.lazy)((()=>Promise.all([t.e(759),t.e(138)]).then(t.bind(t,2670)))),i=[{element:(0,n.jsx)(o,{}),path:"",link:"profile",label:"profile",icon:"user",iconCode:"f007"}];var l=t(8651),c=t(4979);const d=function(){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(l.A,{}),(0,n.jsx)(r.Suspense,{fallback:(0,n.jsx)(c.A,{header:" ",spinner:!0}),children:(0,n.jsxs)(a.BV,{children:[i.map((e=>(0,n.jsx)(a.qh,{path:e.path,element:e.element},e.path))),(0,n.jsx)(a.qh,{path:"*",element:(0,n.jsx)(a.C5,{to:"/profile",replace:!0})},"*")]})})]})}},2670:(e,s,t)=>{t.r(s),t.d(s,{default:()=>k});var r=t(9950),a=t(7176),n=t(6114),o=t(4084),i=t(8156),l=t(5488),c=t(3452),d=t(6713),u=t(9435),p=t(5553),m=t(2714),h=t(3628),f=t(5996),x=t(3304);var b=t(8188),g=t(3150),j=t(2773),v=t(4414);const y=function(){const e=(0,d.O$)(p.A,(e=>e.auth)),[s,t]=(0,r.useState)({}),[y,w]=(0,r.useState)(e),A="314px";return(0,r.useEffect)((()=>{let s=!0;return s&&null!==e&&void 0!==e&&e.profileError?t({error:e.message}):s&&null!==e&&void 0!==e&&e.profileSuccess&&t({success:e.message}),()=>{s=!1}}),[e.profileError,e.profileSuccess]),(0,r.useEffect)((()=>{let e=!0;return(s.error||s.success)&&setTimeout((()=>{e&&t({})}),2e3),()=>{e=!1}}),[s.error,s.success]),(0,v.jsx)(u.tH,{onError:(e,s)=>(0,h.A)({error:{message:e.message,componentStack:s}}),FallbackComponent:g.A,children:(0,v.jsx)("div",{className:"my-3",children:s.processing?(0,v.jsx)(b.A,{height:A,status:"processing",header:"Updating Profile",subhead:"The Profile Poodle is doing his thing."}):s.success?(0,v.jsx)(b.A,{height:A,status:"success",header:"Success!",subhead:s.success}):s.error?(0,v.jsx)(b.A,{height:A,status:"error",header:s.error,subhead:"Please try again"}):(0,v.jsx)(o.A,{className:"mb-3",children:(0,v.jsxs)(i.A,{children:[(0,v.jsxs)(a.A,{children:[(0,v.jsx)(n.A,{xs:"6",className:"text text-nowrap d-none d-md-block pt-2",children:null===e||void 0===e||!e.email_bounced||null!==e&&void 0!==e&&e.profileSuccess?(0,v.jsx)("span",{children:e.email}):(0,v.jsx)("span",{className:"text-danger",children:"please provide a valid email address"})}),(0,v.jsx)(n.A,{md:"6",xs:"12",children:(0,v.jsx)(l.A,{id:"email",type:"text",className:"mb-0 text-center "+(null===e||void 0===e||!e.email_bounced||null!==e&&void 0!==e&&e.profileSuccess?"":"error"),name:"email",placeholder:"email address",onChange:e=>w({...y,email:e.target.value}),value:y.email||"",disabled:s.submitted})}),(0,v.jsx)(n.A,{xs:"12",children:(0,v.jsx)("hr",{className:"my-2"})}),(0,v.jsx)(n.A,{xs:"6",className:"text text-nowrap d-none d-md-block pt-2",children:"first name"}),(0,v.jsx)(n.A,{md:"6",xs:"12",children:(0,v.jsx)(l.A,{id:"firstname",type:"text",className:"mb-0 text-center",name:"fname",placeholder:"first name",onChange:e=>w({...y,firstname:e.target.value}),value:y.firstname||"",disabled:s.submitted})}),(0,v.jsx)(n.A,{xs:"12",children:(0,v.jsx)("hr",{className:"my-2"})}),(0,v.jsx)(n.A,{xs:"6",className:"text text-nowrap d-none d-md-block pt-2",children:"last name"}),(0,v.jsx)(n.A,{md:"6",xs:"12",children:(0,v.jsx)(l.A,{id:"lastname",type:"text",className:"mb-0 text-center",name:"lname",placeholder:"last name",onChange:e=>w({...y,lastname:e.target.value}),value:y.lastname||"",disabled:s.submitted})}),(0,v.jsx)(n.A,{xs:"12",children:(0,v.jsx)("hr",{className:"my-2"})}),(0,v.jsx)(n.A,{xs:"6",className:"text text-nowrap d-none d-md-block pt-2",children:"github repo"}),(0,v.jsx)(n.A,{md:"6",xs:"12",children:(0,v.jsx)(l.A,{id:"github_repo",type:"text",className:"mb-0 text-center",name:"github_repo",placeholder:"github repo",onChange:e=>w({...y,github_repo:e.target.value}),value:y.github_repo||"",disabled:s.submitted})})]}),(0,v.jsx)("hr",{className:"mt-2 mb-4"}),(0,v.jsx)(c.A,{id:"saveProfile",color:"purple",block:!0,onClick:()=>{t({submitted:!0});const{firstname:s,lastname:r,github_repo:a,email:n}=y;s&&r&&n?a&&!(0,j.A)(a)?t({error:"github repo must be a valid URL"}):e.firstname===s&&e.lastname===r&&e.github_repo===a&&e.email===n?t({error:"Nothing seems to have changed"}):(t({processing:!0}),(async e=>{let{auth:s,firstname:t,lastname:r,customer_id:a,user_id:n,github_repo:o,email:i}=e,l=null;try{return l=await(0,m.A)({endpoint:"updateUser",method:"POST",payload:{firstname:t,lastname:r,customer_id:a,user_id:n,github_repo:o,email:i},auth:s}),l.error?p.A.update((e=>{e.auth={...s,...l,profileError:Date.now()}})):(p.A.update((e=>{e.auth={...s,profileSuccess:Date.now(),...l}})),(0,x.A)({email:i,pass:s.pass,loggingIn:!0}))}catch(c){return(0,h.A)({type:"lms data",status:"error",url:f.A.lms_api_url,operation:"updateUser",request:{firstname:t,lastname:r,customer_id:a,user_id:n,github_repo:o},error:{catch:c.toString()},customer_id:a})}})({auth:e,firstname:s,lastname:r,user_id:e.user_id,github_repo:a,email:n})):t({error:"All fields are required"})},disabled:s.submitted,children:"Save Profile"})]})})})})};var w=t(4127),A=t(5283);const N=function(){const e=(0,d.O$)(p.A,(e=>e.auth)),[s,t]=(0,A.A)({}),[m,f]=(0,r.useState)({}),[x,j]=(0,r.useState)({}),y="259px";return(0,r.useEffect)((()=>{let e=!0;return(m.error||m.success)&&setTimeout((()=>{e&&f({})}),2e3),()=>{e=!1}}),[m.error,m.success]),(0,v.jsx)(u.tH,{onError:(e,s)=>(0,h.A)({error:{message:e.message,componentStack:s}}),FallbackComponent:g.A,children:(0,v.jsx)("div",{className:"my-3",children:m.processing?(0,v.jsx)(b.A,{height:y,status:"processing",header:"Updating Password",subhead:"The Security Shepherd is mad-hashing."}):m.success?(0,v.jsx)(b.A,{height:y,status:"success",header:"Success!",subhead:m.success}):m.error?(0,v.jsx)(b.A,{height:y,status:"error",header:m.error,subhead:"Please try again"}):(0,v.jsx)(o.A,{children:(0,v.jsxs)(i.A,{children:[(0,v.jsxs)(a.A,{children:[(0,v.jsx)(n.A,{xs:"6",className:"text text-nowrap d-none d-md-block pt-2",children:"current password"}),(0,v.jsx)(n.A,{md:"6",xs:"12",children:(0,v.jsx)(l.A,{id:"oldpassword",type:"password",className:"mb-0 text-center",name:"current password",placeholder:"current password",onChange:e=>j({...x,oldpassword:e.target.value}),value:x.oldpassword||"",disabled:m.submitted})}),(0,v.jsx)(n.A,{xs:"12",children:(0,v.jsx)("hr",{className:"my-2"})}),(0,v.jsx)(n.A,{xs:"6",className:"text text-nowrap d-none d-md-block pt-2",children:"new password"}),(0,v.jsx)(n.A,{md:"6",xs:"12",children:(0,v.jsx)(l.A,{id:"newpassword1",type:"password",className:"mb-0 text-center",name:"new password",placeholder:"new password",onChange:e=>j({...x,newpassword:e.target.value}),value:x.newpassword||"",disabled:m.submitted})}),(0,v.jsx)(n.A,{xs:"12",children:(0,v.jsx)("hr",{className:"my-2"})}),(0,v.jsx)(n.A,{xs:"6",className:"text text-nowrap d-none d-md-block pt-2",children:"verify password"}),(0,v.jsx)(n.A,{md:"6",xs:"12",children:(0,v.jsx)(l.A,{id:"newpassword2",type:"password",className:"mb-0 text-center",name:"verify password",placeholder:"verify password",onChange:e=>j({...x,newpassword2:e.target.value}),value:x.newpassword2||"",disabled:m.submitted})})]}),(0,v.jsx)("hr",{className:"mt-2 mb-4"}),(0,v.jsx)(c.A,{id:"updatePassword",color:"purple",block:!0,onClick:async()=>{f({submitted:!0});const{oldpassword:r,newpassword:a,newpassword2:n}=x;if(r!==e.pass)f({error:"old password is incorrect"}),j({});else if(a!==n)f({error:"new passwords do not match"}),j({});else if(r&&a&&n){f({processing:!0});const r=await(0,w.A)({auth:e,user_id:e.user_id,password:a});!r||r.passwordError?f({error:e.message}):(t({...s,pass:a}),f({success:e.message}),j({}))}else f({error:"all fields are required"}),j({})},disabled:m.submitted,children:"Update Password"})]})})})})};const k=function(){return(0,v.jsxs)(a.A,{children:[(0,v.jsxs)(n.A,{md:"6",className:"mb-4",children:[(0,v.jsx)("span",{className:"floating-card-header",children:"profile"}),(0,v.jsx)(y,{})]}),(0,v.jsxs)(n.A,{md:"6",className:"mb-4",children:[(0,v.jsx)("span",{className:"floating-card-header",children:"password"}),(0,v.jsx)(N,{})]})]})}},8188:(e,s,t)=>{t.d(s,{A:()=>o});t(9950);var r=t(4084),a=t(8156),n=t(4414);const o=function(e){let{header:s,subhead:t=" ",height:o,status:i,className:l}=e;return(0,n.jsx)(r.A,{className:`form-status ${l}`,children:(0,n.jsxs)(a.A,{className:"text-center",style:{height:o},children:[(0,n.jsx)("div",{className:"text-bold",children:s}),(0,n.jsx)("div",{className:"py-4",children:(0,n.jsx)("i",{className:"fa fa-lg "+("processing"===i?"fa-spinner fa-spin text-purple":"success"===i?"fa-check-circle text-purple":"fa-exclamation-triangle text-danger")})}),(0,n.jsx)("div",{className:"text-grey",children:t})]})})}},8651:(e,s,t)=>{t.d(s,{A:()=>p});t(9950);var r=t(2072),a=t(8125),n=t(5746),o=t(6359),i=t(625),l=t(9435),c=t(3150),d=t(3628),u=t(4414);const p=function(e){let{routes:s=[]}=e;const t=(0,i.Zp)(),p=(0,i.zy)(),m=(null===s||void 0===s?void 0:s.find((e=>e.link===p.pathname)))||s[0];return(0,u.jsx)(l.tH,{onError:(e,s)=>(0,d.A)({error:{message:e.message,componentStack:s}}),FallbackComponent:c.A,children:(0,u.jsx)(r.A,{className:"app-subnav",children:m&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a.A,{navbar:!0,className:"instance-nav d-none d-md-flex",children:s.map((e=>e.external?(0,u.jsx)("li",{className:"nav-item",children:(0,u.jsxs)("a",{className:"nav-link",href:e.url,target:"_blank",rel:"noreferrer",children:[(0,u.jsx)("i",{className:`d-none d-sm-inline-block fa me-1 fa-${e.icon}`}),e.label]})},e.path):(0,u.jsx)(n.A,{children:(0,u.jsxs)(i.k2,{title:e.link,className:"nav-link",to:e.link||e.path,children:[(0,u.jsx)("i",{className:`d-none d-sm-inline-block fa me-1 fa-${e.icon}`}),e.label]})},e.path)))}),(0,u.jsx)(a.A,{navbar:!0,className:"d-flex d-md-none",children:(0,u.jsx)(o.Ay,{className:"react-select-container",classNamePrefix:"react-select",width:"200px",onChange:e=>{let{value:s}=e;return t(s)},options:s.filter((e=>e.link!==m.link)).map((e=>({label:(0,u.jsxs)("span",{children:[(0,u.jsx)("i",{className:`d-none d-sm-inline-block fa me-1 fa-${e.icon}`}),e.label]}),value:e.link,iconCode:e.iconCode}))),value:{...m,value:null===m||void 0===m?void 0:m.link},defaultValue:null===m||void 0===m?void 0:m.link,isSearchable:!1,isClearable:!1})})]})})})}},4127:(e,s,t)=>{t.d(s,{A:()=>i});var r=t(2714),a=t(5553),n=t(3628),o=t(5996);const i=async e=>{let{auth:s,user_id:t,password:i}=e,l=null;try{if(l=await(0,r.A)({endpoint:"updatePassword",method:"POST",payload:{user_id:t,password:i,loggingIn:!0},auth:s}),l.error){const e={...s,...l,passwordError:Date.now()};return a.A.update((s=>{s.auth=e})),e}const e={...s,passwordSuccess:Date.now(),update_password:!1,...l,pass:i};return a.A.update((s=>{s.auth=e})),e}catch(c){return(0,n.A)({type:"lms data",status:"error",url:o.A.lms_api_url,operation:"updatePassword",request:{user_id:t},error:{catch:c.toString()}})}}},2773:(e,s,t)=>{t.d(s,{A:()=>r});const r=e=>!!new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(e)},5488:(e,s,t)=>{t.d(s,{A:()=>v});var r=t(9950),a=t(1942),n=t.n(a),o=t(8738),i=t.n(o),l=t(1497);function c(e){return c="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},c(e)}var d=["className","cssModule","type","bsSize","valid","invalid","tag","addon","plaintext","innerRef"];function u(){return u=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},u.apply(this,arguments)}function p(e,s){if(null==e)return{};var t,r,a=function(e,s){if(null==e)return{};var t,r,a={},n=Object.keys(e);for(r=0;r<n.length;r++)t=n[r],s.indexOf(t)>=0||(a[t]=e[t]);return a}(e,s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(r=0;r<n.length;r++)t=n[r],s.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function m(e,s){for(var t=0;t<s.length;t++){var r=s[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function h(e,s){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,s){return e.__proto__=s,e},h(e,s)}function f(e){var s=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 t,r=b(e);if(s){var a=b(this).constructor;t=Reflect.construct(r,arguments,a)}else t=r.apply(this,arguments);return function(e,s){if(s&&("object"===c(s)||"function"===typeof s))return s;if(void 0!==s)throw new TypeError("Derived constructors may only return object or undefined");return x(e)}(this,t)}}function x(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 g={children:n().node,type:n().string,size:n().oneOfType([n().number,n().string]),bsSize:n().string,valid:n().bool,invalid:n().bool,tag:l.Wx,innerRef:n().oneOfType([n().object,n().func,n().string]),plaintext:n().bool,addon:n().bool,className:n().string,cssModule:n().object},j=function(e){!function(e,s){if("function"!==typeof s&&null!==s)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&h(e,s)}(o,e);var s,t,a,n=f(o);function o(e){var s;return function(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}(this,o),(s=n.call(this,e)).getRef=s.getRef.bind(x(s)),s.focus=s.focus.bind(x(s)),s}return s=o,(t=[{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,s=e.className,t=e.cssModule,a=e.type,n=void 0===a?"text":a,o=e.bsSize,c=e.valid,m=e.invalid,h=e.tag,f=e.addon,x=e.plaintext,b=e.innerRef,g=p(e,d),j=["switch","radio","checkbox"].indexOf(n)>-1,v="select"===n,y="range"===n,w=h||(v||"textarea"===n?n:"input"),A="form-control";x?(A="".concat(A,"-plaintext"),w=h||"input"):y?A="form-range":v?A="form-select":j&&(A=f?null:"form-check-input"),g.size&&/\D/g.test(g.size)&&((0,l.mc)('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),o=g.size,delete g.size);var N=(0,l.qO)(i()(s,m&&"is-invalid",c&&"is-valid",!!o&&(v?"form-select-".concat(o):"form-control-".concat(o)),A),t);return("input"===w||h&&"function"===typeof h)&&(g.type="switch"===n?"checkbox":n),g.children&&!x&&"select"!==n&&"string"===typeof w&&"select"!==w&&((0,l.mc)('Input with a type of "'.concat(n,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete g.children),r.createElement(w,u({},g,{ref:b,className:N,"aria-invalid":m}))}}])&&m(s.prototype,t),a&&m(s,a),Object.defineProperty(s,"prototype",{writable:!1}),o}(r.Component);j.propTypes=g;const v=j}}]);