From db86daf86de04bbb71b774f623a69764e81f43ec Mon Sep 17 00:00:00 2001 From: halcyon <864072399@qq.com> Date: Wed, 11 Feb 2015 17:53:17 +0800 Subject: [PATCH] =?UTF-8?q?dashboard=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jasset/urls.py | 6 +-- jasset/views.py | 12 +++-- jumpserver/urls.py | 2 +- jumpserver/views.py | 10 +++- templates/foot_script.html | 13 ++--- templates/head_script.html | 2 - templates/index.html | 65 ++++++++++++++++++++++++ templates/jasset/group_detail.html | 1 - templates/jasset/group_list.html | 6 +-- templates/jasset/host_list.html | 4 +- templates/jasset/host_search.html | 81 +++++++++++++++++++++++++++++- templates/jasset/idc_detail.html | 3 +- templates/jasset/idc_list.html | 4 +- templates/jasset/jlist_ip.html | 77 +++++++++++++++++++--------- templates/nav.html | 2 +- 15 files changed, 231 insertions(+), 57 deletions(-) create mode 100644 templates/index.html diff --git a/jasset/urls.py b/jasset/urls.py index c7f0ea0a5..f6c2d9701 100644 --- a/jasset/urls.py +++ b/jasset/urls.py @@ -11,16 +11,16 @@ urlpatterns = patterns('', url(r"^(\d+.\d+.\d+.\d+)/$", jlist_ip), url(r'^idc_add/$', add_idc), url(r'^idc_list/$', list_idc), - url(r'^idc_detail/(\d+)$', detail_idc), + url(r'^idc_detail/$', detail_idc), url(r'^idc_del/(\d+)/$', del_idc), url(r'^group_add/$', add_group), url(r'^group_edit/$', edit_group), url(r'^group_list/$', list_group), - url(r'^group_detail/(\d+)/$', detail_group), + url(r'^group_detail/$', detail_group), url(r'^group_del_host/(\w+)/$', group_del_host), url(r'^group_del/(\d+)/$', group_del), url(r'^host_del/(\w+)/$', host_del), - url(r'^host_edit/(\d+)$', host_edit), + url(r'^host_edit/$', host_edit), url(r'^host_edit/batch/$', batch_host_edit), url(r'^test/$', test), ) \ No newline at end of file diff --git a/jasset/views.py b/jasset/views.py index 5af761d86..bfd45fdee 100644 --- a/jasset/views.py +++ b/jasset/views.py @@ -9,6 +9,7 @@ from django.core.paginator import Paginator, EmptyPage, InvalidPage 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 cryptor = PyCrypt(KEY) @@ -174,13 +175,14 @@ def host_del(request, offset): return HttpResponseRedirect('/jasset/host_list/') -def host_edit(request, offset): +def host_edit(request): actives = {1: u'激活', 0: u'禁用'} login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} header_title, path1, path2 = u'修改主机 | Edit Host', u'资产管理', u'修改主机' groups, e_group = [], [] eidc = IDC.objects.all() egroup = BisGroup.objects.filter(type='A') + offset = request.GET.get('id') for g in Asset.objects.get(id=int(offset)).bis_group.all(): e_group.append(g) post = Asset.objects.get(id=int(offset)) @@ -228,7 +230,9 @@ def host_edit(request, offset): def jlist_ip(request, offset): header_title, path1, path2 = u'主机详细信息 | Host Detail.', u'资产管理', u'主机详情' + login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} post = contact_list = Asset.objects.get(ip=str(offset)) + log = Log.objects.filter(host=str(offset)) return render_to_response('jasset/jlist_ip.html', locals(), context_instance=RequestContext(request)) @@ -309,9 +313,10 @@ def edit_group(request): return render_to_response('jasset/group_add.html', locals(), context_instance=RequestContext(request)) -def detail_group(request, offset): +def detail_group(request): header_title, path1, path2 = u'主机组详情 | Group Detail', u'资产管理', u'主机组详情' login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} + offset = request.GET.get('id') 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') @@ -328,9 +333,10 @@ def detail_group(request, offset): return render_to_response('jasset/group_detail.html', locals(), context_instance=RequestContext(request)) -def detail_idc(request, offset): +def detail_idc(request): header_title, path1, path2 = u'主机组详情 | Group Detail', u'资产管理', u'主机组详情' login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} + offset = request.GET.get('id') 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') diff --git a/jumpserver/urls.py b/jumpserver/urls.py index dff10261d..710e289b7 100644 --- a/jumpserver/urls.py +++ b/jumpserver/urls.py @@ -5,7 +5,7 @@ urlpatterns = patterns('', # Examples: # url(r'^$', 'jumpserver.views.home', name='home'), # url(r'^blog/', include('blog.urls')), - (r'^$', 'jumpserver.views.base'), + (r'^$', 'jumpserver.views.index'), (r'^skin_config/$', 'jumpserver.views.skin_config'), (r'^base/$', 'jumpserver.views.base'), (r'^login/$', 'jumpserver.views.login'), diff --git a/jumpserver/views.py b/jumpserver/views.py index ce9a9dba6..7ea11914d 100644 --- a/jumpserver/views.py +++ b/jumpserver/views.py @@ -7,6 +7,7 @@ from django.http import HttpResponseRedirect from django.core.paginator import Paginator, EmptyPage, InvalidPage from juser.models import User +from jlog.models import Log from jasset.models import Asset, BisGroup, IDC @@ -14,8 +15,13 @@ def md5_crypt(string): return hashlib.new("md5", string).hexdigest() -def base(request): - return render_to_response('base.html') +def index(request): + path1, path2 = u'仪表盘', 'Dashboard' + users = User.objects.all() + hosts = Asset.objects.all() + online_host = Log.objects.filter(is_finished=0) + online_user = online_host.distinct() + return render_to_response('index.html', locals()) def skin_config(request): diff --git a/templates/foot_script.html b/templates/foot_script.html index 2105670f2..0db994243 100644 --- a/templates/foot_script.html +++ b/templates/foot_script.html @@ -8,8 +8,6 @@ - - @@ -19,17 +17,14 @@ + - - - - - - \ No newline at end of file diff --git a/templates/head_script.html b/templates/head_script.html index 8c8f7119b..5c316f882 100644 --- a/templates/head_script.html +++ b/templates/head_script.html @@ -5,5 +5,3 @@ - - diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 000000000..30fd56ea7 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,65 @@ +{% extends 'base.html' %} +{% block content %} +{% include 'nav_cat_bar.html' %} + +
+
+
+
+
+ Monthly +
用户总数
+
+
+

{{ users.count}}

+
98%
+ All user +
+
+
+
+
+
+ Annual +
主机总数
+
+
+

{{ hosts.count }}

+
20%
+ All host +
+
+
+ +
+
+
+ Today +
在线用户
+
+
+

{{ online_user.count }}

+
44%
+ Online user +
+
+
+ +
+
+
+ Low value +
已连接服务器
+
+
+

{{ online_host.count }}

+
38%
+ Connect host +
+
+
+
+
+ + +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/group_detail.html b/templates/jasset/group_detail.html index 76ca1e6af..f5a3c1e85 100644 --- a/templates/jasset/group_detail.html +++ b/templates/jasset/group_detail.html @@ -106,7 +106,6 @@ diff --git a/templates/jasset/idc_detail.html b/templates/jasset/idc_detail.html index 446c25d6f..05a44ede5 100644 --- a/templates/jasset/idc_detail.html +++ b/templates/jasset/idc_detail.html @@ -62,7 +62,7 @@ {{ post.date_added|date:"Y-m-d H:i:s" }} {{ post.comment }} - 详情 + 详情 删除 @@ -105,7 +105,6 @@ - - - + {% include 'link_css.html' %} + {% include 'head_script.html' %}