diff --git a/app/assets/javascripts/admin/controllers/admin_logs_blocked_emails_controller.js b/app/assets/javascripts/admin/controllers/admin_logs_blocked_emails_controller.js
index 6a340eaf023..d667a2ad11b 100644
--- a/app/assets/javascripts/admin/controllers/admin_logs_blocked_emails_controller.js
+++ b/app/assets/javascripts/admin/controllers/admin_logs_blocked_emails_controller.js
@@ -13,7 +13,6 @@ Discourse.AdminLogsBlockedEmailsController = Ember.ArrayController.extend(Discou
var self = this;
this.set('loading', true);
Discourse.BlockedEmail.findAll().then(function(result) {
- console.log('findAll done');
self.set('content', result);
self.set('loading', false);
});
diff --git a/app/assets/javascripts/admin/controllers/admin_logs_staff_action_logs_controller.js b/app/assets/javascripts/admin/controllers/admin_logs_staff_action_logs_controller.js
new file mode 100644
index 00000000000..6692643ab06
--- /dev/null
+++ b/app/assets/javascripts/admin/controllers/admin_logs_staff_action_logs_controller.js
@@ -0,0 +1,24 @@
+/**
+ This controller supports the interface for listing staff action logs in the admin section.
+
+ @class AdminLogsStaffActionLogsController
+ @extends Ember.ArrayController
+ @namespace Discourse
+ @module Discourse
+**/
+Discourse.AdminLogsStaffActionLogsController = Ember.ArrayController.extend(Discourse.Presence, {
+ loading: false,
+
+ show: function() {
+ var self = this;
+ this.set('loading', true);
+ Discourse.StaffActionLog.findAll().then(function(result) {
+ self.set('content', result);
+ self.set('loading', false);
+ });
+ },
+
+ toggleFullDetails: function(target) {
+ target.set('showFullDetails', !target.get('showFullDetails'));
+ }
+});
diff --git a/app/assets/javascripts/admin/models/blocked_email.js b/app/assets/javascripts/admin/models/blocked_email.js
index 762102c93f6..9d0bc2cc5da 100644
--- a/app/assets/javascripts/admin/models/blocked_email.js
+++ b/app/assets/javascripts/admin/models/blocked_email.js
@@ -9,7 +9,7 @@
**/
Discourse.BlockedEmail = Discourse.Model.extend({
actionName: function() {
- return I18n.t("admin.logs.actions." + this.get('action'));
+ return I18n.t("admin.logs.blocked_emails.actions." + this.get('action'));
}.property('action')
});
@@ -18,9 +18,7 @@ Discourse.BlockedEmail.reopenClass({
return Discourse.ajax("/admin/logs/blocked_emails.json").then(function(blocked_emails) {
return blocked_emails.map(function(b) {
return Discourse.BlockedEmail.create(b);
- })
+ });
});
}
});
-
-
diff --git a/app/assets/javascripts/admin/models/staff_action_log.js b/app/assets/javascripts/admin/models/staff_action_log.js
new file mode 100644
index 00000000000..1b6433791d2
--- /dev/null
+++ b/app/assets/javascripts/admin/models/staff_action_log.js
@@ -0,0 +1,46 @@
+/**
+ Represents an action taken by a staff member that has been logged.
+
+ @class StaffActionLog
+ @extends Discourse.Model
+ @namespace Discourse
+ @module Discourse
+**/
+Discourse.StaffActionLog = Discourse.Model.extend({
+ showFullDetails: false,
+
+ actionName: function() {
+ return I18n.t("admin.logs.staff_actions.actions." + this.get('action_name'));
+ }.property('action_name'),
+
+ formattedDetails: function() {
+ var formatted = "";
+ if (this.get('email')) {
+ formatted += "Email: " + this.get('email') + "
";
+ }
+ if (this.get('ip_address')) {
+ formatted += "IP: " + this.get('ip_address') + "
";
+ }
+ return formatted;
+ }.property('ip_address', 'email')
+});
+
+Discourse.StaffActionLog.reopenClass({
+ create: function(attrs) {
+ if (attrs.staff_user) {
+ attrs.staff_user = Discourse.AdminUser.create(attrs.staff_user);
+ }
+ if (attrs.target_user) {
+ attrs.target_user = Discourse.AdminUser.create(attrs.target_user);
+ }
+ return this._super(attrs);
+ },
+
+ findAll: function(filter) {
+ return Discourse.ajax("/admin/logs/staff_action_logs.json").then(function(staff_actions) {
+ return staff_actions.map(function(s) {
+ return Discourse.StaffActionLog.create(s);
+ });
+ });
+ }
+});
diff --git a/app/assets/javascripts/admin/routes/admin_logs_routes.js b/app/assets/javascripts/admin/routes/admin_logs_routes.js
index 3301fc46dc1..73cc4917d43 100644
--- a/app/assets/javascripts/admin/routes/admin_logs_routes.js
+++ b/app/assets/javascripts/admin/routes/admin_logs_routes.js
@@ -8,7 +8,7 @@
**/
Discourse.AdminLogsIndexRoute = Discourse.Route.extend({
redirect: function() {
- this.transitionTo('adminLogs.blockedEmails');
+ this.transitionTo('adminLogs.staffActionLogs');
}
});
@@ -21,10 +21,6 @@ Discourse.AdminLogsIndexRoute = Discourse.Route.extend({
@module Discourse
**/
Discourse.AdminLogsBlockedEmailsRoute = Discourse.Route.extend({
- // model: function() {
- // return Discourse.BlockedEmail.findAll();
- // },
-
renderTemplate: function() {
this.render('admin/templates/logs/blocked_emails', {into: 'adminLogs'});
},
@@ -32,4 +28,22 @@ Discourse.AdminLogsBlockedEmailsRoute = Discourse.Route.extend({
setupController: function() {
return this.controllerFor('adminLogsBlockedEmails').show();
}
+});
+
+/**
+ The route that lists staff actions that were logged.
+
+ @class AdminLogsStaffActionLogsRoute
+ @extends Discourse.Route
+ @namespace Discourse
+ @module Discourse
+**/
+Discourse.AdminLogsStaffActionLogsRoute = Discourse.Route.extend({
+ renderTemplate: function() {
+ this.render('admin/templates/logs/staff_action_logs', {into: 'adminLogs'});
+ },
+
+ setupController: function() {
+ return this.controllerFor('adminLogsStaffActionLogs').show();
+ }
});
\ No newline at end of file
diff --git a/app/assets/javascripts/admin/routes/admin_routes.js b/app/assets/javascripts/admin/routes/admin_routes.js
index 5e3133739bf..517cca1a808 100644
--- a/app/assets/javascripts/admin/routes/admin_routes.js
+++ b/app/assets/javascripts/admin/routes/admin_routes.js
@@ -31,6 +31,7 @@ Discourse.Route.buildRoutes(function() {
this.resource('adminLogs', { path: '/logs' }, function() {
this.route('blockedEmails', { path: '/blocked_emails' });
+ this.route('staffActionLogs', { path: '/staff_action_logs' });
});
this.route('groups', {path: '/groups'});
diff --git a/app/assets/javascripts/admin/templates/logs.js.handlebars b/app/assets/javascripts/admin/templates/logs.js.handlebars
index 7d033a1a68a..f3f6f476c98 100644
--- a/app/assets/javascripts/admin/templates/logs.js.handlebars
+++ b/app/assets/javascripts/admin/templates/logs.js.handlebars
@@ -1,7 +1,8 @@
{{i18n admin.logs.email}} | +{{i18n admin.logs.blocked_emails.email}} | {{i18n admin.logs.action}} | -{{i18n admin.logs.match_count}} | -{{i18n admin.logs.last_match_at}} | +{{i18n admin.logs.blocked_emails.match_count}} | +{{i18n admin.logs.blocked_emails.last_match_at}} | {{i18n admin.logs.created_at}} | diff --git a/app/assets/javascripts/admin/templates/logs/staff_action_logs.js.handlebars b/app/assets/javascripts/admin/templates/logs/staff_action_logs.js.handlebars new file mode 100644 index 00000000000..25fd839d3f2 --- /dev/null +++ b/app/assets/javascripts/admin/templates/logs/staff_action_logs.js.handlebars @@ -0,0 +1,50 @@ +{{#if loading}} +
---|
{{i18n admin.logs.action}} | +{{i18n admin.logs.staff_actions.staff_user}} | +{{i18n admin.logs.staff_actions.target_user}} | +{{i18n admin.logs.staff_actions.context}} | +{{i18n admin.logs.created_at}} | +{{i18n admin.logs.staff_actions.details}} | + + + + {{#each model}} +
---|---|---|---|---|---|
{{actionName}} | ++ {{#linkTo 'adminUser' staff_user}}{{avatar staff_user imageSize="tiny"}}{{/linkTo}} + {{#linkTo 'adminUser' staff_user}}{{staff_user.username}}{{/linkTo}} + | ++ {{#if target_user}} + {{#linkTo 'adminUser' target_user}}{{avatar target_user imageSize="tiny"}}{{/linkTo}} + {{#linkTo 'adminUser' target_user}}{{target_user.username}}{{/linkTo}} + {{else}} + — + {{/if}} + | +{{context}} | +{{unboundAgeWithTooltip created_at}} | +
+ {{{formattedDetails}}}
+ {{#if showFullDetails}}
+ {{details}}
+ + Less + {{else}} + More + {{/if}} + |
+