Add blocked users count to dashboard

This commit is contained in:
Neil Lalonde 2013-07-08 12:21:08 -04:00
parent cfc4dda9ff
commit 9b0f63627b
9 changed files with 47 additions and 27 deletions

View File

@ -23,12 +23,9 @@ Discourse.AdminDashboardRoute = Discourse.Route.extend({
_.each(d.reports,function(report){ _.each(d.reports,function(report){
c.set(report.type, Discourse.Report.create(report)); c.set(report.type, Discourse.Report.create(report));
}); });
c.set('admins', d.admins); _.each(['admins', 'moderators', 'blocked', 'banned', 'top_referrers', 'top_traffic_sources', 'top_referred_topics'], function(x) {
c.set('moderators', d.moderators); c.set(x, d[x]);
c.set('blocked', d.blocked); });
c.set('top_referrers', d.top_referrers);
c.set('top_traffic_sources', d.top_traffic_sources);
c.set('top_referred_topics', d.top_referred_topics);
c.set('loading', false); c.set('loading', false);
}); });
} }

View File

@ -34,18 +34,10 @@ Discourse.Route.buildRoutes(function() {
this.resource('adminUsers', { path: '/users' }, function() { this.resource('adminUsers', { path: '/users' }, function() {
this.resource('adminUser', { path: '/:username' }); this.resource('adminUser', { path: '/:username' });
this.resource('adminUsersList', { path: '/list' }, function() { this.resource('adminUsersList', { path: '/list' }, function() {
this.route('active', { path: '/active' }); _.each(['active', 'new', 'pending', 'admins', 'moderators', 'blocked', 'banned',
this.route('new', { path: '/new' }); 'newuser', 'basic', 'regular', 'leaders', 'elders'], function(x) {
this.route('pending', { path: '/pending' }); this.route(x, { path: '/' + x });
this.route('admins', { path: '/admins' }); }, this);
this.route('moderators', { path: '/moderators' });
this.route('blocked', { path: '/blocked' });
// Trust Levels:
this.route('newuser', { path: '/newuser' });
this.route('basic', { path: '/basic' });
this.route('regular', { path: '/regular' });
this.route('leaders', { path: '/leaders' });
this.route('elders', { path: '/elders' });
}); });
}); });

View File

@ -95,3 +95,17 @@ Discourse.AdminUsersListBlockedRoute = Discourse.Route.extend({
return this.controllerFor('adminUsersList').show('blocked'); return this.controllerFor('adminUsersList').show('blocked');
} }
}); });
/**
Handles the route that lists banned users.
@class AdminUsersListBannedRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.AdminUsersListBannedRoute = Discourse.Route.extend({
setupController: function() {
return this.controllerFor('adminUsersList').show('banned');
}
});

View File

@ -97,12 +97,20 @@
</div> </div>
<div class="dashboard-stats totals"> <div class="dashboard-stats totals">
<span class="title"><i class='icon icon-trophy'></i> {{i18n admin.dashboard.admins}}</span> <table>
<span class="value">{{#linkTo 'adminUsersList.admins'}}{{admins}}{{/linkTo}}</span> <tr>
<span class="title"><i class='icon icon-magic'></i> {{i18n admin.dashboard.moderators}}</span> <td class="title"><i class='icon icon-trophy'></i> {{i18n admin.dashboard.admins}}</td>
<span class="value">{{#linkTo 'adminUsersList.moderators'}}{{moderators}}{{/linkTo}}</span> <td class="value">{{#linkTo 'adminUsersList.admins'}}{{admins}}{{/linkTo}}</td>
<span class="title"><i class='icon icon-ban-circle'></i> {{i18n admin.dashboard.blocked}}</span> <td class="title"><i class='icon icon-ban-circle'></i> {{i18n admin.dashboard.banned}}</td>
<span class="value">{{#linkTo 'adminUsersList.blocked'}}{{blocked}}{{/linkTo}}</span> <td class="value">{{#linkTo 'adminUsersList.banned'}}{{banned}}{{/linkTo}}</td>
</tr>
<tr>
<td class="title"><i class='icon icon-magic'></i> {{i18n admin.dashboard.moderators}}</td>
<td class="value">{{#linkTo 'adminUsersList.moderators'}}{{moderators}}{{/linkTo}}</td>
<td class="title"><i class='icon icon-ban-circle'></i> {{i18n admin.dashboard.blocked}}</td>
<td class="value">{{#linkTo 'adminUsersList.blocked'}}{{blocked}}{{/linkTo}}</td>
</tr>
</table>
</div> </div>
<div class="dashboard-stats"> <div class="dashboard-stats">

View File

@ -467,12 +467,16 @@ table {
} }
&.totals { &.totals {
table {
width: auto;
}
margin-top: 12px; margin-top: 12px;
padding-left: 5px; padding-left: 5px;
.value { .value {
text-align: left;
font-weight: bold; font-weight: bold;
margin-left: 8px; padding-left: 8px;
margin-right: 30px; padding-right: 30px;
} }
} }

View File

@ -54,12 +54,13 @@ class AdminDashboardData
reports: REPORTS.map { |type| Report.find(type).as_json }, reports: REPORTS.map { |type| Report.find(type).as_json },
admins: User.admins.count, admins: User.admins.count,
moderators: User.moderators.count, moderators: User.moderators.count,
banned: User.banned.count,
blocked: User.blocked.count, blocked: User.blocked.count,
top_referrers: IncomingLinksReport.find('top_referrers').as_json, top_referrers: IncomingLinksReport.find('top_referrers').as_json,
top_traffic_sources: IncomingLinksReport.find('top_traffic_sources').as_json, top_traffic_sources: IncomingLinksReport.find('top_traffic_sources').as_json,
top_referred_topics: IncomingLinksReport.find('top_referred_topics').as_json top_referred_topics: IncomingLinksReport.find('top_referred_topics').as_json
}.merge( }.merge(
SiteSetting.version_checks? ? {version_check: DiscourseUpdates.check_version} : {} SiteSetting.version_checks? ? {version_check: DiscourseUpdates.check_version.as_json} : {}
) )
end end

View File

@ -64,6 +64,7 @@ class User < ActiveRecord::Base
attr_accessor :notification_channel_position attr_accessor :notification_channel_position
scope :blocked, -> { where(blocked: true) } # no index scope :blocked, -> { where(blocked: true) } # no index
scope :banned, -> { where('banned_till IS NOT NULL AND banned_till > ?', Time.zone.now) } # no index
module NewTopicDuration module NewTopicDuration
ALWAYS = -1 ALWAYS = -1

View File

@ -1009,6 +1009,7 @@ en:
moderators: 'Moderators:' moderators: 'Moderators:'
admins: 'Admins:' admins: 'Admins:'
blocked: 'Blocked:' blocked: 'Blocked:'
banned: 'Banned:'
private_messages_short: "PMs" private_messages_short: "PMs"
private_messages_title: "Private Messages" private_messages_title: "Private Messages"
@ -1151,6 +1152,7 @@ en:
admins: 'Admin Users' admins: 'Admin Users'
moderators: 'Moderators' moderators: 'Moderators'
blocked: 'Blocked Users' blocked: 'Blocked Users'
banned: 'Banned Users'
user: user:
ban_failed: "Something went wrong banning this user {{error}}" ban_failed: "Something went wrong banning this user {{error}}"

View File

@ -27,6 +27,7 @@ class AdminUserIndexQuery
when 'admins' then @query.where('admin = ?', true) when 'admins' then @query.where('admin = ?', true)
when 'moderators' then @query.where('moderator = ?', true) when 'moderators' then @query.where('moderator = ?', true)
when 'blocked' then @query.blocked when 'blocked' then @query.blocked
when 'banned' then @query.banned
when 'pending' then @query.where('approved = false') when 'pending' then @query.where('approved = false')
end end
end end