Pārlūkot izejas kodu

Add unit shortening to users page

production
Jack Foltz pirms 6 gadiem
vecāks
revīzija
150b736071
Parakstījis: foltik <jack@foltz.io> GPG atslēgas ID: 303F88F996E95541
2 mainītis faili ar 18 papildinājumiem un 1 dzēšanām
  1. +17
    -0
      app/public/panel/controllers/UserCtrl.js
  2. +1
    -1
      public/views/panel/users.html

+ 17
- 0
app/public/panel/controllers/UserCtrl.js Parādīt failu

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

+ 1
- 1
public/views/panel/users.html Parādīt failu

@@ -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>

Notiek ielāde…
Atcelt
Saglabāt