rabbitview.js 2.69 KB
$(
    updateView()
);

function updateView() {
    $.ajax({
        url: getUrlBasePath() + "/rabbitmq/allRabbitMq",
        type: "post",
        dataType: "json",
        data: {
            moType: "aws"
        },
        success: function (response) {
            var awsView = document.getElementById("aws_rabbit_row");
            updateRabbitView(awsView, response.data, "aws");
        },
        error: function (e) {

        }
    });

    $.ajax({
        url: getUrlBasePath() + "/rabbitmq/allRabbitMq",
        type: "post",
        dataType: "json",
        data: {
            moType: "qc"
        },
        success: function (response) {
            var qcView = document.getElementById("qcloud_rabbit_row");
            updateRabbitView(qcView, response.data, "qcloud")

        },
        error: function (e) {

        }
    });


}

function updateRabbitView(view, data, type) {

    for (var i = 0; i < data.length; i++) {

        var col = $("<div class='col-md-4' id='" + data[i].moId + "' onclick='ok(id)'>");

        col.appendTo(view);

        var panel = $("<div>");

        if (data[i].moState == 0) {
            panel.addClass("panel panel-fail-alt noborder");
        }
        else {
            panel.addClass("panel panel-success-alt noborder");
        }

        col.append(panel);

        var panel_head = $("<div class='panel-heading noborder'>")

        panel.append(panel_head);

        var panel_icon = $("<div class='panel-icon' style='background-image:url(\""+ contextPath + "img/rabbit.png\"); width:60px;height:60px;' >");

        panel_head.append(panel_icon);

        var media_body = $("<div class='media-body'>");

        panel_head.append(media_body);

        var tile = $("<h5 class='md-title nomargin'>");

        var tile_value = $("<strong>").html(data[i].moName);

        tile.append(tile_value);

        media_body.append(tile);

        var tile_info = $("<h1 class='mt5'>").html(data[i].moHostIp);

        media_body.append(tile_info);

        var hr = $("<hr>");

        panel_head.append(hr);

        var parameters = $("<div class='clearfix mt20'>");

        panel_head.append(parameters);

        var queuePara = $("<div class='pull-left'>");

        queuePara.append($("<h5 class='md-title nomargin'>").html("Queues"));

        queuePara.append($("<h4 class='nomargin'>").html(data[i].moQueues));

        parameters.append(queuePara);

        var msgPara = $("<div class='pull-right'>");

        msgPara.append($("<h5 class='md-title nomargin'>").html("Messages"));

        msgPara.append($("<h4 class='nomargin'>").html(data[i].moMsgs));

        parameters.append(msgPara);
    }

}


function ok(id) {
    window.location.href = "toRabbitmqInfo?moId=" + id;
}