diff --git a/jumpserver.conf b/jumpserver.conf
index 743f0db43..0c2df628a 100644
--- a/jumpserver.conf
+++ b/jumpserver.conf
@@ -8,11 +8,11 @@ password = mysql234
database = jumpserver
[ldap]
-ldap_enable = 1
-host_url = ldap://127.0.0.1:389
-base_dn = dc=jumpserver,dc=org
-root_dn = cn=admin,dc=jumpserver,dc=org
-root_pw = secret234
+ldap_enable = 0
+host_url = ldap://192.168.8.60:389
+base_dn = dc=fengxing, dc=com
+root_dn = cn=admin,dc=fengxing,dc=com
+root_pw = 123456
[websocket]
web_socket_host = 127.0.0.1:3000
diff --git a/jumpserver/views.py b/jumpserver/views.py
index 61b7cdb65..5bdf91dc6 100644
--- a/jumpserver/views.py
+++ b/jumpserver/views.py
@@ -1,7 +1,10 @@
#coding: utf-8
import hashlib
+import datetime
+from django.db.models import Q
+from django.db.models import Count
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.core.paginator import Paginator, EmptyPage, InvalidPage
@@ -15,11 +18,34 @@ def md5_crypt(string):
return hashlib.new("md5", string).hexdigest()
+def getDaysByNum(num):
+ today = datetime.date.today()
+ oneday = datetime.timedelta(days=1)
+ li = []
+ for i in range(0, num):
+ today = today-oneday
+ li.append(str(today)[0:10])
+ li.reverse()
+ return li
+
+
def index(request):
path1, path2 = u'仪表盘', 'Dashboard'
+ dic = {}
+ today = datetime.datetime.now().day
+ from_week = datetime.datetime.now() - datetime.timedelta(days=7)
+ week_data = Log.objects.filter(start_time__range=[from_week, datetime.datetime.now()])
+ top_ten = week_data.values('user').annotate(times=Count('user')).order_by('-times')[:10]
+ for user in top_ten:
+ username = user['user']
+ li = []
+ for t in getDaysByNum(7):
+ times = week_data.filter(user=user).filter(start_time__gt=t).count()
+ li.append(times)
+ dic[username] = li
+ print dic
users = User.objects.all()
hosts = Asset.objects.all()
- user = 'wangyong'
online_host = Log.objects.filter(is_finished=0)
online_user = online_host.distinct()
return render_to_response('index.html', locals())
diff --git a/templates/index.html b/templates/index.html
index 4ae4f3c04..684bee21c 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -78,7 +78,7 @@ $(function () {
},
yAxis: {
title: {
- text: '登陆次数'
+ text: '登录次数'
},
plotLines: [{
value: 0,
@@ -95,19 +95,25 @@ $(function () {
verticalAlign: 'middle',
borderWidth: 0
},
- series: [{
- name: '{{ user }}',
- data: [5, 10, 20, 10, 8, 1, 0]
- }, {
- name: '广宏伟',
- data: [10, 11, 13, 12, 18, 11, 6]
- }, {
- name: '刘德华',
- data: [2, 2, 5, 6, 4, 7, 3]
- }, {
- name: '梁朝伟',
- data: [3, 4, 5, 8, 11, 15, 8]
- }]
+{# series: [{#}
+{# name: '{{ user }}',#}
+{# data: [5, 10, 20, 10, 8, 1, 0]#}
+{# }, {#}
+{# name: '广宏伟',#}
+{# data: [10, 11, 13, 12, 18, 11, 6]#}
+{# }, {#}
+{# name: '刘德华',#}
+{# data: [2, 2, 5, 6, 4, 7, 3]#}
+{# }, {#}
+{# name: '梁朝伟',#}
+{# data: [3, 4, 5, 8, 11, 15, 8]#}
+{# }]#}
+ series: [
+ {% for k,v in dic.items %}
+ {name: '{{ k }}',
+ data: {{ v }}},
+ {% endfor %}
+ ]
});
});
diff --git a/templates/jlog/log_offline.html b/templates/jlog/log_offline.html
index 49d045a91..c2384ff71 100644
--- a/templates/jlog/log_offline.html
+++ b/templates/jlog/log_offline.html
@@ -127,7 +127,7 @@
-
+{##}