|
|
@ -574,11 +574,9 @@ const NetworkInitForm = forwardRef< |
|
|
|
hostDetail?: APIHostDetail; |
|
|
|
hostDetail?: APIHostDetail; |
|
|
|
toggleSubmitDisabled?: (testResult: boolean) => void; |
|
|
|
toggleSubmitDisabled?: (testResult: boolean) => void; |
|
|
|
} |
|
|
|
} |
|
|
|
>( |
|
|
|
>(({ hostDetail, toggleSubmitDisabled }, ref) => { |
|
|
|
( |
|
|
|
const { hostType, hostUUID = 'local' } = hostDetail ?? {}; |
|
|
|
{ hostDetail: { hostType, hostUUID = 'local' } = {}, toggleSubmitDisabled }, |
|
|
|
|
|
|
|
ref, |
|
|
|
|
|
|
|
) => { |
|
|
|
|
|
|
|
const [dragMousePosition, setDragMousePosition] = useState<{ |
|
|
|
const [dragMousePosition, setDragMousePosition] = useState<{ |
|
|
|
x: number; |
|
|
|
x: number; |
|
|
|
y: number; |
|
|
|
y: number; |
|
|
@ -602,8 +600,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
>(`${API_BASE_URL}/network-interface/${hostUUID}`, { |
|
|
|
>(`${API_BASE_URL}/network-interface/${hostUUID}`, { |
|
|
|
refreshInterval: 2000, |
|
|
|
refreshInterval: 2000, |
|
|
|
onSuccess: (data) => { |
|
|
|
onSuccess: (data) => { |
|
|
|
const map = data.reduce<NetworkInterfaceInputMap>( |
|
|
|
const map = data.reduce<NetworkInterfaceInputMap>((result, metadata) => { |
|
|
|
(result, metadata) => { |
|
|
|
|
|
|
|
const { networkInterfaceUUID } = metadata; |
|
|
|
const { networkInterfaceUUID } = metadata; |
|
|
|
|
|
|
|
|
|
|
|
result[networkInterfaceUUID] = networkInterfaceInputMap[ |
|
|
|
result[networkInterfaceUUID] = networkInterfaceInputMap[ |
|
|
@ -611,9 +608,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
] ?? { metadata }; |
|
|
|
] ?? { metadata }; |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
}, |
|
|
|
}, {}); |
|
|
|
{}, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setNetworkInterfaceInputMap(map); |
|
|
|
setNetworkInterfaceInputMap(map); |
|
|
|
}, |
|
|
|
}, |
|
|
@ -795,8 +790,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
const inputTestPrefix = createInputTestPrefix(inputUUID); |
|
|
|
const inputTestPrefix = createInputTestPrefix(inputUUID); |
|
|
|
const inputTestIDIfaces = IT_IDS.networkInterfaces(inputTestPrefix); |
|
|
|
const inputTestIDIfaces = IT_IDS.networkInterfaces(inputTestPrefix); |
|
|
|
const inputTestIDIPAddress = IT_IDS.networkIPAddress(inputTestPrefix); |
|
|
|
const inputTestIDIPAddress = IT_IDS.networkIPAddress(inputTestPrefix); |
|
|
|
const inputTestIDSubnetMask = |
|
|
|
const inputTestIDSubnetMask = IT_IDS.networkSubnetMask(inputTestPrefix); |
|
|
|
IT_IDS.networkSubnetMask(inputTestPrefix); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const setNetworkIfacesInputMessage = (message?: Message) => |
|
|
|
const setNetworkIfacesInputMessage = (message?: Message) => |
|
|
|
setMessage(inputTestIDIfaces, message); |
|
|
|
setMessage(inputTestIDIfaces, message); |
|
|
@ -976,10 +970,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
}, [networkInputs, toggleSubmitDisabled]); |
|
|
|
}, [networkInputs, toggleSubmitDisabled]); |
|
|
|
const removeNetwork = useCallback( |
|
|
|
const removeNetwork = useCallback( |
|
|
|
(networkIndex: number) => { |
|
|
|
(networkIndex: number) => { |
|
|
|
const [{ inputUUID, interfaces }] = networkInputs.splice( |
|
|
|
const [{ inputUUID, interfaces }] = networkInputs.splice(networkIndex, 1); |
|
|
|
networkIndex, |
|
|
|
|
|
|
|
1, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interfaces.forEach((iface) => { |
|
|
|
interfaces.forEach((iface) => { |
|
|
|
if (iface === undefined) { |
|
|
|
if (iface === undefined) { |
|
|
@ -999,11 +990,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
...previous, |
|
|
|
...previous, |
|
|
|
})); |
|
|
|
})); |
|
|
|
}, |
|
|
|
}, |
|
|
|
[ |
|
|
|
[networkInputs, networkInterfaceInputMap, testInputToToggleSubmitDisabled], |
|
|
|
networkInputs, |
|
|
|
|
|
|
|
networkInterfaceInputMap, |
|
|
|
|
|
|
|
testInputToToggleSubmitDisabled, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
const getNetworkTypeCount: GetNetworkTypeCountFunction = useCallback( |
|
|
|
const getNetworkTypeCount: GetNetworkTypeCountFunction = useCallback( |
|
|
|
( |
|
|
|
( |
|
|
@ -1140,8 +1127,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
interfaces, |
|
|
|
interfaces, |
|
|
|
ipAddress: ipAddressInputRef?.current.getValue?.call(null) ?? '', |
|
|
|
ipAddress: ipAddressInputRef?.current.getValue?.call(null) ?? '', |
|
|
|
name, |
|
|
|
name, |
|
|
|
subnetMask: |
|
|
|
subnetMask: subnetMaskInputRef?.current.getValue?.call(null) ?? '', |
|
|
|
subnetMaskInputRef?.current.getValue?.call(null) ?? '', |
|
|
|
|
|
|
|
type, |
|
|
|
type, |
|
|
|
typeCount, |
|
|
|
typeCount, |
|
|
|
}), |
|
|
|
}), |
|
|
@ -1294,6 +1280,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
{...{ |
|
|
|
{...{ |
|
|
|
createDropMouseUpHandler, |
|
|
|
createDropMouseUpHandler, |
|
|
|
getNetworkTypeCount, |
|
|
|
getNetworkTypeCount, |
|
|
|
|
|
|
|
hostDetail, |
|
|
|
networkIndex, |
|
|
|
networkIndex, |
|
|
|
networkInput, |
|
|
|
networkInput, |
|
|
|
networkInterfaceInputMap, |
|
|
|
networkInterfaceInputMap, |
|
|
@ -1372,8 +1359,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
</MUIBox> |
|
|
|
</MUIBox> |
|
|
|
</MUIBox> |
|
|
|
</MUIBox> |
|
|
|
); |
|
|
|
); |
|
|
|
}, |
|
|
|
}); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NetworkInitForm.defaultProps = { |
|
|
|
NetworkInitForm.defaultProps = { |
|
|
|
hostDetail: undefined, |
|
|
|
hostDetail: undefined, |
|
|
|