From c188fa2a1fbce426ef24c8b9ece26502d6b4a5bf Mon Sep 17 00:00:00 2001 From: psychobunny Date: Fri, 17 Apr 2015 13:21:45 -0400 Subject: [PATCH] closes #3049 --- public/src/admin/admin.js | 58 +++++++++++++++++++++++++++ public/src/admin/general/dashboard.js | 55 ------------------------- src/views/admin/header.tpl | 26 +++++++++--- 3 files changed, 78 insertions(+), 61 deletions(-) diff --git a/public/src/admin/admin.js b/public/src/admin/admin.js index 8a4c6b56b2..d44dc1d980 100644 --- a/public/src/admin/admin.js +++ b/public/src/admin/admin.js @@ -19,6 +19,7 @@ selectMenuItem(data.url); setupHeaderMenu(); + setupRestartLinks(); }); $(window).resize(setupHeaderMenu); @@ -150,4 +151,61 @@ $('.mobile-header').remove(); } } + + function setupRestartLinks() { + $('.restart').off('click').on('click', function() { + bootbox.confirm('Are you sure you wish to restart NodeBB?', function(confirm) { + if (confirm) { + app.alert({ + alert_id: 'instance_restart', + type: 'info', + title: 'Restarting... ', + message: 'NodeBB is restarting.', + timeout: 5000 + }); + + $(window).one('action:reconnected', function() { + app.alert({ + alert_id: 'instance_restart', + type: 'success', + title: ' Success', + message: 'NodeBB has successfully restarted.', + timeout: 5000 + }); + }); + + socket.emit('admin.restart'); + } + }); + }); + + $('.reload').off('click').on('click', function() { + app.alert({ + alert_id: 'instance_reload', + type: 'info', + title: 'Reloading... ', + message: 'NodeBB is reloading.', + timeout: 5000 + }); + + socket.emit('admin.reload', function(err) { + if (!err) { + app.alert({ + alert_id: 'instance_reload', + type: 'success', + title: ' Success', + message: 'NodeBB has successfully reloaded.', + timeout: 5000 + }); + } else { + app.alert({ + alert_id: 'instance_reload', + type: 'danger', + title: '[[global:alert.error]]', + message: '[[error:reload-failed, ' + err.message + ']]' + }); + } + }); + }); + } }()); \ No newline at end of file diff --git a/public/src/admin/general/dashboard.js b/public/src/admin/general/dashboard.js index 3ae00b1e43..021b321b5f 100644 --- a/public/src/admin/general/dashboard.js +++ b/public/src/admin/general/dashboard.js @@ -61,61 +61,6 @@ define('admin/general/dashboard', ['semver'], function(semver) { } }); - $('.restart').on('click', function() { - bootbox.confirm('Are you sure you wish to restart NodeBB?', function(confirm) { - if (confirm) { - app.alert({ - alert_id: 'instance_restart', - type: 'info', - title: 'Restarting... ', - message: 'NodeBB is restarting.', - timeout: 5000 - }); - - $(window).one('action:reconnected', function() { - app.alert({ - alert_id: 'instance_restart', - type: 'success', - title: ' Success', - message: 'NodeBB has successfully restarted.', - timeout: 5000 - }); - }); - - socket.emit('admin.restart'); - } - }); - }); - - $('.reload').on('click', function() { - app.alert({ - alert_id: 'instance_reload', - type: 'info', - title: 'Reloading... ', - message: 'NodeBB is reloading.', - timeout: 5000 - }); - - socket.emit('admin.reload', function(err) { - if (!err) { - app.alert({ - alert_id: 'instance_reload', - type: 'success', - title: ' Success', - message: 'NodeBB has successfully reloaded.', - timeout: 5000 - }); - } else { - app.alert({ - alert_id: 'instance_reload', - type: 'danger', - title: '[[global:alert.error]]', - message: '[[error:reload-failed, ' + err.message + ']]' - }); - } - }); - }); - setupGraphs(); }; diff --git a/src/views/admin/header.tpl b/src/views/admin/header.tpl index a2b3a4c8e7..4fbeea9566 100644 --- a/src/views/admin/header.tpl +++ b/src/views/admin/header.tpl @@ -91,18 +91,32 @@ -