Commit 1338d25b authored by ibuler's avatar ibuler

fix bug

parents 9f171da5 f994c4d1
...@@ -518,7 +518,10 @@ class Nav(object): ...@@ -518,7 +518,10 @@ class Nav(object):
@staticmethod @staticmethod
def get_max_asset_property_length(assets, property_='hostname'): def get_max_asset_property_length(assets, property_='hostname'):
try:
return max([len(getattr(asset, property_)) for asset in assets]) return max([len(getattr(asset, property_)) for asset in assets])
except ValueError:
return 30
def print_search_result(self): def print_search_result(self):
hostname_max_length = self.get_max_asset_property_length(self.search_result) hostname_max_length = self.get_max_asset_property_length(self.search_result)
......
...@@ -16,6 +16,7 @@ from jperm.ansible_api import MyTask ...@@ -16,6 +16,7 @@ from jperm.ansible_api import MyTask
from jperm.perm_api import get_role_info, get_role_push_host from jperm.perm_api import get_role_info, get_role_push_host
from jumpserver.api import my_render, get_object, CRYPTOR from jumpserver.api import my_render, get_object, CRYPTOR
# 设置PERM APP Log # 设置PERM APP Log
from jumpserver.api import logger from jumpserver.api import logger
#logger = set_log(LOG_LEVEL, filename='jumpserver_perm.log') #logger = set_log(LOG_LEVEL, filename='jumpserver_perm.log')
...@@ -416,6 +417,7 @@ def perm_role_detail(request): ...@@ -416,6 +417,7 @@ def perm_role_detail(request):
users = role_info.get("users") users = role_info.get("users")
user_groups = role_info.get("user_groups") user_groups = role_info.get("user_groups")
pushed_asset, need_push_asset = get_role_push_host(get_object(PermRole, id=role_id)) pushed_asset, need_push_asset = get_role_push_host(get_object(PermRole, id=role_id))
except ServerError, e: except ServerError, e:
logger.warning(e) logger.warning(e)
......
...@@ -30,13 +30,15 @@ ...@@ -30,13 +30,15 @@
<div class="ibox-content"> <div class="ibox-content">
<div> <div>
<div class="text-left"> <div class="text-left">
<table class="table" id="ugedit" > <table class="table" id="ugedit">
<td class="text-navy text-left">时间</td> <td class="text-navy text-left">时间</td>
<td class="text-navy text-right">名称</td> <td class="text-navy text-right">名称</td>
{% for rule in rules %} {% for rule in rules %}
<tr class="gradeX"> <tr class="gradeX">
<td class="text-left"> {{ rule.date_added | date:"Y-m-d H:i:s"}} </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> <td class="text-right"><a
href="{% url 'rule_detail' %}?id={{ rule.id }}">{{ rule.name }}</a>
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
...@@ -44,8 +46,7 @@ ...@@ -44,8 +46,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="col-sm-4">
<div class="ibox float-e-margins"> <div class="ibox float-e-margins">
<div class="ibox-title"> <div class="ibox-title">
<span class="label label-primary"><b>授权用户/用户组</b></span> <span class="label label-primary"><b>授权用户/用户组</b></span>
...@@ -69,7 +70,7 @@ ...@@ -69,7 +70,7 @@
</div> </div>
<div class="ibox-content"> <div class="ibox-content">
<div class="text-center"> <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-left">用户</td>
<td class="text-navy text-right">用户组</td> <td class="text-navy text-right">用户组</td>
<tr> <tr>
...@@ -77,7 +78,9 @@ ...@@ -77,7 +78,9 @@
<table class="table progress-striped text-left"> <table class="table progress-striped text-left">
{% for user in users %} {% for user in users %}
<tr class="gradeX"> <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> </tr>
{% endfor %} {% endfor %}
</table> </table>
...@@ -86,7 +89,9 @@ ...@@ -86,7 +89,9 @@
<table class="table progress-striped text-right"> <table class="table progress-striped text-right">
{% for group in user_groups %} {% for group in user_groups %}
<tr class="gradeX-"> <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> </tr>
{% endfor %} {% endfor %}
</table> </table>
...@@ -97,8 +102,6 @@ ...@@ -97,8 +102,6 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="col-sm-4">
<div class="ibox float-e-margins"> <div class="ibox float-e-margins">
<div class="ibox-title"> <div class="ibox-title">
<span class="label label-primary"><b>授权主机组/主机组</b></span> <span class="label label-primary"><b>授权主机组/主机组</b></span>
...@@ -122,7 +125,7 @@ ...@@ -122,7 +125,7 @@
</div> </div>
<div class="ibox-content"> <div class="ibox-content">
<div class="text-center"> <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-left">主机</td>
<td class="text-navy text-right">主机组</td> <td class="text-navy text-right">主机组</td>
<tr> <tr>
...@@ -130,7 +133,9 @@ ...@@ -130,7 +133,9 @@
<table class="table progress-striped text-left"> <table class="table progress-striped text-left">
{% for asset in assets %} {% for asset in assets %}
<tr class="gradeX"> <tr class="gradeX">
<td> <a href="{% url 'asset_detail' %}?id={{ asset.id }}">{{ asset.ip }}</a> </td> <td>
<a href="{% url 'asset_detail' %}?id={{ asset.id }}">{{ asset.ip }}</a>
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
...@@ -139,7 +144,9 @@ ...@@ -139,7 +144,9 @@
<table class="table progress-striped text-right"> <table class="table progress-striped text-right">
{% for group in asset_groups %} {% for group in asset_groups %}
<tr class="gradeX-"> <tr class="gradeX-">
<td> <a href="{% url 'asset_list' %}?group_id={{ group.id }}">{{ group.name }}</a> </td> <td>
<a href="{% url 'asset_list' %}?group_id={{ group.id }}">{{ group.name }}</a>
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
...@@ -150,9 +157,70 @@ ...@@ -150,9 +157,70 @@
</div> </div>
</div> </div>
</div> </div>
<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="row"> </div>
<div class="col-sm-6"> <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 float-e-margins">
<div class="ibox-title"> <div class="ibox-title">
<span class="label label-primary"><b>{{ role.name }} - 推送主机</b></span> <span class="label label-primary"><b>{{ role.name }} - 推送主机</b></span>
...@@ -177,17 +245,17 @@ ...@@ -177,17 +245,17 @@
<div class="ibox-content"> <div class="ibox-content">
<div> <div>
<div class="text-left"> <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-danger del_muti"> 删除 </a><span> </span>
<a class="btn btn-xs btn-primary re_push"> 重新推送 </a> <a class="btn btn-xs btn-primary re_push"> 重新推送 </a>
<thead> <thead>
<tr> <tr>
<th class="text-center"> <th class="text-center">
<input type="checkbox" id="check_push" onclick="checkAll('check_push', 'asset_id')"> <input type="checkbox" id="check_push"
onclick="checkAll('check_push', 'asset_id')">
</th> </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>
<th class="text-center">结果</th> <th class="text-center">结果</th>
<th class="text-center">操作</th> <th class="text-center">操作</th>
</tr> </tr>
...@@ -200,13 +268,19 @@ ...@@ -200,13 +268,19 @@
</th> </th>
<td class="text-center"> {{ asset.hostname }} </td> <td class="text-center"> {{ asset.hostname }} </td>
<td class="text-center"> {{ info.key | yesno:"是,否,未知" }} </td> <td class="text-center"> {{ info.key | yesno:"是,否,未知" }} </td>
<td class="text-center"> {{ info.password | yesno:"是,否,未知" }} </td>
{% if info.success %} {% 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 %} {% 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 %} {% 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> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
...@@ -215,9 +289,7 @@ ...@@ -215,9 +289,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="col-sm-4">
<div class="ibox float-e-margins"> <div class="ibox float-e-margins">
<div class="ibox-title"> <div class="ibox-title">
<span class="label label-danger"><b>{{ role.name }} - 未推送主机</b></span> <span class="label label-danger"><b>{{ role.name }} - 未推送主机</b></span>
...@@ -236,12 +308,13 @@ ...@@ -236,12 +308,13 @@
<div class="ibox-content"> <div class="ibox-content">
<div> <div>
<div class="text-left"> <div class="text-left">
<table class="table table-striped" > <table class="table table-striped">
<a class="btn btn-xs btn-primary push_muti"> 推送 </a> <a class="btn btn-xs btn-primary push_muti"> 推送 </a>
<thead> <thead>
<tr> <tr>
<th class="text-center"> <th class="text-center">
<input type="checkbox" id="check_no_push" onclick="checkAll('check_no_push', 'asset_no_push_id')"> <input type="checkbox" id="check_no_push"
onclick="checkAll('check_no_push', 'asset_no_push_id')">
</th> </th>
<th class="text-center">主机</th> <th class="text-center">主机</th>
<th class="text-center">IP</th> <th class="text-center">IP</th>
...@@ -272,32 +345,31 @@ ...@@ -272,32 +345,31 @@
{% endblock %} {% endblock %}
{% block self_footer_js %} {% block self_footer_js %}
<script> <script>
$(document).ready(function(){ $(document).ready(function () {
$('.del').click(function(){ $('.del').click(function () {
var url = $(this).attr('href'); var url = $(this).attr('href');
$.get( $.get(
url, url,
{}, {},
function(data){ function (data) {
location.reload() location.reload()
} }
); );
return false; return false;
}); });
$('.del_muti').click(function(){ $('.del_muti').click(function () {
var check_array = []; var check_array = [];
if (confirm("确定删除")) { if (confirm("确定删除")) {
$(".gradeX input[name='asset_id']:checked").each(function() { $(".gradeX input[name='asset_id']:checked").each(function () {
check_array.push($(this).attr("value")) check_array.push($(this).attr("value"))
}); });
var url = '/jperm/role/recycle/?role_id={{ role.id }}&asset_id=' + check_array.join(','); var url = '/jperm/role/recycle/?role_id={{ role.id }}&asset_id=' + check_array.join(',');
console.log(check_array); console.log(check_array);
$.get(url, $.get(url,
{}, {},
function(data){ function (data) {
location.reload() location.reload()
} }
) )
...@@ -305,25 +377,25 @@ ...@@ -305,25 +377,25 @@
return false; return false;
}); });
$('.push_muti').click(function(){ $('.push_muti').click(function () {
var check_array = []; var check_array = [];
$(".gradeX input[name='asset_no_push_id']:checked").each(function() { $(".gradeX input[name='asset_no_push_id']:checked").each(function () {
check_array.push($(this).attr("value")) check_array.push($(this).attr("value"))
}); });
var url = '/jperm/role/push/?id={{ role.id }}&asset_id=' + check_array.join(','); var url = '/jperm/role/push/?id={{ role.id }}&asset_id=' + check_array.join(',');
$(this).attr('href', url) $(this).attr('href', url)
}); });
$('.re_push').click(function(){ $('.re_push').click(function () {
var check_array = []; var check_array = [];
$(".gradeX input[name='asset_id']:checked").each(function() { $(".gradeX input[name='asset_id']:checked").each(function () {
check_array.push($(this).attr("value")) check_array.push($(this).attr("value"))
}); });
var url = '/jperm/role/push/?id={{ role.id }}&asset_id=' + check_array.join(','); var url = '/jperm/role/push/?id={{ role.id }}&asset_id=' + check_array.join(',');
$(this).attr('href', url) $(this).attr('href', url)
}); });
$('.push_failed').click(function() { $('.push_failed').click(function () {
var fail_reason = $(this).attr('title'); var fail_reason = $(this).attr('title');
layer.alert(fail_reason, { layer.alert(fail_reason, {
skin: 'layui-layer-molv', skin: 'layui-layer-molv',
...@@ -333,5 +405,5 @@ ...@@ -333,5 +405,5 @@
}) })
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<div class="dataTables_info" id="editable_info" role="status" aria-live="polite"> <div class="dataTables_info" id="editable_info" role="status" aria-live="polite">
Showing {{ users.start_index }} to {{ users.end_index }} of {{ p.count }} entries Showing {{ roles.start_index }} to {{ roles.end_index }} of {{ p.count }} entries
</div> </div>
</div> </div>
{% include 'paginator.html' %} {% include 'paginator.html' %}
...@@ -80,8 +80,6 @@ ...@@ -80,8 +80,6 @@
</div> </div>
</div> </div>
</div> </div>
<script> <script>
function remove_role(role_id){ function remove_role(role_id){
$.ajax({ $.ajax({
......
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<div class="dataTables_info" id="editable_info" role="status" aria-live="polite"> <div class="dataTables_info" id="editable_info" role="status" aria-live="polite">
Showing {{ users.start_index }} to {{ users.end_index }} of {{ p.count }} entries Showing {{ rules.start_index }} to {{ rules.end_index }} of {{ p.count }} entries
</div> </div>
</div> </div>
{% include 'paginator.html' %} {% include 'paginator.html' %}
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<div class="dataTables_info" id="editable_info" role="status" aria-live="polite"> <div class="dataTables_info" id="editable_info" role="status" aria-live="polite">
Showing {{ users.start_index }} to {{ users.end_index }} of {{ p.count }} entries Showing {{ sudos.start_index }} to {{ sudos.end_index }} of {{ p.count }} entries
</div> </div>
</div> </div>
{% include 'paginator.html' %} {% include 'paginator.html' %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment