Skip to content

Commit

Permalink
修改回滚SQL逻辑,可以由该工单的申请人、审核人、副审核人提交回滚申请,提交时可以修改SQL内容等要素。
Browse files Browse the repository at this point in the history
  • Loading branch information
liujing committed Jul 28, 2017
1 parent aa2ca28 commit f8b2e53
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 23 deletions.
1 change: 1 addition & 0 deletions sql/static/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ <h4 class="modal-title" id="myModalLabel">
<script src="{% static 'bootstrap-3.3.7-dist/js/bootstrap.min.js' %}"></script>
<script src="{% static 'dist/js/bootstrap-select.js' %}"></script>
<script src="{% static 'user/js/detail.js' %}"></script>
<script src="{% static 'user/js/rollback.js' %}"></script>
<script src="{% static 'user/js/autoreview.js' %}"></script>
<script src="{% static 'user/js/submitsql.js' %}"></script>
<script src="{% static 'highcharts/highcharts.js' %}"></script>
Expand Down
6 changes: 5 additions & 1 deletion sql/static/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
<h4>单子名称:<span id="editWorkflowNname">{{workflowDetail.workflow_name}}</span></h4>
<input type="hidden" id="workflowDetail_id" name="workflowid" value="{{workflowDetail.id}}">
<input type="hidden" id="editSqlContent" value="{{workflowDetail.sql_content}}"/>
<hr>
<input type="hidden" id="editClustername" value="{{workflowDetail.cluster_name}}"/>
<input type="hidden" id="editIsbackup" value="{{workflowDetail.is_backup}}"/>
<input type="hidden" id="editReviewman" value="{{listAllReviewMen.0}}"/>
<input type="hidden" id="editSubReviewman" value="{{listAllReviewMen.1}}"/>
<hr>
<table class="table table-striped table-hover">
<thead>
<tr>
Expand Down
17 changes: 7 additions & 10 deletions sql/static/rollback.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
{% block content %}
<div>
<div style="width: 20%; float: left"><h4>回滚SQL语句:</h4></div>
{% if loginUser in review_man %}
<div style="width: 80%; float: right">
<form method="post" action="/autoreview/" role="form">
{% csrf_token %}
<input type="hidden" name="sql_content" value="{% for sql in listBackupSql %}{{ sql }}{% endfor %}">
<input type="hidden" name="workflow_name" value="{{ rollbackWorkflowName }}">
<input type="hidden" name="cluster_name" value="{{ cluster_name }}">
<input type="hidden" name="is_backup" value="">
<input type="hidden" name="review_man" value="{{ loginUser }}"> {# 因为只有这个工单的审核人才能看到这个按钮,所以回滚请求直接提给自己 #}
<input id="btn-submitsql" type="submit" class="btn btn-warning" value="提交回滚请求" />
</form>
<input type="hidden" id="editSqlContent" value="{% for sql in listBackupSql %}{{ sql }}{% endfor %}">
<input type="hidden" id="editWorkflowNname" value="{{ rollbackWorkflowName }}">
<input type="hidden" id="editClustername" value="{{ cluster_name }}">
<input type="hidden" id="editIsbackup" value="">
<input type="hidden" id="editReviewman" value="{{ review_man }}">
<input type="hidden" id="editSubReviewman" value="{{ sub_review_man }}">
<a type='button' id="btnSubmitRollback" class="btn btn-warning" href="/editsql/">提交回滚请求</a>
</div>
{% endif %}
<br><br>
</div>
<table class="table table-striped table-hover">
Expand Down
11 changes: 1 addition & 10 deletions sql/static/submitSql.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ <h4 class="panel-title">
<!-- <button type="submit" class="btn btn-primary">SQL提交</button> -->
<input id="btn-submitsql" type="button" class="btn btn-primary" value="SQL提交" />
</div>
</div>
</form>
</div>
</div>

<div id="inception-result" style="display:none;" class="row clearfix">
Expand All @@ -93,13 +93,4 @@ <h4 class="panel-title">
</div>
</div>
</div>
</div>
<script type="text/javascript">
var pathname = window.location.pathname;
if (pathname == "/editsql/") {
document.getElementById('workflowid').value = sessionStorage.getItem('editWorkflowDetailId');
document.getElementById('workflow_name').value = sessionStorage.getItem('editWorkflowNname');
document.getElementById('sql_content').value = sessionStorage.getItem('editSqlContent');
}
</script>
{% endblock content %}
8 changes: 8 additions & 0 deletions sql/static/user/js/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,17 @@ $(document).ready(function () {
var editWorkflowDetailId = $("#workflowDetail_id").val();
var editWorkflowNname = $("#editWorkflowNname").text();
var editSqlContent = $("#editSqlContent").val();
var editClustername = $("#editClustername").val();
var editIsbackup = $("#editIsbackup").val();
var editReviewman = $("#editReviewman").val();
var editSubReviewman = $("#editSubReviewman").val();
sessionStorage.setItem('editWorkflowDetailId', editWorkflowDetailId);
sessionStorage.setItem('editWorkflowNname', editWorkflowNname);
sessionStorage.setItem('editSqlContent', editSqlContent);
sessionStorage.setItem('editClustername', editClustername);
sessionStorage.setItem('editIsbackup', editIsbackup);
sessionStorage.setItem('editReviewman', editReviewman);
sessionStorage.setItem('editSubReviewman', editSubReviewman);
});

$("#btnExecute").click(function(){
Expand Down
20 changes: 20 additions & 0 deletions sql/static/user/js/rollback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$(document).ready(function () {
var isRollback = window.location.pathname.indexOf("rollback");
if (isRollback != -1){
$("#btnSubmitRollback").click(function () {
var editWorkflowNname = $("#editWorkflowNname").val();
var editSqlContent = $("#editSqlContent").val();
var editClustername = $("#editClustername").val();
var editIsbackup = $("#editIsbackup").val();
var editReviewman = $("#editReviewman").val();
var editSubReviewman = $("#editSubReviewman").val();
sessionStorage.removeItem('editWorkflowDetailId');
sessionStorage.setItem('editWorkflowNname', editWorkflowNname);
sessionStorage.setItem('editSqlContent', editSqlContent);
sessionStorage.setItem('editClustername', editClustername);
sessionStorage.setItem('editIsbackup', editIsbackup);
sessionStorage.setItem('editReviewman', editReviewman);
sessionStorage.setItem('editSubReviewman', editSubReviewman);
});
};
});
14 changes: 14 additions & 0 deletions sql/static/user/js/submitsql.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,17 @@ $("#review_man").change(function review_man(){
var review_man = $(this).val();
$("div#" + review_man).hide();
});

$(document).ready(function () {
var pathname = window.location.pathname;
if (pathname == "/editsql/") {
document.getElementById('workflowid').value = sessionStorage.getItem('editWorkflowDetailId');
document.getElementById('workflow_name').value = sessionStorage.getItem('editWorkflowNname');
document.getElementById('sql_content').value = sessionStorage.getItem('editSqlContent');
document.getElementById('cluster_name').value = sessionStorage.getItem('editClustername');
document.getElementById('is_backup').value = sessionStorage.getItem('editIsbackup');
document.getElementById('review_man').value = sessionStorage.getItem('editReviewman');
var sub_review_name = sessionStorage.getItem('editSubReviewman');
$("input[name='sub_review_man'][value=\'"+sub_review_name+"\']").attr("checked", true);
}
});
10 changes: 8 additions & 2 deletions sql/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,15 @@ def rollback(request):
workflowName = workflowDetail.workflow_name
rollbackWorkflowName = "【回滚工单】原工单Id:%s ,%s" % (workflowId, workflowName)
cluster_name = workflowDetail.cluster_name
review_man = workflowDetail.review_man
try:
listAllReviewMen = json.loads(workflowDetail.review_man)
review_man = listAllReviewMen[0]
sub_review_man = listAllReviewMen[1]
except ValueError:
review_man = workflowDetail.review_man
sub_review_man = ''

context = {'listBackupSql':listBackupSql, 'rollbackWorkflowName':rollbackWorkflowName, 'cluster_name':cluster_name, 'review_man':review_man}
context = {'listBackupSql':listBackupSql, 'rollbackWorkflowName':rollbackWorkflowName, 'cluster_name':cluster_name, 'review_man':review_man, 'sub_review_man':sub_review_man}
return render(request, 'rollback.html', context)

#SQL审核必读
Expand Down

0 comments on commit f8b2e53

Please sign in to comment.