gui: Restrict shown decimals and restrict size of header columns (#4973)
This commit is contained in:
@@ -1,21 +1,6 @@
|
||||
angular.module('syncthing.core')
|
||||
.filter('binary', function () {
|
||||
return function (input) {
|
||||
if (input === undefined || isNaN(input)) {
|
||||
return '0 ';
|
||||
}
|
||||
if (input > 1024 * 1024 * 1024) {
|
||||
input /= 1024 * 1024 * 1024;
|
||||
return input.toLocaleString(undefined, {maximumFractionDigits: 2}) + ' Gi';
|
||||
}
|
||||
if (input > 1024 * 1024) {
|
||||
input /= 1024 * 1024;
|
||||
return input.toLocaleString(undefined, {maximumFractionDigits: 2}) + ' Mi';
|
||||
}
|
||||
if (input > 1024) {
|
||||
input /= 1024;
|
||||
return input.toLocaleString(undefined, {maximumFractionDigits: 2}) + ' Ki';
|
||||
}
|
||||
return Math.round(input).toLocaleString(undefined, {maximumFractionDigits: 2}) + ' ';
|
||||
return unitPrefixed(input, true);
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
angular.module('syncthing.core')
|
||||
.filter('localeNumber', function () {
|
||||
return function (input, decimals) {
|
||||
if (typeof(decimals) !== 'undefined') {
|
||||
return input.toLocaleString(undefined, {maximumFractionDigits: decimals});
|
||||
}
|
||||
return function (input) {
|
||||
return input.toLocaleString();
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,21 +1,6 @@
|
||||
angular.module('syncthing.core')
|
||||
.filter('metric', function () {
|
||||
return function (input) {
|
||||
if (input === undefined || isNaN(input)) {
|
||||
return '0 ';
|
||||
}
|
||||
if (input > 1000 * 1000 * 1000) {
|
||||
input /= 1000 * 1000 * 1000;
|
||||
return input.toLocaleString(undefined, {maximumFractionDigits: 2}) + ' G';
|
||||
}
|
||||
if (input > 1000 * 1000) {
|
||||
input /= 1000 * 1000;
|
||||
return input.toLocaleString(undefined, {maximumFractionDigits: 2}) + ' M';
|
||||
}
|
||||
if (input > 1000) {
|
||||
input /= 1000;
|
||||
return input.toLocaleString(undefined, {maximumFractionDigits: 2}) + ' k';
|
||||
}
|
||||
return Math.round(input).toLocaleString(undefined, {maximumFractionDigits: 2}) + ' ';
|
||||
return unitPrefixed(input, false);
|
||||
};
|
||||
});
|
||||
|
||||
15
gui/default/syncthing/core/percentFilter.js
Normal file
15
gui/default/syncthing/core/percentFilter.js
Normal file
@@ -0,0 +1,15 @@
|
||||
angular.module('syncthing.core')
|
||||
.filter('percent', function () {
|
||||
return function (input) {
|
||||
// Prevent 0.00%
|
||||
if (input === undefined || input < 0.01) {
|
||||
return 0 + '%';
|
||||
}
|
||||
// Hard limit at two decimals
|
||||
if (input < 0.1) {
|
||||
return input.toLocaleString(undefined, {maximumFractionDigits: 2}) + '%';
|
||||
}
|
||||
// "Soft" limit at two significant digits (e.g. 1.2%, not 1.27%)
|
||||
return input.toLocaleString(undefined, {maximumSignificantDigits: 2}) + '%';
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user