diff --git a/app/assets/javascripts/admin/controllers/admin_users_list_controller.js b/app/assets/javascripts/admin/controllers/admin_users_list_controller.js index f9c40a79d7d..a14f914c2ef 100644 --- a/app/assets/javascripts/admin/controllers/admin_users_list_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_users_list_controller.js @@ -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); })); }, diff --git a/app/assets/javascripts/admin/models/admin_user.js b/app/assets/javascripts/admin/models/admin_user.js index 1d2f41b5058..99c9d4c478a 100644 --- a/app/assets/javascripts/admin/models/admin_user.js +++ b/app/assets/javascripts/admin/models/admin_user.js @@ -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; } diff --git a/app/assets/javascripts/admin/routes/admin_routes.js b/app/assets/javascripts/admin/routes/admin_routes.js index 67493ca2681..37d50251ba8 100644 --- a/app/assets/javascripts/admin/routes/admin_routes.js +++ b/app/assets/javascripts/admin/routes/admin_routes.js @@ -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' }); }); }); diff --git a/app/assets/javascripts/admin/routes/admin_users_list_trust_level_routes.js b/app/assets/javascripts/admin/routes/admin_users_list_trust_level_routes.js new file mode 100644 index 00000000000..9c05d1e927f --- /dev/null +++ b/app/assets/javascripts/admin/routes/admin_users_list_trust_level_routes.js @@ -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'); + } +}); \ No newline at end of file diff --git a/app/assets/javascripts/admin/templates/reports/trust_levels_report.js.handlebars b/app/assets/javascripts/admin/templates/reports/trust_levels_report.js.handlebars index b4f3d7490b3..efd9dece091 100644 --- a/app/assets/javascripts/admin/templates/reports/trust_levels_report.js.handlebars +++ b/app/assets/javascripts/admin/templates/reports/trust_levels_report.js.handlebars @@ -1,8 +1,8 @@
{{view Ember.Checkbox checkedBinding="selectAll"}} | - {{/if}} -- | {{i18n username}} | -{{i18n email}} | -{{i18n admin.users.last_emailed}} | -{{i18n last_seen}} | -{{i18n admin.user.topics_entered}} | -{{i18n admin.user.posts_read_count}} | -{{i18n admin.user.time_read}} | -{{i18n created}} | - {{#if showApproval}} -{{i18n admin.users.approved}} | - {{/if}} -+ |
---|
{{view Ember.Checkbox checkedBinding="selectAll"}} | + {{/if}} ++ | {{i18n username}} | +{{i18n email}} | +{{i18n admin.users.last_emailed}} | +{{i18n last_seen}} | +{{i18n admin.user.topics_entered}} | +{{i18n admin.user.posts_read_count}} | +{{i18n admin.user.time_read}} | +{{i18n created}} | + {{#if showApproval}} +{{i18n admin.users.approved}} | + {{/if}} +- {{#each content}} - | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ {{#if can_approve}} + {{view Ember.Checkbox checkedBinding="selected"}} + {{/if}} + | + {{/if}}- {{#if can_approve}} - {{view Ember.Checkbox checkedBinding="selected"}} + {{avatar this imageSize="small"}} + | +{{unbound username}} | +{{shorten email}} | +{{{unbound last_emailed_age}}} | +{{{unbound last_seen_age}}} | +{{{unbound topics_entered}}} | +{{{unbound posts_read_count}}} | +{{{unbound time_read}}} | + +{{{unbound created_at_age}}} | + + {{#if controller.showApproval}} ++ {{#if approved}} + {{i18n yes_value}} + {{else}} + {{i18n no_value}} {{/if}} | - {{/if}} -- {{avatar this imageSize="small"}} - | -{{unbound username}} | -{{shorten email}} | -{{{unbound last_emailed_age}}} | -{{{unbound last_seen_age}}} | -{{{unbound topics_entered}}} | -{{{unbound posts_read_count}}} | -{{{unbound time_read}}} | - -{{{unbound created_at_age}}} | - - {{#if controller.showApproval}} -- {{#if approved}} - {{i18n yes_value}} - {{else}} - {{i18n no_value}} {{/if}} - | - {{/if}} -- {{#if admin}}{{/if}} - {{#if moderator}}{{/if}} - | - | + {{#if admin}}{{/if}} + {{#if moderator}}{{/if}} + | + + {{/each}} - |
{{i18n search.no_results}}
+ {{/if}} {{/if}} diff --git a/app/assets/javascripts/admin/views/report/admin_report_trust_levels_view.js b/app/assets/javascripts/admin/views/report/admin_report_trust_levels_view.js index 1731ff38214..b2b902bdcb8 100644 --- a/app/assets/javascripts/admin/views/report/admin_report_trust_levels_view.js +++ b/app/assets/javascripts/admin/views/report/admin_report_trust_levels_view.js @@ -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' diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index c95f856625e..e0267f31b18 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -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) diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 7e94d76638c..4f6371c1fc8 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -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}}"