修改支持选中执行

pull/26/head
ibuler 2015-12-03 10:38:10 +08:00
parent 6080a861db
commit 255e3a043a
3 changed files with 10 additions and 4 deletions

View File

@ -363,5 +363,6 @@ def download(request):
@login_required(login_url='/login') @login_required(login_url='/login')
def exec_cmd(request): def exec_cmd(request):
role = request.GET.get('role') role = request.GET.get('role')
check_assets = request.GET.get('check_assets', '')
web_terminal_uri = 'ws://%s/exec?role=%s' % (WEB_SOCKET_HOST, role) web_terminal_uri = 'ws://%s/exec?role=%s' % (WEB_SOCKET_HOST, role)
return my_render('exec_cmd.html', locals(), request) return my_render('exec_cmd.html', locals(), request)

View File

@ -14,7 +14,7 @@
<div id="footer"> <div id="footer">
<div class="content"> <div class="content">
<input type="text" id="pattern" placeholder="Ansible Pattern"> <input type="text" id="pattern" value="{{ check_assets }}" placeholder="Ansible Pattern">
<input type="text" id="command" placeholder="Command to execute"> <input type="text" id="command" placeholder="Command to execute">
<input type="button" id="send_btn" value="Send" onclick="sendMessage()"> <input type="button" id="send_btn" value="Send" onclick="sendMessage()">
</div> </div>
@ -119,7 +119,7 @@
position: relative; position: relative;
} }
#pattern { width: 20%; } #pattern { width: 25%; }
#command { width: 60%; } #command { width: 60%; }
#send_btn { #send_btn {
width: 10%; width: 10%;

View File

@ -176,6 +176,11 @@
$('#exec_cmd').click(function(){ $('#exec_cmd').click(function(){
var url = '/jperm/role/get/'; var url = '/jperm/role/get/';
var new_url = '/exec_cmd/?role='; var new_url = '/exec_cmd/?role=';
var check_array = [];
$(".gradeX input:checked").closest('tr').find('.hostname a').each(function() {
check_array.push($(this).text())
});
check_assets = check_array.join(':');
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: url, url: url,
@ -190,7 +195,7 @@
maxmin: true, maxmin: true,
shade: false, shade: false,
area: ['800px', '700px'], area: ['800px', '700px'],
content: new_url+data content: new_url+data+'&check_assets='+check_assets
}); });
//window.open(new_url + data, '', 'location=no, resizeable=no, height=410, width=625, top=89px, left=99px,toolbar=no,menubar=no,scrollbars=auto,status=no'); //window.open(new_url + data, '', 'location=no, resizeable=no, height=410, width=625, top=89px, left=99px,toolbar=no,menubar=no,scrollbars=auto,status=no');
} else if (dataArray.length == '1' && data == 'error'){ } else if (dataArray.length == '1' && data == 'error'){
@ -198,7 +203,7 @@
} else { } else {
aUrl = ''; aUrl = '';
$.each(dataArray, function(index, value){ $.each(dataArray, function(index, value){
aUrl += '<a onclick="windowOpenExec(this); return false" class="btn btn-xs btn-primary newa" href=' + new_url + value + '>' + value + '</a> ' aUrl += '<a onclick="windowOpenExec(this); return false" class="btn btn-xs btn-primary newa" href=' + new_url + value + '&check_assets=' + check_assets + '>' + value + '</a> '
}); });
layer.alert(aUrl, { layer.alert(aUrl, {
skin: 'layui-layer-molv', skin: 'layui-layer-molv',