From f409127f1dc88a928d5b553c26b7e2ced5660ff6 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Sat, 12 Mar 2016 12:18:54 -0800 Subject: [PATCH 1/5] start --- server-console/src/main.js | 187 +++++++++++++++++++------------------ 1 file changed, 97 insertions(+), 90 deletions(-) diff --git a/server-console/src/main.js b/server-console/src/main.js index e05106aa6f..c17c959320 100644 --- a/server-console/src/main.js +++ b/server-console/src/main.js @@ -477,118 +477,125 @@ function performContentMigration() { var logWindow = null; + +var labels = { + serverRunningState: { + label: 'Server - Stopped', + enabled: false + }, + version: { + label: 'Version - ' + buildInfo.buildIdentifier, + }, + startServer: { + label: 'Start Server', + click: function() { + homeServer.restart(); + } + }, + stopServer: { + label: 'Stop Server', + visible: false, + click: function() { + homeServer.stop(); + } + }, + + goHome: { + label: 'Go Home', + click: goHomeClicked, + enabled: false + }, + quit: { + label: 'Quit', + accelerator: 'Command+Q', + click: function() { + shutdown(); + } + }, + + settings: { + label: 'Settings', + click: function() { + shell.openExternal('http://localhost:40100/settings'); + }, + enabled: false + }, + viewLogs: { + label: 'View Logs', + click: function() { + logWindow.open(); + } + }, + migrateContent: { + label: 'Migrate Stack Manager Content', + click: function() { + promptToMigrateContent(); + } + }, + shuttingDown: { + label: "Shutting down...", + enabled: false + }, +} + +var separator = { + type: 'separator' +}; + + function buildMenuArray(serverState) { - var menuArray = null; + + updateLabels(serverState); + + var menuArray = []; if (isShuttingDown) { - menuArray = [ - { - label: "Shutting down...", - enabled: false - } - ]; + menuArray.push(labels.shuttingDown); } else { - menuArray = [ - { - label: 'Server - Stopped', - enabled: false - }, - { - type: 'separator' - }, - { - label: 'Go Home', - click: goHomeClicked, - enabled: false - }, - { - type: 'separator' - }, - { - label: 'Start Server', - click: function() { homeServer.restart(); } - }, - { - label: 'Stop Server', - visible: false, - click: function() { homeServer.stop(); } - }, - { - label: 'Settings', - click: function() { shell.openExternal('http://localhost:40100/settings'); }, - enabled: false - }, - { - label: 'View Logs', - click: function() { logWindow.open(); } - }, - { - type: 'separator' - }, - { - label: 'Share', - click: function() { shell.openExternal('http://localhost:40100/settings/?action=share') } - }, - { - type: 'separator' - }, - { - label: 'Quit', - accelerator: 'Command+Q', - click: function() { shutdown(); } - } - ]; + menuArray.push(labels.stopped); + // menuArray.push(version); + menuArray.push(separator); + menuArray.push(labels.goHome); + menuArray.push(separator); + menuArray.push(labels.startServer); + menuArray.push(labels.stopServer); + menuArray.push(labels.settings); + menuArray.push(labels.logs); + menuArray.push(separator); + menuArray.push(labels.share); + menuArray.push(separator); + menuArray.push(labels.quit); var foundStackManagerContent = isStackManagerContentPresent(); if (foundStackManagerContent) { // add a separator and the stack manager content migration option - menuArray.splice(menuArray.length - 1, 0, { - label: 'Migrate Stack Manager Content', - click: function() { promptToMigrateContent(); } - }, { - type: 'separator' - }); + menuArray.splice(menuArray.length - 1, 0, labels.migrateContent, separator); } - updateMenuArray(menuArray, serverState); } return menuArray; + } -const GO_HOME_INDEX = 2; -const SERVER_LABEL_INDEX = 0; -const RESTART_INDEX = 4; -const STOP_INDEX = 5; -const SETTINGS_INDEX = 6; +function updateLabels(serverState) { -function updateMenuArray(menuArray, serverState) { // update the tray menu state var running = serverState == ProcessGroupStates.STARTED; - var serverLabelItem = menuArray[SERVER_LABEL_INDEX]; - var restartItem = menuArray[RESTART_INDEX]; - - // Go Home is only enabled if running - menuArray[GO_HOME_INDEX].enabled = running; - - // Stop is only visible if running - menuArray[STOP_INDEX].visible = running; - - // Settings is only visible if running - menuArray[SETTINGS_INDEX].enabled = running; - + labels.goHome.enabled = running; + labels.stop.visible = running; + labels.settings.enabled = running; if (serverState == ProcessGroupStates.STARTED) { - serverLabelItem.label = "Server - Started"; - restartItem.label = "Restart Server"; + labels.serverState.label = "Server - Started"; + labels.restart.label = "Restart Server"; } else if (serverState == ProcessGroupStates.STOPPED) { - serverLabelItem.label = "Server - Stopped"; - restartItem.label = "Start Server"; + labels.serverState.label = "Server - Stopped"; + labels.restart.label = "Start Server"; } else if (serverState == ProcessGroupStates.STOPPING) { - serverLabelItem.label = "Server - Stopping"; - - restartItem.label = "Restart Server"; - restartItem.enabled = false; + labels.serverState.label = "Server - Stopping"; + labels.restart.label = "Restart Server"; + labels.restart.enabled = false; } } From 50e7bd77424580f972f2507572d631dd4541555f Mon Sep 17 00:00:00 2001 From: James Pollack Date: Sat, 12 Mar 2016 13:42:18 -0800 Subject: [PATCH 2/5] claenup --- server-console/src/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server-console/src/main.js b/server-console/src/main.js index c17c959320..a90080e3b4 100644 --- a/server-console/src/main.js +++ b/server-console/src/main.js @@ -479,14 +479,14 @@ var logWindow = null; var labels = { - serverRunningState: { + serverState: { label: 'Server - Stopped', enabled: false }, version: { label: 'Version - ' + buildInfo.buildIdentifier, }, - startServer: { + restart: { label: 'Start Server', click: function() { homeServer.restart(); @@ -584,7 +584,7 @@ function updateLabels(serverState) { var running = serverState == ProcessGroupStates.STARTED; labels.goHome.enabled = running; - labels.stop.visible = running; + labels.stopServer.visible = running; labels.settings.enabled = running; if (serverState == ProcessGroupStates.STARTED) { labels.serverState.label = "Server - Started"; From 03a109b60f1000e0562ad719732ebb535b26dbad Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Sat, 12 Mar 2016 14:54:10 -0800 Subject: [PATCH 3/5] menu --- server-console/src/main.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/server-console/src/main.js b/server-console/src/main.js index a90080e3b4..5fc373b070 100644 --- a/server-console/src/main.js +++ b/server-console/src/main.js @@ -477,14 +477,14 @@ function performContentMigration() { var logWindow = null; - var labels = { serverState: { label: 'Server - Stopped', enabled: false }, version: { - label: 'Version - ' + buildInfo.buildIdentifier, + label: 'Version - ' + buildInfo.buildIdentifier, + enabled: false }, restart: { label: 'Start Server', @@ -499,7 +499,6 @@ var labels = { homeServer.stop(); } }, - goHome: { label: 'Go Home', click: goHomeClicked, @@ -512,7 +511,6 @@ var labels = { shutdown(); } }, - settings: { label: 'Settings', click: function() { @@ -526,6 +524,12 @@ var labels = { logWindow.open(); } }, + share: { + label: 'Share', + click: function() { + shell.openExternal('http://localhost:40100/settings/?action=share') + } + }, migrateContent: { label: 'Migrate Stack Manager Content', click: function() { @@ -552,15 +556,15 @@ function buildMenuArray(serverState) { if (isShuttingDown) { menuArray.push(labels.shuttingDown); } else { - menuArray.push(labels.stopped); - // menuArray.push(version); + menuArray.push(labels.serverState); + menuArray.push(labels.version); menuArray.push(separator); menuArray.push(labels.goHome); menuArray.push(separator); - menuArray.push(labels.startServer); + menuArray.push(labels.restart); menuArray.push(labels.stopServer); menuArray.push(labels.settings); - menuArray.push(labels.logs); + menuArray.push(labels.viewLogs); menuArray.push(separator); menuArray.push(labels.share); menuArray.push(separator); @@ -574,6 +578,7 @@ function buildMenuArray(serverState) { } + return menuArray; } From 98d4f34d642bfade7b9c51e0bb4c720d97036b24 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Sat, 12 Mar 2016 14:59:54 -0800 Subject: [PATCH 4/5] enable --- server-console/src/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server-console/src/main.js b/server-console/src/main.js index 5fc373b070..d75dda182f 100644 --- a/server-console/src/main.js +++ b/server-console/src/main.js @@ -587,7 +587,8 @@ function updateLabels(serverState) { // update the tray menu state var running = serverState == ProcessGroupStates.STARTED; - + console.log('RUNNING??? ' + running) + console.log('SERVERSTATE?' + serverState) labels.goHome.enabled = running; labels.stopServer.visible = running; labels.settings.enabled = running; @@ -597,6 +598,7 @@ function updateLabels(serverState) { } else if (serverState == ProcessGroupStates.STOPPED) { labels.serverState.label = "Server - Stopped"; labels.restart.label = "Start Server"; + labels.restart.enabled = true; } else if (serverState == ProcessGroupStates.STOPPING) { labels.serverState.label = "Server - Stopping"; labels.restart.label = "Restart Server"; From b929089af7644977621f13fc8a3ff06b5b4cd837 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Sat, 12 Mar 2016 15:01:34 -0800 Subject: [PATCH 5/5] options --- server-console/src/main.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/server-console/src/main.js b/server-console/src/main.js index d75dda182f..18cffdb81b 100644 --- a/server-console/src/main.js +++ b/server-console/src/main.js @@ -587,8 +587,6 @@ function updateLabels(serverState) { // update the tray menu state var running = serverState == ProcessGroupStates.STARTED; - console.log('RUNNING??? ' + running) - console.log('SERVERSTATE?' + serverState) labels.goHome.enabled = running; labels.stopServer.visible = running; labels.settings.enabled = running;