diff --git a/resources/scripts/components/server/Console.tsx b/resources/scripts/components/server/Console.tsx index 74de72c04..26e214a36 100644 --- a/resources/scripts/components/server/Console.tsx +++ b/resources/scripts/components/server/Console.tsx @@ -67,6 +67,7 @@ export default () => { const { connected, instance } = ServerContext.useStoreState(state => state.socket); const [ canSendCommands ] = usePermissions([ 'control.console' ]); const serverId = ServerContext.useStoreState(state => state.server.data!.id); + const isTransferring = ServerContext.useStoreState(state => state.server.data!.isTransferring) const [ history, setHistory ] = usePersistedState(`${serverId}:command_history`, []); const [ historyIndex, setHistoryIndex ] = useState(-1); @@ -165,7 +166,10 @@ export default () => { useEffect(() => { if (connected && instance) { - // terminal.clear(); + // Do not clear the console if the server is being transferred. + if (!isTransferring) { + terminal.clear(); + } instance.addListener('status', handlePowerChangeEvent); instance.addListener('console output', handleConsoleOutput); diff --git a/resources/scripts/components/server/TransferListener.tsx b/resources/scripts/components/server/TransferListener.tsx index ce9c84793..b46e655bc 100644 --- a/resources/scripts/components/server/TransferListener.tsx +++ b/resources/scripts/components/server/TransferListener.tsx @@ -6,19 +6,23 @@ const TransferListener = () => { const getServer = ServerContext.useStoreActions(actions => actions.server.getServer); const setServerFromState = ServerContext.useStoreActions(actions => actions.server.setServerFromState); - // Listen for the installation completion event and then fire off a request to fetch the updated - // server information. This allows the server to automatically become available to the user if they - // just sit on the page. + // Listen for the transfer status event so we can update the state of the server. useWebsocketEvent('transfer status', (status: string) => { if (status === 'starting') { setServerFromState(s => ({ ...s, isTransferring: true })); return; } + if (status === 'failure') { + setServerFromState(s => ({ ...s, isTransferring: false })); + return; + } + if (status !== 'success') { return; } + // Refresh the server's information as it's node and allocations were just updated. getServer(uuid).catch(error => console.error(error)); }); diff --git a/resources/scripts/components/server/WebsocketHandler.tsx b/resources/scripts/components/server/WebsocketHandler.tsx index d519da4f5..10b91dd47 100644 --- a/resources/scripts/components/server/WebsocketHandler.tsx +++ b/resources/scripts/components/server/WebsocketHandler.tsx @@ -53,16 +53,12 @@ export default () => { return; } - // Force a reconnection to the websocket which will connect us - // to the target node instead of the source node. - - // Close the current websocket connection. + // This code forces a reconnection to the websocket which will connect us to the target node instead of the source node + // in order to be able to receive transfer logs from the target node. socket.close(); - setError('connecting'); setConnectionState(false); setInstance(null); - connect(uuid); });