Add total users report; restructure dashboard reports js

This commit is contained in:
Neil Lalonde
2013-03-12 14:40:59 -04:00
parent b97a3c8d34
commit 4eda422cdf
15 changed files with 111 additions and 24 deletions
@@ -31,7 +31,7 @@ Discourse.AdminDashboardRoute = Discourse.Route.extend({
if( !c.get('reportsCheckedAt') || Date.create('1 hour ago') > c.get('reportsCheckedAt') ) {
// TODO: use one request to get all reports, or maybe one request for all dashboard data including version check.
c.set('reportsCheckedAt', new Date());
['visits', 'signups', 'topics', 'posts'].each(function(reportType){
['visits', 'signups', 'topics', 'posts', 'total_users'].each(function(reportType){
c.set(reportType, Discourse.Report.find(reportType));
});
}
@@ -54,9 +54,26 @@
<th>{{i18n admin.dashboard.reports.last_30_days}}</th>
</tr>
</thead>
{{ render 'admin_signups' signups }}
{{ render 'admin_visits' visits }}
{{ render 'admin_topics' topics }}
{{ render 'admin_posts' posts }}
{{ render 'admin_report_signups' signups }}
{{ render 'admin_report_topics' topics }}
{{ render 'admin_report_posts' posts }}
</table>
</div>
</div>
<div class="dashboard-stats">
<table class="table table-condensed table-hover">
<thead>
<tr>
<th>&nbsp;</th>
<th>{{i18n admin.dashboard.reports.today}}</th>
<th>{{i18n admin.dashboard.reports.yesterday}}</th>
<th>{{i18n admin.dashboard.reports.7_days_ago}}</th>
<th>{{i18n admin.dashboard.reports.30_days_ago}}</th>
</tr>
</thead>
{{ render 'admin_report_total_users' total_users }}
{{ render 'admin_report_visits' visits }}
</table>
</div>
<div class="clearfix"></div>
@@ -0,0 +1,9 @@
{{#if loaded}}
<tr>
<td class="title">{{title}}</td>
<td class="value">{{valueAtDaysAgo data 0}}</td>
<td class="value">{{valueAtDaysAgo data 1}}</td>
<td class="value">{{valueAtDaysAgo data 7}}</td>
<td class="value">{{valueAtDaysAgo data 30}}</td>
</tr>
{{/if}}
@@ -0,0 +1,9 @@
{{#if loaded}}
<tr>
<td class="title">{{title}}</td>
<td class="value">{{valueAtDaysAgo data 0}}</td>
<td class="value">{{valueAtDaysAgo data 1}}</td>
<td class="value">{{sumLast data 7}}</td>
<td class="value">{{sumLast data 30}}</td>
</tr>
{{/if}}
@@ -0,0 +1,4 @@
Discourse.AdminReportPostsView = Discourse.View.extend({
templateName: 'admin/templates/reports/summed_counts_report',
tagName: 'tbody'
});
@@ -0,0 +1,4 @@
Discourse.AdminReportSignupsView = Discourse.View.extend({
templateName: 'admin/templates/reports/summed_counts_report',
tagName: 'tbody'
});
@@ -0,0 +1,4 @@
Discourse.AdminReportTopicsView = Discourse.View.extend({
templateName: 'admin/templates/reports/summed_counts_report',
tagName: 'tbody'
});
@@ -0,0 +1,4 @@
Discourse.AdminReportTotalUsersView = Discourse.View.extend({
templateName: 'admin/templates/reports/per_day_counts_report',
tagName: 'tbody'
});
@@ -0,0 +1,4 @@
Discourse.AdminReportVisitsView = Discourse.View.extend({
templateName: 'admin/templates/reports/per_day_counts_report',
tagName: 'tbody'
});
@@ -1,9 +0,0 @@
/**
These views are needed so we can render the same template multiple times on
the admin dashboard.
**/
var opts = { templateName: 'admin/templates/report', tagName: 'tbody' };
Discourse.AdminSignupsView = Discourse.View.extend(opts);
Discourse.AdminVisitsView = Discourse.View.extend(opts);
Discourse.AdminTopicsView = Discourse.View.extend(opts);
Discourse.AdminPostsView = Discourse.View.extend(opts);