修改bug,实时搜索完成

pull/6/head
halcyon 2015-04-07 19:15:45 +08:00
parent 7de943c6e4
commit ef63fce7c4
15 changed files with 532 additions and 90 deletions

View File

@ -1,6 +1,6 @@
import datetime
from django.db import models
from juser.models import UserGroup, DEPT
from juser.models import User, UserGroup, DEPT
class IDC(models.Model):
@ -43,4 +43,13 @@ class Asset(models.Model):
comment = models.CharField(max_length=100, blank=True, null=True)
def __unicode__(self):
return self.ip
return self.ip
class AssetAlias(models.Model):
user = models.ForeignKey(User)
host = models.ForeignKey(Asset)
alias = models.CharField(max_length=100, blank=True, null=True)
def __unicode__(self):
return self.comment

View File

@ -22,4 +22,5 @@ urlpatterns = patterns('',
url(r'^host_del/(\w+)/$', host_del),
url(r'^host_edit/$', host_edit),
url(r'^host_edit/batch/$', batch_host_edit),
url(r'^host_edit_common/batch/$', batch_host_edit_common),
)

View File

@ -6,9 +6,9 @@ from django.db.models import Q
from django.template import RequestContext
from django.shortcuts import render_to_response
from jasset.models import IDC, Asset, BisGroup
from jasset.models import IDC, Asset, BisGroup, AssetAlias
from juser.models import UserGroup, DEPT
from jperm.models import Perm
from jperm.models import Perm, SudoPerm
from jumpserver.views import pages
from jumpserver.api import *
@ -88,6 +88,7 @@ def jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_dept, j_activ
a.dept = depts
a.save()
@require_admin
def add_host(request):
login_types = {'L': 'LDAP', 'M': 'MAP'}
@ -189,12 +190,6 @@ def batch_host_edit(request):
j_group = request.POST.getlist(j_group)
j_active = request.POST.get(j_active).strip()
j_comment = request.POST.get(j_comment).strip()
print j_dept, j_group
#
# if is_group_admin(request) and not validate(request, asset=[j_id]):
# emg = u'删除失败,您无权操作!'
# print 'hehe'
# return HttpResponseRedirect('/jasset/host_list/')
if j_type == 'M':
j_user = "editable[" + str(i) + "][j_user]"
@ -202,13 +197,36 @@ def batch_host_edit(request):
j_user = request.POST.get(j_user).strip()
password = request.POST.get(j_password).strip()
j_password = cryptor.encrypt(password)
jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_dept, j_active, j_comment, j_user, j_password)
jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_dept, j_active, j_comment, j_user,
j_password)
else:
jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_dept, j_active, j_comment)
return render_to_response('jasset/host_list.html')
@require_login
def batch_host_edit_common(request):
user_id = request.session.get('user_id', '')
u = User.objects.get(id=user_id)
if request.method == 'POST':
len_table = request.POST.get('len_table')
for i in range(int(len_table)):
j_id = "editable[" + str(i) + "][j_id]"
j_alias = "editable[" + str(i) + "][j_alias]"
j_id = request.POST.get(j_id).strip()
j_alias = request.POST.get(j_alias).strip()
a = Asset.objects.get(id=j_id)
asset_alias = AssetAlias.objects.filter(user=u, host=a)
if asset_alias:
asset_alias = asset_alias[0]
asset_alias.alias = j_alias
asset_alias.save()
else:
AssetAlias.objects.create(user=u, host=a, alias=j_alias)
return render_to_response('jasset/host_list_common.html')
@require_login
def list_host(request):
header_title, path1, path2 = u'查看主机', u'资产管理', u'查看主机'
@ -222,6 +240,8 @@ def list_host(request):
if did:
dept = DEPT.objects.get(id=did)
posts = dept.asset_set.all()
return render_to_response('jasset/host_list_nop.html', locals(), context_instance=RequestContext(request))
elif gid:
posts = []
user_group = UserGroup.objects.get(id=gid)
@ -230,32 +250,47 @@ def list_host(request):
for post in perm.asset_group.asset_set.all():
posts.append(post)
posts = list(set(posts))
return render_to_response('jasset/host_list_nop.html', locals(), context_instance=RequestContext(request))
elif sid:
pass
posts = []
user_group = UserGroup.objects.get(id=sid)
perms = Perm.objects.filter(user_group=user_group)
for perm in perms:
for post in perm.asset_group.asset_set.all():
posts.append(post)
posts = list(set(posts))
return render_to_response('jasset/host_list_nop.html', locals(), context_instance=RequestContext(request))
else:
if is_super_user(request):
if keyword:
posts = Asset.objects.filter(Q(ip__contains=keyword) | Q(idc__name__contains=keyword) |
Q(bis_group__name__contains=keyword) | Q(comment__contains=keyword)).distinct().order_by('ip')
Q(bis_group__name__contains=keyword) | Q(
comment__contains=keyword)).distinct().order_by('ip')
else:
posts = Asset.objects.all().order_by('ip')
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
return render_to_response('jasset/host_list.html', locals(), context_instance=RequestContext(request))
elif is_group_admin(request):
if keyword:
posts = Asset.objects.filter(Q(ip__contains=keyword) | Q(idc__name__contains=keyword) |
Q(bis_group__name__contains=keyword) | Q(comment__contains=keyword)).filter(dept=dept).distinct().order_by('ip')
Q(bis_group__name__contains=keyword) | Q(
comment__contains=keyword)).filter(dept=dept).distinct().order_by('ip')
else:
posts = Asset.objects.all().filter(dept=dept).order_by('ip')
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
return render_to_response('jasset/host_list.html', locals(), context_instance=RequestContext(request))
elif is_common_user(request):
user_id = request.session.get('user_id')
username = User.objects.get(id=user_id).name
posts = user_perm_asset_api(username)
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
return render_to_response('jasset/host_list.html', locals(), context_instance=RequestContext(request))
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
return render_to_response('jasset/host_list_common.html', locals(),
context_instance=RequestContext(request))
@require_admin
@ -478,21 +513,32 @@ def list_group(request):
dept = DEPT.objects.get(id=dept_id)
keyword = request.GET.get('keyword', '')
gid = request.GET.get('gid')
sid = request.GET.get('sid')
if gid:
posts = []
user_group = UserGroup.objects.get(id=gid)
perms = Perm.objects.filter(user_group=user_group)
for perm in perms:
posts.append(perm.asset_group)
elif sid:
posts = []
user_group = UserGroup.objects.get(id=sid)
perms = Perm.objects.filter(user_group=user_group)
for perm in perms:
posts.append(perm.asset_group)
else:
if is_super_user(request):
if keyword:
posts = BisGroup.objects.exclude(name='ALL').filter(Q(name__contains=keyword) | Q(comment__contains=keyword))
posts = BisGroup.objects.exclude(name='ALL').filter(
Q(name__contains=keyword) | Q(comment__contains=keyword))
else:
posts = BisGroup.objects.exclude(name='ALL').order_by('id')
elif is_group_admin(request):
if keyword:
posts = BisGroup.objects.filter(Q(name__contains=keyword) | Q(comment__contains=keyword)).filter(dept=dept)
posts = BisGroup.objects.filter(Q(name__contains=keyword) | Q(comment__contains=keyword)).filter(
dept=dept)
else:
posts = BisGroup.objects.filter(dept=dept).order_by('id')
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
@ -506,7 +552,7 @@ def edit_group(request):
group = BisGroup.objects.get(id=group_id)
all = Asset.objects.all()
dept_id = get_user_dept(request)
eposts = contact_list = Asset.objects.filter(bis_group=group).order_by('ip')
eposts = Asset.objects.filter(bis_group=group).order_by('ip')
if is_super_user(request):
edept = DEPT.objects.all()
@ -552,6 +598,7 @@ def detail_group(request):
return render_to_response('jasset/group_detail.html', locals(), context_instance=RequestContext(request))
@require_admin
def detail_idc(request):
header_title, path1, path2 = u'IDC详情', u'资产管理', u'IDC详情'
login_types = {'L': 'LDAP', 'M': 'MAP'}
@ -605,6 +652,7 @@ def group_del(request, offset):
return HttpResponseRedirect('/jasset/jgroup_list/')
@require_login
def host_search(request):
keyword = request.GET.get('keyword')
login_types = {'L': 'LDAP', 'M': 'MAP'}
@ -618,6 +666,15 @@ def host_search(request):
posts = Asset.objects.filter(Q(ip__contains=keyword) | Q(idc__name__contains=keyword) |
Q(bis_group__name__contains=keyword) | Q(
comment__contains=keyword)).filter(dept=dept).distinct().order_by('ip')
elif is_common_user(request):
user_id = request.session.get('user_id')
username = User.objects.get(id=user_id).name
post_perm = user_perm_asset_api(username)
post_all = Asset.objects.filter(Q(ip__contains=keyword) | Q(idc__name__contains=keyword) |
Q(bis_group__name__contains=keyword) | Q(comment__contains=keyword)) \
.distinct().order_by('ip')
posts = list(set(post_all) & set(post_perm))
print posts
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
return render_to_response('jasset/host_search.html', locals(), context_instance=RequestContext(request))

View File

@ -9,7 +9,7 @@ database = jumpserver
[ldap]
ldap_enable = 1
host_url = ldap://192.168.173.129:389
host_url = ldap://192.168.8.230:389
base_dn = dc=jumpserver, dc=org
root_dn = cn=admin,dc=jumpserver,dc=org
root_pw = secret234

View File

@ -7,6 +7,7 @@ import time
from django import template
from juser.models import User, UserGroup, DEPT
from jumpserver.api import *
from jasset.models import AssetAlias
register = template.Library()
@ -162,6 +163,17 @@ def ugrp_perm_asset_count(user_group_id):
return len(set(assets))
@register.filter(name='get_user_alias')
def get_user_alias(post, user_id):
user = User.objects.get(id=user_id)
host = Asset.objects.get(id=post.id)
alias = AssetAlias.objects.filter(user=user, host=host)
if alias:
return alias[0].alias
else:
return ''
@register.filter(name='group_type_to_str')
def group_type_to_str(type_name):
group_types = {
@ -187,25 +199,11 @@ def ast_to_list_1(lis):
return ast.literal_eval(lis)
# @register.filter(name='perm_asset_count')
# def perm_asset_count(user_id):
# return len(perm_user_asset(user_id))
@register.filter(name='string_length')
def string_length(string, length):
return '%s ...' % string[0:length]
@register.filter(name='get_dic_user')
def get_dic_user(dic):
return dic.get('user')
@register.filter(name='get_dic_times')
def get_dic_times(dic):
return dic.get('times')
@register.filter(name='to_name')
def to_name(user_id):
try:

View File

@ -83,7 +83,6 @@ def index(request):
login_10 = Log.objects.order_by('-start_time')[:10]
# a week top 10
# user_top_ten_more = []
for user_info in user_top_ten:
username = user_info.get('user')
last = Log.objects.filter(user=username).latest('start_time')

View File

@ -69,9 +69,9 @@
{% for data in user_top_five %}
<li class="list-group-item fist-item">
<span class="pull-right">
{{ data|get_dic_times }}次/周
{{ data.times }}次/周
</span>
<span class="label {{ color|random }}">{{ forloop.counter }}</span> {{ data|get_dic_user }}
<span class="label {{ color|random }}">{{ forloop.counter }}</span> {{ data.user }}
</li>
{% endfor %}
</ul>
@ -95,8 +95,8 @@
</div>
</div>
<div class="ibox-content ibox-heading">
<h3><i class="fa fa-envelope-o"></i> New messages</h3>
<small><i class="fa fa-tim"></i> You have 22 new messages and 16 waiting in draft folder.</small>
<h3><i class="fa fa-envelope-o"></i> 权限申请记录 </h3>
<small><i class="fa fa-map-marker"></i> 最近十条权限申请记录信息.</small>
</div>
<div class="ibox-content">
<div class="feed-activity-list">
@ -124,11 +124,14 @@
<div class="ibox-title">
<h5>最近十次登录</h5>
<div class="ibox-tools">
<span class="label label-warning-light">10 Messages</span>
<span class="label label-info-light">10 Messages</span>
</div>
</div>
<div class="ibox-content ibox-heading">
<h3><i class="fa fa-paper-plane-o"></i> 登录记录 </h3>
<small<i class="fa fa-map-marker"></i> 最近十次登录记录. </small>
</div>
<div class="ibox-content">
<div>
<div class="feed-activity-list">
{% for login in login_10 %}
@ -150,7 +153,7 @@
{% endfor %}
</div>
<button class="btn btn-primary btn-block m-t"><i class="fa fa-arrow-down"></i> Show More</button>
<button class="btn btn-primary btn-block m-t"><i class="fa fa-arrow-down"></i> 更多 </button>
</div>
@ -181,8 +184,8 @@
</div>
</div>
<div class="ibox-content ibox-heading">
<h3>You have meeting today!</h3>
<small><i class="fa fa-map-marker"></i> Meeting is on 6:00am. Check your schedule to see detail.</small>
<h3><i class="fa fa-user"></i> 一周Top10用户 </h3>
<small><i class="fa fa-map-marker"></i> 一周Top10用户登录次数及最近一次登录记录. </small>
</div>
<div class="ibox-content inspinia-timeline">
{% for data in user_top_ten %}
@ -190,9 +193,9 @@
<div class="row">
<div class="col-xs-5 date">
<i class="fa fa-info-circle"></i>
<strong>{{ data|get_dic_user }}</strong>
<strong>{{ data.user }}</strong>
<br/>
<small class="text-navy">{{ data|get_dic_times }}次</small>
<small class="text-navy">{{ data.times }}次</small>
</div>
<div class="col-xs-7 content no-top-border">
<p class="m-b-xs">最近一次登录</p>

View File

@ -45,28 +45,36 @@
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="groups" class="col-lg-2 control-label">主机<span class="red-fonts">*</span></label>
<div class="col-sm-3">
<select id="groups" size="12" class="form-control m-b" multiple>
{% for post in posts %}
<option value="{{ post.id }}">{{ post.ip }}</option>
{% endfor %}
</select>
</div>
<div class="col-sm-1">
<div class="btn-group" style="margin-top: 50px;">
<button type="button" class="btn btn-xm btn-white" onclick="move('groups', 'groups_selected')"><i class="fa fa-chevron-right"></i></button>
<button type="button" class="btn btn-xm btn-white" onclick="move_left('groups_selected', 'groups')"><i class="fa fa-chevron-left"></i></button>
</div>
</div>
<div class="col-sm-3">
<div>
<select id="groups_selected" name="j_hosts" class="form-control m-b" size="12" multiple>
{% for post in eposts %}
<div>
<label for="groups" class="col-lg-2 control-label">主机<span class="red-fonts">*</span></label>
<div class="col-sm-3">
<select multiple="multiple" id="id_domains_filter" name="domains_filter" style="display: none;">
</select>
<div class="input-group" style="padding-bottom: 5px">
<input type="text" size="19" class="form-control input-sm" id="search" name="keyword" placeholder="过滤">
</div>
<select id="groups" size="12" class="form-control m-b" multiple>
{% for post in posts %}
<option value="{{ post.id }}">{{ post.ip }}</option>
{% endfor %}
</select>
</div>
<div class="col-sm-1">
<div class="btn-group" style="margin-top: 50px;">
<button type="button" class="btn btn-xm btn-white" onclick="move('groups', 'groups_selected')"><i class="fa fa-chevron-right"></i></button>
<button type="button" class="btn btn-xm btn-white" onclick="move_left('groups_selected', 'groups')"><i class="fa fa-chevron-left"></i></button>
</div>
</div>
<div class="col-sm-3">
<h4 style="padding-bottom: 5px">已选中主机</h4>
<div>
<select id="groups_selected" name="j_hosts" class="form-control m-b" size="12" multiple>
{% for post in eposts %}
<option value="{{ post.id }}">{{ post.ip }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
</div>
@ -113,6 +121,17 @@
$(this).prop('selected', true)
})
}
$('#search').keyup(function() {
var $rows = $('#groups option');
var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
$rows.show().filter(function() {
var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
return !~text.indexOf(val);
}).hide();
});
</script>
{% endblock %}

View File

@ -0,0 +1,172 @@
{% 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>
<ul class="dropdown-menu dropdown-user">
<li><a href="#">未启用 1</a>
</li>
<li><a href="#">未启用 2</a>
</li>
</ul>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div>
<span>点击别名栏修改主机别名, 可在跳板机上使用别名直接登录.</span>
<form id="search_form" method="get" action="" class="pull-right mail-search">
<div class="input-group">
<input type="text" class="form-control input-sm" id="search_input" name="keyword" placeholder="Search">
<input type="text" style="display: none">
<div class="input-group-btn">
<button id='search_btn' type="button" class="btn btn-sm btn-primary" onclick="host_search()">
Search
</button>
</div>
</div>
</form>
</div>
<form id="contents_form" name="contents_form">
<table class="table table-striped table-bordered table-hover " id="editable" name="editable">
<thead>
<tr>
<th class="text-center"><input id="checkall" type="checkbox" class="i-checks" name="checkall" value="checkall" data-editable='false' onclick="check_all('contents_form')"></th>
<th class="text-center" name="j_ip"> IP地址 </th>
<th class="text-center"> 端口号 </th>
<th class="text-center" name="j_type"> 登录方式 </th>
<th class="text-center" name="j_idc"> 所属IDC </th>
<th class="text-center"> 所属部门 </th>
<th class="text-center"> 所属主机组 </th>
<th class="text-center"> 别名 </th>
<th class="text-center" name="j_comment"> 备注 </th>
<th class="text-center"> 操作 </th>
</tr>
</thead>
<tbody>
{% for post in contacts.object_list %}
<tr class="gradeX">
<td class="text-center" name="j_id" value="{{ post.id }}" data-editable='false'><input name="id" value="{{ post.id }}" type="checkbox" class="i-checks"></td>
<td class="text-center" data-editable='false' name="j_ip"> {{ post.ip }} </td>
<td class="text-center" data-editable='false' name="j_port"> {{ post.port }} </td>
<td class="text-center" data-editable='false' name="j_type"> {{ login_types|get_item:post.login_type }} </td>
<td class="text-center" data-editable='false' name="j_idc"> {{ post.idc.name }} </td>
<td class="text-center" data-editable='false' name="j_dept">{{ post.dept.all | group_str2 }}</td>
<td class="text-center" data-editable='false' name="j_group">{{ post.bis_group.all | group_str2_all }}</td>
<td class="text-center" name="j_alias"> {{ post|get_user_alias:user_id }} </td>
<td class="text-center" data-editable='false' name="j_comment"> {{ post.comment }} </td>
<td class="text-center" data-editable='false'>
<a value="/jasset/{{ post.ip }}/" class="iframe btn btn-xs btn-primary">详情</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="row">
<div class="col-sm-6">
<input type="button" id="alter_button" class="btn btn-warning btn-sm" name="alter_button" value="修改" onclick="alter('contents_form')" />
</div>
{% include 'paginator.html' %}
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('#editable').editableTableWidget();
});
$(".iframe").on('click', function(){
var url= $(this).attr("value");
$.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}
});
});
function alter(form) {
selectData = GetTableDataBox();
if (selectData[1] != 0) {
$.ajax({
type: "post",
url: "/jasset/host_edit_common/batch/",
data: {"editable": selectData[0], "len_table": selectData[1]},
success: function (data) {
alert("修改成功");
window.open("/jasset/host_list/", "_self");
}
});
}
}
function del(form) {
var checkboxes = document.getElementById(form);
var id_list = {};
var j = 0;
for (var i = 0; i < checkboxes.elements.length; i++) {
if (checkboxes.elements[i].type == "checkbox" && checkboxes.elements[i].checked == true && checkboxes.elements[i].value != "checkall") {
id_list[j] = checkboxes.elements[i].value;
j++;
}
}
if (confirm("确定删除")) {
$.ajax({
type: "POST",
url: "/jasset/host_del/multi/",
data: {"id_list": id_list, "len_list": j},
success: function (data) {
window.open("/jasset/host_list/", "_self");
}
});
}
}
function host_search(){
$.ajax({
type: "GET",
url: "/jasset/search/",
data: $("#search_form").serialize(),
success: function (data) {
$("#contents_form").html(data);
}
});
}
$("#search_input").keydown(function(e){
if(e.keyCode==13){
host_search()
}
})
</script>
{% endblock %}

View File

@ -0,0 +1,177 @@
{% 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>
<ul class="dropdown-menu dropdown-user">
<li><a href="#">未启用 1</a>
</li>
<li><a href="#">未启用 2</a>
</li>
</ul>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div>
<a target="_blank" href="/jasset/host_add" class="btn btn-sm btn-primary "> 添加 </a>
<!--<form id="search_form" method="get" action="" class="pull-right mail-search">-->
<!--<div class="input-group">-->
<!--<input type="text" class="form-control input-sm" id="search_input" name="keyword" placeholder="Search">-->
<!--<input type="text" style="display: none">-->
<!--<div class="input-group-btn">-->
<!--<button id='search_btn' type="button" class="btn btn-sm btn-primary" onclick="host_search()">-->
<!--Search-->
<!--</button>-->
<!--</div>-->
<!--</div>-->
<!--</form>-->
</div>
<form id="contents_form" name="contents_form">
<table class="table table-striped table-bordered table-hover " id="editable" name="editable">
<thead>
<tr>
<th class="text-center"><input id="checkall" type="checkbox" class="i-checks" name="checkall" value="checkall" data-editable='false' onclick="check_all('contents_form')"></th>
<th class="text-center" name="j_ip"> IP地址 </th>
<th class="text-center"> 端口号 </th>
<th class="text-center" name="j_type"> 登录方式 </th>
<th class="text-center" name="j_idc"> 所属IDC </th>
<th class="text-center"> 所属部门 </th>
<th class="text-center"> 所属主机组 </th>
<th class="text-center"> 是否激活 </th>
<th class="text-center" name="j_comment"> 备注 </th>
<th class="text-center"> 操作 </th>
</tr>
</thead>
<tbody>
{% for post in posts %}
<tr class="gradeX">
<td class="text-center" name="j_id" value="{{ post.id }}" data-editable='false'><input name="id" value="{{ post.id }}" type="checkbox" class="i-checks"></td>
<td class="text-center" name="j_ip"> {{ post.ip }} </td>
<td class="text-center" name="j_port"> {{ post.port }} </td>
<td class="text-center" name="j_type"> {{ login_types|get_item:post.login_type }} </td>
<td class="text-center" name="j_idc"> {{ post.idc.name }} </td>
<td class="text-center" name="j_dept">{{ post.dept.all | group_str2 }}</td>
<td class="text-center" name="j_group">{{ post.bis_group.all | group_str2_all }}</td>
<td class="text-center" name="j_active"> {{ post.is_active|bool2str }} </td>
<td class="text-center" name="j_comment"> {{ post.comment }} </td>
<td class="text-center" data-editable='false'>
<a value="/jasset/{{ post.ip }}/" class="iframe btn btn-xs btn-primary">详情</a>
{% ifnotequal session_role_id 0 %}
<a href="/jasset/host_edit/?id={{ post.id }}" class="btn btn-xs btn-info">编辑</a>
<a href="/jasset/host_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
{% endifnotequal %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="row">
<div class="col-sm-6">
<input type="button" id="del_button" class="btn btn-danger btn-sm" name="del_button" value="删除" onclick="del('contents_form')" />
<input type="button" id="alter_button" class="btn btn-warning btn-sm" name="alter_button" value="修改" onclick="alter('contents_form')" />
</div>
<!--{% include 'paginator.html' %}-->
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('#editable').editableTableWidget();
});
$(".iframe").on('click', function(){
var url= $(this).attr("value");
$.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}
});
});
function alter(form) {
selectData = GetTableDataBox();
if (selectData[1] != 0) {
$.ajax({
type: "post",
url: "/jasset/host_edit/batch/",
data: {"editable": selectData[0], "len_table": selectData[1]},
success: function (data) {
alert("修改成功");
window.open("/jasset/host_list/", "_self");
}
});
}
}
function del(form) {
var checkboxes = document.getElementById(form);
var id_list = {};
var j = 0;
for (var i = 0; i < checkboxes.elements.length; i++) {
if (checkboxes.elements[i].type == "checkbox" && checkboxes.elements[i].checked == true && checkboxes.elements[i].value != "checkall") {
id_list[j] = checkboxes.elements[i].value;
j++;
}
}
if (confirm("确定删除")) {
$.ajax({
type: "POST",
url: "/jasset/host_del/multi/",
data: {"id_list": id_list, "len_list": j},
success: function (data) {
window.open("/jasset/host_list/", "_self");
}
});
}
}
function host_search(){
$.ajax({
type: "GET",
url: "/jasset/search/",
data: $("#search_form").serialize(),
success: function (data) {
$("#contents_form").html(data);
}
});
}
$("#search_input").keydown(function(e){
if(e.keyCode==13){
host_search()
}
})
</script>
{% endblock %}

View File

@ -8,7 +8,11 @@
<th class="text-center" name="j_type"> 登录方式 </th>
<th class="text-center" name="j_idc"> 所属IDC </th>
<th class="text-center"> 所属业务组 </th>
<th class="text-center"> 是否激活 </th>
{% ifnotequal session_role_id 0 %}
<th class="text-center"> 是否激活 </th>
{% else %}
<th class="text-center"> 别名 </th>
{% endifnotequal %}
<th class="text-center" name="j_time"> 添加时间 </th>
<th class="text-center" name="j_comment"> 备注 </th>
<th class="text-center"> 操作 </th>
@ -23,13 +27,19 @@
<td class="text-center" name="j_type"> {{ login_types|get_item:post.login_type }} </td>
<td class="text-center" name="j_idc"> {{ post.idc.name }} </td>
<td class="text-center" name="j_group">{{ post.bis_group.all | group_str2 }}</td>
<td class="text-center" name="j_active"> {{ post.is_active|bool2str }} </td>
{% ifnotequal session_role_id 0 %}
<td class="text-center" name="j_alias"> {{ post.is_active|bool2str }} </td>
{% else %}
<td class="text-center" name="j_active"> {{ post|get_user_alias:user_id }} </td>
{% endifnotequal %}
<td class="text-center"> {{ post.date_added|date:"Y-m-d H:i:s" }} </td>
<td class="text-center" name="j_comment"> {{ post.comment }} </td>
<td class="text-center" data-editable='false'>
<a value="/jasset/{{ post.ip }}/" class="iframe btn btn-xs btn-primary">详情</a>
<a href="/jasset/host_edit/?id={{ post.id }}" class="btn btn-xs btn-info">编辑</a>
<a href="/jasset/host_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
{% ifnotequal session_role_id 0 %}
<a href="/jasset/host_edit/?id={{ post.id }}" class="btn btn-xs btn-info">编辑</a>
<a href="/jasset/host_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
{% endifnotequal %}
</td>
</tr>
{% endfor %}

View File

@ -74,7 +74,7 @@
<select multiple="multiple" id="id_domains_filter" name="domains_filter" style="display: none;">
</select>
<div class="input-group" style="padding-bottom: 5px">
<input type="text" size="19" class="form-control input-sm" id="search_input" name="keyword" placeholder="过滤" oninput="search_domain(this.value)">
<input type="text" size="19" class="form-control input-sm" id="search" name="keyword" placeholder="过滤">
</div>
<select id="groups" size="12" class="form-control m-b" multiple>
{% for post in posts %}
@ -119,17 +119,16 @@
</div>
</div>
</div>
<script>
function search_domain(text){
console.log(text)
$("#groups").children().each(function(){$(this).remove();});
$("#id_domains_filter").children().each(function(){
if ($(this).text().search(text) != -1) {
console.log(text);
$("#groups").append($(this).clone())
}
});
}
<script>
var $rows = $('#groups option');
$('#search').keyup(function() {
var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
$rows.show().filter(function() {
var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
return !~text.indexOf(val);
}).hide();
});
</script>
{% endblock content %}

View File

@ -58,7 +58,6 @@
<th class="text-center"> 申请主机 </th>
<th class="text-center"> 批准人 </th>
<th class="text-center"> 申请时间 </th>
<!--<th class="text-center"> 批准时间 </th>-->
<th class="text-center"> 备注 </th>
<th class="text-center"> 详情 </th>
@ -69,11 +68,10 @@
<tr class="gradeX">
<td class="text-center" id="username"> {{ post.applyer }} </td>
<td class="text-center" id="dept"> {{ post.dept }} </td>
<td class="text-center" id="ip"> {% for i in post.bisgroup|ast_to_list %} {{ i }} {% endfor %}... </td>
<td class="text-center" id="remote_ip">{% for i in post.asset|ast_to_list %} {{ i }} {% endfor %}... </td>
<td class="text-center" id="ip"> {{ post.bisgroup|ast_to_list }} </td>
<td class="text-center" id="remote_ip">{{ post.asset|ast_to_list }} </td>
<td class="text-center" id="approver"> {{ post.approver }} </td>
<td class="text-center" id="start_time"> {{ post.date_add|date:"Y-m-d H:i:s"}} </td>
<!--<td class="text-center" id="end_time"> {{ post.date_end|date:"Y-m-d H:i:s" }} </td>-->
<td class="text-center" id=""> {{ post.comment }} </td>
<td class="text-center" data-editable='false'>
<a value="/jperm/apply_info/?uuid={{ post.uuid }}" class="iframe btn btn-xs btn-primary">详情</a>

View File

@ -67,8 +67,8 @@
<tr class="gradeX">
<td class="text-center" id="username"> {{ post.applyer }} </td>
<td class="text-center" id="dept"> {{ post.dept }} </td>
<td class="text-center" id="ip"> {% for i in post.bisgroup|ast_to_list %} {{ i }} {% endfor %}... </td>
<td class="text-center" id="remote_ip"> {% for i in post.asset|ast_to_list %} {{ i }} {% endfor %}... </td>
<td class="text-center" id="ip"> {{ post.bisgroup|ast_to_list }}</td>
<td class="text-center" id="remote_ip"> {{ post.asset|ast_to_list }} </td>
<td class="text-center" id="start_time"> {{ post.date_add|date:"Y-m-d H:i:s"}} </td>
<td class="text-center" id=""> {{ post.comment }} </td>
<td class="text-center" data-editable='false'>

View File

@ -67,8 +67,8 @@
<td class="text-center"> {{ group.name }} </td>
<td class="text-center"> {{ group.dept.name }} </td>
<td class="text-center"><a href="/juser/user_list/?gid={{ group.id }}">{{ group.id | member_count }} </a> </td>
<td class="text-center"> {{ group.id | ugrp_perm_agrp_count }} </td>
<td class="text-center"> {{ group.id | ugrp_perm_asset_count }} </td>
<td class="text-center"><a href="/jasset/group_list/?sid={{ group.id }}">{{ group.id | ugrp_perm_agrp_count }} </a> </td>
<td class="text-center"><a href="/jasset/host_list/?sid={{ group.id }}"> {{ group.id | ugrp_perm_asset_count }} </a> </td>
<td class="text-center"> {{ group.id | ugrp_perm_asset_count }} </td>
<td class="text-center"> {{ group.comment }} </td>
<td class="text-center">