Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
5b0f8971
Commit
5b0f8971
authored
Nov 05, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update proxy log and command log view
parent
41337d28
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
21 deletions
+81
-21
command_log_list.html
apps/audits/templates/audits/command_log_list.html
+29
-6
proxy_log_list.html
apps/audits/templates/audits/proxy_log_list.html
+10
-2
views.py
apps/audits/views.py
+42
-13
No files found.
apps/audits/templates/audits/command_log_list.html
View file @
5b0f8971
...
@@ -13,19 +13,36 @@
...
@@ -13,19 +13,36 @@
{% block table_search %}
{% block table_search %}
<form
id=
"search_form"
method=
"get"
action=
""
class=
"pull-right form-inline"
>
<form
id=
"search_form"
method=
"get"
action=
""
class=
"pull-right form-inline"
>
<div
class=
"form-group"
id=
"date"
>
<div
class=
"input-daterange input-group"
id=
"datepicker"
>
<span
class=
"input-group-addon"
><i
class=
"fa fa-calendar"
></i></span>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_from"
value=
"{{ date_from }}"
>
<span
class=
"input-group-addon"
>
to
</span>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_to"
value=
"{{ date_to }}"
>
</div>
</div>
<div
class=
"input-group"
>
<div
class=
"input-group"
>
<select
class=
"select2 form-control"
name=
"user"
>
<select
class=
"select2 form-control"
name=
"user
name
"
>
<option
>
{% trans 'Select u
ser' %}
</option>
<option
value=
""
>
{% trans 'U
ser' %}
</option>
{% for user in user_list %}
{% for user in user_list %}
<option
value=
"{{ user.username }}"
>
{{ user.username }}
</option>
<option
value=
"{{ user.username }}"
{%
if
user
.
username =
=
username
%}
selected
{%
endif
%}
>
{{ user.username }}
</option>
{% endfor %}
{% endfor %}
</select>
</select>
</div>
</div>
<div
class=
"input-group"
>
<div
class=
"input-group"
>
<select
class=
"select2 form-control"
name=
"
asset
"
>
<select
class=
"select2 form-control"
name=
"
ip
"
>
<option
>
{% trans 'Select a
sset' %}
</option>
<option
value=
""
>
{% trans 'A
sset' %}
</option>
{% for asset in asset_list %}
{% for asset in asset_list %}
<option
value=
"{{ asset.ip }}"
>
{{ asset.ip }}
</option>
<option
value=
"{{ asset.ip }}"
{%
if
asset
.
ip =
=
ip
%}
selected
{%
endif
%}
>
{{ asset.ip }}
</option>
{% endfor %}
</select>
</div>
<div
class=
"input-group"
>
<select
class=
"select2 form-control"
name=
"system_user"
>
{#
<option
value=
""
>
{{ system_user }}
</option>
#}
<option
value=
""
>
{% trans 'System user' %}
</option>
{% for system_user in system_user_list %}
<option
value=
"{{ system_user.username }}"
{%
if
system_user
.
username =
=
system_user
%}
selected
{%
endif
%}
>
{{ system_user.username }}
</option>
{% endfor %}
{% endfor %}
</select>
</select>
</div>
</div>
...
@@ -78,6 +95,12 @@
...
@@ -78,6 +95,12 @@
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
$
(
'.footable'
).
footable
();
$
(
'.footable'
).
footable
();
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
();
$
(
'#date .input-daterange'
).
datepicker
({
dateFormat
:
'mm/dd/yy'
,
keyboardNavigation
:
false
,
forceParse
:
false
,
autoclose
:
true
});
});
});
</script>
</script>
{% endblock %}
{% endblock %}
...
...
apps/audits/templates/audits/proxy_log_list.html
View file @
5b0f8971
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
<select
class=
"select2 form-control"
name=
"username"
>
<select
class=
"select2 form-control"
name=
"username"
>
<option
value=
""
>
{% trans 'Select user' %}
</option>
<option
value=
""
>
{% trans 'Select user' %}
</option>
{% for user in user_list %}
{% for user in user_list %}
<option
value=
"{{ user.username }}"
>
{{ user.username }}
</option>
<option
value=
"{{ user.username }}"
{%
if
user
.
username =
=
username
%}
selected
{%
endif
%}
>
{{ user.username }}
</option>
{% endfor %}
{% endfor %}
</select>
</select>
</div>
</div>
...
@@ -34,7 +34,15 @@
...
@@ -34,7 +34,15 @@
<select
class=
"select2 form-control"
name=
"ip"
>
<select
class=
"select2 form-control"
name=
"ip"
>
<option
value=
""
>
{% trans 'Select asset' %}
</option>
<option
value=
""
>
{% trans 'Select asset' %}
</option>
{% for asset in asset_list %}
{% for asset in asset_list %}
<option
value=
"{{ asset.ip }}"
>
{{ asset.ip }}
</option>
<option
value=
"{{ asset.ip }}"
{%
if
asset
.
ip =
=
ip
%}
selected
{%
endif
%}
>
{{ asset.ip }}
</option>
{% endfor %}
</select>
</div>
<div
class=
"input-group"
>
<select
class=
"select2 form-control"
name=
"system_user"
>
<option
value=
""
>
{% trans 'System user' %}
</option>
{% for su in system_user_list %}
<option
value=
"{{ su.username }}"
{%
if
su
.
username =
=
system_user
%}
selected
{%
endif
%}
>
{{ su.username }}
</option>
{% endfor %}
{% endfor %}
</select>
</select>
</div>
</div>
...
...
apps/audits/views.py
View file @
5b0f8971
...
@@ -15,6 +15,10 @@ from .utils import AdminUserRequiredMixin
...
@@ -15,6 +15,10 @@ from .utils import AdminUserRequiredMixin
from
.hands
import
User
,
Asset
,
SystemUser
from
.hands
import
User
,
Asset
,
SystemUser
seven_days_ago_s
=
(
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
7
))
.
strftime
(
'
%
m/
%
d/
%
Y'
)
now_s
=
datetime
.
datetime
.
now
()
.
strftime
(
'
%
m/
%
d/
%
Y'
)
class
ProxyLogListView
(
AdminUserRequiredMixin
,
ListView
):
class
ProxyLogListView
(
AdminUserRequiredMixin
,
ListView
):
model
=
ProxyLog
model
=
ProxyLog
template_name
=
'audits/proxy_log_list.html'
template_name
=
'audits/proxy_log_list.html'
...
@@ -25,14 +29,13 @@ class ProxyLogListView(AdminUserRequiredMixin, ListView):
...
@@ -25,14 +29,13 @@ class ProxyLogListView(AdminUserRequiredMixin, ListView):
self
.
keyword
=
keyword
=
self
.
request
.
GET
.
get
(
'keyword'
,
''
)
self
.
keyword
=
keyword
=
self
.
request
.
GET
.
get
(
'keyword'
,
''
)
self
.
username
=
username
=
self
.
request
.
GET
.
get
(
'username'
,
''
)
self
.
username
=
username
=
self
.
request
.
GET
.
get
(
'username'
,
''
)
self
.
ip
=
ip
=
self
.
request
.
GET
.
get
(
'ip'
,
''
)
self
.
ip
=
ip
=
self
.
request
.
GET
.
get
(
'ip'
,
''
)
self
.
date_from_s
=
date_from_s
=
\
self
.
system_user
=
system_user
=
self
.
request
.
GET
.
get
(
'system_user'
,
''
)
self
.
request
.
GET
.
get
(
'date_from'
,
'
%
s'
%
(
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
7
))
.
strftime
(
'
%
m/
%
d/
%
Y'
)
)
self
.
date_from_s
=
date_from_s
=
self
.
request
.
GET
.
get
(
'date_from'
,
'
%
s'
%
seven_days_ago_s
)
self
.
date_to_s
=
date_to_s
=
self
.
request
.
GET
.
get
(
'date_to'
,
'
%
s'
%
datetime
.
datetime
.
now
()
.
strftime
(
'
%
m/
%
d/
%
Y'
)
)
self
.
date_to_s
=
date_to_s
=
self
.
request
.
GET
.
get
(
'date_to'
,
'
%
s'
%
now_s
)
if
date_from_s
:
if
date_from_s
:
date_from
=
timezone
.
datetime
.
strptime
(
date_from_s
,
'
%
m/
%
d/
%
Y'
)
date_from
=
timezone
.
datetime
.
strptime
(
date_from_s
,
'
%
m/
%
d/
%
Y'
)
self
.
queryset
=
self
.
queryset
.
filter
(
date_start__gt
=
date_from
)
self
.
queryset
=
self
.
queryset
.
filter
(
date_start__gt
=
date_from
)
if
date_to_s
:
if
date_to_s
:
date_to
=
timezone
.
datetime
.
strptime
(
date_to_s
+
' 23:59:59'
,
'
%
m/
%
d/
%
Y
%
H:
%
M:
%
S'
)
date_to
=
timezone
.
datetime
.
strptime
(
date_to_s
+
' 23:59:59'
,
'
%
m/
%
d/
%
Y
%
H:
%
M:
%
S'
)
self
.
queryset
=
self
.
queryset
.
filter
(
date_start__lt
=
date_to
)
self
.
queryset
=
self
.
queryset
.
filter
(
date_start__lt
=
date_to
)
...
@@ -40,6 +43,8 @@ class ProxyLogListView(AdminUserRequiredMixin, ListView):
...
@@ -40,6 +43,8 @@ class ProxyLogListView(AdminUserRequiredMixin, ListView):
self
.
queryset
=
self
.
queryset
.
filter
(
username
=
username
)
self
.
queryset
=
self
.
queryset
.
filter
(
username
=
username
)
if
ip
:
if
ip
:
self
.
queryset
=
self
.
queryset
.
filter
(
ip
=
ip
)
self
.
queryset
=
self
.
queryset
.
filter
(
ip
=
ip
)
if
system_user
:
self
.
queryset
=
self
.
queryset
.
filter
(
system_user
=
system_user
)
if
keyword
:
if
keyword
:
self
.
queryset
=
self
.
queryset
.
filter
(
Q
(
username__contains
=
keyword
)
|
self
.
queryset
=
self
.
queryset
.
filter
(
Q
(
username__contains
=
keyword
)
|
Q
(
name__icontains
=
keyword
)
|
Q
(
name__icontains
=
keyword
)
|
...
@@ -52,12 +57,15 @@ class ProxyLogListView(AdminUserRequiredMixin, ListView):
...
@@ -52,12 +57,15 @@ class ProxyLogListView(AdminUserRequiredMixin, ListView):
context
=
{
context
=
{
'app'
:
_
(
'Audits'
),
'app'
:
_
(
'Audits'
),
'action'
:
_
(
'Proxy log list'
),
'action'
:
_
(
'Proxy log list'
),
'user_list'
:
User
.
objects
.
all
(),
'user_list'
:
User
.
objects
.
all
()
.
order_by
(
'username'
)
,
'asset_list'
:
Asset
.
objects
.
all
(),
'asset_list'
:
Asset
.
objects
.
all
()
.
order_by
(
'ip'
)
,
'system_user_list'
:
SystemUser
.
objects
.
all
(),
'system_user_list'
:
SystemUser
.
objects
.
all
()
.
order_by
(
'name'
)
,
'keyword'
:
self
.
keyword
,
'keyword'
:
self
.
keyword
,
'date_from'
:
self
.
date_from_s
,
'date_from'
:
self
.
date_from_s
,
'date_to'
:
self
.
date_to_s
,
'date_to'
:
self
.
date_to_s
,
'username'
:
self
.
username
,
'ip'
:
self
.
ip
,
'system_user'
:
self
.
system_user
,
}
}
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
ProxyLogListView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
ProxyLogListView
,
self
)
.
get_context_data
(
**
kwargs
)
...
@@ -101,14 +109,29 @@ class CommandLogListView(AdminUserRequiredMixin, ListView):
...
@@ -101,14 +109,29 @@ class CommandLogListView(AdminUserRequiredMixin, ListView):
context_object_name
=
'command_list'
context_object_name
=
'command_list'
def
get_queryset
(
self
):
def
get_queryset
(
self
):
# Todo: Default order by lose asset connection num
self
.
queryset
=
super
(
CommandLogListView
,
self
)
.
get_queryset
()
self
.
queryset
=
super
(
CommandLogListView
,
self
)
.
get_queryset
()
self
.
keyword
=
keyword
=
self
.
request
.
GET
.
get
(
'keyword'
,
''
)
self
.
keyword
=
keyword
=
self
.
request
.
GET
.
get
(
'keyword'
,
''
)
self
.
sort
=
sort
=
self
.
request
.
GET
.
get
(
'sort'
,
'-datetime'
)
self
.
sort
=
sort
=
self
.
request
.
GET
.
get
(
'sort'
,
'-datetime'
)
self
.
username
=
username
=
self
.
request
.
GET
.
get
(
'username'
,
''
)
self
.
ip
=
ip
=
self
.
request
.
GET
.
get
(
'ip'
,
''
)
self
.
system_user
=
system_user
=
self
.
request
.
GET
.
get
(
'system_user'
,
''
)
self
.
date_from_s
=
date_from_s
=
self
.
request
.
GET
.
get
(
'date_from'
,
'
%
s'
%
seven_days_ago_s
)
self
.
date_to_s
=
date_to_s
=
self
.
request
.
GET
.
get
(
'date_to'
,
'
%
s'
%
now_s
)
if
date_from_s
:
date_from
=
timezone
.
datetime
.
strptime
(
date_from_s
,
'
%
m/
%
d/
%
Y'
)
self
.
queryset
=
self
.
queryset
.
filter
(
datetime__gt
=
date_from
)
if
date_to_s
:
date_to
=
timezone
.
datetime
.
strptime
(
date_to_s
+
' 23:59:59'
,
'
%
m/
%
d/
%
Y
%
H:
%
M:
%
S'
)
self
.
queryset
=
self
.
queryset
.
filter
(
datetime__lt
=
date_to
)
if
username
:
self
.
queryset
=
self
.
queryset
.
filter
(
proxy_log__username
=
username
)
if
ip
:
self
.
queryset
=
self
.
queryset
.
filter
(
proxy_log__ip
=
ip
)
if
system_user
:
self
.
queryset
=
self
.
queryset
.
filter
(
proxy_log__system_user
=
system_user
)
if
keyword
:
if
keyword
:
self
.
queryset
=
self
.
queryset
.
filter
()
self
.
queryset
=
self
.
queryset
.
filter
(
command
=
keyword
)
if
sort
:
if
sort
:
self
.
queryset
=
self
.
queryset
.
order_by
(
sort
)
self
.
queryset
=
self
.
queryset
.
order_by
(
sort
)
return
self
.
queryset
return
self
.
queryset
...
@@ -117,9 +140,15 @@ class CommandLogListView(AdminUserRequiredMixin, ListView):
...
@@ -117,9 +140,15 @@ class CommandLogListView(AdminUserRequiredMixin, ListView):
context
=
{
context
=
{
'app'
:
_
(
'Audits'
),
'app'
:
_
(
'Audits'
),
'action'
:
_
(
'Command log list'
),
'action'
:
_
(
'Command log list'
),
'user_list'
:
User
.
objects
.
all
(),
'user_list'
:
User
.
objects
.
all
()
.
order_by
(
'username'
),
'asset_list'
:
Asset
.
objects
.
all
(),
'asset_list'
:
Asset
.
objects
.
all
()
.
order_by
(
'ip'
),
'system_user_list'
:
SystemUser
.
objects
.
all
(),
'system_user_list'
:
SystemUser
.
objects
.
all
()
.
order_by
(
'name'
),
'keyword'
:
self
.
keyword
,
'date_from'
:
self
.
date_from_s
,
'date_to'
:
self
.
date_to_s
,
'username'
:
self
.
username
,
'ip'
:
self
.
ip
,
'system_user'
:
self
.
system_user
,
}
}
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
CommandLogListView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
CommandLogListView
,
self
)
.
get_context_data
(
**
kwargs
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment