ultimate acp route refactorizationing

v1.18.x
psychobunny 10 years ago
parent 6a9b131223
commit 341959be82

@ -1,198 +0,0 @@
"use strict";
/* global define, app, socket */
define('forum/admin/extend/widgets', function() {
var Widgets = {};
Widgets.init = function() {
prepareWidgets();
$('#widgets .nav-pills a').on('click', function(ev) {
var $this = $(this);
$('#widgets .nav-pills li').removeClass('active');
$this.parent().addClass('active');
$('#widgets .tab-pane').removeClass('active');
$('#widgets .tab-pane[data-template="' + $this.attr('data-template') + '"]').addClass('active');
ev.preventDefault();
return false;
});
};
function prepareWidgets() {
$('[data-location="drafts"]').insertAfter($('[data-location="drafts"]').closest('.tab-content'));
$('#widgets .available-widgets .panel').draggable({
helper: function(e) {
return $(e.target).parents('.panel').clone().addClass('block').width($(e.target.parentNode).width());
},
distance: 10,
connectToSortable: ".widget-area"
});
$('#widgets .available-containers .containers > [data-container-html]').draggable({
helper: function(e) {
var target = $(e.target);
target = target.attr('data-container-html') ? target : target.parents('[data-container-html]');
return target.clone().addClass('block').width(target.width()).css('opacity', '0.5');
},
distance: 10
});
function appendToggle(el) {
if (!el.hasClass('block')) {
el.addClass('block')
.droppable({
accept: '[data-container-html]',
drop: function(event, ui) {
var el = $(this);
el.find('.panel-body .container-html').val(ui.draggable.attr('data-container-html'));
el.find('.panel-body').removeClass('hidden');
},
hoverClass: "panel-info"
})
.children('.panel-heading')
.append('<div class="pull-right pointer"><span class="delete-widget"><i class="fa fa-times-circle"></i></span></div><div class="pull-left pointer"><span class="toggle-widget"><i class="fa fa-chevron-circle-down"></i></span>&nbsp;</div>')
.children('small').html('');
}
}
$('#widgets .widget-area').sortable({
update: function (event, ui) {
appendToggle(ui.item);
},
connectWith: "div"
}).on('click', '.toggle-widget', function() {
$(this).parents('.panel').children('.panel-body').toggleClass('hidden');
}).on('click', '.delete-widget', function() {
var panel = $(this).parents('.panel');
bootbox.confirm('Are you sure you wish to delete this widget?', function(confirm) {
if (confirm) {
panel.remove();
}
});
}).on('dblclick', '.panel-heading', function() {
$(this).parents('.panel').children('.panel-body').toggleClass('hidden');
});
$('#widgets .save').on('click', saveWidgets);
function saveWidgets() {
var total = $('#widgets [data-template][data-location]').length;
$('#widgets [data-template][data-location]').each(function(i, el) {
el = $(el);
var template = el.attr('data-template'),
location = el.attr('data-location'),
area = el.children('.widget-area'),
widgets = [];
area.find('.panel[data-widget]').each(function() {
var widgetData = {},
data = $(this).find('form').serializeArray();
for (var d in data) {
if (data.hasOwnProperty(d)) {
if (data[d].name) {
widgetData[data[d].name] = data[d].value;
}
}
}
widgets.push({
widget: $(this).attr('data-widget'),
data: widgetData
});
});
socket.emit('admin.widgets.set', {
template: template,
location: location,
widgets: widgets
}, function(err) {
total--;
if (err) {
app.alertError(err.message);
}
if (total === 0) {
app.alert({
alert_id: 'admin:widgets',
type: 'success',
title: 'Widgets Updated',
message: 'Successfully updated widgets',
timeout: 2500
});
}
});
});
}
function populateWidget(widget, data) {
if (data.title) {
var title = widget.find('.panel-heading strong');
title.text(title.text() + ' - ' + data.title);
}
widget.find('input, textarea').each(function() {
var input = $(this),
value = data[input.attr('name')];
if (this.type === 'checkbox') {
input.attr('checked', !!value);
} else {
input.val(value);
}
});
return widget;
}
$.get(RELATIVE_PATH + '/api/admin/appearance/widgets', function(data) {
var areas = data.areas;
for(var i=0; i<areas.length; ++i) {
var area = areas[i],
widgetArea = $('#widgets .area[data-template="' + area.template + '"][data-location="' + area.location + '"]').find('.widget-area');
widgetArea.html('');
for (var k=0; k<area.data.length; ++k) {
var widgetData = area.data[k],
widgetEl = $('.available-widgets [data-widget="' + widgetData.widget + '"]').clone(true);
widgetArea.append(populateWidget(widgetEl, widgetData.data));
appendToggle(widgetEl);
}
}
});
$('.color-selector').on('click', '.btn', function() {
var btn = $(this),
selector = btn.parents('.color-selector'),
container = selector.parents('[data-container-html]'),
classList = [];
selector.children().each(function() {
classList.push($(this).attr('data-class'));
});
container
.removeClass(classList.join(' '))
.addClass(btn.attr('data-class'));
container.attr('data-container-html', container.attr('data-container-html')
.replace(/class="[a-zA-Z0-9-\s]+"/, 'class="' + container[0].className.replace(' pointer ui-draggable', '') + '"')
);
});
}
return Widgets;
});

@ -1,7 +1,7 @@
"use strict";
/* global define, app, socket */
define('forum/admin/plugins', function() {
define('forum/admin/extend/plugins', function() {
var Plugins = {
init: function() {
var pluginsList = $('.plugins'),

@ -1,7 +1,7 @@
"use strict";
/*global define, ajaxify, app, socket, RELATIVE_PATH*/
define('forum/admin/index', ['semver'], function(semver) {
define('forum/admin/general/index', ['semver'], function(semver) {
var Admin = {};
var updateIntervalId = 0;
Admin.init = function() {

@ -0,0 +1,8 @@
"use strict";
/*global define*/
define('forum/admin/general/languages', ['forum/admin/settings'], function(Settings) {
$(function() {
Settings.prepare();
});
});

@ -1,7 +1,7 @@
"use strict";
/* global define, socket */
define('forum/admin/sounds', ['sounds', 'settings'], function(Sounds, Settings) {
define('forum/admin/general/sounds', ['sounds', 'forum/admin/settings'], function(Sounds, Settings) {
var SoundsAdmin = {};
SoundsAdmin.init = function() {

@ -1,8 +0,0 @@
"use strict";
/*global define*/
define('forum/admin/languages', ['forum/admin/settings'], function(Settings) {
$(function() {
Settings.prepare();
});
});

@ -1,7 +1,7 @@
"use strict";
/*global define, socket, app, bootbox, templates, ajaxify, RELATIVE_PATH*/
define('forum/admin/categories', ['uploader', 'forum/admin/iconSelect'], function(uploader, iconSelect) {
define('forum/admin/manage/categories', ['uploader', 'forum/admin/iconSelect'], function(uploader, iconSelect) {
var Categories = {};
Categories.init = function() {

@ -1,7 +1,7 @@
"use strict";
/*global define, templates, socket, ajaxify, app, bootbox*/
define('forum/admin/groups', ['forum/admin/iconSelect'], function(iconSelect) {
define('forum/admin/manage/groups', ['forum/admin/iconSelect'], function(iconSelect) {
var Groups = {};
Groups.init = function() {

@ -1,7 +1,7 @@
"use strict";
/*global define, socket, app, admin, utils, bootbox, RELATIVE_PATH*/
define('forum/admin/tags', ['forum/infinitescroll'], function(infinitescroll) {
define('forum/admin/manage/tags', ['forum/infinitescroll'], function(infinitescroll) {
var Tags = {};
var timeoutId = 0;

@ -1,6 +1,6 @@
"use strict";
/* global socket, define, templates, bootbox, app, ajaxify, */
define('forum/admin/users', function() {
define('forum/admin/manage/users', function() {
var Users = {};
Users.init = function() {
@ -227,7 +227,7 @@ define('forum/admin/users', function() {
return app.alertError(err.message);
}
ajaxify.loadTemplate('admin/users', function(adminUsers) {
ajaxify.loadTemplate('admin/manage/users', function(adminUsers) {
$('.users').html(templates.parse(templates.getBlock(adminUsers, 'users'), data));
$('.fa-spinner').addClass('hidden');
@ -251,7 +251,7 @@ define('forum/admin/users', function() {
handleUserCreate();
function onUsersLoaded(users) {
ajaxify.loadTemplate('admin/users', function(adminUsers) {
ajaxify.loadTemplate('admin/manage/users', function(adminUsers) {
var html = $(templates.parse(templates.getBlock(adminUsers, 'users'), {users: users}));
$('#users-container').append(html);
});

@ -53,7 +53,7 @@ adminController.home = function(req, res, next) {
if (err) {
return next(err);
}
res.render('admin/index', {
res.render('admin/general/index', {
version: pkg.version,
notices: results.notices,
stats: results.stats
@ -137,7 +137,7 @@ function filterAndRenderCategories(req, res, next, active) {
return active ? !category.disabled : category.disabled;
});
res.render('admin/categories', {
res.render('admin/manage/categories', {
categories: categoryData,
csrf: req.csrfToken()
});
@ -150,13 +150,13 @@ adminController.tags.get = function(req, res, next) {
return next(err);
}
res.render('admin/tags', {tags: tags});
res.render('admin/managetags', {tags: tags});
});
};
adminController.database.get = function(req, res, next) {
db.info(function (err, data) {
res.render('admin/database', data);
res.render('admin/advanced/database', data);
});
};
@ -167,7 +167,7 @@ adminController.events.get = function(req, res, next) {
}
data = data.toString().split('\n').reverse().join('\n');
res.render('admin/events', {
res.render('admin/advanced/events', {
eventdata: data
});
});
@ -179,7 +179,7 @@ adminController.plugins.get = function(req, res, next) {
plugins = [];
}
res.render('admin/plugins' , {
res.render('admin/extend/plugins' , {
plugins: plugins
});
})
@ -187,7 +187,7 @@ adminController.plugins.get = function(req, res, next) {
adminController.languages.get = function(req, res, next) {
languages.list(function(err, languages) {
res.render('admin/languages', {
res.render('admin/general/languages', {
languages: languages
});
});
@ -202,7 +202,7 @@ adminController.settings.get = function(req, res, next) {
};
adminController.logger.get = function(req, res, next) {
res.render('admin/logger', {});
res.render('admin/development/logger', {});
};
adminController.appearance.get = function(req, res, next) {
@ -280,7 +280,7 @@ adminController.groups.get = function(req, res, next) {
groups = groups.filter(function(group) {
return group.name !== 'registered-users' && group.name !== 'guests';
});
res.render('admin/groups', {
res.render('admin/manage/groups', {
groups: groups,
yourid: req.user.uid
});
@ -295,7 +295,7 @@ adminController.sounds.get = function(req, res, next) {
};
});
res.render('admin/sounds', {
res.render('admin/general/sounds', {
sounds: sounds
});
});

@ -6,7 +6,7 @@ var user = require('./../../user');
var usersController = {};
usersController.search = function(req, res, next) {
res.render('admin/users', {
res.render('admin/manage/users', {
search_display: '',
loadmore_display: 'none',
users: []
@ -30,7 +30,7 @@ function getUsers(set, req, res, next) {
if (err) {
return next(err);
}
res.render('admin/users', {
res.render('admin/manage/users', {
search_display: 'hidden',
loadmore_display: 'block',
users: users,

@ -36,35 +36,35 @@ function apiRouter(middleware, controllers) {
}
function addRoutes(router, middleware, controllers) {
//main
router.get('/index', controllers.admin.home);
router.get('/plugins', controllers.admin.plugins.get);
router.get('/general/index', controllers.admin.home);
router.get('/general/languages', controllers.admin.languages.get);
router.get('/general/sounds', controllers.admin.sounds.get);
router.get('/manage/categories', middleware.applyCSRF, controllers.admin.categories.active);
router.get('/manage/categories/active', middleware.applyCSRF, controllers.admin.categories.active);
router.get('/manage/categories/disabled', middleware.applyCSRF, controllers.admin.categories.disabled);
router.get('/manage/tags', controllers.admin.tags.get);
router.get('/manage/users', controllers.admin.users.search);
router.get('/manage/users/search', controllers.admin.users.search);
router.get('/manage/users/latest', controllers.admin.users.sortByJoinDate);
router.get('/manage/users/sort-posts', controllers.admin.users.sortByPosts);
router.get('/manage/users/sort-reputation', controllers.admin.users.sortByReputation);
router.get('/manage/groups', controllers.admin.groups.get);
router.get('/settings/:term?', middleware.applyCSRF, controllers.admin.settings.get);
router.get('/appearance/:term?', controllers.admin.appearance.get);
router.get('/extend/plugins', controllers.admin.plugins.get);
router.get('/extend/widgets', controllers.admin.extend.widgets);
router.get('/languages', controllers.admin.languages.get);
router.get('/groups', controllers.admin.groups.get);
router.get('/sounds', controllers.admin.sounds.get);
//settings
router.get('/settings/:term?', middleware.applyCSRF, controllers.admin.settings.get);
router.get('/advanced/database', controllers.admin.database.get);
router.get('/advanced/events', controllers.admin.events.get);
//user
router.get('/users', controllers.admin.users.search);
router.get('/users/search', controllers.admin.users.search);
router.get('/users/latest', controllers.admin.users.sortByJoinDate);
router.get('/users/sort-posts', controllers.admin.users.sortByPosts);
router.get('/users/sort-reputation', controllers.admin.users.sortByReputation);
//forum
router.get('/categories', middleware.applyCSRF, controllers.admin.categories.active);
router.get('/categories/active', middleware.applyCSRF, controllers.admin.categories.active);
router.get('/categories/disabled', middleware.applyCSRF, controllers.admin.categories.disabled);
router.get('/tags', controllers.admin.tags.get);
//misc
router.get('/database', controllers.admin.database.get);
router.get('/events', controllers.admin.events.get);
router.get('/logger', controllers.admin.logger.get);
router.get('/development/logger', controllers.admin.logger.get);
}
module.exports = function(app, middleware, controllers) {

@ -55,7 +55,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand nodebb-logo" href="{relative_path}/admin/index"><img src="{relative_path}/images/logo.png" alt="NodeBB ACP" /> Admin Control Panel <span id="breadcrumbs"></span></a>
<a class="navbar-brand nodebb-logo" href="{relative_path}/admin/general/index"><img src="{relative_path}/images/logo.png" alt="NodeBB ACP" /> Admin Control Panel <span id="breadcrumbs"></span></a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
@ -99,18 +99,18 @@
<div class="sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header"><i class="fa fa-fw fa-dashboard"></i> General</li>
<li class="active"><a href="{relative_path}/admin/index">Dashboard</a></li>
<li><a href="{relative_path}/admin/languages">Languages</a></li>
<li><a href="{relative_path}/admin/sounds">Sounds</a></li>
<li class="active"><a href="{relative_path}/admin/general/index">Dashboard</a></li>
<li><a href="{relative_path}/admin/general/languages">Languages</a></li>
<li><a href="{relative_path}/admin/general/sounds">Sounds</a></li>
</ul>
</div>
<div class="sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header"><i class="fa fa-fw fa-comments-o"></i> Manage</li>
<li><a href="{relative_path}/admin/categories/active">Categories</a></li>
<li><a href="{relative_path}/admin/tags">Tags</a></li>
<li><a href="{relative_path}/admin/users/latest">Users</a></li>
<li><a href="{relative_path}/admin/groups">Groups</a></li>
<li><a href="{relative_path}/admin/manage/categories/active">Categories</a></li>
<li><a href="{relative_path}/admin/manage/tags">Tags</a></li>
<li><a href="{relative_path}/admin/manage/users/latest">Users</a></li>
<li><a href="{relative_path}/admin/manage/groups">Groups</a></li>
</ul>
</div>
<div class="sidebar-nav">
@ -139,22 +139,22 @@
<div class="sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header"><i class="fa fa-fw fa-wrench"></i> Extend</li>
<li><a href="{relative_path}/admin/plugins">Plugins</a></li>
<li><a href="{relative_path}/admin/extend/plugins">Plugins</a></li>
<li><a href="{relative_path}/admin/extend/widgets">Widgets</a></li>
</ul>
</div>
<div class="sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header"><i class="fa fa-fw fa-hdd-o"></i> Advanced</li>
<li><a href="{relative_path}/admin/database">Database</a></li>
<li><a href="{relative_path}/admin/events">Events</a></li>
<li><a href="{relative_path}/admin/advanced/database">Database</a></li>
<li><a href="{relative_path}/admin/advanced/events">Events</a></li>
</ul>
</div>
<div class="sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header"><i class="fa fa-fw fa-facebook-square"></i> Social Authentication</li>
<!-- IF !authentication.length -->
<li><a href="{relative_path}/admin/plugins">Install SSO Plugins</a></li>
<li><a href="{relative_path}/admin/extend/plugins">Install SSO Plugins</a></li>
<!-- ENDIF !authentication.length -->
<!-- BEGIN authentication -->
<li>
@ -177,7 +177,7 @@
<div class="sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header"><i class="fa fa-fw fa-th"></i> Development</li>
<li><a href="{relative_path}/admin/logger">Logger</a></li>
<li><a href="{relative_path}/admin/development/logger">Logger</a></li>
</ul>
</div>
<!-- ENDIF env -->

@ -8,8 +8,8 @@
</h1>
<hr />
<ul class="nav nav-pills">
<li class='active'><a href='/admin/categories/active'>Active</a></li>
<li class=''><a href='/admin/categories/disabled'>Disabled</a></li>
<li class='active'><a href='/admin/manage/categories/active'>Active</a></li>
<li class=''><a href='/admin/manage/categories/disabled'>Disabled</a></li>
</ul>
<div class="row admin-categories">

@ -4,10 +4,10 @@
<a target="_blank" href="/admin/users/csv" class="btn btn-primary">Download CSV</a>
<hr />
<ul class="nav nav-pills">
<li class='active'><a href='{relative_path}/admin/users/search'>Search</a></li>
<li class=''><a href='{relative_path}/admin/users/latest'>Latest Users</a></li>
<li class=''><a href='{relative_path}/admin/users/sort-posts'>Top Posters</a></li>
<li class=''><a href='{relative_path}/admin/users/sort-reputation'>Most Reputation</a></li>
<li class='active'><a href='{relative_path}/admin/manage/users/search'>Search</a></li>
<li class=''><a href='{relative_path}/admin/manage/users/latest'>Latest Users</a></li>
<li class=''><a href='{relative_path}/admin/manage/users/sort-posts'>Top Posters</a></li>
<li class=''><a href='{relative_path}/admin/manage/users/sort-reputation'>Most Reputation</a></li>
<div class="btn-group pull-right">
Loading…
Cancel
Save