pull/6/head
root 10 years ago
parent a746cab21c
commit 67c1f12086

@ -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

@ -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())

@ -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 %}
]
});
});
</script>

@ -127,7 +127,7 @@
</div>
<script src="http://{{ web_socket_host }}/socket.io/socket.io.js"></script>
{#<script src="http://{{ web_socket_host }}/socket.io/socket.io.js"></script>#}
<script>
$('.log_command').on('click',function(){
var url = $(this).attr('href');

Loading…
Cancel
Save