update, now Mac to develop will be all egg pain

pull/26/head
liuzheng712 9 years ago
parent 962d16172c
commit c89d43d269

@ -72,7 +72,7 @@ def get_count_by_date(date_li, item):
return len(set(data_count_tmp))
from jasset.models import Asset, IDC
@require_role(role='user')
def index_cu(request):
# user_id = request.user.id
@ -80,17 +80,21 @@ def index_cu(request):
login_types = {'L': 'LDAP', 'M': 'MAP'}
username = request.user.username
# TODO: need fix,liuzheng need Asset help
asset = get_group_user_perm(request.user)
print asset
assets = asset.get('asset')
# idc = []
# for i in assets:
# idc.append(i.idc.id)
# idc_all = IDC.objects.filter(id__in=idc)
idc_all = []
GUP = get_group_user_perm(request.user)
print GUP
assets = GUP.get('asset')
idcs = []
for i in assets:
idc_all.append(i.idc)
asset_group_all = asset.get('asset_group')
if i.idc_id:
idcs.append(i.idc_id)
idc_all = IDC.objects.filter(id__in=idcs)
for i in idc_all:
print i.name
# idc_all = []
# for i in assets:
# idc_all.append(i.idc)
# print i.idc.name
asset_group_all = GUP.get('asset_group')
# posts = Asset.object.all()
# host_count = len(posts)
#

@ -489,7 +489,10 @@ def down_key(request):
return HttpResponse('No Key File. Contact Admin.')
from jperm.perm_api import get_group_user_perm
@require_role(role='user')
def RunCommand(request):
if request.method == 'GET':
print get_group_user_perm(request.user)
GUP = get_group_user_perm(request.user)
print GUP
assets = GUP.get('asset')
return render_to_response('juser/run_command.html', locals(), context_instance=RequestContext(request))

@ -0,0 +1,138 @@
{% extends 'base.html' %}
{% load mytags %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5> 命令批量执行 </h5>
<div class="ibox-tools">
<a class="collapise-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">
<form method="post" id="ruleForm" class="form-horizontal" action="">
{% if error %}
<div class="alert alert-warning text-center">{{ error }}</div>
{% endif %}
{% if msg %}
<div class="alert alert-success text-center">{{ msg }}</div>
{% endif %}
<div class="form-group">
<label for="asset" class="col-sm-2 control-label">资产<span class="red-fonts">*</span></label>
<div class="col-sm-8">
<select name="asset" data-placeholder="请选择资产" class="chosen-select form-control m-b"
multiple tabindex="2">
{% for asset in assets %}
<option value="{{ asset.ip }}">{{ asset.ip }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">命令<span class="red-fonts">*</span></label>
<div class="col-sm-8">
<input class="form-control" name="cmd" placeholder="请输入要执行的命令">
</div>
</div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
<button class="btn btn-white" type="clean">清除</button>
<button id="submit_button" class="btn btn-primary" type="submit">运行</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block self_head_css_js %}
{% load staticfiles %}
<script src="{% static 'js/jquery.shiftcheckbox.js' %}"></script>
<link href="/static/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
<link href="/static/css/plugins/chosen/chosen.css" rel="stylesheet">
<script src="/static/js/plugins/chosen/chosen.jquery.js"></script>
{% endblock %}
{% block self_footer_js %}
<script>
$(document).ready(function () {
var config = {
'.chosen-select': {},
'.chosen-select-deselect': {allow_single_deselect: true},
'.chosen-select-no-single': {disable_search_threshold: 10},
'.chosen-select-no-results': {no_results_text: 'Oops, nothing found!'},
'.chosen-select-width': {width: "95%"}
};
for (var selector in config) {
$(selector).chosen(config[selector]);
}
$('.del').click(function(){
var row = $(this).closest('tr');
if (confirm("确定删除")) {
$.get(
$(this).attr('value'),
{},
function(data){
row.remove();
alert(data);
}
)}
});
$('#del_btn').click(function(){
var check_array = [];
if (confirm("确定删除")) {
$(".gradeX input:checked").each(function() {
check_array.push($(this).attr("value"))
});
$.post("/juser/user_del/",
{id: check_array.join(",")},
function(data){
$(".gradeX input:checked").closest("tr").remove();
alert(data);
}
)
}
});
$('.email').click(function(){
$.get('/juser/send_mail_retry/?uuid=' + $(this).attr('value'),
{},
function(data){
alert(data)
}
)
});
$("tbody tr").shiftcheckbox({
checkboxSelector: 'input:checkbox',
selectAll: $('#select_all'),
ignoreClick: 'a'
});
$('.shiftCheckbox').shiftcheckbox();
});
</script>
{% endblock %}

@ -73,6 +73,11 @@
<div class="dropzone-previews">
<input id="hosts" name="hosts" type="text" class="form-control" required="不能为空"
placeholder="输入主机地址,逗号隔开,确保你有输入主机地址的权限" size="80%">
<select name="assetgroup" data-placeholder="请选择资产组" class="chosen-select form-control m-b" multiple tabindex="2">
{% for asset_group in asset_groups %}
<option value="{{ asset_group.name }}">{{ asset_group.name }}</option>
{% endfor %}
</select>
{# <div id="hosts_list" style="position:absolute;display: none;z-index:999;">#}
{# TODO: by liuzheng#}

Loading…
Cancel
Save