mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-06-20 00:01:22 +02:00
feat(users): add filter to show ratio formated info
This commit is contained in:
19
modules/core/client/filter/ratio.client.filter.js
Normal file
19
modules/core/client/filter/ratio.client.filter.js
Normal file
@@ -0,0 +1,19 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
// Focus the element on page load
|
||||
// Unless the user is on a small device, because this could obscure the page with a keyboard
|
||||
|
||||
angular.module('core')
|
||||
.filter('ratio', ratio);
|
||||
|
||||
function ratio() {
|
||||
return function (number) {
|
||||
if (number === -1) {
|
||||
return '∞';
|
||||
} else {
|
||||
return number;
|
||||
}
|
||||
};
|
||||
}
|
||||
}());
|
||||
@@ -14,7 +14,7 @@
|
||||
ng-class="{'span-banned': user.status == 'banned'}">
|
||||
<img class="ulist-avatar" ng-src="/{{user.profileImageURL}}">
|
||||
|
||||
<h4 class="list-group-item-heading" ng-bind="user.username"></h4>
|
||||
<h4 class="list-group-item-heading">{{user.displayName}} - <small>{{user.username}}</small></h4>
|
||||
|
||||
<p class="list-group-item-text pull-right small" ng-bind="user.roles"></p>
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
</dd>
|
||||
|
||||
<dt class="h-line">{{ 'STATUS_FIELD.RATIO' | translate}}:</dt>
|
||||
<dd class="h-line"><span ng-class="vm.user.ratio > 1 ? 'ratio-normal' : 'ratio-warning' ">{{ vm.user.ratio }}</span></dd>
|
||||
<dd class="h-line"><span ng-class="vm.user.ratio == 0 ? 'ratio-warning' : 'ratio-normal' ">{{ vm.user.ratio | ratio}}</span></dd>
|
||||
|
||||
<dt class="h-line">{{ 'STATUS_FIELD.SCORE' | translate}}:</dt>
|
||||
<dd class="h-line">
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
</dd>
|
||||
|
||||
<dt class="h-line">{{ 'STATUS_FIELD.RATIO' | translate}}:</dt>
|
||||
<dd class="h-line"><span ng-class="vm.user.ratio > 1 ? 'ratio-normal' : 'ratio-warning' ">{{ vm.user.ratio }}</span></dd>
|
||||
<dd class="h-line"><span ng-class="vm.user.ratio == 0 ? 'ratio-warning' : 'ratio-normal' ">{{ vm.user.ratio | ratio}}</span></dd>
|
||||
|
||||
<li class="status-divider"></li>
|
||||
|
||||
|
||||
@@ -214,7 +214,9 @@ UserSchema.pre('save', function (next) {
|
||||
this.password = this.hashPassword(this.password);
|
||||
}
|
||||
|
||||
if (this.uploaded === 0 || this.downloaded === 0) {
|
||||
if (this.uploaded > 0 && this.downloaded === 0) {
|
||||
this.ratio = -1;
|
||||
} else if (this.uploaded === 0 || this.downloaded === 0) {
|
||||
this.ratio = 0;
|
||||
} else {
|
||||
this.ratio = Math.round((this.uploaded / this.downloaded) * 100) / 100;
|
||||
|
||||
Reference in New Issue
Block a user