project_rollbackByTime.jsp 6.45 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 lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>项目发布</title>
    <link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css"/>
    <link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css"/>
    <link rel="stylesheet" href="<%=basePath %>css/bootstrap.min.css"/>
    <link href="<%=basePath%>css/style.default.css" rel="stylesheet">
    <link href="<%=basePath%>css/morris.css" rel="stylesheet">
    <link href="<%=basePath%>css/select2.css" rel="stylesheet"/>
    <script>
        var contextPath = '<%=basePath %>';

    </script>
</head>

<body style="background-color: #444444;font-size: 14px">

<!-- 头部 -->
<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>
        <!-- query panel -->
        <form class="form-bordered">

            <div class="form-group">
                <label class="col-sm-1 control-label">环境选择</label>

                <div class="col-sm-8">
                    <div class="rdio rdio-default">
                        <input type="radio" name="environment" id="aws" value="aws"/>
                        <label for="aws">aws</label>
                    </div>
                    <div class="rdio rdio-default">
                        <input type="radio" name="environment" id="qcloud" value="qcloud" checked="checked"/>
                        <label for="qcloud">qcloud</label>
                    </div>
                    <div class="rdio rdio-default">
                        <input type="radio" name="environment" id="qcloud_gray" value="qcloud_gray" checked="checked"/>
                        <label for="qcloud_gray">qcloud_gray</label>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-1 control-label">时间选择</label>

                <div class="col-sm-8">
                    <div class="rdio rdio-default">
                        <input type="radio" name="time" id="yestoday" value="yestoday" checked="checked"/>
                        <label for="yestoday">昨天</label>
                    </div>
                    <div class="rdio rdio-default">
                        <input type="radio" name="time" id="beforeYestoday" value="beforeYestoday"/>
                        <label for="beforeYestoday">前天</label>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-1 control-label">确认操作</label>

                <div class="col-sm-8">
                    <button type="button" id="submit-btn" onclick="comfirmSubmit()" class="btn btn-primary">提交</button>
                </div>
            </div>

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

<!-- 初始化确认页面  -->
<div class="modal fade" id="confirmSubmitDivId" tabindex="-1" role="dialog" aria-labelledby="confirmSubmitLabel"
     aria-hidden="true" style="padding-top: 10%">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h2 class="modal-title" id="confirmSubmitLabel">
                    <span style="font-weight: bold;"> 确认提交</span>
                </h2>
            </div>
            <div class="modal-body">
                <form class="bs-example bs-example-form" action="<%=basePath  %>project/doRollbackByTime" role="form"
                      id="GitBranchCreateForm" method="post">
                    <div id="detail-modal-show"></div>
                    <input name="data" type="hidden" id="data">
                    <input name="environment" type="hidden" id="environment">
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary">确认</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>
</body>
<script src="<%=basePath%>js/jquery-2.1.4.min.js"></script>
<script src="<%=basePath%>js/bootstrap.min.js"></script>
<script src="<%=basePath%>js/select2.min.js"></script>
<script src="<%=basePath%>js/custom.js"></script>
<script src="<%=basePath %>/js/unicorn.js"></script>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script type="text/javascript">
    $("#li_project").addClass("active open");
    $("#li_projectRelease").addClass("active");

    function comfirmSubmit() {
        var environment = $("input[name='environment']:checked").val();
        var time = $("input[name='time']:checked").val();

        $.ajax({
            url: contextPath + 'project/rollbackByTime?time=' + time + '&environment=' + environment,
            type: 'POST',
            success: function (data) {
                $("#detail-modal-show").empty();
                var obj = eval("(" + data + ")");
                $("#data").val(data);
                $("#environment").val(environment);

                if(obj.length == 0){
                    alert("没有需要回滚的数据");
                    return;
                }

                for (var i = 0; i < obj.length; i++) {
                    var div = "<div class=\"input-group\">";
                    div += "<span class=\"input-group-addon\">" + obj[i].project + "</span>";
                    div += "<input type=\"text\" name=\"project\" class=\"form-control\" readonly=\"readonly\" value='" + obj[i].rollbackFile + "'>";
                    div += "</div><br>";
                    $("#detail-modal-show").append(div);
                }
                $('#confirmSubmitDivId').modal('show');

            },
            error: function (e) {
                alert("从后台获取数据出错");
            }
        });
    }

</script>

</html>