diff --git a/console/src/index.html b/console/src/index.html index 9ea744ffc1..99dcf064c9 100644 --- a/console/src/index.html +++ b/console/src/index.html @@ -54,11 +54,11 @@
-
+
Domain Server
-
+
Assignment Clients
diff --git a/console/src/index.js b/console/src/index.js index ffb8b8d1d4..bd81276c94 100755 --- a/console/src/index.js +++ b/console/src/index.js @@ -11,18 +11,27 @@ $(function() { // $('#process-interface .power-on').prop('disabled', interfaceOn); // $('#process-interface .power-off').prop('disabled', !interfaceOn); - var serverState = arg.home.state; - var serverCircles = $('#ds-status .circle, #ac-status .circle'); - - switch (serverState) { + var sendingProcess = arg; + var processState = sendingProcess.state; + + var processCircle = null; + if (sendingProcess.name == "domain-server") { + processCircle = $('#ds-status .circle'); + } else if (sendingProcess.name == "ac-monitor") { + processCircle = $('#ac-status .circle'); + } else { + return; + } + + switch (processState) { case HFProcess.ProcessStates.STOPPED: - serverCircles.attr('class', 'circle stopped'); + processCircle.attr('class', 'circle stopped'); break; case HFProcess.ProcessStates.STOPPING: - serverCircles.attr('class', 'circle stopping'); + processCircle.attr('class', 'circle stopping'); break; case HFProcess.ProcessStates.STARTED: - serverCircles.attr('class', 'circle started'); + processCircle.attr('class', 'circle started'); break; } } @@ -45,5 +54,5 @@ $(function() { ipcRenderer.on('process-update', onProcessUpdate); - ipcRenderer.send('update'); + ipcRenderer.send('update-all-processes'); }); diff --git a/console/src/main.js b/console/src/main.js index 935ed474dd..54e2b4f646 100644 --- a/console/src/main.js +++ b/console/src/main.js @@ -114,10 +114,9 @@ app.on('ready', function() { var pInterface = new Process('interface', interfacePath); var homeServer = new ProcessGroup('home', [ - new Process('domain_server', dsPath), - new Process('ac_monitor', acPath, ['-n6', '--log-directory', logPath]) + new Process('domain-server', dsPath), + new Process('ac-monitor', acPath, ['-n6', '--log-directory', logPath]) ]); - homeServer.start(); // make sure we stop child processes on app quit app.on('quit', function(){ @@ -130,37 +129,45 @@ app.on('ready', function() { home: homeServer }; - function sendProcessUpdate() { + function sendProcessUpdate(process) { if (mainWindow) { - console.log("Sending process update to web view"); - mainWindow.webContents.send('process-update', processes); + console.log("Sending process update to web view for " + process.name); + mainWindow.webContents.send('process-update', process); } }; - pInterface.on('state-update', sendProcessUpdate); + // handle process updates + // pInterface.on('state-update', sendProcessUpdate); homeServer.on('state-update', sendProcessUpdate); - ipcMain.on('start-process', function(event, arg) { - pInterface.start(); - sendProcessUpdate(); - }); - ipcMain.on('stop-process', function(event, arg) { - pInterface.stop(); - sendProcessUpdate(); - }); + // start the home server + homeServer.start(); + + // ipcMain.on('start-process', function(event, arg) { + // pInterface.start(); + // }); + // ipcMain.on('stop-process', function(event, arg) { + // pInterface.stop(); + // }); + ipcMain.on('restart-server', function(event, arg) { homeServer.restart(); - sendProcessUpdate(); }); + ipcMain.on('stop-server', function(event, arg) { homeServer.stop(); - sendProcessUpdate(); }); + ipcMain.on('open-logs', function(event, arg) { openFileBrowser(logPath); }); - ipcMain.on('update', sendProcessUpdate); - sendProcessUpdate(); + ipcMain.on('update-all-processes', function(event, arg) { + // enumerate our processes and call sendProcessUpdate to update + // the window with their status + for (let process of homeServer.processes) { + sendProcessUpdate(process); + } + }); } }); diff --git a/console/src/modules/hf-process.js b/console/src/modules/hf-process.js index 234df1cf9f..33909ae21d 100755 --- a/console/src/modules/hf-process.js +++ b/console/src/modules/hf-process.js @@ -89,7 +89,7 @@ ProcessGroup.prototype = extend(ProcessGroup.prototype, { this.restarting = false; } } - this.emit('state-update', this, process); + this.emit('state-update', process); } }); @@ -196,6 +196,8 @@ Process.prototype = extend(Process.prototype, { } this.child.kill(); this.state = ProcessStates.STOPPING; + + this.emit('state-update', this); }, // Events