diff --git a/CHANGELOG_EN.md b/CHANGELOG_EN.md index 1c158232..f1134899 100644 --- a/CHANGELOG_EN.md +++ b/CHANGELOG_EN.md @@ -10,7 +10,8 @@ Supported DBMS: ## [Unreleased] ### Fixed -- Bug fix: fixed volumetry line chart display issue +- Bug fix: fix volumetry chart: incorrect units handling (KB / MB / GB / TB) +- Bug fix: fix volumetry line chart display issue - Bug fix: fixed invalid JSON response ("select-audits" webscript) diff --git a/CHANGELOG_FR.md b/CHANGELOG_FR.md index 1e2cbb0d..5216559a 100644 --- a/CHANGELOG_FR.md +++ b/CHANGELOG_FR.md @@ -10,6 +10,7 @@ SGBD support ## [Unreleased] ### Fixed +- Correction de l'affichage des graphiques de volumétrie avec des données qui ont un format différent (Ko / Mo / Go / To) - Correction de l'affichage du graphique de volumétrie en mode "courbe" - Correction du retour JSON du webscript "select-audits" diff --git a/module_share/src/main/web/components/atolcd/statistics/statistics-tool.js b/module_share/src/main/web/components/atolcd/statistics/statistics-tool.js index 1df249dc..be3c01b8 100644 --- a/module_share/src/main/web/components/atolcd/statistics/statistics-tool.js +++ b/module_share/src/main/web/components/atolcd/statistics/statistics-tool.js @@ -41,55 +41,72 @@ AtolStatistics.dateFormatMasks = { }; AtolStatistics.util.fileSizes = { + 'BYTES_B' : 1, 'BYTES_KB': 1024, 'BYTES_MB': 1048576, 'BYTES_GB': 1073741824, 'BYTES_TB': 1099511627776 }; +AtolStatistics.util.fileSizeMessages = { + 'BYTES_B' : Alfresco.util.message("size.bytes"), + 'BYTES_KB': Alfresco.util.message("size.kilobytes"), + 'BYTES_MB': Alfresco.util.message("size.megabytes"), + 'BYTES_GB': Alfresco.util.message("size.gigabytes"), + 'BYTES_TB': Alfresco.util.message("size.terabytes") +}; + AtolStatistics.util.roundNumber = function (number, digits) { var multiple = Math.pow(10, digits); return Math.round(number * multiple) / multiple; } -AtolStatistics.util.formatFileSize = function (fileSize) { +AtolStatistics.util.formatFileSize = function (fileSize, unit) { if (typeof fileSize == "string") { fileSize = parseInt(fileSize, 10); } + if (unit) { + return { + unit: unit, + value: AtolStatistics.util.roundNumber(fileSize / AtolStatistics.util.fileSizes[unit], 2), + message: AtolStatistics.util.fileSizeMessages[unit] + }; + } + if (fileSize < AtolStatistics.util.fileSizes.BYTES_KB) { return { - unitValue: 1, + unit: "BYTES_B", value: fileSize, - message: Alfresco.util.message("size.bytes") + message: AtolStatistics.util.fileSizeMessages["BYTES_B"] }; } else if (fileSize < AtolStatistics.util.fileSizes.BYTES_MB) { return { - unitValue: AtolStatistics.util.fileSizes.BYTES_KB, + unit: "BYTES_KB", value: AtolStatistics.util.roundNumber(fileSize / AtolStatistics.util.fileSizes.BYTES_KB, 2), - message: Alfresco.util.message("size.kilobytes") + message: AtolStatistics.util.fileSizeMessages["BYTES_KB"] }; } else if (fileSize < AtolStatistics.util.fileSizes.BYTES_GB) { return { - unitValue: AtolStatistics.util.fileSizes.BYTES_MB, + unit: "BYTES_MB", value: AtolStatistics.util.roundNumber(fileSize / AtolStatistics.util.fileSizes.BYTES_MB, 2), - message: Alfresco.util.message("size.megabytes") + message: AtolStatistics.util.fileSizeMessages["BYTES_MB"] }; } else if (fileSize < AtolStatistics.util.fileSizes.BYTES_TB) { return { - unitValue: AtolStatistics.util.fileSizes.BYTES_GB, + unit: "BYTES_GB", value: AtolStatistics.util.roundNumber(fileSize / AtolStatistics.util.fileSizes.BYTES_GB, 2), - message: Alfresco.util.message("size.gigabytes") + message: AtolStatistics.util.fileSizeMessages["BYTES_GB"] }; } return { - unitValue: AtolStatistics.util.fileSizes.BYTES_TB, + unit: "BYTES_TB", value: AtolStatistics.util.roundNumber(fileSize / AtolStatistics.util.fileSizes.BYTES_TB, 2), - message: Alfresco.util.message("size.terabytes") + message: AtolStatistics.util.fileSizeMessages["BYTES_TB"] }; }; diff --git a/module_share/src/main/web/components/atolcd/statistics/volumetry.js b/module_share/src/main/web/components/atolcd/statistics/volumetry.js index 4aea0c4f..c7ec6778 100644 --- a/module_share/src/main/web/components/atolcd/statistics/volumetry.js +++ b/module_share/src/main/web/components/atolcd/statistics/volumetry.js @@ -261,8 +261,9 @@ if (typeof AtolStatistics == "undefined" || !AtolStatistics) { if (!Dom.hasClass(this.id + "-bar-stack-criteria-container", "hidden") && Dom.get(this.id + "-bar_stack-criteria").checked) { // Volumetry conversion by sites - var value_obj = {}; - labelVolumetry = (this.msg("tool.volumetry.label") +" ("+ AtolStatistics.util.formatFileSize(response.json.maxLocal).message +")"); + var value_obj = {}, + maxLocalValue = AtolStatistics.util.formatFileSize(response.json.maxLocal); + labelVolumetry = (this.msg("tool.volumetry.label") + " (" + maxLocalValue.message + ")"); chartArguments.axis.y.label.text = [labelVolumetry]; for (i=0, ii=response.json.stackedValues.length ; i