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
32 KiB
1 lines
32 KiB
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[86],{1939:function(e,n,t){var r=t(5893),o=t(7357),i=t(7169);function u(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(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){u(e,n,t[n])}))}return e}function l(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 c="Decorator",s={ok:"".concat(c,"-ok"),warning:"".concat(c,"-warning"),error:"".concat(c,"-error"),off:"".concat(c,"-off")};n.Z=function(e){var n,t=e.colour,c=e.sx,f=l(e,["colour","sx"]);return(0,r.jsx)(o.Z,a({},f,{className:s[t],sx:a((n={borderRadius:i.n_,height:"100%",width:"1.4em"},u(n,"&.".concat(s.ok),{backgroundColor:i.Ej}),u(n,"&.".concat(s.warning),{backgroundColor:i.Wd}),u(n,"&.".concat(s.error),{backgroundColor:i.hM}),u(n,"&.".concat(s.off),{backgroundColor:i.s7}),n),c)}))}},5741:function(e,n,t){var r=t(5893),o=t(1714),i=t(122),u=t(7169),a=t(4690);function l(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(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){l(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,l=s(e,["children","sx"]);return(0,r.jsx)(i.Z,c({underline:"hover",variant:"subtitle1"},l,{sx:c({color:u.lD,textDecorationColor:u.s7},t),children:(0,r.jsxs)(a.Z,{row:!0,children:[n,(0,r.jsx)(o.Z,{sx:{marginLeft:".3em"}})]})}))}},4427:function(e,n,t){var r=t(5893),o=t(2429),i=t(9309),u=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 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){a(e,n,t[n])}))}return e}n.Z=function(e){var n,t,c=e.children,s=e.sx,f=l((a(t={backgroundColor:u.lD,paddingRight:"3em"},"&.".concat(o.Z.selected),(a(n={backgroundColor:u.s7,fontWeight:400},"&.".concat(o.Z.focusVisible),{backgroundColor:u.s7}),a(n,"&:hover",{backgroundColor:u.s7}),n)),a(t,"&.".concat(o.Z.focusVisible),{backgroundColor:u.s7}),a(t,"&:hover",{backgroundColor:u.s7}),t),s);return(0,r.jsx)(i.Z,l({},e,{sx:f,children:c}))}},4596:function(e,n,t){t.d(n,{Z:function(){return se}});var r=t(5893),o=t(7357),i=t(2734),u=t(8396),a=t(6239),l=t(9699),c=t(2026),s=t(5537),f=t(2428),d=t(8173),v=t(3490),p=t(8951),b=t(7294),m=t(5934),g=t(2029),y=t(7169),h=t(3106),k=t(1250),w=t(4799),x=t(1939),j=t(7750);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 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){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={},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 Z=function(e){var n=e.isFloating,t=e.networkInterface,i=t.networkInterfaceName,u=t.networkInterfaceState,a=e.onClose,l=e.sx,c=C(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,l)},c,{children:[(0,r.jsx)(x.Z,{colour:"up"===u?"ok":"off",sx:{height:"auto"}}),(0,r.jsx)(j.Ac,{text:i}),a&&(0,r.jsx)(w.Z,{onClick:a,size:"small",sx:{color:y.s7},children:(0,r.jsx)(s.Z,{})})]}))};Z.defaultProps={isFloating:!1,onClose:void 0};var M=Z,S=(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"}}})),P=t(4690),D=t(1706),U=t(4069),A=t(7869),N=t(6284),R=t(3679),E=t(1905),V=t(2519),T=t(634),F=t(2152),L=t(2027);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 H(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 _(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}function W(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=[],u=!0,a=!1;try{for(t=t.call(e);!(u=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);u=!0);}catch(l){a=!0,o=l}finally{try{u||null==t.return||t.return()}finally{if(a)throw o}}return i}}(e,n)||$(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 G(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)||$(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 $(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 J={ifaceNotApplied:"".concat("NetworkInitForm","-network-interface-not-applied")},z=[void 0,void 0],X="dns",K="gateway",Y=function(e){return"".concat(e,"Interface")},Q=function(e){return"".concat(e,"IPAddress")},ee=function(e){return"".concat(e,"Name")},ne=function(e){return"".concat(e,"SubnetMask")},te=function(e){return"".concat(e,"NetworkSubnetConflict")},re=Array.from({length:2},(function(e,n){return n+1})),oe={bcn:{ip:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"10.20".concat(e,".").concat(n)},mask:"255.255.0.0"},ifn:{ip:function(){return""},mask:""},mn:{ip:function(){return"10.199."},mask:"255.255.0.0"},sn:{ip:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"10.10".concat(e,".").concat(n)},mask:"255.255.0.0"}},ie=function(e){return"network".concat(e)},ue=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.inputUUID,t=void 0===n?(0,m.Z)():n,r=e.interfaces,o=void 0===r?G(z):r,i=e.ipAddress,u=void 0===i?"":i,a=e.name,l=e.subnetMask,c=void 0===l?"":l,s=e.type,f=void 0===s?"":s,d=e.typeCount,v=void 0===d?0:d,p=_(e,["inputUUID","interfaces","ipAddress","name","subnetMask","type","typeCount"]),b=a;return a||(b=h.Z[f]&&v>0?"".concat(h.Z[f]," ").concat(v):"Unknown Network"),H({inputUUID:t,interfaces:o,ipAddress:u,name:b,subnetMask:c,type:f,typeCount:v},p)},ae=function(e,n){return[{align:"center",field:"",renderCell:function(t){var i,u=t.row,a=(null!==(i=n[u.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,[u].concat(G(t)))},d=(0,r.jsx)(l.Z,{});return a&&(s="auto",f=void 0,d=(0,r.jsx)(c.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)(x.Z,{colour:"up"===t?"ok":"off",sx:{height:"auto"}}),(0,r.jsx)(j.KI,{text:i})]})}},{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.allowMigrationNetwork,t=e.createDropMouseUpHandler,a=e.getNetworkTypeCount,l=e.hostDetail,c=void 0===l?{}:l,d=c.hostType,v=c.sequence,p=e.networkIndex,m=e.networkInput,g=e.networkInterfaceCount,k=e.networkInterfaceInputMap,w=e.removeNetwork,x=e.setMessageRe,I=e.setNetworkInputs,O=e.setNetworkInterfaceInputMap,C=e.testInput,Z=e.testInputToToggleSubmitDisabled,P=(0,i.Z)(),A=(0,u.Z)(P.breakpoints.up("md")),E=(0,u.Z)(P.breakpoints.up("lg")),T=(0,b.useRef)({}),F=(0,b.useRef)({}),L=m.inputUUID,q=m.interfaces,_=m.ipAddress,$=m.isRequired,J=m.subnetMask,z=m.type,X=m.typeCount,K=(0,b.useMemo)((function(){return ie(L)}),[L]),ee=(0,b.useMemo)((function(){return Y(K)}),[K]),ue=(0,b.useMemo)((function(){return Q(K)}),[K]),ae=(0,b.useMemo)((function(){return ne(K)}),[K]),le=(0,b.useMemo)((function(){return te(K)}),[K]),ce=(0,b.useMemo)((function(){return"node"===d}),[d]),se=(0,b.useMemo)((function(){return!ce&&g<=2?[1]:re}),[ce,g]),fe=(0,b.useMemo)((function(){var e=h.Z.bcn,t=h.Z.ifn,r=h.Z.mn,o=h.Z.sn;return ce&&g>=8&&(n||"mn"===z)?{bcn:e,ifn:t,mn:r,sn:o}:{bcn:e,ifn:t,sn:o}}),[n,ce,g,z]),de=(0,b.useCallback)((function(e,n,t){var r=T.current,o=r.getIsChangedByUser,i=r.setValue,u=F.current,a=u.getIsChangedByUser,l=u.setValue;(null===o||void 0===o?void 0:o.call(null))||(e.ipAddress=n,null===i||void 0===i||i.call(null,n)),(null===a||void 0===a?void 0:a.call(null))||(e.subnetMask=t,null===l||void 0===l||l.call(null,t))}),[]);return(0,b.useEffect)((function(){var e,n;"striker"===d&&"ifn"!==z&&(!(null===(e=T.current.getIsChangedByUser)||void 0===e?void 0:e.call(null))&&Number(v)&&(null===(n=T.current.setValue)||void 0===n||n.call(null,_.replace(/^((?:\d+\.){3})\d*$/,"$1".concat(v)))))}),[d,_,v,z]),(0,b.useEffect)((function(){var e=m.ipAddressInputRef,n=m.subnetMaskInputRef;e===T&&n===F||(m.ipAddressInputRef=T,m.subnetMaskInputRef=F,I((function(e){return G(e)})))}),[m,I]),(0,r.jsxs)(R.Lg,{children:[(0,r.jsxs)(R.CH,{children:[(0,r.jsx)(V.Z,{id:"network-".concat(L,"-name"),isReadOnly:$,inputLabelProps:{isNotifyRequired:!0},label:"Network name",selectItems:Object.entries(fe).map((function(e){var n=W(e,2),t=n[0],r=n[1],o=a(t,{lastIndex:p});return t!==z&&(o+=1),{value:t,displayValue:"".concat(r," ").concat(o)}})),selectProps:{onChange:function(e){var n=e.target.value,t=String(n);m.type=t;var r=a(t,{lastIndex:p});m.typeCount=r,m.name="".concat(h.Z[t]," ").concat(r);var o=oe[t];if(o){var i,u=o.ip,l=o.mask;"striker"===d&&"bcn"===t&&(i="4."),de(m,u(r,i),l)}I((function(e){return G(e)}))},renderValue:E?void 0:function(e){return"".concat(String(e).toUpperCase()," ").concat(X)},value:z}}),!$&&(0,r.jsx)(D.Z,{onClick:function(){w(p)},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:[se.map((function(e){var n="Link ".concat(e),i=e-1,u=q[i],a=(null!==u&&void 0!==u?u:{}).networkInterfaceUUID,l=void 0===a?"":a,c=A?(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:n}),(0,r.jsx)(S,{onMouseUp:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var o;null===(o=null===t||void 0===t?void 0:t.call(null,q,i))||void 0===o||o.call.apply(o,[null].concat(G(n))),Z({inputs:B({},ee,{isIgnoreOnCallbacks:!1}),isContinueOnFailure:!0})},children:u?(0,r.jsx)(M,{networkInterface:u,onClose:function(){q[i]=void 0,k[l].isApplied=!1,O((function(e){return H({},e)})),Z({inputs:B({},ee,{isIgnoreOnCallbacks:!1}),isContinueOnFailure:!0})}},"network-interface-".concat(l)):c})]},"network-".concat(L,"-link-").concat(e))})),(0,r.jsx)(U.Z,{input:(0,r.jsx)(N.Z,{id:"network-".concat(L,"-ip-address"),inputProps:{onBlur:function(e){var n=e.target.value;C({inputs:B({},ue,{value:n})})}},inputLabelProps:{isNotifyRequired:!0},label:"IP address",onChange:function(e){var n=e.target.value;Z({inputs:B({},ue,{value:n})}),x(RegExp("(?:^(?:".concat(ue,"|").concat(le,")|").concat(L,"$)")))},value:_}),ref:T}),(0,r.jsx)(U.Z,{input:(0,r.jsx)(N.Z,{id:"network-".concat(L,"-subnet-mask"),inputProps:{onBlur:function(e){var n=e.target.value;C({inputs:B({},ae,{value:n})})}},inputLabelProps:{isNotifyRequired:!0},label:"Subnet mask",onChange:function(e){var n=e.target.value;Z({inputs:B({},ae,{value:n})}),x(RegExp("(?:^(?:".concat(ae,"|").concat(le,")|").concat(L,"$)")))},value:J}),ref:F})]})]})};le.defaultProps={allowMigrationNetwork:!0,createDropMouseUpHandler:void 0,hostDetail:void 0};var ce=(0,b.forwardRef)((function(e,n){var t,i=e.expectHostDetail,u=void 0!==i&&i,l=e.hostDetail,c=e.hostSequence,s=e.toggleSubmitDisabled,w="local",x=c;if(u){if(l){var j;t=(j=l).hostType,w=j.hostUUID,x=j.sequence}}else t="striker";var I,O,C=(0,b.useMemo)((function(){var e=[];if("striker"===t){var n=x?"10.201.4.".concat(x):"10.201.4.";return e.push(ue({ipAddress:n,isRequired:!0,subnetMask:"255.255.0.0",type:"bcn",typeCount:1}),ue({isRequired:!0,type:"ifn",typeCount:1})),e}return e.push(ue({ipAddress:"10.201.",isRequired:!0,subnetMask:"255.255.0.0",type:"bcn",typeCount:1}),ue({isRequired:!0,type:"ifn",typeCount:1}),ue({ipAddress:"10.101.",isRequired:!0,subnetMask:"255.255.0.0",type:"sn",typeCount:1})),e}),[t,x]),Z=(0,b.useMemo)((function(){return"node"===t?{bcn:1,ifn:1,sn:1}:{bcn:1,ifn:1}}),[t]),S=(0,b.useState)({x:0,y:0}),R=S[0],V=S[1],q=(0,b.useState)({}),_=q[0],$=q[1],z=(0,b.useState)(C),re=z[0],oe=z[1],ce=(0,b.useState)(),se=ce[0],fe=ce[1],de=(0,b.useState)(""),ve=de[0],pe=de[1],be=(0,b.useRef)({}),me=(0,b.useRef)({}),ge=(0,b.useRef)(!0),ye=(0,b.useRef)({}),he=(0,E.Z)("".concat(g.Z,"/init/network-interface/").concat(w),{refreshInterval:2e3,onSuccess:function(e){var n=e.reduce((function(e,n){var t,r=n.networkInterfaceUUID;return e[r]=null!==(t=_[r])&&void 0!==t?t:{metadata:n},e}),{});$(n)}}),ke=he.data,we=void 0===ke?[]:ke,xe=he.isLoading,je=(0,b.useMemo)((function(){return re.length>=we.length||Object.values(_).every((function(e){return e.isApplied}))||"node"===t&&we.length<=6}),[t,re,we,_]),Ie=(0,b.useMemo)((function(){return u&&!l}),[u,l]),Oe=(0,b.useMemo)((function(){return re.every((function(e){return"mn"!==e.type}))}),[re]),Ce=(0,b.useCallback)((function(e,n){var t;return null===(t=ye.current.setMessage)||void 0===t?void 0:t.call(null,e,n)}),[]),Ze=(0,b.useCallback)((function(e,n){var t;return null===(t=ye.current.setMessageRe)||void 0===t?void 0:t.call(null,e,n)}),[]),Me=(0,b.useCallback)((function(e){return Ce(X,e)}),[Ce]),Se=(0,b.useCallback)((function(e){return Ce(K,e)}),[Ce]),Pe=(0,b.useCallback)((function(e){var n,t=e.fn,r=void 0===t?"every":t,o=e.ip,i=void 0===o?"":o,u=e.mask,a=void 0===u?"":u,l=e.isNegateMatch,c=void 0===l?"every"===r:l,s=e.onMatch,f=e.onMiss,d=e.skipUUID,v="every"===r;try{n=new p.Netmask("".concat(i,"/").concat(a))}catch(b){}return re[r]((function(e){var t,r,o=e.inputUUID,u=e.ipAddressInputRef,a=e.subnetMaskInputRef;if(o===d)return v;var l=null===(t=null===u||void 0===u?void 0:u.current.getValue)||void 0===t?void 0:t.call(null),m=null===(r=null===a||void 0===a?void 0:a.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 p.Netmask("".concat(l,"/").concat(m)),{b:n,bIP:i})}catch(b){}return g?null===s||void 0===s||s.call(null,e):null===f||void 0===f||f.call(null,e),c?!g:g}))}),[re]),De=(0,b.useCallback)((function(e){Ce("api",e)}),[Ce]),Ue=(0,b.useMemo)((function(){var e,n=(B(e={},X,{defaults:{getValue:function(){var e;return null===(e=be.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:function(){Me()}},tests:[{onFailure:function(){Me({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 k.ah.test(n)}},{test:L.HJ}]}),B(e,K,{defaults:{getValue:function(){var e;return null===(e=me.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:function(){Se()}},tests:[{onFailure:function(){Se({children:"Gateway should be a valid IPv4 address."})},test:function(e){var n=e.value;return k.tf.test(n)}},{test:function(e){var n=e.value,t=!0,r=Pe({fn:"some",ip:n,onMatch:function(e){var r=e.ipAddress,o=e.name,i=e.type,u=e.typeCount;if(n===r)return t=!1,void Se({children:"Gateway cannot be the same as IP address in ".concat(o,".")});pe("".concat(i).concat(u))}});return r||Se({children:"Gateway must be in one network's subnet."}),r&&t}},{test:L.HJ}]}),e);return re.forEach((function(e){var t,r,o=e.inputUUID,i=e.interfaces,u=e.ipAddressInputRef,a=e.name,l=e.subnetMaskInputRef,c=ie(o),s=Y(c),f=Q(c),d=ne(c),v=function(e){return Ce(s,e)},p=function(e){return Ce(f,e)},b=function(e){return Ce(d,e)},m=function(e,n,t){var r,o="".concat(te(c),"-").concat(n),i="".concat(te(ie(n)),"-").concat(e);Ce((null===(r=ye.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===u||void 0===u?void 0:u.current.getValue)||void 0===t?void 0:t.call(null):n,c=e.mask,s=void 0===c?null===(r=null===l||void 0===l?void 0:l.current.getValue)||void 0===r?void 0:r.call(null):c;return Pe({ip:i,mask:s,onMatch:function(e){var n=e.inputUUID,t=e.name;m(o,n,{children:'"'.concat(a,'" and "').concat(t,'" cannot be in the same subnet.')})},onMiss:function(e){var n=e.inputUUID;m(o,n)},skipUUID:o})};n[s]={defaults:{getCompare:function(){return i.map((function(e){return void 0!==e}))},onSuccess:function(){v()}},tests:[{onFailure:function(){v({children:"".concat(a," must have at least 1 interface.")})},test:function(e){return e.compare.some((function(e){return e}))}},{onFailure:function(){v({children:"".concat(a," must have a Link 1 interface.")})},test:function(e){var n=W(e.compare,2),t=n[0];return!(n[1]&&!t)}}]},n[f]={defaults:{getValue:function(){var e;return null===(e=null===u||void 0===u?void 0:u.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:function(){p()}},tests:[{onFailure:function(){p({children:"IP address in ".concat(a," must be a valid IPv4 address.")})},test:function(e){var n=e.value;return k.tf.test(n)}},{test:function(e){var n=e.value;return g({ip:n})}},{test:L.HJ}]},n[ee(c)]={defaults:{value:a},tests:[{test:L.HJ}]},n[d]={defaults:{getValue:function(){var e;return null===(e=null===l||void 0===l?void 0:l.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:function(){b()}},tests:[{onFailure:function(){b({children:"Subnet mask in ".concat(a," must be a valid IPv4 address.")})},test:function(e){var n=e.value;return k.tf.test(n)}},{test:function(e){var n=e.value;return g({mask:n})}},{test:L.HJ}]}})),n}),[re,Me,Se,Ce,Pe]),Ae=(0,b.useMemo)((function(){return(0,L.LT)(Ue)}),[Ue]),Ne=(0,b.useCallback)((function(e){null===s||void 0===s||s.call(null,Ae(H({isIgnoreOnCallbacks:!0,isTestAll:!0},e)))}),[Ae,s]),Re=(0,b.useCallback)((function(){fe(void 0)}),[]),Ee=(0,b.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};re.unshift(ue(e)),null===s||void 0===s||s.call(null,!1),oe(G(re))}),[re,s]),Ve=(0,b.useCallback)((function(e){var n=W(re.splice(e,1),1)[0],t=n.inputUUID;n.interfaces.forEach((function(e){if(void 0!==e){var n=e.networkInterfaceUUID;_[n].isApplied=!1}})),Ne({excludeTestIdsRe:RegExp(t)}),oe(G(re)),$((function(e){return H({},e)}))}),[re,_,Ne]),Te=(0,b.useCallback)((function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.inputs,r=void 0===t?re:t,o=n.lastIndex,i=void 0===o?0:o,u=0,a=r.length-1;a>=i;a-=1)r[a].type===e&&(u+=1);return u}),[re]),Fe=(0,b.useMemo)((function(){if(void 0!==se){var e=se.networkInterfaceUUID;return function(n,t){return function(){var r,o=(null!==(r=n[t])&&void 0!==r?r:{}).networkInterfaceUUID;o&&o!==e&&(_[o].isApplied=!1),n[t]=se,_[e].isApplied=!0}}}}),[se,_]),Le=(0,b.useMemo)((function(){return se?{cursor:"grabbing",userSelect:"none"}:{}}),[se]),qe=(0,b.useMemo)((function(){if(void 0===se)return(0,r.jsx)(r.Fragment,{});var e=R.x,n=R.y;return(0,r.jsx)(M,{isFloating:!0,networkInterface:se,sx:{left:"calc(".concat(e,"px + .4em)"),position:"absolute",top:"calc(".concat(n,"px - 1.6em)"),zIndex:20}})}),[R,se]),Be=(0,b.useMemo)((function(){return se?function(){Re()}:void 0}),[Re,se]),He=(0,b.useMemo)((function(){return se?function(e){var n=e.currentTarget,t=e.nativeEvent,r=t.clientX,o=t.clientY,i=n.getBoundingClientRect(),u=i.left,a=i.top;V({x:r-u,y:o-a})}:void 0}),[se]),_e=(0,b.useMemo)((function(){return se?function(){Re()}:void 0}),[Re,se]);(0,b.useEffect)((function(){if([Object.keys(_).length>0,u,l,ge.current,be.current,me.current].every((function(e){return Boolean(e)}))){var e,n;ge.current=!1;var t=l.dns,r=l.gateway,o=l.gatewayInterface,i=l.networks;if([t,r,o,i].some((function(e){return!e})))return;null===(e=be.current.setValue)||void 0===e||e.call(null,t),null===(n=me.current.setValue)||void 0===n||n.call(null,r);var a=[],c=Object.values(i).reduce((function(e,n){var t,r,o=n.ip,i=n.link1Uuid,u=n.link2Uuid,l=void 0===u?"":u,c=n.subnetMask,s=n.type,f=Te(s,{inputs:e})+1,d=Z[s]===f,v="".concat(h.Z[s]," ").concat(f);return a.push(i,l),e.push({inputUUID:(0,m.Z)(),interfaces:[null===(t=_[i])||void 0===t?void 0:t.metadata,null===(r=_[l])||void 0===r?void 0:r.metadata],ipAddress:o,isRequired:d,name:v,subnetMask:c,type:s,typeCount:f}),e}),[]);pe(o),$((function(e){var n=H({},e);return a.forEach((function(e){n[e]&&(n[e].isApplied=!0)})),n})),oe(c),Ne()}}),[u,Te,l,_,Z,Ne]),(0,b.useEffect)((function(){return(0,T.Z)(1,De),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(){(0,T.Z)(0,De)}}),[De]),(0,b.useImperativeHandle)(n,(function(){return H({},ye.current,{get:function(){var e,n;return{dns:null===(e=be.current.getValue)||void 0===e?void 0:e.call(null),gateway:null===(n=me.current.getValue)||void 0===n?void 0:n.call(null),gatewayInterface:ve,networks:re.map((function(e){var n,t,r=e.inputUUID,o=e.interfaces,i=e.ipAddressInputRef,u=e.name,a=e.subnetMaskInputRef,l=e.type,c=e.typeCount;return{inputUUID:r,interfaces:o,ipAddress:null!==(I=null===(n=null===i||void 0===i?void 0:i.current.getValue)||void 0===n?void 0:n.call(null))&&void 0!==I?I:"",name:u,subnetMask:null!==(O=null===(t=null===a||void 0===a?void 0:a.current.getValue)||void 0===t?void 0:t.call(null))&&void 0!==O?O:"",type:l,typeCount:c}}))}}})}),[ve,re]);var We,Ge="13em";return xe?(0,r.jsx)(F.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;V({x:n-o,y:t-i})},onMouseLeave:Be,onMouseMove:He,onMouseUp:_e,sx:H({position:"relative"},Le),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:ae((function(e){fe(e)}),_),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 u=_[i],a=u.isApplied,l=u.metadata;a||fe(l)}}}},disableColumnMenu:!0,disableSelectionOnClick:!0,getRowClassName:function(e){var n,t=e.row.networkInterfaceUUID,r="";return(null!==(n=_[t])&&void 0!==n&&n).isApplied||(r+=" ".concat(J.ifaceNotApplied)),r},getRowId:function(e){return e.networkInterfaceUUID},hideFooter:!0,initialState:{sorting:{sortModel:[{field:"networkInterfaceName",sort:"asc"}]}},rows:we,sx:(We={color:y.s7},B(We,"& .".concat(a.Z.root),{color:"inherit"}),B(We,"& .".concat(v._.cell,":focus"),{outline:"none"}),B(We,"& .".concat(v._.row,".").concat(J.ifaceNotApplied,":hover"),B({cursor:"grab"},"& .".concat(v._.cell," p"),{cursor:"auto"})),We)}),!Ie&&(0,r.jsx)(P.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:Ge,width:"25%"},"& > :not(:first-child)":{marginLeft:"1em"}},children:re.map((function(e,n){var o=e.inputUUID;return(0,r.jsx)(le,{allowMigrationNetwork:Oe,createDropMouseUpHandler:Fe,getNetworkTypeCount:Te,hostDetail:{hostType:t,sequence:x},networkIndex:n,networkInput:e,networkInterfaceCount:we.length,networkInterfaceInputMap:_,removeNetwork:Ve,setMessageRe:Ze,setNetworkInputs:oe,setNetworkInterfaceInputMap:$,testInput:Ae,testInputToToggleSubmitDisabled:Ne},"network-".concat(o))}))})}),(0,r.jsxs)(P.Z,{sm:"row",sx:{marginTop:".2em","& > :not(button)":{minWidth:Ge,width:{sm:"25%"}}},children:[(0,r.jsx)(D.Z,{disabled:je,onClick:function(){Ee()},children:(0,r.jsx)(f.Z,{})}),(0,r.jsx)(U.Z,{input:(0,r.jsx)(N.Z,{id:"network-init-gateway",inputProps:{onBlur:function(e){var n=e.target.value;Ae({inputs:B({},K,{value:n})})}},inputLabelProps:{isNotifyRequired:!0},onChange:function(e){var n=e.target.value;Ne({inputs:B({},K,{value:n})}),Se()},label:"Gateway"}),ref:me}),(0,r.jsx)(U.Z,{input:(0,r.jsx)(N.Z,{id:"network-init-dns-csv",inputProps:{onBlur:function(e){var n=e.target.value;Ae({inputs:B({},X,{value:n})})}},inputLabelProps:{isNotifyRequired:!0},onChange:function(e){var n=e.target.value;Ne({inputs:B({},X,{value:n})}),Me()},label:"Domain name server(s)"}),ref:be})]}),(0,r.jsx)(A.Z,{count:1,defaultMessageType:"warning",ref:ye})]})]})}));ce.defaultProps={expectHostDetail:!1,hostDetail:void 0,hostSequence:void 0,toggleSubmitDisabled:void 0},ce.displayName="NetworkInitForm";var se=ce},2519:function(e,n,t){t.d(n,{Z:function(){return Z}});var r=t(5893),o=t(5603),i=t(8128),u=t(3640),a=t(7294),l=t(1363),c=t(4427),s=t(9),f=t(192),d=t(5537),v=t(9558),p=t(6239),b=t(7021),m=t(1057),g=t(4799),y=t(3213),h=t(7169);function k(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function w(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){k(e,n,t[n])}))}return e}function x(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 j=function(e){var n=e.onClearIndicatorClick,t=x(e,["onClearIndicatorClick"]),i=t.sx,u=t.value,l=x(t,["sx","value"]),c=(0,a.useMemo)((function(){var e;return w((k(e={},"& .".concat(o.Z.icon),{color:h.s7}),k(e,"& .".concat(v.Z.root),{marginRight:".8em"}),k(e,"& .".concat(p.Z.root),{color:h.s7,visibility:"hidden"}),k(e,"&:hover .".concat(v.Z.root," .").concat(p.Z.root,",\n &.").concat(b.Z.focused," .").concat(v.Z.root," .").concat(p.Z.root),{visibility:"visible"}),e),i)}),[i]),s=(0,a.useMemo)((function(){return String(u).length>0&&n&&(0,r.jsx)(m.Z,{position:"end",children:(0,r.jsx)(g.Z,{onClick:n,children:(0,r.jsx)(d.Z,{fontSize:"small"})})})}),[n,u]);return(0,r.jsx)(y.Z,w({endAdornment:s,value:u},l,{sx:c}))};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 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){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={},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 Z=function(e){var n=e.id,t=e.label,d=e.selectItems,v=e.checkItem,p=e.disableItem,b=e.formControlProps,m=e.hideItem,g=e.inputLabelProps,y=void 0===g?{}:g,h=e.isReadOnly,k=void 0!==h&&h,w=e.messageBoxProps,x=void 0===w?{}:w,Z=e.name,M=e.onBlur,S=e.onChange,P=e.onFocus,D=e.required,U=e.selectProps,A=void 0===U?{}:U,N=A.multiple,R=A.sx,E=e.value,V=e.isCheckableItems,T=void 0===V?N:V,F=C(e.selectProps,["multiple","sx"]),L=(0,a.useMemo)((function(){return k?O(I({},"& .".concat(o.Z.icon),{visibility:"hidden"}),R):R}),[k,R]),q=(0,a.useCallback)((function(e){return T&&(0,r.jsx)(i.Z,{checked:null===v||void 0===v?void 0:v.call(null,e)})}),[v,T]),B=(0,a.useCallback)((function(e,t){return(0,r.jsxs)(c.Z,{disabled:null===p||void 0===p?void 0:p.call(null,e),sx:{display:(null===m||void 0===m?void 0:m.call(null,e))?"none":void 0},value:e,children:[q(e),t]},"".concat(n,"-").concat(e))}),[q,p,m,n]),H=(0,a.useMemo)((function(){return"".concat(n,"-select-element")}),[n]),_=(0,a.useMemo)((function(){return(0,r.jsx)(s.Z,{id:n,label:t})}),[n,t]),W=(0,a.useMemo)((function(){return t&&(0,r.jsx)(f.Z,O({htmlFor:H,isNotifyRequired:D},y,{children:t}))}),[y,D,t,H]),G=(0,a.useMemo)((function(){return d.map((function(e){var n="string"===typeof e?{value:e}:e,t=n.value,r=n.displayValue;return B(t,void 0===r?t:r)}))}),[B,d]);return(0,r.jsxs)(u.Z,O({fullWidth:!0},b,{children:[W,(0,r.jsx)(j,O({id:H,input:_,multiple:N,name:Z,onBlur:M,onChange:S,onFocus:P,readOnly:k,value:E},F,{sx:L,children:G})),(0,r.jsx)(l.Z,O({},x))]}))}},3106:function(e,n){n.Z={bcn:"Back-Channel Network",ifn:"Internet-Facing Network",mn:"Migration Network",sn:"Storage Network"}},634:function(e,n,t){var r=t(5893),o=t(4390),i=t(1770);n.Z=function(e,n){o.Z.put("/init/set-map-network",{value:e}).catch((function(t){var o=(0,i.Z)(t);o.children=(0,r.jsxs)(r.Fragment,{children:["Failed to ",e?"enable":"disable"," network mapping."," ",o.children]}),null===n||void 0===n||n.call(null,o)}))}}}]); |