diff --git a/jasset/urls.py b/jasset/urls.py index 3b8fd120d..a859e209a 100644 --- a/jasset/urls.py +++ b/jasset/urls.py @@ -5,15 +5,18 @@ from jasset.views import * urlpatterns = patterns('', url(r'^$', index), url(r'^host_add/$', jadd_host), + url(r'^host_add_multi/$', jadd_host_multi), url(r'^host_list/$', jlist_host), url(r"^(\d+.\d+.\d+.\d+)/$",jlist_ip), url(r'^idc_add/$', jadd_idc), url(r'^idc_list/$', jlist_idc), + url(r'^idc_detail/(\d+)$', idc_detail), url(r'^idc_del/(\d+)/$', idc_del), url(r'^group_add/$', jadd_group), url(r'^group_list/$', jlist_group), + url(r'^group_detail/(\d)/$', group_detail), url(r'^group_del/(\d+)/$', group_del), - url(r'^host_del/(\d+)/$', host_del), + url(r'^host_del/(\w+)/$', host_del), url(r'^host_edit/(\d+)$', host_edit), url(r'^host_edit/batch/$', batch_host_edit), url(r'^test/$', test), diff --git a/jasset/views.py b/jasset/views.py index f50f1e583..81a0c7dd3 100644 --- a/jasset/views.py +++ b/jasset/views.py @@ -8,7 +8,6 @@ from models import IDC, Asset, BisGroup from juser.models import UserGroup from connect import PyCrypt, KEY from jumpserver.views import jasset_group_add, jasset_host_edit -from jperm.models import Perm cryptor = PyCrypt(KEY) @@ -35,27 +34,25 @@ def jadd_host(request): j_comment = request.POST.get('j_comment') j_idc = IDC.objects.get(name=j_idc) + all_group = BisGroup.objects.get(name='ALL') for group in j_group: c = BisGroup.objects.get(name=group) groups.append(c) + groups.append(all_group) if Asset.objects.filter(ip=str(j_ip)): - emg = u'该IP已存在!' + emg = u'该IP %s 已存在!' %j_ip return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request)) if j_type == 'M': j_user = request.POST.get('j_user') j_password = cryptor.encrypt(request.POST.get('j_password')) - j_root = request.POST.get('j_root') - j_passwd = cryptor.encrypt(request.POST.get('j_passwd')) a = Asset(ip=j_ip, port=j_port, login_type=j_type, idc=j_idc, is_active=int(j_active), comment=j_comment, username_common=j_user, - password_common=j_password, - username_super=j_root, - password_super=j_passwd,) + password_common=j_password) else: a = Asset(ip=j_ip, port=j_port, login_type=j_type, idc=j_idc, @@ -66,13 +63,63 @@ def jadd_host(request): a.bis_group = groups a.save() smg = u'主机 %s 添加成功' %j_ip + return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request)) + +def jadd_host_multi(request): + header_title, path1, path2 = u'批量添加主机 | Add Hosts', u'资产管理', u'批量添加主机' + login_types = {'LDAP': 'L', 'SSH_KEY': 'S', 'PASSWORD': 'P', 'MAP': 'M'} + if request.method == 'POST': + multi_hosts = request.POST.get('j_multi').split('\n') + for host in multi_hosts: + if host == '': + break + groups = [] + j_ip, j_port, j_type, j_idc, j_group, j_user_group, j_active, j_comment = host.split() + j_idc = IDC.objects.get(name=j_idc) + j_type = login_types[j_type] + all_group = BisGroup.objects.get(name='ALL') + j_group = j_group.split(',') + for group in j_group: + g = group.strip('[]') + print g + c = BisGroup.objects.get(name=g) + groups.append(c) + groups.append(all_group) + + 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)) + + if j_type == 'M': + j_user = request.POST.get('j_user') + j_password = cryptor.encrypt(request.POST.get('j_password')) + a = Asset(ip=j_ip, port=j_port, + login_type=j_type, idc=j_idc, + is_active=int(j_active), + comment=j_comment, + username_common=j_user, + password_common=j_password) + else: + a = Asset(ip=j_ip, port=j_port, + login_type=j_type, idc=j_idc, + is_active=int(j_active), + comment=j_comment) + jasset_group_add(j_ip, j_ip, 'P') + a.save() + a.bis_group = groups + a.save() + smg = u'批量添加添加成功' + return HttpResponseRedirect('/jasset/host_list/') + return render_to_response('jasset/host_add_multi.html', locals(), context_instance=RequestContext(request)) + + def batch_host_edit(request): if request.method == 'POST': len_table = request.POST.get('len_table') - print 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]" @@ -81,6 +128,7 @@ def batch_host_edit(request): 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() j_port = request.POST.get(j_port).strip() j_idc = request.POST.get(j_idc).strip() @@ -90,7 +138,7 @@ def batch_host_edit(request): j_comment = request.POST.get(j_comment).strip() print j_ip - jasset_host_edit(j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment) + jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment) return render_to_response('jasset/host_list.html') @@ -100,7 +148,7 @@ def jlist_host(request): login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} posts = contact_list = Asset.objects.all().order_by('ip') print posts - p = paginator = Paginator(contact_list, 5) + p = paginator = Paginator(contact_list, 20) try: page = int(request.GET.get('page', '1')) except ValueError: @@ -113,16 +161,23 @@ def jlist_host(request): return render_to_response('jasset/host_list.html', locals(), context_instance=RequestContext(request)) + def host_del(request, offset): - len_list = request.POST.get("len_list") - for i in range(int(len_list)): - key = "id_list["+str(i)+"]" - print key - jid = request.POST.get(key) - print jid + print offset + if offset == 'multi': + len_list = request.POST.get("len_list") + for i in range(int(len_list)): + key = "id_list["+str(i)+"]" + print key + jid = request.POST.get(key) + print jid + Asset.objects.filter(id=jid).delete() + else: + jid = int(offset) Asset.objects.filter(id=jid).delete() return HttpResponseRedirect('/jasset/host_list/') + def host_edit(request, offset): actives = {1: u'激活', 0: u'禁用'} login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} @@ -132,7 +187,7 @@ def host_edit(request, offset): egroup = BisGroup.objects.filter(type='A') for g in Asset.objects.get(id=int(offset)).bis_group.all(): e_group.append(g) - post = Asset.objects.get(id = int(offset)) + post = Asset.objects.get(id=int(offset)) if request.method == 'POST': j_ip = request.POST.get('j_ip') j_idc = request.POST.get('j_idc') @@ -142,27 +197,24 @@ def host_edit(request, offset): j_active = request.POST.get('j_active') j_comment = request.POST.get('j_comment') j_idc = IDC.objects.get(name=j_idc) + print j_group for group in j_group: c = BisGroup.objects.get(name=group) groups.append(c) - a = Asset.objects.get(ip=int(offset)) + a = Asset.objects.get(id=int(offset)) if j_type == 'M': j_user = request.POST.get('j_user') j_password = cryptor.encrypt(request.POST.get('j_password')) - j_root = request.POST.get('j_root') - j_passwd = cryptor.encrypt(request.POST.get('j_passwd')) a.ip = j_ip a.port = j_port a.login_type = j_type a.idc = j_idc a.is_active = j_active a.comment = j_comment - a.username_common = j_user - a.password_common = j_password - a.username_super = j_root - a.password_super = j_passwd + a.username = j_user + a.password = j_password else: a.ip = j_ip a.port = j_port @@ -183,9 +235,10 @@ def host_edit(request, offset): def jlist_ip(request, offset): header_title, path1, path2 = u'主机详细信息 | Host Detail.', u'资产管理', u'主机详情' print offset - post = contact_list = Asset.objects.get(ip = str(offset)) + post = contact_list = Asset.objects.get(ip=str(offset)) return render_to_response('jasset/jlist_ip.html', locals(), context_instance=RequestContext(request)) + def jadd_idc(request): header_title, path1, path2 = u'添加IDC | Add IDC', u'资产管理', u'添加IDC' if request.method == 'POST': @@ -204,14 +257,16 @@ def jadd_idc(request): def jlist_idc(request): - header_title, path1, path2 = u'查看IDC | List Host', u'资产管理', u'查看IDC' + header_title, path1, path2 = u'查看IDC | List IDC', u'资产管理', u'查看IDC' posts = IDC.objects.all().order_by('id') return render_to_response('jasset/idc_list.html', locals(), context_instance=RequestContext(request)) + def idc_del(request, offset): IDC.objects.filter(id=offset).delete() return HttpResponseRedirect('/jasset/idc_list/') + def jadd_group(request): header_title, path1, path2 = u'添加主机组 | Add Group', u'资产管理', u'添加主机组' if request.method == 'POST': @@ -229,13 +284,53 @@ def jadd_group(request): def jlist_group(request): - header_title, path1, path2 = u'查看业务组 | Add Group', u'资产管理', u'查看业务组' + header_title, path1, path2 = u'查看主机组 | List Group', u'资产管理', u'查看主机组' posts = BisGroup.objects.filter(type='A').order_by('id') return render_to_response('jasset/group_list.html', locals(), context_instance=RequestContext(request)) + +def group_detail(request, offset): + header_title, path1, path2 = u'主机组详情 | Group Detail', u'资产管理', u'主机组详情' + login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} + group_name = BisGroup.objects.get(id=offset).name + b = BisGroup.objects.get(id=offset) + posts = contact_list = Asset.objects.filter(bis_group=b).order_by('ip') + p = paginator = Paginator(contact_list, 5) + try: + page = int(request.GET.get('page', '1')) + except ValueError: + page = 1 + + try: + contacts = paginator.page(page) + except (EmptyPage, InvalidPage): + contacts = paginator.page(paginator.num_pages) + return render_to_response('jasset/group_detail.html', locals(), context_instance=RequestContext(request)) + + +def idc_detail(request, offset): + header_title, path1, path2 = u'主机组详情 | Group Detail', u'资产管理', u'主机组详情' + login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} + idc_name = IDC.objects.get(id=offset).name + b = IDC.objects.get(id=offset) + posts = contact_list = Asset.objects.filter(idc=b).order_by('ip') + p = paginator = Paginator(contact_list, 5) + try: + page = int(request.GET.get('page', '1')) + except ValueError: + page = 1 + + try: + contacts = paginator.page(page) + except (EmptyPage, InvalidPage): + contacts = paginator.page(paginator.num_pages) + return render_to_response('jasset/idc_detail.html', locals(), context_instance=RequestContext(request)) + + def group_del(request, offset): BisGroup.objects.filter(id=offset).delete() return HttpResponseRedirect('/jasset/group_list/') + def test(request): return render_to_response('jasset/test.html', locals()) diff --git a/jlog/urls.py b/jlog/urls.py index 75f4111fe..55a17bd7b 100644 --- a/jlog/urls.py +++ b/jlog/urls.py @@ -4,6 +4,6 @@ from jlog.views import * urlpatterns = patterns('', url(r'^$', jlog_list), - url(r'^log_list/$', jlog_list), + url(r'^log_list/(\w+)/$', jlog_list), url(r'^log_kill/(\d+)', jlog_kill), ) diff --git a/jlog/views.py b/jlog/views.py index 6ce5714b5..af4758224 100644 --- a/jlog/views.py +++ b/jlog/views.py @@ -13,12 +13,14 @@ from jlog.models import Log CONF = ConfigParser.ConfigParser() CONF.read('%s/jumpserver.conf' % BASE_DIR) -def jlog_list(request): + +def jlog_list(request, offset='online'): header_title, path1, path2 = u'查看日志 | Log List.', u'查看日志', u'日志列表' + web_socket_host = CONF.get('websocket', 'web_socket_host') online = Log.objects.filter(is_finished=0) offline = Log.objects.filter(is_finished=1) - web_socket_host = CONF.get('websocket', 'web_socket_host') - return render_to_response('jlog/log_list.html',locals()) + + return render_to_response('jlog/log_list.html', locals()) def jlog_kill(request, offset): @@ -26,4 +28,4 @@ def jlog_kill(request, offset): if pid: os.kill(int(pid), 9) Log.objects.filter(pid=pid).update(is_finished=1, end_time=datetime.now()) - return render_to_response('jlog/log_list.html', locals()) \ No newline at end of file + return HttpResponseRedirect('jlog/log_list.html', locals()) \ No newline at end of file diff --git a/jumpserver/templatetags/mytags.py b/jumpserver/templatetags/mytags.py index 43bfca702..20ba40fd4 100644 --- a/jumpserver/templatetags/mytags.py +++ b/jumpserver/templatetags/mytags.py @@ -5,6 +5,7 @@ from django import template from django.db.models import Q from juser.models import User, UserGroup from jperm.views import perm_user_asset +from jasset.models import BisGroup register = template.Library() @@ -85,6 +86,15 @@ def group_type_to_str(type_name): } return group_types.get(type_name) + @register.filter(name='perm_asset_count') def perm_asset_count(user_id): return len(perm_user_asset(user_id)) + + +@register.filter(name='filter_private') +def filter_private(group): + agroup = [] + p = BisGroup.objects.get(name='ALL') + [agroup.append(g) for g in group if g != p] + return agroup diff --git a/jumpserver/views.py b/jumpserver/views.py index b19e73644..44e5d1f5d 100644 --- a/jumpserver/views.py +++ b/jumpserver/views.py @@ -30,17 +30,23 @@ def jasset_group_add(name, comment, type): BisGroup.objects.create(name=name, comment=comment, type=type) smg = u'业务组%s添加成功' %name -def jasset_host_edit(j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment): + +def jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment): + print 'ok' groups = [] is_active = {u'是': '1', u'否': '2'} login_types = {'LDAP': 'L', 'SSH_KEY': 'S', 'PASSWORD': 'P', 'MAP': 'M'} - for group in j_group: + for group in j_group[0].split(): + print group.strip() c = BisGroup.objects.get(name=group.strip()) groups.append(c) j_type = login_types[j_type] + print j_type j_idc = IDC.objects.get(name=j_idc) - a = Asset.objects.get(ip=str(j_ip)) - + print j_idc + print + a = Asset.objects.get(id=j_id) + print '123' if j_type == 'M': a.ip = j_ip a.port = j_port @@ -48,10 +54,8 @@ def jasset_host_edit(j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment): a.idc = j_idc a.is_active = j_active a.comment = j_comment - a.username_common = j_user - a.password_common = j_password - a.username_super = j_root - a.password_super = j_passwd + a.username = j_user + a.password = j_password else: a.ip = j_ip a.port = j_port @@ -59,7 +63,6 @@ def jasset_host_edit(j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment): a.login_type = j_type a.is_active = is_active[j_active] a.comment = j_comment - a.save() a.bis_group = groups a.save() diff --git a/templates/head_script.html b/templates/head_script.html index 4e4716ded..a2d50f12e 100644 --- a/templates/head_script.html +++ b/templates/head_script.html @@ -1,48 +1,54 @@ + + + + + + + + - - - - + - + + + diff --git a/templates/jasset/group_detail.html b/templates/jasset/group_detail.html new file mode 100644 index 000000000..650404d06 --- /dev/null +++ b/templates/jasset/group_detail.html @@ -0,0 +1,151 @@ +{% extends 'base.html' %} +{% load mytags %} +{% block content %} +{% include 'nav_cat_bar.html' %} + +
+
+
+
+
+
主机组{{ group_name }}详细信息列表
+ +
+ +
+ + +
+ + + + + + + + + + + + + + + + + {% for post in contacts.object_list %} + + + + + + + + + + + + + {% endfor %} + +
IP地址 端口号 登录方式 所属IDC 所属业务组 是否激活 添加时间 备注 操作
{{ post.ip }} {{ post.port }} {{ login_types|get_item:post.login_type }} {{ post.idc.name }} {% for group in post.bis_group.all %} {{ group }} {% endfor %} {{ post.is_active|bool2str }} {{ post.date_added|date:"Y-m-d H:i:s" }} {{ post.comment }} + 详情 + 编辑 + 删除 +
+
+
+ + +
+
+
+
    + + {% if contacts.has_previous %} +
  • «
  • + {% endif %} + + {% for page in p.page_range %} + {% ifequal offset1 page %} +
  • {{ page }}
  • + {% else %} +
  • {{ page }}
  • + {% endifequal %} + {% endfor %} + {% if contacts.has_next %} +
  • »
  • + {% endif %} +
+
+
+
+
+
+
+
+
+
+ + + +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/group_list.html b/templates/jasset/group_list.html index bd57a5abf..69ceff7e3 100644 --- a/templates/jasset/group_list.html +++ b/templates/jasset/group_list.html @@ -22,6 +22,7 @@ ID 主机组名 + 主机数量 备注 操作 @@ -31,10 +32,10 @@ {{ post.id }} {{ post.name }} + {{ post.asset_set.count }} {{ post.comment }} - 详情 - 编辑 + 详情 删除 diff --git a/templates/jasset/host_add.html b/templates/jasset/host_add.html index 4483ac57c..ab28db1e3 100644 --- a/templates/jasset/host_add.html +++ b/templates/jasset/host_add.html @@ -4,13 +4,7 @@
-
- 请选择添加内容: - 添加主机 - 添加IDC - 添加业务组 -
-
+
填写主机基本信息
@@ -33,107 +27,112 @@
- {% if emg %} -
{{ emg }}
- {% endif %} - {% if smg %} -
{{ smg }}
- {% endif %} -
-
-
+
+ +
+
+
+ {% if emg %} +
{{ emg }}
+ {% endif %} + {% if smg %} +
{{ smg }}
+ {% endif %} + +
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
- - -
-
-
-
- -
-
-
-
- -
-
-
-
-
- -
-
- -
- -
-
- -
-
- -
- {% for g in egroup %} - - {% endfor %} -
-
- -
-
- -
- {% for g in eusergroup %} - - {% endfor %} -
-
- -
-
-
-
-
-
-
- -
-
-
-
- -
-
-
- - -
-
- +
@@ -151,17 +150,6 @@ document.getElementById("a1").style.display="none"; }}; - function change(type){ - if (type == 'addhost') { - var data = $('#add_asset'); - } else if (type == 'addidc') { - var data = $('#addidc'); - } else { - var data = $('addgroup'); - } - $("#add_asset").html(data); - } - $('#assetForm').validator({ timely: 2, theme: "yellow_right_effect", diff --git a/templates/jasset/host_add_multi.html b/templates/jasset/host_add_multi.html new file mode 100644 index 000000000..df8884108 --- /dev/null +++ b/templates/jasset/host_add_multi.html @@ -0,0 +1,67 @@ +{% extends 'base.html' %} +{% block content %} +{% include 'nav_cat_bar.html' %} +
+
+
+
+
+
填写主机基本信息
+ +
+ +
+
+ +
+
+ {% if emg %} +
{{ emg }}
+ {% endif %} + {% if smg %} +
{{ smg }}
+ {% endif %} +

按照文本框内主机信息格式填写, 多台主机回车换行

+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+ + +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/host_edit.html b/templates/jasset/host_edit.html index f197efa53..00e8483f5 100644 --- a/templates/jasset/host_edit.html +++ b/templates/jasset/host_edit.html @@ -35,17 +35,17 @@
{{ smg }}
{% endif %}
-
+
-
+
-
+
{% for t, type in login_types.items %} {% ifequal t post.login_type %} @@ -61,27 +61,15 @@
-
- -
-
-
-
- -
-
-
-
-
- +
{{ g }} - {% else %} - - {% endif %} - {% endfor %} +
-
+
{% for a,active in actives.items %} {% ifequal a post.is_active %} diff --git a/templates/jasset/host_list.html b/templates/jasset/host_list.html index 5d485a623..4b333fdfb 100644 --- a/templates/jasset/host_list.html +++ b/templates/jasset/host_list.html @@ -52,12 +52,12 @@ {% for post in contacts.object_list %} - + {{ post.ip }} {{ post.port }} {{ login_types|get_item:post.login_type }} {{ post.idc.name }} - {% for group in post.bis_group.all %} {{ group }} {% endfor %} + {% for group in post.bis_group.all|filter_private %} {{ group }} {% endfor %} {{ post.is_active|bool2str }} {{ post.date_added|date:"Y-m-d H:i:s" }} {{ post.comment }} @@ -112,40 +112,40 @@ function alter(form) { selectData = GetTableDataBox(); - if (selectData[1] != 0){ + 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/", - data: {"id_list": id_list, "len_list": j}, + 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"); + } + }); + } + } {% endblock %} \ No newline at end of file diff --git a/templates/jasset/idc_detail.html b/templates/jasset/idc_detail.html new file mode 100644 index 000000000..c76f40b54 --- /dev/null +++ b/templates/jasset/idc_detail.html @@ -0,0 +1,150 @@ +{% extends 'base.html' %} +{% load mytags %} +{% block content %} +{% include 'nav_cat_bar.html' %} + +
+
+
+
+
+
IDC {{ idc_name }} 详细信息列表
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + {% for post in contacts.object_list %} + + + + + + + + + + + + + {% endfor %} + +
IP地址 端口号 登录方式 所属IDC 所属业务组 是否激活 添加时间 备注 操作
{{ post.ip }} {{ post.port }} {{ login_types|get_item:post.login_type }} {{ post.idc.name }} {% for group in post.bis_group.all %} {{ group }} {% endfor %} {{ post.is_active|bool2str }} {{ post.date_added|date:"Y-m-d H:i:s" }} {{ post.comment }} + 详情 + 删除 +
+
+
+ + +
+
+
+
    + + {% if contacts.has_previous %} +
  • «
  • + {% endif %} + + {% for page in p.page_range %} + {% ifequal offset1 page %} +
  • {{ page }}
  • + {% else %} +
  • {{ page }}
  • + {% endifequal %} + {% endfor %} + {% if contacts.has_next %} +
  • »
  • + {% endif %} +
+
+
+
+ +
+
+
+
+
+ + + +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/idc_list.html b/templates/jasset/idc_list.html index a8693ea2f..81912f6ac 100644 --- a/templates/jasset/idc_list.html +++ b/templates/jasset/idc_list.html @@ -22,6 +22,7 @@ ID 机房名 + 主机数量 备注 操作 @@ -31,10 +32,10 @@ {{ post.id }} {{ post.name }} + {{ post.asset_set.count }} {{ post.comment }} - 详情 - 编辑 + 详情 删除 diff --git a/templates/jlog/log_list.html b/templates/jlog/log_list.html index c015ee6bd..cd9b98720 100644 --- a/templates/jlog/log_list.html +++ b/templates/jlog/log_list.html @@ -2,83 +2,115 @@ {% block content %} {% include 'nav_cat_bar.html' %}
-
-

用户日志详细信息列表

- -
-
-
-
-
- - - - - - - - - - - - - - {% for post in online %} - - - - - - - - - {% endfor %} - -
用户名 登录主机 实时监控 阻断 登录时间 结束时间
{{ post.user.name }} {{ post.asset.ip }} 监控 阻断 {{ post.start_time|date:"Y-m-d H:i:s" }} {{ post.end_time|date:"Y-m-d H:i:s" }}
-
+
+
+
用户日志详细信息列表
+ -
-
- - - - - - - - + - - - - {% for post in offline %} - - - - - - - - {% endfor %} - -
用户名 登录主机 命令统计 登录时间 结束时间
{{ post.user.name }} {{ post.asset.ip }} 命令统计 {{ post.start_time|date:"Y-m-d H:i:s"}} {{ post.end_time|date:"Y-m-d H:i:s" }}
+
+
+ +
+
+
+ + + + + + + + + + + + + + {% for post in online %} + + + + + + + + + {% endfor %} + +
用户名 登录主机 实时监控 阻断 登录时间 结束时间
{{ post.user.name }} {{ post.asset.ip }} 监控 {{ post.start_time|date:"Y-m-d H:i:s" }} {{ post.end_time|date:"Y-m-d H:i:s" }}
+
+
+ + + + + + + + + + + + + {% for post in offline %} + + + + + + + + {% endfor %} + +
用户名 登录主机 命令统计 登录时间 结束时间
{{ post.user.name }} {{ post.asset.ip }} 命令统计 {{ post.start_time|date:"Y-m-d H:i:s"}} {{ post.end_time|date:"Y-m-d H:i:s" }}
+
+
@@ -103,6 +135,8 @@ var node = $(e.target); message.id = genUid(); message.filename = node.attr('filename'); + var username = $('#username')[0].innerText; + var ip = $('#ip')[0].innerText; BootstrapDialog.show({message:function(){ var escapeString = function (html){ var elem = document.createElement('div') @@ -110,7 +144,7 @@ elem.appendChild(txt) return elem.innerHTML; } - var tag = $('
'); + var tag = $('
'); //告诉服务器端有用户登录 socket.emit('login', {userid:message.id, filename:message.filename}); socket.on('message',function(obj){ @@ -123,7 +157,7 @@ tag[0].style.color = "#00FF00"; return tag[0]; } , - title:'Jumpserver实时监控:', + title:'Jumpserver实时监控 '+' 登录用户名: '+''+username+''+' 登录主机: '+''+ip, onhide:function(){ socket.emit('disconnect'); }}); @@ -144,5 +178,25 @@ SOCKET_HOST: "{{ web_socket_host }}" } $(".monitor").webSocket() + +// function log_fresh(str){ +// $.ajax({ +// type: "GET", +// url: "/jlog/log_list/", +// data : $(".panel-body").serialize(), +// success: function(data){ +// $("#tab-1").html(data); +// } +// }); + + function cut(num){ + var g_url = "/jlog/log_kill/"+num; + console.log(g_url); + $.ajax({ + type: "GET", + url: g_url, + success: window.open("/jlog/","_self") + }); +} {% endblock %} \ No newline at end of file diff --git a/templates/nav.html b/templates/nav.html index bf2440b35..f4c069580 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -39,7 +39,7 @@
  • 日志审计