You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jumpserver/templates/jasset/asset_list.html

267 lines
12 KiB

{% extends 'base.html' %}
{% load mytags %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins" id="all">
<div class="ibox-title">
<h5> 主机详细信息列表</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
9 years ago
<form id="asset_form">
<div class="col-sm-2" style="padding-left: 0px">
<label>
<select name="idc" class="form-control m-b" onchange="change_info()">
<option value="">IDC机房</option>
{% for idc in idc_all %}
{% ifequal idc.name idc_name %}
<option value="{{idc.name}}" selected> {{ idc.name }}</option>
{% else %}
<option value="{{idc.name}}"> {{ idc.name }}</option>
{% endifequal %}
{% endfor %}
</select>
</label>
</div>
<div class="col-sm-2">
<label>
<select name="group" class="form-control m-b" onchange="change_info()">
9 years ago
<option value="">主机组</option>
9 years ago
{% for asset_group in asset_group_all %}
{% ifequal asset_group.name group_name %}
<option value="{{ asset_group.name }}" selected> {{ asset_group.name }} </option>
{% else %}
<option value="{{ asset_group.name }}"> {{ asset_group.name }} </option>
{% endifequal %}
{% endfor %}
</select>
</label>
</div>
9 years ago
9 years ago
<div class="col-sm-2">
<label>
9 years ago
<select name="asset_type" class="form-control m-b" onchange="change_info()">
9 years ago
<option value="">所有类型</option>
9 years ago
{% for type in asset_types %}
9 years ago
{% ifequal type.0|int2str asset_type %}
<option value="{{ type.0 }}" selected> {{ type.1 }}</option>
{% else %}
<option value="{{ type.0 }}"> {{ type.1 }}</option>
{% endifequal %}
{% endfor %}
</select>
</label>
</div>
<div class="col-sm-2">
<label>
<select name="status" class="form-control m-b" onchange="change_info()">
<option value="">状态</option>
9 years ago
{% for s in asset_status %}
{% ifequal s.0|int2str status %}
<option value="{{ s.0 }}" selected> {{ s.1 }}</option>
9 years ago
{% else %}
9 years ago
<option value="{{ s.0 }}"> {{ s.1 }}</option>
9 years ago
{% endifequal %}
{% endfor %}
</select>
</label>
</div>
9 years ago
<div class="col-sm-4">
<div class="input-group">
<input type="text" class="form-control m-b" id="search_input" name="keyword" value="{{ keyword }}" placeholder="Search">
<input type="text" style="display: none">
<div class="input-group-btn">
<button id='search_btn' href="/jasset/asset_list/?search=true" type="button" class="btn btn-xm btn-primary search-btn" onclick="change_info()">
- 搜索 -
</button>
<button type="button" href="/jasset/asset_list/?export=true" name="export" class="btn btn-xm btn-success search-btn-excel" onclick="return false">
- 导出 -
</button>
</div>
9 years ago
</div>
9 years ago
</div>
9 years ago
<div id="export"></div>
9 years ago
<table class="table table-striped table-bordered table-hover " id="editable" name="editable">
<thead>
<tr>
<th class="text-center">
9 years ago
<input id="checkall" type="checkbox" class="i-checks" name="checkall" value="checkall" data-editable='false' onclick="check_all('asset_form')">
9 years ago
</th>
<th class="text-center" name="ip"> IP地址 </th>
<th class="text-center"> 主机名 </th>
<th class="text-center"> IDC </th>
<th class="text-center"> 所属主机组 </th>
9 years ago
{# <th class="text-center"> 配置信息 </th>#}
<th class="text-center"> 操作系统 </th>
9 years ago
<th class="text-center"> 使用默认管理 </th>
<th class="text-center"> 操作 </th>
</tr>
</thead>
<tbody>
{% for asset in assets.object_list %}
<tr class="gradeX">
<td class="text-center" name="id" value="{{ asset.id }}" data-editable='false'>
<input name="id" value="{{ asset.id }}" type="checkbox" class="i-checks">
</td>
9 years ago
<td class="text-center"> {{ asset.ip|default_if_none:"" }} </td>
<td class="text-center"> {{ asset.hostname|default_if_none:"" }} </td>
<td class="text-center"> {{ asset.idc.name|default_if_none:"" }} </td>
9 years ago
<td class="text-center">{{ asset.group.all|group_str2 }}</td>
9 years ago
{# <td class="text-center">{{ asset.cpu }}|{{ asset.memory }}|{{ asset.disk }}</td>#}
9 years ago
<td class="text-center">{{ asset.system_type|default_if_none:"" }}{{ asset.system_version|default_if_none:"" }}</td>
9 years ago
<td class="text-center"> {{ asset.use_default_auth|bool2str }} </td>
<td class="text-center" data-editable='false'>
<a href="/jasset/asset_detail/?id={{ asset.id }}" class="btn btn-xs btn-primary">详情</a>
{% ifnotequal session_role_id 0 %}
<a href="/jasset/asset_edit/?id={{ asset.id }}" class="btn btn-xs btn-info">编辑</a>
9 years ago
<a href="/jasset/asset_update/?id={{ asset.id }}" class="btn btn-xs btn-info">更新</a>
9 years ago
<a value="/jasset/asset_del/?id={{ asset.id }}" class="btn btn-xs btn-danger asset_del">删除</a>
{% endifnotequal %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="row">
<div class="col-sm-6">
<input type="button" id="asset_del" class="btn btn-danger btn-sm" name="del_button" value="删除"/>
9 years ago
<a value="/jasset/asset_edit_batch/" type="button" class="btn btn-sm btn-warning iframe">修改</a>
9 years ago
</div>
{% include 'paginator.html' %}
</div>
9 years ago
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block self_footer_js %}
<script>
$('table td').on('change', function(env, id){
var url = "/jasset/show_all_ajax/?env=" + env + "&id=" + id;
console.log(url);
$.ajax({
type: "GET",
url: url,
// data: $("#search_form").serialize(),
success: function (data) {
$("#j_dept_"+id).html(data);
}
});
});
$(document).ready(function(){
$('.asset_del').click(function(){
var row = $(this).closest('tr');
9 years ago
if (confirm("确定删除")) {
$.get(
$(this).attr('value'),
{},
function (data) {
row.remove()
}
)
}
})
});
9 years ago
$(".iframe").on('click', function(){
var asset_id_all = getIDall();
if (asset_id_all == ''){
9 years ago
alert("请至少选择一行!");
return false;
}
var url= $(this).attr("value") + '?asset_id_all=' + asset_id_all;
9 years ago
index = $.layer({
type: 2,
title: 'JumpServer - 批量修改主机',
maxmin: true,
shift: 'top',
border: [2, 0.3, '#1AB394'],
shade: [0.5, '#000000'],
shadeClose: true,
area : ['800px' , '600px'],
iframe: {src: url},
close: function(){
location.replace(location.href);
}
});
9 years ago
});
$('.search-btn-excel').unbind('click').bind('click',function(){
var url= $(this).attr("href");
console.log(url);
$.ajax({
type: "GET",
url: url,
data: $("#asset_form").serialize(),
success: function (data) {
$("#export").html(data);
}
});
});
9 years ago
$('#asset_del').click(function () {
var asset_id_all = getIDall();
console.log(asset_id_all);
if (asset_id_all == ''){
alert("请至少选择一行!");
return false;
}
if (confirm("确定删除")) {
$.ajax({
9 years ago
type: "post",
data: {asset_id_all: asset_id_all},
url: "/jasset/asset_del/?arg=batch",
success: function () {
9 years ago
parent.location.reload();
}
});
}
9 years ago
});
function change_info(){
var args = $("#asset_form").serialize();
9 years ago
window.location = "/jasset/asset_list/?" + args
}
$("#search_input").keydown(function(e){
if(e.keyCode==13){
9 years ago
change_info()
}
});
function show_all(env, id) {
var url = "/jasset/show_all_ajax/?env=" + env + "&id=" + id;
console.log(url);
$.ajax({
type: "GET",
url: url,
success: function (data) {
$("#j_group_" + id).html(data);
}
});
}
</script>
{% endblock %}