All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scripts.views.sonar-views.js Maven / Gradle / Ivy

/*
 * Licensed to Marvelution under one or more contributor license 
 * agreements.  See the NOTICE file distributed with this work 
 * for additional information regarding copyright ownership.
 * Marvelution licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

AJS.$.namespace("AJS.sonar.views");

AJS.sonar.views.ALTERNATE_METRIC_LINK_PARAMS = {
		line_coverage: "highlight=line_coverage&metric=uncovered_lines",
		branch_coverage: "highlight=branch_coverage&metric=uncovered_conditions",
		public_documented_api_density: "highlight=public_documented_api_density&metric=public_undocumented_api",
		public_undocumented_api: "highlight=public_undocumented_api&metric=public_undocumented_api",
		commented_out_code_lines: "highlight=commented_out_code_lines&metric=commented_out_code_lines",
		duplicated_lines_density: "highlight=duplicated_lines_density&metric=duplicated_lines",
		violations_density: "highlight=weighted_violations&metric=weighted_violations"
};

/**
 * Create the common View container div element
 * 
 * @return the container div element
 */
AJS.sonar.views.createViewContainer = function() {
	return AJS.$("
").addClass("view-container"); } /** * Create a column div element * * @param isLeft flag whether the column is for left (true) or right (false) * @return the column div element */ AJS.sonar.views.createColumn = function(isLeft) { var column = AJS.$("
"); if (isLeft) { column.attr({id: "leftColumn"}); column.addClass("left-column"); } else { column.attr({id: "rightColumn"}); column.addClass("right-column"); } return column; } /** * Create a header element for Sonar Views * * @param labelKey the label i18n key used to get the text of the header * @return the header element */ AJS.sonar.views.createHeader = function(labelKey) { return AJS.$("

").text(AJS.sonar.text.getMsg(labelKey)); } /** * Create the Measure row for a view * * @param serverUrl the Sonar base url * @param view the name of the current view (e.g.: coverage, complexity, loc) * @param measure the measure data * @param metric the metric of the measure * @param isBig display the measure in big text (true) of small text (false) * @return the measure row element */ AJS.sonar.views.createMeasureRow = function(serverUrl, view, resourceId, measure, metric, isBig) { var textBase = "sonar.views." + view + "."; var row = AJS.$("

"); if (isBig) { row.addClass("big-measure"); } var linkParams = "metric=" + metric.key; if (AJS.sonar.views.ALTERNATE_METRIC_LINK_PARAMS[metric.key]) { linkParams = AJS.sonar.views.ALTERNATE_METRIC_LINK_PARAMS[metric.key]; } var backLink = AJS.$("").attr({ href: serverUrl + "/drilldown/measures/" + resourceId + "?" + linkParams, target: "_parent" }); backLink.append(AJS.$("").addClass("alert_" + measure.alert).text(measure.frmt_val)); if (AJS.sonar.text.getMsg(textBase + metric.key) !== "" && AJS.sonar.text.getMsg(textBase + metric.key) !== (textBase + metric.key)) { backLink.append(AJS.$("").text(" " + AJS.sonar.text.getMsg(textBase + metric.key))); } var imageName = AJS.sonar.utils.getTrendImage(measure, !isBig); if (imageName !== "") { backLink.append(AJS.$("").attr({src: serverUrl + "/images" + imageName})); } backLink.appendTo(row); return row; } /** * Add the footer to the view container * * @param viewContainer the div containing the sonar view * @param serverUrl the url of the Sonar server */ AJS.sonar.views.addViewFooter = function(viewContainer, serverUrl) { var footer = AJS.$("





© 2015 - 2024 Weber Informatics LLC | Privacy Policy