Commit 67c1f120 authored by root's avatar root

dashboard

parent a746cab2
...@@ -8,11 +8,11 @@ password = mysql234 ...@@ -8,11 +8,11 @@ password = mysql234
database = jumpserver database = jumpserver
[ldap] [ldap]
ldap_enable = 1 ldap_enable = 0
host_url = ldap://127.0.0.1:389 host_url = ldap://192.168.8.60:389
base_dn = dc=jumpserver,dc=org base_dn = dc=fengxing, dc=com
root_dn = cn=admin,dc=jumpserver,dc=org root_dn = cn=admin,dc=fengxing,dc=com
root_pw = secret234 root_pw = 123456
[websocket] [websocket]
web_socket_host = 127.0.0.1:3000 web_socket_host = 127.0.0.1:3000
......
#coding: utf-8 #coding: utf-8
import hashlib 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.shortcuts import render_to_response
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.core.paginator import Paginator, EmptyPage, InvalidPage from django.core.paginator import Paginator, EmptyPage, InvalidPage
...@@ -15,11 +18,34 @@ def md5_crypt(string): ...@@ -15,11 +18,34 @@ def md5_crypt(string):
return hashlib.new("md5", string).hexdigest() 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): def index(request):
path1, path2 = u'仪表盘', 'Dashboard' 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() users = User.objects.all()
hosts = Asset.objects.all() hosts = Asset.objects.all()
user = 'wangyong'
online_host = Log.objects.filter(is_finished=0) online_host = Log.objects.filter(is_finished=0)
online_user = online_host.distinct() online_user = online_host.distinct()
return render_to_response('index.html', locals()) return render_to_response('index.html', locals())
......
...@@ -78,7 +78,7 @@ $(function () { ...@@ -78,7 +78,7 @@ $(function () {
}, },
yAxis: { yAxis: {
title: { title: {
text: '登次数' text: '登次数'
}, },
plotLines: [{ plotLines: [{
value: 0, value: 0,
...@@ -95,19 +95,25 @@ $(function () { ...@@ -95,19 +95,25 @@ $(function () {
verticalAlign: 'middle', verticalAlign: 'middle',
borderWidth: 0 borderWidth: 0
}, },
series: [{ {# series: [{#}
name: '{{ user }}', {# name: '{{ user }}',#}
data: [5, 10, 20, 10, 8, 1, 0] {# data: [5, 10, 20, 10, 8, 1, 0]#}
}, { {# }, {#}
name: '广宏伟', {# name: '广宏伟',#}
data: [10, 11, 13, 12, 18, 11, 6] {# data: [10, 11, 13, 12, 18, 11, 6]#}
}, { {# }, {#}
name: '刘德华', {# name: '刘德华',#}
data: [2, 2, 5, 6, 4, 7, 3] {# data: [2, 2, 5, 6, 4, 7, 3]#}
}, { {# }, {#}
name: '梁朝伟', {# name: '梁朝伟',#}
data: [3, 4, 5, 8, 11, 15, 8] {# data: [3, 4, 5, 8, 11, 15, 8]#}
}] {# }]#}
series: [
{% for k,v in dic.items %}
{name: '{{ k }}',
data: {{ v }}},
{% endfor %}
]
}); });
}); });
</script> </script>
......
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
</div> </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> <script>
$('.log_command').on('click',function(){ $('.log_command').on('click',function(){
var url = $(this).attr('href'); var url = $(this).attr('href');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment