Skip to content

Commit 5668a78

Browse files
committed
Hopefully the last small tweaks and fixes to transfer logs
1 parent 8d297a0 commit 5668a78

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

resources/scripts/components/server/Console.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export default () => {
6767
const { connected, instance } = ServerContext.useStoreState(state => state.socket);
6868
const [ canSendCommands ] = usePermissions([ 'control.console' ]);
6969
const serverId = ServerContext.useStoreState(state => state.server.data!.id);
70+
const isTransferring = ServerContext.useStoreState(state => state.server.data!.isTransferring)
7071
const [ history, setHistory ] = usePersistedState<string[]>(`${serverId}:command_history`, []);
7172
const [ historyIndex, setHistoryIndex ] = useState(-1);
7273

@@ -165,7 +166,10 @@ export default () => {
165166

166167
useEffect(() => {
167168
if (connected && instance) {
168-
// terminal.clear();
169+
// Do not clear the console if the server is being transferred.
170+
if (!isTransferring) {
171+
terminal.clear();
172+
}
169173

170174
instance.addListener('status', handlePowerChangeEvent);
171175
instance.addListener('console output', handleConsoleOutput);

resources/scripts/components/server/TransferListener.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@ const TransferListener = () => {
66
const getServer = ServerContext.useStoreActions(actions => actions.server.getServer);
77
const setServerFromState = ServerContext.useStoreActions(actions => actions.server.setServerFromState);
88

9-
// Listen for the installation completion event and then fire off a request to fetch the updated
10-
// server information. This allows the server to automatically become available to the user if they
11-
// just sit on the page.
9+
// Listen for the transfer status event so we can update the state of the server.
1210
useWebsocketEvent('transfer status', (status: string) => {
1311
if (status === 'starting') {
1412
setServerFromState(s => ({ ...s, isTransferring: true }));
1513
return;
1614
}
1715

16+
if (status === 'failure') {
17+
setServerFromState(s => ({ ...s, isTransferring: false }));
18+
return;
19+
}
20+
1821
if (status !== 'success') {
1922
return;
2023
}
2124

25+
// Refresh the server's information as it's node and allocations were just updated.
2226
getServer(uuid).catch(error => console.error(error));
2327
});
2428

resources/scripts/components/server/WebsocketHandler.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,12 @@ export default () => {
5353
return;
5454
}
5555

56-
// Force a reconnection to the websocket which will connect us
57-
// to the target node instead of the source node.
58-
59-
// Close the current websocket connection.
56+
// This code forces a reconnection to the websocket which will connect us to the target node instead of the source node
57+
// in order to be able to receive transfer logs from the target node.
6058
socket.close();
61-
6259
setError('connecting');
6360
setConnectionState(false);
6461
setInstance(null);
65-
6662
connect(uuid);
6763
});
6864

0 commit comments

Comments
 (0)