From 2c09e97ca04709a916f3cd7963606da8b867fce2 Mon Sep 17 00:00:00 2001
From: Erick Guan <fantasticfears@gmail.com>
Date: Fri, 15 May 2015 00:53:33 +0800
Subject: [PATCH] FIX: unhandle show report action

---
 .../components/admin-report-counts.js.es6     |  2 +-
 .../admin-report-per-day-counts.js.es6        |  3 +
 .../admin-report-trust-level-counts.js.es6    |  3 +
 .../components/admin-report-counts.hbs        | 24 +++--
 .../admin-report-per-day-counts.hbs           |  6 ++
 .../admin-report-trust-level-counts.hbs       |  6 ++
 .../javascripts/admin/templates/dashboard.hbs | 88 +++++++++++--------
 .../reports/per_day_counts_report.hbs         |  8 --
 .../templates/reports/trust_levels_report.hbs |  8 --
 9 files changed, 79 insertions(+), 69 deletions(-)
 create mode 100644 app/assets/javascripts/admin/components/admin-report-per-day-counts.js.es6
 create mode 100644 app/assets/javascripts/admin/components/admin-report-trust-level-counts.js.es6
 create mode 100644 app/assets/javascripts/admin/templates/components/admin-report-per-day-counts.hbs
 create mode 100644 app/assets/javascripts/admin/templates/components/admin-report-trust-level-counts.hbs
 delete mode 100644 app/assets/javascripts/admin/templates/reports/per_day_counts_report.hbs
 delete mode 100644 app/assets/javascripts/admin/templates/reports/trust_levels_report.hbs

diff --git a/app/assets/javascripts/admin/components/admin-report-counts.js.es6 b/app/assets/javascripts/admin/components/admin-report-counts.js.es6
index 28e45b10e..25bf94db2 100644
--- a/app/assets/javascripts/admin/components/admin-report-counts.js.es6
+++ b/app/assets/javascripts/admin/components/admin-report-counts.js.es6
@@ -1,3 +1,3 @@
 export default Ember.Component.extend({
-  tagName: 'tbody'
+  tagName: 'tr'
 });
diff --git a/app/assets/javascripts/admin/components/admin-report-per-day-counts.js.es6 b/app/assets/javascripts/admin/components/admin-report-per-day-counts.js.es6
new file mode 100644
index 000000000..25bf94db2
--- /dev/null
+++ b/app/assets/javascripts/admin/components/admin-report-per-day-counts.js.es6
@@ -0,0 +1,3 @@
+export default Ember.Component.extend({
+  tagName: 'tr'
+});
diff --git a/app/assets/javascripts/admin/components/admin-report-trust-level-counts.js.es6 b/app/assets/javascripts/admin/components/admin-report-trust-level-counts.js.es6
new file mode 100644
index 000000000..25bf94db2
--- /dev/null
+++ b/app/assets/javascripts/admin/components/admin-report-trust-level-counts.js.es6
@@ -0,0 +1,3 @@
+export default Ember.Component.extend({
+  tagName: 'tr'
+});
diff --git a/app/assets/javascripts/admin/templates/components/admin-report-counts.hbs b/app/assets/javascripts/admin/templates/components/admin-report-counts.hbs
index e91598e5d..d86e5ed5d 100644
--- a/app/assets/javascripts/admin/templates/components/admin-report-counts.hbs
+++ b/app/assets/javascripts/admin/templates/components/admin-report-counts.hbs
@@ -1,13 +1,11 @@
-<tr>
-  <td class="title">
-    {{#if report.icon}}
-      {{fa-icon report.icon}}
-    {{/if}}
-    <a {{bind-attr href="report.reportUrl"}}>{{report.title}}</a>
-  </td>
-  <td class="value">{{report.todayCount}}</td>
-  <td {{bind-attr class=":value report.yesterdayTrend"}} {{bind-attr title="report.yesterdayCountTitle"}}>{{report.yesterdayCount}} {{fa-icon "caret-up" class="up"}} {{fa-icon "caret-down" class="down"}}</td>
-  <td {{bind-attr class=":value report.sevenDayTrend"}} {{bind-attr title="report.sevenDayCountTitle"}}>{{report.lastSevenDaysCount}} {{fa-icon "caret-up" class="up"}} {{fa-icon "caret-down" class="down"}}</td>
-  <td {{bind-attr class=":value report.thirtyDayTrend"}} {{bind-attr title="report.thirtyDayCountTitle"}}>{{report.lastThirtyDaysCount}} {{fa-icon "caret-up" class="up"}} {{fa-icon "caret-down" class="down"}}</td>
-  <td class="value">{{report.total}}</td>
-</tr>
+<td class="title">
+  {{#if report.icon}}
+    {{fa-icon report.icon}}
+  {{/if}}
+  <a href="{{report.reportUrl}}">{{report.title}}</a>
+</td>
+<td class="value">{{report.todayCount}}</td>
+<td {{bind-attr class=":value report.yesterdayTrend"}} title="{{report.yesterdayCountTitle}}">{{report.yesterdayCount}} {{fa-icon "caret-up" class="up"}} {{fa-icon "caret-down" class="down"}}</td>
+<td {{bind-attr class=":value report.sevenDayTrend"}} title="{{report.sevenDayCountTitle}}">{{report.lastSevenDaysCount}} {{fa-icon "caret-up" class="up"}} {{fa-icon "caret-down" class="down"}}</td>
+<td {{bind-attr class=":value report.thirtyDayTrend"}} title="{{report.thirtyDayCountTitle}}">{{report.lastThirtyDaysCount}} {{fa-icon "caret-up" class="up"}} {{fa-icon "caret-down" class="down"}}</td>
+<td class="value">{{report.total}}</td>
diff --git a/app/assets/javascripts/admin/templates/components/admin-report-per-day-counts.hbs b/app/assets/javascripts/admin/templates/components/admin-report-per-day-counts.hbs
new file mode 100644
index 000000000..bc7029da5
--- /dev/null
+++ b/app/assets/javascripts/admin/templates/components/admin-report-per-day-counts.hbs
@@ -0,0 +1,6 @@
+<td class="title"><a href="report.reportUrl}}">{{report.title}}</a></td>
+<td class="value">{{report.todayCount}}</td>
+<td class="value">{{report.yesterdayCount}}</td>
+<td class="value">{{report.sevenDaysAgoCount}}</td>
+<td class="value">{{report.thirtyDaysAgoCount}}</td>
+<td class="value"></td>
diff --git a/app/assets/javascripts/admin/templates/components/admin-report-trust-level-counts.hbs b/app/assets/javascripts/admin/templates/components/admin-report-trust-level-counts.hbs
new file mode 100644
index 000000000..93df84f2b
--- /dev/null
+++ b/app/assets/javascripts/admin/templates/components/admin-report-trust-level-counts.hbs
@@ -0,0 +1,6 @@
+<td class="title">{{report.title}}</td>
+<td class="value">{{#link-to 'adminUsersList.show' 'newuser'}}{{value-at-tl report.data level="0"}}{{/link-to}}</td>
+<td class="value">{{#link-to 'adminUsersList.show' 'basic'}}{{value-at-tl report.data level="1"}}{{/link-to}}</td>
+<td class="value">{{#link-to 'adminUsersList.show' 'regular'}}{{value-at-tl report.data level="2"}}{{/link-to}}</td>
+<td class="value">{{#link-to 'adminUsersList.show' 'leader'}}{{value-at-tl report.data level="3"}}{{/link-to}}</td>
+<td class="value">{{#link-to 'adminUsersList.show' 'elder'}}{{value-at-tl report.data level="4"}}{{/link-to}}</td>
diff --git a/app/assets/javascripts/admin/templates/dashboard.hbs b/app/assets/javascripts/admin/templates/dashboard.hbs
index f73a52b5c..32ce15f9c 100644
--- a/app/assets/javascripts/admin/templates/dashboard.hbs
+++ b/app/assets/javascripts/admin/templates/dashboard.hbs
@@ -15,9 +15,11 @@
           <th>4</th>
         </tr>
       </thead>
-      {{#unless loading}}
-        {{ render 'admin/templates/reports/trust_levels_report' users_by_trust_level tagName="tbody"}}
-      {{/unless}}
+      <tbody>
+        {{#unless loading}}
+          {{admin-report-trust-level-counts report=users_by_trust_level}}
+        {{/unless}}
+      </tbody>
     </table>
   </div>
 
@@ -50,16 +52,18 @@
           <th>{{i18n 'admin.dashboard.reports.all'}}</th>
         </tr>
       </thead>
-      {{#unless loading}}
-        {{ render 'admin/templates/reports/per_day_counts_report' visits tagName="tbody"}}
-        {{admin-report-counts report=signups}}
-        {{admin-report-counts report=topics}}
-        {{admin-report-counts report=posts}}
-        {{admin-report-counts report=likes}}
-        {{admin-report-counts report=flags}}
-        {{admin-report-counts report=bookmarks}}
-        {{admin-report-counts report=emails}}
-      {{/unless}}
+      <tbody>
+        {{#unless loading}}
+          {{admin-report-per-day-counts report=visits}}
+          {{admin-report-counts report=signups}}
+          {{admin-report-counts report=topics}}
+          {{admin-report-counts report=posts}}
+          {{admin-report-counts report=likes}}
+          {{admin-report-counts report=flags}}
+          {{admin-report-counts report=bookmarks}}
+          {{admin-report-counts report=emails}}
+        {{/unless}}
+      </tbody>
     </table>
   </div>
 
@@ -75,12 +79,14 @@
           <th>{{i18n 'admin.dashboard.reports.all'}}</th>
         </tr>
       </thead>
-      {{#unless loading}}
-        {{admin-report-counts report=page_view_anon_reqs}}
-        {{admin-report-counts report=page_view_logged_in_reqs}}
-        {{admin-report-counts report=page_view_crawler_reqs}}
-        {{admin-report-counts report=page_view_total_reqs}}
-      {{/unless}}
+      <tbody>
+        {{#unless loading}}
+          {{admin-report-counts report=page_view_anon_reqs}}
+          {{admin-report-counts report=page_view_logged_in_reqs}}
+          {{admin-report-counts report=page_view_crawler_reqs}}
+          {{admin-report-counts report=page_view_total_reqs}}
+        {{/unless}}
+      </tbody>
     </table>
   </div>
 
@@ -97,13 +103,15 @@
           <th>{{i18n 'admin.dashboard.reports.all'}}</th>
         </tr>
       </thead>
-      {{#unless loading}}
-        {{admin-report-counts report=user_to_user_private_messages}}
-        {{admin-report-counts report=system_private_messages}}
-        {{admin-report-counts report=notify_moderators_private_messages}}
-        {{admin-report-counts report=notify_user_private_messages}}
-        {{admin-report-counts report=moderator_warning_private_messages}}
-      {{/unless}}
+      <tbody>
+        {{#unless loading}}
+          {{admin-report-counts report=user_to_user_private_messages}}
+          {{admin-report-counts report=system_private_messages}}
+          {{admin-report-counts report=notify_moderators_private_messages}}
+          {{admin-report-counts report=notify_user_private_messages}}
+          {{admin-report-counts report=moderator_warning_private_messages}}
+        {{/unless}}
+      </tbody>
     </table>
   </div>
 
@@ -118,14 +126,14 @@
         </tr>
       </thead>
       <tbody>
-          {{#unless loading}}
+        {{#unless loading}}
           <tr>
             <td>{{i18n 'admin.dashboard.uploads'}}</td>
             <td>{{disk_space.uploads_used}} ({{i18n 'admin.dashboard.space_free' size=disk_space.uploads_free}})</td>
             <td><a href="/admin/backups">{{i18n 'admin.dashboard.backups'}}</a></td>
             <td>{{disk_space.backups_used}} ({{i18n 'admin.dashboard.space_free' size=disk_space.backups_free}})</td>
           </tr>
-          {{/unless}}
+        {{/unless}}
       </tbody>
     </table>
   </div>
@@ -144,20 +152,22 @@
             <th>{{i18n 'admin.dashboard.reports.all'}}</th>
           </tr>
         </thead>
-        {{#unless loading}}
-          {{admin-report-counts report=http_2xx_reqs}}
-          {{admin-report-counts report=http_3xx_reqs}}
-          {{admin-report-counts report=http_4xx_reqs}}
-          {{admin-report-counts report=http_5xx_reqs}}
-          {{admin-report-counts report=http_background_reqs}}
-          {{admin-report-counts report=http_total_reqs}}
-        {{/unless}}
+        <tbody>
+          {{#unless loading}}
+            {{admin-report-counts report=http_2xx_reqs}}
+            {{admin-report-counts report=http_3xx_reqs}}
+            {{admin-report-counts report=http_4xx_reqs}}
+            {{admin-report-counts report=http_5xx_reqs}}
+            {{admin-report-counts report=http_background_reqs}}
+            {{admin-report-counts report=http_total_reqs}}
+          {{/unless}}
+        </tbody>
       </table>
     </div>
     {{else}}
-    <div class="dashboard-stats">
-      <a href {{action showTrafficReport}}>{{i18n 'admin.dashboard.show_traffic_report'}}</a>
-    </div>
+      <div class="dashboard-stats">
+        <a href {{action 'showTrafficReport'}}>{{i18n 'admin.dashboard.show_traffic_report'}}</a>
+      </div>
     {{/if}}
   {{/unless}}
 </div>
diff --git a/app/assets/javascripts/admin/templates/reports/per_day_counts_report.hbs b/app/assets/javascripts/admin/templates/reports/per_day_counts_report.hbs
deleted file mode 100644
index bc025cdf8..000000000
--- a/app/assets/javascripts/admin/templates/reports/per_day_counts_report.hbs
+++ /dev/null
@@ -1,8 +0,0 @@
-<tr>
-  <td class="title"><a {{bind-attr href="reportUrl"}}>{{title}}</a></td>
-  <td class="value">{{todayCount}}</td>
-  <td class="value">{{yesterdayCount}}</td>
-  <td class="value">{{sevenDaysAgoCount}}</td>
-  <td class="value">{{thirtyDaysAgoCount}}</td>
-  <td class="value"></td>
-</tr>
diff --git a/app/assets/javascripts/admin/templates/reports/trust_levels_report.hbs b/app/assets/javascripts/admin/templates/reports/trust_levels_report.hbs
deleted file mode 100644
index cedde2f3a..000000000
--- a/app/assets/javascripts/admin/templates/reports/trust_levels_report.hbs
+++ /dev/null
@@ -1,8 +0,0 @@
-<tr>
-  <td class="title">{{title}}</td>
-  <td class="value">{{#link-to 'adminUsersList.show' 'newuser'}}{{value-at-tl data level="0"}}{{/link-to}}</td>
-  <td class="value">{{#link-to 'adminUsersList.show' 'basic'}}{{value-at-tl data level="1"}}{{/link-to}}</td>
-  <td class="value">{{#link-to 'adminUsersList.show' 'regular'}}{{value-at-tl data level="2"}}{{/link-to}}</td>
-  <td class="value">{{#link-to 'adminUsersList.show' 'leader'}}{{value-at-tl data level="3"}}{{/link-to}}</td>
-  <td class="value">{{#link-to 'adminUsersList.show' 'elder'}}{{value-at-tl data level="4"}}{{/link-to}}</td>
-</tr>