Sha256: 34403e769acb9e56e337b62ebf4eec55696293b239f444018a58c135952b2621

Contents?: true

Size: 1.85 KB

Versions: 2

Compression:

Stored size: 1.85 KB

Contents

$(document).on('turbo:load', function (event) {
    hideLoader();

    console.log("Into TCP Debug");
    // Action cable Websocket
    App.cable.subscriptions.create("ActivityLogChannel", {
        connected() {
            console.log("Connected to the channel:", this);
            this.send({ message: 'TCP Debug Client is connected', topic: "tcp_debug", namespace: "subscriptions" });
        },
        disconnected() {
            console.log("TCP Debug Client Disconnected");
        },
        received(data) {
            if(data["topic"] == "tcp_debug")
                console.log("TCP DEBUG", data);
        }
    });

    $("#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("text-danger").addClass("text-success");
    }).catch(function (params) {
        // console.log("KO", params)
        $("#response").html(params["responseJSON"]["debug_status"]).removeClass("text-success").addClass("text-danger");
    }).always(hideLoader);
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thecore_tcp_debug-3.0.6 app/assets/javascripts/main_tcp_debug.js
thecore_tcp_debug-3.0.5 app/assets/javascripts/main_tcp_debug.js