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

ui.static.topic.management.topicConfigUpdate.js Maven / Gradle / Ivy

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

function updateTopicConfig() {
    let button = $(this);
    let topicName = button.attr("data-topic-name");
    let clusterIdentifier = button.attr("data-cluster-identifier");
    let topicConfigToSet = extractTopicConfigUpdates(topicName, clusterIdentifier);
    showOpProgress("Updating topic config...");
    $
        .ajax("api/management/update-topic-to-config" +
            "?topicName="+encodeURIComponent(topicName) +
            "&clusterIdentifier="+encodeURIComponent(clusterIdentifier), {
            method: "POST",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(topicConfigToSet)
        })
        .done(function () {
            showOpSuccess("Config update completed with success");
        })
        .fail(function (error) {
            let errorMsg = extractErrMsg(error);
            showOpError("Config update failed: " + errorMsg);
        });
}

function extractTopicConfigUpdates(topicName, clusterIdentifier) {
    let configValues = {};
    $("" +
        "[data-topic=" + cleanupIdHtmlSelector(topicName) + "]" +
        "[data-cluster=" + cleanupIdHtmlSelector(clusterIdentifier) + "]" +
        " .new-value"
    ).each(function () {
        let value = $(this).attr("data-value");
        let key = $(this).attr("data-name");
        let isNull = $(this).attr("data-is-null") === "true";
        configValues[key] = isNull ? null : value;
    });
    return configValues;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy