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

ui.static.acls-js.createPrincipal.js Maven / Gradle / Ivy

There is a newer version: 0.8.0
Show newest version
$(document).ready(function () {
    $("#create-btn").click(createPrincipalAcls);
});

function createPrincipalAcls() {
    let principalAcls = extractPrincipalAcls();
    doCreatePrincipalAcls(principalAcls);
}

function doCreatePrincipalAcls(principalAcls) {
    let validateErr = validatePrincipalAcls(principalAcls);
    if (validateErr) {
        showOpError(validateErr);
        return;
    }
    let updateMsg = extractUpdateMessage();
    if (updateMsg.trim() === "") {
        updateMsg = "initial creation";
    }
    updateMsg = appendJiraIssuesIfAny(updateMsg, principalAcls.description);
    showOpProgress("Creating principal ACLs...");
    $
        .ajax("api/acls?message=" + encodeURI(updateMsg) + "&" + targetBranchUriParam(), {
            method: "POST",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(principalAcls)
        })
        .done(function () {
            showOpSuccess("Creation completed with success, redirecting...");
            setTimeout(function () {
                $.get("api/acls/single?principal=" + encodeURI(principalAcls.principal))
                    .done(function () {
                        location.href = urlFor("acls.showAllPrincipalAcls", {principal: principalAcls.principal})
                    })
                    .fail(function () {
                        location.href = urlFor("acls.showAll");
                    })
            }, 1000);
        })
        .fail(function (error) {
            let errorMsg = extractErrMsg(error);
            showOpError("Creation failed: " + errorMsg);
        });
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy