mirror of
https://github.com/Foltik/Shimapan
synced 2024-11-30 14:31:42 -05:00
Add unit shortening to users page
This commit is contained in:
parent
c7e58c490f
commit
150b736071
@ -6,4 +6,21 @@ angular.module('UserCtrl', ['UserSvc']).controller('UserController', ['$scope',
|
||||
$scope.users = users;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.shorten = function(size) {
|
||||
var units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
var currUnit = 0;
|
||||
|
||||
var num = parseFloat(size);
|
||||
for (i = 0; i < units.length; i++) {
|
||||
if (num / 1000 >= 1 && currUnit < units.length - 1) {
|
||||
currUnit++;
|
||||
num /= 1000;
|
||||
} else {
|
||||
// Round to 2 decimal places
|
||||
return Number(Math.round(num + 'e1')+'e-1') + ' ' +
|
||||
units[currUnit];
|
||||
}
|
||||
}
|
||||
}
|
||||
}]);
|
@ -11,7 +11,7 @@
|
||||
<td>{{user.username}}</td>
|
||||
<td>{{user.scope}}</td>
|
||||
<td>{{user.uploadCount}}</td>
|
||||
<td>{{user.uploadSize}}</td>
|
||||
<td>{{shorten(user.uploadSize)}}</td>
|
||||
<td>{{user.date}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
Loading…
Reference in New Issue
Block a user