Sha256: 7ea0c56df3aca6773a98a044a96c50ae3be994a859b31129916f695464cc4614

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

$(document).on('turbo:load', function (event) {
    currentURL = new URL(event.originalEvent.detail.url);
    if(currentURL.pathname.endsWith("tcp_debug")){
        hideLoader();
    }
    $("#ping-host").keypress(function(event){if(event.keyCode == 13){$('#ping').click();}});
    $("#telnet-host").keypress(function(event){if(event.keyCode == 13){$('#telnet').click();}});
    $("#telnet-port").keypress(function(event){if(event.keyCode == 13){$('#telnet').click();}});
});

function hideLoader() {
    $(".loader").hide();
    $(".tcp-debug-response").show();
}

function showLoader() {
    $(".loader").show();
    $(".tcp-debug-response").hide();
}

function startTest(element) {
    $("#response").empty();
    typeOfTest = $(element).attr("id");
    host = $(`#${typeOfTest}-host`).val();
    port = $(`#${typeOfTest}-port`).val();
    // console.log(typeOfTest)
    // console.log(host)
    // console.log(port)
    showLoader();
    $.get("#{rails_admin.send('tcp_debug_path')}", {
        test: typeOfTest,
        host: host,
        port: port
    }).then(function (params) {
        // console.log("OK", params)
        $("#response").html(params["debug_status"]).removeClass("bg-danger").addClass("bg-success");
    }).catch(function (params) {
        // console.log("KO", params)
        $("#response").html(params["responseJSON"]["debug_status"]).removeClass("bg-success").addClass("bg-danger");
    }).always(hideLoader);
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thecore_tcp_debug-3.0.1 app/assets/javascripts/rails_admin/custom/thecore/tcp_debug.js