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

72 lines
2.1 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
**/
2014-12-06 23:15:22 -05:00
import { outputExportResult } from 'admin/lib/export-result';
export default Ember.ArrayController.extend(Discourse.Presence, {
loading: false,
2013-08-09 16:58:57 -04:00
filters: {},
2013-08-09 16:58:57 -04:00
show: function() {
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
Discourse.StaffActionLog.findAll(this.get('filters')).then(function(result) {
2014-10-31 17:35:27 -04:00
self.set('model', 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-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'));
} else {
2013-08-09 16:58:57 -04:00
return null;
}
2013-08-09 16:58:57 -04: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);
2014-12-06 23:15:22 -05:00
},
exportStaffActionLogs: function(subject) {
Discourse.ExportCsv.exportStaffActionLogs().then(outputExportResult);
}
}
});