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
d56f030d
Commit
d56f030d
authored
Dec 26, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish terminal accept
parent
775cd523
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
134 additions
and
15 deletions
+134
-15
forms.py
apps/applications/forms.py
+4
-1
models.py
apps/applications/models.py
+2
-2
terminal_form.html
apps/applications/templates/applications/terminal_form.html
+0
-0
terminal_list.html
apps/applications/templates/applications/terminal_list.html
+41
-2
terminal_modal_accept.bak.html
...ons/templates/applications/terminal_modal_accept.bak.html
+27
-0
terminal_modal_accept.html
...cations/templates/applications/terminal_modal_accept.html
+19
-0
views_urls.py
apps/applications/urls/views_urls.py
+1
-0
views.py
apps/applications/views.py
+36
-4
base.html
apps/templates/base.html
+1
-0
user_list.html
apps/users/templates/users/user_list.html
+3
-6
No files found.
apps/applications/forms.py
View file @
d56f030d
...
...
@@ -14,4 +14,6 @@ class TerminalForm(forms.ModelForm):
help_texts
=
{
'url'
:
'Example: ssh://192.168.1.1:22 or http://jms.jumpserver.org, that user login'
}
widgets
=
{
'name'
:
forms
.
TextInput
(
attrs
=
{
'readonly'
:
'readonly'
})
}
\ No newline at end of file
apps/applications/models.py
View file @
d56f030d
...
...
@@ -13,7 +13,7 @@ class Terminal(models.Model):
)
name
=
models
.
CharField
(
max_length
=
30
,
unique
=
True
,
verbose_name
=
_
(
'Name'
))
remote_addr
=
models
.
GenericIPAddressField
(
verbose_name
=
_
(
'Remote address'
),
blank
=
True
,
null
=
True
)
type
=
models
.
CharField
(
choices
=
TYPE_CHOICES
,
max_length
=
2
,
blank
=
True
,
verbose_name
=
_
(
'Terminal type'
))
type
=
models
.
CharField
(
choices
=
TYPE_CHOICES
,
max_length
=
3
,
blank
=
True
,
verbose_name
=
_
(
'Terminal type'
))
user
=
models
.
OneToOneField
(
User
,
verbose_name
=
'Application user'
,
null
=
True
)
url
=
models
.
CharField
(
max_length
=
100
,
blank
=
True
,
verbose_name
=
_
(
'URL to login'
))
is_accepted
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
'Is Accepted'
)
...
...
@@ -53,7 +53,7 @@ class Terminal(models.Model):
__str__
=
__unicode__
class
Meta
:
db_table
=
'applications'
ordering
=
(
'is_accepted'
,)
class
TerminalHeatbeat
(
models
.
Model
):
...
...
apps/applications/templates/applications/terminal_form.html
0 → 100644
View file @
d56f030d
apps/applications/templates/applications/terminal_list.html
View file @
d56f030d
...
...
@@ -2,15 +2,17 @@
{% load i18n static %}
{% block custom_head_css_js %}
{{ block.super }}
<style>
div
.dataTables_wrapper
div
.dataTables_filter
,
.dataTables_length
{
float
:
right
!important
;
}
div
.dataTables_wrapper
div
.dataTables_filter
{
margin-left
:
15px
;
}
#modal
.modal-body
{
max-height
:
200px
;
}
</style>
{% endblock %}
{% block table_search %}{% endblock %}
...
...
@@ -36,6 +38,8 @@
<tbody>
</tbody>
</table>
{% include 'applications/terminal_modal_accept.html' %}
{% endblock %}
{% block custom_foot_js %}
<script
src=
"{% static 'js/jquery.form.min.js' %}"
></script>
...
...
@@ -70,7 +74,7 @@ $(document).ready(function(){
var
delete_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn_delete" data-uid="99991937" data-name="99991938">{% trans "Delete" %}</a>'
.
replace
(
'99991937'
,
cellData
)
.
replace
(
'99991938'
,
rowData
.
name
);
var
accept_btn
=
'<a
href="" class="btn btn-xs btn-primary
">{% trans "Accept" %}</a> '
var
accept_btn
=
'<a
class="btn btn-xs btn-primary btn-accept" data-id="99991937
">{% trans "Accept" %}</a> '
.
replace
(
'99991937'
,
cellData
);
var
reject_btn
=
'<a href="" class="btn btn-xs btn-danger">{% trans "Reject" %}</a>'
if
(
rowData
.
is_accepted
)
{
...
...
@@ -86,12 +90,47 @@ $(document).ready(function(){
op_html
:
$
(
'#actions'
).
html
()
};
jumpserver
.
initDataTable
(
options
);
}).
on
(
'click'
,
'.btn_delete'
,
function
(){
var
$this
=
$
(
this
);
var
uid
=
$this
.
data
(
'uid'
);
var
name
=
$
(
this
).
data
(
'name'
);
var
the_url
=
'{% url "api-applications:terminal-detail" pk=99991937 %}'
.
replace
(
'99991937'
,
uid
);
objectDelete
(
$this
,
name
,
the_url
)
}).
on
(
'click'
,
'.btn-accept'
,
function
()
{
var
$this
=
$
(
this
);
var
terminal_id
=
$this
.
data
(
'id'
);
var
the_url
=
"{% url 'api-applications:terminal-detail' pk=99991937 %}"
.
replace
(
'99991937'
,
terminal_id
);
var
post_url
=
$
(
'#form_terminal_accept'
).
attr
(
'action'
).
replace
(
'99991937'
,
terminal_id
);
console
.
log
(
post_url
);
$
.
ajax
({
url
:
the_url
,
method
:
'GET'
,
success
:
function
(
data
)
{
$
(
'#id_name'
).
val
(
data
.
name
);
$
(
'#id_remote_addr'
).
val
(
data
.
remote_addr
);
$
(
'#id_type'
).
val
(
data
.
type
);
$
(
'#id_url'
).
val
(
data
.
url
);
$
(
'#id_comment'
).
val
(
data
.
comment
);
$
(
'#form_terminal_accept'
).
attr
(
'action'
,
post_url
)
}
});
$
(
'#modal_terminal_accept'
).
modal
({
show
:
true
});
}).
on
(
'click'
,
'#btn_terminal_accept'
,
function
()
{
var
$form
=
$
(
'#form_terminal_accept'
);
function
success
(
data
,
textStatus
,
jqXHR
)
{
if
(
data
.
success
===
false
)
{
console
.
log
(
data
.
msg
);
window
.
location
.
reload
()
}
else
{
console
.
log
(
data
.
msg
);
}
}
$form
.
ajaxSubmit
({
success
:
success
});
})
</script>
{% endblock %}
apps/applications/templates/applications/terminal_modal_accept.bak.html
0 → 100644
View file @
d56f030d
{% extends '_modal.html' %}
{% load static %}
{% load bootstrap %}
{% load i18n %}
{% block modal_body %}
<form
action=
""
method=
"post"
class=
"form-horizontal"
>
{% csrf_token %}
{{ form.name|bootstrap_horizontal }}
{{ form.remote_addr|bootstrap_horizontal }}
{{ form.type|bootstrap_horizontal }}
{{ form.url|bootstrap_horizontal }}
{{ form.comment|bootstrap_horizontal }}
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-2"
>
<button
class=
"btn btn-default"
type=
"reset"
>
{% trans 'Reset' %}
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"submit"
>
{% trans 'Submit' %}
</button>
</div>
</div>
</form>
{% endblock %}
{% block custom_foot_js %}
{% endblock %}
\ No newline at end of file
apps/applications/templates/applications/terminal_modal_accept.html
0 → 100644
View file @
d56f030d
{% extends '_modal.html' %}
{% load i18n %}
{% block modal_id %}modal_terminal_accept{% endblock %}
{% block modal_class %}modal-lg{% endblock %}
{% block modal_title%}{% trans "Accept terminal registration" %}{% endblock %}
{% block modal_body %}
{% load bootstrap %}
<form
action=
"{% url 'applications:terminal-modal-accept' pk="
99991937
"
%}"
method=
"post"
class=
"form-horizontal"
id=
"form_terminal_accept"
>
{% csrf_token %}
{{ form.name|bootstrap_horizontal }}
{{ form.remote_addr|bootstrap_horizontal }}
{{ form.type|bootstrap_horizontal }}
{{ form.url|bootstrap_horizontal }}
{{ form.comment|bootstrap_horizontal }}
</form>
{% endblock %}
{% block modal_confirm_id %}btn_terminal_accept{% endblock %}
\ No newline at end of file
apps/applications/urls/views_urls.py
View file @
d56f030d
...
...
@@ -11,4 +11,5 @@ 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'
),
]
apps/applications/views.py
View file @
d56f030d
# ~*~ coding: utf-8 ~*~
#
from
django.views.generic
import
ListView
,
UpdateView
,
DeleteView
from
django.views.generic
import
ListView
,
UpdateView
,
DeleteView
,
FormView
from
django.utils.translation
import
ugettext
as
_
from
django.urls
import
reverse_lazy
from
.models
import
Terminal
from
users.utils
import
AdminUserRequiredMixin
from
common.mixins
import
JSONResponseMixin
from
.forms
import
TerminalForm
class
TerminalListView
(
ListView
):
model
=
Terminal
template_name
=
'applications/terminal_list.html'
form_class
=
TerminalForm
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
TerminalListView
,
self
)
.
get_context_data
(
**
kwargs
)
context
.
update
({
'app'
:
_
(
'Terminal'
),
'action'
:
_
(
'Terminal list'
)})
context
.
update
({
'app'
:
_
(
'Terminal'
),
'action'
:
_
(
'Terminal list'
),
'form'
:
self
.
form_class
()
})
return
context
...
...
@@ -34,4 +41,30 @@ class TerminalUpdateView(UpdateView):
class
TerminalDeleteView
(
DeleteView
):
model
=
Terminal
template_name
=
'assets/delete_confirm.html'
success_url
=
reverse_lazy
(
'applications:applications-list'
)
\ No newline at end of file
success_url
=
reverse_lazy
(
'applications:applications-list'
)
class
TerminalModelAccept
(
AdminUserRequiredMixin
,
JSONResponseMixin
,
UpdateView
):
model
=
Terminal
form_class
=
TerminalForm
def
form_valid
(
self
,
form
):
terminal
=
form
.
save
()
terminal
.
is_accepted
=
True
terminal
.
save
()
data
=
{
'success'
:
True
,
'msg'
:
'success'
}
print
(
'Valid'
)
return
self
.
render_json_response
(
data
)
def
form_invalid
(
self
,
form
):
print
(
form
.
errors
)
data
=
{
'success'
:
False
,
'msg'
:
','
.
join
(
form
.
errors
)
}
return
self
.
render_json_response
(
data
)
apps/templates/base.html
View file @
d56f030d
...
...
@@ -16,6 +16,7 @@
<body>
<div
id=
"wrapper"
>
{% include '_left_side_bar.html' %}
<div
id=
"page-wrapper"
class=
"gray-bg"
>
{% include '_header_bar.html' %}
...
...
apps/users/templates/users/user_list.html
View file @
d56f030d
...
...
@@ -132,8 +132,7 @@ $(document).ready(function(){
$form
.
ajaxSubmit
({
success
:
success
});
})
})
.
on
(
'click'
,
'#btn_bulk_update'
,
function
(){
}).
on
(
'click'
,
'#btn_bulk_update'
,
function
(){
var
action
=
$
(
'#slct_bulk_update'
).
val
();
var
$data_table
=
$
(
'#user_list_table'
).
DataTable
();
var
id_list
=
[];
...
...
@@ -205,15 +204,13 @@ $(document).ready(function(){
default
:
break
;
}
})
.
on
(
'click'
,
'.btn_user_delete'
,
function
(){
}).
on
(
'click'
,
'.btn_user_delete'
,
function
(){
var
$this
=
$
(
this
);
var
name
=
$this
.
data
(
'name'
);
var
uid
=
$this
.
data
(
'uid'
);
var
the_url
=
'{% url "api-users:user-detail" pk=99991937 %}'
.
replace
(
'99991937'
,
uid
);
objectDelete
(
$this
,
name
,
the_url
);
})
.
on
(
'click'
,
'#btn_user_bulk_update'
,
function
(){
}).
on
(
'click'
,
'#btn_user_bulk_update'
,
function
(){
var
json_data
=
$
(
'#fm_user_bulk_update'
).
serializeObject
();
var
body
=
{};
body
.
enable_otp
=
(
json_data
.
enable_otp
===
'on'
)?
true
:
false
;
...
...
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