From 33bddbff85d2878da540bbda4b17a28606d1fa0d Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 8 Aug 2013 18:35:14 -0400 Subject: [PATCH] Use Ember.ListView for staff action logs page --- .../logs/staff_action_logs.js.handlebars | 53 ++++------------- .../staff_action_logs_list_item.js.handlebars | 25 ++++++++ .../views/logs/blocked_emails_list_view.js | 2 +- .../views/logs/staff_action_logs_list_view.js | 5 ++ app/assets/stylesheets/admin/admin_base.scss | 58 +++++++++++++------ .../admin/staff_action_logs_controller.rb | 4 +- 6 files changed, 84 insertions(+), 63 deletions(-) create mode 100644 app/assets/javascripts/admin/templates/logs/staff_action_logs_list_item.js.handlebars create mode 100644 app/assets/javascripts/admin/views/logs/staff_action_logs_list_view.js 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 index d2566801579..4f2e03289f2 100644 --- a/app/assets/javascripts/admin/templates/logs/staff_action_logs.js.handlebars +++ b/app/assets/javascripts/admin/templates/logs/staff_action_logs.js.handlebars @@ -2,48 +2,19 @@
{{i18n loading}}
{{else}} {{#if model.length}} - - - - - - - - - +
+
+
{{i18n admin.logs.action}}
+
{{i18n admin.logs.staff_actions.staff_user}}
+
{{i18n admin.logs.staff_actions.target_user}}
+
{{i18n admin.logs.staff_actions.when}}
+
{{i18n admin.logs.staff_actions.context}}
+
{{i18n admin.logs.staff_actions.details}}
+
+
-
- {{#each model}} - - - - - - - - - {{/each}} - -
{{i18n admin.logs.action}}{{i18n admin.logs.staff_actions.staff_user}}{{i18n admin.logs.staff_actions.target_user}}{{i18n admin.logs.staff_actions.when}}{{i18n admin.logs.staff_actions.context}}{{i18n admin.logs.staff_actions.details}}
{{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}} - {{unboundAgeWithTooltip created_at}}{{context}} - {{{formattedDetails}}} - {{#if showFullDetails}} - {{details}} -
- {{i18n less}} - {{else}} - {{i18n more}} - {{/if}} -
+ {{view Discourse.StaffActionLogsListView contentBinding="controller"}} + {{else}} {{i18n search.no_results}} {{/if}} diff --git a/app/assets/javascripts/admin/templates/logs/staff_action_logs_list_item.js.handlebars b/app/assets/javascripts/admin/templates/logs/staff_action_logs_list_item.js.handlebars new file mode 100644 index 00000000000..1ffea587d7d --- /dev/null +++ b/app/assets/javascripts/admin/templates/logs/staff_action_logs_list_item.js.handlebars @@ -0,0 +1,25 @@ +
{{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}} +
+
{{unboundAgeWithTooltip created_at}}
+
{{context}}
+
+ {{{formattedDetails}}} + {{#if showFullDetails}} + {{i18n less}}
+ {{details}} + {{else}} + {{i18n more}} + {{/if}} +
+
diff --git a/app/assets/javascripts/admin/views/logs/blocked_emails_list_view.js b/app/assets/javascripts/admin/views/logs/blocked_emails_list_view.js index 102547afe2d..3779b979000 100644 --- a/app/assets/javascripts/admin/views/logs/blocked_emails_list_view.js +++ b/app/assets/javascripts/admin/views/logs/blocked_emails_list_view.js @@ -1,5 +1,5 @@ Discourse.BlockedEmailsListView = Ember.ListView.extend({ - height: 500, + height: 700, rowHeight: 32, itemViewClass: Ember.ListItemView.extend({templateName: "admin/templates/logs/blocked_emails_list_item"}) }); diff --git a/app/assets/javascripts/admin/views/logs/staff_action_logs_list_view.js b/app/assets/javascripts/admin/views/logs/staff_action_logs_list_view.js new file mode 100644 index 00000000000..ceb1f6fe29d --- /dev/null +++ b/app/assets/javascripts/admin/views/logs/staff_action_logs_list_view.js @@ -0,0 +1,5 @@ +Discourse.StaffActionLogsListView = Ember.ListView.extend({ + height: 700, + rowHeight: 75, + itemViewClass: Ember.ListItemView.extend({templateName: "admin/templates/logs/staff_action_logs_list_item"}) +}); diff --git a/app/assets/stylesheets/admin/admin_base.scss b/app/assets/stylesheets/admin/admin_base.scss index d6b8ee41380..8d6b39bff53 100644 --- a/app/assets/stylesheets/admin/admin_base.scss +++ b/app/assets/stylesheets/admin/admin_base.scss @@ -698,19 +698,6 @@ table { .blocked-emails { width: 900px; - margin-left: 5px; - border-bottom: dotted 1px #ddd; - .heading-container { - width: 100%; - background-color: #e4e4e4; - } - .heading { - font-weight: bold; - } - .col { - display: inline-block; - padding-top: 6px; - } .email { width: 400px; margin-left: 5px; @@ -719,18 +706,22 @@ table { width: 110px; text-align: center; } - .ember-list-item-view { - width: 100%; - border-top: solid 1px #ddd; - } } .staff-actions { + width: 100%; .action { width: 120px; + margin-left: 5px; } - .staff_user, .target_user, .created_at { - white-space: nowrap; + .staff_user, .target_user { + width: 100px; + } + .created_at { + width: 50px; + } + .context { + width: 200px; } .created_at { text-align: center; @@ -740,6 +731,9 @@ table { a { text-decoration: underline; } + &.value { + height: 70px; + } } } @@ -753,3 +747,29 @@ table { .ember-list-item-view { position: absolute; } + +.blocked-emails, .staff-actions { + margin-left: 5px; + border-bottom: dotted 1px #ddd; + + .heading-container { + width: 100%; + background-color: #e4e4e4; + } + .col.heading { + font-weight: bold; + padding: 4px 0; + } + .col { + display: inline-block; + padding-top: 6px; + vertical-align: top; + overflow-y: auto; + overflow-x: hidden; + } + + .ember-list-item-view { + width: 100%; + border-top: solid 1px #ddd; + } +} diff --git a/app/controllers/admin/staff_action_logs_controller.rb b/app/controllers/admin/staff_action_logs_controller.rb index 1de752d2587..fc3ed049c20 100644 --- a/app/controllers/admin/staff_action_logs_controller.rb +++ b/app/controllers/admin/staff_action_logs_controller.rb @@ -1,8 +1,8 @@ class Admin::StaffActionLogsController < Admin::AdminController def index - staff_actions = StaffActionLog.limit(50).order('created_at desc').to_a - render_serialized(staff_actions, StaffActionLogSerializer) + staff_action_logs = StaffActionLog.limit(200).order('id DESC').includes(:staff_user, :target_user).to_a + render_serialized(staff_action_logs, StaffActionLogSerializer) end end