Add filter by action to staff logs page
This commit is contained in:
parent
33bddbff85
commit
90a3bcf6ff
|
@ -8,11 +8,12 @@
|
|||
**/
|
||||
Discourse.AdminLogsStaffActionLogsController = Ember.ArrayController.extend(Discourse.Presence, {
|
||||
loading: false,
|
||||
filters: null,
|
||||
|
||||
show: function() {
|
||||
show: function(filters) {
|
||||
var self = this;
|
||||
this.set('loading', true);
|
||||
Discourse.StaffActionLog.findAll().then(function(result) {
|
||||
Discourse.StaffActionLog.findAll(this.get('filters')).then(function(result) {
|
||||
self.set('content', result);
|
||||
self.set('loading', false);
|
||||
});
|
||||
|
@ -20,5 +21,23 @@ Discourse.AdminLogsStaffActionLogsController = Ember.ArrayController.extend(Disc
|
|||
|
||||
toggleFullDetails: function(target) {
|
||||
target.set('showFullDetails', !target.get('showFullDetails'));
|
||||
},
|
||||
|
||||
clearFiltersClass: function() {
|
||||
if (this.get('filters') === null) {
|
||||
return 'invisible';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}.property('filters'),
|
||||
|
||||
clearFilters: function() {
|
||||
this.set('filters', null);
|
||||
this.show();
|
||||
},
|
||||
|
||||
filterByAction: function(action) {
|
||||
this.set('filters', {action_name: action});
|
||||
this.show();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -36,8 +36,8 @@ Discourse.StaffActionLog.reopenClass({
|
|||
return this._super(attrs);
|
||||
},
|
||||
|
||||
findAll: function(filter) {
|
||||
return Discourse.ajax("/admin/logs/staff_action_logs.json").then(function(staff_actions) {
|
||||
findAll: function(filters) {
|
||||
return Discourse.ajax("/admin/logs/staff_action_logs.json", { data: filters }).then(function(staff_actions) {
|
||||
return staff_actions.map(function(s) {
|
||||
return Discourse.StaffActionLog.create(s);
|
||||
});
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<p>{{i18n admin.logs.blocked_emails.description}}</p>
|
||||
|
||||
{{#if loading}}
|
||||
<div class='admin-loading'>{{i18n loading}}</div>
|
||||
{{else}}
|
||||
|
|
|
@ -1,21 +1,28 @@
|
|||
{{#if loading}}
|
||||
<div class='admin-loading'>{{i18n loading}}</div>
|
||||
{{else}}
|
||||
{{#if model.length}}
|
||||
<div class='table staff-actions'>
|
||||
<div class="heading-container">
|
||||
<div class="col heading action">{{i18n admin.logs.action}}</div>
|
||||
<div class="col heading staff_user">{{i18n admin.logs.staff_actions.staff_user}}</div>
|
||||
<div class="col heading target_user">{{i18n admin.logs.staff_actions.target_user}}</div>
|
||||
<div class="col heading created_at">{{i18n admin.logs.staff_actions.when}}</div>
|
||||
<div class="col heading context">{{i18n admin.logs.staff_actions.context}}</div>
|
||||
<div class="col heading details">{{i18n admin.logs.staff_actions.details}}</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
|
||||
{{view Discourse.StaffActionLogsListView contentBinding="controller"}}
|
||||
</div>
|
||||
<p>
|
||||
<a {{action clearFilters}} {{bindAttr class="clearFiltersClass"}}>{{i18n admin.logs.staff_actions.clear_filters}}</a>
|
||||
</p>
|
||||
|
||||
|
||||
<div class='table staff-actions'>
|
||||
<div class="heading-container">
|
||||
<div class="col heading action">{{i18n admin.logs.action}}</div>
|
||||
<div class="col heading staff_user">{{i18n admin.logs.staff_actions.staff_user}}</div>
|
||||
<div class="col heading target_user">{{i18n admin.logs.staff_actions.target_user}}</div>
|
||||
<div class="col heading created_at">{{i18n admin.logs.staff_actions.when}}</div>
|
||||
<div class="col heading context">{{i18n admin.logs.staff_actions.context}}</div>
|
||||
<div class="col heading details">{{i18n admin.logs.staff_actions.details}}</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
|
||||
{{#if loading}}
|
||||
<br/>
|
||||
<div class='admin-loading'>{{i18n loading}}</div>
|
||||
{{else}}
|
||||
{{i18n search.no_results}}
|
||||
{{#if model.length}}
|
||||
{{view Discourse.StaffActionLogsListView contentBinding="controller"}}
|
||||
{{else}}
|
||||
{{i18n search.no_results}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<div class="col value action">{{actionName}}</div>
|
||||
<div class="col value action">
|
||||
<a {{action filterByAction action_name}}>{{actionName}}</a>
|
||||
</div>
|
||||
<div class="col value staff_user">
|
||||
{{#linkTo 'adminUser' staff_user}}{{avatar staff_user imageSize="tiny"}}{{/linkTo}}
|
||||
{{#linkTo 'adminUser' staff_user}}{{staff_user.username}}{{/linkTo}}
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
margin-bottom: 50px;
|
||||
.admin-contents {
|
||||
padding: 8px;
|
||||
|
||||
p {
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
table.report {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class Admin::StaffActionLogsController < Admin::AdminController
|
||||
|
||||
def index
|
||||
staff_action_logs = StaffActionLog.limit(200).order('id DESC').includes(:staff_user, :target_user).to_a
|
||||
staff_action_logs = StaffActionLog.with_filters(params.slice(:action_name)).limit(200).order('id DESC').includes(:staff_user, :target_user).to_a
|
||||
render_serialized(staff_action_logs, StaffActionLogSerializer)
|
||||
end
|
||||
|
||||
|
|
|
@ -11,6 +11,14 @@ class StaffActionLog < ActiveRecord::Base
|
|||
def self.actions
|
||||
@actions ||= Enum.new(:delete_user, :change_trust_level)
|
||||
end
|
||||
|
||||
def self.with_filters(filters)
|
||||
query = self
|
||||
if filters[:action_name] and action_id = StaffActionLog.actions[filters[:action_name].to_sym]
|
||||
query = query.where('action = ?', action_id)
|
||||
end
|
||||
query
|
||||
end
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
|
|
@ -1168,6 +1168,7 @@ en:
|
|||
created_at: "Created"
|
||||
blocked_emails:
|
||||
title: "Blocked Emails"
|
||||
description: "When someone tries to create a new account, the following email addresses will be checked and the registration will be blocked, or some other action performed."
|
||||
email: "Email Address"
|
||||
last_match_at: "Last Matched"
|
||||
match_count: "Matches"
|
||||
|
@ -1176,6 +1177,7 @@ en:
|
|||
do_nothing: "do nothing"
|
||||
staff_actions:
|
||||
title: "Staff Actions"
|
||||
clear_filters: "Show All"
|
||||
staff_user: "Staff User"
|
||||
target_user: "Target User"
|
||||
when: "When"
|
||||
|
|
Loading…
Reference in New Issue