(this["webpackJsonpocpp-cs"]=this["webpackJsonpocpp-cs"]||[]).push([[40],{1341:function(e,t,a){"use strict";a.r(t);var n=a(3),s=a(9),r=a(27),i=a(22),c=a(21),o=a(29),l=a(30),d=a(0),u=a.n(d),h=a(210),m=a(111),j=a(112),p=a(447),b=a(744),x=a(144),f=a(834),O=a(844),g=a(746),v=a(871),w=a(1337),k=a(742),y=a(739),S=a(802),C=a(803),R=a(20),A=a(189),I={maxWidth:2e3,maxHeight:2e3,quality:.8};function N(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=document.createElement("canvas"),n=document.createElement("img"),s=Object.assign(I,t),r=s.maxWidth,i=s.maxHeight,c=s.quality;return new Promise((function(t,s){n.onload=function(){var e=n.width,s=n.height;e>s?e>r&&(s=Math.round(s*=r/e),e=r):s>i&&(e=Math.round(e*=i/s),s=i),a.width=e,a.height=s,a.getContext("2d").drawImage(n,0,0,e,s),t(a.toDataURL("image/jpeg",c))},n.onerror=function(e){t(!1)},n.src=e}))}var q=a(889),H=a(795),P=a(2),z=function(e){Object(o.a)(a,e);var t=Object(l.a)(a);function a(e){var n;return Object(i.a)(this,a),(n=t.call(this,e)).m=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"userprofile.";return n.props.intl.formatMessage({id:t+e})},n.save=function(){var e=Object(r.a)(Object(s.a)().mark((function e(t){var a;return Object(s.a)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=n.props.user,n.setState({pending:!0}),e.next=4,n.context.api.q("/user/set",{username:a.raw.profile.username,password:t.password,email:t.email,name:t.name});case 4:e.sent?(p.b.success(n.m("save.success","")),n.onAfterSave()):(p.b.error(n.m("save.fail","")),n.setState({pending:!1}));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n.changePassword=function(){var e=Object(r.a)(Object(s.a)().mark((function e(t){return Object(s.a)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.setState({pending:!0}),e.next=3,n.context.api.q("/user/password",{oldpass:t.oldpass,newpass:t.newpass});case 3:e.sent?(p.b.success(n.m("save.success","")),n.onAfterSave()):(p.b.error(n.m("save.fail","")),n.setState({pending:!1}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n.prepareAvatar=Object(r.a)(Object(s.a)().mark((function e(){var t,a,r;return Object(s.a)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.state.fileInputRef.current){e.next=19;break}if(!n.state.fileInputRef.current.files[0]){e.next=16;break}if(n.setState({pending:!0}),t=n.state.fileInputRef.current.files[0],!((a=window.appConfig.maxFileSize)&&t.size>a)){e.next=9;break}return p.b.error("".concat(n.m("file.size.exceed",""),": ").concat(Math.round(a/1024)," ").concat(n.m("kb",""))),n.setState({pending:!1}),e.abrupt("return");case 9:return e.next=11,Object(q.a)(t);case 11:r=e.sent,N(r.readerResult,{maxWidth:200,maxHeight:200}).then((function(e){e?n.saveAvatar(e):(p.b.error(n.m("file.read.failed","")),n.setState({pending:!1}))})),e.next=17;break;case 16:n.modalHide();case 17:e.next=20;break;case 19:n.modalHide();case 20:case"end":return e.stop()}}),e)}))),n.saveAvatar=function(){var e=Object(r.a)(Object(s.a)().mark((function e(t){return Object(s.a)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.setState({pending:!0}),e.next=3,n.context.api.q("/user/profile/set",{picture:t});case 3:e.sent?(p.b.success(n.m("save.success","")),n.onAfterSave()):(p.b.error(n.m("save.fail","")),n.setState({pending:!1}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n.modalShow=function(){n.setState({modalShow:!0})},n.modalHide=function(){n.setState({modalShow:!1})},n.onAfterSave=function(){document.location.reload()},n.state={pending:!1,moodalShow:!1,fileInputRef:u.a.createRef()},n}return Object(c.a)(a,[{key:"render",value:function(){var e=this,t=this.props.user,a=this.state,s=a.pending,r=a.modalShow,i=a.fileInputRef,c={labelCol:{span:8},wrapperCol:{span:16}};return Object(P.jsxs)("div",{children:[Object(P.jsx)(j.a,{children:Object(P.jsx)("title",{children:this.m("profile")})}),Object(P.jsx)(b.a,{title:this.m("avatar.change"),visible:r,onOk:this.prepareAvatar,onCancel:this.modalHide,footer:[Object(P.jsx)(x.a,{onClick:this.modalHide,children:this.m("cancell","")},"cancell"),Object(P.jsx)(x.a,{onClick:function(){return e.saveAvatar("")},children:this.m("avatar.remove")},"remove"),Object(P.jsx)(x.a,{type:"primary",loading:s,onClick:this.prepareAvatar,children:this.m("save","")},"submit")],children:Object(P.jsx)(f.a,{spinning:s,children:Object(P.jsx)("input",{ref:i,type:"file",className:"form-control"})})}),Object(P.jsx)("h2",{className:"title gx-mb-4",children:this.m("profile")}),Object(P.jsx)(O.a,{children:Object(P.jsxs)(A.a,{between:!0,className:"flex-reset-lg",children:[Object(P.jsxs)(A.a,{wrap:!0,children:[Object(P.jsx)("div",{className:"gx-pointer",onClick:this.modalShow,children:t.show.picture?Object(P.jsx)(g.a,{size:64,src:t.show.picture,style:{marginRight:"15px"}}):Object(P.jsx)(g.a,{size:64,style:{marginRight:"15px"},children:t.show.literal})}),Object(P.jsxs)("div",{children:[Object(P.jsx)("h5",{children:t.show.hello}),Object(P.jsxs)(v.b,{children:[Object(P.jsx)(w.a,{style:{backgroundColor:"#52c41a"},count:this.m("active")}),t.isAdmin&&Object(P.jsx)(w.a,{style:{backgroundColor:"#038FDE"},count:this.m("admin")}),t.isGuest&&Object(P.jsx)(w.a,{style:{backgroundColor:"#a0d911"},count:this.m("guest")})]})]})]}),Object(P.jsxs)("div",{className:"gx-text-right",children:[Object(P.jsxs)("div",{children:[this.m("connection"),":"]}),Object(P.jsxs)("div",{className:"gx-text-muted gx-font-weight-light gx-mt-1 break-all",children:[t.connectionLink,Object(P.jsx)("span",{className:"gx-ml-2 gx-link",onClick:function(){navigator.clipboard.writeText(t.connectionLink),p.b.success(e.m("copied"))},children:Object(P.jsx)(H.a,{})})]}),Object(P.jsx)("div",{children:Object(P.jsx)("small",{children:this.m("connectionHint")})})]})]})}),Object(P.jsx)(O.a,{children:Object(P.jsx)(f.a,{spinning:s,children:Object(P.jsxs)(k.a,Object(n.a)(Object(n.a)({name:"basic",onFinish:this.save,className:"gx-signin-form gx-form-row0",autoComplete:"off"},c),{},{children:[Object(P.jsx)(k.a.Item,{rules:[{required:!0,type:"email",message:this.m("email.invalid")}],name:"email",label:this.m("email"),initialValue:t.raw.profile.email,children:Object(P.jsx)(y.a,{placeholder:this.m("email")})}),Object(P.jsx)(k.a.Item,{rules:[{required:!0,message:this.m("name.invalid")}],name:"name",label:this.m("name"),initialValue:t.raw.profile.name,children:Object(P.jsx)(y.a,{placeholder:this.m("name")})}),Object(P.jsxs)(S.a,{children:[Object(P.jsx)(C.a,{span:8}),Object(P.jsx)(C.a,{span:16,children:Object(P.jsx)(x.a,{type:"primary",htmlType:"submit",loading:s,children:this.m("save","")})})]})]}))})}),Object(P.jsxs)("h2",{className:"gx-mb-4",children:[this.m("passchange")," "]}),Object(P.jsx)(O.a,{children:Object(P.jsx)(f.a,{spinning:s,children:Object(P.jsxs)(k.a,Object(n.a)(Object(n.a)({name:"basic",onFinish:this.changePassword,className:"gx-signin-form gx-form-row0",autoComplete:"off"},c),{},{children:[Object(P.jsx)(k.a.Item,{rules:[{required:!0}],label:this.m("oldpass"),name:"oldpass",children:Object(P.jsx)(y.a.Password,{})}),Object(P.jsx)(k.a.Item,{rules:[{required:!0}],label:this.m("newpass"),name:"newpass",children:Object(P.jsx)(y.a.Password,{})}),Object(P.jsxs)(S.a,{children:[Object(P.jsx)(C.a,{span:8}),Object(P.jsx)(C.a,{span:16,children:Object(P.jsx)(x.a,{type:"primary",htmlType:"submit",loading:s,children:this.m("change","")})})]})]}))})})]})}}]),a}(u.a.Component);z.contextType=m.a;t.default=Object(R.c)((function(e){return{user:e.user}}),null)(Object(h.c)(z))},889:function(e,t,a){"use strict";function n(e){return new Promise((function(t,a){var n=new FileReader;n.readAsDataURL(e),n.onload=function(){var e=n.result,a=e.toString(),s=/^data:(.*,)?/,r=a.match(s)[0],i=a.replace(s,"");i.length%4>0&&(i+="=".repeat(4-i.length%4)),t({encoded:i,type:r,readerResult:e})},n.onerror=function(e){return a(e)}}))}a.d(t,"a",(function(){return n}))}}]);
//# sourceMappingURL=40.d88570c6.chunk.js.map