mirror of https://github.com/jumpserver/jumpserver
修改bug
parent
fb1c17dc51
commit
bbe5b588c0
|
@ -10,7 +10,7 @@ from models import IDC, Asset, BisGroup
|
|||
from juser.models import UserGroup
|
||||
from connect import PyCrypt, KEY
|
||||
from jlog.models import Log
|
||||
from jumpserver.views import jasset_group_add, jasset_host_edit, pages
|
||||
from jumpserver.views import jasset_group_add, jasset_host_edit, pages, page_list_return
|
||||
|
||||
cryptor = PyCrypt(KEY)
|
||||
|
||||
|
@ -65,7 +65,7 @@ def add_host(request):
|
|||
j_comment = request.POST.get('j_comment')
|
||||
|
||||
if Asset.objects.filter(ip=str(j_ip)):
|
||||
emg = u'该IP %s 已存在!' %j_ip
|
||||
emg = u'该IP %s 已存在!' % j_ip
|
||||
return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
if j_type == 'M':
|
||||
|
@ -74,8 +74,7 @@ def add_host(request):
|
|||
f_add_host(j_ip, j_port, j_idc, j_type, j_group, j_active, j_comment, j_user, j_password)
|
||||
else:
|
||||
f_add_host(j_ip, j_port, j_idc, j_type, j_group, j_active, j_comment)
|
||||
|
||||
smg = u'主机 %s 添加成功' %j_ip
|
||||
smg = u'主机 %s 添加成功' % j_ip
|
||||
|
||||
return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
|
@ -97,8 +96,9 @@ def add_host_multi(request):
|
|||
j_group.append(g)
|
||||
|
||||
if Asset.objects.filter(ip=str(j_ip)):
|
||||
emg = u'该IP %s 已存在!' %j_ip
|
||||
return render_to_response('jasset/host_add_multi.html', locals(), context_instance=RequestContext(request))
|
||||
emg = u'该IP %s 已存在!' % j_ip
|
||||
return render_to_response('jasset/host_add_multi.html', locals(),
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
if j_type == 'M':
|
||||
j_user = request.POST.get('j_user')
|
||||
|
@ -117,14 +117,14 @@ def batch_host_edit(request):
|
|||
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_ip = "editable["+str(i)+"][j_ip]"
|
||||
j_port = "editable["+str(i)+"][j_port]"
|
||||
j_idc = "editable["+str(i)+"][j_idc]"
|
||||
j_type = "editable["+str(i)+"][j_type]"
|
||||
j_group = "editable["+str(i)+"][j_group]"
|
||||
j_active = "editable["+str(i)+"][j_active]"
|
||||
j_comment = "editable["+str(i)+"][j_comment]"
|
||||
j_id = "editable[" + str(i) + "][j_id]"
|
||||
j_ip = "editable[" + str(i) + "][j_ip]"
|
||||
j_port = "editable[" + str(i) + "][j_port]"
|
||||
j_idc = "editable[" + str(i) + "][j_idc]"
|
||||
j_type = "editable[" + str(i) + "][j_type]"
|
||||
j_group = "editable[" + str(i) + "][j_group]"
|
||||
j_active = "editable[" + str(i) + "][j_active]"
|
||||
j_comment = "editable[" + str(i) + "][j_comment]"
|
||||
|
||||
j_id = request.POST.get(j_id).strip()
|
||||
j_ip = request.POST.get(j_ip).strip()
|
||||
|
@ -144,14 +144,17 @@ def list_host(request):
|
|||
header_title, path1, path2 = u'查看主机 | List Host', u'资产管理', u'查看主机'
|
||||
login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'}
|
||||
posts = contact_list = Asset.objects.all().order_by('ip')
|
||||
p = paginator = Paginator(contact_list, 20)
|
||||
try:
|
||||
page = int(request.GET.get('page', '1'))
|
||||
except ValueError:
|
||||
page = 1
|
||||
p = paginator = Paginator(contact_list, 10)
|
||||
|
||||
try:
|
||||
contacts = paginator.page(page)
|
||||
current_page = int(request.GET.get('page', '1'))
|
||||
except ValueError:
|
||||
current_page = 1
|
||||
|
||||
page_range = page_list_return(len(p.page_range), current_page)
|
||||
|
||||
try:
|
||||
contacts = paginator.page(current_page)
|
||||
except (EmptyPage, InvalidPage):
|
||||
contacts = paginator.page(paginator.num_pages)
|
||||
|
||||
|
@ -162,7 +165,7 @@ def host_del(request, offset):
|
|||
if offset == 'multi':
|
||||
len_list = request.POST.get("len_list")
|
||||
for i in range(int(len_list)):
|
||||
key = "id_list["+str(i)+"]"
|
||||
key = "id_list[" + str(i) + "]"
|
||||
jid = request.POST.get(key)
|
||||
a = Asset.objects.get(id=jid).ip
|
||||
Asset.objects.filter(id=jid).delete()
|
||||
|
@ -222,7 +225,7 @@ def host_edit(request):
|
|||
a.save()
|
||||
a.bis_group = groups
|
||||
a.save()
|
||||
smg = u'主机 %s 修改成功' %j_ip
|
||||
smg = u'主机 %s 修改成功' % j_ip
|
||||
return HttpResponseRedirect('/jasset/host_list')
|
||||
|
||||
return render_to_response('jasset/host_edit.html', locals(), context_instance=RequestContext(request))
|
||||
|
@ -245,7 +248,7 @@ def add_idc(request):
|
|||
emg = u'该IDC已存在!'
|
||||
return render_to_response('jasset/idc_add.html', locals(), context_instance=RequestContext(request))
|
||||
else:
|
||||
smg = u'IDC:%s添加成功' %j_idc
|
||||
smg = u'IDC:%s添加成功' % j_idc
|
||||
IDC.objects.create(name=j_idc, comment=j_comment)
|
||||
|
||||
return render_to_response('jasset/idc_add.html', locals(), context_instance=RequestContext(request))
|
||||
|
@ -279,7 +282,7 @@ def add_group(request):
|
|||
for host in j_hosts:
|
||||
g = Asset.objects.get(id=host)
|
||||
group.asset_set.add(g)
|
||||
smg = u'主机组%s添加成功' %j_group
|
||||
smg = u'主机组%s添加成功' % j_group
|
||||
|
||||
return render_to_response('jasset/group_add.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
|
@ -307,7 +310,7 @@ def edit_group(request):
|
|||
g = Asset.objects.get(id=host)
|
||||
group.asset_set.add(g)
|
||||
BisGroup.objects.filter(id=group_id).update(name=j_group, comment=j_comment)
|
||||
smg = u'主机组%s修改成功' %j_group
|
||||
smg = u'主机组%s修改成功' % j_group
|
||||
return HttpResponseRedirect('/jasset/group_detail/%s' % group_id)
|
||||
|
||||
return render_to_response('jasset/group_add.html', locals(), context_instance=RequestContext(request))
|
||||
|
@ -363,7 +366,7 @@ def group_del_host(request, offset):
|
|||
group = IDC.objects.get(name=group_name)
|
||||
len_list = request.POST.get("len_list")
|
||||
for i in range(int(len_list)):
|
||||
key = "id_list["+str(i)+"]"
|
||||
key = "id_list[" + str(i) + "]"
|
||||
print key
|
||||
jid = request.POST.get(key)
|
||||
print jid
|
||||
|
@ -371,7 +374,7 @@ def group_del_host(request, offset):
|
|||
print g
|
||||
group.asset_set.remove(g)
|
||||
print 'ok'
|
||||
return HttpResponseRedirect('/jasset/%s_detail/%s' %(offset, group.id))
|
||||
return HttpResponseRedirect('/jasset/%s_detail/%s' % (offset, group.id))
|
||||
|
||||
|
||||
def group_del(request, offset):
|
||||
|
@ -383,7 +386,8 @@ def host_search(request):
|
|||
keyword = request.GET.get('keyword')
|
||||
login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'}
|
||||
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')
|
||||
print posts
|
||||
contact_list, p, contacts = pages(posts, request)
|
||||
print contact_list, p, contacts
|
||||
|
|
|
@ -94,10 +94,8 @@ def jasset_group_add(name, comment, jtype):
|
|||
if BisGroup.objects.filter(name=name):
|
||||
emg = u'该业务组已存在!'
|
||||
else:
|
||||
BisGroup.objects.create(name=name, comment=comment, type=type)
|
||||
smg = u'业务组%s添加成功' % name
|
||||
BisGroup.objects.create(name=name, comment=comment, type=jtype)
|
||||
smg = u'业务组%s添加成功' %name
|
||||
smg = u'业务组%s添加成功' % name
|
||||
|
||||
|
||||
class ServerError(Exception):
|
||||
|
|
|
@ -62,9 +62,9 @@
|
|||
<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 href="/jasset/{{ post.ip }}/" class="iframe btn btn-xs btn-primary">详情</a>
|
||||
<a href="/jasset/host_edit/{{ post.id }}" class="btn btn-xs btn-info">编辑</a>
|
||||
<a href="/jasset/host_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
|
||||
<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>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -109,6 +109,21 @@
|
|||
$('#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) {
|
||||
|
|
|
@ -91,18 +91,30 @@
|
|||
<ul class="pagination" style="margin-top: 0; float: right">
|
||||
|
||||
{% if contacts.has_previous %}
|
||||
<li><a href="?page={{ contacts.previous_page_number }}">«</a></li>
|
||||
<li class="paginate_button previous" aria-controls="editable" tabindex="0" id="editable_previous">
|
||||
<a href="?page={{ contacts.previous_page_number }}">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="paginate_button previous disabled" aria-controls="editable" tabindex="0" id="editable_previous">
|
||||
<a href="#">Previous</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% for page in p.page_range %}
|
||||
{% ifequal offset1 page %}
|
||||
<li class="active"><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
|
||||
{% for page in page_range %}
|
||||
{% ifequal current_page page %}
|
||||
<li class="paginate_button active" aria-controls="editable" tabindex="0"><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
|
||||
{% else %}
|
||||
<li><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
|
||||
<li class="paginate_button" aria-controls="editable" tabindex="0"><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
|
||||
{% endifequal %}
|
||||
{% endfor %}
|
||||
<li class="paginate_button" aria-controls="editable" tabindex="0"><a href="?page={{ p.num_pages }}" title="第{{ page }}页">...{{ p.num_pages }}</a></li>
|
||||
{% if contacts.has_next %}
|
||||
<li><a href="?page={{ contacts.next_page_number }}">»</a></li>
|
||||
<li class="paginate_button next" aria-controls="editable" tabindex="0" id="editable_next">
|
||||
<a href="?page={{ contacts.next_page_number }}">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="paginate_button next disabled" aria-controls="editable" tabindex="0" id="editable_next">
|
||||
<a href="#">Next</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -79,18 +79,29 @@
|
|||
<ul class="pagination" style="margin-top: 0; float: right">
|
||||
|
||||
{% if contacts.has_previous %}
|
||||
<li><a href="?page={{ contacts.previous_page_number }}">«</a></li>
|
||||
<li class="paginate_button previous" aria-controls="editable" tabindex="0" id="editable_previous">
|
||||
<a href="?page={{ contacts.previous_page_number }}">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="paginate_button previous disabled" aria-controls="editable" tabindex="0" id="editable_previous">
|
||||
<a href="#">Previous</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% for page in p.page_range %}
|
||||
{% ifequal offset1 page %}
|
||||
<li class="active"><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
|
||||
{% for page in page_range %}
|
||||
{% ifequal current_page page %}
|
||||
<li class="paginate_button active" aria-controls="editable" tabindex="0"><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
|
||||
{% else %}
|
||||
<li><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
|
||||
<li class="paginate_button" aria-controls="editable" tabindex="0"><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
|
||||
{% endifequal %}
|
||||
{% endfor %}
|
||||
{% if contacts.has_next %}
|
||||
<li><a href="?page={{ contacts.next_page_number }}">»</a></li>
|
||||
<li class="paginate_button next" aria-controls="editable" tabindex="0" id="editable_next">
|
||||
<a href="?page={{ contacts.next_page_number }}">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="paginate_button next disabled" aria-controls="editable" tabindex="0" id="editable_next">
|
||||
<a href="#">Next</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<td class="text-center"> <a href="/jasset/idc_detail/?id={{ post.id }}">{{ post.asset_set.count }}</a> </td>
|
||||
<td class="text-center"> {{ post.comment }} </td>
|
||||
<td class="text-center">
|
||||
<a href="/jasset/?id={{ post.id }}" class="iframe btn btn-xs btn-primary">详情</a>
|
||||
<a href="/jasset/idc_detail/?id={{ post.id }}" class="iframe btn btn-xs btn-primary">详情</a>
|
||||
<a href="/jasset/idc_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -78,7 +78,6 @@
|
|||
<th class="text-center"> 实时监控 </th>
|
||||
<th class="text-center"> 阻断 </th>
|
||||
<th class="text-center"> 登录时间 </th>
|
||||
<th class="text-center"> 结束时间 </th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -90,7 +89,6 @@
|
|||
<td class="text-center"><a class="monitor" filename="{{ post.log_path }}"> 监控 </a></td>
|
||||
<td class="text-center"><input type="button" id="cut" class="btn btn-danger btn-xs" name="cut" value="阻断" onclick='cut("{{ post.pid }}")' /></td>
|
||||
<td class="text-center"> {{ post.start_time|date:"Y-m-d H:i:s" }} </td>
|
||||
<td class="text-center"> {{ post.end_time|date:"Y-m-d H:i:s" }} </td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
Loading…
Reference in New Issue