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
d19b47a4
Commit
d19b47a4
authored
Oct 26, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add command log modal
parent
573b3a87
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
12 deletions
+46
-12
models.py
apps/audits/models.py
+11
-0
serializers.py
apps/audits/serializers.py
+1
-1
proxy_log_command_list_modal.html
...audits/templates/audits/proxy_log_command_list_modal.html
+2
-4
proxy_log_list.html
apps/audits/templates/audits/proxy_log_list.html
+32
-7
No files found.
apps/audits/models.py
View file @
d19b47a4
...
@@ -54,6 +54,17 @@ class ProxyLog(models.Model):
...
@@ -54,6 +54,17 @@ class ProxyLog(models.Model):
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
'
%
s-
%
s-
%
s-
%
s'
%
(
self
.
username
,
self
.
hostname
,
self
.
system_user
,
self
.
id
)
return
'
%
s-
%
s-
%
s-
%
s'
%
(
self
.
username
,
self
.
hostname
,
self
.
system_user
,
self
.
id
)
@property
def
commands_dict
(
self
):
commands
=
self
.
command_log
.
all
()
return
[
{
"command_no"
:
command
.
command_no
,
"command"
:
command
.
command
,
"output"
:
command
.
output_decode
,
"datetime"
:
command
.
datetime
,
}
for
command
in
commands
]
class
Meta
:
class
Meta
:
db_table
=
'proxy_log'
db_table
=
'proxy_log'
ordering
=
[
'-date_start'
,
'username'
]
ordering
=
[
'-date_start'
,
'username'
]
...
...
apps/audits/serializers.py
View file @
d19b47a4
...
@@ -14,7 +14,7 @@ class ProxyLogSerializer(serializers.ModelSerializer):
...
@@ -14,7 +14,7 @@ class ProxyLogSerializer(serializers.ModelSerializer):
class
Meta
:
class
Meta
:
model
=
models
.
ProxyLog
model
=
models
.
ProxyLog
fields
=
[
'id'
,
'name'
,
'username'
,
'hostname'
,
'ip'
,
'system_user'
,
'login_type'
,
'terminal'
,
fields
=
[
'id'
,
'name'
,
'username'
,
'hostname'
,
'ip'
,
'system_user'
,
'login_type'
,
'terminal'
,
'log_file'
,
'was_failed'
,
'is_finished'
,
'date_start'
,
'time'
,
'command_length'
]
'log_file'
,
'was_failed'
,
'is_finished'
,
'date_start'
,
'time'
,
'command_length'
,
"commands_dict"
]
@staticmethod
@staticmethod
def
get_time
(
obj
):
def
get_time
(
obj
):
...
...
apps/audits/templates/audits/
_proxy_log_command
_modal.html
→
apps/audits/templates/audits/
proxy_log_command_list
_modal.html
View file @
d19b47a4
{% extends '_modal.html' %}
{% extends '_modal.html' %}
{% load i18n %}
{% load i18n %}
{% block modal_id %}Proxy command list{% endblock %}
{% block modal_id %}command_table{% endblock %}
{% block modal_title%}{% trans "Proxy command list" %}{% endblock %}
{% block modal_body %}
{% block modal_body %}
<div
class=
"ibox-content"
>
<table
class=
"footable table table-stripped toggle-arrow-tiny"
data-page-size=
"10"
>
<table
class=
"footable table table-stripped toggle-arrow-tiny"
data-page-size=
"10"
>
<thead>
<thead>
<tr>
<tr>
...
@@ -13,7 +11,7 @@
...
@@ -13,7 +11,7 @@
<th>
Datetime
</th>
<th>
Datetime
</th>
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody
class=
"table_body"
>
{% for command in object_list %}
{% for command in object_list %}
<tr>
<tr>
<td>
{{ command.command_no }}
</td>
<td>
{{ command.command_no }}
</td>
...
...
apps/audits/templates/audits/proxy_log_list.html
View file @
d19b47a4
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
<tbody>
<tbody>
</tbody>
</tbody>
</table>
</table>
{% include 'audits/
_proxy_log_command
_modal.html' %}
{% include 'audits/
proxy_log_command_list
_modal.html' %}
{% endblock %}
{% endblock %}
{% block custom_foot_js %}
{% block custom_foot_js %}
<script
src=
"{% static 'js/jquery.form.min.js' %}"
></script>
<script
src=
"{% static 'js/jquery.form.min.js' %}"
></script>
...
@@ -55,6 +55,13 @@ $(document).ready(function(){
...
@@ -55,6 +55,13 @@ $(document).ready(function(){
var
detail_btn
=
'<a href="{% url "users:user-detail" pk=99991937 %}">'
+
cellData
+
'</a>'
;
var
detail_btn
=
'<a href="{% url "users:user-detail" pk=99991937 %}">'
+
cellData
+
'</a>'
;
$
(
td
).
html
(
detail_btn
.
replace
(
'99991937'
,
rowData
.
id
));
$
(
td
).
html
(
detail_btn
.
replace
(
'99991937'
,
rowData
.
id
));
}},
}},
{
targets
:
4
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
if
(
cellData
)
{
$
(
td
).
html
(
'<a url="{% url "audits:proxy-log-detail-api" pk=99991938 %}" class="commands">99991937</a>'
.
replace
(
'99991937'
,
cellData
)
.
replace
(
'99991938'
,
rowData
.
id
))
}
}},
{
targets
:
5
,
createdCell
:
function
(
td
,
cellData
)
{
{
targets
:
5
,
createdCell
:
function
(
td
,
cellData
)
{
if
(
cellData
)
{
if
(
cellData
)
{
$
(
td
).
html
(
'<i class="fa fa-times text-danger"></i>'
)
$
(
td
).
html
(
'<i class="fa fa-times text-danger"></i>'
)
...
@@ -85,12 +92,30 @@ $(document).ready(function(){
...
@@ -85,12 +92,30 @@ $(document).ready(function(){
op_html
:
$
(
'#actions'
).
html
()
op_html
:
$
(
'#actions'
).
html
()
};
};
jumpserver
.
initDataTable
(
options
);
jumpserver
.
initDataTable
(
options
);
}).
on
(
'click'
,
'.btn_delete'
,
function
(){
}).
on
(
'click'
,
'.commands'
,
function
()
{
var
$this
=
$
(
this
);
var
url
=
$
(
this
).
attr
(
'url'
);
var
uid
=
$this
.
data
(
'uid'
);
$
.
ajax
({
var
name
=
$
(
this
).
data
(
'name'
);
url
:
url
,
var
the_url
=
'{% url "terminal:terminal-detail-update-delete-api" pk=99991937 %}'
.
replace
(
'99991937'
,
uid
);
method
:
'GET'
,
objectDelete
(
$this
,
name
,
the_url
)
success
:
function
(
data
)
{
var
table_body
=
''
;
$
.
each
(
data
.
commands_dict
,
function
(
index
,
value
)
{
table_body
+=
'<tr>'
+
'<td>'
+
value
.
command_no
+
'</td>'
+
'<td>'
+
value
.
command
+
'</td>'
+
'<td>'
+
value
.
output
+
'</td>'
+
'<td>'
+
value
.
datetime
+
'</td>'
+
'</tr>'
});
console
.
log
(
table_body
);
$
(
'.table_body'
).
html
(
table_body
);
$
(
'.footable'
).
footable
();
$
(
'#command_table'
).
modal
(
'show'
);
}
})
})
})
</script>
</script>
{% endblock %}
{% endblock %}
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