2017-02-18 01:56:23 -07:00
|
|
|
'use strict';
|
2015-06-08 15:50:33 -04:00
|
|
|
|
2018-03-26 13:53:07 -06:00
|
|
|
define('admin/modules/instance', [
|
2021-12-06 12:45:35 -05:00
|
|
|
'alerts',
|
|
|
|
|
], function (alerts) {
|
2021-10-12 17:26:18 +03:00
|
|
|
const instance = {};
|
2015-06-08 15:50:33 -04:00
|
|
|
|
2018-03-26 15:17:40 -04:00
|
|
|
instance.rebuildAndRestart = function (callback) {
|
2021-12-06 12:45:35 -05:00
|
|
|
alerts.alert({
|
2018-03-26 15:17:40 -04:00
|
|
|
alert_id: 'instance_rebuild_and_restart',
|
2015-06-08 15:50:33 -04:00
|
|
|
type: 'info',
|
2018-03-26 15:17:40 -04:00
|
|
|
title: 'Rebuilding... <i class="fa fa-spin fa-refresh"></i>',
|
|
|
|
|
message: 'NodeBB is rebuilding front-end assets (css, javascript, etc).',
|
2015-06-08 15:50:33 -04:00
|
|
|
});
|
|
|
|
|
|
2016-11-18 12:53:26 -05:00
|
|
|
$(window).one('action:reconnected', function () {
|
2021-12-06 12:45:35 -05:00
|
|
|
alerts.alert({
|
2018-03-26 15:17:40 -04:00
|
|
|
alert_id: 'instance_rebuild_and_restart',
|
2016-11-18 12:53:26 -05:00
|
|
|
type: 'success',
|
|
|
|
|
title: '<i class="fa fa-check"></i> Success',
|
2018-03-26 15:17:40 -04:00
|
|
|
message: 'NodeBB has rebuilt and restarted successfully.',
|
2017-02-17 19:31:21 -07:00
|
|
|
timeout: 5000,
|
2016-11-18 12:53:26 -05:00
|
|
|
});
|
2015-06-08 15:50:33 -04:00
|
|
|
|
|
|
|
|
if (typeof callback === 'function') {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-11-18 12:53:26 -05:00
|
|
|
|
2018-03-26 15:17:40 -04:00
|
|
|
socket.emit('admin.reload', function () {
|
2021-12-06 12:45:35 -05:00
|
|
|
alerts.alert({
|
2018-03-26 15:17:40 -04:00
|
|
|
alert_id: 'instance_rebuild_and_restart',
|
|
|
|
|
type: 'info',
|
|
|
|
|
title: 'Build Complete!... <i class="fa fa-spin fa-refresh"></i>',
|
|
|
|
|
message: 'NodeBB is restarting.',
|
|
|
|
|
});
|
|
|
|
|
});
|
2015-06-08 15:53:07 -04:00
|
|
|
};
|
2015-06-08 15:52:39 -04:00
|
|
|
|
2016-10-13 11:43:39 +02:00
|
|
|
instance.restart = function (callback) {
|
2021-12-06 12:45:35 -05:00
|
|
|
alerts.alert({
|
2015-06-08 15:52:39 -04:00
|
|
|
alert_id: 'instance_restart',
|
|
|
|
|
type: 'info',
|
2018-03-26 15:17:40 -04:00
|
|
|
title: 'Restarting... <i class="fa fa-spin fa-refresh"></i>',
|
|
|
|
|
message: 'NodeBB is restarting.',
|
2015-06-08 15:52:39 -04:00
|
|
|
});
|
|
|
|
|
|
2016-10-13 11:43:39 +02:00
|
|
|
$(window).one('action:reconnected', function () {
|
2021-12-06 12:45:35 -05:00
|
|
|
alerts.alert({
|
2015-06-08 15:52:39 -04:00
|
|
|
alert_id: 'instance_restart',
|
|
|
|
|
type: 'success',
|
|
|
|
|
title: '<i class="fa fa-check"></i> Success',
|
2018-03-26 15:17:40 -04:00
|
|
|
message: 'NodeBB has restarted successfully.',
|
|
|
|
|
timeout: 5000,
|
2015-06-08 15:52:39 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (typeof callback === 'function') {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2018-03-26 15:17:40 -04:00
|
|
|
socket.emit('admin.restart');
|
2015-06-08 15:53:07 -04:00
|
|
|
};
|
2016-12-15 13:03:14 +03:00
|
|
|
|
2015-06-08 15:50:33 -04:00
|
|
|
return instance;
|
|
|
|
|
});
|