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

scripts.sonar-admin.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.admin");

AJS.sonar.admin.displaySonarAssociationPopup = function(associationId, projectId, componentId, titleText, cancelText, saveText, failureText) {
	var popup = new AJS.Dialog(500, 300);
	popup.addHeader(titleText);
	popup.addPanel("Panel 1", "panel1");
	popup.getCurrentPanel().body.append(AJS.$("#associationDialog"));
	popup.addButton(cancelText, function (dialog) {
		dialog.hide();
	});
	popup.addButton(saveText, function (dialog) {
		var server = AJS.$("#sonarServer").val();
		var project = AJS.$("#sonarProjectList").val();
		var associationId = AJS.$("#associationId").val();
		var url = 'add';
		if (associationId > 0) {
			url = 'edit/' + associationId;
		}
		AJS.$.ajax({
			type : "POST",
			async: false,
			dataType: "text",
			data: ({
				projectId: projectId,
				componentId: componentId,
				sonarServer: server,
				sonarProject: project
			}),
			url : contextPath + "/rest/sonar/1.0/association/" + url,
			success: function() {
				dialog.hide();
				location.reload();
			},
			error: function() {
				alert(failureText);
			}
		});
	});
	popup.gotoPage(0);
	popup.gotoPanel(0);
	if (associationId > 0) {
		AJS.sonar.admin.initiateSonarProjectList(associationId);
		AJS.$("#sonarProjectList").css("display", "block");
	} else {
		AJS.$("#sonarProjectList").css("display", "none");
	}
	AJS.$("#associationId").val(associationId);
	popup.show();
};

AJS.sonar.admin.initiateSonarProjectList = function(associationId) {
	AJS.$('#waitImage').css("display", "block");
	var selectList = AJS.$('#sonarProjectList');
	selectList.css("display", "none");
	AJS.$.ajax({
		type : "GET",
		async: true,
		dataType: "json",
		data: ({
			associationId: associationId
		}),
		url : contextPath + "/rest/sonar/1.0/association/get/currentConfiguration",
		success: function(data) {
			selectList.empty();
			if (data !== null && data !== undefined) {
				AJS.$("#sonarServer").val(data.sonarServer);
				AJS.$(data.availableResources).each(function() {
					AJS.$("




© 2015 - 2024 Weber Informatics LLC | Privacy Policy