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
6a510dad
Commit
6a510dad
authored
Oct 24, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update some bug
parent
6b161d59
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
37 deletions
+66
-37
asset_list.html
apps/assets/templates/assets/asset_list.html
+1
-1
views.py
apps/assets/views.py
+5
-5
jumpserver.js
apps/static/js/jumpserver.js
+27
-18
api.py
apps/terminal/api.py
+9
-4
terminal_list.html
apps/terminal/templates/terminal/terminal_list.html
+13
-7
urls.py
apps/terminal/urls.py
+2
-0
views.py
apps/terminal/views.py
+8
-1
backends.py
apps/users/backends.py
+1
-1
No files found.
apps/assets/templates/assets/asset_list.html
View file @
6a510dad
...
...
@@ -146,7 +146,7 @@
"aoColumnDefs"
:
[
{
"bSortable"
:
false
,
"aTargets"
:
[
0
]
}],
"bAutoWidth"
:
false
,
"language"
:
{
"url"
:
"/static/js/plugins/dataTables/i18n/zh-hans.json"
"url"
:
"/static/js/plugins/dataTables/i18n/zh-hans.json"
},
columns
:
[
{
data
:
"checkbox"
},
...
...
apps/assets/views.py
View file @
6a510dad
...
...
@@ -74,8 +74,6 @@ class AssetCreateView(AdminUserRequiredMixin,CreateAssetTagsMiXin,CreateView):
return
super
(
AssetCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetUpdateView
(
AdminUserRequiredMixin
,
UpdateAssetTagsMiXin
,
UpdateView
):
model
=
Asset
form_class
=
AssetCreateForm
...
...
@@ -118,13 +116,13 @@ class AssetDetailView(DetailView):
kwargs
.
update
(
context
)
return
super
(
AssetDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetModalListView
(
AdminUserRequiredMixin
,
ListView
):
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
model
=
Asset
context_object_name
=
'asset_modal_list'
template_name
=
'assets/asset_modal_list.html'
def
get_context_data
(
self
,
**
kwargs
):
group_id
=
self
.
request
.
GET
.
get
(
'group_id'
)
tag_id
=
self
.
request
.
GET
.
get
(
'tag_id'
)
...
...
@@ -142,6 +140,7 @@ class AssetModalListView(AdminUserRequiredMixin, ListView):
kwargs
.
update
(
context
)
return
super
(
AssetModalListView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetGroupCreateView
(
AdminUserRequiredMixin
,
CreateView
):
model
=
AssetGroup
form_class
=
AssetGroupForm
...
...
@@ -160,7 +159,6 @@ class AssetGroupCreateView(AdminUserRequiredMixin, CreateView):
kwargs
.
update
(
context
)
return
super
(
AssetGroupCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
def
form_valid
(
self
,
form
):
asset_group
=
form
.
save
()
assets_id_list
=
self
.
request
.
POST
.
getlist
(
'assets'
,
[])
...
...
@@ -170,6 +168,7 @@ class AssetGroupCreateView(AdminUserRequiredMixin, CreateView):
asset_group
.
save
()
return
super
(
AssetGroupCreateView
,
self
)
.
form_valid
(
form
)
class
AssetGroupListView
(
AdminUserRequiredMixin
,
ListView
):
model
=
AssetGroup
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
...
...
@@ -218,6 +217,7 @@ class AssetGroupDetailView(SingleObjectMixin, AdminUserRequiredMixin, ListView):
kwargs
.
update
(
context
)
return
super
(
AssetGroupDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetGroupUpdateView
(
AdminUserRequiredMixin
,
UpdateView
):
model
=
AssetGroup
form_class
=
AssetGroupForm
...
...
@@ -296,6 +296,7 @@ class IDCCreateView(AdminUserRequiredMixin, CreateView):
# IDC_add_success_next(user)
return
super
(
IDCCreateView
,
self
)
.
form_valid
(
form
)
class
IDCUpdateView
(
AdminUserRequiredMixin
,
UpdateView
):
model
=
IDC
form_class
=
IDCForm
...
...
@@ -327,7 +328,6 @@ class IDCDeleteView(AdminUserRequiredMixin, DeleteView):
success_url
=
reverse_lazy
(
'assets:idc-list'
)
class
AdminUserListView
(
AdminUserRequiredMixin
,
ListView
):
model
=
AdminUser
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
...
...
apps/static/js/jumpserver.js
View file @
6a510dad
...
...
@@ -197,7 +197,7 @@ function APIUpdateAttr(props) {
type
:
props
.
method
||
"PATCH"
,
data
:
props
.
body
,
contentType
:
props
.
content_type
||
"application/json; charset=utf-8"
,
dataType
:
props
.
data_type
||
"json"
,
dataType
:
props
.
data_type
||
"json"
}).
done
(
function
(
data
,
textStatue
,
jqXHR
)
{
if
(
typeof
props
.
success
===
'function'
)
{
return
props
.
success
(
data
);
...
...
@@ -215,28 +215,37 @@ function APIUpdateAttr(props) {
}
// Sweet Alert for Delete
function
objectDelete
(
obj
,
name
,
url
){
function
objectDelete
(
obj
,
name
,
url
)
{
var
$this
=
$
(
this
);
function
doDelete
()
{
var
uid
=
$this
.
data
(
'uid'
);
var
body
=
{};
var
success
=
function
()
{
swal
(
'Deleted!'
,
"[ "
+
name
+
"]"
+
" has been deleted "
,
"success"
);
$
(
obj
).
parent
().
parent
().
remove
();
};
var
fail
=
function
()
{
swal
(
"Failed"
,
"Delete"
+
"[ "
+
name
+
" ]"
+
"failed"
,
"error"
);
};
APIUpdateAttr
({
url
:
url
,
body
:
JSON
.
stringify
(
body
),
method
:
'DELETE'
,
success
:
success
,
error
:
fail
});
}
swal
({
title
:
'Are you sure delete ?'
,
text
:
"
【"
+
name
+
"】
"
,
text
:
"
["
+
name
+
"]
"
,
type
:
"warning"
,
showCancelButton
:
true
,
cancelButtonText
:
'Cancel'
,
confirmButtonColor
:
"#DD6B55"
,
confirmButtonText
:
'
Yes, delete it!
'
,
confirmButtonText
:
'
Confirm
'
,
closeOnConfirm
:
false
},
function
()
{
$
.
ajax
({
type
:
"post"
,
url
:
url
,
data
:
{
},
dataType
:
"text"
,
success
:
function
(
data
)
{
swal
(
'Deleted!'
,
"【"
+
name
+
"】"
+
"has been deleted."
,
"success"
);
$
(
obj
).
parent
().
parent
().
remove
();
}
});
doDelete
()
});
}
...
...
@@ -279,7 +288,7 @@ jumpserver.initDataTable = function (options) {
$
(
td
).
html
(
'<div class="checkbox checkbox-default"><input type="checkbox" class="ipt_check"><label></label></div>'
);
}
},
{
className
:
'text-center'
,
targets
:
'_all'
}
,
{
className
:
'text-center'
,
targets
:
'_all'
}
];
columnDefs
=
options
.
columnDefs
?
options
.
columnDefs
.
concat
(
columnDefs
)
:
columnDefs
;
var
table
=
ele
.
DataTable
({
...
...
@@ -342,6 +351,6 @@ jumpserver.initDataTable = function (options) {
jumpserver
.
checked
=
false
;
table
.
rows
().
deselect
();
}
})
})
;
return
table
;
}
}
;
apps/terminal/api.py
View file @
6a510dad
# -*- coding: utf-8 -*-
#
from
rest_framework.generics
import
ListCreateAPIView
,
Create
APIView
from
rest_framework.generics
import
ListCreateAPIView
,
RetrieveUpdateDestroy
APIView
from
rest_framework.views
import
APIView
,
Response
from
rest_framework.permissions
import
AllowAny
...
...
@@ -18,7 +18,6 @@ class TerminalCreateListApi(ListCreateAPIView):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
name
=
unsign
(
request
.
data
.
get
(
'name'
,
''
))
print
(
name
)
if
name
:
terminal
=
get_object_or_none
(
Terminal
,
name
=
name
)
if
terminal
:
...
...
@@ -36,12 +35,18 @@ class TerminalCreateListApi(ListCreateAPIView):
terminal
=
Terminal
.
objects
.
create
(
name
=
name
,
ip
=
ip
)
return
Response
(
data
=
{
'data'
:
{
'name'
:
name
,
'ip'
:
terminal
.
ip
},
'msg'
:
'Need admin active it'
},
status
=
20
4
)
status
=
20
1
)
else
:
return
Response
(
data
=
{
'msg'
:
'Secrete key invalid'
},
status
=
401
)
class
TerminalHeatbeatApi
(
CreateAPIView
):
class
TerminalHeatbeatApi
(
List
CreateAPIView
):
model
=
TerminalHeatbeat
serializer_class
=
TerminalHeatbeatSerializer
permission_classes
=
(
IsSuperUserOrTerminalUser
,)
class
TerminalApiDetailUpdateDetailApi
(
RetrieveUpdateDestroyAPIView
):
queryset
=
Terminal
.
objects
.
all
()
serializer_class
=
TerminalSerializer
permission_classes
=
(
IsSuperUserOrTerminalUser
,)
apps/terminal/templates/terminal/terminal_list.html
View file @
6a510dad
...
...
@@ -47,10 +47,6 @@ $(document).ready(function(){
var
detail_btn
=
'<a href="{% url "users:user-detail" pk=99991937 %}">'
+
cellData
+
'</a>'
;
$
(
td
).
html
(
detail_btn
.
replace
(
'99991937'
,
rowData
.
id
));
}},
{
targets
:
4
,
createdCell
:
function
(
td
,
cellData
)
{
var
innerHtml
=
cellData
.
length
>
8
?
cellData
.
substring
(
0
,
8
)
+
'...'
:
cellData
;
$
(
td
).
html
(
'<a href="javascript:void(0);" data-toggle="tooltip" title="'
+
cellData
+
'">'
+
innerHtml
+
'</a>'
);
}},
{
targets
:
5
,
createdCell
:
function
(
td
,
cellData
)
{
if
(
!
cellData
)
{
$
(
td
).
html
(
'<i class="fa fa-times text-danger"></i>'
)
...
...
@@ -59,9 +55,13 @@ $(document).ready(function(){
}
}},
{
targets
:
6
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
update_btn
=
'<a href="{% url "terminal:terminal-update" pk=99991937 %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'
.
replace
(
'99991937'
,
cellData
);
var
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn_user_delete" data-uid="99991937">{% trans "Delete" %}</a>'
.
replace
(
'99991937'
,
cellData
);
$
(
td
).
html
(
update_btn
+
del_btn
)
console
.
log
(
rowData
.
name
);
var
update_btn
=
'<a href="{% url "terminal:terminal-update" pk=99991937 %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'
.
replace
(
'99991937'
,
cellData
);
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
);
$
(
td
).
html
(
update_btn
+
delete_btn
)
}}
],
ajax_url
:
'{% url "terminal:terminal-list-create-api" %}'
,
...
...
@@ -70,6 +70,12 @@ $(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 "terminal:terminal-detail-update-delete-api" pk=99991937 %}'
.
replace
(
'99991937'
,
uid
);
objectDelete
(
$this
,
name
,
the_url
)
})
</script>
{% endblock %}
apps/terminal/urls.py
View file @
6a510dad
...
...
@@ -16,5 +16,7 @@ urlpatterns = [
urlpatterns
+=
[
url
(
r'^v1/terminal/$'
,
api
.
TerminalCreateListApi
.
as_view
(),
name
=
'terminal-list-create-api'
),
url
(
r'^v1/terminal/(?P<pk>\d+)/$'
,
api
.
TerminalApiDetailUpdateDetailApi
.
as_view
(),
name
=
'terminal-detail-update-delete-api'
),
url
(
r'^v1/terminal-heatbeat/$'
,
api
.
TerminalHeatbeatApi
.
as_view
(),
name
=
'terminal-heatbeat-api'
),
]
apps/terminal/views.py
View file @
6a510dad
# ~*~ coding: utf-8 ~*~
#
from
django.views.generic
import
ListView
,
UpdateView
from
django.views.generic
import
ListView
,
UpdateView
,
DeleteView
from
django.utils.translation
import
ugettext
as
_
from
django.urls
import
reverse_lazy
...
...
@@ -29,3 +29,9 @@ class TerminalUpdateView(UpdateView):
context
=
super
(
TerminalUpdateView
,
self
)
.
get_context_data
(
**
kwargs
)
context
.
update
({
'app'
:
_
(
'Terminal'
),
'action'
:
_
(
'Update terminal'
)})
return
context
class
TerminalDeleteView
(
DeleteView
):
model
=
Terminal
template_name
=
'assets/delete_confirm.html'
success_url
=
reverse_lazy
(
'terminal:terminal-list'
)
\ No newline at end of file
apps/users/backends.py
View file @
6a510dad
...
...
@@ -41,7 +41,7 @@ class TerminalAuthentication(authentication.BaseAuthentication):
else
:
raise
exceptions
.
AuthenticationFailed
(
_
(
'Invalid sign.'
))
if
not
terminal
.
is_active
:
if
not
terminal
or
not
terminal
.
is_active
:
raise
exceptions
.
AuthenticationFailed
(
_
(
'Terminal inactive or deleted.'
))
terminal
.
is_authenticated
=
True
return
terminal
,
None
...
...
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