jumpserver/templates/jasset/asset_list.html

358 lines
17 KiB
HTML
Raw Normal View History

2015-04-20 02:12:11 +00:00
{% extends 'base.html' %}
{% load mytags %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
2015-11-26 12:19:54 +00:00
<div class="col-sm-12">
2015-04-20 02:12:11 +00:00
<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">
2015-11-03 15:53:12 +00:00
<form id="asset_form">
2015-11-26 13:01:39 +00:00
<div class="col-sm-1" style="padding-left: 0">
<a target="_blank" href="/jasset/group_add/" class="btn btn-sm btn-primary "> 添加资产 </a>
</div>
<div class="col-sm-7" style="padding-left: 0px">
2015-11-03 15:53:12 +00:00
<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>
2015-11-26 12:19:54 +00:00
<label>
<select name="group" class="form-control m-b" onchange="change_info()">
<option value="">主机组</option>
{% 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>
2015-11-03 15:53:12 +00:00
<label>
2015-11-08 14:39:30 +00:00
<select name="asset_type" class="form-control m-b" onchange="change_info()">
2015-11-03 15:53:12 +00:00
<option value="">所有类型</option>
2015-11-08 14:39:30 +00:00
{% for type in asset_types %}
2015-11-03 15:53:12 +00:00
{% 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>
2015-11-26 12:19:54 +00:00
2015-11-03 15:53:12 +00:00
<label>
<select name="status" class="form-control m-b" onchange="change_info()">
2015-11-21 10:28:25 +00:00
<option value="">所有状态</option>
2015-11-08 14:39:30 +00:00
{% for s in asset_status %}
{% ifequal s.0|int2str status %}
<option value="{{ s.0 }}" selected> {{ s.1 }}</option>
2015-11-03 15:53:12 +00:00
{% else %}
2015-11-08 14:39:30 +00:00
<option value="{{ s.0 }}"> {{ s.1 }}</option>
2015-11-03 15:53:12 +00:00
{% endifequal %}
{% endfor %}
</select>
</label>
</div>
2015-11-26 12:19:54 +00:00
2015-11-26 13:01:39 +00:00
<div class="col-sm-4" style="padding-right: 0">
2015-11-26 12:19:54 +00:00
<div class="input-group inline-group">
2015-11-08 14:39:30 +00:00
<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>
2015-04-20 02:12:11 +00:00
</div>
2015-11-08 14:39:30 +00:00
</div>
2015-11-03 15:53:12 +00:00
</div>
2015-11-26 12:19:54 +00:00
{# <div class="col-sm-2">#}
{# </div>#}
{##}
{# <div class="col-sm-2">#}
{# </div>#}
{# <div class="col-sm-2">#}
{# </div>#}
{# <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>#}
{# </div>#}
{# </div>#}
2015-04-20 02:12:11 +00:00
2015-11-08 14:39:30 +00:00
<div id="export"></div>
2015-11-03 15:53:12 +00:00
<table class="table table-striped table-bordered table-hover " id="editable" name="editable">
<thead>
<tr>
<th class="text-center">
2015-11-08 14:39:30 +00:00
<input id="checkall" type="checkbox" class="i-checks" name="checkall" value="checkall" data-editable='false' onclick="check_all('asset_form')">
2015-11-03 15:53:12 +00:00
</th>
<th class="text-center"> 主机名 </th>
2015-11-21 10:28:25 +00:00
<th class="text-center" name="ip"> IP地址 </th>
2015-11-03 15:53:12 +00:00
<th class="text-center"> IDC </th>
<th class="text-center"> 所属主机组 </th>
2015-11-14 15:09:13 +00:00
{# <th class="text-center"> 配置信息 </th>#}
<th class="text-center"> 操作系统 </th>
2015-11-03 15:53:12 +00:00
<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>
2015-11-26 11:06:17 +00:00
<td class="text-center hostname"> {{ asset.hostname|default_if_none:"" }} </td>
2015-11-21 10:28:25 +00:00
<td class="text-center"> {{ asset.ip|default_if_none:"" }} </td>
2015-11-17 15:34:13 +00:00
<td class="text-center"> {{ asset.idc.name|default_if_none:"" }} </td>
2015-11-08 14:39:30 +00:00
<td class="text-center">{{ asset.group.all|group_str2 }}</td>
2015-11-14 15:09:13 +00:00
{# <td class="text-center">{{ asset.cpu }}|{{ asset.memory }}|{{ asset.disk }}</td>#}
2015-11-17 15:34:13 +00:00
<td class="text-center">{{ asset.system_type|default_if_none:"" }}{{ asset.system_version|default_if_none:"" }}</td>
2015-11-03 15:53:12 +00:00
<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>
2015-11-23 10:39:38 +00:00
<a value="{{ asset.id }}" class="conn btn btn-xs btn-warning">连接</a>
2015-11-03 15:53:12 +00:00
<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="删除"/>
2015-11-08 14:39:30 +00:00
<a value="/jasset/asset_edit_batch/" type="button" class="btn btn-sm btn-warning iframe">修改</a>
2015-11-22 15:53:25 +00:00
<input type="button" id="asset_update" class="btn btn-info btn-sm" name="update_button" value="更新"/>
2015-11-24 03:20:01 +00:00
<input type="button" id="asset_update_all" class="btn btn-primary btn-sm" name="update_button" value="更新全部"/>
2015-11-03 15:53:12 +00:00
</div>
{% include 'paginator.html' %}
2015-04-20 02:12:11 +00:00
</div>
2015-11-08 14:39:30 +00:00
</form>
</div>
2015-04-20 02:12:11 +00:00
</div>
</div>
</div>
</div>
2015-09-08 16:19:17 +00:00
{% endblock %}
2015-04-20 02:12:11 +00:00
2015-09-08 16:19:17 +00:00
{% block self_footer_js %}
2015-04-20 02:12:11 +00:00
<script>
$(document).ready(function(){
2015-09-08 16:19:17 +00:00
$('.asset_del').click(function(){
var row = $(this).closest('tr');
2015-11-22 15:53:25 +00:00
if (confirm("确定删除?")) {
2015-11-19 13:58:44 +00:00
$.get(
$(this).attr('value'),
{},
function (data) {
row.remove()
}
)
}
2015-11-23 10:39:38 +00:00
});
2015-11-23 11:15:52 +00:00
$('.conn').click(function(){
var url='/jlog/get_role_name/?id=' + $(this).attr('value');
2015-11-23 10:39:38 +00:00
var href = $(this).attr('href');
var new_url = '/jlog/web_terminal/?id=' + $(this).attr('value') + '&role=';
2015-11-26 11:06:17 +00:00
var hostname = $(this).closest('tr').find('.hostname')[0].innerHTML;
2015-11-23 10:39:38 +00:00
$.ajax({
type: 'GET',
url: url,
data: {},
success: function(data){
var dataArray = data.split(',');
2015-11-23 11:15:52 +00:00
if (dataArray.length == 1 && data != 'error'){
2015-11-26 11:06:17 +00:00
var title = 'Jumpserver Web Terminal' + '<span class="text-info"> '+ hostname +'</span>';
2015-11-25 10:59:12 +00:00
layer.open({
2015-11-26 11:06:17 +00:00
type: 2,
title: title,
maxmin: true,
shade: false,
area: ['628px', '452px'],
content: new_url
});
2015-11-25 10:59:12 +00:00
//window.open(new_url + data, '', 'location=no, resizeable=no, height=410, width=625, top=89px, left=99px,toolbar=no,menubar=no,scrollbars=auto,status=no');
2015-11-23 11:15:52 +00:00
} else if (dataArray.length == '1' && data == 'error'){
2015-11-23 10:39:38 +00:00
layer.alert('没有授权角色')
} else {
aUrl = '';
$.each(dataArray, function(index, value){
2015-11-26 11:06:17 +00:00
aUrl += '<a onclick="windowOpen(this); return false" class="btn btn-xs btn-primary newa" href=' + new_url + value + ' value=' + hostname + '>' + value + '</a> '
2015-11-23 10:39:38 +00:00
});
layer.alert(aUrl, {
skin: 'layui-layer-molv',
title: '多个角色,请选择一个连接',
2015-11-25 10:59:12 +00:00
shade: false,
2015-11-23 10:39:38 +00:00
closeBtn: 0
})
}
}
});
return false
});
2015-04-20 02:12:11 +00:00
});
2015-11-26 11:06:17 +00:00
function windowOpen(a){
var new_url = $(a).attr('href');
var hostname = $(a).attr('value');
var title = 'Jumpserver Web Terminal - ' + '<span class="text-info"> '+ hostname +'</span>';
2015-11-25 10:59:12 +00:00
layer.open({
type: 2,
2015-11-26 11:06:17 +00:00
title: title,
2015-11-25 10:59:12 +00:00
maxmin: true,
area: ['628px', '452px'],
shade: false,
content: new_url
});
//window.open(new_url, '', 'height=410, width=625, top=89px, left=99px,toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
2015-11-23 10:39:38 +00:00
return false
}
2015-11-08 14:39:30 +00:00
$(".iframe").on('click', function(){
2015-11-19 16:03:36 +00:00
var asset_id_all = getIDall();
if (asset_id_all == ''){
2015-11-08 14:39:30 +00:00
alert("请至少选择一行!");
return false;
}
2015-11-19 16:03:36 +00:00
var url= $(this).attr("value") + '?asset_id_all=' + asset_id_all;
2015-11-21 10:28:25 +00:00
layer.open({
type: 2,
title: 'JumpServer - 批量修改主机',
maxmin: true,
shift: 'top',
border: [2, 0.3, '#1AB394'],
shade: [0.5, '#000000'],
shadeClose: true,
content: url,
cancel: function(){
location.replace(location.href);
}
});
2015-11-08 14:39:30 +00:00
});
$('.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);
}
});
});
2015-04-20 02:12:11 +00:00
2015-11-23 10:39:38 +00:00
2015-11-03 15:53:12 +00:00
$('#asset_del').click(function () {
var asset_id_all = getIDall();
if (asset_id_all == ''){
alert("请至少选择一行!");
return false;
2015-04-20 02:12:11 +00:00
}
2015-11-22 15:53:25 +00:00
if (confirm("确定删除?")) {
2015-04-20 02:12:11 +00:00
$.ajax({
2015-11-03 15:53:12 +00:00
type: "post",
data: {asset_id_all: asset_id_all},
url: "/jasset/asset_del/?arg=batch",
success: function () {
2015-11-12 16:03:51 +00:00
parent.location.reload();
2015-04-20 02:12:11 +00:00
}
});
}
2015-11-03 15:53:12 +00:00
});
2015-11-22 15:53:25 +00:00
$('#asset_update').click(function () {
var asset_id_all = getIDall();
if (asset_id_all == ''){
alert("请至少选择一行!");
return false;
}
layer.msg('玩命更新中...', {time: 200000});
$.ajax({
type: "post",
data: {asset_id_all: asset_id_all},
url: "/jasset/asset_update_batch/",
success: function () {
parent.location.reload();
}
});
});
2015-11-24 03:20:01 +00:00
{# function update_tips(){#}
{# layer.tips('我是另外一个tips只不过我长得跟之前那位稍有些不一样。', '吸附元素选择器', {#}
{# tips: [1, '#3595CC'],#}
{# time: 4000#}
{# });#}
{# }#}
$('#asset_update_all').click(function () {
layer.msg('玩命更新中...', {time: 200000});
$.ajax({
type: "post",
url: "/jasset/asset_update_batch/?arg=all",
success: function () {
parent.location.reload();
}
});
});
2015-11-03 15:53:12 +00:00
function change_info(){
var args = $("#asset_form").serialize();
2015-11-08 14:39:30 +00:00
window.location = "/jasset/asset_list/?" + args
2015-04-20 02:12:11 +00:00
}
$("#search_input").keydown(function(e){
if(e.keyCode==13){
2015-11-08 14:39:30 +00:00
change_info()
2015-04-20 02:12:11 +00:00
}
2015-09-08 16:19:17 +00:00
});
2015-04-20 02:12:11 +00:00
</script>
{% endblock %}