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

scripts.views.sonar-events-view.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.events");

AJS.sonar.views.events.VIEW_NAME = "events";

AJS.sonar.views.events.CATEGORIES = [{
			name: "all",
			key: ""
		}, {
			name: "alert",
			key: "Alert"
		}, {
			name: "profile",
			key: "Profile"
		}, {
			name: "version",
			key: "Version"
}];

/**
 * Generate the Sonar Events view
 * 
 * @param baseUrl the base url of the system displaying the view
 * @param server the Sonar server object
 * @param measureData the measure data of a project on Sonar
 * @param metricsDetails the details of the coverage measures
 * @return the jQuery wrapped view object
 */
AJS.sonar.views.events.generateView = function(baseUrl, server, projectKey, resizeMethod) {
	AJS.sonar.text.load(baseUrl);
	var view = AJS.sonar.views.createViewContainer();
	var header = AJS.$("
").addClass("treemap-header"); view.append(header); var eventsTable = AJS.$("").attr({id: "eventsTable"}); view.append(eventsTable); var onChange = function() { AJS.$("#treemap-loading").show(); var eventCategories = AJS.$("#eventCategories").val(); AJS.sonar.views.events.populateEventsTable(server, AJS.$("#eventsTable"), projectKey, eventCategories, resizeMethod); }; AJS.$(""); var date = AJS.sonar.utils.dateFromISO8601(event.dt); row.append(AJS.$("
").text(date.format("d M Y"))); row.append(AJS.$("").text(event.c)); row.append(AJS.$("").text(event.n)); if (event.ds !== undefined && event.ds !== "") { row.append(AJS.$("").text(event.ds)); } else { row.append(AJS.$("")); } eventsTable.append(row); }); AJS.$("#eventsTable tr:odd").addClass("odd-row"); AJS.$("#eventsTable tr:even").addClass("even-row"); try { resizeMethod(); } catch(x) {} } AJS.$("#treemap-loading").hide(); }, function(request, textStatus) { treemapContainer.empty(); AJS.$("
").addClass("center-div").text( AJS.sonar.text.getMsg("sonar.views.events.failed.to.get.data") ).appendTo(treemapContainer); try { resizeMethod(); } catch(x) {} } ); AJS.$.ajax(ajaxOptions); } /** * Create a Select element for Metrics * * @param name the name of the select element * @param id the id of the select element * @param options the Metric options * @param selected the selected metric key * @param onChange function to bind to the onChange event of the select element * @return the select element */ AJS.sonar.views.events.createSelectElement = function(name, id, selected, onChange) { var select = AJS.$("