|
|
@ -37,12 +37,10 @@ import { BLUE, GREY } from '../lib/consts/DEFAULT_THEME'; |
|
|
|
import NETWORK_TYPES from '../lib/consts/NETWORK_TYPES'; |
|
|
|
import NETWORK_TYPES from '../lib/consts/NETWORK_TYPES'; |
|
|
|
import { REP_IPV4, REP_IPV4_CSV } from '../lib/consts/REG_EXP_PATTERNS'; |
|
|
|
import { REP_IPV4, REP_IPV4_CSV } from '../lib/consts/REG_EXP_PATTERNS'; |
|
|
|
|
|
|
|
|
|
|
|
import api from '../lib/api'; |
|
|
|
|
|
|
|
import BriefNetworkInterface from './BriefNetworkInterface'; |
|
|
|
import BriefNetworkInterface from './BriefNetworkInterface'; |
|
|
|
import Decorator from './Decorator'; |
|
|
|
import Decorator from './Decorator'; |
|
|
|
import DropArea from './DropArea'; |
|
|
|
import DropArea from './DropArea'; |
|
|
|
import FlexBox from './FlexBox'; |
|
|
|
import FlexBox from './FlexBox'; |
|
|
|
import handleAPIError from '../lib/handleAPIError'; |
|
|
|
|
|
|
|
import IconButton from './IconButton'; |
|
|
|
import IconButton from './IconButton'; |
|
|
|
import InputWithRef, { InputForwardedRefContent } from './InputWithRef'; |
|
|
|
import InputWithRef, { InputForwardedRefContent } from './InputWithRef'; |
|
|
|
import { Message } from './MessageBox'; |
|
|
|
import { Message } from './MessageBox'; |
|
|
@ -51,6 +49,7 @@ import OutlinedInputWithLabel from './OutlinedInputWithLabel'; |
|
|
|
import { InnerPanel, InnerPanelHeader } from './Panels'; |
|
|
|
import { InnerPanel, InnerPanelHeader } from './Panels'; |
|
|
|
import periodicFetch from '../lib/fetchers/periodicFetch'; |
|
|
|
import periodicFetch from '../lib/fetchers/periodicFetch'; |
|
|
|
import SelectWithLabel from './SelectWithLabel'; |
|
|
|
import SelectWithLabel from './SelectWithLabel'; |
|
|
|
|
|
|
|
import setMapNetwork from '../lib/setMapNetwork'; |
|
|
|
import Spinner from './Spinner'; |
|
|
|
import Spinner from './Spinner'; |
|
|
|
import { createTestInputFunction, testNotBlank } from '../lib/test_input'; |
|
|
|
import { createTestInputFunction, testNotBlank } from '../lib/test_input'; |
|
|
|
import { BodyText, MonoText, SmallText } from './Text'; |
|
|
|
import { BodyText, MonoText, SmallText } from './Text'; |
|
|
@ -873,20 +872,9 @@ const NetworkInitForm = forwardRef< |
|
|
|
[networkInputs], |
|
|
|
[networkInputs], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const setMapNetwork = useCallback( |
|
|
|
const handleSetMapNetworkError = useCallback( |
|
|
|
(value: 0 | 1) => { |
|
|
|
(msg: Message): void => { |
|
|
|
api.put('/init/set-map-network', { value }).catch((error) => { |
|
|
|
setMessage(MSG_ID_API, msg); |
|
|
|
const emsg = handleAPIError(error); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emsg.children = ( |
|
|
|
|
|
|
|
<> |
|
|
|
|
|
|
|
Failed to {value ? 'enable' : 'disable'} network mapping.{' '} |
|
|
|
|
|
|
|
{emsg.children} |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setMessage(MSG_ID_API, emsg); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
[setMessage], |
|
|
|
[setMessage], |
|
|
|
); |
|
|
|
); |
|
|
@ -1383,7 +1371,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
// Enable network mapping on component mount.
|
|
|
|
// Enable network mapping on component mount.
|
|
|
|
setMapNetwork(1); |
|
|
|
setMapNetwork(1, handleSetMapNetworkError); |
|
|
|
|
|
|
|
|
|
|
|
if (window) { |
|
|
|
if (window) { |
|
|
|
window.addEventListener( |
|
|
|
window.addEventListener( |
|
|
@ -1401,9 +1389,9 @@ const NetworkInitForm = forwardRef< |
|
|
|
|
|
|
|
|
|
|
|
return () => { |
|
|
|
return () => { |
|
|
|
// Disable network mapping on component unmount.
|
|
|
|
// Disable network mapping on component unmount.
|
|
|
|
setMapNetwork(0); |
|
|
|
setMapNetwork(0, handleSetMapNetworkError); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, [setMapNetwork]); |
|
|
|
}, [handleSetMapNetworkError]); |
|
|
|
|
|
|
|
|
|
|
|
useImperativeHandle( |
|
|
|
useImperativeHandle( |
|
|
|
ref, |
|
|
|
ref, |
|
|
|