Add server state change events into the console log

This commit is contained in:
Dane Everitt 2019-09-28 13:45:09 -07:00
parent 0108035c05
commit 8599e2c64b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -49,6 +49,10 @@ export default () => {
'\u001b[1m\u001b[41m[Internal] ' + line.replace(/(?:\r\n|\r|\n)$/im, '') + '\u001b[0m',
);
const handlePowerChangeEvent = (state: string) => terminal.writeln(
'\u001b[1m\u001b[33m[Status Change] Server marked as ' + state + '...\u001b[0m',
);
const handleCommandKeydown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key !== 'Enter' || (e.key === 'Enter' && e.currentTarget.value.length < 1)) {
return;
@ -72,6 +76,7 @@ export default () => {
if (connected && instance) {
terminal.clear();
instance.addListener('status', handlePowerChangeEvent);
instance.addListener('console output', handleConsoleOutput);
instance.addListener('daemon error', handleDaemonErrorOutput);
instance.send('send logs');
@ -79,7 +84,8 @@ export default () => {
return () => {
instance && instance.removeListener('console output', handleConsoleOutput)
.removeListener('daemon error', handleDaemonErrorOutput);
.removeListener('daemon error', handleDaemonErrorOutput)
.removeListener('status', handlePowerChangeEvent);
};
}, [ connected, instance ]);