You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
24 KiB
1 lines
24 KiB
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[692],{1939:function(e,n,t){var r=t(5893),o=t(7357),a=t(7169);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function u(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){i(e,n,t[n])}))}return e}function c(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var l="Decorator",s={ok:"".concat(l,"-ok"),warning:"".concat(l,"-warning"),error:"".concat(l,"-error"),off:"".concat(l,"-off")};n.Z=function(e){var n,t=e.colour,l=e.sx,f=c(e,["colour","sx"]);return(0,r.jsx)(o.Z,u({},f,{className:s[t],sx:u((n={borderRadius:a.n_,height:"100%",width:"1.4em"},i(n,"&.".concat(s.ok),{backgroundColor:a.Ej}),i(n,"&.".concat(s.warning),{backgroundColor:a.Wd}),i(n,"&.".concat(s.error),{backgroundColor:a.hM}),i(n,"&.".concat(s.off),{backgroundColor:a.s7}),n),l)}))}},5741:function(e,n,t){var r=t(5893),o=t(1714),a=t(122),i=t(7169),u=t(4690);function c(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function l(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){c(e,n,t[n])}))}return e}function s(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}n.Z=function(e){var n=e.children,t=e.sx,c=s(e,["children","sx"]);return(0,r.jsx)(a.Z,l({underline:"hover",variant:"subtitle1"},c,{sx:l({color:i.lD,textDecorationColor:i.s7},t),children:(0,r.jsxs)(u.Z,{row:!0,children:[n,(0,r.jsx)(o.Z,{sx:{marginLeft:".3em"}})]})}))}},8461:function(e,n,t){t.d(n,{Z:function(){return fe}});var r=t(5893),o=t(7357),a=t(2734),i=t(8396),u=t(6239),c=t(9699),l=t(2026),s=t(5537),f=t(2428),d=t(2275),p=t(3490),v=t(8951),m=t(7294),b=t(5934),g=t(2029),h=t(7169),y=t(3106),w=t(1250),x=t(4390),k=t(4799),I=t(1939),j=t(7750);function C(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function O(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){C(e,n,t[n])}))}return e}function M(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var S=function(e){var n=e.isFloating,t=e.networkInterface,a=t.networkInterfaceName,i=t.networkInterfaceState,u=e.onClose,c=e.sx,l=M(e,["isFloating","networkInterface","onClose","sx"]),f=n?{borderColor:h.s7,borderRadius:h.n_,borderStyle:"solid",borderWidth:"1px",backgroundColor:h.E5,padding:".6em 1.2em"}:{};return(0,r.jsxs)(o.Z,O({sx:O({display:"flex",flexDirection:"row","& > :not(:first-child)":{alignSelf:"center",marginLeft:".5em"}},f,c)},l,{children:[(0,r.jsx)(I.Z,{colour:"up"===i?"ok":"off",sx:{height:"auto"}}),(0,r.jsx)(j.Ac,{text:a}),u&&(0,r.jsx)(k.Z,{onClick:u,size:"small",sx:{color:h.s7},children:(0,r.jsx)(s.Z,{})})]}))};S.defaultProps={isFloating:!1,onClose:void 0};var Z=S,U=(0,t(1496).ZP)(o.Z)((function(){return{borderColor:h.s7,borderStyle:"dashed",borderWidth:"4px",display:"flex",flexDirection:"column",padding:".6em","& > :not(:first-child)":{marginTop:".3em"}}})),D=t(4690),P=t(1770),A=t(1706),N=t(9099),R=t(7869),E=t(6284),T=t(3679),F=t(1905),L=t(7783),V=t(2152),H=function(e){for(var n=0,t=0;t<e.length;t+=1)n+=e.codePointAt(t)||0;return n},_=t(7987);function q(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function B(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function G(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){B(e,n,t[n])}))}return e}function J(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,o,a=[],i=!0,u=!1;try{for(t=t.call(e);!(i=(r=t.next()).done)&&(a.push(r.value),!n||a.length!==n);i=!0);}catch(c){u=!0,o=c}finally{try{i||null==t.return||t.return()}finally{if(u)throw o}}return a}}(e,n)||X(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function W(e){return function(e){if(Array.isArray(e))return q(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||X(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function X(e,n){if(e){if("string"===typeof e)return q(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?q(e,n):void 0}}var $={ifaceNotApplied:"".concat("NetworkInitForm","-network-interface-not-applied")},z=[void 0,void 0],K=[{inputUUID:"30dd2ac5-8024-4a7e-83a1-6a3df7218972",interfaces:W(z),ipAddress:"10.200.1.1",isRequired:!0,name:"".concat(y.Z.bcn," 1"),subnetMask:"255.255.0.0",type:"bcn",typeCount:1},{inputUUID:"e7ef3af5-5602-440c-87f8-69c242e3d7f3",interfaces:W(z),ipAddress:"10.201.1.1",isRequired:!0,name:"".concat(y.Z.ifn," 1"),subnetMask:"255.255.0.0",type:"ifn",typeCount:1}],Y=W(K).concat([{inputUUID:"525e4847-f929-44a7-83b2-28eb289ffb57",interfaces:W(z),ipAddress:"10.202.1.1",isRequired:!0,name:"".concat(y.Z.sn," 1"),subnetMask:"255.255.0.0",type:"sn",typeCount:1}]),Q="dns",ee="gateway",ne=function(e){return"".concat(e,"Interface")},te=function(e){return"".concat(e,"IPAddress")},re=function(e){return"".concat(e,"Name")},oe=function(e){return"".concat(e,"SubnetMask")},ae=function(e){return"".concat(e,"NetworkSubnetConflict")},ie=Array.from({length:2},(function(e,n){return n+1})),ue=function(e){return"network".concat(e)},ce=function(e,n){return[{align:"center",field:"",renderCell:function(t){var a,i=t.row,u=(null!==(a=n[i.networkInterfaceUUID])&&void 0!==a&&a).isApplied,s="grab",f=function(){for(var n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];e.apply(void 0,[i].concat(W(t)))},d=(0,r.jsx)(c.Z,{});return u&&(s="auto",f=void 0,d=(0,r.jsx)(l.Z,{sx:{color:h.Ej}})),(0,r.jsx)(o.Z,{onMouseDown:f,sx:{alignItems:"center",display:"flex",flexDirection:"row","&:hover":{cursor:s}},children:d})},sortable:!1,width:1},{field:"networkInterfaceName",flex:1,headerName:"Name",renderCell:function(e){var n=e.row,t=(void 0===n?{}:n).networkInterfaceState,a=e.value;return(0,r.jsxs)(o.Z,{sx:{display:"flex",flexDirection:"row","& > :not(:first-child)":{marginLeft:".5em"}},children:[(0,r.jsx)(I.Z,{colour:"up"===t?"ok":"off",sx:{height:"auto"}}),(0,r.jsx)(j.KI,{text:a})]})},sortComparator:function(e,n){return H(e)-H(n)}},{field:"networkInterfaceMACAddress",flex:1,headerName:"MAC",renderCell:function(e){var n=e.value;return(0,r.jsx)(j.$_,{text:n})}},{field:"networkInterfaceState",flex:1,headerName:"State",renderCell:function(e){var n=e.value,t=String(n);return(0,r.jsx)(j.KI,{text:"".concat(t.charAt(0).toUpperCase()).concat(t.substring(1))})}},{field:"networkInterfaceSpeed",flex:1,headerName:"Speed",renderCell:function(e){var n=e.value;return(0,r.jsx)(j.KI,{text:"".concat(parseFloat(n).toLocaleString()," Mbps")})}},{field:"networkInterfaceOrder",flex:1,headerName:"Order"}]},le=function(e){var n=e.createDropMouseUpHandler,t=e.getNetworkTypeCount,u=e.hostDetail,c=(void 0===u?{}:u).hostType,l=e.networkIndex,d=e.networkInput,p=e.networkInterfaceCount,v=e.networkInterfaceInputMap,b=e.removeNetwork,g=e.setMessageRe,w=e.setNetworkInputs,x=e.setNetworkInterfaceInputMap,k=e.testInput,I=e.testInputToToggleSubmitDisabled,C=(0,a.Z)(),O=(0,i.Z)(C.breakpoints.up("md")),M=(0,i.Z)(C.breakpoints.up("lg")),S=(0,m.useRef)({}),D=(0,m.useRef)({}),P=d.inputUUID,R=d.interfaces,F=d.ipAddress,V=d.isRequired,H=d.subnetMask,_=d.type,q=d.typeCount,X=(0,m.useMemo)((function(){return ue(P)}),[P]),$=(0,m.useMemo)((function(){return ne(X)}),[X]),z=(0,m.useMemo)((function(){return te(X)}),[X]),K=(0,m.useMemo)((function(){return oe(X)}),[X]),Y=(0,m.useMemo)((function(){return ae(X)}),[X]),Q=(0,m.useMemo)((function(){return"node"===c}),[c]),ee=(0,m.useMemo)((function(){return!Q&&p<=2?[1]:ie}),[Q,p]),re=(0,m.useMemo)((function(){var e=y.Z.bcn,n=y.Z.ifn,t=y.Z.mn,r=y.Z.sn;return Q&&p>=8?{bcn:e,ifn:n,mn:t,sn:r}:{bcn:e,ifn:n,sn:r}}),[Q,p]);return(0,m.useEffect)((function(){var e=d.ipAddressInputRef,n=d.subnetMaskInputRef;e===S&&n===D||(d.ipAddressInputRef=S,d.subnetMaskInputRef=D,w((function(e){return W(e)})))}),[d,w]),(0,r.jsxs)(T.Lg,{children:[(0,r.jsxs)(T.CH,{children:[(0,r.jsx)(L.Z,{id:"network-".concat(P,"-name"),isReadOnly:V,inputLabelProps:{isNotifyRequired:!0},label:"Network name",selectItems:Object.entries(re).map((function(e){var n=J(e,2),r=n[0],o=n[1],a=t(r,{lastIndex:l});return r!==_&&(a+=1),{value:r,displayValue:"".concat(o," ").concat(a)}})),selectProps:{onChange:function(e){var n=e.target.value,r=String(n);d.type=r;var o=t(r,{lastIndex:l});d.typeCount=o,d.name="".concat(y.Z[r]," ").concat(o),w((function(e){return W(e)}))},renderValue:M?void 0:function(e){return"".concat(String(e).toUpperCase()," ").concat(q)},value:_}}),!V&&(0,r.jsx)(A.Z,{onClick:function(){b(l)},sx:{padding:".2em",position:"absolute",right:"-9px",top:"-4px"},children:(0,r.jsx)(s.Z,{fontSize:"small"})})]}),(0,r.jsxs)(o.Z,{sx:{display:"flex",flexDirection:"column",margin:".6em","& > :not(:first-child)":{marginTop:"1em"}},children:[ee.map((function(e){var t="Link ".concat(e),a=e-1,i=R[a],u=(null!==i&&void 0!==i?i:{}).networkInterfaceUUID,c=void 0===u?"":u,l=O?(0,r.jsx)(j.Ac,{text:"Drop to add interface."}):(0,r.jsx)(f.Z,{sx:{alignSelf:"center",color:h.s7}});return(0,r.jsxs)(o.Z,{sx:{alignItems:"center",display:"flex",flexDirection:"row","& > :not(:first-child)":{marginLeft:"1em"},"& > :last-child":{flexGrow:1}},children:[(0,r.jsx)(j.Ac,{sx:{whiteSpace:"nowrap"},text:t}),(0,r.jsx)(U,{onMouseUp:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var o;null===(o=null===n||void 0===n?void 0:n.call(null,R,a))||void 0===o||o.call.apply(o,[null].concat(W(t))),I({inputs:B({},$,{isIgnoreOnCallbacks:!1}),isContinueOnFailure:!0})},children:i?(0,r.jsx)(Z,{networkInterface:i,onClose:function(){R[a]=void 0,v[c].isApplied=!1,x((function(e){return G({},e)})),I({inputs:B({},$,{isIgnoreOnCallbacks:!1}),isContinueOnFailure:!0})}},"network-interface-".concat(c)):l})]},"network-".concat(P,"-link-").concat(e))})),(0,r.jsx)(N.Z,{input:(0,r.jsx)(E.Z,{id:"network-".concat(P,"-ip-address"),inputProps:{onBlur:function(e){var n=e.target.value;k({inputs:B({},z,{value:n})})}},inputLabelProps:{isNotifyRequired:!0},label:"IP address",onChange:function(e){var n=e.target.value;I({inputs:B({},z,{value:n})}),g(RegExp("(?:^(?:".concat(z,"|").concat(Y,")|").concat(P,"$)")))},value:F}),ref:S}),(0,r.jsx)(N.Z,{input:(0,r.jsx)(E.Z,{id:"network-".concat(P,"-subnet-mask"),inputProps:{onBlur:function(e){var n=e.target.value;k({inputs:B({},K,{value:n})})}},inputLabelProps:{isNotifyRequired:!0},label:"Subnet mask",onChange:function(e){var n=e.target.value;I({inputs:B({},K,{value:n})}),g(RegExp("(?:^(?:".concat(K,"|").concat(Y,")|").concat(P,"$)")))},value:H}),ref:D})]})]})};le.defaultProps={createDropMouseUpHandler:void 0,hostDetail:void 0};var se=(0,m.forwardRef)((function(e,n){var t,a,i=e.hostDetail,c=e.toggleSubmitDisabled,l=null!==i&&void 0!==i?i:{},s=l.dns,y=l.gateway,k=l.hostType,I=l.hostUUID,j=void 0===I?"local":I,C=(0,m.useState)({x:0,y:0}),O=C[0],M=C[1],S=(0,m.useState)({}),U=S[0],T=S[1],L=(0,m.useState)("node"===k?Y:K),H=L[0],q=L[1],X=(0,m.useState)(),ie=X[0],se=X[1],fe=(0,m.useState)(""),de=fe[0],pe=fe[1],ve=(0,m.useRef)({}),me=(0,m.useRef)({}),be=(0,m.useRef)({}),ge=(0,F.Z)("".concat(g.Z,"/init/network-interface/").concat(j),{refreshInterval:2e3,onSuccess:function(e){var n=e.reduce((function(e,n){var t,r=n.networkInterfaceUUID;return e[r]=null!==(t=U[r])&&void 0!==t?t:{metadata:n},e}),{});T(n)}}),he=ge.data,ye=void 0===he?[]:he,we=ge.isLoading,xe=(0,m.useMemo)((function(){return H.length>=ye.length||Object.values(U).every((function(e){return e.isApplied}))||"node"===k&&ye.length<=6}),[k,H,ye,U]),ke=(0,m.useCallback)((function(e,n){var t;return null===(t=be.current.setMessage)||void 0===t?void 0:t.call(null,e,n)}),[]),Ie=(0,m.useCallback)((function(e,n){var t;return null===(t=be.current.setMessageRe)||void 0===t?void 0:t.call(null,e,n)}),[]),je=(0,m.useCallback)((function(e){return ke(Q,e)}),[ke]),Ce=(0,m.useCallback)((function(e){return ke(ee,e)}),[ke]),Oe=(0,m.useCallback)((function(e){var n,t=e.fn,r=void 0===t?"every":t,o=e.ip,a=void 0===o?"":o,i=e.mask,u=void 0===i?"":i,c=e.isNegateMatch,l=void 0===c?"every"===r:c,s=e.onMatch,f=e.onMiss,d=e.skipUUID,p="every"===r;try{n=new v.Netmask("".concat(a,"/").concat(u))}catch(m){}return H[r]((function(e){var t,r,o=e.inputUUID,i=e.ipAddressInputRef,u=e.subnetMaskInputRef;if(o===d)return p;var c=null===(t=null===i||void 0===i?void 0:i.current.getValue)||void 0===t?void 0:t.call(null),b=null===(r=null===u||void 0===u?void 0:u.current.getValue)||void 0===r?void 0:r.call(null),g=!1;try{g=function(e,n){var t=n.b,r=n.bIP,o=void 0===r?"":r;return e.contains(null!==t&&void 0!==t?t:o)||void 0!==t&&t.contains(e)}(new v.Netmask("".concat(c,"/").concat(b)),{b:n,bIP:a})}catch(m){}return g?null===s||void 0===s||s.call(null,e):null===f||void 0===f||f.call(null,e),l?!g:g}))}),[H]),Me=(0,m.useCallback)((function(e){x.Z.put("/init/set-map-network",{value:e}).catch((function(n){var t=(0,P.Z)(n);t.children=(0,r.jsxs)(r.Fragment,{children:["Failed to ",e?"enable":"disable"," network mapping."," ",t.children]}),ke("api",t)}))}),[ke]),Se=(0,m.useMemo)((function(){var e,n=(B(e={},Q,{defaults:{getValue:function(){var e;return null===(e=me.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:function(){je()}},tests:[{onFailure:function(){je({children:"Domain name servers should be a comma-separated list of IPv4 addresses without trailing comma(s)."})},test:function(e){var n=e.value;return w.ah.test(n)}},{test:_.HJ}]}),B(e,ee,{defaults:{getValue:function(){var e;return null===(e=ve.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:function(){Ce()}},tests:[{onFailure:function(){Ce({children:"Gateway should be a valid IPv4 address."})},test:function(e){var n=e.value;return w.tf.test(n)}},{test:function(e){var n=e.value,t=!0,r=Oe({fn:"some",ip:n,onMatch:function(e){var r=e.ipAddress,o=e.name,a=e.type,i=e.typeCount;if(n===r)return t=!1,void Ce({children:"Gateway cannot be the same as IP address in ".concat(o,".")});pe("".concat(a).concat(i))}});return r||Ce({children:"Gateway must be in one network's subnet."}),r&&t}},{test:_.HJ}]}),e);return H.forEach((function(e){var t,r,o=e.inputUUID,a=e.interfaces,i=e.ipAddressInputRef,u=e.name,c=e.subnetMaskInputRef,l=ue(o),s=ne(l),f=te(l),d=oe(l),p=function(e){return ke(s,e)},v=function(e){return ke(f,e)},m=function(e){return ke(d,e)},b=function(e,n,t){var r,o="".concat(ae(l),"-").concat(n),a="".concat(ae(ue(n)),"-").concat(e);ke((null===(r=be.current.exists)||void 0===r?void 0:r.call(null,a))?a:o,t)},g=function(e){var n=e.ip,a=void 0===n?null===(t=null===i||void 0===i?void 0:i.current.getValue)||void 0===t?void 0:t.call(null):n,l=e.mask,s=void 0===l?null===(r=null===c||void 0===c?void 0:c.current.getValue)||void 0===r?void 0:r.call(null):l;return Oe({ip:a,mask:s,onMatch:function(e){var n=e.inputUUID,t=e.name;b(o,n,{children:'"'.concat(u,'" and "').concat(t,'" cannot be in the same subnet.')})},onMiss:function(e){var n=e.inputUUID;b(o,n)},skipUUID:o})};n[s]={defaults:{getCompare:function(){return a.map((function(e){return void 0!==e}))},onSuccess:function(){p()}},tests:[{onFailure:function(){p({children:"".concat(u," must have at least 1 interface.")})},test:function(e){return e.compare.some((function(e){return e}))}},{onFailure:function(){p({children:"".concat(u," must have a Link 1 interface.")})},test:function(e){var n=J(e.compare,2),t=n[0];return!(n[1]&&!t)}}]},n[f]={defaults:{getValue:function(){var e;return null===(e=null===i||void 0===i?void 0:i.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:function(){v()}},tests:[{onFailure:function(){v({children:"IP address in ".concat(u," must be a valid IPv4 address.")})},test:function(e){var n=e.value;return w.tf.test(n)}},{test:function(e){var n=e.value;return g({ip:n})}},{test:_.HJ}]},n[re(l)]={defaults:{value:u},tests:[{test:_.HJ}]},n[d]={defaults:{getValue:function(){var e;return null===(e=null===c||void 0===c?void 0:c.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:function(){m()}},tests:[{onFailure:function(){m({children:"Subnet mask in ".concat(u," must be a valid IPv4 address.")})},test:function(e){var n=e.value;return w.tf.test(n)}},{test:function(e){var n=e.value;return g({mask:n})}},{test:_.HJ}]}})),n}),[H,je,Ce,ke,Oe]),Ze=(0,m.useMemo)((function(){return(0,_.LT)(Se)}),[Se]),Ue=(0,m.useCallback)((function(e){null===c||void 0===c||c.call(null,Ze(G({isIgnoreOnCallbacks:!0,isTestAll:!0},e)))}),[Ze,c]),De=(0,m.useCallback)((function(){se(void 0)}),[]),Pe=(0,m.useCallback)((function(){H.unshift({inputUUID:(0,b.Z)(),interfaces:W(z),ipAddress:"",name:"Unknown Network",subnetMask:"",type:"",typeCount:0}),null===c||void 0===c||c.call(null,!1),q(W(H))}),[H,c]),Ae=(0,m.useCallback)((function(e){var n=J(H.splice(e,1),1)[0],t=n.inputUUID;n.interfaces.forEach((function(e){if(void 0!==e){var n=e.networkInterfaceUUID;U[n].isApplied=!1}})),Ue({excludeTestIdsRe:RegExp(t)}),q(W(H)),T((function(e){return G({},e)}))}),[H,U,Ue]),Ne=(0,m.useCallback)((function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.inputs,r=void 0===t?H:t,o=n.lastIndex,a=void 0===o?0:o,i=0,u=r.length-1;u>=a;u-=1)r[u].type===e&&(i+=1);return i}),[H]),Re=(0,m.useMemo)((function(){if(void 0!==ie){var e=ie.networkInterfaceUUID;return function(n,t){return function(){var r,o=(null!==(r=n[t])&&void 0!==r?r:{}).networkInterfaceUUID;o&&o!==e&&(U[o].isApplied=!1),n[t]=ie,U[e].isApplied=!0}}}}),[ie,U]),Ee=(0,m.useMemo)((function(){return ie?{cursor:"grabbing",userSelect:"none"}:{}}),[ie]),Te=(0,m.useMemo)((function(){if(void 0===ie)return(0,r.jsx)(r.Fragment,{});var e=O.x,n=O.y;return(0,r.jsx)(Z,{isFloating:!0,networkInterface:ie,sx:{left:"calc(".concat(e,"px + .4em)"),position:"absolute",top:"calc(".concat(n,"px - 1.6em)"),zIndex:20}})}),[O,ie]),Fe=(0,m.useMemo)((function(){return ie?function(){De()}:void 0}),[De,ie]),Le=(0,m.useMemo)((function(){return ie?function(e){var n=e.currentTarget,t=e.nativeEvent,r=t.clientX,o=t.clientY,a=n.getBoundingClientRect(),i=a.left,u=a.top;M({x:r-i,y:o-u})}:void 0}),[ie]),Ve=(0,m.useMemo)((function(){return ie?function(){De()}:void 0}),[De,ie]);(0,m.useEffect)((function(){return Me(1),window&&window.addEventListener("beforeunload",(function(){var e=new XMLHttpRequest;e.open("PUT","".concat(g.Z,"/init/set-map-network"),!1),e.send(null)}),{once:!0}),function(){Me(0)}}),[Me]),(0,m.useImperativeHandle)(n,(function(){return{get:function(){var e,n;return{dns:null===(e=me.current.getValue)||void 0===e?void 0:e.call(null),gateway:null===(n=ve.current.getValue)||void 0===n?void 0:n.call(null),gatewayInterface:de,networks:H.map((function(e){var n,r,o=e.inputUUID,i=e.interfaces,u=e.ipAddressInputRef,c=e.name,l=e.subnetMaskInputRef,s=e.type,f=e.typeCount;return{inputUUID:o,interfaces:i,ipAddress:null!==(t=null===(n=null===u||void 0===u?void 0:u.current.getValue)||void 0===n?void 0:n.call(null))&&void 0!==t?t:"",name:c,subnetMask:null!==(a=null===(r=null===l||void 0===l?void 0:l.current.getValue)||void 0===r?void 0:r.call(null))&&void 0!==a?a:"",type:s,typeCount:f}}))}}}}),[de,H]);var He,_e="13em";return we?(0,r.jsx)(V.Z,{}):(0,r.jsxs)(o.Z,{onMouseDown:function(e){var n=e.clientX,t=e.clientY,r=e.currentTarget.getBoundingClientRect(),o=r.left,a=r.top;M({x:n-o,y:t-a})},onMouseLeave:Fe,onMouseMove:Le,onMouseUp:Ve,sx:G({position:"relative"},Ee),children:[Te,(0,r.jsxs)(o.Z,{sx:{display:"flex",flexDirection:"column","& > :not(:first-child, :nth-child(3))":{marginTop:"1em"}},children:[(0,r.jsx)(d._,{autoHeight:!0,columns:ce((function(e){se(e)}),U),componentsProps:{row:{onMouseDown:function(e){var n=e.target,t=(void 0===n?{}:n).parentElement,r=(void 0===t?{}:t).dataset,o=(void 0===r?{}:r).id,a=void 0===o?void 0:o;if(a){var i=U[a],u=i.isApplied,c=i.metadata;u||se(c)}}}},disableColumnMenu:!0,disableSelectionOnClick:!0,getRowClassName:function(e){var n,t=e.row.networkInterfaceUUID,r="";return(null!==(n=U[t])&&void 0!==n&&n).isApplied||(r+=" ".concat($.ifaceNotApplied)),r},getRowId:function(e){return e.networkInterfaceUUID},hideFooter:!0,rows:ye,sx:(He={color:h.s7},B(He,"& .".concat(u.Z.root),{color:"inherit"}),B(He,"& .".concat(p._.cell,":focus"),{outline:"none"}),B(He,"& .".concat(p._.row,".").concat($.ifaceNotApplied,":hover"),B({cursor:"grab"},"& .".concat(p._.cell," p"),{cursor:"auto"})),He)}),(0,r.jsx)(D.Z,{row:!0,sx:{"& > :first-child":{alignSelf:"start",marginTop:".7em"},"& > :last-child":{flexGrow:1}},children:(0,r.jsx)(o.Z,{sx:{alignItems:"strech",display:"flex",flexDirection:"row",overflowX:"auto",paddingLeft:".3em","& > div":{marginBottom:".8em",marginTop:".4em",minWidth:_e,width:"25%"},"& > :not(:first-child)":{marginLeft:"1em"}},children:H.map((function(e,n){var t=e.inputUUID;return(0,r.jsx)(le,{createDropMouseUpHandler:Re,getNetworkTypeCount:Ne,hostDetail:i,networkIndex:n,networkInput:e,networkInterfaceCount:ye.length,networkInterfaceInputMap:U,removeNetwork:Ae,setMessageRe:Ie,setNetworkInputs:q,setNetworkInterfaceInputMap:T,testInput:Ze,testInputToToggleSubmitDisabled:Ue},"network-".concat(t))}))})}),(0,r.jsxs)(D.Z,{sm:"row",sx:{marginTop:".2em","& > :not(button)":{minWidth:_e,width:{sm:"25%"}}},children:[(0,r.jsx)(A.Z,{disabled:xe,onClick:Pe,children:(0,r.jsx)(f.Z,{})}),(0,r.jsx)(N.Z,{input:(0,r.jsx)(E.Z,{id:"network-init-gateway",inputProps:{onBlur:function(e){var n=e.target.value;Ze({inputs:B({},ee,{value:n})})}},inputLabelProps:{isNotifyRequired:!0},onChange:function(e){var n=e.target.value;Ue({inputs:B({},ee,{value:n})}),Ce()},label:"Gateway",value:y}),ref:ve}),(0,r.jsx)(N.Z,{input:(0,r.jsx)(E.Z,{id:"network-init-dns-csv",inputProps:{onBlur:function(e){var n=e.target.value;Ze({inputs:B({},Q,{value:n})})}},inputLabelProps:{isNotifyRequired:!0},onChange:function(e){var n=e.target.value;Ue({inputs:B({},Q,{value:n})}),je()},label:"Domain name server(s)",value:s}),ref:me})]}),(0,r.jsx)(R.Z,{count:1,defaultMessageType:"warning",ref:be})]})]})}));se.defaultProps={hostDetail:void 0,toggleSubmitDisabled:void 0},se.displayName="NetworkInitForm";var fe=se},3106:function(e,n){n.Z={bcn:"Back-Channel Network",ifn:"Internet-Facing Network",mn:"Migration Network",sn:"Storage Network"}}}]); |