File: /home/imensosw/orgchart.imenso.co/build/static/js/main.2180b1b5.chunk.js
(this.webpackJsonporgchart=this.webpackJsonporgchart||[]).push([[0],{105:function(e,t,a){},109:function(e,t,a){"use strict";a.r(t);var n=a(3),s=a.n(n),i=a(14),c=a.n(i),l=(a(68),a(12)),r=a(6),o=(a(34),a(20)),d=a(16),h=a(19),j=a(2);function u(e){var t,a=Object(r.g)(),s=Object(n.useState)({email:"",password:""}),i=Object(h.a)(s,2),c=i[0],l=i[1];Object(n.useEffect)((function(){localStorage.getItem("token")&&a.push("/charts")}),[]);return Object(j.jsx)(j.Fragment,{children:Object(j.jsx)("div",{className:"App-header",children:Object(j.jsx)("div",{style:{width:"400px"},children:Object(j.jsxs)("form",{onSubmit:function(e){e.preventDefault(),fetch("http://chartapi.imenso.co/api/login",{method:"POST",body:JSON.stringify({email:c.email,password:c.password}),headers:{Accept:"application/json","Content-Type":"application/json"}}).then((function(e){return e.json()})).then((function(e){"success"===e.status?(localStorage.setItem("token",e.token),a.push("/charts")):alert("Invalid username / Password")}))},style:{backgroundColor:"teal",padding:"50px",borderRadius:"25px"},children:[Object(j.jsx)("h3",{style:(t={fontFamily:"sans-serif",textAlign:"center"},Object(d.a)(t,"fontFamily","sans-serif"),Object(d.a)(t,"fontWeight","200"),Object(d.a)(t,"fontSize","25px"),t),class:"mb-4",children:"LOGIN"}),Object(j.jsxs)("div",{children:[Object(j.jsx)("label",{for:"exampleInputEmail1",className:"form-label",children:"Email address"}),Object(j.jsx)("input",{type:"email",className:"form-control",id:"exampleInputEmail1",placeholder:"Email Address","aria-describedby":"emailHelp",value:c.email,onChange:function(e){return l(Object(o.a)(Object(o.a)({},c),{},{email:e.target.value}))}}),Object(j.jsx)("div",{id:"emailHelp",className:"form-text"})]}),Object(j.jsxs)("div",{children:[Object(j.jsx)("label",{for:"exampleInputPassword1",className:"form-label",children:" Password"}),Object(j.jsx)("input",{type:"password",className:"form-control",id:"exampleInputPassword1",placeholder:"Password",value:c.password,onChange:function(e){return l(Object(o.a)(Object(o.a)({},c),{},{password:e.target.value}))}})]}),Object(j.jsx)("div",{style:{textAlign:"center"},className:"mt-4",children:Object(j.jsx)("button",{type:"submit",className:"btn btn-light w-100",disabled:!(c.email.length>0&&c.password.length>0),children:" Login"})})]})})})})}var b=a(18),m=a.n(b),p=a(50),f=a(24),O=a(25),x=a(15),v=a(28),g=a(27),N=a.p+"static/media/logo-adib.7d4ea3cd.png",y=a(51),k=a.n(y),S=(a(44),a(45),a(52)),C=a(53),D=a(54),w=(a(91),a(0)),I=a(33);var F=function(){var e=Object(r.g)(),t=Object(n.useState)(!1),a=Object(h.a)(t,2),s=a[0],i=a[1],c=Object(n.useState)(localStorage.getItem("token")),o=Object(h.a)(c,2),d=(o[0],o[1]),u=function(){return i(!s)};return Object(j.jsx)(j.Fragment,{children:Object(j.jsxs)(w.b.Provider,{value:{color:"#fff"},children:[Object(j.jsx)("button",{type:"button",class:"btn",children:Object(j.jsx)(l.b,{to:"#",className:"menu-bars",children:Object(j.jsx)(S.a,{color:"black",onClick:u})})}),Object(j.jsx)("nav",{className:s?"nav-menu active":"nav-menu",children:Object(j.jsxs)("ul",{className:"nav-menu-items",onClick:u,children:[Object(j.jsx)("li",{className:"navbar-toggle",children:Object(j.jsx)(l.b,{to:"#",on:!0,className:"menu-bars_close",children:Object(j.jsx)(C.a,{col:!0})})}),Object(j.jsx)("li",{className:"nav-text",children:Object(j.jsxs)(l.b,{to:"/",children:[Object(j.jsx)(I.a,{style:{marginRight:"5px"}}),"Home"]})}),Object(j.jsx)("li",{className:"nav-text",children:Object(j.jsxs)(l.b,{to:"/dashboard",children:[Object(j.jsx)(D.a,{style:{marginRight:"5px"}}),"DashBoard"]})}),Object(j.jsx)("li",{className:"nav-text",children:Object(j.jsxs)(l.b,{onClick:function(){localStorage.removeItem("token"),d(""),e.push("/")},children:[Object(j.jsx)(I.b,{style:{marginRight:"5px"}})," Logout"]})})]})})]})})},L=a(113),P=a(114),_=function(e){Object(v.a)(a,e);var t=Object(g.a)(a);function a(){var e;return Object(f.a)(this,a),(e=t.call(this)).state={error:"",fileupload:"",isLoading:!1,uploadPercentage:0,selectedFile:"",token:localStorage.getItem("token"),data:[],message:"",value:""},e.handleInputChange=e.handleInputChange.bind(Object(x.a)(e)),e}return Object(O.a)(a,[{key:"handleInputChange",value:function(e){this.upload(),this.setState({selectedFile:e.target.files[0],value:e.target.value,message:""})}},{key:"componentDidMount",value:function(){this.fetchtask()}},{key:"upload",value:function(){this.state.selectedFile?(this.submit(),this.setState({message:this.state.message})):this.setState({message:"Please Select File"})}},{key:"submit",value:function(){var e=this,t=new FormData;t.append("file",this.state.selectedFile),console.warn(this.state.selectedFile);var a={onUploadProgress:function(t){var a=t.loaded,n=t.total,s=Math.floor(100*a/n);console.log("".concat(a,"kb of ").concat(n,"kb | ").concat(s,"%")),s<100&&(e.setState({uploadPercentage:s}),e.fetchtask())}};k.a.post("http://chartapi.imenso.co/api/upload",t,a,{}).then((function(t){console.log(t),e.setState({selectedFile:t.data.url,uploadPercentage:100,message:t.data.message},(function(){setTimeout((function(){e.setState({uploadPercentage:0,selectedFile:""}),e.fetchtask(),e.handleClear()}),1e3)}))}))}},{key:"fetchtask",value:function(){var e=Object(p.a)(m.a.mark((function e(){var t,a;return m.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"http://chartapi.imenso.co/api/getData",e.next=3,fetch("http://chartapi.imenso.co/api/getData");case 3:return t=e.sent,e.next=6,t.json();case 6:a=e.sent,this.setState({data:a});case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"handleClear",value:function(){this.setState({selectedFile:"",fileInputKey:Date.now(),message:this.state.message})}},{key:"render",value:function(){var e=this;if(!this.state.token)return Object(j.jsx)(r.a,{to:"/"});var t=this.state.uploadPercentage;return Object(j.jsxs)(s.a.Fragment,{children:[Object(j.jsx)("section",{className:"main bg-light",children:Object(j.jsx)("div",{children:Object(j.jsx)("div",{className:"",children:Object(j.jsx)("div",{className:"container-fluid",children:Object(j.jsx)("div",{className:"d-flex justify-content-between align-items-center",children:Object(j.jsxs)("div",{className:"d-flex align-items-center",children:[Object(j.jsx)(F,{}),Object(j.jsx)("div",{className:"brand-logo mr-3",children:Object(j.jsx)("img",{src:N,alt:"logo"})}),Object(j.jsx)("h1",{className:"mb-0 border-left pl-3",children:"Organisation Chart "})]})})})})})}),Object(j.jsxs)("div",{className:"container mt-4",children:[Object(j.jsx)("div",{className:"col-12 w-4 alert alert-secondary justify-content-between",children:Object(j.jsxs)("div",{className:"custom-file justify-content-center",style:{width:"400px"},children:[Object(j.jsxs)("div",{className:"d-flex justify-content-center",children:[Object(j.jsx)("input",{type:"file",className:"form-control profile-pic-uploader",style:{minWidth:"230px"},onChange:this.handleInputChange},this.state.fileInputKey),Object(j.jsx)(L.a,{size:"sm",style:{height:"38px",marginLeft:"50px"},variant:"info",onClick:function(){return e.upload()},children:" Upload! "})]}),Object(j.jsx)("div",{style:{color:"red"},children:this.state.message}),Object(j.jsx)("div",{style:{marginTop:"10px"},children:t>0&&Object(j.jsx)(P.a,{now:t,active:!0,label:"".concat(t,"%")})})]})}),Object(j.jsx)("div",{className:"col-12 mt-5",onChange:function(){return e.handleTable()},children:Object(j.jsxs)("table",{className:"table table-striped",children:[Object(j.jsx)("thead",{className:!0,children:Object(j.jsxs)("tr",{children:[Object(j.jsx)("th",{children:"Id"}),Object(j.jsx)("th",{children:"Date"}),Object(j.jsx)("th",{children:"FileName"})]})}),Object(j.jsx)("tbody",{children:this.state.data.map((function(e,t){return Object(j.jsxs)("tr",{children:[Object(j.jsx)("td",{children:t+1}),Object(j.jsx)("td",{children:e.file_name}),Object(j.jsx)("td",{children:e.date_and_time})]},t)}))})]})})]})]})}}]),a}(s.a.Component),T=a(55),R=a.n(T),E=(a(105),function(e){var t=e.nodeData;return Object(j.jsxs)("div",{onLoad:function(){window.scrollTo(500,100)},children:[Object(j.jsx)("div",{className:"fullname",children:t.name}),Object(j.jsx)("div",{className:"position",children:t.title}),Object(j.jsx)("div",{className:"id",children:t.id})]})}),A=a(23),H=a.n(A),J=a(56),z=a.p+"static/media/pdf.34c48f5a.svg",M=(a(108),function(e){Object(v.a)(a,e);var t=Object(g.a)(a);function a(){var e;Object(f.a)(this,a),(e=t.call(this)).printDocument=function(){e.handleLoading(),H()(e.inputRef.current).then((function(e){var t=e.toDataURL("image/.png"),a=new J.a("l","mm","a0"),n=a.getImageProperties(t),s=a.internal.pageSize.getWidth(),i=n.height*s/n.width;a.addImage(t,"JPEG",0,0,s,i),a.save("OrgChart.pdf")}))},e.handleLoading=e.handleLoading.bind(Object(x.a)(e)),e.pdfExportComponent=s.a.createRef(null);return e.inputRef=s.a.createRef(),e.state={tasks:[],level:"N1",group:"",sub_division:"",token:localStorage.getItem("token"),isLoading:!1,department:"",Dept:[]},e}return Object(O.a)(a,[{key:"componentDidMount",value:function(){this.fetchtask()}},{key:"fetchtask",value:function(){var e=this;fetch("http://chartapi.imenso.co/api/getTreeData",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({level:this.state.level,department:this.state.department,sub_division:this.state.sub_division,group:this.state.group})}).then((function(e){return e.json()})).then((function(t){console.log(t),e.setState({tasks:t.data,department:""}),console.log(e.state.tasks)})).catch((function(e){}))}},{key:"fetchDepartment",value:function(){var e=this;fetch("http://chartapi.imenso.co/api/getDepartment",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({sub_division:this.state.sub_division})}).then((function(e){return e.json()})).then((function(t){e.setState({Dept:t.department,department:""}),console.log(e.state.department)})).catch((function(e){}))}},{key:"handleLevel",value:function(e){var t=this;this.setState({level:e},(function(){t.fetchtask()}))}},{key:"handleGroup",value:function(e){var t=this;this.setState({group:e},(function(){t.fetchtask()}))}},{key:"HandleSubDivision",value:function(e){var t=this;this.setState({sub_division:e},(function(){t.fetchtask(),t.fetchDepartment()}))}},{key:"HandleDepartment",value:function(e){var t=this;this.setState({department:e},(function(){t.fetchtask()}))}},{key:"handleLoading",value:function(e){var t=this;this.setState({isLoading:!0},(function(){setTimeout((function(){t.setState({isLoading:!1})}),2e3)}))}},{key:"render",value:function(){var e=this;return this.state.token?Object(j.jsx)(s.a.Fragment,{children:Object(j.jsxs)("section",{className:"main bg-light",children:[Object(j.jsx)("div",{className:"action-btn ",children:Object(j.jsxs)("div",{className:"d-flex justify-content-end ",children:[Object(j.jsx)("div",{className:"mr-4",children:Object(j.jsxs)("select",{value:this.state.level,onChange:function(t){return e.handleLevel(t.target.value)},className:"form-control",style:{cursor:"pointer"},children:[Object(j.jsx)("option",{value:"N1",children:"Select Level"}),Object(j.jsx)("option",{value:"N2",children:"n2"}),Object(j.jsx)("option",{value:"N3",children:"n3"}),Object(j.jsx)("option",{value:"N4",children:"n4"}),Object(j.jsx)("option",{value:"N5",children:"n5"})]})}),Object(j.jsx)("div",{className:"mr-4",children:Object(j.jsxs)("select",{value:this.state.sub_division,onChange:function(t){return e.HandleSubDivision(t.target.value)},className:"form-control",style:{cursor:"pointer"},children:[Object(j.jsx)("option",{value:"",children:"Sub Division"}),Object(j.jsx)("option",{value:"Sub_Division 1",children:"Sub Division 1"}),Object(j.jsx)("option",{value:"Sub_Division 2",children:"Sub Division 2"})]})}),Object(j.jsx)("div",{className:"mr-4",children:Object(j.jsx)("select",{value:this.state.department,onChange:function(t){return e.HandleDepartment(t.target.value)},className:"form-control",style:{cursor:"pointer"},children:""===this.state.sub_division?Object(j.jsx)("option",{children:"Department"}):this.state.Dept.map((function(e,t){return Object(j.jsx)("option",{children:e.department_n4},e.department_n4)}))})}),Object(j.jsx)("div",{children:Object(j.jsxs)(L.a,{disabled:this.state.isLoading,variant:"danger",id:"btn",onClick:this.state.isLoading?null:this.printDocument,children:[Object(j.jsx)("img",{src:z,className:"pdf-icon mr-2"}),this.state.isLoading?"Saving Pdf":"Export PDF"]})})]})}),Object(j.jsx)("div",{children:Object(j.jsx)("div",{className:"",children:Object(j.jsx)("div",{className:"container-fluid",children:Object(j.jsx)("div",{className:"d-flex justify-content-between align-items-center",children:Object(j.jsxs)("div",{className:"d-flex align-items-center",children:[Object(j.jsx)(F,{}),Object(j.jsx)("div",{className:"brand-logo mr-3",children:Object(j.jsx)("img",{src:N,alt:"logo"})}),Object(j.jsx)("h1",{className:"mb-0 border-left pl-3",children:"Organisation Chart "})]})})})})}),Object(j.jsx)("div",{ref:this.inputRef,children:Object(j.jsx)(R.a,{datasource:this.state.tasks,chartClass:"myChart",NodeTemplate:E,zoom:!0})})]})}):Object(j.jsx)(r.a,{to:"/"})}}]),a}(s.a.Component)),B=function(){return Object(j.jsx)(l.a,{children:Object(j.jsxs)(r.d,{children:[Object(j.jsx)(r.b,{exact:!0,path:"/",children:Object(j.jsx)(u,{})}),Object(j.jsx)(r.b,{exact:!0,path:"/charts",children:Object(j.jsx)(M,{})}),Object(j.jsx)(r.b,{exact:!0,path:"/dashboard",children:Object(j.jsx)(_,{})})]})})},G=function(e){e&&e instanceof Function&&a.e(5).then(a.bind(null,486)).then((function(t){var a=t.getCLS,n=t.getFID,s=t.getFCP,i=t.getLCP,c=t.getTTFB;a(e),n(e),s(e),i(e),c(e)}))};c.a.render(Object(j.jsx)(s.a.StrictMode,{children:Object(j.jsx)(B,{})}),document.getElementById("root")),G()},34:function(e,t,a){},44:function(e,t,a){},45:function(e,t,a){},68:function(e,t,a){},91:function(e,t,a){}},[[109,1,3]]]);
//# sourceMappingURL=main.2180b1b5.chunk.js.map