From 585d613d4b999834279586a7480dc968d98423f1 Mon Sep 17 00:00:00 2001 From: Timothy Fike Date: Mon, 26 Mar 2018 15:17:40 -0400 Subject: [PATCH] fix reload actions (#6394) * fix reload actions * wait until restart action is complete instead of using timeouts. * Change Reload nominclature to Rebuild and Restart. --- public/language/en-GB/admin/admin.json | 2 +- .../en-GB/admin/appearance/themes.json | 2 +- .../language/en-GB/admin/extend/plugins.json | 2 +- .../en-GB/admin/general/dashboard.json | 4 +- public/language/en-GB/admin/menu.json | 2 +- public/src/admin/admin.js | 6 +-- public/src/admin/appearance/themes.js | 4 +- public/src/admin/extend/plugins.js | 4 +- public/src/admin/modules/instance.js | 41 +++++++++---------- src/socket.io/admin.js | 4 +- src/views/admin/general/dashboard.tpl | 4 +- .../admin/partials/quick_actions/buttons.tpl | 2 +- 12 files changed, 38 insertions(+), 39 deletions(-) diff --git a/public/language/en-GB/admin/admin.json b/public/language/en-GB/admin/admin.json index cca6420575..36f0fdde60 100644 --- a/public/language/en-GB/admin/admin.json +++ b/public/language/en-GB/admin/admin.json @@ -1,5 +1,5 @@ { - "alert.confirm-reload": "Are you sure you wish to rebuild and restart NodeBB?", + "alert.confirm-rebuild-and-restart": "Are you sure you wish to rebuild and restart NodeBB?", "alert.confirm-restart": "Are you sure you wish to restart NodeBB?", "acp-title": "%1 | NodeBB Admin Control Panel", diff --git a/public/language/en-GB/admin/appearance/themes.json b/public/language/en-GB/admin/appearance/themes.json index 3148a01337..597830f379 100644 --- a/public/language/en-GB/admin/appearance/themes.json +++ b/public/language/en-GB/admin/appearance/themes.json @@ -7,5 +7,5 @@ "revert-confirm": "Are you sure you wish to restore the default NodeBB theme?", "theme-changed": "Theme Changed", "revert-success": "You have successfully reverted your NodeBB back to it's default theme.", - "restart-to-activate": "Please restart your NodeBB to fully activate this theme" + "restart-to-activate": "Please rebuild and restart your NodeBB to fully activate this theme." } \ No newline at end of file diff --git a/public/language/en-GB/admin/extend/plugins.json b/public/language/en-GB/admin/extend/plugins.json index 7515f72590..05f7df4ecb 100644 --- a/public/language/en-GB/admin/extend/plugins.json +++ b/public/language/en-GB/admin/extend/plugins.json @@ -37,7 +37,7 @@ "alert.uninstalled": "Plugin Uninstalled", "alert.activate-success": "Please restart your NodeBB to fully activate this plugin", "alert.deactivate-success": "Plugin successfully deactivated", - "alert.upgrade-success": "Please reload your NodeBB to fully upgrade this plugin", + "alert.upgrade-success": "Please rebuild and restart your NodeBB to fully upgrade this plugin.", "alert.install-success": "Plugin successfully installed, please activate the plugin.", "alert.uninstall-success": "The plugin has been successfully deactivated and uninstalled.", "alert.suggest-error": "

NodeBB could not reach the package manager, proceed with installation of latest version?

Server returned (%1): %2
", diff --git a/public/language/en-GB/admin/general/dashboard.json b/public/language/en-GB/admin/general/dashboard.json index 4d287c409d..56049387eb 100644 --- a/public/language/en-GB/admin/general/dashboard.json +++ b/public/language/en-GB/admin/general/dashboard.json @@ -37,8 +37,8 @@ "search-plugin-tooltip": "Install a search plugin from the plugin page in order to activate search functionality", "control-panel": "System Control", - "reload": "Restart", - "restart": "Rebuild & Restart", + "rebuild-and-restart": "Rebuild & Restart", + "restart": "Restart", "restart-warning": "Rebuilding or Restarting your NodeBB will drop all existing connections for a few seconds.", "restart-disabled": "Rebuilding and Restarting your NodeBB has been disabled as you do not seem to be running it via the appropriate daemon.", "maintenance-mode": "Maintenance Mode", diff --git a/public/language/en-GB/admin/menu.json b/public/language/en-GB/admin/menu.json index bebff6aa37..7e0d46d86b 100644 --- a/public/language/en-GB/admin/menu.json +++ b/public/language/en-GB/admin/menu.json @@ -63,7 +63,7 @@ "development/logger": "Logger", "development/info": "Info", - "reload-forum": "Rebuild & Restart Forum", + "rebuild-and-restart-forum": "Rebuild & Restart Forum", "restart-forum": "Restart Forum", "logout": "Log out", "view-forum": "View Forum", diff --git a/public/src/admin/admin.js b/public/src/admin/admin.js index b654210f37..ee2432fa5c 100644 --- a/public/src/admin/admin.js +++ b/public/src/admin/admin.js @@ -119,11 +119,11 @@ } function setupRestartLinks() { - $('.reload').off('click').on('click', function () { - bootbox.confirm('[[admin/admin:alert.confirm-reload]]', function (confirm) { + $('.rebuild-and-restart').off('click').on('click', function () { + bootbox.confirm('[[admin/admin:alert.confirm-rebuild-and-restart]]', function (confirm) { if (confirm) { require(['admin/modules/instance'], function (instance) { - instance.reload(); + instance.rebuildAndRestart(); }); } }); diff --git a/public/src/admin/appearance/themes.js b/public/src/admin/appearance/themes.js index c0a96831bb..0a5f81d236 100644 --- a/public/src/admin/appearance/themes.js +++ b/public/src/admin/appearance/themes.js @@ -33,7 +33,9 @@ define('admin/appearance/themes', ['translator', 'benchpress'], function (transl message: '[[admin/appearance/themes:restart-to-activate]]', timeout: 5000, clickfn: function () { - socket.emit('admin.restart'); + require(['admin/modules/instance'], function (instance) { + instance.rebuildAndRestart(); + }); }, }); }); diff --git a/public/src/admin/extend/plugins.js b/public/src/admin/extend/plugins.js index 1debd9b168..aa0bac657b 100644 --- a/public/src/admin/extend/plugins.js +++ b/public/src/admin/extend/plugins.js @@ -49,7 +49,7 @@ define('admin/extend/plugins', ['jqueryui', 'translator', 'benchpress'], functio timeout: 5000, clickfn: function () { require(['admin/modules/instance'], function (instance) { - instance.restart(); + instance.rebuildAndRestart(); }); }, }); @@ -217,7 +217,7 @@ define('admin/extend/plugins', ['jqueryui', 'translator', 'benchpress'], functio timeout: 5000, clickfn: function () { require(['admin/modules/instance'], function (instance) { - instance.reload(); + instance.rebuildAndRestart(); }); }, }); diff --git a/public/src/admin/modules/instance.js b/public/src/admin/modules/instance.js index a8b38062d9..574b87d0a4 100644 --- a/public/src/admin/modules/instance.js +++ b/public/src/admin/modules/instance.js @@ -4,21 +4,20 @@ define('admin/modules/instance', function () { var instance = {}; - instance.reload = function (callback) { + instance.rebuildAndRestart = function (callback) { app.alert({ - alert_id: 'instance_reload', + alert_id: 'instance_rebuild_and_restart', type: 'info', - title: 'Reloading... ', - message: 'NodeBB is reloading.', - timeout: 5000, + title: 'Rebuilding... ', + message: 'NodeBB is rebuilding front-end assets (css, javascript, etc).', }); $(window).one('action:reconnected', function () { app.alert({ - alert_id: 'instance_reload', + alert_id: 'instance_rebuild_and_restart', type: 'success', title: ' Success', - message: 'NodeBB has reloaded successfully.', + message: 'NodeBB has rebuilt and restarted successfully.', timeout: 5000, }); @@ -27,16 +26,22 @@ define('admin/modules/instance', function () { } }); - socket.emit('admin.reload'); + socket.emit('admin.reload', function () { + app.alert({ + alert_id: 'instance_rebuild_and_restart', + type: 'info', + title: 'Build Complete!... ', + message: 'NodeBB is restarting.', + }); + }); }; instance.restart = function (callback) { app.alert({ alert_id: 'instance_restart', type: 'info', - title: 'Rebuilding... ', - message: 'NodeBB is rebuilding front-end assets (css, javascript, etc).', - timeout: 10000, + title: 'Restarting... ', + message: 'NodeBB is restarting.', }); $(window).one('action:reconnected', function () { @@ -44,8 +49,8 @@ define('admin/modules/instance', function () { alert_id: 'instance_restart', type: 'success', title: ' Success', - message: 'NodeBB has successfully restarted.', - timeout: 10000, + message: 'NodeBB has restarted successfully.', + timeout: 5000, }); if (typeof callback === 'function') { @@ -53,15 +58,7 @@ define('admin/modules/instance', function () { } }); - socket.emit('admin.restart', function () { - app.alert({ - alert_id: 'instance_restart', - type: 'info', - title: 'Build Complete!... ', - message: 'NodeBB is reloading.', - timeout: 10000, - }); - }); + socket.emit('admin.restart'); }; return instance; diff --git a/src/socket.io/admin.js b/src/socket.io/admin.js index 95bb430069..2eab0eb8d1 100644 --- a/src/socket.io/admin.js +++ b/src/socket.io/admin.js @@ -58,7 +58,7 @@ SocketAdmin.before = function (socket, method, data, next) { ], next); }; -SocketAdmin.reload = function (socket, data, callback) { +SocketAdmin.restart = function (socket, data, callback) { events.log({ type: 'restart', uid: socket.uid, @@ -68,7 +68,7 @@ SocketAdmin.reload = function (socket, data, callback) { callback(); }; -SocketAdmin.restart = function (socket, data, callback) { +SocketAdmin.reload = function (socket, data, callback) { async.waterfall([ function (next) { require('../meta/build').buildAll(next); diff --git a/src/views/admin/general/dashboard.tpl b/src/views/admin/general/dashboard.tpl index c58bd6bef4..7af9513dad 100644 --- a/src/views/admin/general/dashboard.tpl +++ b/src/views/admin/general/dashboard.tpl @@ -120,8 +120,8 @@
[[admin/general/dashboard:control-panel]]

- - + +

diff --git a/src/views/admin/partials/quick_actions/buttons.tpl b/src/views/admin/partials/quick_actions/buttons.tpl index 1687d437b0..950283d69e 100644 --- a/src/views/admin/partials/quick_actions/buttons.tpl +++ b/src/views/admin/partials/quick_actions/buttons.tpl @@ -9,7 +9,7 @@

  • - +