Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
87eed2e5
J
jumpserver
项目概览
gjl2004yn
/
jumpserver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jumpserver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
87eed2e5
编写于
12月 15, 2016
作者:
W
wangjun5
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add asset tool
上级
a737564a
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
229 addition
and
34 deletion
+229
-34
apps/assets/api.py
apps/assets/api.py
+9
-2
apps/assets/serializers.py
apps/assets/serializers.py
+13
-0
apps/assets/templates/assets/asset_detail.html
apps/assets/templates/assets/asset_detail.html
+156
-10
apps/assets/templates/assets/asset_group_list.html
apps/assets/templates/assets/asset_group_list.html
+10
-3
apps/assets/templates/assets/asset_list.html
apps/assets/templates/assets/asset_list.html
+10
-1
apps/assets/urls/api_urls.py
apps/assets/urls/api_urls.py
+5
-0
apps/users/templates/users/user_detail.html
apps/users/templates/users/user_detail.html
+20
-15
apps/users/templates/users/user_list.html
apps/users/templates/users/user_list.html
+6
-3
未找到文件。
apps/assets/api.py
浏览文件 @
87eed2e5
...
@@ -38,6 +38,10 @@ class AssetGroupViewSet(viewsets.ModelViewSet):
...
@@ -38,6 +38,10 @@ class AssetGroupViewSet(viewsets.ModelViewSet):
queryset
=
AssetGroup
.
objects
.
all
()
queryset
=
AssetGroup
.
objects
.
all
()
serializer_class
=
serializers
.
AssetGroupSerializer
serializer_class
=
serializers
.
AssetGroupSerializer
class
AssetUpdateGroupApi
(
generics
.
RetrieveUpdateAPIView
):
queryset
=
Asset
.
objects
.
all
()
serializer_class
=
serializers
.
AssetUpdateGroupSerializer
permission_classes
=
(
IsSuperUser
,)
class
IDCViewSet
(
viewsets
.
ModelViewSet
):
class
IDCViewSet
(
viewsets
.
ModelViewSet
):
"""API endpoint that allows IDC to be viewed or edited."""
"""API endpoint that allows IDC to be viewed or edited."""
...
@@ -45,18 +49,21 @@ class IDCViewSet(viewsets.ModelViewSet):
...
@@ -45,18 +49,21 @@ class IDCViewSet(viewsets.ModelViewSet):
serializer_class
=
serializers
.
IDCSerializer
serializer_class
=
serializers
.
IDCSerializer
permission_classes
=
(
IsSuperUser
,)
permission_classes
=
(
IsSuperUser
,)
class
AdminUserViewSet
(
viewsets
.
ModelViewSet
):
class
AdminUserViewSet
(
viewsets
.
ModelViewSet
):
queryset
=
AdminUser
.
objects
.
all
()
queryset
=
AdminUser
.
objects
.
all
()
serializer_class
=
serializers
.
AdminUserSerializer
serializer_class
=
serializers
.
AdminUserSerializer
permission_classes
=
(
IsSuperUser
,)
permission_classes
=
(
IsSuperUser
,)
class
SystemUserViewSet
(
viewsets
.
ModelViewSet
):
class
SystemUserViewSet
(
viewsets
.
ModelViewSet
):
queryset
=
SystemUser
.
objects
.
all
()
queryset
=
SystemUser
.
objects
.
all
()
serializer_class
=
serializers
.
SystemUserSerializer
serializer_class
=
serializers
.
SystemUserSerializer
permission_classes
=
(
IsSuperUser
,)
permission_classes
=
(
IsSuperUser
,)
class
SystemUserUpdateApi
(
generics
.
RetrieveUpdateAPIView
):
queryset
=
Asset
.
objects
.
all
()
serializer_class
=
serializers
.
AssetUpdateSystemUserSerializer
permission_classes
=
(
IsSuperUser
,)
# class IDCAssetsApi(generics.ListAPIView):
# class IDCAssetsApi(generics.ListAPIView):
# model = IDC
# model = IDC
...
...
apps/assets/serializers.py
浏览文件 @
87eed2e5
...
@@ -17,6 +17,19 @@ class AssetGroupSerializer(serializers.ModelSerializer):
...
@@ -17,6 +17,19 @@ class AssetGroupSerializer(serializers.ModelSerializer):
def
get_assets_amount
(
obj
):
def
get_assets_amount
(
obj
):
return
obj
.
assets
.
count
()
return
obj
.
assets
.
count
()
class
AssetUpdateGroupSerializer
(
serializers
.
ModelSerializer
):
groups
=
serializers
.
PrimaryKeyRelatedField
(
many
=
True
,
queryset
=
AssetGroup
.
objects
.
all
())
class
Meta
:
model
=
Asset
fields
=
[
'id'
,
'groups'
]
class
AssetUpdateSystemUserSerializer
(
serializers
.
ModelSerializer
):
system_users
=
serializers
.
PrimaryKeyRelatedField
(
many
=
True
,
queryset
=
SystemUser
.
objects
.
all
())
class
Meta
:
model
=
Asset
fields
=
[
'id'
,
'system_users'
]
class
AdminUserSerializer
(
serializers
.
ModelSerializer
):
class
AdminUserSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
class
Meta
:
...
...
apps/assets/templates/assets/asset_detail.html
浏览文件 @
87eed2e5
...
@@ -96,7 +96,7 @@
...
@@ -96,7 +96,7 @@
</tr>
</tr>
<tr>
<tr>
<td>
{% trans 'Asset status' %}:
</td>
<td>
{% trans 'Asset status' %}:
</td>
<td><b>
{{ asset.
get_status_display()
}}
</b></td>
<td><b>
{{ asset.
status
}}
</b></td>
</tr>
</tr>
<tr>
<tr>
<td>
{% trans 'Is active' %}:
</td>
<td>
{% trans 'Is active' %}:
</td>
...
@@ -205,9 +205,9 @@
...
@@ -205,9 +205,9 @@
<form>
<form>
<tr>
<tr>
<td
colspan=
"2"
class=
"no-borders"
>
<td
colspan=
"2"
class=
"no-borders"
>
<select
data-placeholder=
"{% trans 'Join asset groups' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
<select
data-placeholder=
"{% trans 'Join asset groups' %}"
id=
"groups_selected"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for asset_group in asset_groups_remain %}
{% for asset_group in asset_groups_remain %}
<option
value=
"{{ asset_group.id }}"
>
{{ asset_group.name }}
</option>
<option
value=
"{{ asset_group.id }}"
id=
"opt_{{ asset_group.id }}"
>
{{ asset_group.name }}
</option>
{% endfor %}
{% endfor %}
</select>
</select>
</td>
</td>
...
@@ -221,9 +221,9 @@
...
@@ -221,9 +221,9 @@
{% for asset_group in asset_groups %}
{% for asset_group in asset_groups %}
<tr>
<tr>
<td
><b
data-gid=
{{
asset_group.id
}}
>
{{ asset_group.name }}
</b></td>
<td
><b
class=
"bdg_group"
data-gid=
{{
asset_group.id
}}
>
{{ asset_group.name }}
</b></td>
<td>
<td>
<button
class=
"btn btn-danger pull-right btn-xs "
type=
"button"
><i
class=
"fa fa-minus"
></i></button>
<button
class=
"btn btn-danger pull-right btn-xs
btn_leave_group
"
type=
"button"
><i
class=
"fa fa-minus"
></i></button>
</td>
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
...
@@ -243,22 +243,22 @@
...
@@ -243,22 +243,22 @@
<td
colspan=
"2"
>
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select system user' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
<select
data-placeholder=
"{% trans 'Select system user' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for system_user in system_users_remain %}
{% for system_user in system_users_remain %}
<option
value=
"{{ system_user.id }}"
>
{{ system_user.name }}
</option>
<option
value=
"{{ system_user.id }}"
id=
"opt_{{ system_user.id }}"
>
{{ system_user.name }}
</option>
{% endfor %}
{% endfor %}
</select>
</select>
</td>
</td>
</tr>
</tr>
<tr
class=
"no-borders-tr"
>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<td
colspan=
"2"
>
<button
type=
"button"
class=
"btn btn-warning btn-sm"
>
{% trans 'Associate' %}
</button>
<button
type=
"button"
class=
"btn btn-warning btn-sm
btn-system-user
"
>
{% trans 'Associate' %}
</button>
</td>
</td>
</tr>
</tr>
</form>
</form>
{% for system_user in system_users %}
{% for system_user in system_users %}
<tr>
<tr>
<td
><b>
{{ system_user.name }}
</b></td>
<td
><b
class=
"bdg_group"
data-sid=
{{
system_user.id
}}
>
{{ system_user.name }}
</b></td>
<td>
<td>
<button
class=
"btn btn-danger btn-xs"
type=
"button"
style=
"float: right;"
><i
class=
"fa fa-minus"
></i></button>
<button
class=
"btn btn-danger btn-xs
pull-right btn_leave_system
"
type=
"button"
style=
"float: right;"
><i
class=
"fa fa-minus"
></i></button>
</td>
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
...
@@ -275,8 +275,154 @@
...
@@ -275,8 +275,154 @@
{% endblock %}
{% endblock %}
{% block custom_foot_js %}
{% block custom_foot_js %}
<script>
<script>
jumpserver
.
groups_selected
=
{};
function
updateAssetGroups
(
groups
)
{
var
the_url
=
"
{% url 'api-assets:asset-update-group' pk=asset.id %}
"
;
var
body
=
{
groups
:
Object
.
assign
([],
groups
)
};
var
success
=
function
(
data
)
{
// remove all the selected groups from select > option and rendered ul element;
$
(
'
.select2-selection__rendered
'
).
empty
();
$
(
'
#groups_selected
'
).
val
(
''
);
$
.
map
(
jumpserver
.
groups_selected
,
function
(
group_name
,
index
)
{
$
(
'
#opt_
'
+
index
).
remove
();
// change tr html of user groups.
$
(
'
.group_edit tbody
'
).
append
(
'
<tr>
'
+
'
<td><b class="bdg_group" data-gid="
'
+
index
+
'
">
'
+
group_name
+
'
</b></td>
'
+
'
<td><button class="btn btn-danger btn-xs pull-right btn_leave_group" type="button"><i class="fa fa-minus"></i></button></td>
'
+
'
</tr>
'
)
});
// clear jumpserver.groups_selected
jumpserver
.
groups_selected
=
{};
};
APIUpdateAttr
({
url
:
the_url
,
body
:
JSON
.
stringify
(
body
),
success
:
success
});
}
function
updateAssetSystem
(
system_users
)
{
var
the_url
=
"
{% url 'api-assets:asset-update-systemusers' pk=asset.id %}
"
;
var
body
=
{
system_users
:
Object
.
assign
([],
system_users
)
};
var
success
=
function
(
data
)
{
$
(
'
.select2-selection__rendered
'
).
empty
();
$
(
'
#groups_selected
'
).
val
(
''
);
$
.
map
(
jumpserver
.
groups_selected
,
function
(
name
,
index
)
{
$
(
'
#opt_
'
+
index
).
remove
();
$
(
'
.group_edit tbody
'
).
append
(
'
<tr>
'
+
'
<td><b class="bdg_group" data-sid="
'
+
index
+
'
">
'
+
name
+
'
</b></td>
'
+
'
<td><button class="btn btn-danger btn-xs pull-right btn_leave_system" type="button"><i class="fa fa-minus"></i></button></td>
'
+
'
</tr>
'
)
});
// clear jumpserver.groups_selected
jumpserver
.
groups_selected
=
{};
};
APIUpdateAttr
({
url
:
the_url
,
body
:
JSON
.
stringify
(
body
),
success
:
success
});
}
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
$
(
'
.select2
'
).
select2
();
$
(
'
.select2
'
).
select2
()
.
on
(
'
select2:select
'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
jumpserver
.
groups_selected
[
data
.
id
]
=
data
.
text
;
}).
on
(
'
select2:unselect
'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
delete
jumpserver
.
groups_selected
[
data
.
id
]
})
})
.
on
(
'
click
'
,
'
#is_active
'
,
function
()
{
var
the_url
=
'
{% url "api-assets:asset-detail" pk=asset.id %}
'
;
var
checked
=
$
(
this
).
prop
(
'
checked
'
);
var
body
=
{
'
is_active
'
:
checked
};
var
success
=
'
{% trans "Update Successfully!" %}
'
;
var
status
=
$
(
"
.ibox-content > table > tbody > tr:nth-child(13) > td:last >b
"
).
text
();
APIUpdateAttr
({
url
:
the_url
,
body
:
JSON
.
stringify
(
body
),
success_message
:
success
});
if
(
status
==
"
False
"
)
{
$
(
"
.ibox-content > table > tbody > tr:nth-child(13) > td:last >b
"
).
html
(
'
True
'
);
}
else
{
$
(
"
.ibox-content > table > tbody > tr:nth-child(13) > td:last >b
"
).
html
(
'
False
'
);
}
})
.
on
(
'
click
'
,
'
#btn_add_user_group
'
,
function
()
{
if
(
Object
.
keys
(
jumpserver
.
groups_selected
).
length
===
0
)
{
return
false
;
}
var
groups
=
$
(
'
.bdg_group
'
).
map
(
function
()
{
return
$
(
this
).
data
(
'
gid
'
);
}).
get
();
$
.
map
(
jumpserver
.
groups_selected
,
function
(
value
,
index
)
{
groups
.
push
(
parseInt
(
index
));
$
(
'
#opt_
'
+
index
).
remove
();
});
updateAssetGroups
(
groups
)
})
.
on
(
'
click
'
,
'
.btn_leave_group
'
,
function
()
{
var
$this
=
$
(
this
);
var
$tr
=
$this
.
closest
(
'
tr
'
);
var
$badge
=
$tr
.
find
(
'
.bdg_group
'
);
var
gid
=
$badge
.
data
(
'
gid
'
);
var
group_name
=
$badge
.
html
()
||
$badge
.
text
();
$
(
'
#groups_selected
'
).
append
(
'
<option value="
'
+
gid
+
'
" id="opt_
'
+
gid
+
'
">
'
+
group_name
+
'
</option>
'
);
$tr
.
remove
();
var
groups
=
$
(
'
.bdg_group
'
).
map
(
function
()
{
return
$
(
this
).
data
(
'
gid
'
);
}).
get
();
updateAssetGroups
(
groups
)
})
})
.
on
(
'
click
'
,
'
.btn-system-user
'
,
function
()
{
if
(
Object
.
keys
(
jumpserver
.
groups_selected
).
length
===
0
)
{
return
false
;
}
var
system_users
=
$
(
'
.bdg_group
'
).
map
(
function
()
{
return
$
(
this
).
data
(
'
sid
'
);
}).
get
();
$
.
map
(
jumpserver
.
groups_selected
,
function
(
value
,
index
)
{
system_users
.
push
(
parseInt
(
index
));
$
(
'
#opt_
'
+
index
).
remove
();
});
updateAssetSystem
(
system_users
)
})
.
on
(
'
click
'
,
'
.btn_leave_system
'
,
function
()
{
var
$this
=
$
(
this
);
var
$tr
=
$this
.
closest
(
'
tr
'
);
var
$badge
=
$tr
.
find
(
'
.bdg_group
'
);
var
sid
=
$badge
.
data
(
'
sid
'
);
var
name
=
$badge
.
html
()
||
$badge
.
text
();
$
(
'
#groups_selected
'
).
append
(
'
<option value="
'
+
sid
+
'
" id="opt_
'
+
sid
+
'
">
'
+
name
+
'
</option>
'
);
$tr
.
remove
();
var
system_users
=
$
(
'
.bdg_group
'
).
map
(
function
()
{
return
$
(
this
).
data
(
'
sid
'
);
}).
get
();
console
.
log
(
system_users
);
updateAssetSystem
(
system_users
)
})
</script>
</script>
{% endblock %}
{% endblock %}
apps/assets/templates/assets/asset_group_list.html
浏览文件 @
87eed2e5
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<div
class=
"uc pull-left m-l-5 m-r-5"
>
<div
class=
"uc pull-left m-l-5 m-r-5"
>
<a
href=
"{% url "
assets:asset-group-create
"
%}"
class=
"btn btn-sm btn-primary"
>
{% trans "Create asset group" %}
</a>
<a
href=
"{% url "
assets:asset-group-create
"
%}"
class=
"btn btn-sm btn-primary"
>
{% trans "Create asset group" %}
</a>
</div>
</div>
<table
class=
"table table-striped table-bordered table-hover "
id=
"a
dmin_user
_list_table"
>
<table
class=
"table table-striped table-bordered table-hover "
id=
"a
sset_groups
_list_table"
>
<thead>
<thead>
<tr>
<tr>
<th
class=
"text-center"
>
<th
class=
"text-center"
>
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
<script>
<script>
$
(
document
).
ready
(
function
(){
$
(
document
).
ready
(
function
(){
var
options
=
{
var
options
=
{
ele
:
$
(
'
#a
dmin_user
_list_table
'
),
ele
:
$
(
'
#a
sset_groups
_list_table
'
),
columnDefs
:
[
columnDefs
:
[
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
detail_btn
=
'
<a href="{% url "assets:asset-group-detail" pk=99991937 %}">
'
+
cellData
+
'
</a>
'
;
var
detail_btn
=
'
<a href="{% url "assets:asset-group-detail" pk=99991937 %}">
'
+
cellData
+
'
</a>
'
;
...
@@ -46,7 +46,14 @@ $(document).ready(function(){
...
@@ -46,7 +46,14 @@ $(document).ready(function(){
columns
:
[{
data
:
"
id
"
},
{
data
:
"
name
"
},
{
data
:
"
assets_amount
"
},
{
data
:
"
comment
"
},
{
data
:
"
id
"
}]
columns
:
[{
data
:
"
id
"
},
{
data
:
"
name
"
},
{
data
:
"
assets_amount
"
},
{
data
:
"
comment
"
},
{
data
:
"
id
"
}]
};
};
jumpserver
.
initDataTable
(
options
);
jumpserver
.
initDataTable
(
options
);
});
})
.
on
(
'
click
'
,
'
.btn_asset_group_delete
'
,
function
()
{
var
$this
=
$
(
this
);
var
name
=
$
(
this
).
closest
(
"
tr
"
).
find
(
"
:nth-child(2)
"
).
children
(
'
a
'
).
html
();
var
uid
=
$this
.
data
(
'
uid
'
);
var
the_url
=
'
{% url "api-assets:asset-group-detail" pk=99991937 %}
'
.
replace
(
'
99991937
'
,
uid
);
objectDelete
(
$this
,
name
,
the_url
);
});
</script>
</script>
{% endblock %}
{% endblock %}
apps/assets/templates/assets/asset_list.html
浏览文件 @
87eed2e5
...
@@ -127,8 +127,9 @@
...
@@ -127,8 +127,9 @@
}},
}},
{
targets
:
9
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
{
targets
:
9
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
update_btn
=
'
<a href="{% url "assets:asset-update" pk=99991937 %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>
'
.
replace
(
'
99991937
'
,
cellData
);
var
update_btn
=
'
<a href="{% url "assets:asset-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
);
var
del_btn
=
'
<a class="btn btn-xs btn-danger m-l-xs btn_
asset
_delete" data-uid="99991937">{% trans "Delete" %}</a>
'
.
replace
(
'
99991937
'
,
cellData
);
$
(
td
).
html
(
update_btn
+
del_btn
)
$
(
td
).
html
(
update_btn
+
del_btn
)
}}
}}
],
],
ajax_url
:
'
{% url "api-assets:asset-list" %}
'
,
ajax_url
:
'
{% url "api-assets:asset-list" %}
'
,
...
@@ -179,6 +180,14 @@
...
@@ -179,6 +180,14 @@
$form
.
ajaxSubmit
({
success
:
success
});
$form
.
ajaxSubmit
({
success
:
success
});
})
})
})
.
on
(
'
click
'
,
'
.btn_asset_delete
'
,
function
()
{
var
$this
=
$
(
this
);
var
name
=
$
(
this
).
closest
(
"
tr
"
).
find
(
"
:nth-child(2)
"
).
children
(
'
a
'
).
html
();
var
uid
=
$this
.
data
(
'
uid
'
);
var
the_url
=
'
{% url "api-assets:asset-detail" pk=99991937 %}
'
.
replace
(
'
99991937
'
,
uid
);
objectDelete
(
$this
,
name
,
the_url
);
});
});
</script>
</script>
{% endblock %}
{% endblock %}
\ No newline at end of file
apps/assets/urls/api_urls.py
浏览文件 @
87eed2e5
...
@@ -17,6 +17,11 @@ urlpatterns = [
...
@@ -17,6 +17,11 @@ urlpatterns = [
url
(
r
'^v1/assets_bulk/$'
,
api
.
AssetListUpdateApi
.
as_view
(),
name
=
'asset-bulk-update'
),
url
(
r
'^v1/assets_bulk/$'
,
api
.
AssetListUpdateApi
.
as_view
(),
name
=
'asset-bulk-update'
),
# url(r'^v1/idc/(?P<pk>[0-9]+)/assets/$', api.IDCAssetsApi.as_view(), name='api-idc-assets'),
# url(r'^v1/idc/(?P<pk>[0-9]+)/assets/$', api.IDCAssetsApi.as_view(), name='api-idc-assets'),
url
(
r
'^v1/system-user/auth/'
,
api
.
SystemUserAuthApi
.
as_view
(),
name
=
'system-user-auth'
),
url
(
r
'^v1/system-user/auth/'
,
api
.
SystemUserAuthApi
.
as_view
(),
name
=
'system-user-auth'
),
url
(
r
'^v1/assets/(?P<pk>\d+)/groups/$'
,
api
.
AssetUpdateGroupApi
.
as_view
(),
name
=
'asset-update-group'
),
url
(
r
'^v1/assets/(?P<pk>\d+)/system-users/$'
,
api
.
SystemUserUpdateApi
.
as_view
(),
name
=
'asset-update-systemusers'
),
]
]
urlpatterns
+=
router
.
urls
urlpatterns
+=
router
.
urls
...
...
apps/users/templates/users/user_detail.html
浏览文件 @
87eed2e5
...
@@ -255,16 +255,19 @@ function updateUserGroups(groups) {
...
@@ -255,16 +255,19 @@ function updateUserGroups(groups) {
success
:
success
success
:
success
});
});
}
}
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
$
(
'
.select2
'
).
select2
()
$
(
'
.select2
'
).
select2
()
.
on
(
'
select2:select
'
,
function
(
evt
)
{
.
on
(
'
select2:select
'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
var
data
=
evt
.
params
.
data
;
jumpserver
.
groups_selected
[
data
.
id
]
=
data
.
text
;
jumpserver
.
groups_selected
[
data
.
id
]
=
data
.
text
;
}).
on
(
'
select2:unselect
'
,
function
(
evt
)
{
})
.
on
(
'
select2:unselect
'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
var
data
=
evt
.
params
.
data
;
delete
jumpserver
.
groups_selected
[
data
.
id
]
delete
jumpserver
.
groups_selected
[
data
.
id
]
})
})
}).
on
(
'
click
'
,
'
#is_active
'
,
function
()
{
})
.
on
(
'
click
'
,
'
#is_active
'
,
function
()
{
var
the_url
=
"
{% url 'api-users:user-detail' pk=user.id %}
"
;
var
the_url
=
"
{% url 'api-users:user-detail' pk=user.id %}
"
;
var
checked
=
$
(
this
).
prop
(
'
checked
'
);
var
checked
=
$
(
this
).
prop
(
'
checked
'
);
var
body
=
{
var
body
=
{
...
@@ -276,7 +279,8 @@ $(document).ready(function() {
...
@@ -276,7 +279,8 @@ $(document).ready(function() {
body
:
JSON
.
stringify
(
body
),
body
:
JSON
.
stringify
(
body
),
success_message
:
success
success_message
:
success
});
});
}).
on
(
'
click
'
,
'
#enable_otp
'
,
function
()
{
})
.
on
(
'
click
'
,
'
#enable_otp
'
,
function
()
{
var
the_url
=
"
{% url 'api-users:user-detail' pk=user.id %}
"
;
var
the_url
=
"
{% url 'api-users:user-detail' pk=user.id %}
"
;
var
checked
=
$
(
this
).
prop
(
'
checked
'
);
var
checked
=
$
(
this
).
prop
(
'
checked
'
);
var
body
=
{
var
body
=
{
...
@@ -288,7 +292,8 @@ $(document).ready(function() {
...
@@ -288,7 +292,8 @@ $(document).ready(function() {
body
:
JSON
.
stringify
(
body
),
body
:
JSON
.
stringify
(
body
),
success_message
:
success
success_message
:
success
});
});
}).
on
(
'
click
'
,
'
#btn_join_group
'
,
function
()
{
})
.
on
(
'
click
'
,
'
#btn_join_group
'
,
function
()
{
if
(
Object
.
keys
(
jumpserver
.
groups_selected
).
length
===
0
)
{
if
(
Object
.
keys
(
jumpserver
.
groups_selected
).
length
===
0
)
{
return
false
;
return
false
;
}
}
...
...
apps/users/templates/users/user_list.html
浏览文件 @
87eed2e5
...
@@ -132,7 +132,8 @@ $(document).ready(function(){
...
@@ -132,7 +132,8 @@ $(document).ready(function(){
$form
.
ajaxSubmit
({
success
:
success
});
$form
.
ajaxSubmit
({
success
:
success
});
})
})
}).
on
(
'
click
'
,
'
#btn_bulk_update
'
,
function
(){
})
.
on
(
'
click
'
,
'
#btn_bulk_update
'
,
function
(){
var
action
=
$
(
'
#slct_bulk_update
'
).
val
();
var
action
=
$
(
'
#slct_bulk_update
'
).
val
();
var
$data_table
=
$
(
'
#user_list_table
'
).
DataTable
();
var
$data_table
=
$
(
'
#user_list_table
'
).
DataTable
();
var
id_list
=
[];
var
id_list
=
[];
...
@@ -204,13 +205,15 @@ $(document).ready(function(){
...
@@ -204,13 +205,15 @@ $(document).ready(function(){
default
:
default
:
break
;
break
;
}
}
}).
on
(
'
click
'
,
'
.btn_user_delete
'
,
function
(){
})
.
on
(
'
click
'
,
'
.btn_user_delete
'
,
function
(){
var
$this
=
$
(
this
);
var
$this
=
$
(
this
);
var
name
=
$this
.
data
(
'
name
'
);
var
name
=
$this
.
data
(
'
name
'
);
var
uid
=
$this
.
data
(
'
uid
'
);
var
uid
=
$this
.
data
(
'
uid
'
);
var
the_url
=
'
{% url "api-users:user-detail" pk=99991937 %}
'
.
replace
(
'
99991937
'
,
uid
);
var
the_url
=
'
{% url "api-users:user-detail" pk=99991937 %}
'
.
replace
(
'
99991937
'
,
uid
);
objectDelete
(
$this
,
name
,
the_url
);
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
json_data
=
$
(
'
#fm_user_bulk_update
'
).
serializeObject
();
var
body
=
{};
var
body
=
{};
body
.
enable_otp
=
(
json_data
.
enable_otp
===
'
on
'
)?
true
:
false
;
body
.
enable_otp
=
(
json_data
.
enable_otp
===
'
on
'
)?
true
:
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录