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
008be6a8
Commit
008be6a8
authored
Feb 12, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fixtrue] 完成terminal detail 和批量结束会话
parent
1f544b98
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
158 additions
and
15 deletions
+158
-15
api.py
apps/applications/api.py
+18
-9
terminal_detail.html
.../applications/templates/applications/terminal_detail.html
+77
-0
terminal_list.html
apps/applications/templates/applications/terminal_list.html
+1
-1
views_urls.py
apps/applications/urls/views_urls.py
+6
-2
views.py
apps/applications/views.py
+16
-2
example.html
apps/audits/templates/audits/example.html
+0
-0
proxy_log_list.html
apps/audits/templates/audits/proxy_log_list.html
+40
-1
No files found.
apps/applications/api.py
View file @
008be6a8
...
...
@@ -4,6 +4,7 @@
from
collections
import
OrderedDict
from
django.core.cache
import
cache
from
django.conf
import
settings
from
django.utils
import
timezone
import
copy
from
rest_framework.generics
import
ListCreateAPIView
,
RetrieveUpdateDestroyAPIView
from
rest_framework
import
viewsets
...
...
@@ -80,21 +81,29 @@ class TerminalHeatbeatViewSet(viewsets.ModelViewSet):
task
=
tasks
.
get
(
terminal
.
name
)
tasks
[
terminal
.
name
]
=
[]
return
Response
({
'msg'
:
'Success'
,
'tasks'
:
task
,
},
'tasks'
:
task
},
status
=
201
)
class
TerminateConnectionView
(
APIView
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
proxy_log_id
=
request
.
data
.
get
(
'proxy_log_id'
)
proxy_log
=
get_object_or_404
(
ProxyLog
,
id
=
proxy_log_id
)
terminal_id
=
proxy_log
.
terminal
if
terminal_id
in
tasks
:
tasks
[
terminal_id
]
.
append
({
'name'
:
'kill_proxy'
,
'proxy_log_id'
:
proxy_log_id
})
if
isinstance
(
request
.
data
,
dict
):
data
=
[
request
.
data
]
else
:
tasks
[
terminal_id
]
=
[{
'name'
:
'kill_proxy'
,
'proxy_log_id'
:
proxy_log_id
}]
data
=
request
.
data
for
d
in
data
:
proxy_log_id
=
d
.
get
(
'proxy_log_id'
)
proxy_log
=
get_object_or_404
(
ProxyLog
,
id
=
proxy_log_id
)
terminal_id
=
proxy_log
.
terminal
proxy_log
.
is_finished
=
True
proxy_log
.
date_finished
=
timezone
.
now
()
proxy_log
.
save
()
if
terminal_id
in
tasks
:
tasks
[
terminal_id
]
.
append
({
'name'
:
'kill_proxy'
,
'proxy_log_id'
:
proxy_log_id
})
else
:
tasks
[
terminal_id
]
=
[{
'name'
:
'kill_proxy'
,
'proxy_log_id'
:
proxy_log_id
}]
print
(
tasks
)
return
Response
({
'msg'
:
'get it'
})
apps/applications/templates/applications/terminal_detail.html
0 → 100644
View file @
008be6a8
{% extends 'base.html' %}
{% load static %}
{% load i18n %}
{% block content %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"panel-options"
>
<ul
class=
"nav nav-tabs"
>
<li
class=
"active"
>
<a
href=
""
class=
"text-center"
><i
class=
"fa fa-laptop"
></i>
{% trans 'Terminal detail' %}
</a>
</li>
<li
class=
"pull-right"
>
<a
class=
"btn btn-outline btn-default"
href=
"{% url 'applications:terminal-update' pk=terminal.id %}"
><i
class=
"fa fa-edit"
></i>
Update
</a>
</li>
</ul>
</div>
<div
class=
"tab-content"
>
<div
class=
"col-sm-7"
style=
"padding-left: 0"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
class=
"label"
><b>
{{ terminal.name }}
</b></span>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
</ul>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
>
<table
class=
"table"
>
<tbody>
<tr
class=
"no-borders-tr"
>
<td
width=
"20%"
>
{% trans 'Name' %}:
</td>
<td><b>
{{ terminal.name }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Remote addr' %}:
</td>
<td><b>
{{ terminal.remote_addr }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Terminal url' %}:
</td>
<td><b>
{{ terminal.url }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Terminal type' %}:
</td>
<td><b>
{{ terminal.get_type_display }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Date created' %}:
</td>
<td><b>
{{ terminal.date_created }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Comment' %}:
</td>
<td><b>
{{ asset.comment }}
</b></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
apps/applications/templates/applications/terminal_list.html
View file @
008be6a8
...
...
@@ -50,7 +50,7 @@ $(document).ready(function(){
buttons
:
[],
columnDefs
:
[
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
detail_btn
=
'<a href="{% url "
users:user
-detail" pk=99991937 %}">'
+
cellData
+
'</a>'
;
var
detail_btn
=
'<a href="{% url "
applications:terminal
-detail" pk=99991937 %}">'
+
cellData
+
'</a>'
;
$
(
td
).
html
(
detail_btn
.
replace
(
'99991937'
,
rowData
.
id
));
}},
{
targets
:
5
,
createdCell
:
function
(
td
,
cellData
)
{
...
...
apps/applications/urls/views_urls.py
View file @
008be6a8
...
...
@@ -10,6 +10,10 @@ app_name = 'applications'
urlpatterns
=
[
url
(
r'^terminal$'
,
views
.
TerminalListView
.
as_view
(),
name
=
'terminal-list'
),
url
(
r'^terminal/(?P<pk>\d+)/update$'
,
views
.
TerminalUpdateView
.
as_view
(),
name
=
'terminal-update'
),
url
(
r'^terminal/(?P<pk>\d+)/modal/accept$'
,
views
.
TerminalModelAccept
.
as_view
(),
name
=
'terminal-modal-accept'
),
url
(
r'^terminal/(?P<pk>\d+)/$'
,
views
.
TerminalDetailView
.
as_view
(),
name
=
'terminal-detail'
),
url
(
r'^terminal/(?P<pk>\d+)/update$'
,
views
.
TerminalUpdateView
.
as_view
(),
name
=
'terminal-update'
),
url
(
r'^terminal/(?P<pk>\d+)/modal/accept$'
,
views
.
TerminalModelAccept
.
as_view
(),
name
=
'terminal-modal-accept'
),
]
apps/applications/views.py
View file @
008be6a8
# ~*~ coding: utf-8 ~*~
#
from
django.views.generic
import
ListView
,
UpdateView
,
DeleteView
,
Form
View
from
django.views.generic
import
ListView
,
UpdateView
,
DeleteView
,
Detail
View
from
django.views.generic.edit
import
BaseUpdateView
from
django.utils.translation
import
ugettext
as
_
from
django.urls
import
reverse_lazy
...
...
@@ -35,7 +35,21 @@ class TerminalUpdateView(UpdateView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
TerminalUpdateView
,
self
)
.
get_context_data
(
**
kwargs
)
context
.
update
({
'app'
:
_
(
'Terminal'
),
'action'
:
_
(
'Update applications'
)})
context
.
update
({
'app'
:
_
(
'Applications'
),
'action'
:
_
(
'Update terminal'
)})
return
context
class
TerminalDetailView
(
DetailView
):
model
=
Terminal
template_name
=
'applications/terminal_detail.html'
context_object_name
=
'terminal'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
TerminalDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
context
.
update
({
'app'
:
_
(
'Applications'
),
'action'
:
_
(
'Terminal detail'
)
})
return
context
...
...
apps/audits/templates/audits/example.html
deleted
100644 → 0
View file @
1f544b98
apps/audits/templates/audits/proxy_log_list.html
View file @
008be6a8
...
...
@@ -60,6 +60,7 @@
{% endblock %}
{% block table_head %}
<th
class=
"text-center"
></th>
<th
class=
"text-center"
>
{% trans 'ID' %}
</th>
<th
class=
"text-center"
>
{% trans 'User' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset' %}
</th>
...
...
@@ -76,6 +77,7 @@
{% block table_body %}
{% for proxy_log in proxy_log_list %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
><input
type=
"checkbox"
class=
"cbx-term"
value=
"{{ proxy_log.id }}"
></td>
<td
class=
"text-center"
>
<a
href=
"{% url 'audits:proxy-log-detail' pk=proxy_log.id %}"
>
{{ proxy_log.id }}
</a>
</td>
...
...
@@ -100,7 +102,7 @@
</td>
{% else %}
<td
class=
"text-center"
>
<a><i
class=
"fa fa-times text-danger"
></i></a>
<a
class=
"btn-term"
value=
"{{ proxy_log.id }}"
><i
class=
"fa fa-times text-danger"
></i></a>
</td>
<td
class=
"text-center"
>
<a><span
class=
"text-danger"
><i
class=
"fa fa-eye"
></i></span></a>
...
...
@@ -112,9 +114,33 @@
{% endfor %}
{% endblock %}
{% block content_bottom_left %}
<div
id=
"actions"
>
<div
class=
"input-group"
>
<select
class=
"form-control m-b"
style=
"width: auto"
id=
"slct_bulk_update"
>
<option
value=
"terminate"
>
{% trans 'Terminate selected' %}
</option>
</select>
<div
class=
"input-group-btn pull-left"
style=
"padding-left: 5px;"
>
<button
id=
'btn_bulk_update'
style=
"height: 32px;"
class=
"btn btn-sm btn-primary"
>
{% trans 'Submit' %}
</button>
</div>
</div>
</div>
{% endblock %}
{% block custom_foot_js %}
<script
src=
"{% static 'js/plugins/datepicker/bootstrap-datepicker.js' %}"
></script>
<script>
function
terminateConnection
(
data
)
{
function
success
()
{
window
.
setTimeout
(
function
()
{
window
.
location
.
reload
()
},
300
)
}
var
the_url
=
"{% url 'api-applications:terminate-connection' %}"
;
APIUpdateAttr
({
url
:
the_url
,
method
:
'POST'
,
body
:
JSON
.
stringify
(
data
),
success
:
success
,
success_message
:
'Terminate success'
});
}
$
(
document
).
ready
(
function
()
{
$
(
'table'
).
DataTable
({
"searching"
:
false
,
...
...
@@ -129,6 +155,19 @@
forceParse
:
false
,
autoclose
:
true
});
}).
on
(
'click'
,
'.btn-term'
,
function
()
{
var
$this
=
$
(
this
);
var
proxy_log_id
=
$this
.
attr
(
'value'
);
var
data
=
{
proxy_log_id
:
proxy_log_id
};
terminateConnection
(
data
)
}).
on
(
'click'
,
'#btn_bulk_update'
,
function
()
{
var
data
=
[];
$
(
'.cbx-term:checked'
).
each
(
function
()
{
data
.
push
({
proxy_log_id
:
$
(
this
).
attr
(
'value'
)})
});
terminateConnection
(
data
)
})
</script>
{% 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