nginxview.js 3.39 KB
$(
    updateView()
);

function updateView() {
    $.ajax({
        url: contextPath + "nginx/allNginx",
        type: "post",
        dataType: "json",
        data: {
            type: "aws"
        },
        success: function (response) {
            var awsView = document.getElementById("aws_nginx_row");
            updateNginxView(awsView, response.data, "aws");
        },
        error: function (e) {

        }
    });

    $.ajax({
        url: contextPath + "nginx/allNginx",
        type: "post",
        dataType: "json",
        data: {
            type: "qc"
        },
        success: function (response) {
            var qcView = document.getElementById("qcloud_nginx_row");
            updateNginxView(qcView, response.data, "qcloud")

        },
        error: function (e) {

        }
    });


}

function updateNginxView(awsView, data, type) {

    for (var i = 0; i < data.length; i++) {
        var col = $("<div class='col-md-4' id='" + type + "' onclick='ok(id)'>");

        col.appendTo(awsView);

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

        if (data[i].error>5000 || data[i].apiU200>5000 || data[i].serviceU200>5000) {

            panel.addClass("panel panel-fail-alt noborder");
        }
        else {
            if (data[i].error>1000 || data[i].apiU2000>1000 || data[i].serviceU200>1000)
            {
                panel.addClass("panel panel-alarm-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/nginx.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].name);

        tile.append(tile_value);

        media_body.append(tile);

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

        media_body.append(tile_info);

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

        panel_head.append(hr);

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

        panel_head.append(parameters);

        var apiPara = $("<div class='pull-left'>");
        apiPara.append($("<h5 class='md-title nomargin'>").html("Api 非200响应"));
        apiPara.append($("<h4 class='nomargin' style='margin-left: 20px'>").html(data[i].apiU200));

        parameters.append(apiPara);

        var servicePara = $("<div class='pull-left' style='margin-left: 135px'>");

        servicePara.append($("<h5 class='md-title nomargin'>").html("Service 非200响应"));

        servicePara.append($("<h4 class='nomargin' style='margin-left: 20px'>").html(data[i].serviceU200));

        parameters.append(servicePara);

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

        errorPara.append($("<h5 class='md-title nomargin'>").html("Error 总计"));

        errorPara.append($("<h4 class='nomargin' style='margin-left: 20px'>").html(data[i].error));

        parameters.append(errorPara);
    }

}


function ok(id) {

    if (id == "aws") {
        window.location.href="toNginxaws"
    }
    else
    {
        window.location.href="toNginxqc"
    }
}