mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
closes #2749
This commit is contained in:
@@ -93,6 +93,38 @@ define('admin/extend/plugins', function() {
|
||||
$(this).toggleClass('hide', pluginId && pluginId.indexOf(term) === -1);
|
||||
});
|
||||
});
|
||||
|
||||
$('#plugin-order').on('click', function() {
|
||||
$('#order-active-plugins-modal').modal('show');
|
||||
socket.emit('admin.plugins.getActive', function(err, activePlugins) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
var html = '';
|
||||
activePlugins.forEach(function(plugin) {
|
||||
html += '<li class="">' + plugin + '</li>';
|
||||
});
|
||||
if (!activePlugins.length) {
|
||||
html = 'No Active Plugins';
|
||||
}
|
||||
$('#order-active-plugins-modal .plugin-list').html(html).sortable();
|
||||
});
|
||||
});
|
||||
|
||||
$('#save-plugin-order').on('click', function() {
|
||||
var plugins = $('#order-active-plugins-modal .plugin-list').children();
|
||||
var data = [];
|
||||
plugins.each(function(index, el) {
|
||||
data.push({name: $(el).text(), order: index});
|
||||
});
|
||||
|
||||
socket.emit('admin.plugins.orderActivePlugins', data, function(err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
$('#order-active-plugins-modal').modal('hide');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function confirmInstall(pluginID, callback) {
|
||||
|
||||
@@ -110,7 +110,7 @@ var fs = require('fs'),
|
||||
});
|
||||
|
||||
async.filter(plugins, fs.exists, function(plugins){
|
||||
async.each(plugins, Plugins.loadPlugin, next);
|
||||
async.eachSeries(plugins, Plugins.loadPlugin, next);
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
@@ -262,7 +262,10 @@ var fs = require('fs'),
|
||||
|
||||
function(dirs, next) {
|
||||
dirs = dirs.filter(function(dir){
|
||||
return dir.startsWith('nodebb-plugin-') || dir.startsWith('nodebb-widget-') || dir.startsWith('nodebb-rewards-') || dir.startsWith('nodebb-theme-')
|
||||
return dir.startsWith('nodebb-plugin-') ||
|
||||
dir.startsWith('nodebb-widget-') ||
|
||||
dir.startsWith('nodebb-rewards-') ||
|
||||
dir.startsWith('nodebb-theme-');
|
||||
}).map(function(dir){
|
||||
return path.join(npmPluginPath, dir);
|
||||
});
|
||||
|
||||
@@ -130,4 +130,8 @@ module.exports = function(Plugins) {
|
||||
Plugins.isActive = function(id, callback) {
|
||||
db.isSortedSetMember('plugins:active', id, callback);
|
||||
};
|
||||
|
||||
Plugins.getActive = function(callback) {
|
||||
db.getSortedSetRange('plugins:active', 0, -1, callback);
|
||||
};
|
||||
};
|
||||
@@ -110,6 +110,20 @@ SocketAdmin.plugins.toggleInstall = function(socket, data, callback) {
|
||||
plugins.toggleInstall(data.id, data.version, callback);
|
||||
};
|
||||
|
||||
SocketAdmin.plugins.getActive = function(socket, data, callback) {
|
||||
plugins.getActive(callback);
|
||||
};
|
||||
|
||||
SocketAdmin.plugins.orderActivePlugins = function(socket, data, callback) {
|
||||
async.each(data, function(plugin, next) {
|
||||
if (plugin && plugin.name) {
|
||||
db.sortedSetAdd('plugins:active', plugin.order || 0, plugin.name, next);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}, callback);
|
||||
};
|
||||
|
||||
SocketAdmin.plugins.upgrade = function(socket, data, callback) {
|
||||
plugins.upgrade(data.id, data.version, callback);
|
||||
};
|
||||
|
||||
@@ -83,7 +83,8 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Plugin Search</div>
|
||||
<div class="panel-body">
|
||||
<input class="form-control" type="text" id="plugin-search" placeholder="Search for plugin..."/>
|
||||
<input class="form-control" type="text" id="plugin-search" placeholder="Search for plugin..."/><br/>
|
||||
<button class="btn btn-default" id="plugin-order">Order Active Plugins</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -96,4 +97,30 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="order-active-plugins-modal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">Order Active Plugins</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Plugins load in the order specified here, from top to bottom</p>
|
||||
<ul class="plugin-list">
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary" id="save-plugin-order">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user