mirror of https://github.com/jumpserver/jumpserver
search ok
parent
ffab7ae697
commit
76ad67307b
|
@ -43,13 +43,27 @@ from jlog.log_api import renderTemplate
|
|||
def log_list(request, offset):
|
||||
""" 显示日志 """
|
||||
header_title, path1, path2 = u'查看日志', u'查看日志', u'在线用户'
|
||||
keyword = request.GET.get('keyword', '')
|
||||
web_socket_host = CONF.get('websocket', 'web_socket_host')
|
||||
keyword = request.GET.get('keyword', None)
|
||||
# posts = get_user_log(get_user_info(request, offset))
|
||||
|
||||
if offset == 'online':
|
||||
web_socket_host = CONF.get('websocket', 'web_socket_host')
|
||||
posts = Log.objects.filter(is_finished=False).order_by('-start_time')
|
||||
else:
|
||||
posts = Log.objects.filter(is_finished=True).order_by('-start_time')
|
||||
if keyword is not None:
|
||||
date_seven_day = request.GET.get('start')
|
||||
date_now_str = request.GET.get('end')
|
||||
datetime_start = datetime.datetime.strptime(date_seven_day, '%m/%d/%Y')
|
||||
datetime_end = datetime.datetime.strptime(date_now_str, '%m/%d/%Y')
|
||||
print datetime_start, datetime_end
|
||||
posts = posts.filter(start_time__gte=datetime_start).filter(start_time__lte=datetime_end).filter(
|
||||
Q(user__icontains=keyword) | Q(host__icontains=keyword) | Q(remote_ip__icontains=keyword))
|
||||
|
||||
else:
|
||||
date_now = datetime.datetime.now()
|
||||
date_now_str = date_now.strftime('%m/%d/%Y')
|
||||
date_seven_day = (date_now + datetime.timedelta(days=-7)).strftime('%m/%d/%Y')
|
||||
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
|
||||
|
||||
return render_to_response('jlog/log_%s.html' % offset, locals(), context_instance=RequestContext(request))
|
||||
|
|
|
@ -8,4 +8,5 @@
|
|||
<!-- validator js -->
|
||||
<script src="/static/js/validator/jquery.validator.js"></script>
|
||||
<script src="/static/js/validator/zh_CN.js"></script>
|
||||
<script src="/static/js/datapicker/bootstrap-datepicker.js"></script>
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
{% extends 'base.html' %}
|
||||
{% block self_head_css_js %}
|
||||
<link href="/static/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
{% include 'nav_cat_bar.html' %}
|
||||
|
||||
|
@ -52,23 +55,21 @@
|
|||
<li><a href="/jlog/log_list/online/" class="text-center"><i class="fa fa-laptop"></i> 在线 </a></li>
|
||||
<li class="active"><a href="/jlog/log_list/offline/" class="text-center"><i class="fa fa-bar-chart-o"></i> 历史记录 </a></li>
|
||||
<li style="float: right">
|
||||
<form class="form-inline">
|
||||
<form class="form-inline" action="" method="get">
|
||||
<div class="form-group" id="data_5">
|
||||
<div class="input-daterange input-group" id="datepicker">
|
||||
<input type="text" class="input-sm form-control" style="width: 100px;" name="start" value="05/14/2014">
|
||||
<input type="text" class="input-sm form-control" style="width: 100px;" name="start" value="{{ date_seven_day }}">
|
||||
<span class="input-group-addon">to</span>
|
||||
<input type="text" class="input-sm form-control" style="width: 100px;" name="end" value="05/22/2014">
|
||||
<input type="text" class="input-sm form-control" style="width: 100px;" name="end" value="{{ date_now_str }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control input-sm" id="search_input" name="keyword" placeholder="Search">
|
||||
</div>
|
||||
|
||||
<button id='search_btn' type="button" class="btn btn-sm btn-primary" onclick="log_search()">
|
||||
Search
|
||||
</button>
|
||||
</div>
|
||||
<button id='search_btn' type="submit" class="btn btn-sm btn-primary">
|
||||
Search
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -153,13 +154,14 @@
|
|||
});
|
||||
}
|
||||
|
||||
$("#search_input").keydown(function(e){
|
||||
if(e.keyCode==13){
|
||||
log_search()
|
||||
}
|
||||
});
|
||||
{# $("#search_input").keydown(function(e){#}
|
||||
{# if(e.keyCode==13){#}
|
||||
{# log_search()#}
|
||||
{# }#}
|
||||
{# });#}
|
||||
|
||||
$('#data_5 .input-daterange').datepicker({
|
||||
dateFormat: 'yy-mm-dd',
|
||||
keyboardNavigation: false,
|
||||
forceParse: false,
|
||||
autoclose: true
|
||||
|
@ -168,5 +170,6 @@
|
|||
</script>
|
||||
{% endblock %}
|
||||
{% block self_footer_js %}
|
||||
|
||||
<script src="/static/js/cropper/cropper.min.js"></script>
|
||||
<script src="/static/js/datapicker/bootstrap-datepicker.js"></script>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue