mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
more fixes to ajaxify, updated /users blocks to sit flush to the left, started work on the ACP including basic templates, added a method to get active users in all rooms (socket connections), added more routes mostly pointing to admin, added a routing folder to start organizing routes better, starting with admin.
This commit is contained in:
62
src/routes/admin.js
Normal file
62
src/routes/admin.js
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
(function(Admin) {
|
||||
Admin.create_routes = function(app) {
|
||||
|
||||
(function() {
|
||||
var routes = ['categories', 'users', 'topics', 'settings', 'themes', 'twitter', 'facebook', 'gplus'];
|
||||
|
||||
for (var i=0, ii=routes.length; i<ii; i++) {
|
||||
(function(route) {
|
||||
app.get('/admin/' + route, function(req, res) {
|
||||
res.send(templates['admin/header'] + app.create_route('admin/' + route) + templates['admin/footer']);
|
||||
});
|
||||
}(routes[i]));
|
||||
}
|
||||
}());
|
||||
|
||||
//todo consolidate.
|
||||
app.get('/admin', function(req, res) {
|
||||
res.send(templates['admin/header'] + app.create_route('admin/index') + templates['admin/footer']);
|
||||
});
|
||||
app.get('/admin/index', function(req, res) {
|
||||
res.send(templates['admin/header'] + app.create_route('admin/index') + templates['admin/footer']);
|
||||
});
|
||||
|
||||
|
||||
function api_method(req, res) {
|
||||
switch(req.params.method) {
|
||||
case 'users' :
|
||||
if (req.params.tab == 'search') {
|
||||
res.send(JSON.stringify({search_display: 'block', users: []}))
|
||||
} else {
|
||||
global.modules.user.getUserList(function(data){
|
||||
res.send(JSON.stringify({search_display: 'none', users:data}));
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
case 'categories':
|
||||
if (req.params.tab == 'disabled') {
|
||||
res.send(JSON.stringify({categories: []}));
|
||||
} else {
|
||||
global.modules.categories.get(function(data) {
|
||||
res.send(JSON.stringify(data));
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'topics' :
|
||||
global.modules.topics.get(function(data) {
|
||||
res.send(JSON.stringify(data));
|
||||
});
|
||||
break;
|
||||
default :
|
||||
res.send('{}');
|
||||
}
|
||||
}
|
||||
|
||||
app.get('/api/admin/:method/:tab?*', api_method);
|
||||
app.get('/api/admin/:method*', api_method);
|
||||
};
|
||||
|
||||
|
||||
}(exports));
|
||||
Reference in New Issue
Block a user