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

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

There is a newer version: 1.9.1
Show newest version
/*
 * 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",
		suspect_lcom4_density: "metric=lcom4"
};

/**
 * 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 backLink = AJS.$("").attr({ href: AJS.sonar.views.evaluateDrilldownHref(serverUrl, resourceId, metric.key), 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; } /** * Helper method to generate the drilldown href for a measure * * @param serverUrl the sonar base url * @param resourceId the resource id * @param metric the metric to drilldown on * @returns the URL */ AJS.sonar.views.evaluateDrilldownHref = function(serverUrl, resourceId, metric) { var linkParams = "metric=" + metric; if (AJS.sonar.views.ALTERNATE_METRIC_LINK_PARAMS[metric]) { linkParams = AJS.sonar.views.ALTERNATE_METRIC_LINK_PARAMS[metric]; } return serverUrl + "/drilldown/measures/" + resourceId + "?" + linkParams; } /** * 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