diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-01-12 19:03:00 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-01-12 19:03:00 +0100 |
| commit | 56974322f8c67ec5680654ed4bcb08ca57117c46 (patch) | |
| tree | e64c00274a47c46cf78e99b6ba62df4bc4dbbba4 /addons/web/static/src/js/core | |
| parent | f6ef0c776096774fc4c6821449ab42cfc2f53e62 (diff) | |
| parent | 3b80a059ff4305fe10c9b40a3118508b1b849ead (diff) | |
[MERGE] forward port branch 11.0 up to 3b80a059ff4
Diffstat (limited to 'addons/web/static/src/js/core')
| -rw-r--r-- | addons/web/static/src/js/core/utils.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/addons/web/static/src/js/core/utils.js b/addons/web/static/src/js/core/utils.js index 99534708a94..1bdd9e70a69 100644 --- a/addons/web/static/src/js/core/utils.js +++ b/addons/web/static/src/js/core/utils.js @@ -24,6 +24,22 @@ var utils = { } }, /** + * Check if the value is a bin_size or not. + * If not, compute an approximate size out of the base64 encoded string. + * + * @param {string} value original format + * @return {string} bin_size (human-readable) + */ + binaryToBinsize: function (value) { + if (!this.is_bin_size(value)) { + // Computing approximate size out of base64 encoded string + // http://en.wikipedia.org/wiki/Base64#MIME + return this.human_size(value.length / 1.37); + } + // already bin_size + return value; + }, + /** * Confines a value inside an interval * * @param {number} [val] the value to confine @@ -132,7 +148,7 @@ var utils = { size /= 1024; ++i; } - return size.toFixed(2) + ' ' + units[i]; + return size.toFixed(2) + ' ' + units[i].trim(); }, /** * Insert "thousands" separators in the provided number (which is actually |
