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, {
|
Discourse.AdminLogsStaffActionLogsController = Ember.ArrayController.extend(Discourse.Presence, {
|
||||||
loading: false,
|
loading: false,
|
||||||
|
filters: null,
|
||||||
|
|
||||||
show: function() {
|
show: function(filters) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.set('loading', true);
|
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('content', result);
|
||||||
self.set('loading', false);
|
self.set('loading', false);
|
||||||
});
|
});
|
||||||
|
@ -20,5 +21,23 @@ Discourse.AdminLogsStaffActionLogsController = Ember.ArrayController.extend(Disc
|
||||||
|
|
||||||
toggleFullDetails: function(target) {
|
toggleFullDetails: function(target) {
|
||||||
target.set('showFullDetails', !target.get('showFullDetails'));
|
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);
|
return this._super(attrs);
|
||||||
},
|
},
|
||||||
|
|
||||||
findAll: function(filter) {
|
findAll: function(filters) {
|
||||||
return Discourse.ajax("/admin/logs/staff_action_logs.json").then(function(staff_actions) {
|
return Discourse.ajax("/admin/logs/staff_action_logs.json", { data: filters }).then(function(staff_actions) {
|
||||||
return staff_actions.map(function(s) {
|
return staff_actions.map(function(s) {
|
||||||
return Discourse.StaffActionLog.create(s);
|
return Discourse.StaffActionLog.create(s);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
<p>{{i18n admin.logs.blocked_emails.description}}</p>
|
||||||
|
|
||||||
{{#if loading}}
|
{{#if loading}}
|
||||||
<div class='admin-loading'>{{i18n loading}}</div>
|
<div class='admin-loading'>{{i18n loading}}</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
{{#if loading}}
|
|
||||||
<div class='admin-loading'>{{i18n loading}}</div>
|
<p>
|
||||||
{{else}}
|
<a {{action clearFilters}} {{bindAttr class="clearFiltersClass"}}>{{i18n admin.logs.staff_actions.clear_filters}}</a>
|
||||||
{{#if model.length}}
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<div class='table staff-actions'>
|
<div class='table staff-actions'>
|
||||||
<div class="heading-container">
|
<div class="heading-container">
|
||||||
<div class="col heading action">{{i18n admin.logs.action}}</div>
|
<div class="col heading action">{{i18n admin.logs.action}}</div>
|
||||||
|
@ -13,9 +15,14 @@
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{#if loading}}
|
||||||
|
<br/>
|
||||||
|
<div class='admin-loading'>{{i18n loading}}</div>
|
||||||
|
{{else}}
|
||||||
|
{{#if model.length}}
|
||||||
{{view Discourse.StaffActionLogsListView contentBinding="controller"}}
|
{{view Discourse.StaffActionLogsListView contentBinding="controller"}}
|
||||||
</div>
|
|
||||||
{{else}}
|
{{else}}
|
||||||
{{i18n search.no_results}}
|
{{i18n search.no_results}}
|
||||||
{{/if}}
|
{{/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">
|
<div class="col value staff_user">
|
||||||
{{#linkTo 'adminUser' staff_user}}{{avatar staff_user imageSize="tiny"}}{{/linkTo}}
|
{{#linkTo 'adminUser' staff_user}}{{avatar staff_user imageSize="tiny"}}{{/linkTo}}
|
||||||
{{#linkTo 'adminUser' staff_user}}{{staff_user.username}}{{/linkTo}}
|
{{#linkTo 'adminUser' staff_user}}{{staff_user.username}}{{/linkTo}}
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
margin-bottom: 50px;
|
margin-bottom: 50px;
|
||||||
.admin-contents {
|
.admin-contents {
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin-left: 6px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table.report {
|
table.report {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class Admin::StaffActionLogsController < Admin::AdminController
|
class Admin::StaffActionLogsController < Admin::AdminController
|
||||||
|
|
||||||
def index
|
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)
|
render_serialized(staff_action_logs, StaffActionLogSerializer)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,14 @@ class StaffActionLog < ActiveRecord::Base
|
||||||
def self.actions
|
def self.actions
|
||||||
@actions ||= Enum.new(:delete_user, :change_trust_level)
|
@actions ||= Enum.new(:delete_user, :change_trust_level)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
|
|
|
@ -1168,6 +1168,7 @@ en:
|
||||||
created_at: "Created"
|
created_at: "Created"
|
||||||
blocked_emails:
|
blocked_emails:
|
||||||
title: "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"
|
email: "Email Address"
|
||||||
last_match_at: "Last Matched"
|
last_match_at: "Last Matched"
|
||||||
match_count: "Matches"
|
match_count: "Matches"
|
||||||
|
@ -1176,6 +1177,7 @@ en:
|
||||||
do_nothing: "do nothing"
|
do_nothing: "do nothing"
|
||||||
staff_actions:
|
staff_actions:
|
||||||
title: "Staff Actions"
|
title: "Staff Actions"
|
||||||
|
clear_filters: "Show All"
|
||||||
staff_user: "Staff User"
|
staff_user: "Staff User"
|
||||||
target_user: "Target User"
|
target_user: "Target User"
|
||||||
when: "When"
|
when: "When"
|
||||||
|
|
Loading…
Reference in New Issue