2013-08-07 16:04:12 -04:00
|
|
|
/**
|
|
|
|
This controller supports the interface for listing staff action logs in the admin section.
|
|
|
|
|
|
|
|
@class AdminLogsStaffActionLogsController
|
|
|
|
@extends Ember.ArrayController
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
|
|
|
**/
|
2014-07-22 23:20:45 -04:00
|
|
|
export default Ember.ArrayController.extend(Discourse.Presence, {
|
2013-08-07 16:04:12 -04:00
|
|
|
loading: false,
|
2013-08-09 16:58:57 -04:00
|
|
|
filters: {},
|
2013-08-07 16:04:12 -04:00
|
|
|
|
2013-08-09 16:58:57 -04:00
|
|
|
show: function() {
|
2013-08-07 16:04:12 -04:00
|
|
|
var self = this;
|
|
|
|
this.set('loading', true);
|
2013-08-09 16:58:57 -04:00
|
|
|
Discourse.URL.set('queryParams', this.get('filters')); // TODO: doesn't work
|
2013-08-09 10:06:02 -04:00
|
|
|
Discourse.StaffActionLog.findAll(this.get('filters')).then(function(result) {
|
2013-08-07 16:04:12 -04:00
|
|
|
self.set('content', result);
|
|
|
|
self.set('loading', false);
|
|
|
|
});
|
2013-09-10 21:21:16 -04:00
|
|
|
}.observes('filters.action_name', 'filters.acting_user', 'filters.target_user', 'filters.subject'),
|
2013-08-07 16:04:12 -04:00
|
|
|
|
2013-08-09 16:58:57 -04:00
|
|
|
filtersExists: function() {
|
|
|
|
return (_.size(this.get('filters')) > 0);
|
2013-09-10 21:21:16 -04:00
|
|
|
}.property('filters.action_name', 'filters.acting_user', 'filters.target_user', 'filters.subject'),
|
2013-08-09 16:58:57 -04:00
|
|
|
|
|
|
|
actionFilter: function() {
|
|
|
|
if (this.get('filters.action_name')) {
|
|
|
|
return I18n.t("admin.logs.staff_actions.actions." + this.get('filters.action_name'));
|
2013-08-09 10:06:02 -04:00
|
|
|
} else {
|
2013-08-09 16:58:57 -04:00
|
|
|
return null;
|
2013-08-09 10:06:02 -04:00
|
|
|
}
|
2013-08-09 16:58:57 -04:00
|
|
|
}.property('filters.action_name'),
|
2013-08-09 10:06:02 -04:00
|
|
|
|
2013-10-31 12:17:06 -04:00
|
|
|
showInstructions: function() {
|
|
|
|
return this.get('model.length') > 0;
|
|
|
|
}.property('loading', 'model.length'),
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
clearFilter: function(key) {
|
|
|
|
delete this.get('filters')[key];
|
|
|
|
this.notifyPropertyChange('filters');
|
|
|
|
},
|
2013-08-09 10:06:02 -04:00
|
|
|
|
2013-10-31 12:17:06 -04:00
|
|
|
clearAllFilters: function() {
|
|
|
|
this.set('filters', {});
|
|
|
|
},
|
2013-08-20 13:50:51 -04:00
|
|
|
|
2013-10-31 12:17:06 -04:00
|
|
|
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);
|
|
|
|
}
|
2013-08-07 16:04:12 -04:00
|
|
|
}
|
|
|
|
});
|