Admin Dashboard: click numbers in Users per Trust Level table to see a list of the users
This commit is contained in:
parent
e8172e66d2
commit
fe1b979c65
|
@ -11,6 +11,7 @@ Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Pres
|
|||
query: null,
|
||||
selectAll: false,
|
||||
content: null,
|
||||
loading: false,
|
||||
|
||||
/**
|
||||
Triggered when the selectAll property is changed
|
||||
|
@ -42,6 +43,15 @@ Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Pres
|
|||
this.refreshUsers();
|
||||
}).observes('query'),
|
||||
|
||||
/**
|
||||
The title of the user list, based on which query was performed.
|
||||
|
||||
@property title
|
||||
**/
|
||||
title: function() {
|
||||
return Em.String.i18n('admin.users.titles.' + this.get('query'));
|
||||
}.property('query'),
|
||||
|
||||
/**
|
||||
Do we want to show the approval controls?
|
||||
|
||||
|
@ -78,7 +88,9 @@ Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Pres
|
|||
@method refreshUsers
|
||||
**/
|
||||
refreshUsers: function() {
|
||||
this.set('content', Discourse.AdminUser.findAll(this.get('query'), this.get('username')));
|
||||
this.set('loading', true);
|
||||
var _this = this;
|
||||
this.set('content', Discourse.AdminUser.findAll(this.get('query'), this.get('username'), function() { _this.set('loading', false); }));
|
||||
},
|
||||
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ Discourse.AdminUser.reopenClass({
|
|||
});
|
||||
},
|
||||
|
||||
findAll: function(query, filter) {
|
||||
findAll: function(query, filter, doneCallback) {
|
||||
var result = Em.A();
|
||||
Discourse.ajax({
|
||||
url: Discourse.getURL("/admin/users/list/") + query + ".json",
|
||||
|
@ -205,6 +205,7 @@ Discourse.AdminUser.reopenClass({
|
|||
users.each(function(u) {
|
||||
result.pushObject(Discourse.AdminUser.create(u));
|
||||
});
|
||||
if( doneCallback ) { doneCallback(); }
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,12 @@ Discourse.Route.buildRoutes(function() {
|
|||
this.route('active', { path: '/active' });
|
||||
this.route('new', { path: '/new' });
|
||||
this.route('pending', { path: '/pending' });
|
||||
// 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' });
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
Handles the route that lists users at trust level 0.
|
||||
|
||||
@class AdminUsersListNewuserRoute
|
||||
@extends Discourse.Route
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminUsersListNewuserRoute = Discourse.Route.extend({
|
||||
setupController: function() {
|
||||
return this.controllerFor('adminUsersList').show('newuser');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
Handles the route that lists users at trust level 1.
|
||||
|
||||
@class AdminUsersListBasicRoute
|
||||
@extends Discourse.Route
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminUsersListBasicRoute = Discourse.Route.extend({
|
||||
setupController: function() {
|
||||
return this.controllerFor('adminUsersList').show('basic');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
Handles the route that lists users at trust level 2.
|
||||
|
||||
@class AdminUsersListRegularRoute
|
||||
@extends Discourse.Route
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminUsersListRegularRoute = Discourse.Route.extend({
|
||||
setupController: function() {
|
||||
return this.controllerFor('adminUsersList').show('regular');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
Handles the route that lists users at trust level 3.
|
||||
|
||||
@class AdminUsersListLeadersRoute
|
||||
@extends Discourse.Route
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminUsersListLeadersRoute = Discourse.Route.extend({
|
||||
setupController: function() {
|
||||
return this.controllerFor('adminUsersList').show('leader');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
Handles the route that lists users at trust level 4.
|
||||
|
||||
@class AdminUsersListEldersRoute
|
||||
@extends Discourse.Route
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminUsersListEldersRoute = Discourse.Route.extend({
|
||||
setupController: function() {
|
||||
return this.controllerFor('adminUsersList').show('elder');
|
||||
}
|
||||
});
|
|
@ -1,8 +1,8 @@
|
|||
<tr>
|
||||
<td class="title">{{title}}</td>
|
||||
<td class="value">{{valueAtTrustLevel data 0}}</td>
|
||||
<td class="value">{{valueAtTrustLevel data 1}}</td>
|
||||
<td class="value">{{valueAtTrustLevel data 2}}</td>
|
||||
<td class="value">{{valueAtTrustLevel data 3}}</td>
|
||||
<td class="value">{{valueAtTrustLevel data 4}}</td>
|
||||
<td class="value">{{#linkTo 'adminUsersList.newuser'}}{{valueAtTrustLevel data 0}}{{/linkTo}}</td>
|
||||
<td class="value">{{#linkTo 'adminUsersList.basic'}}{{valueAtTrustLevel data 1}}{{/linkTo}}</td>
|
||||
<td class="value">{{#linkTo 'adminUsersList.regular'}}{{valueAtTrustLevel data 2}}{{/linkTo}}</td>
|
||||
<td class="value">{{#linkTo 'adminUsersList.leaders'}}{{valueAtTrustLevel data 3}}{{/linkTo}}</td>
|
||||
<td class="value">{{#linkTo 'adminUsersList.elders'}}{{valueAtTrustLevel data 4}}{{/linkTo}}</td>
|
||||
</tr>
|
|
@ -19,67 +19,74 @@
|
|||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if content.length}}
|
||||
<table class='table'>
|
||||
<tr>
|
||||
{{#if showApproval}}
|
||||
<th>{{view Ember.Checkbox checkedBinding="selectAll"}}</th>
|
||||
{{/if}}
|
||||
<th> </th>
|
||||
<th>{{i18n username}}</th>
|
||||
<th>{{i18n email}}</th>
|
||||
<th>{{i18n admin.users.last_emailed}}</th>
|
||||
<th>{{i18n last_seen}}</th>
|
||||
<th>{{i18n admin.user.topics_entered}}</th>
|
||||
<th>{{i18n admin.user.posts_read_count}}</th>
|
||||
<th>{{i18n admin.user.time_read}}</th>
|
||||
<th>{{i18n created}}</th>
|
||||
{{#if showApproval}}
|
||||
<th>{{i18n admin.users.approved}}</th>
|
||||
{{/if}}
|
||||
<th> </th>
|
||||
<h2>{{title}}</h2>
|
||||
<br/>
|
||||
|
||||
</tr>
|
||||
{{#if loading}}
|
||||
<div class='admin-loading'>{{i18n loading}}</div>
|
||||
{{else}}
|
||||
{{#if content.length}}
|
||||
<table class='table'>
|
||||
<tr>
|
||||
{{#if showApproval}}
|
||||
<th>{{view Ember.Checkbox checkedBinding="selectAll"}}</th>
|
||||
{{/if}}
|
||||
<th> </th>
|
||||
<th>{{i18n username}}</th>
|
||||
<th>{{i18n email}}</th>
|
||||
<th>{{i18n admin.users.last_emailed}}</th>
|
||||
<th>{{i18n last_seen}}</th>
|
||||
<th>{{i18n admin.user.topics_entered}}</th>
|
||||
<th>{{i18n admin.user.posts_read_count}}</th>
|
||||
<th>{{i18n admin.user.time_read}}</th>
|
||||
<th>{{i18n created}}</th>
|
||||
{{#if showApproval}}
|
||||
<th>{{i18n admin.users.approved}}</th>
|
||||
{{/if}}
|
||||
<th> </th>
|
||||
|
||||
{{#each content}}
|
||||
<tr {{bindAttr class="selected"}}>
|
||||
{{#if controller.showApproval}}
|
||||
</tr>
|
||||
|
||||
{{#each content}}
|
||||
<tr {{bindAttr class="selected"}}>
|
||||
{{#if controller.showApproval}}
|
||||
<td>
|
||||
{{#if can_approve}}
|
||||
{{view Ember.Checkbox checkedBinding="selected"}}
|
||||
{{/if}}
|
||||
</td>
|
||||
{{/if}}
|
||||
<td>
|
||||
{{#if can_approve}}
|
||||
{{view Ember.Checkbox checkedBinding="selected"}}
|
||||
<a href="{{unbound adminPath}}">{{avatar this imageSize="small"}}</a>
|
||||
</td>
|
||||
<td><a href="{{unbound adminPath}}">{{unbound username}}</a></td>
|
||||
<td>{{shorten email}}</td>
|
||||
<td>{{{unbound last_emailed_age}}}</td>
|
||||
<td>{{{unbound last_seen_age}}}</td>
|
||||
<td>{{{unbound topics_entered}}}</td>
|
||||
<td>{{{unbound posts_read_count}}}</td>
|
||||
<td>{{{unbound time_read}}}</td>
|
||||
|
||||
<td>{{{unbound created_at_age}}}</td>
|
||||
|
||||
{{#if controller.showApproval}}
|
||||
<td>
|
||||
{{#if approved}}
|
||||
{{i18n yes_value}}
|
||||
{{else}}
|
||||
{{i18n no_value}}
|
||||
{{/if}}
|
||||
</td>
|
||||
{{/if}}
|
||||
<td>
|
||||
<a href="{{unbound adminPath}}">{{avatar this imageSize="small"}}</a>
|
||||
</td>
|
||||
<td><a href="{{unbound adminPath}}">{{unbound username}}</a></td>
|
||||
<td>{{shorten email}}</td>
|
||||
<td>{{{unbound last_emailed_age}}}</td>
|
||||
<td>{{{unbound last_seen_age}}}</td>
|
||||
<td>{{{unbound topics_entered}}}</td>
|
||||
<td>{{{unbound posts_read_count}}}</td>
|
||||
<td>{{{unbound time_read}}}</td>
|
||||
|
||||
<td>{{{unbound created_at_age}}}</td>
|
||||
|
||||
{{#if controller.showApproval}}
|
||||
<td>
|
||||
{{#if approved}}
|
||||
{{i18n yes_value}}
|
||||
{{else}}
|
||||
{{i18n no_value}}
|
||||
{{/if}}
|
||||
</td>
|
||||
{{/if}}
|
||||
<td>
|
||||
{{#if admin}}<i class="icon-trophy" title="{{i18n admin.title}}"></i>{{/if}}
|
||||
{{#if moderator}}<i class="icon-magic" title="{{i18n admin.moderator}}"></i>{{/if}}
|
||||
<td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
<td>
|
||||
{{#if admin}}<i class="icon-trophy" title="{{i18n admin.title}}"></i>{{/if}}
|
||||
{{#if moderator}}<i class="icon-magic" title="{{i18n admin.moderator}}"></i>{{/if}}
|
||||
<td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
||||
</table>
|
||||
{{else}}
|
||||
<div class='admin-loading'>{{i18n loading}}</div>
|
||||
</table>
|
||||
{{else}}
|
||||
<p>{{i18n search.no_results}}</p>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
/**
|
||||
The view that displays the number of users at each trust level
|
||||
on the admin dashboard.
|
||||
|
||||
@class AdminReportTrustLevelsView
|
||||
@extends Discourse.View
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminReportTrustLevelsView = Discourse.View.extend({
|
||||
templateName: 'admin/templates/reports/trust_levels_report',
|
||||
tagName: 'tbody'
|
||||
|
|
|
@ -10,6 +10,10 @@ class Admin::UsersController < Admin::AdminController
|
|||
@users = User.order("created_at DESC, username")
|
||||
end
|
||||
|
||||
if ['newuser', 'basic', 'regular', 'leader', 'elder'].include?(params[:query])
|
||||
@users = @users.where('trust_level = ?', TrustLevel.levels[params[:query].to_sym])
|
||||
end
|
||||
|
||||
@users = @users.where('approved = false') if params[:query] == 'pending'
|
||||
@users = @users.where('username_lower like :filter or email like :filter', filter: "%#{params[:filter]}%") if params[:filter].present?
|
||||
@users = @users.take(100)
|
||||
|
|
|
@ -913,6 +913,15 @@ en:
|
|||
approved_selected:
|
||||
one: "approve user"
|
||||
other: "approve users ({{count}})"
|
||||
titles:
|
||||
active: 'Active Users'
|
||||
new: 'New Users'
|
||||
pending: 'Users Pending Review'
|
||||
newuser: 'Users at Trust Level 0 (New User)'
|
||||
basic: 'Users at Trust Level 1 (Basic User)'
|
||||
regular: 'Users at Trust Level 2 (Regular User)'
|
||||
leader: 'Users at Trust Level 3 (Leader)'
|
||||
elder: 'Users at Trust Level 4 (Elder)'
|
||||
|
||||
user:
|
||||
ban_failed: "Something went wrong banning this user {{error}}"
|
||||
|
|
Loading…
Reference in New Issue