mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Add user counts for each trust level to admin dashboard
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -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> </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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -0,0 +1,4 @@
|
||||
Discourse.AdminReportTrustLevelsView = Discourse.View.extend({
|
||||
templateName: 'admin/templates/reports/trust_levels_report',
|
||||
tagName: 'tbody'
|
||||
});
|
||||
Reference in New Issue
Block a user