mirror of https://github.com/jumpserver/jumpserver
				
				
				
			添加推送
							parent
							
								
									4b36fc540d
								
							
						
					
					
						commit
						f72c5753c9
					
				|  | @ -396,9 +396,12 @@ def perm_role_push(request): | |||
|     # 渲染数据 | ||||
|     header_title, path1, path2 = "系统角色", "角色管理", "角色推送" | ||||
|     role_id = request.GET.get('id') | ||||
|     asset_ids = request.GET.get('asset_id') | ||||
|     role = get_object(PermRole, id=role_id) | ||||
|     assets = Asset.objects.all() | ||||
|     asset_groups = AssetGroup.objects.all() | ||||
|     if asset_ids: | ||||
|         need_push_asset = [get_object(Asset, id=asset_id) for asset_id in asset_ids.split(',')] | ||||
| 
 | ||||
|     if request.method == "POST": | ||||
|         # 获取推荐角色的名称列表 | ||||
|  |  | |||
|  | @ -16,9 +16,9 @@ function check_all(form) { | |||
|     } | ||||
| } | ||||
| 
 | ||||
| function checkAll(){ | ||||
|     var checklist = document.getElementsByName ("checked"); | ||||
|     if(document.getElementById("check_all").checked) | ||||
| function checkAll(id, name){ | ||||
|     var checklist = document.getElementsByName(name); | ||||
|     if(document.getElementById(id).checked) | ||||
|         { | ||||
|         for(var i=0;i<checklist.length;i++) | ||||
|         { | ||||
|  |  | |||
|  | @ -175,7 +175,7 @@ | |||
|                                     <thead> | ||||
|                                         <tr> | ||||
|                                             <th class="text-center"> | ||||
|                                                 <input type="checkbox" id="check_all" onclick="checkAll()"> | ||||
|                                                 <input type="checkbox" id="check_push" onclick="checkAll('check_push', 'asset_id')"> | ||||
|                                             </th> | ||||
|                                             <th class="text-center">主机</th> | ||||
|                                             <th class="text-center">密钥</th> | ||||
|  | @ -188,7 +188,7 @@ | |||
|                                     {% for asset, info in pushed_asset.items %} | ||||
|                                         <tr class="gradeX"> | ||||
|                                             <th class="text-center"> | ||||
|                                                 <input type="checkbox" name="checked" value="{{ asset.id }}"> | ||||
|                                                 <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> | ||||
|  | @ -220,7 +220,6 @@ | |||
|                             <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> | ||||
|  | @ -229,9 +228,13 @@ | |||
|                     <div class="ibox-content"> | ||||
|                         <div> | ||||
|                             <div class="text-left"> | ||||
|                                 <table class="table table-striped" id="ugedit" > | ||||
|                                 <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> | ||||
|  | @ -239,6 +242,9 @@ | |||
|                                     <tbody> | ||||
|                                     {% for asset in need_push_asset %} | ||||
|                                         <tr class="gradeX"> | ||||
|                                             <th class="text-center"> | ||||
|                                                 <input type="checkbox" name="asset_no_push_id" value="{{ asset.id }}"> | ||||
|                                             </th> | ||||
|                                             <td class="text-center"> {{ asset.hostname }} </td> | ||||
|                                             <td class="text-center"> {{ asset.ip }} </td> | ||||
|                                         </tr> | ||||
|  | @ -276,10 +282,11 @@ | |||
|         $('.del_muti').click(function(){ | ||||
|             var check_array = []; | ||||
|             if (confirm("确定删除")) { | ||||
|                 $(".gradeX input:checked").each(function() { | ||||
|                 $(".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){ | ||||
|  | @ -290,6 +297,15 @@ | |||
|             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) | ||||
|         }) | ||||
| 
 | ||||
|     }) | ||||
| </script> | ||||
| {% endblock %} | ||||
|  | @ -45,7 +45,7 @@ | |||
|                                 <div class="col-sm-8"> | ||||
|                                     <select name="assets" id="assets" data-placeholder="请选择资产" class="chosen-select form-control m-b" multiple  tabindex="2"> | ||||
|                                         {% for asset in assets %} | ||||
|                                             <option value="{{ asset.id }}" {% if asset in pushed_assets %}selected{% endif %}>{{ asset.hostname }}</option> | ||||
|                                             <option value="{{ asset.id }}" {% if asset in need_push_asset %}selected{% endif %}>{{ asset.hostname }}</option> | ||||
|                                         {% endfor %} | ||||
|                                     </select> | ||||
|                                 </div> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 ibuler
						ibuler