center_switch.jsp 10.3 KB
<%@page language="java" contentType="text/html;charset=utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="<%=basePath %>css/bootstrap.min.css"/>
    <link rel="stylesheet" href="<%=basePath %>css/bootstrap-datetimepicker.css"/>
    <link href="<%=basePath %>js/bootstrap-plugin/css/bootstrap.table.css" rel="stylesheet" media="screen"/>
    <link rel="stylesheet" href="<%=basePath %>css/bootstrap-responsive.min.css"/>
    <link rel="stylesheet" href="<%=basePath %>css/fullcalendar.css"/>
    <link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css"/>
    <link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css"/>
    <link rel="stylesheet" href="<%=basePath %>css/jquery-ui.css"/>
    <link rel="stylesheet" href="<%=basePath %>css/uniform.css"/>
    <link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
    <link rel="stylesheet" href="<%=basePath %>js/jstree/themes/proton/style.css"/>
    <link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
    <link rel="stylesheet" href="<%=basePath %>css/yoho.css"/>
    <script src="<%=basePath %>js/excanvas.min.js" charset="UTF-8" type="text/javascript"></script>
    <script src="<%=basePath %>js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script>
    <script src="<%=basePath %>js/jquery-ui.custom.js" charset="UTF-8" type="text/javascript"></script>
    <script src="<%=basePath %>/js/bootstrap.min.js"></script>
    <script src="<%=basePath %>/js/unicorn.js"></script>
    <script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/moment-with-locales.js" charset="UTF-8"
            type="text/javascript"></script>
    <script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/bootstrap-datetimepicker.js" charset="UTF-8"
            type="text/javascript"></script>
    <script src="<%=basePath %>js/global.js" charset="UTF-8" type="text/javascript"></script>
    <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.pagination.js" charset="UTF-8"
            type="text/javascript"></script>
    <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.table.js" charset="UTF-8" type="text/javascript"></script>
    <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.dialog.js" charset="UTF-8" type="text/javascript"></script>
    <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
    <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.panel.js" charset="UTF-8" type="text/javascript"></script>
    <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.alerts.js" charset="UTF-8" type="text/javascript"></script>
    <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.accordion.js" charset="UTF-8"
            type="text/javascript"></script>
    <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.breadcrumb.js" charset="UTF-8"
            type="text/javascript"></script>
    <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.validate.js" charset="UTF-8"
            type="text/javascript"></script>
    <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
    <script src="<%=basePath %>js/layer/layer.js" charset="UTF-8" type="text/javascript"></script>
    <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.select.js" charset="UTF-8" type="text/javascript"></script>
    <script src="<%=basePath %>js/jstree/jstree.min.js"></script>
    <script src="<%=basePath %>js/jquery.toaster.js"></script>
    <script>
        var contextPath = '<%=basePath %>';
    </script>
    <title>YOHO!运维</title>
</head>
<body>

<!-- 头部 -->
<div id="head">
</div>
<!-- 右侧具体内容 -->
<div id="content">
    <div id="breadcrumb">
        <a href="#" title="Go to Home" class="tip-bottom"><i
                class="icon-home"></i> Home</a> <a href="#" class="current">双中心切换</a>
    </div>

    <div class="container-fluid">
        <div class="widget-box">
            <div id="switchTable">

            </div>
        </div>
    </div>

</div>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
    <div class="modal-dialog" style="margin-top: 5%;
        margin-left: auto;
        height:50.333%;
        width: 60%;
        overflow:scroll;
        overflow-x:auto;
        overflow-y:auto ">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel"></h4>
            </div>
            <div class="modal-body">
                  <div id="check_result_div" style="">

                  </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>

<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script type="text/javascript">
    $("#li_switch").addClass("active open");
    $("#li_centerswitch").addClass("active");</script>
</body>
</html>

<script>
    $(function () {
        //加载表格
        $("#switchTable").table({
            columnAutoWidth: false,
            url: contextPath + "centerSwitch/getSwitchList",
            striped: true,
            title: "切换列表",
            loadFilter: function (data) {
                return defaultLoadFilter(data);
            },
            columns: [{
                title: "切换项",
                field: "cName",
                width: "15%"
            }, {
                title: "切向QQ",
                field: "name",
                formatter: function (value, rowData, rowIndex) {
                    var div = $("<div>");
                    $("<button onclick=\"doExe(\'" + value + "\',\'beforeCheck\')\">").addClass("btn btn-xs btn-success").html("前检测").appendTo(div);
                    div.append("&nbsp;");
                    $("<button onclick=\"toDoExe(\'" + value + "\',\'toQcloud\')\">").addClass("btn btn-primary").html("切换").appendTo(div);
                    div.append("&nbsp;");
                    $("<button onclick=\"doExe(\'" + value + "\',\'afterCheck\')\">").addClass("btn btn-xs btn-success").html("后检测").appendTo(div);

                    return div;
                },
                width: "35%"
            },{
                title: "切回AWS",
                field: "name",
                formatter: function (value, rowData, rowIndex) {
                    var div = $("<div>");
                    $("<button onclick=\"doExe(\'" + value + "\',\'afterCheck\')\">").addClass("btn btn-xs btn-success").html("前检测").appendTo(div);
                    div.append("&nbsp;");
                    $("<button onclick=\"toDoExe(\'" + value + "\',\'toAws\')\">").addClass("btn btn-primary").html("切换").appendTo(div);
                    div.append("&nbsp;");
                    $("<button onclick=\"doExe(\'" + value + "\',\'beforeCheck\')\">").addClass("btn btn-xs btn-success").html("后检测").appendTo(div);
                    return div;
                },
                width: "35%"
            },{
                title: "状态查看",
                field: "name",
                formatter: function (value, rowData, rowIndex) {
                    var div = $("<div>");
                    $("<button onclick=\"doExe(\'" + value + "\',\'status\')\">").addClass("btn btn-primary").html("当前状态").appendTo(div);
                    return div;
                },
                width: "35%"
            }]
        });
    });

    //执行切换
    function toDoExe(name, toCloud) {
        var dialog = $("<div>").appendTo($("body"));
        dialog.dialog({
            title: "切换确定",
            backdrop: "static",
            content: "name:"+name+"        exe:"+toCloud,
            buttons: [{
                text: "否",
                className: "btn-danger",
                onclick: function () {
                    $(dialog).dialog("hide");
                }
            }, {
                text: "是",
                className: "btn-success",
                onclick: function () {
                    $(dialog).dialog("hide");
                    doExe(name,toCloud);
                }
            }]
        });
    }

    //执行切换
    function doExe(name, exe) {
        var jq = $("#switchTable");

        $.ajax({
            type: 'post',
            url: contextPath + "/centerSwitch/doExe",
            data:{
                'name':name,
                'exe':exe
            },
            dataType: 'json',
            beforeSend:function(){
                var div = $("<div>").attr("tableSelector", jq.selector).addClass("modal-backdrop fade in").appendTo($("body")).hide();
                var tableOffset = jq.offset();
                var tableWidth = jq.outerWidth(true), tableHeight = jq.outerHeight(true);
                div.append($("<div>").addClass("table-loading").css({
                    left : (tableWidth - 124) / 2,
                    top : (tableHeight - 124) / 2
                }));
                div.css({
                    width : tableWidth,
                    height : tableHeight,
                    left : tableOffset.left,
                    top : tableOffset.top
                });
                div.show();
            },
            success: function (resp) {
                $("body").find("div[tableSelector='"+ jq.selector +"']").remove();
                $("#check_result_div").html(resp.data);
                $("#myModalLabel").text("name:"+name+"        exe:"+exe);
                $("#myModal").modal('show');

            },
            error: function () {
                $("body").find("div[tableSelector='"+ jq.selector +"']").remove();
            }
        });
    }

</script>