syncthing/gui/scripts/syncthing/core/filters/metricFilter.js

22 lines
716 B
JavaScript

angular.module('syncthing.core')
.filter('metric', function () {
return function (input) {
if (input === undefined) {
return '0 ';
}
if (input > 1000 * 1000 * 1000) {
input /= 1000 * 1000 * 1000;
return input.toFixed(decimals(input, 2)) + ' G';
}
if (input > 1000 * 1000) {
input /= 1000 * 1000;
return input.toFixed(decimals(input, 2)) + ' M';
}
if (input > 1000) {
input /= 1000;
return input.toFixed(decimals(input, 2)) + ' k';
}
return Math.round(input) + ' ';
};
});