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
25 KiB
1 lines
25 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),i=t(7169);function a(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){a(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={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[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:i.n_,height:"100%",width:"1.4em"},a(n,"&.".concat(s.ok),{backgroundColor:i.Ej}),a(n,"&.".concat(s.warning),{backgroundColor:i.Wd}),a(n,"&.".concat(s.error),{backgroundColor:i.hM}),a(n,"&.".concat(s.off),{backgroundColor:i.s7}),n),l)}))}},5741:function(e,n,t){var r=t(5893),o=t(1714),i=t(122),a=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={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[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)(i.Z,l({underline:"hover",variant:"subtitle1"},c,{sx:l({color:a.lD,textDecorationColor:a.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),i=t(2734),a=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),y=t(7169),h=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={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var U=function(e){var n=e.isFloating,t=e.networkInterface,i=t.networkInterfaceName,a=t.networkInterfaceState,u=e.onClose,c=e.sx,l=M(e,["isFloating","networkInterface","onClose","sx"]),f=n?{borderColor:y.s7,borderRadius:y.n_,borderStyle:"solid",borderWidth:"1px",backgroundColor:y.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"===a?"ok":"off",sx:{height:"auto"}}),(0,r.jsx)(j.Ac,{text:i}),u&&(0,r.jsx)(k.Z,{onClick:u,size:"small",sx:{color:y.s7},children:(0,r.jsx)(s.Z,{})})]}))};U.defaultProps={isFloating:!1,onClose:void 0};var Z=U,D=(0,t(1496).ZP)(o.Z)((function(){return{borderColor:y.s7,borderStyle:"dashed",borderWidth:"4px",display:"flex",flexDirection:"column",padding:".6em","& > :not(:first-child)":{marginTop:".3em"}}})),S=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},q=t(7987);function _(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,i=[],a=!0,u=!1;try{for(t=t.call(e);!(a=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);a=!0);}catch(c){u=!0,o=c}finally{try{a||null==t.return||t.return()}finally{if(u)throw o}}return i}}(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 _(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 _(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)?_(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(h.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(h.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(h.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")},ie=function(e){return"".concat(e,"NetworkSubnetConflict")},ae=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 i,a=t.row,u=(null!==(i=n[a.networkInterfaceUUID])&&void 0!==i&&i).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,[a].concat(W(t)))},d=(0,r.jsx)(c.Z,{});return u&&(s="auto",f=void 0,d=(0,r.jsx)(l.Z,{sx:{color:y.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,i=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:i})]})},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,i.Z)(),O=(0,a.Z)(C.breakpoints.up("md")),M=(0,a.Z)(C.breakpoints.up("lg")),U=(0,m.useRef)({}),S=(0,m.useRef)({}),P=d.inputUUID,R=d.interfaces,F=d.ipAddress,V=d.isRequired,H=d.subnetMask,q=d.type,_=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 ie(X)}),[X]),Q=(0,m.useMemo)((function(){return"node"===c}),[c]),ee=(0,m.useMemo)((function(){return!Q&&p<=2?[1]:ae}),[Q,p]),re=(0,m.useMemo)((function(){var e=h.Z.bcn,n=h.Z.ifn,t=h.Z.mn,r=h.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===U&&n===S||(d.ipAddressInputRef=U,d.subnetMaskInputRef=S,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],i=t(r,{lastIndex:l});return r!==q&&(i+=1),{value:r,displayValue:"".concat(o," ").concat(i)}})),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(h.Z[r]," ").concat(o),w((function(e){return W(e)}))},renderValue:M?void 0:function(e){return"".concat(String(e).toUpperCase()," ").concat(_)},value:q}}),!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),i=e-1,a=R[i],u=(null!==a&&void 0!==a?a:{}).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:y.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)(D,{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,i))||void 0===o||o.call.apply(o,[null].concat(W(t))),I({inputs:B({},$,{isIgnoreOnCallbacks:!1}),isContinueOnFailure:!0})},children:a?(0,r.jsx)(Z,{networkInterface:a,onClose:function(){R[i]=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:U}),(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:S})]})]})};le.defaultProps={createDropMouseUpHandler:void 0,hostDetail:void 0};var se=(0,m.forwardRef)((function(e,n){var t,i,a=e.expectHostDetail,c=void 0!==a&&a,l=e.hostDetail,s=e.toggleSubmitDisabled,k=null!==l&&void 0!==l?l:{},I=k.hostType,j=k.hostUUID,C=void 0===j?"local":j,O=(0,m.useMemo)((function(){return"node"===I?Y:K}),[I]),M=(0,m.useMemo)((function(){return"node"===I?{bcn:1,ifn:1,sn:1}:{bcn:1,ifn:1}}),[I]),U=(0,m.useState)({x:0,y:0}),D=U[0],T=U[1],L=(0,m.useState)({}),H=L[0],_=L[1],X=(0,m.useState)(O),ae=X[0],se=X[1],fe=(0,m.useState)(),de=fe[0],pe=fe[1],ve=(0,m.useState)(""),me=ve[0],be=ve[1],ge=(0,m.useRef)({}),ye=(0,m.useRef)({}),he=(0,m.useRef)(!0),we=(0,m.useRef)({}),xe=(0,F.Z)("".concat(g.Z,"/init/network-interface/").concat(C),{refreshInterval:2e3,onSuccess:function(e){var n=e.reduce((function(e,n){var t,r=n.networkInterfaceUUID;return e[r]=null!==(t=H[r])&&void 0!==t?t:{metadata:n},e}),{});_(n)}}),ke=xe.data,Ie=void 0===ke?[]:ke,je=xe.isLoading,Ce=(0,m.useMemo)((function(){return ae.length>=Ie.length||Object.values(H).every((function(e){return e.isApplied}))||"node"===I&&Ie.length<=6}),[I,ae,Ie,H]),Oe=(0,m.useMemo)((function(){return c&&!l}),[c,l]),Me=(0,m.useCallback)((function(e,n){var t;return null===(t=we.current.setMessage)||void 0===t?void 0:t.call(null,e,n)}),[]),Ue=(0,m.useCallback)((function(e,n){var t;return null===(t=we.current.setMessageRe)||void 0===t?void 0:t.call(null,e,n)}),[]),Ze=(0,m.useCallback)((function(e){return Me(Q,e)}),[Me]),De=(0,m.useCallback)((function(e){return Me(ee,e)}),[Me]),Se=(0,m.useCallback)((function(e){var n,t=e.fn,r=void 0===t?"every":t,o=e.ip,i=void 0===o?"":o,a=e.mask,u=void 0===a?"":a,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(i,"/").concat(u))}catch(m){}return ae[r]((function(e){var t,r,o=e.inputUUID,a=e.ipAddressInputRef,u=e.subnetMaskInputRef;if(o===d)return p;var c=null===(t=null===a||void 0===a?void 0:a.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:i})}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}))}),[ae]),Pe=(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]}),Me("api",t)}))}),[Me]),Ae=(0,m.useMemo)((function(){var e,n=(B(e={},Q,{defaults:{getValue:function(){var e;return null===(e=ge.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:function(){Ze()}},tests:[{onFailure:function(){Ze({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:q.HJ}]}),B(e,ee,{defaults:{getValue:function(){var e;return null===(e=ye.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:function(){De()}},tests:[{onFailure:function(){De({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=Se({fn:"some",ip:n,onMatch:function(e){var r=e.ipAddress,o=e.name,i=e.type,a=e.typeCount;if(n===r)return t=!1,void De({children:"Gateway cannot be the same as IP address in ".concat(o,".")});be("".concat(i).concat(a))}});return r||De({children:"Gateway must be in one network's subnet."}),r&&t}},{test:q.HJ}]}),e);return ae.forEach((function(e){var t,r,o=e.inputUUID,i=e.interfaces,a=e.ipAddressInputRef,u=e.name,c=e.subnetMaskInputRef,l=ue(o),s=ne(l),f=te(l),d=oe(l),p=function(e){return Me(s,e)},v=function(e){return Me(f,e)},m=function(e){return Me(d,e)},b=function(e,n,t){var r,o="".concat(ie(l),"-").concat(n),i="".concat(ie(ue(n)),"-").concat(e);Me((null===(r=we.current.exists)||void 0===r?void 0:r.call(null,i))?i:o,t)},g=function(e){var n=e.ip,i=void 0===n?null===(t=null===a||void 0===a?void 0:a.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 Se({ip:i,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 i.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===a||void 0===a?void 0:a.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:q.HJ}]},n[re(l)]={defaults:{value:u},tests:[{test:q.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:q.HJ}]}})),n}),[ae,Ze,De,Me,Se]),Ne=(0,m.useMemo)((function(){return(0,q.LT)(Ae)}),[Ae]),Re=(0,m.useCallback)((function(e){null===s||void 0===s||s.call(null,Ne(G({isIgnoreOnCallbacks:!0,isTestAll:!0},e)))}),[Ne,s]),Ee=(0,m.useCallback)((function(){pe(void 0)}),[]),Te=(0,m.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.inputUUID,t=void 0===n?(0,b.Z)():n,r=e.interfaces,o=void 0===r?W(z):r,i=e.ipAddress,a=void 0===i?"":i,u=e.name,c=void 0===u?"Unknown Network":u,l=e.subnetMask,f=void 0===l?"":l,d=e.type,p=void 0===d?"":d,v=e.typeCount,m=void 0===v?0:v;ae.unshift({inputUUID:t,interfaces:o,ipAddress:a,name:c,subnetMask:f,type:p,typeCount:m}),null===s||void 0===s||s.call(null,!1),se(W(ae))}),[ae,s]),Fe=(0,m.useCallback)((function(e){var n=J(ae.splice(e,1),1)[0],t=n.inputUUID;n.interfaces.forEach((function(e){if(void 0!==e){var n=e.networkInterfaceUUID;H[n].isApplied=!1}})),Re({excludeTestIdsRe:RegExp(t)}),se(W(ae)),_((function(e){return G({},e)}))}),[ae,H,Re]),Le=(0,m.useCallback)((function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.inputs,r=void 0===t?ae:t,o=n.lastIndex,i=void 0===o?0:o,a=0,u=r.length-1;u>=i;u-=1)r[u].type===e&&(a+=1);return a}),[ae]),Ve=(0,m.useMemo)((function(){if(void 0!==de){var e=de.networkInterfaceUUID;return function(n,t){return function(){var r,o=(null!==(r=n[t])&&void 0!==r?r:{}).networkInterfaceUUID;o&&o!==e&&(H[o].isApplied=!1),n[t]=de,H[e].isApplied=!0}}}}),[de,H]),He=(0,m.useMemo)((function(){return de?{cursor:"grabbing",userSelect:"none"}:{}}),[de]),qe=(0,m.useMemo)((function(){if(void 0===de)return(0,r.jsx)(r.Fragment,{});var e=D.x,n=D.y;return(0,r.jsx)(Z,{isFloating:!0,networkInterface:de,sx:{left:"calc(".concat(e,"px + .4em)"),position:"absolute",top:"calc(".concat(n,"px - 1.6em)"),zIndex:20}})}),[D,de]),_e=(0,m.useMemo)((function(){return de?function(){Ee()}:void 0}),[Ee,de]),Be=(0,m.useMemo)((function(){return de?function(e){var n=e.currentTarget,t=e.nativeEvent,r=t.clientX,o=t.clientY,i=n.getBoundingClientRect(),a=i.left,u=i.top;T({x:r-a,y:o-u})}:void 0}),[de]),Ge=(0,m.useMemo)((function(){return de?function(){Ee()}:void 0}),[Ee,de]);(0,m.useEffect)((function(){if([Object.keys(H).length>0,c,l,he.current,ge.current,ye.current].every((function(e){return Boolean(e)}))){var e,n;he.current=!1;var t=l.dns,r=l.gateway,o=l.gatewayInterface,i=l.networks;null===(e=ge.current.setValue)||void 0===e||e.call(null,t),null===(n=ye.current.setValue)||void 0===n||n.call(null,r);var a=[],u=Object.values(i).reduce((function(e,n){var t,r,o=n.ip,i=n.link1Uuid,u=n.link2Uuid,c=void 0===u?"":u,l=n.subnetMask,s=n.type,f=Le(s,{inputs:e})+1,d=M[s]===f,p="".concat(h.Z[s]," ").concat(f);return a.push(i,c),e.push({inputUUID:(0,b.Z)(),interfaces:[null===(t=H[i])||void 0===t?void 0:t.metadata,null===(r=H[c])||void 0===r?void 0:r.metadata],ipAddress:o,isRequired:d,name:p,subnetMask:l,type:s,typeCount:f}),e}),[]);be(o),_((function(e){var n=G({},e);return a.forEach((function(e){n[e]&&(n[e].isApplied=!0)})),n})),se(u),Re()}}),[Te,c,Le,l,ae,H,M,Re]),(0,m.useEffect)((function(){return Pe(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(){Pe(0)}}),[Pe]),(0,m.useImperativeHandle)(n,(function(){return G({},we.current,{get:function(){var e,n;return{dns:null===(e=ge.current.getValue)||void 0===e?void 0:e.call(null),gateway:null===(n=ye.current.getValue)||void 0===n?void 0:n.call(null),gatewayInterface:me,networks:ae.map((function(e){var n,r,o=e.inputUUID,a=e.interfaces,u=e.ipAddressInputRef,c=e.name,l=e.subnetMaskInputRef,s=e.type,f=e.typeCount;return{inputUUID:o,interfaces:a,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!==(i=null===(r=null===l||void 0===l?void 0:l.current.getValue)||void 0===r?void 0:r.call(null))&&void 0!==i?i:"",type:s,typeCount:f}}))}}})}),[me,ae]);var Je,We="13em";return je?(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,i=r.top;T({x:n-o,y:t-i})},onMouseLeave:_e,onMouseMove:Be,onMouseUp:Ge,sx:G({position:"relative"},He),children:[qe,(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){pe(e)}),H),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,i=void 0===o?void 0:o;if(i){var a=H[i],u=a.isApplied,c=a.metadata;u||pe(c)}}}},disableColumnMenu:!0,disableSelectionOnClick:!0,getRowClassName:function(e){var n,t=e.row.networkInterfaceUUID,r="";return(null!==(n=H[t])&&void 0!==n&&n).isApplied||(r+=" ".concat($.ifaceNotApplied)),r},getRowId:function(e){return e.networkInterfaceUUID},hideFooter:!0,rows:Ie,sx:(Je={color:y.s7},B(Je,"& .".concat(u.Z.root),{color:"inherit"}),B(Je,"& .".concat(p._.cell,":focus"),{outline:"none"}),B(Je,"& .".concat(p._.row,".").concat($.ifaceNotApplied,":hover"),B({cursor:"grab"},"& .".concat(p._.cell," p"),{cursor:"auto"})),Je)}),!Oe&&(0,r.jsx)(S.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:We,width:"25%"},"& > :not(:first-child)":{marginLeft:"1em"}},children:ae.map((function(e,n){var t=e.inputUUID;return(0,r.jsx)(le,{createDropMouseUpHandler:Ve,getNetworkTypeCount:Le,hostDetail:l,networkIndex:n,networkInput:e,networkInterfaceCount:Ie.length,networkInterfaceInputMap:H,removeNetwork:Fe,setMessageRe:Ue,setNetworkInputs:se,setNetworkInterfaceInputMap:_,testInput:Ne,testInputToToggleSubmitDisabled:Re},"network-".concat(t))}))})}),(0,r.jsxs)(S.Z,{sm:"row",sx:{marginTop:".2em","& > :not(button)":{minWidth:We,width:{sm:"25%"}}},children:[(0,r.jsx)(A.Z,{disabled:Ce,onClick:function(){Te()},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;Ne({inputs:B({},ee,{value:n})})}},inputLabelProps:{isNotifyRequired:!0},onChange:function(e){var n=e.target.value;Re({inputs:B({},ee,{value:n})}),De()},label:"Gateway"}),ref:ye}),(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;Ne({inputs:B({},Q,{value:n})})}},inputLabelProps:{isNotifyRequired:!0},onChange:function(e){var n=e.target.value;Re({inputs:B({},Q,{value:n})}),Ze()},label:"Domain name server(s)"}),ref:ge})]}),(0,r.jsx)(R.Z,{count:1,defaultMessageType:"warning",ref:we})]})]})}));se.defaultProps={expectHostDetail:!1,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"}}}]); |