1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 05:45:22 +02:00

fix(general): fix the size display using the filesize library (#246)

* fix(general): fix the size display using the filesize library

* refactor(humansize): use default value for filter
This commit is contained in:
Anthony Lapenna 2016-10-01 21:38:20 +13:00 committed by GitHub
parent 59e65222eb
commit 739a5ec299
7 changed files with 13 additions and 39 deletions

View file

@ -123,15 +123,13 @@ angular.module('portainer.filters', [])
})
.filter('humansize', function () {
'use strict';
return function (bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes === 0) {
return 'n/a';
return function (bytes, round) {
if (!round) {
round = 1;
}
if (bytes || bytes === 0) {
return filesize(bytes, {base: 10, round: round});
}
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10);
var value = bytes / Math.pow(1024, i);
var decimalPlaces = (i < 1) ? 0 : (i - 1);
return value.toFixed(decimalPlaces) + ' ' + sizes[[i]];
};
})
.filter('containername', function () {