Add user counts for each trust level to admin dashboard

This commit is contained in:
Neil Lalonde
2013-03-15 18:08:46 -04:00
parent 1d9764d8fc
commit d9cdde9aa7
10 changed files with 99 additions and 10 deletions

View File

@@ -36,3 +36,21 @@ Handlebars.registerHelper('sumLast', function(property, numDays) {
return sum;
}
});
/**
Return the count of users at the given trust level.
@method valueAtTrustLevel
@for Handlebars
**/
Handlebars.registerHelper('valueAtTrustLevel', function(property, trustLevel) {
var data = Ember.Handlebars.get(this, property);
if( data ) {
var item = data.find( function(d, i, arr) { return parseInt(d.x,10) === parseInt(trustLevel,10); } );
if( item ) {
return item.y;
} else {
return 0;
}
}
});

View File

@@ -38,12 +38,27 @@
</p>
</div>
<div class="dashboard-stats totals">
<div class="dashboard-stats">
{{i18n admin.dashboard.total_users}}: <strong>{{#unless loading}}{{ totalUsers }}{{/unless}}</strong><br/>
</div>
<div class="dashboard-stats trust-levels">
<table class="table table-condensed table-hover">
<tr>
<td class="title">{{i18n admin.dashboard.total_users}}</td>
<td class="value">{{#unless loading}}{{ totalUsers }}{{/unless}}</td>
</tr>
<thead>
<tr>
<th>&nbsp;</th>
<th>0</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
</tr>
</thead>
{{#unless loading}}
{{ render 'admin_report_trust_levels' users_by_trust_level }}
{{/unless}}
</table>
</div>

View File

@@ -0,0 +1,9 @@
<tr>
<td class="title">{{title}}</td>
<td class="value">{{valueAtTrustLevel data 0}}</td>
<td class="value">{{valueAtTrustLevel data 1}}</td>
<td class="value">{{valueAtTrustLevel data 2}}</td>
<td class="value">{{valueAtTrustLevel data 3}}</td>
<td class="value">{{valueAtTrustLevel data 4}}</td>
<td class="value">{{valueAtTrustLevel data 5}}</td>
</tr>

View File

@@ -0,0 +1,4 @@
Discourse.AdminReportTrustLevelsView = Discourse.View.extend({
templateName: 'admin/templates/reports/trust_levels_report',
tagName: 'tbody'
});