diff --git a/console/src/css/style.less b/console/src/css/style.less index 621c0c0e10..603be6c28d 100644 --- a/console/src/css/style.less +++ b/console/src/css/style.less @@ -147,6 +147,7 @@ header { .process-status { @status-red: #BD5F6D; @status-green: #59AEA8; + @status-orange: #D89C40; margin-bottom: 10px; @@ -163,9 +164,13 @@ header { background-color: @status-red; } - &.running { + &.started { background-color: @status-green; } + + &.stopping { + background-color: @status-orange; + } } } diff --git a/console/src/index.html b/console/src/index.html index cd6d91e184..9ea744ffc1 100644 --- a/console/src/index.html +++ b/console/src/index.html @@ -53,12 +53,12 @@

STATUS

-
-
+
+
Domain Server
-
-
+
+
Assignment Clients
diff --git a/console/src/index.js b/console/src/index.js index b684f03926..160a340dc3 100755 --- a/console/src/index.js +++ b/console/src/index.js @@ -1,5 +1,6 @@ $(function() { const ipcRenderer = require('electron').ipcRenderer; + const HFProcess = require('./modules/hf-process.js'); function onProcessUpdate(event, arg) { console.log("update", event, arg); @@ -11,10 +12,18 @@ $(function() { // $('#process-interface .power-off').prop('disabled', !interfaceOn); var serverState = arg.home.state; - $('#server .status').text(serverState); - var serverOn = serverState != 'stopped'; - $('#server .power-on').prop('disabled', serverOn); - $('#server .power-off').prop('disabled', !serverOn); + var serverCircles = $('#ds-status .circle, #ac-status .circle'); + switch (serverState) { + case HFProcess.ProcessStates.STOPPED: + serverCircles.attr('class', 'circle stopped'); + break; + case HFProcess.ProcessStates.STOPPING: + serverCircles.attr('class', 'circle stopping'); + break; + case HFProcess.ProcessStates.STARTED: + serverCircles.attr('class', 'circle started'); + break; + } } $('#process-interface .power-on').click(function() { @@ -23,10 +32,10 @@ $(function() { $('#process-interface .power-off').click(function() { ipcRenderer.send('stop-process', { name: 'interface' }); }); - $('#server .power-on').click(function() { - ipcRenderer.send('start-server', { name: 'home' }); + $('#manage-server #restart').click(function() { + ipcRenderer.send('restart-server', { name: 'home' }); }); - $('#server .power-off').click(function() { + $('#manage-server #stop').click(function() { ipcRenderer.send('stop-server', { name: 'home' }); }); $('#open-logs').click(function() { diff --git a/console/src/main.js b/console/src/main.js index 162f8fb4b7..a33dbd00b7 100644 --- a/console/src/main.js +++ b/console/src/main.js @@ -148,7 +148,9 @@ app.on('ready', function() { pInterface.stop(); sendProcessUpdate(); }); - ipcMain.on('start-server', function(event, arg) { + ipcMain.on('restart-server', function(event, arg) { + homeServer.stop(); + sendProcessUpdate(); homeServer.start(); sendProcessUpdate(); }); diff --git a/console/src/modules/hf-process.js b/console/src/modules/hf-process.js index 76d0aaff2e..7a1a5d8646 100755 --- a/console/src/modules/hf-process.js +++ b/console/src/modules/hf-process.js @@ -24,6 +24,7 @@ function ProcessGroup(name, processes) { this.name = name; this.state = ProcessGroupStates.STOPPED; this.processes = []; + this.restarting = false; for (let process of processes) { this.addProcess(process); @@ -57,6 +58,16 @@ ProcessGroup.prototype = extend(ProcessGroup.prototype, { } this.state = ProcessGroupStates.STOPPING; }, + restart: function() { + // set our restart flag so the group will restart once stopped + this.restarting = true; + + // call stop, that will put them in the stopping state + this.stop(); + + // update our state + this.state = ProcessGroupStates.STOPPING; + }, // Event handlers onProcessStateUpdate: function(process) { @@ -69,6 +80,12 @@ ProcessGroup.prototype = extend(ProcessGroup.prototype, { } if (!processesStillRunning) { this.state = ProcessGroupStates.STOPPED; + + // if we we're supposed to restart, call start now and reset the flag + if (this.restarting) { + this.start(); + this.restarting = false; + } } this.emit('state-update', this, process); }