(this["webpackJsonpgonzo-test-client"]=this["webpackJsonpgonzo-test-client"]||[]).push([[115],{"+69I":function(e,t,a){"use strict";var n=a("q1tI"),s=a.n(n),i=a("/MKj"),r=a("17x9"),l=a.n(r),o=a("VyNe"),c=a("0ajJ"),u=a("9jj8"),h=a("zH/4"),d=a("IXwn"),p=a("uSQv"),m=a("55Ip"),g=a("ANjH"),f=a("f0zD"),b=a("42VQ"),y=a("gLBR"),S=a("Zayz"),v=a("AF5L"),O=a("zDJl"),w=a("dz5w"),E=a("LCzB"),D=a("XzT5");function j(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function T(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class C extends n.Component{constructor(...e){super(...e),this.onRemoveClick=()=>{const{worktype:e,t:t}=this.props;this.props.show(b.a,{title:t("newSettings.system.systemSchedule.worktypeRow.removeTitle"),text:D.a.t("newSettings.system.systemSchedule.worktypeRow.removeText",{type:e.SetData.Name}),confirmText:t("yes"),onConfirmed:t=>{let a=e.prepareBeanToSave();a.DtaDelTime=(new Date).getTime(),a.setDtaModTime(),this.props.dispatch(Object(y.c)(a)),t.handleHide()}})},this.onUpdateOnDevicesClick=()=>{const{worktype:e,gateways:t}=this.props;let a=e.getBackendObject();for(let n of t)Object(v.w)(n,a)}}render(){const{worktype:e,index:t,farm:a,t:n}=this.props;return s.a.createElement(u.a,null,s.a.createElement("span",null,s.a.createElement("h3",null,t+1)),e&&s.a.createElement(s.a.Fragment,null,s.a.createElement("span",null,s.a.createElement("div",null,s.a.createElement("strong",null,e.SetData.Name)),s.a.createElement("small",null,n("designation"))),s.a.createElement("span",null,s.a.createElement("div",null,s.a.createElement("strong",null,Object(S.e)(e.SetData.WorkTime))),s.a.createElement("small",null,n("workTime"))),s.a.createElement("span",null,s.a.createElement("div",null,s.a.createElement("strong",null,Object(S.e)(e.SetData.StopTime))),s.a.createElement("small",null,n("stopTime"))),s.a.createElement(d.a,null,s.a.createElement(m.Link,{to:"/".concat(a,"/settings/system/schedules/worktype/edit/").concat(e.SetID)},s.a.createElement(p.a,{buttonStyle:"round",icon:s.a.createElement("i",{className:"fas fa-edit"})})),s.a.createElement(p.a,{type:"button",icon:s.a.createElement("i",{className:"fas fa-share"}),buttonStyle:"round",onClick:this.onUpdateOnDevicesClick}),s.a.createElement(p.a,{buttonColor:"error",buttonStyle:"round",icon:s.a.createElement("i",{className:"fas fa-trash"}),onClick:this.onRemoveClick}))),!e&&s.a.createElement(s.a.Fragment,null,s.a.createElement("span",{className:"opacity-50",style:{flexGrow:6}},s.a.createElement("h5",{className:"justify-content-center"},n("newSettings.system.systemSchedule.worktypeRow.notConfigured"))),s.a.createElement(d.a,null,s.a.createElement(m.Link,{to:"/".concat(a,"/settings/system/schedules/worktype/add/").concat(t)},s.a.createElement(p.a,{buttonColor:"success",buttonStyle:"round",icon:s.a.createElement("i",{className:"fas fa-plus"})})))))}}C.propTypes={worktype:l.a.instanceOf(h.a),index:l.a.number.isRequired,farm:l.a.string.isRequired,gateways:l.a.arrayOf(l.a.instanceOf(w.a))},C=Object(i.connect)((function(e){return{farm:e.location.farm,gateways:e.farmDevices.devices.filter(e=>e.DevType===O.d.GATEWAY)}}),(function(e){return function(e){for(var t=1;t{const{schedule:e,t:t}=this.props;this.props.show(b.a,{title:t("newSettings.system.systemSchedule.scheduleRow.removeTitle"),text:D.a.t("newSettings.system.systemSchedule.scheduleRow.removeText",{type:e.SetData.Name}),confirmText:t("yes"),onConfirmed:t=>{let a=e.prepareBeanToSave();a.DtaDelTime=(new Date).getTime(),a.setDtaModTime(),this.props.dispatch(Object(y.c)(a)),t.handleHide()}})},this.onUpdateOnDevicesClick=()=>{const{schedule:e,gateways:t}=this.props;let a=e.getBackendObject();for(let n of t)Object(v.v)(n,a)}}render(){const{index:e,schedule:t,farm:a,t:n}=this.props;return s.a.createElement(u.a,null,s.a.createElement("span",null,s.a.createElement("h3",null,e+1)),t&&s.a.createElement(s.a.Fragment,null,s.a.createElement("span",null,s.a.createElement("div",null,s.a.createElement("strong",null,t.SetData.Name)),s.a.createElement("small",null,n("designation"))),s.a.createElement("span",null,s.a.createElement("div",null,s.a.createElement("strong",null,t.SetData.Intervals.length)),s.a.createElement("small",null,n("newSettings.system.systemSchedule.scheduleRow.numberOfIntervals"))),s.a.createElement(d.a,null,s.a.createElement(m.Link,{to:"/".concat(a,"/settings/system/schedules/edit/").concat(t.SetID)},s.a.createElement(p.a,{buttonStyle:"round",icon:s.a.createElement("i",{className:"fas fa-edit"})})),s.a.createElement(p.a,{type:"button",icon:s.a.createElement("i",{className:"fas fa-share"}),buttonStyle:"round",onClick:this.onUpdateOnDevicesClick}),s.a.createElement(p.a,{buttonColor:"error",buttonStyle:"round",icon:s.a.createElement("i",{className:"fas fa-trash"}),onClick:this.onRemoveClick}))),!t&&s.a.createElement(s.a.Fragment,null,s.a.createElement("span",{className:"opacity-50",style:{flexGrow:6}},s.a.createElement("h5",{className:"justify-content-center"},n("newSettings.system.systemSchedule.scheduleRow.notConfigured"))),s.a.createElement(d.a,null,s.a.createElement(m.Link,{to:"/".concat(a,"/settings/system/schedules/add/").concat(e)},s.a.createElement(p.a,{buttonColor:"success",buttonStyle:"round",icon:s.a.createElement("i",{className:"fas fa-plus"})})))))}}x.propTypes={index:l.a.number.isRequired,schedule:l.a.instanceOf(I.a),farm:l.a.string,gateways:l.a.arrayOf(l.a.instanceOf(w.a))},x=Object(i.connect)((function(e){return{farm:e.location.farm,gateways:e.farmDevices.devices.filter(e=>e.DevType===O.d.GATEWAY)}}),(function(e){return function(e){for(var t=1;te.SetData.Index===a);t.push(s.a.createElement(P,{index:a,worktype:n}))}return t}createScheduleList(){const{schedules:e}=this.props;let t=[];for(let a=0;a<15;a++){let n=e.find(e=>e.SetData.Index===a);t.push(s.a.createElement(R,{index:a,schedule:n}))}return t}render(){const{t:e}=this.props;return s.a.createElement("div",{className:"system-schedules"},s.a.createElement(o.a,null,s.a.createElement("h4",null,e("newSettings.system.systemSchedule.mainView.workTypes")),s.a.createElement(c.a,null,this.createWorktypesList())),s.a.createElement(o.a,null,s.a.createElement("h4",null,e("schedules")),s.a.createElement(c.a,null,this.createScheduleList())))}}A.propTypes={worktypes:l.a.arrayOf(l.a.instanceOf(h.a)).isRequired,schedules:l.a.arrayOf(l.a.instanceOf(I.a)).isRequired},A=Object(i.connect)((function(e){return{worktypes:e.settings.scheduleWorktypes,schedules:e.settings.systemSchedules}}))(A);t.a=Object(E.a)()(A)},"3NtG":function(e,t,a){"use strict";var n=a("q1tI"),s=a.n(n),i=a("3Z9Z"),r=a("JI6e"),l=a("wQmL"),o=a("d/v1"),c=a("pJVQ"),u=a("tDQA"),h=a("/MKj"),d=a("4huo"),p=a("BkRI"),m=a.n(p),g=a("ZRKa"),f=a("gLBR"),b=a("2UNB"),y=a("P0Qa");function S(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function v(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}var O=a("y4iu"),w=a("VyNe"),E=a("q17X"),D=a("qx5e"),j=a("s506"),T=a("eASP"),C=a("pxzG"),P=a("LCzB");const I="settings-system-unit-and-time";class k extends s.a.Component{constructor(e){super(e);const{dispatch:t}=this.props;t(Object(l.c)(I,{unitSystem:Object(E.getUnitSystem)(),feedingUnit:Object(E.getFeedingUnit)(),cageUnit:Object(E.getCageUnit)(),scaleUnit:Object(E.getScaleUnit)(),animalUnit:Object(E.getAnimalUnit)()}))}render(){const{handleSubmit:e,t:t,unit:a}=this.props,n=(e,t)=>[{name:Object(C.l)("weight",T.a.SMALL,{overrideUnitSystem:a}),value:T.a.SMALL},{name:Object(C.l)("weight",T.a.MEDIUM,{overrideUnitSystem:a}),value:T.a.MEDIUM},{name:Object(C.l)("weight",T.a.BIG,{overrideUnitSystem:a}),value:T.a.BIG}].slice(e,t+1),l=[{name:t("newSettings.system.unitAndTimeSystem.imperial"),value:"imperial"},{name:t("newSettings.system.unitAndTimeSystem.metric"),value:"metric"}];return s.a.createElement(w.a,{className:I},s.a.createElement(O.a,{handleSubmit:e},s.a.createElement(i.a,{className:"justify-content-center"},s.a.createElement(r.a,{lg:6},s.a.createElement(o.a,{id:"unitSystem",name:"unitSystem",component:d.b,label:t("newSettings.system.unitAndTimeSystem.unitSystem"),options:l}),s.a.createElement(o.a,{id:"animalUnit",name:"animalUnit",component:d.b,label:t("animals"),options:n(0,1)}),s.a.createElement(o.a,{id:"feedingUnit",name:"feedingUnit",component:d.b,label:t("newSettings.system.unitAndTimeSystem.feedingUnit"),options:n(0,1)}),s.a.createElement(o.a,{id:"cageUnit",name:"cageUnit",component:d.b,label:t("newSettings.system.unitAndTimeSystem.cageUnit"),options:n(0,1)}),s.a.createElement(o.a,{id:"scaleUnit",name:"scaleUnit",component:d.b,label:t("weightPanels"),options:n(1,2)})))))}}k=Object(c.a)({form:I,onSubmit:function(e,t,a){console.log(e);const{unitSystem:n,feedingUnit:s,cageUnit:i,scaleUnit:r,animalUnit:l}=e,{user:{ClientID:o}}=a;let c=g.a.getSettingByID(o),u={UnitSystem:n,FeedingUnit:s,CageUnit:i,ScaleUnit:r,AnimalUnit:l};if(c){let e=m()(c);e.SetData?e.SetData.Settings||(e.SetData=function(e){for(var t=1;t",e),t(Object(f.c)(e))}else{let e=b.a.createSetting(y.a.GENERAL,{Settings:{System:u}});console.log("create - >",e),t(Object(f.a)(e))}},validate:function(e,t){const a={},{unitSystem:n}=e;return n||(a.unitSystem=t.t("required")),a}})(k);const N=Object(u.a)(I);k=Object(h.connect)(e=>({farm:e.location.farm,user:e.user.user,unit:N(e,"unitSystem")}))(k),k=Object(P.a)()(k);t.a=Object(D.a)({roles:[j.c._BILLING],showComponent:!0})(k)},"6ndd":function(e,t,a){},HhzP:function(e,t,a){"use strict";var n=a("q1tI"),s=a.n(n),i=a("VyNe"),r=a("/MKj"),l=a("Ty5D"),o=a("qx5e"),c=a("s506"),u=a("LCzB"),h=a("kiQV"),d=a("SjWX"),p=a("uSQv"),m=a("EE6H"),g=a("Bffz"),f=a("fz41"),b=a("n1Xc"),y=a("wQVC");function S(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function v(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class O extends s.a.Component{constructor(e){super(e),this.callTestAPI=(e=0)=>{const{user:{ClientID:t}}=this.props;return Object(f.c)(function(e){for(var t=1;t{e&&this.setState({send:{loading:!0,success:void 0}});const{farm:t,user:{ClientID:a,LocalUserID:n}}=this.props,s={};s.localTime=+new Date,s.farmId=t,s.clientId=a,s.localUserId=n;try{s.browser=JSON.parse(JSON.stringify(Object(d.detect)()))}catch(r){s.browser="Error getting browser"}s.stage="local",s.appBuildTime="18.09.2020 14:44",s.appVersion=h.version;try{s.collections=m.e.listCollections()}catch(l){s.collections="List collections failed",s.collectionsError=l.message}Array.isArray(s.collections)&&s.collections.forEach(({name:e},t)=>{try{const a=m.e.getCollection(e);a?("cachedTablesParams"===e&&(s.cachedDtaModTime=JSON.parse(JSON.stringify(a.data||[]))),s.collections[t].last10Objects=JSON.parse(JSON.stringify((a.data||[]).slice(Math.max((a.data||[]).length-10,0))))):s.collections[t].last10Objects="Collection missing"}catch(l){s.collections[t].last10Objects="Error getting information",s.collections[t].last10ObjectsError=l.message}});let i=0;if(s.cachedDtaModTime)try{i=s.cachedDtaModTime.find(e=>"settings"===e.table).DtaModTime||0}catch(r){i=0}else s.cachedDtaModTime="Error getting information";s.testApiCall1={type:"SettingsWithLatestDtaModTime",dtaModTime:i},this.callTestAPI(i).then(e=>{s.testApiCall1.success=!0,s.testApiCall1.responseSize=e.length}).catch(e=>{s.testApiCall1.success=!1}).finally(()=>{s.testApiCall2={type:"SettingsWithZeroedDtaModTime",dtaModTime:0},this.callTestAPI(0).then(e=>{s.testApiCall2.success=!0,s.testApiCall2.responseSize=e.length}).catch(e=>{s.testApiCall2.success=!1}).finally(()=>{Object(b.a)(s).then(t=>{e&&this.setState({send:{loading:!1,success:!0}})}).catch(t=>{e&&this.setState({send:{loading:!1,success:!1}})})})})},this.deleteIndexedDB=async()=>{try{this.sendReport(!1)}catch(e){console.error("Error sending report")}(await indexedDB.databases()).forEach(e=>{console.log("deleting->",e.name),indexedDB.deleteDatabase(e.name)}),Object(y.m)(),location.reload(!0)},this.state={send:{loading:!1,success:void 0}}}render(){const{t:e}=this.props,{send:t}=this.state;return s.a.createElement(i.a,null,s.a.createElement("h4",null,e("newSettings.utility.deleteLocalDatabase")),s.a.createElement(p.a,{className:"mt-1",icon:s.a.createElement("i",{className:"fas fa-fw fa-trash"}),buttonColor:"error",type:"button",onClick:this.deleteIndexedDB}),s.a.createElement("h4",null,e("newSettings.utility.sendReport")),s.a.createElement(p.a,{className:"mt-1",isLoading:t.loading,icon:s.a.createElement("i",{className:"fas fa-fw ".concat(void 0===t.success?"fa-paper-plane":t.success?"fa-check":"fa-exclamation")}),type:"button",onClick:this.sendReport}))}}O=Object(r.connect)(e=>({farm:e.location.farm,user:e.user.user}))(O);let w=Object(l.o)(O);w=Object(o.a)({roles:[c.c._GENERAL_READ],showComponent:!0})(w),t.a=Object(u.a)()(w)},JvrF:function(e,t,a){"use strict";var n=a("q1tI"),s=a.n(n),i=a("IXwn"),r=a("uSQv"),l=a("VyNe"),o=a("AAik"),c=a("/MKj"),u=a("zDJl"),h=a("VfnB"),d=a("55Ip"),p=a("Ty5D"),m=a("qx5e"),g=a("s506"),f=a("BvFm"),b=a("LCzB"),y=a("yjtO");class S extends s.a.Component{constructor(e){super(e),this.onSelectionChange=e=>{this.setState({selectedSiloses:e})},this.state={selectedSiloses:[]}}render(){const{siloses:e,t:t,farm:a}=this.props,n=Object(h.t)(t),{selectedSiloses:c}=this.state;return Object(f.a)()?s.a.createElement(l.a,null,s.a.createElement(o.a,{data:e,headers:n,shouldIndex:!0,mobileRow:s.a.createElement(y.a,null),selectableRow:!0,singleRowSelect:!0,onSelectedRowsChanged:this.onSelectionChange}),s.a.createElement(i.a,{fixed:!0,renderInPortal:!1},s.a.createElement(d.Link,{to:{pathname:"/".concat(a,"/settings/weightPanels/manage/configuration"),state:{selectedSiloses:c}},disabled:0===c.length},s.a.createElement(r.a,{buttonColor:"success",buttonStyle:"round",icon:s.a.createElement("i",{className:"fas fa-arrow-right"}),disabled:0===c.length})))):null}}S=Object(c.connect)(e=>({siloses:e.farmDevices.devices.filter(e=>e.DevType===u.d.SCALE),farm:e.location.farm}))(S);let v=Object(p.o)(S);v=Object(m.a)({roles:[g.c._DEVICE_CONFIG],showComponent:!0})(v),t.a=Object(b.a)()(v)},V9Uu:function(e,t,a){"use strict";var n=a("q1tI"),s=a.n(n),i=a("/MKj"),r=a("VyNe"),l=a("HIda"),o=a("d/v1"),c=a("pJVQ"),u=a("26mJ"),h=a("3Z9Z"),d=a("JI6e"),p=a("XoCd"),m=a("zH/4"),g=a("gLBR");var f=a("IXwn"),b=a("uSQv"),y=a("Zayz"),S=a("LCzB");class v extends n.Component{constructor(e){super(e);const{match:{params:{index:t,SetID:a}},worktypes:n}=this.props;if(a){let e=n.find(e=>e.SetID===a);this.props.initialize(e)}else this.props.initialize({SetData:{Index:+t,WorkTime:1e3,StopTime:1e3}})}render(){const{handleSubmit:e,t:t}=this.props;return s.a.createElement(r.a,null,s.a.createElement("form",{onSubmit:e},s.a.createElement(l.a,{name:"SetData"},s.a.createElement(o.a,{name:"Name",component:u.a,label:t("designation"),type:"text"}),s.a.createElement(h.a,null,s.a.createElement(d.a,{md:6},s.a.createElement(o.a,{name:"WorkTime",component:p.a,label:t("workTime"),min:1e3,max:6e5,step:1e3,valueFormatter:y.e})),s.a.createElement(d.a,{md:6},s.a.createElement(o.a,{name:"StopTime",component:p.a,label:t("stopTime"),min:1e3,max:6e5,step:1e3,valueFormatter:y.e})))),s.a.createElement(f.a,{fixed:!0,renderInPortal:!1},s.a.createElement(b.a,{buttonStyle:"round",buttonColor:"success",icon:s.a.createElement("i",{className:"fas fa-save"})}))))}}v=Object(c.a)({form:"addOrEditWorktypeSystemSchedule",onSubmit:function(e,t,a){if(void 0===a.match.params.index){let a=new m.a(e).prepareBeanToSave();a.setDtaModTime(),t(Object(g.c)(a))}else{const{SetData:{Name:a,WorkTime:n,StopTime:s,Index:i}}=e;let r=m.a.createSystemScheduleWorktype(a,n,s,i);t(Object(g.a)(r))}const{farm:n}=a;a.history.push("/".concat(n,"/settings/system/schedules"))},validate:function(e,t){const a={SetData:{}},{t:n}=t;return e.SetData?e.SetData.Name||(a.SetData.Name=n("required")):a.SetData={Name:n("required")},a}})(v),v=Object(i.connect)((function(e){return{worktypes:e.settings.scheduleWorktypes,farm:e.location.farm}}))(v);t.a=Object(S.a)()(v)},ZIzh:function(e,t,a){},a63n:function(e,t,a){"use strict";var n=a("q1tI"),s=a.n(n),i=a("/MKj"),r=a("17x9"),l=a.n(r),o=a("VyNe"),c=a("d/v1"),u=a("HIda"),h=a("3t43"),d=a("Yw+G"),p=a("pJVQ"),m=a("26mJ"),g=a("uSQv"),f=a("3Z9Z"),b=a("JI6e"),y=a("wd/R"),S=a.n(y),v=a("4huo"),O=a("Zayz"),w=a("gLBR"),E=a("ehys");var D=a("IXwn"),j=a("zH/4"),T=a("LCzB"),C=a("XzT5");function P(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function I(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class k extends n.Component{constructor(e){super(e),this.formatTime=e=>e?S.a.utc(e).format("HH:mm"):null,this.parseTime=e=>{if(!e)return null;let t=S.a.utc(0),a=e.split(":");return t.hour(+a[0]).minutes(+a[1]),t.toDate().getTime()},this.renderIntervals=({fields:e})=>s.a.createElement(s.a.Fragment,null,e.map((t,a)=>s.a.createElement(o.a,null,s.a.createElement("h5",{className:"flex-lg-row justify-content-between align-content-center"},C.a.t("newSettings.system.systemSchedule.addSystemSchedule.interval",{type:a+1}),s.a.createElement(g.a,{onClick:()=>e.remove(a),type:"button",buttonStyle:"round",className:"text",icon:s.a.createElement("i",{className:"fas fa-trash"}),disabled:1===e.length})),s.a.createElement(f.a,null,s.a.createElement(b.a,{xs:4},s.a.createElement(c.a,{name:"".concat(t,".StartTime"),id:"".concat(t,".StartTime"),label:this.props.t("newSettings.system.systemSchedule.addSystemSchedule.startTime"),type:"time",format:this.formatTime,parse:this.parseTime,component:m.a})),s.a.createElement(b.a,{xs:4},s.a.createElement(c.a,{name:"".concat(t,".StopTime"),id:"".concat(t,".StopTime"),label:this.props.t("newSettings.system.systemSchedule.addSystemSchedule.stopTime"),type:"time",format:this.formatTime,parse:this.parseTime,component:m.a})),s.a.createElement(b.a,{xs:4},s.a.createElement(c.a,{name:"".concat(t,".WorkType"),component:v.b,options:this.props.worktypes.map(e=>({name:e.getSelectName(),value:e.SetID})),label:this.props.t("worktype"),clearButton:!1}))))),e.length<=32&&s.a.createElement(o.a,null,s.a.createElement("h5",{className:"flex-lg-row justify-content-between align-content-center pointer",onClick:()=>e.push({})},this.props.t("newSettings.system.systemSchedule.addSystemSchedule.addNext")," ",s.a.createElement("i",{className:"fas fa-plus"}))));const{match:{params:{index:t,SetID:a}},schedules:n}=this.props;if(a){let e=n.find(e=>e.SetID===a);this.props.initialize(e)}else this.props.initialize({SetData:{Intervals:[{StartTime:S.a.utc(0).minutes(15).toDate().getTime(),StopTime:S.a.utc(0).hour(23).minutes(45).toDate().getTime()}],Index:+t}})}render(){const{handleSubmit:e,t:t}=this.props;return s.a.createElement("form",{onSubmit:e},s.a.createElement(u.a,{name:"SetData"},s.a.createElement(o.a,null,s.a.createElement(c.a,{name:"Name",component:m.a,label:t("designation"),type:"text"})),s.a.createElement(h.a,{name:"Intervals",component:this.renderIntervals})),s.a.createElement(D.a,{fixed:!0,renderInPortal:!1},s.a.createElement(g.a,{buttonColor:"success",buttonStyle:"round",icon:s.a.createElement("i",{className:"fas fa-save"})})))}}k.propTypes=function(e){for(var t=1;t{const s={};if(void 0===t.StartTime&&(s.StartTime=n("required")),void 0===t.StopTime&&(s.StopTime=n("required")),t.WorkType||(s.WorkType=n("required")),void 0!==t.StartTime&&void 0!==t.StopTime){let i=e.SetData.Intervals.filter((e,t)=>void 0!==e.StartTime&&void 0!==e.StopTime&&t!==a),r=!1;for(let e of i)Object(O.a)(t.StartTime,t.StopTime,e.StartTime,e.StopTime)&&(r=!0);r&&(s.StartTime=n("errors.duplicate"),s.StopTime=n("errors.duplicate")),t.StopTimethis.path.current.clientWidth}createPath(){const{path:e}=this.props;let t=d.a.createElement("div",{className:"source-data-path",ref:this.path},e);return this.isPathOverflowing()?d.a.createElement(v.a,{tooltipContent:e},t):t}render(){const{value:e,number:t,t:a}=this.props;return d.a.createElement("div",{className:"source-data"},t&&d.a.createElement("div",{className:"source-data-value"},a("newSettings.translate.source.count",{number:t})),!t&&d.a.createElement("div",{className:"source-data-value"},e),this.createPath())}}w.propTypes={path:S.a.string.isRequired,value:S.a.string.isRequired,number:S.a.number};var E=Object(O.a)()(w),D=a("2dKy");a("rSdu");class j extends h.Component{constructor(...e){super(...e),this.state={value:this.props.value,changed:!1},this.onSave=()=>{this.setState({changed:!1})},this.sendChangeToAPI=()=>{const{lang:e,path:t}=this.props,{value:a}=this.state;this.props.addToQueue({lang:e,path:t,value:a},this.onSave)},this.onChange=e=>{for(let t of this.props.inserts)e=this.addInsert(e,t);this.setState({value:e,changed:!0})}}static getDerivedStateFromProps(e,t){return t.changed||t.value===e.value?null:{value:e.value,changed:!1}}addInsert(e,t){if(!e.includes(t)){for(let a=t.length-1;a>=3;a--){let n=e.replace(t.slice(0,a),t);if(n!==e)return n}return e+t}return e}getClassName(){const{sourceValue:e}=this.props,{value:t}=this.state;let a="destination";return t===e&&(a+=" equal"),t||(a+=" empty"),a}render(){const{lang:e}=this.props,{value:t}=this.state;return d.a.createElement(D.a,{type:"textarea",value:t,className:this.getClassName(),lang:e,onChange:this.onChange,onBlur:this.sendChangeToAPI})}}j.propTypes={value:S.a.string,index:S.a.number.isRequired,lang:S.a.string.isRequired,sourceValue:S.a.string,path:S.a.string.isRequired,addToQueue:S.a.func.isRequired,inserts:S.a.arrayOf(S.a.string)};var T=j,C=a("wQVC"),P=(a("ZIzh"),a("IXwn")),I=a("uSQv"),k=a("qeiZ"),N=a("16p8"),x=a("ANjH"),R=a("f0zD"),A=a("9D2Z"),L=a("kG49"),U=a("42VQ"),B=a("Ty5D"),W=a("TbHc"),q=a("udB/"),M=a("S8cm"),F=a("bYcM"),V=a.n(F),z=a("0ygv"),Q=a.n(z),_=a("eD4C"),J=a("9xE7"),G=a("wd8a");function H(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function Z(e){for(var t=1;t{this.setState(e=>({queueLength:e.queueLength+1}))},this.decrementQueueLength=(e,t)=>{this.setState(e=>e.queueLength>2?{queueLength:e.queueLength-2}:{queueLength:0})},this.sendData=async(e,t)=>{for(let n of e)try{await this.update(n.data,n.callbacks),t(null,!0)}catch(a){t(null,!0)}},this.queue=new V.a((e,t)=>this.sendData(e,t),{store:new Q.a,id:(e,t)=>{t(null,"".concat(e.data.lang,"_").concat(e.data.path))},merge:(e,t,a)=>{e.data.hasOwnProperty("accepted")?a(null,{data:Z({},t.data,{accepted:!0}),callbacks:[...e.callbacks,...t.callbacks]}):t.data.hasOwnProperty("accepted")?a(null,{data:Z({},e.data,{accepted:!0}),callbacks:[...e.callbacks,...t.callbacks]}):a(null,Z({},t,{callbacks:[...e.callbacks,...t.callbacks]}))},batchSize:2,batchDelay:1e3,afterProcessDelay:1e3}),this.addToSaveQueue=(e,t)=>{this.queue.push({data:e,callbacks:[t]})},this.pressedShift=e=>{16===e.keyCode&&(this.shift=!0)},this.releasedShift=e=>{16===e.keyCode&&(this.shift=!1)},this.beforeUnload=e=>{this.state.queueLength>0?e.returnValue="123":(delete e.returnValue,e.preventDefault())},this.onChangeSource=e=>{let t=this.props.i18n.services.pluralResolver.getRule(e);this.setState({pluralsSource:t.numbers,source:e,sourceData:Y.getTranslation(this.props,e)}),this.props.dispatch(Object(g.e)(e))},this.onChangeDestination=e=>{let t=this.props.i18n.services.pluralResolver.getRule(e);this.setState({pluralsDestination:t.numbers,destination:e,destinationData:Y.getTranslation(this.props,e)}),this.props.dispatch(Object(g.e)(e))},this.renderRow=({key:e,style:t,index:a})=>{const{data:n}=this.state,{user:s}=this.props;let i=n[a],r=new RegExp("{\\w+}|{{\\w+}}","g"),l=i.value.match(r);return d.a.createElement("div",{key:e,style:t,className:"translate-row"},d.a.createElement("div",{className:"translate-col"},d.a.createElement(E,{path:i.path,value:i.value,number:i.number||null})),d.a.createElement("div",{className:"translate-arrow"},d.a.createElement(I.a,{buttonStyle:"round",icon:d.a.createElement("i",{className:"fas fa-arrow-right"}),onClick:()=>this.copyFromSourceToDestination(i.value,a),disabled:i.value===i.destination})),d.a.createElement("div",{className:"translate-col"},d.a.createElement(T,{lang:this.state.destination,value:i.destination,index:a,path:i.path,sourceValue:i.value,addToQueue:this.addToSaveQueue,inserts:l||[]})),d.a.createElement("div",{className:"translate-col-checkbox"},d.a.createElement(M.a,{label:"",id:e,checked:i.accepted,onChange:e=>this.onCheckboxChange(e,a)})),d.a.createElement("div",{className:"translate-col-checkbox"},i.sourcePath&&s.UserType===G.SERVICE&&d.a.createElement(I.a,{buttonStyle:"round",icon:i.loading?d.a.createElement("i",{className:"fas fa-circle-notch fa-fw fa-spin"}):d.a.createElement("i",{className:"fas fa-trash fa-fw"}),onClick:()=>this.onRemoveClick(a),disabled:i.loading})),d.a.createElement("div",{className:"index"},a+1))},this.scrollToNextEmpty=()=>{let e=this.findNextEmpty();e>=0&&this.scrollToIndex(e)},this.scrollPreviousEmpty=()=>{let e=this.findPreviousEmpty();e>=0&&this.scrollToIndex(e)},this.onRowsRendered=({startIndex:e})=>{const{disablePreviousButton:t,disableNextButton:a}=this.state;this.firstRenderedIndex=e;let n={};this.findNextEmpty()<0?n.disableNextButton=!0:a&&(n.disableNextButton=!1),this.findPreviousEmpty()<0?n.disablePreviousButton=!0:t&&(n.disablePreviousButton=!1),s()(n)||this.setState(n)},this.filterPredicate=e=>JSON.stringify(e).toLowerCase().includes(this.state.filter.toLowerCase()),this.filterBelow=()=>{const{data:e}=this.state;let t=r()(e,this.filterPredicate,0===window.scrollY?0:this.firstRenderedIndex+2);t<0&&(t=r()(e,this.filterPredicate)),this.scrollToIndex(t)},this.filterAbove=()=>{const{data:e}=this.state;let t=e.length-r()(e.slice(0).reverse(),this.filterPredicate,e.length-this.firstRenderedIndex);t>e.length&&(t=e.length-r()(e.slice(0).reverse(),this.filterPredicate)-1),this.scrollToIndex(t)},this.onSubmitFilter=e=>{this.shift?this.filterAbove():this.filterBelow(),e.preventDefault()},this.onChangeFilter=e=>{this.setState({filter:e})},this.onAddButtonClick=e=>{this.setState({event:e})},this.onAddLanguageClick=()=>{this.props.show(N.a,{languages:this.allLanguages,current:this.state.languages})},this.onAddTranslationClick=()=>{this.props.show(W.a,{locale:this.state.source})},this.showBeforeLeave=e=>{const{t:t}=this.props;return this.props.show(U.a,{title:t("newSettings.translate.edit.notSaved"),text:t("newSettings.translate.edit.notSavedText"),confirmText:t("yes"),closeText:t("cancel"),onConfirmed:t=>{this.queue.use(new Q.a),this.setState({queueLength:0},()=>{this.props.history.push(e.pathname),t.handleHide()})}}),!1},this.onHideAccepted=e=>{this.setState({hideAccepted:e})},this.onExchangeClick=()=>{this.setState(e=>({source:e.destination,destination:e.source,pluralsSource:e.pluralsDestination,pluralsDestination:e.pluralsSource}))},console.log(this.props),this.queue.on("task_queued",this.incrementQueueLength),this.queue.on("batch_finish",this.decrementQueueLength),this.queue.on("batch_failed",this.decrementQueueLength),this.queue.on("drain",()=>{this.props.dispatch(Object(g.e)([this.state.source,this.state.destination],!1))})}static getTranslation(e,t){return u()(e.translations,t,null)}static getAcceptedData(e,t){return u()(e.acceptedTranslations,t,null)}static getDerivedStateFromProps(e,t){let a=Y.getTranslation(e,t.source),n=Y.getTranslation(e,t.destination),s=Y.getAcceptedData(e,t.destination);return o()(t.sourceData,a)&&o()(t.destinationData,n)&&o()(t.acceptedData,s)?o()(t.languages,e.languages)?null:{languages:e.languages}:{sourceData:a,destinationData:n,acceptedData:s}}async componentDidMount(){for(let e of _)this.allLanguages[e.code]=e.nativeName;this.props.dispatch(Object(g.c)()),this.props.dispatch(Object(g.e)([this.state.source,this.state.destination])),document.addEventListener("keydown",this.pressedShift),document.addEventListener("keyup",this.releasedShift),window.addEventListener("beforeunload",this.beforeUnload),this.state.sourceData&&this.state.destinationData&&this.setState({data:this.createData(this.state.sourceData,this.state.destinationData,this.state.acceptedData)})}componentDidUpdate(e,t,a){o()(this.state.sourceData,t.sourceData)&&o()(this.state.destinationData,t.destinationData)&&o()(this.state.acceptedData,t.acceptedData)&&t.hideAccepted===this.state.hideAccepted||this.setState({data:this.createData(this.state.sourceData,this.state.destinationData,this.state.acceptedData)})}componentWillUnmount(){document.removeEventListener("keydown",this.pressedShift),document.removeEventListener("keyup",this.releasedShift),window.removeEventListener("beforeunload",this.beforeUnload)}update(e,t){return new Promise((a,n)=>{let s=r()(this.state.data,t=>"".concat(t.path)===e.path);Object(k.c)([e]).then(n=>{let i=this.state.data.slice(0);i[s].destination=e.value,this.setState({data:i});for(let e of t)e&&e();a(n)}).catch(e=>{console.error(e),Object(k.d)(e),this.scrollToIndex(s),n(e)})})}pushToArray(e,t,a,n,s){const{pluralsDestination:i,pluralsSource:l}=this.state;if(i.length!==l.length)if(2===i.length){if(t.includes("_0")){let i=t.replace("_0",""),r=i+"_plural",l=u()(s,"".concat(i,".acceptedIDs"),[]).find(e=>e===this.props.user.LocalUserID)||!1,o=u()(s,"".concat(r,".acceptedIDs"),[]).find(e=>e===this.props.user.LocalUserID)||!1;return e.push({value:n,path:i,destination:u()(a,i,""),accepted:l,sourcePath:t}),void e.push({value:n,path:r,destination:u()(a,r,""),accepted:o,number:2,sourcePath:null})}for(let e=1;ee.path===l);if(o>-1){let t=e.splice(o,1)[0];for(let r=0;re===this.props.user.LocalUserID)||!1;e.push({value:0===r?t.value:n,path:o,destination:u()(a,o,""),accepted:c,number:0!==r?i[r]:void 0,sourcePath:0===r?t.path:null})}}return}}else{if(t.includes("_0")){let r=t.replace("_0","");for(let l=0;le===this.props.user.LocalUserID)||!1;e.push({value:n,path:o,destination:u()(a,o,""),accepted:c,number:0!==l?i[l]:void 0,sourcePath:0===l?t:null})}return}for(let e=1;ee===this.props.user.LocalUserID)||!1,c=null;new RegExp("_\\d$").test(t)&&(c=+t.slice(-1),0===c&&(c=null)),t.endsWith("_plural")&&(c=1),e.push({value:n,path:t,destination:u()(a,t,""),accepted:o,sourcePath:t,number:i[c]})}createData(e,t,a,n=""){if(!e)return[];let s=[];for(let i in e){let r=e[i];if(Array.isArray(r))for(let e=0;ee===this.props.user.LocalUserID)||!1;(this.state.hideAccepted&&!l||!this.state.hideAccepted)&&this.pushToArray(s,e,t,r,a)}}return s}copyFromSourceToDestination(e,t){const a=this.state.data.slice(0);a[t].destination=e,this.setState({data:a}),this.addToSaveQueue({lang:this.state.destination,value:e,path:"".concat(a[t].path)})}onCheckboxChange(e,t){const a=this.state.data.slice(0);a[t].accepted=e,this.setState({data:a}),this.addToSaveQueue({lang:this.state.destination,path:"".concat(a[t].path),value:a[t].destination,accepted:e})}onRemoveClick(e){const{show:t,t:a}=this.props,n=this.state.data.slice(0);t(U.a,{title:a("newSettings.translate.edit.removeTitle"),text:a("newSettings.translate.edit.removeText",{path:n[e].path}),confirmText:a("yes"),closeText:a("cancel"),onConfirmed:t=>{n[e].loading=!0,this.setState({data:n}),Object(J.a)([{lang:this.state.destination,path:n[e].path},{lang:this.state.source,path:n[e].sourcePath}]).then(e=>{this.props.dispatch(Object(g.e)([this.state.destination,this.state.source],!1)),Object(J.c)(e)}).catch(t=>{Object(J.b)(t);const a=this.state.data.slice(0);a[e].loading=!1,this.setState({data:a})}),t.handleHide()}})}scrollToIndex(e){let t=this.container.current.getBoundingClientRect(),a=this.selectContainer.current.clientHeight,n=Object(C.f)(1);window.scrollTo({top:e*n*5+t.top+window.scrollY+a+2*n,behavior:"smooth"})}findNextEmpty(){const{data:e}=this.state;return r()(e,e=>!e.destination||e.destination===e.value,this.firstRenderedIndex+2)}findPreviousEmpty(){const e=this.state.data.slice(0);let t=e.length-r()(e.reverse(),e=>!e.destination||e.destination===e.value,e.length-this.firstRenderedIndex);return t0?"fas fa-fw fa-circle-notch fa-spin":"fas fa-check fa-fw"}))),d.a.createElement("div",{className:"translate-row languages",ref:this.selectContainer},d.a.createElement("div",{className:"translate-col"},d.a.createElement(f.a,{value:n,options:a.filter(e=>e!==s).map(e=>({value:e,name:this.allLanguages[e]||"? (".concat(e,")")})),onChange:this.onChangeSource,clearButton:!1})),d.a.createElement("div",{className:"translate-arrow"},d.a.createElement(I.a,{buttonStyle:"round",icon:d.a.createElement("i",{className:"fas fa-exchange"}),onClick:this.onExchangeClick})),d.a.createElement("div",{className:"translate-col"},d.a.createElement(f.a,{value:s,options:a.filter(e=>e!==n).map(e=>({value:e,name:this.allLanguages[e]||"? (".concat(e,")")})),onChange:this.onChangeDestination,clearButton:!1})),d.a.createElement("div",{className:"translate-col-checkbox"},d.a.createElement(v.a,{tooltipContent:e("newSettings.translate.edit.showHideAccepted")},d.a.createElement("div",null,d.a.createElement(M.a,{label:"",checked:u,onChange:this.onHideAccepted})))),d.a.createElement("div",{className:"translate-col-checkbox"})),d.a.createElement(b.f,null,({height:e,isScrolling:t,scrollTop:a,onChildScroll:n})=>d.a.createElement(b.e,{autoHeight:!0,height:e,rowCount:i.length,rowHeight:Object(C.f)(5),width:window.innerWidth,rowRenderer:this.renderRow,isScrolling:t,scrollTop:a,data:i,className:"w-100",onScroll:n,onRowsRendered:this.onRowsRendered})),d.a.createElement(P.a,{fixed:!0},d.a.createElement(I.a,{buttonColor:"info",buttonStyle:"round",icon:d.a.createElement("i",{className:"fas fa-arrow-up"}),disabled:l,onClick:this.scrollPreviousEmpty}),d.a.createElement(I.a,{buttonColor:"info",buttonStyle:"round",icon:d.a.createElement("i",{className:"fas fa-arrow-down"}),disabled:r,onClick:this.scrollToNextEmpty}),t.UserType===G.SERVICE&&d.a.createElement(I.a,{buttonColor:"info",buttonStyle:"round",icon:d.a.createElement("i",{className:"fas fa-plus"}),onClick:this.onAddButtonClick}),d.a.createElement(A.a,{event:o},d.a.createElement(L.a,{onClick:this.onAddLanguageClick},e("newSettings.translate.edit.newLocale")),d.a.createElement(L.a,{onClick:this.onAddTranslationClick},e("newSettings.translate.edit.newTranslation")))),d.a.createElement(N.b,null),d.a.createElement(W.b,null),d.a.createElement(B.b,{when:h>0,message:this.showBeforeLeave}))}}t.a=Object(x.d)(Object(O.a)(),Object(p.connect)((function(e){return{farm:e.location.farm,user:e.user.user,translations:e.language.translations.content,acceptedTranslations:e.language.translations.acceptance,languages:e.language.availableTranslationLanguages,loadingLanguages:e.language.loading.translationLanguages,loadingTranslation:e.language.loading.translations}}),(function(e){return Z({},Object(x.b)({show:R.d},e),{dispatch:e})})))(Y)},ktQ7:function(e,t,a){"use strict";var n=a("q1tI"),s=a.n(n),i=a("d/v1"),r=a("pJVQ"),l=a("y4iu"),o=a("VyNe"),c=a("XM6k"),u=a("3Z9Z"),h=a("JI6e"),d=a("/MKj"),p=a("BkRI"),m=a.n(p),g=a("ZRKa"),f=a("gLBR"),b=a("2UNB"),y=a("P0Qa");function S(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function v(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}var O=a("q17X"),w=a("uSQv"),E=a("Ty5D"),D=a("LCzB");class j extends s.a.Component{constructor(e){super(e),this.showCertInfo=()=>{this.props.history.push("/acceptCert")};const{dispatch:t,initialize:a}=this.props;t(a({showAliases:Object(O.getShowAliases)(),offline:Object(O.getOffline)(),RFIDReader:Object(O.getRFIDTagReader)()}))}render(){const{handleSubmit:e,t:t}=this.props;return s.a.createElement(o.a,null,s.a.createElement(l.a,{handleSubmit:e,optionalButtons:s.a.createElement(w.a,{buttonColor:"info",buttonStyle:"round",icon:s.a.createElement("i",{className:"fas fa-info"}),onClick:this.showCertInfo})},s.a.createElement(u.a,{className:"justify-content-center"},s.a.createElement(h.a,{lg:6},s.a.createElement("div",null,s.a.createElement(i.a,{name:"showAliases",component:c.a,label:t("newSettings.system.devicesSystem.showAliases"),id:"showAliases"})),s.a.createElement("div",null,s.a.createElement(i.a,{name:"offline",id:"offline",component:c.a,label:t("newSettings.system.devicesSystem.offline")})),s.a.createElement("div",null,s.a.createElement(i.a,{name:"RFIDReader",id:"RFIDReader",component:c.a,label:t("newSettings.system.devicesSystem.rfidReader")}))))))}}j=Object(r.a)({form:"devices-system-view",onSubmit:function(e,t,a){const{showAliases:n,offline:s,RFIDReader:i}=e,{user:{ClientID:r}}=a;let l=g.a.getSettingByID(r),o={ShowAliases:n,Offline:s,RFIDReader:i};if(console.log(o),l){let e=m()(l);e.SetData?e.SetData.Settings||(e.SetData=function(e){for(var t=1;t",e),t(Object(f.c)(e))}else{let e=b.a.createSetting(y.a.GENERAL,{Settings:{Devices:o}});console.log("create - >",e),t(Object(f.a)(e))}}})(j);let T=Object(d.connect)(e=>({user:e.user.user}))(j);j=Object(E.o)(T);t.a=Object(D.a)()(j)},oFjU:function(e,t,a){"use strict";var n=a("q1tI"),s=a.n(n),i=a("udB/"),r=a("3Z9Z"),l=a("JI6e"),o=a("/MKj"),c=a("/kok"),u=a("D1y2"),h=a.n(u),d=a("BkRI"),p=a.n(d),m=a("mwIZ"),g=a.n(m),f=a("Y+p1"),b=a.n(f),y=a("1smR"),S=a("17x9"),v=a.n(S),O=a("Gaw7"),w=a("B/gD"),E=a("zTlQ"),D=a("Vv3o"),j=a("pxzG"),T=a("eASP"),C=a("vYJ8"),P=a("zDJl"),I=a("IBmF"),k=a("vzZS"),N=a("wd/R"),x=a.n(N),R=a("LCzB"),A=a("XzT5");function L(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function U(e){for(var t=1;t({number:t+1,value:0}))};class q extends s.a.Component{constructor(e){super(e),this.getValues=(e=this.props)=>{const{siloses:t,shadows:a}=e;let n=t[0];try{let e=a.get(n.DevID);return{flashDisplay:e.configuration.flashDisplay||W.flashDisplay,isPin:e.configuration.isPin||W.isPin,pin:(e.configuration.pin+""||W.pin).padStart(4,"0"),sweepWeights:e.configuration.sweepWeights||W.sweepWeights,minWeights:e.configuration.minWeights||W.minWeights,loadedDataFrom:P.i.SHADOW,SetTime:e.metadata.motorSetup,device:n}}catch(s){return{flashDisplay:g()(n,"Settings.Configuration.".concat(I.m.SET_CONFIGURATION,".flashDisplay"),W.flashDisplay),isPin:g()(n,"Settings.Configuration.".concat(I.m.SET_CONFIGURATION,".isPin"),W.isPin),pin:g()(n,"Settings.Configuration.".concat(I.m.SET_CONFIGURATION,".pin"),W.pin).padStart(4,"0"),sweepWeights:g()(n,"Settings.Configuration.".concat(I.m.SET_CONFIGURATION,".sweepWeights"),W.sweepWeights),minWeights:g()(n,"Settings.Configuration.".concat(I.m.SET_CONFIGURATION,".minWeights"),W.minWeights),SetTime:g()(n,"Settings.Configuration.".concat(I.m.SET_CONFIGURATION,".SetTime"),0),loadedDataFrom:n&&n.Settings&&n.Settings.Configuration&&n.Settings.Configuration[I.m.SET_CONFIGURATION]?P.i.DYNAMO:P.i.NO_DATA,device:n}}},this.onClick=()=>{const{siloses:e}=this.props;if(!Object.keys(this.validate()).length){const{flashDisplay:t,isPin:a,pin:n,sweepWeights:s,minWeights:i}=this.state;e.forEach(e=>{Object(O.b)(e,{flashDisplay:!!t,isPin:!!a,pin:n,sweepWeights:!!s,minWeights:i})})}},this.setValue=(e,t)=>{this.setState(a=>{let n=p()(a);return h()(n,e,t),U({},n,{changed:!0})})},this.validate=()=>{let e={};const{t:t}=this.props,{pin:a}=this.state;return/([0-9]{4})$/.test(a+"")||(e.pin=t("required")),e},this.renderMinWeights=()=>{const{minWeights:e}=this.state;return s.a.createElement("div",null,new Array(8).fill(1).map((t,a)=>s.a.createElement("div",null,s.a.createElement(D.a,{onChange:e=>this.setValue("minWeights[".concat(a,"].value"),e),label:A.a.t("newSettings.silo.generalSetup.minWeights",{type:a+1}),min:0,max:5e6,step:1e3,value:e[a].value,valueFormatter:e=>Object(j.j)(e,{showUnit:!0,unit:T.a.MEDIUM,fixed:0})}))))},this.state=U({},W,{changed:!1})}UNSAFE_componentWillReceiveProps(e,t){this.state.changed||this.setState(U({},this.getValues(e)))}shouldComponentUpdate(e,t,a){return!b()(this.state,t)||!b()(this.props.t("newSettings.silo.generalSetup"),e.t("newSettings.silo.generalSetup"))}render(){const{t:e}=this.props,{flashDisplay:t,isPin:a,pin:n,sweepWeights:i,loadedDataFrom:r,SetTime:l,device:o}=this.state;let c=this.validate();return s.a.createElement(y.b,{title:e("newSettings.silo.generalSetup.title"),disabled:!!Object.keys(c).length,onButtonClick:this.onClick},r!==P.i.SHADOW&&s.a.createElement(s.a.Fragment,null,r===P.i.DYNAMO&&!o.Settings.Configuration[I.m.SET_CONFIGURATION].isSet&&s.a.createElement(k.a,{boxColor:"warning"},A.a.t("newSettings.devices.settingsInfo.dynamo",{date:x()(l).format("DD.MM.YYYY HH:mm")})),r===P.i.NO_DATA&&s.a.createElement(k.a,{boxColor:"error"},e("newSettings.devices.settingsInfo.noData"))),s.a.createElement(w.a,{id:"sweepWeights",value:i,label:e("newSettings.silo.generalSetup.sweepWeights"),onChange:e=>this.setValue("sweepWeights",e)}),s.a.createElement(w.a,{id:"isPin",value:a,label:e("newSettings.silo.generalSetup.isPin"),onChange:e=>this.setValue("isPin",e)}),s.a.createElement(E.a,{disabled:!a,error:c.pin,label:e("newSettings.silo.generalSetup.pin"),type:"text",value:n,optionalProps:{maxLength:4,pattern:"[0-9]{4}"},onChange:e=>this.setValue("pin",e)}),s.a.createElement(w.a,{id:"flashDisplay",value:t,label:e("newSettings.silo.generalSetup.flashDisplay"),onChange:e=>this.setValue("flashDisplay",e)}),s.a.createElement(C.a,{in:t,mountOnEnter:!0,unmountOnExit:!0},this.renderMinWeights()))}}q.propTypes={siloses:v.a.array.isRequired},q=Object(o.connect)(e=>({shadows:e.shadows.shadows}))(q);var M=Object(R.a)()(q),F=a("UB5X"),V=a.n(F),z=a("J2iB"),Q=a.n(z),_=a("uSQv");function J(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function G(e){for(var t=1;t{const{siloses:t,shadows:a}=e;let n=g()(a.get(t[0].DevID),"tares");return{tare:n?n.map(e=>Object(j.j)(e.value,{unit:T.a.MEDIUM,rawValue:!0})):X.tare}},this.getValues=(e,t)=>{const{siloses:a,shadows:n}=e;let s=n.get(a[0].DevID);return{weight:g()(s,"weights[".concat(t,"].value")),rawWeight:g()(s,"weightsRaw[".concat(t,"].value"))}},this.setAllTares=()=>{const{siloses:e}=this.props,{tare:t}=this.state;!Object.keys(this.validate()).length&&e.forEach(e=>{new Array(8).fill(1).forEach((a,n)=>{Object(O.d)(e,{number:n,value:Object(j.i)(+t[n],{fromUnit:Z})})})})},this.setSingleTare=e=>{const t=!g()(this.validate(),"tare[".concat(e,"]")),{siloses:a}=this.props,{tare:n}=this.state;t&&a.forEach(t=>{Object(O.d)(t,{number:e,value:Object(j.i)(+n[e],{fromUnit:Z})})})},this.setValue=(e,t)=>{this.setState(a=>{let n=p()(a);return h()(n,e,t),G({},n,{changed:!0})})},this.validate=()=>{let e={};const{tare:t}=this.state,{t:a}=this.props;return t.forEach((t,n)=>{!Q()(t)&&""!==t&&V()(+t)||h()(e,"tare[".concat(n,"]"),a("required"))}),e},this.renderTares=()=>{const{tare:e}=this.state;let t=this.validate(),a=[];for(let n=0;n<8;n++){let{weight:i,rawWeight:r}=this.getValues(this.props,n);a.push(s.a.createElement("div",{key:n},s.a.createElement(E.a,{className:"make-room-for-button",error:g()(t,"tare[".concat(n,"]")),label:A.a.t("newSettings.silo.tare.header",{type:n+1,amount1:Object(j.j)(i,{showUnit:!0,unit:T.a.MEDIUM,fixed:0}),amount2:Object(j.j)(r,{showUnit:!0,unit:T.a.MEDIUM,fixed:0})}),type:"number",value:e[n],onChange:e=>this.setValue("tare[".concat(n,"]"),e),unit:s.a.createElement("bdi",null,Object(j.l)("weight",Z))}),s.a.createElement(_.a,{buttonStyle:"round",type:"button",disabled:g()(t,"tare[".concat(n,"]")),onClick:()=>this.setSingleTare(n),icon:s.a.createElement("i",{className:"fas fa-save"})})))}return a},this.state=G({},X,{changed:!1})}UNSAFE_componentWillReceiveProps(e,t){this.state.changed||this.setState(G({},this.getTareValues(e)))}shouldComponentUpdate(e,t,a){return!b()(this.state,t)||!b()(this.props.t("newSettings.silo.tare"),e.t("newSettings.silo.tare"))}render(){const{t:e}=this.props;return s.a.createElement(s.a.Fragment,null,s.a.createElement(y.b,{title:e("newSettings.silo.tare.title"),onButtonClick:this.setAllTares},this.renderTares()))}}Y.propTypes={siloses:v.a.array.isRequired},Y=Object(o.connect)(e=>({shadows:e.shadows.shadows}))(Y);var K=Object(R.a)()(Y);function $(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function ee(e){for(var t=1;t{const{siloses:t,shadows:a}=e;let n=g()(a.get(t[0].DevID),"scales");return{scale:n?n.map(e=>e.value):ae.scale}},this.getWeight=(e,t)=>{const{siloses:a,shadows:n}=e;let s=n.get(a[0].DevID);return g()(s,"weights[".concat(t,"].value"))},this.setAllScales=()=>{const{siloses:e}=this.props,{scale:t}=this.state;!Object.keys(this.validate()).length&&e.forEach(e=>{new Array(8).fill(1).forEach((a,n)=>{Object(O.c)(e,{number:n,value:+t[n]})})})},this.setSingleScale=e=>{const t=!g()(this.validate(),"scale[".concat(e,"]")),{siloses:a}=this.props,{scale:n}=this.state;t&&a.forEach(t=>{Object(O.c)(t,{number:e,value:+n[e]})})},this.setValue=(e,t)=>{this.setState(a=>{let n=p()(a);return h()(n,e,t),ee({},n,{changed:!0})})},this.validate=()=>{let e={};const{scale:t}=this.state,{t:a}=this.props;return t.forEach((t,n)=>{!Q()(t)&&""!==t&&V()(+t)||h()(e,"scale[".concat(n,"]"),a("required"))}),e},this.renderScales=()=>{const{scale:e}=this.state;let t=this.validate();return s.a.createElement(s.a.Fragment,null,new Array(8).fill(1).map((a,n)=>s.a.createElement("div",null,s.a.createElement(E.a,{className:"make-room-for-button",error:g()(t,"scale[".concat(n,"]")),label:A.a.t("newSettings.silo.scale.header",{type:n+1,amount:Object(j.j)(this.getWeight(this.props,n),{showUnit:!0,unit:T.a.MEDIUM,fixed:0})}),type:"number",value:e[n],onChange:e=>this.setValue("scale[".concat(n,"]"),e)}),s.a.createElement(_.a,{buttonStyle:"round",type:"button",disabled:g()(t,"scale[".concat(n,"]")),onClick:()=>this.setSingleScale(n),icon:s.a.createElement("i",{className:"fas fa-save"})}))))},this.state=ee({},ae,{changed:!1})}UNSAFE_componentWillReceiveProps(e,t){this.state.changed||this.setState(ee({},this.getScaleValues(e)))}shouldComponentUpdate(e,t,a){return!b()(this.state,t)||!b()(this.props.t("newSettings.silo.scale"),e.t("newSettings.silo.scale"))}render(){const{t:e}=this.props;return s.a.createElement(s.a.Fragment,null,s.a.createElement(y.b,{title:e("newSettings.silo.scale.title"),onButtonClick:this.setAllScales},this.renderScales()))}}ne.propTypes={siloses:v.a.array.isRequired},ne=Object(o.connect)(e=>({shadows:e.shadows.shadows}))(ne);var se=Object(R.a)()(ne);class ie extends s.a.Component{constructor(e){super(e),this.state={selectedSiloses:this.props.location.state?this.props.location.state.selectedSiloses:[],loading:!0},this.setLoading=()=>{this.setState({loading:!1})},0===this.state.selectedSiloses.length&&this.props.history.push("/".concat(this.props.farm,"/settings/weightPanels/manage")),c.a.startSendingDeviceState(this.state.selectedSiloses,this.setLoading,this.setLoading)}render(){const{selectedSiloses:e,loading:t}=this.state;return 0===e.length?null:s.a.createElement("div",{style:{position:"relative"}},s.a.createElement(i.a,{isLoading:t}),s.a.createElement(r.a,null,s.a.createElement(l.a,{xl:12},s.a.createElement(M,{siloses:e}))),s.a.createElement(r.a,null,s.a.createElement(l.a,{xl:6},s.a.createElement(K,{siloses:e})),s.a.createElement(l.a,{xl:6},s.a.createElement(se,{siloses:e}))))}}ie=Object(o.connect)(e=>({farm:e.location.farm}))(ie);t.a=ie},phFi:function(e,t,a){},rSdu:function(e,t,a){}}]); //# sourceMappingURL=main~fc8f7cc0.ab887ea5.chunk.js.map