2016-09-17 15:43:41 +00:00
|
|
|
|
{% extends '_base_list.html' %}
|
2016-11-06 13:29:04 +00:00
|
|
|
|
{% load i18n static %}
|
2016-11-06 16:39:26 +00:00
|
|
|
|
{% block table_search %}
|
2016-09-07 16:40:59 +00:00
|
|
|
|
{% endblock %}
|
2017-12-11 09:08:43 +00:00
|
|
|
|
|
|
|
|
|
{% block help_message %}
|
|
|
|
|
<div class="alert alert-info help-message">
|
2018-02-25 10:08:00 +00:00
|
|
|
|
管理用户是 服务器上已存在的特权用户,Jumpserver使用该用户来 `推送系统用户`、`获取资产硬件信息`等。
|
2017-12-11 09:08:43 +00:00
|
|
|
|
</div>
|
|
|
|
|
{% endblock %}
|
|
|
|
|
|
2016-11-06 13:29:04 +00:00
|
|
|
|
{% block table_container %}
|
2017-12-11 09:08:43 +00:00
|
|
|
|
<div class="uc pull-left m-r-5">
|
2016-11-06 16:39:26 +00:00
|
|
|
|
<a href="{% url "assets:admin-user-create" %}" class="btn btn-sm btn-primary"> {% trans "Create admin user" %} </a>
|
2016-11-06 13:29:04 +00:00
|
|
|
|
</div>
|
|
|
|
|
<table class="table table-striped table-bordered table-hover " id="admin_user_list_table" >
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th class="text-center">
|
|
|
|
|
<input type="checkbox" id="check_all" class="ipt_check_all" >
|
|
|
|
|
</th>
|
|
|
|
|
<th class="text-center">{% trans 'Name' %}</th>
|
|
|
|
|
<th class="text-center">{% trans 'Username' %}</th>
|
2018-01-05 09:57:02 +00:00
|
|
|
|
<th class="text-center">{% trans 'Asset' %}</th>
|
|
|
|
|
<th class="text-center">{% trans 'Reachable' %}</th>
|
2017-12-10 16:29:25 +00:00
|
|
|
|
<th class="text-center">{% trans 'Unreachable' %}</th>
|
2018-01-05 09:57:02 +00:00
|
|
|
|
<th class="text-center">{% trans 'Ratio' %}</th>
|
2016-11-06 13:29:04 +00:00
|
|
|
|
<th class="text-center">{% trans 'Comment' %}</th>
|
2016-11-06 16:39:26 +00:00
|
|
|
|
<th class="text-center">{% trans 'Action' %}</th>
|
2016-11-06 13:29:04 +00:00
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
{% endblock %}
|
|
|
|
|
{% block content_bottom_left %}{% endblock %}
|
|
|
|
|
{% block custom_foot_js %}
|
|
|
|
|
<script>
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
|
var options = {
|
|
|
|
|
ele: $('#admin_user_list_table'),
|
|
|
|
|
columnDefs: [
|
|
|
|
|
{targets: 1, createdCell: function (td, cellData, rowData) {
|
2017-12-12 06:38:51 +00:00
|
|
|
|
var detail_btn = '<a href="{% url "assets:admin-user-detail" pk=DEFAULT_PK %}">' + cellData + '</a>';
|
|
|
|
|
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
|
2018-01-05 09:57:02 +00:00
|
|
|
|
}},
|
|
|
|
|
{targets: 4, createdCell: function (td, cellData) {
|
|
|
|
|
var innerHtml = "";
|
|
|
|
|
if (cellData !== 0) {
|
|
|
|
|
innerHtml = "<span class='text-navy'>" + cellData + "</span>";
|
|
|
|
|
} else {
|
|
|
|
|
innerHtml = "<span>" + cellData + "</span>";
|
|
|
|
|
}
|
|
|
|
|
$(td).html('<span href="javascript:void(0);" data-toggle="tooltip" title="' + cellData +'">' + innerHtml + '</span>');
|
|
|
|
|
}},
|
|
|
|
|
{targets: 5, createdCell: function (td, cellData) {
|
|
|
|
|
var innerHtml = "";
|
|
|
|
|
if (cellData !== 0) {
|
|
|
|
|
innerHtml = "<span class='text-danger'>" + cellData + "</span>";
|
|
|
|
|
} else {
|
|
|
|
|
innerHtml = "<span>" + cellData + "</span>";
|
|
|
|
|
}
|
|
|
|
|
$(td).html('<span href="javascript:void(0);" data-toggle="tooltip" title="' + cellData + '">' + innerHtml + '</span>');
|
|
|
|
|
}},
|
2017-12-10 16:29:25 +00:00
|
|
|
|
{targets: 6, createdCell: function (td, cellData, rowData) {
|
2018-01-05 09:57:02 +00:00
|
|
|
|
var val = 0;
|
|
|
|
|
var innerHtml = "";
|
|
|
|
|
var total = rowData.assets_amount;
|
|
|
|
|
var reachable = rowData.reachable_amount;
|
|
|
|
|
if (total !== 0) {
|
|
|
|
|
val = reachable/total * 100;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (val === 100) {
|
|
|
|
|
innerHtml = "<span class='text-navy'>" + val + "% </span>";
|
|
|
|
|
} else {
|
2018-02-25 14:36:42 +00:00
|
|
|
|
var num = new Number(val);
|
|
|
|
|
innerHtml = "<span class='text-danger'>" + num.toFixed(1) + "% </span>";
|
2018-01-05 09:57:02 +00:00
|
|
|
|
}
|
|
|
|
|
$(td).html('<span href="javascript:void(0);" data-toggle="tooltip" title="' + cellData + '">' + innerHtml + '</span>');
|
|
|
|
|
|
|
|
|
|
}},
|
|
|
|
|
{targets: 8, createdCell: function (td, cellData, rowData) {
|
2017-12-12 06:38:51 +00:00
|
|
|
|
var update_btn = '<a href="{% url "assets:admin-user-update" pk=DEFAULT_PK %}" class="btn btn-xs m-l-xs btn-info">{% trans "Update" %}</a>'.replace('{{ DEFAULT_PK }}', cellData);
|
|
|
|
|
var del_btn = '<a class="btn btn-xs btn-danger m-l-xs btn_admin_user_delete" data-uid="{{ DEFAULT_PK }}">{% trans "Delete" %}</a>'.replace('{{ DEFAULT_PK }}', cellData);
|
2017-02-25 15:20:20 +00:00
|
|
|
|
$(td).html(update_btn + del_btn)
|
2016-11-06 13:29:04 +00:00
|
|
|
|
}}],
|
2016-11-16 09:45:46 +00:00
|
|
|
|
ajax_url: '{% url "api-assets:admin-user-list" %}',
|
2017-04-02 16:27:18 +00:00
|
|
|
|
columns: [{data: function(){return ""}}, {data: "name" }, {data: "username" }, {data: "assets_amount" },
|
2018-01-05 09:57:02 +00:00
|
|
|
|
{data: "reachable_amount"}, {data: "unreachable_amount"}, {data: "id"}, {data: "comment" }, {data: "id" }]
|
2016-11-06 13:29:04 +00:00
|
|
|
|
};
|
|
|
|
|
jumpserver.initDataTable(options);
|
2017-01-06 12:34:24 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
.on('click', '.btn_admin_user_delete', function () {
|
|
|
|
|
var $this = $(this);
|
|
|
|
|
var $data_table = $("#admin_user_list_table").DataTable();
|
|
|
|
|
var name = $(this).closest("tr").find(":nth-child(2)").children('a').html();
|
|
|
|
|
var uid = $this.data('uid');
|
2017-12-12 06:38:51 +00:00
|
|
|
|
var the_url = '{% url "api-assets:admin-user-detail" pk=DEFAULT_PK %}'.replace('{{ DEFAULT_PK }}', uid);
|
2017-01-06 12:34:24 +00:00
|
|
|
|
objectDelete($this, name, the_url);
|
2017-02-25 15:20:20 +00:00
|
|
|
|
setTimeout( function () {
|
|
|
|
|
$data_table.ajax.reload();
|
|
|
|
|
}, 3000);
|
2017-01-06 12:34:24 +00:00
|
|
|
|
|
2016-11-06 13:29:04 +00:00
|
|
|
|
});
|
|
|
|
|
</script>
|
2016-09-07 16:40:59 +00:00
|
|
|
|
{% endblock %}
|
2016-11-06 13:29:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|