Staff action logs can be filtered to changes of one site setting

This commit is contained in:
Neil Lalonde 2013-08-20 13:50:51 -04:00
parent 31dac4b197
commit 3abeb5f793
6 changed files with 20 additions and 4 deletions

View File

@ -18,7 +18,7 @@ Discourse.AdminLogsStaffActionLogsController = Ember.ArrayController.extend(Disc
self.set('content', result);
self.set('loading', false);
});
}.observes('filters.action_name', 'filters.staff_user', 'filters.target_user'),
}.observes('filters.action_name', 'filters.staff_user', 'filters.target_user', 'filters.subject'),
toggleFullDetails: function(target) {
target.set('showFullDetails', !target.get('showFullDetails'));
@ -26,7 +26,7 @@ Discourse.AdminLogsStaffActionLogsController = Ember.ArrayController.extend(Disc
filtersExists: function() {
return (_.size(this.get('filters')) > 0);
}.property('filters.action_name', 'filters.staff_user', 'filters.target_user'),
}.property('filters.action_name', 'filters.staff_user', 'filters.target_user', 'filters.subject'),
clearFilter: function(key) {
delete this.get('filters')[key];
@ -55,5 +55,9 @@ Discourse.AdminLogsStaffActionLogsController = Ember.ArrayController.extend(Disc
filterByTargetUser: function(target_user) {
this.set('filters.target_user', target_user.username);
},
filterBySubject: function(subject) {
this.set('filters.subject', subject);
}
});

View File

@ -20,6 +20,12 @@
<i class="icon icon-remove-sign"></i>
</a>
{{/if}}
{{#if filters.subject}}
<a {{action clearFilter "subject"}} class="filter">
<span class="label">{{i18n admin.logs.staff_actions.subject}}</span>: {{filters.subject}}
<i class="icon icon-remove-sign"></i>
</a>
{{/if}}
</div>
<div class='table staff-actions'>

View File

@ -11,7 +11,7 @@
<a {{action filterByTargetUser target_user}}>{{target_user.username}}</a>
{{/if}}
{{#if subject}}
<span {{bindAttr title="subject"}}>{{subject}}</span>
<a {{action filterBySubject subject}} {{bindAttr title="subject"}}>{{subject}}</a>
{{/if}}
</div>
<div class="col value created_at">{{unboundAgeWithTooltip created_at}}</div>

View File

@ -1,7 +1,7 @@
class Admin::StaffActionLogsController < Admin::AdminController
def index
staff_action_logs = StaffActionLog.with_filters(params.slice(:action_name, :staff_user, :target_user)).limit(200).order('id DESC').includes(:staff_user, :target_user).to_a
staff_action_logs = StaffActionLog.with_filters(params.slice(:action_name, :staff_user, :target_user, :subject)).limit(200).order('id DESC').includes(:staff_user, :target_user).to_a
render_serialized(staff_action_logs, StaffActionLogSerializer)
end

View File

@ -22,6 +22,7 @@ class StaffActionLog < ActiveRecord::Base
query = query.where("#{key.to_s}_id = ?", obj_id)
end
end
query = query.where("subject = ?", filters[:subject]) if filters[:subject]
query
end
end

View File

@ -0,0 +1,5 @@
class AddSubjectIndexToStaffActionLogs < ActiveRecord::Migration
def change
add_index :staff_action_logs, [:subject, :id]
end
end