Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Grain-Yu committed Nov 28, 2023
1 parent 864c490 commit c240b2a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 52 deletions.
20 changes: 4 additions & 16 deletions sql/engines/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,21 +892,9 @@ def get_review_status_summary(self, checksum):
self.close()
return query_result

def set_review_details(self, checksum):
def set_review_details(self, checksum, reviewed_by, reviewed_on, comments, reviewed_status):
"""sql优化详情功能,获取checksum对应的sql优化详情"""
sql_review_summary = f"""select reviewed_by,reviewed_on,comments,reviewed_status from archery.mysql_slow_query_review where checksum='{checksum}';"""
query_result = self.query("mysql", sql_review_summary)
if not query_result.error:
review_summary = query_result.rows
rows = []
row = {
"checksum": checksum,
"reviewed_by": review_summary[0],
"reviewed_on": review_summary[1],
"comments": review_summary[2],
"reviewed_status": review_summary[3],
}
rows.append(row)
query_result.rows = rows
sql_update_review = f"""update archery.mysql_slow_query_review set reviewed_by='{reviewed_by}',reviewed_on='{reviewed_on}',comments='{comments}',reviewed_status='{reviewed_status}' where checksum='{checksum}';"""
exec_result = self.query("mysql", sql_update_review)
self.close()
return query_result
return exec_result
3 changes: 0 additions & 3 deletions sql/manual_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,4 @@ def editreview(request):
exec_result = exec_engine.set_review_details(
checksum=checksum, reviewed_by=reviewed_by, reviewed_on=reviewed_on,comments=comments,reviewed_status=reviewed_status
)
# 关闭连接
engine.close()

return JsonResponse({"status": 0, "msg": "", "data": []})
67 changes: 34 additions & 33 deletions sql/templates/sqlreview.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@




{% block content %}

<!-- 表格-->
Expand All @@ -11,43 +12,40 @@
</table>
</div>
<!-- 修改密码模态框 -->
<div class="modal fade" id="reset-pwd" tabindex="-1" role="dialog">
<div class="modal fade" id="edit-review" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title">修改密码
实例: <span id="reset-instance" style="color: red"></span>
账号: <span id="reset-user" style="color: red"></span></h4>
<h6 style="color:red">此操作会修改账号密码同时变更平台录入信息请谨慎操作</h6>
<h4 class="modal-title">编辑详情</h4>
</div>
<div class="modal-body form-group">
<div class="form-group row">
<label for="password1" class="col-sm-3 col-form-label">
<span style="color:red">*</span>密码</label>
<label for="comments" class="col-sm-3 col-form-label">
<span style="color:red">*</span>内容</label>
<div class="col-sm-9">
<input type="password" id="reset-pwd1" class="form-control" autocomplete="new-password"
aria-describedby="resetpwdHelpBlock"
placeholder="请输入密码">
<small id="resetpwdHelpBlock" class="form-text text-muted">
密码需要8-32个字符至少包含英文数字和特殊符号
<input type="text" id="comments" class="form-control"
placeholder="请填写详情">
</small>
</div>
</div>
<div class="form-group row">
<label for="password2" class="col-sm-3 col-form-label">
<span style="color:red">*</span>确认密码</label>
<label for="reviewed-status" class="col-sm-3 col-form-label">
<span style="color:red">*</span>优化状态</label>
<div class="col-sm-9">
<input type="password" id="reset-pwd2" class="form-control"
autocomplete="new-password"
placeholder="请再次输入密码">
<input type="text" id="reviewed-status" class="form-control"
aria-describedby="editrewHelpBlock"
placeholder="请填写优化状态">
<small id="editrewHelpBlock" class="form-text text-muted">
请输入open/resolved/pending/closed
</small>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-danger" id="resetPwdBtn">修改</button>
<button type="button" class="btn btn-danger" id="editRevBtn">修改</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -122,18 +120,18 @@ <h6 style="color:red">注:此操作会修改账号密码,同时变更平台
},{
title: '优化状态',
field: 'reviewed_status'
},{
title: '操作',
field: '',
formatter: function (value, row, index) {
let btn_edit_review = "<button class=\"btn btn-warning btn-xs\" review_checksum=\"" + row.checksum + "\" onclick=\"review_edit(this)" + "\">编辑</button>\n";
return btn_edit_review
}
}],
onLoadSuccess: function (data) {
if (data.status !== 0) {
alert("数据加载失败!" + data.msg);
$('#btn-create-account').addClass('disabled');
$('#btn-create-account').prop('disabled', true);
} else if ($("#instance").val()) {
$("#btn-create-account").removeClass('disabled');
$("#btn-create-account").prop('disabled', false);

}
},
}},
onLoadError: onLoadErrorCallback,
onSearch: function (e) {
//传搜索参数给服务器
Expand All @@ -145,10 +143,10 @@ <h6 style="color:red">注:此操作会修改账号密码,同时变更平台

//编辑页面
function review_edit(obj) {
var review_checksum = sessionStorage.getItem('review_checksum');
$("#reset-pwd").modal('show');
review_checksum = $(obj).attr("review_checksum");
$("#edit-review").modal('show');
//编辑详情
$("#resetPwdBtn").unbind("click").click(function () {
$("#editRevBtn").unbind("click").click(function () {
var dt = new Date();
var date = dt.getDate();
var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
Expand All @@ -168,9 +166,9 @@ <h6 style="color:red">注:此操作会修改账号密码,同时变更平台
},
success: function (data) {
if (data.status === 0) {
$('#reset-pwd').modal('hide');
$("#reset-pwd input").val("");
user_list()
$('#edit-review').modal('hide');
$("#edit-review input").val("");
review_list()
} else {
alert(data.msg);
}
Expand All @@ -181,6 +179,9 @@ <h6 style="color:red">注:此操作会修改账号密码,同时变更平台
});
});
}

//初始化数据
$(document).ready(function () {
review_list();
});
</script>
{% endblock %}

0 comments on commit c240b2a

Please sign in to comment.