diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-11-05 09:54:55 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-11-06 16:48:25 +0100 |
commit | bb00fc56370280793250bc06638f689295af2f01 (patch) | |
tree | df8cafb77a2032ab7c0063b289e2c9621636e303 /server/sonar-web/src/main/js/helpers/measures.js | |
parent | 266e3139c3ef6112d43d3422489a0654937b1816 (diff) | |
download | sonarqube-bb00fc56370280793250bc06638f689295af2f01.tar.gz sonarqube-bb00fc56370280793250bc06638f689295af2f01.zip |
SONAR-6357 add detailed "Size" panel for the "Overview" main page
Diffstat (limited to 'server/sonar-web/src/main/js/helpers/measures.js')
-rw-r--r-- | server/sonar-web/src/main/js/helpers/measures.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/helpers/measures.js b/server/sonar-web/src/main/js/helpers/measures.js index 0e9433295f6..23a27e9270e 100644 --- a/server/sonar-web/src/main/js/helpers/measures.js +++ b/server/sonar-web/src/main/js/helpers/measures.js @@ -1,4 +1,5 @@ import numeral from 'numeral'; +import _ from 'underscore'; /** @@ -23,6 +24,33 @@ export function formatMeasureVariation (value, type) { } +/** + * Return a localized metric name + * @param {string} metricKey + * @returns {string} + */ +export function localizeMetric (metricKey) { + return window.t('metric', metricKey, 'name'); +} + + +/** + * Group list of metrics by their domain + * @param {Array} metrics + * @returns {Array} + */ +export function groupByDomain (metrics) { + let groupedMetrics = _.groupBy(metrics, 'domain'); + let domains = _.map(groupedMetrics, (metricList, domain) => { + return { + domain: domain, + metrics: _.sortBy(metricList, 'name') + }; + }); + return _.sortBy(domains, 'domain'); +} + + /* * Helpers */ |