From 4e55707652b7dfa9fb18891c5a9d1366a6baf2bd Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 25 Aug 2014 10:46:48 -0400 Subject: [PATCH] closed #2011 --- public/src/forum/admin/index.js | 41 +++++++++++++++++++++++++++------ src/meta.js | 13 +++++++---- src/socket.io/admin.js | 4 ++++ 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/public/src/forum/admin/index.js b/public/src/forum/admin/index.js index c10706e257..58eb0d8eef 100644 --- a/public/src/forum/admin/index.js +++ b/public/src/forum/admin/index.js @@ -37,18 +37,45 @@ define('forum/admin/index', function() { }); $('.restart').on('click', function() { + bootbox.confirm('Are you sure you wish to restart NodeBB?', function(confirm) { + if (confirm) { + app.alert({ + timeout: 5000, + title: 'Restarting... ', + message: 'NodeBB is restarting.', + type: 'info' + }); + + $(window).one('action:reconnected', function() { + app.alertSuccess('NodeBB has successfully restarted.'); + }); + + socket.emit('admin.restart'); + } + }); + }); + + $('.reload').on('click', function() { app.alert({ - timeout: 5000, - title: 'Restarting...', + alert_id: 'instance_reload', + title: 'Reloading... ', message: 'NodeBB is restarting.', - type: 'info' + type: 'info', + timeout: 5000 }); - $(window).one('action:reconnected', function() { - app.alertSuccess('NodeBB has successfully restarted.'); + socket.emit('admin.reload', function(err) { + if (!err) { + app.alertSuccess('NodeBB has successfully reloaded.'); + } else { + app.alert({ + alert_id: 'instance_reload', + title: '[[global:alert.error]]', + message: err.message, + type: 'danger' + }); + } }); - - socket.emit('admin.restart'); }); }; diff --git a/src/meta.js b/src/meta.js index fb4e5cac52..9a616cc957 100644 --- a/src/meta.js +++ b/src/meta.js @@ -3,7 +3,8 @@ var async = require('async'), winston = require('winston'), user = require('./user'), - groups = require('./groups'); + groups = require('./groups'), + plugins = require('./plugins'); (function (Meta) { @@ -28,9 +29,13 @@ var async = require('async'), }); }; - Meta.reload = function(step) { - // 1. Reload plugins and associated routes - // 2. Minify scripts and css, update cache buster + Meta.reload = function(callback) { + plugins.reload(function() { + async.parallel([ + async.apply(Meta.js.minify, false), + async.apply(Meta.css.minify) + ], callback); + }); }; Meta.restart = function() { diff --git a/src/socket.io/admin.js b/src/socket.io/admin.js index bc8140a2a1..f51b0dd2a7 100644 --- a/src/socket.io/admin.js +++ b/src/socket.io/admin.js @@ -38,6 +38,10 @@ SocketAdmin.before = function(socket, method, next) { }); }; +SocketAdmin.reload = function(socket, data, callback) { + meta.reload(callback); +}; + SocketAdmin.restart = function(socket, data, callback) { meta.restart(); };