aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-web/src/main/js/application.js46
-rw-r--r--server/sonar-web/src/main/js/overview/models/state.js10
2 files changed, 33 insertions, 23 deletions
diff --git a/server/sonar-web/src/main/js/application.js b/server/sonar-web/src/main/js/application.js
index cde3f74828b..dba8ef02702 100644
--- a/server/sonar-web/src/main/js/application.js
+++ b/server/sonar-web/src/main/js/application.js
@@ -375,22 +375,14 @@ function fileFromPath (path) {
(function () {
/**
- * Format a work duration measure
- * @param {number} value
+ * Format a work duration based on parameters
+ * @param {bool} isNegative
+ * @param {number} days
+ * @param {number} hours
+ * @param {number} minutes
* @returns {string}
*/
- var durationFormatter = function (value) {
- if (value === 0) {
- return '0';
- }
- var hoursInDay = window.SS.hoursInDay || 8,
- isNegative = value < 0,
- absValue = Math.abs(value);
- var days = Math.floor(absValue / hoursInDay / 60);
- var remainingValue = absValue - days * hoursInDay * 60;
- var hours = Math.floor(remainingValue / 60);
- remainingValue -= hours * 60;
- var minutes = remainingValue;
+ var formatDuration = function (isNegative, days, hours, minutes) {
var formatted = '';
if (days > 0) {
formatted += tp('work_duration.x_days', isNegative ? -1 * days : days);
@@ -411,8 +403,27 @@ function fileFromPath (path) {
};
/**
+ * Format a work duration measure
+ * @param {number} value
+ * @returns {string}
+ */
+ var durationFormatter = function (value) {
+ if (value === 0) {
+ return '0';
+ }
+ var hoursInDay = window.SS.hoursInDay || 8,
+ isNegative = value < 0,
+ absValue = Math.abs(value);
+ var days = Math.floor(absValue / hoursInDay / 60);
+ var remainingValue = absValue - days * hoursInDay * 60;
+ var hours = Math.floor(remainingValue / 60);
+ remainingValue -= hours * 60;
+ return formatDuration(isNegative, days, hours, remainingValue);
+ };
+
+ /**
* Format a work duration variation
- * @param value
+ * @param {number} value
*/
var durationVariationFormatter = function (value) {
if (value === 0) {
@@ -424,11 +435,10 @@ function fileFromPath (path) {
/**
* Format a rating measure
- * @param value
+ * @param {number} value
*/
var ratingFormatter = function (value) {
- var intValue = +value;
- return String.fromCharCode(97 + intValue - 1).toUpperCase();
+ return String.fromCharCode(97 + value - 1).toUpperCase();
};
/**
diff --git a/server/sonar-web/src/main/js/overview/models/state.js b/server/sonar-web/src/main/js/overview/models/state.js
index b62181ada55..44964c68157 100644
--- a/server/sonar-web/src/main/js/overview/models/state.js
+++ b/server/sonar-web/src/main/js/overview/models/state.js
@@ -127,7 +127,7 @@ define(function () {
fetchIssues: function () {
var that = this;
- function _fetch (field, createdAfter) {
+ function fetchIssuesByPeriod (field, createdAfter) {
var url = baseUrl + '/api/issues/search',
options = {
ps: 1,
@@ -142,15 +142,15 @@ define(function () {
});
}
- _fetch('issues', null);
+ fetchIssuesByPeriod('issues', null);
if (this.hasPeriod(1)) {
- _fetch('issues1', this.get('period1Date'));
+ fetchIssuesByPeriod('issues1', this.get('period1Date'));
}
if (this.hasPeriod(2)) {
- _fetch('issues2', this.get('period2Date'));
+ fetchIssuesByPeriod('issues2', this.get('period2Date'));
}
if (this.hasPeriod(3)) {
- _fetch('issues3', this.get('period3Date'));
+ fetchIssuesByPeriod('issues3', this.get('period3Date'));
}
},