Skip to content

Commit

Permalink
历史工单列表样式调整,增加导出、搜索功能,支持搜索提交人和工单名称
Browse files Browse the repository at this point in the history
在线查询新增美化sql功能
  • Loading branch information
hhyo authored and lihuanhuan committed Mar 23, 2018
1 parent 8f7e481 commit afb4173
Show file tree
Hide file tree
Showing 11 changed files with 338 additions and 231 deletions.
4 changes: 2 additions & 2 deletions sql/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@


class master_configAdmin(admin.ModelAdmin):
list_display = ('id', 'cluster_name', 'master_host', 'master_port', 'master_user', 'master_password', 'create_time', 'update_time')
list_display = ('id', 'cluster_name', 'master_host', 'master_port', 'master_user', 'create_time')
search_fields = ['id', 'cluster_name', 'master_host', 'master_port', 'master_user', 'master_password', 'create_time', 'update_time']

class workflowAdmin(admin.ModelAdmin):
list_display = ('id','workflow_name', 'engineer', 'review_man', 'create_time', 'finish_time', 'status', 'is_backup', 'review_content', 'cluster_name', 'reviewok_time', 'sql_content', 'execute_result')
list_display = ('id', 'workflow_name', 'cluster_name', 'engineer', 'create_time', 'status', 'is_backup')
search_fields = ['id','workflow_name', 'engineer', 'review_man', 'sql_content']

#创建用户表单重新定义,继承自UserCreationForm
Expand Down
289 changes: 157 additions & 132 deletions sql/static/allWorkflow.html
Original file line number Diff line number Diff line change
@@ -1,142 +1,167 @@
{% extends "base.html" %}

{% block content %}
<ul class="nav nav-tabs">
{% if navStatus == 'all' %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="/allworkflow/?pageNo=0&navStatus=all">全部工单</a>
</li>
<!-- tab-->
<ul class="nav nav-tabs">
{% if navStatus == 'all' %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="/allworkflow/?pageNo=0&navStatus=all">全部工单</a>
</li>

{% if role == '审核人' %}
{% if navStatus == 'waitingforme' %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="/allworkflow/?pageNo=0&navStatus=waitingforme">待我审核的</a>
</li>
{% endif %}
{% if navStatus == 'manreviewing' %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="/allworkflow/?navStatus=manreviewing">待我审核的</a>
</li>

{% if navStatus == 'finish' %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="/allworkflow/?pageNo=0&navStatus=finish">已执行完毕</a>
</li>
{% if navStatus == 'finish' %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="/allworkflow/?navStatus=finish">已执行完毕</a>
</li>

{% if navStatus == 'executing' %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="/allworkflow/?pageNo=0&navStatus=executing">执行中</a>
</li>
{% if navStatus == 'executing' %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="/allworkflow/?navStatus=executing">执行中</a>
</li>

{% if navStatus == 'abort' %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="/allworkflow/?pageNo=0&navStatus=abort">人工终止流程</a>
</li>
{% if navStatus == 'abort' %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="/allworkflow/?navStatus=abort">人工终止流程</a>
</li>

{% if navStatus == 'autoreviewwrong' %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="/allworkflow/?pageNo=0&navStatus=autoreviewwrong">自动审核不通过的</a>
</li>
{% if navStatus == 'autoreviewwrong' %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="/allworkflow/?navStatus=autoreviewwrong">自动审核不通过的</a>
</li>

</ul>
<table data-toggle="table" class="table table-striped table-hover">
<thead>
<tr>
<th>
工单ID
</th>
<th>
工单名称
</th>
<th>
发起人
</th>
<th>
工单状态
</th>
<th>
发起时间
</th>
<th>
目标集群
</th>
</tr>
</thead>
<tbody>
{% for workflow in listWorkflow %}
<tr>
<td>
{{workflow.id}}
</td>
<td>
<a href="/detail/{{workflow.id}}/">{{workflow.workflow_name}}</a>
</td>
<td>
{{workflow.engineer}}
</td>
<td>
{{workflow.status}}
</td>
<td>
{{workflow.create_time|date:"Y-m-d H:i:s"}}
</td>
<td>
{{workflow.cluster_name}}
</td>
</tr>
{% empty %}
<tr>
<td>当前状态暂无工单,嘿嘿嘿.</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>

</tr>
{% endfor %}

</tbody>
</table>
<div style="text-align:center;">
<ul class="pagination" style="display:inline-block;">
<li>
<a href="/allworkflow/?pageNo={{pageNo|add:"-1"}}&navStatus={{navStatus}}">前一页</a>
</li>
<li class="active">
<a href="/allworkflow/?pageNo={{pageNo|add:"0"}}&navStatus={{navStatus}}">{{pageNo|add:"1"}}</a>
</li>
{% if listWorkflow|length >= PAGE_LIMIT %}
<li>
<a href="/allworkflow/?pageNo={{pageNo|add:"1"}}&navStatus={{navStatus}}">{{pageNo|add:"2"}}</a>
</li>
<li>
<a href="/allworkflow/?pageNo={{pageNo|add:"2"}}&navStatus={{navStatus}}">{{pageNo|add:"3"}}</a>
</li>
<li>
<a href="/allworkflow/?pageNo={{pageNo|add:"3"}}&navStatus={{navStatus}}">{{pageNo|add:"4"}}</a>
</li>
<li>
<a href="/allworkflow/?pageNo={{pageNo|add:"4"}}&navStatus={{navStatus}}">{{pageNo|add:"5"}}</a>
</li>
<li>
<a href="/allworkflow/?pageNo={{pageNo|add:"1"}}&navStatus={{navStatus}}">后一页</a>
</li>
{% endif %}
</ul>
</div>
</ul>
<!-- 审核列表的表格-->
<div class="table-responsive">
<table id="sqlaudit-list" data-toggle="table" class="table table-striped table-hover"
style="table-layout:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
</table>
</div>
{% endblock content%}
{% block js %}
{% load staticfiles %}
<script src="{% static 'bootstrap-table/js/bootstrap-table-export.min.js' %}"></script>
<script src="{% static 'bootstrap-table/js/tableExport.min.js' %}"></script>
<script src="{% static 'dist/js/sql-formatter.min.js' %}"></script>
<script>
//获取申请列表
function get_sqlauditlist() {
//采取异步请求
//初始化table
$('#sqlaudit-list').bootstrapTable('destroy').bootstrapTable({
method: 'post',
contentType: "application/x-www-form-urlencoded",
url: "/sqlworkflow/",
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
pagination: true, //是否显示分页(*)
sortable: true, //是否启用排序
sortOrder: "asc", //排序方式
sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
pageNumber: 1, //初始化加载第一页,默认第一页,并记录
pageSize: 14, //每页的记录行数(*)
pageList: [20, 30, 50, 100], //可供选择的每页的行数(*)
showExport: true, //是否显示导出按钮
exportOptions: {
fileName: 'allworkflow' //文件名称设置
},
search: true, //是否显示表格搜索
strictSearch: false, //是否全匹配搜索
showColumns: true, //是否显示所有的列(选择显示的列)
showRefresh: true, //是否显示刷新按钮
minimumCountColumns: 2, //最少允许的列数
clickToSelect: true, //是否启用点击选中行
uniqueId: "id", //每一行的唯一标识,一般为主键列
showToggle: true, //是否显示详细视图和列表视图的切换按钮
cardView: false, //是否显示详细视图
detailView: false, //是否显示父子表
locale: 'zh-CN', //本地化
toolbar: "#toolbar", //指明自定义的toolbar
queryParamsType: 'limit',
//请求服务数据时所传参数
queryParams:
function (params) {
return {
limit: params.limit,
offset: params.offset,
navStatus: "{{ navStatus }}",
search: params.search
}
},
columns: [{
title: '工单ID',
field: 'id'
}, {
title: '工单名称',
field: 'workflow_name',
formatter: function (value, row, index) {
return "<a href=\"/detail/" + row.id + "/\">" + value + "</a>"
}
}, {
title: '发起人',
field: 'engineer'
}, {
title: '工单状态',
field: 'status',
formatter: function (value, row, index) {
return sqlworkflowStatus_formatter(value)
}
}, {
title: '发起时间',
field: 'create_time'
}, {
title: '目标集群',
field: 'cluster_name'
}],
onLoadSuccess: function () {
},
onLoadError: function () {
alert("数据加载失败!");
},
onSearch: function (e) {
//传搜索参数给服务器
queryParams(e)
},
responseHandler: function (res) {
//在ajax获取到数据,渲染表格之前,修改数据源
return res;
}
});

}
//激活标签页时保存当前标签页的id
$(function () {
$("#nav-tabs").on('shown.bs.tab', "li", function (e) {
var active_tab = $(e.target).parents().attr('id');
get_sqlauditlist();
});
});

//初始化数据
$(document).ready(function () {
var active_tab = 'all';
get_sqlauditlist();
});
</script>
{% endblock %}
2 changes: 1 addition & 1 deletion sql/static/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<a href="{{menu.url}}" class="list-group-item"
{% endif %}

{% if menu.key == 'masterconfig' or menu.key == 'userconfig' or menu.key == 'workflowconfig' %}
{% if menu.key == 'admin' %}
target="_blank"><span class="{{menu.class}}">&nbsp;{{menu.name}}</span></a>
{% else %}
><span class="{{menu.class}}">&nbsp;{{menu.name}}</span></a>
Expand Down
50 changes: 26 additions & 24 deletions sql/static/detail.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -150,32 +150,34 @@ <h4>单子名称:<span id="editWorkflowNname">{{workflowDetail.workflow_name}}
</table>
<br>
{% if workflowDetail.status == '等待审核人审核' %}
{% if loginUser in listAllReviewMen %}
<form action="/execute/" method="post" style="display:inline-block;">
{% csrf_token %}
<input type="hidden" name="workflowid" value="{{workflowDetail.id}}">
<input type="submit" id="btnExecute" type="button" onclick="execute()" class="btn btn-primary btn-default" data-loading-text="Loading..." value="审核通过,执行" />
</form>
{% elif workflowDetail.engineer == loginUser %}
<!--只允许发起人提交其他集群-->
<a type='button' id="btnSubmitOtherCluster" class='btn btn-warning' href="/submitothercluster/">上线其他集群</a>
{% endif %}
{% if loginUser in listAllReviewMen %}
<form action="/execute/" method="post" style="display:inline-block;">
{% csrf_token %}
<input type="hidden" name="workflowid" value="{{workflowDetail.id}}">
<input type="submit" id="btnExecute" type="button" onclick="execute()" class="btn btn-primary btn-default" data-loading-text="Loading..." value="审核通过,执行" />
</form>
{% elif workflowDetail.engineer == loginUser %}
<!--只允许发起人提交其他集群-->
<a type='button' id="btnSubmitOtherCluster" class='btn btn-warning' href="/submitothercluster/">上线其他集群</a>
{% endif %}

<form action="/cancel/" method="post" style="display:inline-block;">
{% csrf_token %}
<input type="hidden" name="workflowid" value="{{workflowDetail.id}}">
<input type="submit" id="btnCancel" type="button" onclick="execute()" class="btn btn-default" data-loading-text="Loading..." value="终止流程" />
</form>

<form action="/cancel/" method="post" style="display:inline-block;">
{% csrf_token %}
<input type="hidden" name="workflowid" value="{{workflowDetail.id}}">
<input type="submit" id="btnCancel" type="button" onclick="execute()" class="btn btn-default" data-loading-text="Loading..." value="终止流程" />
</form>
{% elif workflowDetail.status == '已正常结束' and workflowDetail.is_backup == '是' %}
<form action="/rollback/" method="get" style="display:inline-block;">
{% csrf_token %}
<input type="hidden" name="workflowid" value="{{workflowDetail.id}}">
<input type="submit" id="btnRollback" type="button" class="btn btn-default" data-loading-text="Loading..." value="查看回滚SQL" />
</form>
{% if workflowDetail.engineer == loginUser %}
<!--只允许发起人提交其他集群-->
<a type='button' id="btnSubmitOtherCluster" class='btn btn-warning' href="/submitothercluster/">上线其他集群</a>
{% endif %}
<form action="/rollback/" method="get" style="display:inline-block;">
{% csrf_token %}
<input type="hidden" name="workflowid" value="{{workflowDetail.id}}">
<input type="submit" id="btnRollback" type="button" class="btn btn-default" data-loading-text="Loading..." value="查看回滚SQL" />
</form>
{% if workflowDetail.engineer == loginUser %}
<!--只允许发起人提交其他集群-->
<a type='button' id="btnSubmitOtherCluster" class='btn btn-warning' href="/submitothercluster/">上线其他集群</a>
{% endif %}

{% elif workflowDetail.status == '自动审核不通过' or workflowDetail.status == '人工终止流程' or workflowDetail.status == '执行有异常' %}
{% if workflowDetail.engineer == loginUser %}
<!--只允许发起人修改工单-->
Expand Down
2 changes: 2 additions & 0 deletions sql/static/dist/js/sql-formatter.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit afb4173

Please sign in to comment.