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
1338d25b
Commit
1338d25b
authored
May 10, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
fix bug
parents
9f171da5
f994c4d1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
201 additions
and
125 deletions
+201
-125
connect.py
connect.py
+4
-1
views.py
jperm/views.py
+2
-0
perm_role_detail.html
templates/jperm/perm_role_detail.html
+192
-119
perm_role_list.html
templates/jperm/perm_role_list.html
+1
-3
perm_rule_list.html
templates/jperm/perm_rule_list.html
+1
-1
perm_sudo_list.html
templates/jperm/perm_sudo_list.html
+1
-1
No files found.
connect.py
View file @
1338d25b
...
...
@@ -518,7 +518,10 @@ class Nav(object):
@staticmethod
def
get_max_asset_property_length
(
assets
,
property_
=
'hostname'
):
return
max
([
len
(
getattr
(
asset
,
property_
))
for
asset
in
assets
])
try
:
return
max
([
len
(
getattr
(
asset
,
property_
))
for
asset
in
assets
])
except
ValueError
:
return
30
def
print_search_result
(
self
):
hostname_max_length
=
self
.
get_max_asset_property_length
(
self
.
search_result
)
...
...
jperm/views.py
View file @
1338d25b
...
...
@@ -16,6 +16,7 @@ from jperm.ansible_api import MyTask
from
jperm.perm_api
import
get_role_info
,
get_role_push_host
from
jumpserver.api
import
my_render
,
get_object
,
CRYPTOR
# 设置PERM APP Log
from
jumpserver.api
import
logger
#logger = set_log(LOG_LEVEL, filename='jumpserver_perm.log')
...
...
@@ -416,6 +417,7 @@ def perm_role_detail(request):
users
=
role_info
.
get
(
"users"
)
user_groups
=
role_info
.
get
(
"user_groups"
)
pushed_asset
,
need_push_asset
=
get_role_push_host
(
get_object
(
PermRole
,
id
=
role_id
))
except
ServerError
,
e
:
logger
.
warning
(
e
)
...
...
templates/jperm/perm_role_detail.html
View file @
1338d25b
...
...
@@ -30,13 +30,15 @@
<div
class=
"ibox-content"
>
<div>
<div
class=
"text-left"
>
<table
class=
"table"
id=
"ugedit"
>
<td
class=
"text-navy text-left"
>
时间
</td>
<td
class=
"text-navy text-right"
>
名称
</td>
<table
class=
"table"
id=
"ugedit"
>
<td
class=
"text-navy text-left"
>
时间
</td>
<td
class=
"text-navy text-right"
>
名称
</td>
{% for rule in rules %}
<tr
class=
"gradeX"
>
<td
class=
"text-left"
>
{{ rule.date_added | date:"Y-m-d H:i:s"}}
</td>
<td
class=
"text-right"
>
<a
href=
"{% url 'rule_detail' %}?id={{ rule.id }}"
>
{{ rule.name }}
</a>
</td>
<td
class=
"text-left"
>
{{ rule.date_added | date:"Y-m-d H:i:s" }}
</td>
<td
class=
"text-right"
><a
href=
"{% url 'rule_detail' %}?id={{ rule.id }}"
>
{{ rule.name }}
</a>
</td>
</tr>
{% endfor %}
</table>
...
...
@@ -44,8 +46,7 @@
</div>
</div>
</div>
</div>
<div
class=
"col-sm-4"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
class=
"label label-primary"
><b>
授权用户/用户组
</b></span>
...
...
@@ -68,37 +69,39 @@
</div>
</div>
<div
class=
"ibox-content"
>
<div
class=
"text-center"
>
<table
class=
"table"
id=
"agedit"
>
<td
class=
"text-navy text-left"
>
用户
</td>
<td
class=
"text-navy text-right"
>
用户组
</td>
<tr>
<td>
<table
class=
"table progress-striped text-left"
>
<div
class=
"text-center"
>
<table
class=
"table"
id=
"agedit"
>
<td
class=
"text-navy text-left"
>
用户
</td>
<td
class=
"text-navy text-right"
>
用户组
</td>
<tr>
<td>
<table
class=
"table progress-striped text-left"
>
{% for user in users %}
<tr
class=
"gradeX"
>
<td>
<a
href=
"{% url 'user_detail' %}?id={{ user.id }}"
>
{{ user.name }}
</a>
</td>
<td>
<a
href=
"{% url 'user_detail' %}?id={{ user.id }}"
>
{{ user.name }}
</a>
</td>
</tr>
{% endfor %}
</table>
</td>
<td>
<table
class=
"table progress-striped text-right"
>
</table>
</td>
<td>
<table
class=
"table progress-striped text-right"
>
{% for group in user_groups %}
<tr
class=
"gradeX-"
>
<td>
<a
href=
"{% url 'user_group_list' %}?id={{ group.id }}"
>
{{ group.name }}
</a>
</td>
<td>
<a
href=
"{% url 'user_group_list' %}?id={{ group.id }}"
>
{{ group.name }}
</a>
</td>
</tr>
{% endfor %}
</table>
</td>
</table>
</td>
</tr>
</table>
</div>
</div>
</div>
</tr>
</table>
</div>
</div>
<div
class=
"col-sm-4"
>
</div
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
class=
"label label-primary"
><b>
授权主机组/主机组
</b></span>
...
...
@@ -122,26 +125,30 @@
</div>
<div
class=
"ibox-content"
>
<div
class=
"text-center"
>
<table
class=
"table"
id=
"agedit"
>
<table
class=
"table"
id=
"agedit"
>
<td
class=
"text-navy text-left"
>
主机
</td>
<td
class=
"text-navy text-right"
>
主机组
</td>
<tr>
<td>
<table
class=
"table progress-striped text-left"
>
{% for asset in assets %}
<tr
class=
"gradeX"
>
<td>
<a
href=
"{% url 'asset_detail' %}?id={{ asset.id }}"
>
{{ asset.ip }}
</a>
</td>
</tr>
{% endfor %}
{% for asset in assets %}
<tr
class=
"gradeX"
>
<td>
<a
href=
"{% url 'asset_detail' %}?id={{ asset.id }}"
>
{{ asset.ip }}
</a>
</td>
</tr>
{% endfor %}
</table>
</td>
<td>
<table
class=
"table progress-striped text-right"
>
{% for group in asset_groups %}
<tr
class=
"gradeX-"
>
<td>
<a
href=
"{% url 'asset_list' %}?group_id={{ group.id }}"
>
{{ group.name }}
</a>
</td>
</tr>
{% endfor %}
{% for group in asset_groups %}
<tr
class=
"gradeX-"
>
<td>
<a
href=
"{% url 'asset_list' %}?group_id={{ group.id }}"
>
{{ group.name }}
</a>
</td>
</tr>
{% endfor %}
</table>
</td>
</tr>
...
...
@@ -150,9 +157,70 @@
</div>
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-sm-6"
>
<div
class=
"col-sm-8"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
class=
"label label-danger"
><b>
{{ role.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>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
>
<div>
<div
class=
"text-left"
>
<table
class=
"table table-striped"
id=
"ugedit"
>
<a
class=
"btn btn-xs btn-danger del_muti"
>
删除
</a><span>
</span>
<a
class=
"btn btn-xs btn-primary re_push"
>
重新推送
</a>
<thead>
<tr>
<th
class=
"text-center"
>
<input
type=
"checkbox"
id=
"check_push"
onclick=
"checkAll('check_push', 'asset_id')"
>
</th>
<th
class=
"text-center"
>
主机
</th>
<th
class=
"text-center"
>
密钥
</th>
<th
class=
"text-center"
>
结果
</th>
<th
class=
"text-center"
>
操作
</th>
</tr>
</thead>
<tbody>
{% for asset, info in pushed_asset.items %}
{% if not info.success %}
<tr
class=
"gradeX"
>
<th
class=
"text-center"
>
<input
type=
"checkbox"
name=
"asset_id"
value=
"{{ asset.id }}"
>
</th>
<td
class=
"text-center"
>
{{ asset.hostname }}
</td>
<td
class=
"text-center"
>
{{ info.key | yesno:"是,否,未知" }}
</td>
{% if info.success %}
<td
class=
"text-center"
style=
"color: #1ab394;"
>
{{ info.success | yesno:"成功,失败,未知" }}
</td>
{% else %}
<td
class=
"text-center push_failed"
style=
"color: #ec4758;cursor: help"
title=
"{{ info.result }}"
>
{{ info.success | yesno:"成功,失败,未知" }}
</td>
{% endif %}
<td
class=
"text-center"
><a
class=
"fa fa-times del"
href=
"{% url 'role_recycle' %}?role_id={{ role.id }}&asset_id={{ asset.id }}"
style=
"color: #ec4758;"
></a></td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
class=
"label label-primary"
><b>
{{ role.name }} - 推送主机
</b></span>
...
...
@@ -177,20 +245,20 @@
<div
class=
"ibox-content"
>
<div>
<div
class=
"text-left"
>
<table
class=
"table table-striped"
id=
"ugedit"
>
<table
class=
"table table-striped"
id=
"ugedit"
>
<a
class=
"btn btn-xs btn-danger del_muti"
>
删除
</a><span>
</span>
<a
class=
"btn btn-xs btn-primary re_push"
>
重新推送
</a>
<thead>
<tr>
<th
class=
"text-center"
>
<input
type=
"checkbox"
id=
"check_push"
onclick=
"checkAll('check_push', 'asset_id')"
>
</th
>
<th
class=
"text-center"
>
主机
</th>
<th
class=
"text-center"
>
密钥
</th>
<th
class=
"text-center"
>
密码
</th>
<th
class=
"text-center"
>
结果
</th>
<th
class=
"text-center"
>
操作
</th>
</tr>
<tr>
<th
class=
"text-center"
>
<input
type=
"checkbox"
id=
"check_push"
onclick=
"checkAll('check_push', 'asset_id')"
>
</th>
<th
class=
"text-center"
>
主机
</th>
<th
class=
"text-center"
>
密钥
</th>
<th
class=
"text-center"
>
结果
</th>
<th
class=
"text-center"
>
操作
</th>
</tr>
</thead>
<tbody>
{% for asset, info in pushed_asset.items %}
...
...
@@ -200,13 +268,19 @@
</th>
<td
class=
"text-center"
>
{{ asset.hostname }}
</td>
<td
class=
"text-center"
>
{{ info.key | yesno:"是,否,未知" }}
</td>
<td
class=
"text-center"
>
{{ info.password | yesno:"是,否,未知" }}
</td>
{% if info.success %}
<td
class=
"text-center"
style=
"color: #1ab394;"
>
{{ info.success | yesno:"成功,失败,未知" }}
</td>
<td
class=
"text-center"
style=
"color: #1ab394;"
>
{{ info.success | yesno:"成功,失败,未知" }}
</td>
{% else %}
<td
class=
"text-center push_failed"
style=
"color: #ec4758;cursor: help"
title=
"{{ info.result }}"
>
{{ info.success | yesno:"成功,失败,未知" }}
</td>
<td
class=
"text-center push_failed"
style=
"color: #ec4758;cursor: help"
title=
"{{ info.result }}"
>
{{ info.success | yesno:"成功,失败,未知" }}
</td>
{% endif %}
<td
class=
"text-center"
><a
class=
"fa fa-times del"
href=
"{% url 'role_recycle' %}?role_id={{ role.id }}&asset_id={{ asset.id }}"
style=
"color: #ec4758;"
></a></td>
<td
class=
"text-center"
>
<a
class=
"fa fa-times del"
href=
"{% url 'role_recycle' %}?role_id={{ role.id }}&asset_id={{ asset.id }}"
style=
"color: #ec4758;"
>
</a>
</td>
</tr>
{% endfor %}
</tbody>
...
...
@@ -215,9 +289,7 @@
</div>
</div>
</div>
</div>
<div
class=
"col-sm-4"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
class=
"label label-danger"
><b>
{{ role.name }} - 未推送主机
</b></span>
...
...
@@ -236,16 +308,17 @@
<div
class=
"ibox-content"
>
<div>
<div
class=
"text-left"
>
<table
class=
"table table-striped"
>
<table
class=
"table table-striped"
>
<a
class=
"btn btn-xs btn-primary push_muti"
>
推送
</a>
<thead>
<tr>
<th
class=
"text-center"
>
<input
type=
"checkbox"
id=
"check_no_push"
onclick=
"checkAll('check_no_push', 'asset_no_push_id')"
>
</th>
<th
class=
"text-center"
>
主机
</th>
<th
class=
"text-center"
>
IP
</th>
</tr>
<tr>
<th
class=
"text-center"
>
<input
type=
"checkbox"
id=
"check_no_push"
onclick=
"checkAll('check_no_push', 'asset_no_push_id')"
>
</th>
<th
class=
"text-center"
>
主机
</th>
<th
class=
"text-center"
>
IP
</th>
</tr>
</thead>
<tbody>
{% for asset in need_push_asset %}
...
...
@@ -272,66 +345,65 @@
{% endblock %}
{% block self_footer_js %}
<script>
$
(
document
).
ready
(
function
(){
$
(
'.del'
).
click
(
function
(){
var
url
=
$
(
this
).
attr
(
'href'
);
$
.
get
(
url
,
{},
function
(
data
){
location
.
reload
()
}
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.del'
).
click
(
function
()
{
var
url
=
$
(
this
).
attr
(
'href'
);
$
.
get
(
url
,
{},
function
(
data
)
{
location
.
reload
()
}
);
return
false
;
});
);
return
false
;
});
$
(
'.del_muti'
).
click
(
function
()
{
var
check_array
=
[];
if
(
confirm
(
"确定删除"
))
{
$
(
".gradeX input[name='asset_id']:checked"
).
each
(
function
()
{
check_array
.
push
(
$
(
this
).
attr
(
"value"
))
});
var
url
=
'/jperm/role/recycle/?role_id={{ role.id }}&asset_id='
+
check_array
.
join
(
','
);
console
.
log
(
check_array
);
$
.
get
(
url
,
{},
function
(
data
)
{
location
.
reload
()
}
)
}
return
false
;
});
$
(
'.del_muti'
).
click
(
function
(){
var
check_array
=
[];
if
(
confirm
(
"确定删除"
))
{
$
(
".gradeX input[name='asset_id']:checked"
).
each
(
function
()
{
$
(
'.push_muti'
).
click
(
function
()
{
var
check_array
=
[];
$
(
".gradeX input[name='asset_no_push_id']:checked"
).
each
(
function
()
{
check_array
.
push
(
$
(
this
).
attr
(
"value"
))
});
var
url
=
'/jperm/role/recycle/?role_id={{ role.id }}&asset_id='
+
check_array
.
join
(
','
);
console
.
log
(
check_array
);
$
.
get
(
url
,
{},
function
(
data
){
location
.
reload
()
}
)
}
return
false
;
});
$
(
'.push_muti'
).
click
(
function
(){
var
check_array
=
[];
$
(
".gradeX input[name='asset_no_push_id']:checked"
).
each
(
function
()
{
check_array
.
push
(
$
(
this
).
attr
(
"value"
))
var
url
=
'/jperm/role/push/?id={{ role.id }}&asset_id='
+
check_array
.
join
(
','
);
$
(
this
).
attr
(
'href'
,
url
)
});
var
url
=
'/jperm/role/push/?id={{ role.id }}&asset_id='
+
check_array
.
join
(
','
);
$
(
this
).
attr
(
'href'
,
url
)
});
$
(
'.re_push'
).
click
(
function
(){
var
check_array
=
[];
$
(
".gradeX input[name='asset_id']:checked"
).
each
(
function
()
{
check_array
.
push
(
$
(
this
).
attr
(
"value"
))
$
(
'.re_push'
).
click
(
function
()
{
var
check_array
=
[];
$
(
".gradeX input[name='asset_id']:checked"
).
each
(
function
()
{
check_array
.
push
(
$
(
this
).
attr
(
"value"
))
});
var
url
=
'/jperm/role/push/?id={{ role.id }}&asset_id='
+
check_array
.
join
(
','
);
$
(
this
).
attr
(
'href'
,
url
)
});
var
url
=
'/jperm/role/push/?id={{ role.id }}&asset_id='
+
check_array
.
join
(
','
);
$
(
this
).
attr
(
'href'
,
url
)
});
$
(
'.push_failed'
).
click
(
function
()
{
var
fail_reason
=
$
(
this
).
attr
(
'title'
);
layer
.
alert
(
fail_reason
,
{
skin
:
'layui-layer-molv'
,
area
:
'500px'
})
});
$
(
'.push_failed'
).
click
(
function
()
{
var
fail_reason
=
$
(
this
).
attr
(
'title'
);
layer
.
alert
(
fail_reason
,
{
skin
:
'layui-layer-molv'
,
area
:
'500px'
})
});
})
</script>
})
</script>
{% endblock %}
\ No newline at end of file
templates/jperm/perm_role_list.html
View file @
1338d25b
...
...
@@ -70,7 +70,7 @@
<div
class=
"row"
>
<div
class=
"col-sm-6"
>
<div
class=
"dataTables_info"
id=
"editable_info"
role=
"status"
aria-live=
"polite"
>
Showing {{
users.start_index }} to {{ user
s.end_index }} of {{ p.count }} entries
Showing {{
roles.start_index }} to {{ role
s.end_index }} of {{ p.count }} entries
</div>
</div>
{% include 'paginator.html' %}
...
...
@@ -80,8 +80,6 @@
</div>
</div>
</div>
<script>
function
remove_role
(
role_id
){
$
.
ajax
({
...
...
templates/jperm/perm_rule_list.html
View file @
1338d25b
...
...
@@ -89,7 +89,7 @@
<div
class=
"row"
>
<div
class=
"col-sm-6"
>
<div
class=
"dataTables_info"
id=
"editable_info"
role=
"status"
aria-live=
"polite"
>
Showing {{
users.start_index }} to {{ user
s.end_index }} of {{ p.count }} entries
Showing {{
rules.start_index }} to {{ rule
s.end_index }} of {{ p.count }} entries
</div>
</div>
{% include 'paginator.html' %}
...
...
templates/jperm/perm_sudo_list.html
View file @
1338d25b
...
...
@@ -72,7 +72,7 @@
<div
class=
"row"
>
<div
class=
"col-sm-6"
>
<div
class=
"dataTables_info"
id=
"editable_info"
role=
"status"
aria-live=
"polite"
>
Showing {{
users.start_index }} to {{ user
s.end_index }} of {{ p.count }} entries
Showing {{
sudos.start_index }} to {{ sudo
s.end_index }} of {{ p.count }} entries
</div>
</div>
{% include 'paginator.html' %}
...
...
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