discourse/app/assets/javascripts/admin/controllers/admin-logs-staff-action-logs.js.es6

66 lines
1.9 KiB
Plaintext
Raw Normal View History

/**
This controller supports the interface for listing staff action logs in the admin section.
@class AdminLogsStaffActionLogsController
@extends Ember.ArrayController
@namespace Discourse
@module Discourse
**/
export default Ember.ArrayController.extend(Discourse.Presence, {
loading: false,
2013-08-10 04:58:57 +08:00
filters: {},
2013-08-10 04:58:57 +08:00
show: function() {
var self = this;
this.set('loading', true);
2013-08-10 04:58:57 +08:00
Discourse.URL.set('queryParams', this.get('filters')); // TODO: doesn't work
Discourse.StaffActionLog.findAll(this.get('filters')).then(function(result) {
2014-11-01 05:35:27 +08:00
self.set('model', result);
self.set('loading', false);
});
2013-09-11 09:21:16 +08:00
}.observes('filters.action_name', 'filters.acting_user', 'filters.target_user', 'filters.subject'),
2013-08-10 04:58:57 +08:00
filtersExists: function() {
return (_.size(this.get('filters')) > 0);
2013-09-11 09:21:16 +08:00
}.property('filters.action_name', 'filters.acting_user', 'filters.target_user', 'filters.subject'),
2013-08-10 04:58:57 +08:00
actionFilter: function() {
if (this.get('filters.action_name')) {
return I18n.t("admin.logs.staff_actions.actions." + this.get('filters.action_name'));
} else {
2013-08-10 04:58:57 +08:00
return null;
}
2013-08-10 04:58:57 +08:00
}.property('filters.action_name'),
showInstructions: function() {
return this.get('model.length') > 0;
}.property('loading', 'model.length'),
actions: {
clearFilter: function(key) {
delete this.get('filters')[key];
this.notifyPropertyChange('filters');
},
clearAllFilters: function() {
this.set('filters', {});
},
filterByAction: function(action) {
this.set('filters.action_name', action);
},
filterByStaffUser: function(acting_user) {
this.set('filters.acting_user', acting_user.username);
},
filterByTargetUser: function(target_user) {
this.set('filters.target_user', target_user.username);
},
filterBySubject: function(subject) {
this.set('filters.subject', subject);
}
}
});