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
474f7e0f
Commit
474f7e0f
authored
Sep 30, 2016
by
江世峰
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of code.simcu.com:jumpserver/jumpserver
merge
parents
fd52a85d
d8143a67
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
180 additions
and
35 deletions
+180
-35
jumpserver.css
apps/static/css/jumpserver.css
+103
-7
jumpserver.js
apps/static/js/jumpserver.js
+12
-0
_modal.html
apps/templates/_modal.html
+1
-1
api.py
apps/users/api.py
+18
-6
serializers.py
apps/users/serializers.py
+2
-2
_select_user_modal.html
apps/users/templates/users/_select_user_modal.html
+23
-0
user_detail.html
apps/users/templates/users/user_detail.html
+2
-2
user_group_detail.html
apps/users/templates/users/user_group_detail.html
+0
-0
user_group_list.html
apps/users/templates/users/user_group_list.html
+1
-1
user_list.html
apps/users/templates/users/user_list.html
+13
-11
urls.py
apps/users/urls.py
+5
-5
No files found.
apps/static/css/jumpserver.css
View file @
474f7e0f
...
@@ -91,12 +91,108 @@ table.dataTable tbody td.selected td i.text-navy
...
@@ -91,12 +91,108 @@ table.dataTable tbody td.selected td i.text-navy
color
:
white
;
color
:
white
;
}
}
.m-0
{
div
.dataTables_wrapper
div
.dataTables_filter
,
margin
:
0px
!important
;
.dataTables_length
{
float
:
right
!important
;
}
}
.m-t-0
{
div
.dataTables_wrapper
div
.dataTables_filter
{
margin-top
:
0px
!important
;
margin-left
:
15px
;
}
.m-b-0
{
margin-bottom
:
0px
!important
;
}
.m-l-0
{
margin-left
:
0px
!important
;
}
.m-r-0
{
margin-right
:
0px
!important
;
}
.m-5
{
margin
:
5px
!important
;
}
.m-t-5
{
margin-top
:
5px
!important
;
}
.m-b-5
{
margin-bottom
:
5px
!important
;
}
.m-l-5
{
margin-left
:
5px
!important
;
}
.m-r-5
{
margin-right
:
5px
!important
;
}
.m-10
{
margin
:
10px
!important
;
}
.m-t-10
{
margin-top
:
10px
!important
;
}
.m-b-10
{
margin-bottom
:
10px
!important
;
}
.m-l-10
{
margin-left
:
10px
!important
;
}
.m-r-10
{
margin-right
:
10px
!important
;
}
.m-15
{
margin
:
15px
!important
;
}
.m-t-15
{
margin-top
:
15px
!important
;
}
.m-b-15
{
margin-bottom
:
15px
!important
;
}
.m-l-15
{
margin-left
:
15px
!important
;
}
.m-r-15
{
margin-right
:
15px
!important
;
}
.m-20
{
margin
:
20px
!important
;
}
.m-t-20
{
margin-top
:
20px
!important
;
}
.m-b-20
{
margin-bottom
:
20px
!important
;
}
.m-l-20
{
margin-left
:
20px
!important
;
}
.m-r-20
{
margin-right
:
20px
!important
;
}
.m-25
{
margin
:
25px
!important
;
}
.m-t-25
{
margin-top
:
25px
!important
;
}
.m-b-25
{
margin-bottom
:
25px
!important
;
}
.m-l-25
{
margin-left
:
25px
!important
;
}
.m-r-25
{
margin-right
:
25px
!important
;
}
.m-30
{
margin
:
30px
!important
;
}
.m-t-30
{
margin-top
:
30px
!important
;
}
.m-b-30
{
margin-bottom
:
30px
!important
;
}
.m-l-30
{
margin-left
:
30px
!important
;
}
.m-r-30
{
margin-right
:
30px
!important
;
}
}
apps/static/js/jumpserver.js
View file @
474f7e0f
...
@@ -257,6 +257,7 @@ $.fn.serializeObject = function()
...
@@ -257,6 +257,7 @@ $.fn.serializeObject = function()
return
o
;
return
o
;
};
};
var
jumpserver
=
{};
var
jumpserver
=
{};
jumpserver
.
checked
=
false
;
jumpserver
.
initDataTable
=
function
(
options
)
{
jumpserver
.
initDataTable
=
function
(
options
)
{
// options = {
// options = {
// ele *: $('#dataTable_id'),
// ele *: $('#dataTable_id'),
...
@@ -331,5 +332,16 @@ jumpserver.initDataTable = function (options) {
...
@@ -331,5 +332,16 @@ jumpserver.initDataTable = function (options) {
$
(
'#op'
).
html
(
options
.
op_html
||
''
);
$
(
'#op'
).
html
(
options
.
op_html
||
''
);
$
(
'#uc'
).
html
(
options
.
uc_html
||
''
);
$
(
'#uc'
).
html
(
options
.
uc_html
||
''
);
});
});
$
(
'.ipt_check_all'
).
on
(
'click'
,
function
()
{
if
(
!
jumpserver
.
checked
)
{
$
(
this
).
closest
(
'table'
).
find
(
'.ipt_check'
).
prop
(
'checked'
,
true
);
jumpserver
.
checked
=
true
;
table
.
rows
().
select
();
}
else
{
$
(
this
).
closest
(
'table'
).
find
(
'.ipt_check'
).
prop
(
'checked'
,
false
);
jumpserver
.
checked
=
false
;
table
.
rows
().
deselect
();
}
})
return
table
;
return
table
;
}
}
apps/templates/_modal.html
View file @
474f7e0f
{% load i18n %}
{% load i18n %}
<div
aria-hidden=
"true"
role=
"dialog"
id=
"{% block modal_id %}{% endblock %}"
class=
"modal inmodal"
>
<div
aria-hidden=
"true"
role=
"dialog"
id=
"{% block modal_id %}{% endblock %}"
class=
"modal inmodal"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-dialog
{% block modal_class %}{% endblock %}
"
>
<div
class=
"modal-content animated fadeIn"
>
<div
class=
"modal-content animated fadeIn"
>
<div
class=
"modal-header"
>
<div
class=
"modal-header"
>
<button
data-dismiss=
"modal"
class=
"close"
type=
"button"
><span
aria-hidden=
"true"
>
×
</span><span
class=
"sr-only"
>
Close
</span></button>
<button
data-dismiss=
"modal"
class=
"close"
type=
"button"
><span
aria-hidden=
"true"
>
×
</span><span
class=
"sr-only"
>
Close
</span></button>
...
...
apps/users/api.py
View file @
474f7e0f
...
@@ -9,7 +9,7 @@ from rest_framework import generics, status
...
@@ -9,7 +9,7 @@ from rest_framework import generics, status
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework_bulk
import
ListBulkCreateUpdateDestroyAPIView
from
rest_framework_bulk
import
ListBulkCreateUpdateDestroyAPIView
from
.serializers
import
UserSerializer
,
UserGroupSerializer
,
UserAttributeSerializer
,
UserGroup
EditSerializer
,
\
from
.serializers
import
UserSerializer
,
UserGroupSerializer
,
UserAttributeSerializer
,
GroupUser
EditSerializer
,
\
GroupEditSerializer
,
UserPKUpdateSerializer
,
UserBulkUpdateSerializer
GroupEditSerializer
,
UserPKUpdateSerializer
,
UserBulkUpdateSerializer
from
.models
import
User
,
UserGroup
from
.models
import
User
,
UserGroup
...
@@ -46,14 +46,14 @@ class UserAttributeApi(generics.RetrieveUpdateDestroyAPIView):
...
@@ -46,14 +46,14 @@ class UserAttributeApi(generics.RetrieveUpdateDestroyAPIView):
serializer_class
=
UserAttributeSerializer
serializer_class
=
UserAttributeSerializer
class
UserGroup
EditApi
(
generics
.
RetrieveUpdateAPIView
):
class
GroupUser
EditApi
(
generics
.
RetrieveUpdateAPIView
):
queryset
=
User
.
objects
.
all
()
queryset
=
User
.
objects
.
all
()
serializer_class
=
UserGroup
EditSerializer
serializer_class
=
GroupUser
EditSerializer
class
UserResetPasswordApi
(
generics
.
UpdateAPIView
):
class
UserResetPasswordApi
(
generics
.
UpdateAPIView
):
queryset
=
User
.
objects
.
all
()
queryset
=
User
.
objects
.
all
()
serializer_class
=
UserGroup
EditSerializer
serializer_class
=
GroupUser
EditSerializer
def
perform_update
(
self
,
serializer
):
def
perform_update
(
self
,
serializer
):
# Note: we are not updating the user object here.
# Note: we are not updating the user object here.
...
@@ -68,7 +68,7 @@ class UserResetPasswordApi(generics.UpdateAPIView):
...
@@ -68,7 +68,7 @@ class UserResetPasswordApi(generics.UpdateAPIView):
class
UserResetPKApi
(
generics
.
UpdateAPIView
):
class
UserResetPKApi
(
generics
.
UpdateAPIView
):
queryset
=
User
.
objects
.
all
()
queryset
=
User
.
objects
.
all
()
serializer_class
=
UserGroup
EditSerializer
serializer_class
=
GroupUser
EditSerializer
def
perform_update
(
self
,
serializer
):
def
perform_update
(
self
,
serializer
):
user
=
self
.
get_object
()
user
=
self
.
get_object
()
...
@@ -88,10 +88,22 @@ class UserUpdatePKApi(generics.UpdateAPIView):
...
@@ -88,10 +88,22 @@ class UserUpdatePKApi(generics.UpdateAPIView):
user
.
save
()
user
.
save
()
class
Group
DeleteApi
(
generics
.
DestroyAPIView
):
class
Group
EditApi
(
generics
.
RetrieveUpdate
DestroyAPIView
):
queryset
=
UserGroup
.
objects
.
all
()
queryset
=
UserGroup
.
objects
.
all
()
serializer_class
=
GroupEditSerializer
serializer_class
=
GroupEditSerializer
def
perform_update
(
self
,
serializer
):
users
=
serializer
.
validated_data
.
get
(
'users'
)
if
users
:
group
=
self
.
get_object
()
# Note: use `list` method to force hitting the db.
group_users
=
list
(
group
.
users
.
all
())
serializer
.
save
()
group
.
users
.
set
(
users
+
group_users
)
group
.
save
()
return
serializer
.
save
()
class
UserBulkUpdateApi
(
ListBulkCreateUpdateDestroyAPIView
):
class
UserBulkUpdateApi
(
ListBulkCreateUpdateDestroyAPIView
):
queryset
=
User
.
objects
.
all
()
queryset
=
User
.
objects
.
all
()
...
...
apps/users/serializers.py
View file @
474f7e0f
...
@@ -31,7 +31,7 @@ class GroupEditSerializer(serializers.ModelSerializer):
...
@@ -31,7 +31,7 @@ class GroupEditSerializer(serializers.ModelSerializer):
class
Meta
:
class
Meta
:
model
=
UserGroup
model
=
UserGroup
fields
=
[
'id'
,
'name'
,
'comment'
,
'date_created'
,
'created_by'
]
fields
=
[
'id'
,
'name'
,
'comment'
,
'date_created'
,
'created_by'
,
'users'
]
class
UserAttributeSerializer
(
serializers
.
ModelSerializer
):
class
UserAttributeSerializer
(
serializers
.
ModelSerializer
):
...
@@ -41,7 +41,7 @@ class UserAttributeSerializer(serializers.ModelSerializer):
...
@@ -41,7 +41,7 @@ class UserAttributeSerializer(serializers.ModelSerializer):
fields
=
[
'avatar'
,
'wechat'
,
'phone'
,
'enable_otp'
,
'comment'
,
'is_active'
,
'name'
]
fields
=
[
'avatar'
,
'wechat'
,
'phone'
,
'enable_otp'
,
'comment'
,
'is_active'
,
'name'
]
class
UserGroup
EditSerializer
(
serializers
.
ModelSerializer
):
class
GroupUser
EditSerializer
(
serializers
.
ModelSerializer
):
groups
=
serializers
.
PrimaryKeyRelatedField
(
many
=
True
,
queryset
=
UserGroup
.
objects
.
all
())
groups
=
serializers
.
PrimaryKeyRelatedField
(
many
=
True
,
queryset
=
UserGroup
.
objects
.
all
())
class
Meta
:
class
Meta
:
...
...
apps/users/templates/users/_select_user_modal.html
0 → 100644
View file @
474f7e0f
{% extends '_modal.html' %}
{% load i18n %}
{% block modal_class %}modal-lg{% endblock %}
{% block modal_id %}select_user_modal{% endblock %}
{% block modal_title%}{% trans "Please Select User" %}{% endblock %}
{% block modal_body %}
<table
class=
"table table-striped table-bordered table-hover "
id=
"select_user_table"
>
<thead>
<tr>
<th
class=
"text-center"
>
<div
class=
"checkbox checkbox-default"
><input
id=
""
type=
"checkbox"
class=
"ipt_check_all"
><label></label></div>
</th>
<th
class=
"text-center"
>
{% trans 'Name' %}
</a></th>
<th
class=
"text-center"
>
{% trans 'Username' %}
</a></th>
<th
class=
"text-center"
>
{% trans 'Role' %}
</th>
<th
class=
"text-center"
>
{% trans 'User group' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset num' %}
</th>
<th
class=
"text-center"
>
{% trans 'Active' %}
</a></th>
</tr>
</thead>
</table>
{% endblock %}
{% block modal_confirm_id %}btn_select_user{% endblock %}
apps/users/templates/users/user_detail.html
View file @
474f7e0f
...
@@ -222,7 +222,7 @@
...
@@ -222,7 +222,7 @@
jumpserver
.
selected_groups
=
{};
jumpserver
.
selected_groups
=
{};
function
updateUserGroups
(
user_groups
)
{
function
updateUserGroups
(
user_groups
)
{
var
the_url
=
"{% url 'users:
user-group
-edit-api' pk=user_object.id %}"
;
var
the_url
=
"{% url 'users:
group-user
-edit-api' pk=user_object.id %}"
;
var
body
=
{
var
body
=
{
id
:
{{
user_object
.
id
}},
id
:
{{
user_object
.
id
}},
groups
:
Object
.
assign
([],
user_groups
)
groups
:
Object
.
assign
([],
user_groups
)
...
@@ -237,7 +237,7 @@ function updateUserGroups(user_groups) {
...
@@ -237,7 +237,7 @@ function updateUserGroups(user_groups) {
$
(
'.group_edit tbody'
).
append
(
$
(
'.group_edit tbody'
).
append
(
'<tr>'
+
'<tr>'
+
'<td><b class="bdg_user_group" data-gid="'
+
index
+
'">'
+
group_name
+
'</b></td>'
+
'<td><b class="bdg_user_group" data-gid="'
+
index
+
'">'
+
group_name
+
'</b></td>'
+
'<td><button class="btn btn-danger btn-
sm
pull-right btn_delete_user_group" type="button"><i class="fa fa-minus"></i></button></td>'
+
'<td><button class="btn btn-danger btn-
xs
pull-right btn_delete_user_group" type="button"><i class="fa fa-minus"></i></button></td>'
+
'</tr>'
'</tr>'
)
)
});
});
...
...
apps/users/templates/users/user_group_detail.html
View file @
474f7e0f
This diff is collapsed.
Click to expand it.
apps/users/templates/users/user_group_list.html
View file @
474f7e0f
...
@@ -65,7 +65,7 @@ $(document).on('click', '.btn_delete_user_group', function(){
...
@@ -65,7 +65,7 @@ $(document).on('click', '.btn_delete_user_group', function(){
var
$this
=
$
(
this
);
var
$this
=
$
(
this
);
function
doDelete
()
{
function
doDelete
()
{
var
group_id
=
$this
.
data
(
'gid'
);
var
group_id
=
$this
.
data
(
'gid'
);
var
the_url
=
"{% url 'users:user-group-
delete
-api' 99991937 %}"
.
replace
(
'99991937'
,
group_id
);
var
the_url
=
"{% url 'users:user-group-
edit
-api' 99991937 %}"
.
replace
(
'99991937'
,
group_id
);
var
body
=
{};
var
body
=
{};
var
success
=
function
()
{
var
success
=
function
()
{
var
msg
=
"{% trans 'Group Deleted.' %}"
;
var
msg
=
"{% trans 'Group Deleted.' %}"
;
...
...
apps/users/templates/users/user_list.html
View file @
474f7e0f
...
@@ -2,6 +2,19 @@
...
@@ -2,6 +2,19 @@
{% load i18n static %}
{% load i18n static %}
{% get_current_language as LANGUAGE_CODE %}
{% get_current_language as LANGUAGE_CODE %}
{% load common_tags %}
{% load common_tags %}
{% 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
;
}
</style>
{% endblock %}
{% block table_search %}{% endblock %}
{% block table_search %}{% endblock %}
{% block table_container %}
{% block table_container %}
<div
class=
"uc pull-left"
><a
href=
"{% url "
users:user-create
"
%}"
class=
"btn btn-sm btn-primary"
>
{% trans "Create user" %}
</a></div>
<div
class=
"uc pull-left"
><a
href=
"{% url "
users:user-create
"
%}"
class=
"btn btn-sm btn-primary"
>
{% trans "Create user" %}
</a></div>
...
@@ -43,7 +56,6 @@
...
@@ -43,7 +56,6 @@
{% endblock %}
{% endblock %}
{% block custom_foot_js %}
{% block custom_foot_js %}
<script>
<script>
jumpserver
.
checked
=
false
;
$
(
document
).
ready
(
function
(){
$
(
document
).
ready
(
function
(){
var
options
=
{
var
options
=
{
ele
:
$
(
'#user_list_table'
),
ele
:
$
(
'#user_list_table'
),
...
@@ -169,16 +181,6 @@ $(document).ready(function(){
...
@@ -169,16 +181,6 @@ $(document).ready(function(){
},
function
()
{
},
function
()
{
doDelete
();
doDelete
();
});
});
}).
on
(
'click'
,
'.ipt_check_all'
,
function
(){
if
(
!
jumpserver
.
checked
)
{
$
(
this
).
closest
(
'table'
).
find
(
'.ipt_check'
).
prop
(
'checked'
,
true
);
jumpserver
.
checked
=
true
;
$
(
'#user_list_table'
).
DataTable
().
rows
().
select
();
}
else
{
$
(
this
).
closest
(
'table'
).
find
(
'.ipt_check'
).
prop
(
'checked'
,
false
);
jumpserver
.
checked
=
false
;
$
(
'#user_list_table'
).
DataTable
().
rows
().
deselect
();
}
}).
on
(
'click'
,
'#btn_user_bulk_update'
,
function
(){
}).
on
(
'click'
,
'#btn_user_bulk_update'
,
function
(){
var
json_data
=
$
(
'#fm_user_bulk_update'
).
serializeObject
();
var
json_data
=
$
(
'#fm_user_bulk_update'
).
serializeObject
();
var
body
=
{};
var
body
=
{};
...
...
apps/users/urls.py
View file @
474f7e0f
...
@@ -46,10 +46,10 @@ urlpatterns += [
...
@@ -46,10 +46,10 @@ urlpatterns += [
url
(
r'^v1/user-groups$'
,
api
.
UserGroupListAddApi
.
as_view
(),
name
=
'user-group-list-api'
),
url
(
r'^v1/user-groups$'
,
api
.
UserGroupListAddApi
.
as_view
(),
name
=
'user-group-list-api'
),
url
(
r'^v1/user-groups/(?P<pk>[0-9]+)$'
,
url
(
r'^v1/user-groups/(?P<pk>[0-9]+)$'
,
api
.
UserGroupDetailDeleteUpdateApi
.
as_view
(),
name
=
'user-group-detail-api'
),
api
.
UserGroupDetailDeleteUpdateApi
.
as_view
(),
name
=
'user-group-detail-api'
),
url
(
r'^v1/user-groups/
group/
(?P<pk>\d+)/user/(?P<uid>\d+)/$'
,
url
(
r'^v1/user-groups/(?P<pk>\d+)/user/(?P<uid>\d+)/$'
,
api
.
DeleteUserFromGroupApi
.
as_view
(),
name
=
'delete-user-from-group-api'
),
api
.
DeleteUserFromGroupApi
.
as_view
(),
name
=
'delete-user-from-group-api'
),
url
(
r'^v1/user-groups/(?P<pk>[0-9]+)/
edit
$'
,
url
(
r'^v1/user-groups/(?P<pk>[0-9]+)/
users/
$'
,
api
.
UserGroupEditApi
.
as_view
(),
name
=
'user-group
-edit-api'
),
api
.
GroupUserEditApi
.
as_view
(),
name
=
'group-user
-edit-api'
),
url
(
r'^v1/user-groups/(?P<pk>[0-9]+)/
delete/$'
,
api
.
GroupDelete
Api
.
as_view
(),
url
(
r'^v1/user-groups/(?P<pk>[0-9]+)/
edit/$'
,
api
.
GroupEdit
Api
.
as_view
(),
name
=
'user-group-
delete
-api'
),
name
=
'user-group-
edit
-api'
),
]
]
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