1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-11-16 09:31:13 -05:00
shimapan/app/public/panel/controllers/UserCtrl.js

26 lines
826 B
JavaScript
Raw Normal View History

2018-01-15 11:46:49 -05:00
var angular = require('angular');
angular.module('UserCtrl', ['UserSvc']).controller('UserController', ['$scope', 'UserService', function($scope, UserService) {
$scope.getUsers = function() {
UserService.getAllUsers(function(users) {
$scope.users = users;
});
};
2018-01-15 18:14:37 -05:00
$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];
}
}
}
2018-01-15 11:46:49 -05:00
}]);