DatabaseProject/bin/main/public/static/js/main.4ee489f9.chunk.js
2024-04-15 18:28:13 +02:00

2 lines
No EOL
9.5 KiB
JavaScript

(this.webpackJsonpfrontend=this.webpackJsonpfrontend||[]).push([[0],{70:function(e,t,a){e.exports=a(97)},75:function(e,t,a){},93:function(e,t,a){},97:function(e,t,a){"use strict";a.r(t);var n=a(0),o=a.n(n),l=a(8),r=a.n(l),c=(a(75),a(149)),s=a(148),i=a(44),u=a(61),m=Object(u.a)({palette:{primary:{main:"#556cd6"},secondary:{main:"#19857b"},error:{main:i.a.A400},background:{default:"#fff"}}}),p=a(15),d=a(12),h=a(19),f=a(20),k=a(24),b=a(16),g=a.n(b),E=a(4),v=a(135),S=a(63),y=(a(93),a(11)),C=a(150),j=a(151),O=a(138),P=function(e){function t(){var e,a;Object(p.a)(this,t);for(var n=arguments.length,o=new Array(n),l=0;l<n;l++)o[l]=arguments[l];return(a=Object(h.a)(this,(e=Object(f.a)(t)).call.apply(e,[this].concat(o)))).state={cookie:""},a.handleInputChange=function(e){a.setState(Object(y.a)({},e.target.name,e.target.value))},a.handleSubmit=function(e){if(e.preventDefault(),a.isFormValid()){var t=a.state.cookie,n={cookie:t};g.a.post("pallets",null,{params:n}).then((function(e){if(console.log(e),e.data.id){var n="A pallet of "+t+" was produced with id "+e.data.id;a.props.setStatus(n)}else alert("An error occured: "+e.data.status+". See console for more info.");a.props.refresh()})).catch((function(e){alert("An error occured. See console for more info."),console.log(e)})),a.setState({cookie:""})}},a.isFormValid=function(){return a.state.cookie.length>0},a}return Object(k.a)(t,e),Object(d.a)(t,[{key:"render",value:function(){return o.a.createElement(v.a,{className:this.props.classes.PalletProductionPaper},o.a.createElement(S.a,{color:"textSecondary",variant:"button",gutterBottom:!0},"Production"),o.a.createElement("form",null,o.a.createElement(O.a,{container:!0,direction:"row",justify:"flex-start",alignItems:"flex-end"},o.a.createElement(C.a,{style:{minWidth:"140px"},id:"cookie",select:!0,label:"Select Cookie",value:this.state.cookie,onChange:this.handleInputChange,name:"cookie",SelectProps:{native:!0}},o.a.createElement("option",{value:""}),this.props.cookies.map((function(e){return o.a.createElement("option",{key:e.name,value:e.name},e.name)}))),o.a.createElement(j.a,{style:{marginLeft:"10px"},variant:"contained",onClick:this.handleSubmit,disabled:!this.isFormValid()},"Produce pallet!"))))}}]),t}(n.Component),x=Object(E.a)((function(e){return{PalletProductionPaper:{padding:"10px",marginBottom:"15px"}}}))(P),w=function(e){function t(){var e,a;Object(p.a)(this,t);for(var n=arguments.length,o=new Array(n),l=0;l<n;l++)o[l]=arguments[l];return(a=Object(h.a)(this,(e=Object(f.a)(t)).call.apply(e,[this].concat(o)))).state={cookie:"",from:"",to:"",blocked:""},a.handleInputChange=function(e){a.setState(Object(y.a)({},e.target.name,e.target.value))},a.handleSubmit=function(){a.props.palletsFilter(a.state)},a.handleClear=function(){a.setState({cookie:"",from:"",to:"",blocked:""}),a.props.palletsFilter({})},a}return Object(k.a)(t,e),Object(d.a)(t,[{key:"render",value:function(){return o.a.createElement("form",{style:{paddingLeft:"10px",marginBottom:"10px",marginTop:"5px"}},o.a.createElement(O.a,{container:!0,direction:"row",justify:"flex-start",alignItems:"flex-end"},o.a.createElement(C.a,{style:{minWidth:"140px"},id:"cookie",select:!0,label:"Select Cookie",value:this.state.cookie,onChange:this.handleInputChange,name:"cookie",SelectProps:{native:!0}},o.a.createElement("option",{value:""}),this.props.cookies.map((function(e){return o.a.createElement("option",{key:e.name,value:e.name},e.name)}))),o.a.createElement(C.a,{style:{marginLeft:"10px"},id:"from",label:"From",type:"date",value:this.state.from,onChange:this.handleInputChange,name:"from",InputLabelProps:{shrink:!0}}),o.a.createElement(C.a,{style:{marginLeft:"10px"},id:"to",label:"To",type:"date",value:this.state.to,onChange:this.handleInputChange,name:"to",InputLabelProps:{shrink:!0}}),o.a.createElement(C.a,{style:{marginLeft:"10px",minWidth:"90px"},id:"blocked",select:!0,label:"Blocked?",value:this.state.blocked,onChange:this.handleInputChange,name:"blocked",SelectProps:{native:!0}},o.a.createElement("option",{value:""}),o.a.createElement("option",{value:"yes"},"Yes"),o.a.createElement("option",{value:"no"},"No")),o.a.createElement(j.a,{style:{marginLeft:"10px"},variant:"contained",onClick:this.handleSubmit},"Filter"),o.a.createElement(j.a,{style:{marginLeft:"10px"},variant:"contained",onClick:this.handleClear},"Clear")))}}]),t}(n.Component),F=a(139),A=a(143),I=a(142),D=a(140),L=a(141);var B=Object(E.a)((function(e){return{root:{width:"100%",overflowX:"auto"},table:{minWidth:400},header:{marginLeft:"10px",marginTop:"10px"}}}))((function(e){var t=e.classes;return o.a.createElement(v.a,{className:t.root},o.a.createElement(S.a,{className:t.header,color:"textSecondary",variant:"button",gutterBottom:!0},"Produced Pallets"),o.a.createElement(w,{cookies:e.cookies,palletsFilter:e.palletsFilter}),o.a.createElement(F.a,{className:t.table},o.a.createElement(D.a,null,o.a.createElement(L.a,null,o.a.createElement(I.a,null,"Name"),o.a.createElement(I.a,null,"Production date"),o.a.createElement(I.a,null,"Customer"),o.a.createElement(I.a,null,"Blocked"))),o.a.createElement(A.a,null,e.pallets.map((function(e){var t=e.customer&&"null"!==e.customer?e.customer:"";return o.a.createElement(L.a,{key:e.id},o.a.createElement(I.a,{component:"th",scope:"row"},e.cookie),o.a.createElement(I.a,null,e.production_date),o.a.createElement(I.a,null,t),o.a.createElement(I.a,null,e.blocked))})))))})),N=a(153),R=a(147),T=a(145),W=a(146),V=a(144),q=function(e){function t(){var e,a;Object(p.a)(this,t);for(var n=arguments.length,o=new Array(n),l=0;l<n;l++)o[l]=arguments[l];return(a=Object(h.a)(this,(e=Object(f.a)(t)).call.apply(e,[this].concat(o)))).state={open:!1},a.openDialog=function(){a.setState({open:!0})},a.closeDialog=function(){a.setState({open:!1})},a.resetDatabase=function(){a.closeDialog(),g.a.post("reset",{}).then((function(e){console.log(e),a.props.refresh(),a.props.setStatus("The database was restored")})).catch((function(e){alert("An error occured. See console."),console.log(e)}))},a}return Object(k.a)(t,e),Object(d.a)(t,[{key:"render",value:function(){return o.a.createElement("p",null,o.a.createElement(j.a,{variant:"contained",onClick:this.openDialog},"Reset database"),o.a.createElement(N.a,{open:this.state.open,onClose:this.closeDialog,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description"},o.a.createElement(V.a,{id:"alert-dialog-title"},"Reset database?"),o.a.createElement(T.a,null,o.a.createElement(W.a,{id:"alert-dialog-description"},"Do you want do reset the database?")),o.a.createElement(R.a,null,o.a.createElement(j.a,{onClick:this.resetDatabase,color:"primary"},"Yes"),o.a.createElement(j.a,{onClick:this.closeDialog,color:"primary",autoFocus:!0},"No"))))}}]),t}(n.Component),J=function(e){function t(){var e,a;Object(p.a)(this,t);for(var n=arguments.length,l=new Array(n),r=0;r<n;r++)l[r]=arguments[r];return(a=Object(h.a)(this,(e=Object(f.a)(t)).call.apply(e,[this].concat(l)))).state={cookies:[],pallets:[],palletsFilter:{},disconnected:!1,cookieStatus:"",palletStatus:""},a.refresh=function(){a.fetchCookies(),a.fetchPallets(a.state.palletsFilter)},a.fetchCookies=function(){g.a.get("cookies").then((function(e){e.data&&e.data.cookies?a.setState({cookies:e.data.cookies,cookieStatus:e.data.cookies&&0!==e.data.cookies.length?"":"Cookie request success, but no cookies returned from API"}):a.setState({cookieStatus:"Couldn't fetch cookies from REST server"})})).catch((function(e){console.log(e),a.setState({disconnected:!0})}))},a.fetchPallets=function(e){var t={};Object.keys(e).filter((function(t){return e[t].length>0})).forEach((function(a){return t[a]=e[a]})),g.a.get("pallets",{params:t}).then((function(e){console.log(e),e.data&&e.data.pallets?a.setState({pallets:e.data.pallets,palletStatus:e.data.pallets&&0!==e.data.pallets.length?"":"Pallet request success, but no pallets returned from API."}):a.setState({palletStatus:"Couldn't fetch pallets from REST server"})})).catch((function(e){console.log(e),a.setState({disconnected:!0})}))},a.setStatus=function(e){a.setState({status:e})},a.setPalletsFilter=function(e){a.setState({palletsFilter:e}),a.fetchPallets(e)},a.mainArea=function(){return o.a.createElement("div",null,o.a.createElement(x,{cookies:a.state.cookies,refresh:a.refresh,setStatus:a.setStatus}),o.a.createElement(B,{cookies:a.state.cookies,pallets:a.state.pallets,palletsFilter:a.setPalletsFilter}),o.a.createElement(q,{refresh:a.refresh,setStatus:a.setStatus}))},a}return Object(k.a)(t,e),Object(d.a)(t,[{key:"componentDidMount",value:function(){this.refresh()}},{key:"render",value:function(){var e=[this.state.cookieStatus,this.state.palletStatus].join(" - ");this.state.disconnected&&(e=o.a.createElement("b",null,"Disconnected. Couldn't connect to REST server (",g.a.defaults.baseURL,")"));var t=null;return this.state.disconnected||(t=this.mainArea()),o.a.createElement("div",{className:"App"},o.a.createElement(S.a,{variant:"h3",gutterBottom:!0},"Krusty"),o.a.createElement(v.a,{className:this.props.classes.StatusPaper},o.a.createElement("div",null,o.a.createElement("b",null,"Status:")," ",e)),t)}}]),t}(n.Component),U=Object(E.a)((function(e){return{StatusPaper:{padding:"10px",marginBottom:"15px"}}}))(J);Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));g.a.defaults.baseURL="/api/v1",r.a.render(o.a.createElement(s.a,{theme:m},o.a.createElement(c.a,null),o.a.createElement(U,null)),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()})).catch((function(e){console.error(e.message)}))}},[[70,1,2]]]);
//# sourceMappingURL=main.4ee489f9.chunk.js.map