mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
admin panel integration completion + styling of admin panel plugins page
This commit is contained in:
@@ -145,6 +145,18 @@
|
||||
.plugins {
|
||||
li {
|
||||
list-style-type: none;
|
||||
background: rgba(64, 64, 64, 0.05);
|
||||
padding: 1em;
|
||||
border-left: 5px solid #08c;
|
||||
|
||||
h2 {
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,20 +3,31 @@ var nodebb_admin = nodebb_admin || {};
|
||||
(function() {
|
||||
var plugins = {
|
||||
init: function() {
|
||||
// socket.on('api:admin.plugins.getInstalled', function(pluginsArr) {
|
||||
// var pluginsFrag = document.createDocumentFragment(),
|
||||
// liEl = document.createElement('li');
|
||||
// for(var x=0,numPlugins=pluginsArr.length;x<numPlugins;x++) {
|
||||
// liEl.setAttribute('data-plugin-id', pluginsArr[x].id);
|
||||
var pluginsList = $('.plugins'),
|
||||
pluginID, pluginTgl;
|
||||
|
||||
// }
|
||||
// });
|
||||
pluginsList.on('click', 'button[data-action="toggleActive"]', function() {
|
||||
pluginID = $(this).parents('li').attr('data-plugin-id');
|
||||
socket.emit('api:admin.plugins.toggle', pluginID);
|
||||
});
|
||||
|
||||
socket.on('api:admin.plugins.toggle', function(status) {
|
||||
pluginTgl = document.querySelector('.plugins li[data-plugin-id="' + status.id + '"] button');
|
||||
pluginTgl.innerHTML = '<i class="icon-off"></i> ' + (status.active ? 'Dea' : 'A') + 'ctivate';
|
||||
|
||||
app.alert({
|
||||
alert_id: 'plugin_toggled_' + status.id,
|
||||
title: 'Plugin Enabled',
|
||||
message: 'You may need to restart NodeBB in order for these changes to be reflected.',
|
||||
type: 'notify',
|
||||
timeout: 5000
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
nodebb_admin.plugins = plugins;
|
||||
nodebb_admin.plugins.init();
|
||||
// socket.emit('api:admin.plugins.getInstalled');
|
||||
});
|
||||
})();
|
||||
@@ -4,11 +4,13 @@
|
||||
<!-- BEGIN plugins -->
|
||||
<li data-plugin-id="{plugins.id}">
|
||||
<h2>{plugins.name}</h2>
|
||||
<div class="pull-right">
|
||||
<button data-action="toggleActive" class="btn btn-primary">{plugins.activeText}</button>
|
||||
</div>
|
||||
<p>{plugins.description}</p>
|
||||
<p>For more information: <a href="{plugins.url}">{plugins.url}</a></p>
|
||||
</li>
|
||||
<!-- END plugins -->
|
||||
<!-- <li><i class="icon-refresh icon-spin"></i> Loading plugins</li> -->
|
||||
</ul>
|
||||
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/admin/plugins.js"></script>
|
||||
@@ -178,29 +178,18 @@ var fs = require('fs'),
|
||||
delete config.library;
|
||||
delete config.hooks;
|
||||
config.active = active;
|
||||
config.activeText = '<i class="icon-off"></i> ' + (active ? 'Dea' : 'A') + 'ctivate';
|
||||
next(null, config);
|
||||
});
|
||||
}
|
||||
], function(err, config) {
|
||||
if (err) next(); // Silently fail
|
||||
if (err) return next(); // Silently fail
|
||||
|
||||
plugins.push(config);
|
||||
next();
|
||||
});
|
||||
// fs.stat(path.join(moduleBasePath, file), function(err, stats) {
|
||||
// if (err || !stats.isDirectory()) return next(); // Silently fail
|
||||
|
||||
// // Load the config file
|
||||
// fs.readFile(path.join(modulePath, 'plugin.json'), function(err, configJSON) {
|
||||
// if (err) return next(); // Silently fail if config can't be read
|
||||
// var config = JSON.parse(configJSON);
|
||||
// delete config.library;
|
||||
// delete config.hooks;
|
||||
|
||||
// plugins.push(config);
|
||||
// next();
|
||||
// });
|
||||
// });
|
||||
}, function(err) {
|
||||
console.log(plugins);
|
||||
next(null, plugins);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -633,11 +633,9 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('api:admin.plugins.getInstalled', function() {
|
||||
plugins.showInstalled(function(err, plugins) {
|
||||
if (err) plugins = [];
|
||||
|
||||
return socket.emit('api:admin.plugins.getInstalled', plugins);
|
||||
socket.on('api:admin.plugins.toggle', function(plugin_id) {
|
||||
plugins.toggleActive(plugin_id, function(status) {
|
||||
socket.emit('api:admin.plugins.toggle', status);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user