1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-12-11 14:02:19 -05:00
shimapan/app/public/panel/controllers/UserCtrl.js

26 lines
826 B
JavaScript

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;
});
};
$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];
}
}
}
}]);