本帖最后由 jiangsongnian 于 2014-09-17 09:20:26 编辑

解决方案 »

  1.   


    js
    function loadRcglAppServerMaintence(plugin,title){
    var servletUrl = basePath + 'AppServerServlet.do?oper=';
    var $dg = null;
    var dialog;
    var p_id = -1,script_type;

    $dg = $('#'+plugin);
    var idField = 'p_id';
    var sortName = 'p_id';
    var rows;
    $dg.datagrid({
    toolbar: '#appServMantainceToolbar',
    //title:title,
    //width:'auto',
    //height: maxH1,
    //fitColumns: true,
    iconCls:'icon-save',
    autoRowHeight: false,
    singleSelect:true,
    striped: true,
    fit: true,
    method:'get',
    url: servletUrl + 'getAppServerGrid',
    sortName: sortName,
    sortOrder: 'asc',
    remoteSort: true,
    idField: idField, 
    rownumbers:true,
    onSelect : function(rowIndex, rowData){
    p_id = rowData['P_ID'];
    },
    columns:[[
    {field: 'P_ID', title:'ID', width:120, align:'center', hidden: true}, 
    {field: 'P_NAME', title:'应用名称', width:140, align:'center'}, 
    {field: 'P_MANAGER1', title:'第一负责人', width:80, align:'center'},
    {field: 'P_MANAGER2', title:'第二负责人', width:80, align:'center', hidden: true},
    {field: 'APP_IP', title: '服务器地址',width: 90, align: 'center', sortable: true},
    {field: 'APP_PORT', title: '端口',width: 70, align: 'center'}
    //{field: 'AVIENDTIME', title: '过期时间',width: 120, align: 'center'},
    //{field: 'QUERY_CF', title: 'QUERY_CF',width: 100, align: 'center'},
    //{field: 'QUERY_TOPIC', title: 'QUERY_TOPIC',width: 100, align: 'center'}
    ]]
    });
    $('#btnAppFind').on('click',function(){
    search('searchValueApp',$dg,'P_NAME,P_MANAGER1,P_MANAGER2,APP_IP');
    $('#searchValueApp').focus();
    });

    bindButtonToInputBox('searchValueApp','btnAppFind');

    $('#searchAppValue').focus();

    $('#zhcx_btnSeeApp').on('click',function(){
    execScript(p_id,'see');
    });

    $('#zhcx_btnStopApp').on('click',function(){
    execScript(p_id,'stop');
    });

    $('#zhcx_btnStartApp').on('click',function(){
    execScript(p_id,'start');
    });

    $('#zhcx_btnRestartApp').on('click',function(){
    execScript(p_id,'restart');
    });//发送IP、远程脚步类型参数到servlet
    var execScript = function(pId, scriptType) {
    if(pId==-1){

    return false;
    }
    console.info(pId + '  ' + scriptType);
    $('#zhcx_app_dialog').dialog('open');
    $('#scriptResult').panel('open');
    $('#scriptResult').panel({content:''});
    $('#netStatus').datagrid('getPanel').panel('close');

    //$.post(servletUrl + 'excuteScript' , { p_id: pId, script_type: scriptType },//ajax发送、接收数据
                        $.ajax({
    type:'post',
    url: servletUrl + 'excuteScript',
    data: 'p_id=' + pId+'&script_type='+scriptType,
        dataType:'json',
        success: function(data){
          closeDialog();
          $('#scriptResult').panel({content:data.msg});
        }
        });
    }
    netMonitor(p_id);//$('#divAddLjxdQueryUser').dialog('open');

    $('#zhcx_netMonitor').on('click',function(){
    $('#scriptResult').panel({content:' '})
    $('#scriptResult').panel('close');
    $('#netStatus').datagrid('getPanel').panel('open');
    getNetStatus(p_id);
    });


    function getNetStatus (pId){
    if(pId==-1){

    return false;
    }
    $('#zhcx_app_dialog').dialog('open');
    $.ajax({
    type: 'post',
    url: servletUrl + "netMonitor",
    data: "p_id=" + pId,
    dataType: 'json',
        success: function(data){
          closeDialog();
          if(data.success){
          $("#netStatus").datagrid('loadData',data);
          }else{
          alert(data.msg);
          }
        }
    });
    }

    function netMonitor ( pId ) {
    $("#netStatus").datagrid({
    title:'网络状态',
    rownumbers:true,
    width:'auto',
    //height: maxH2,
    //autoRowHeight: false,
    singleSelect:true,
    striped: true,
    fit: true,
    method:'get',
    remoteSort: false,
    //url: servletUrl + 'netMonitor&p_id='+ pId,
    sortName: 'CONNECTCOUNT',
    sortOrder: 'desc',
    //remoteSort: true,
    //idField: 'IP', 
    columns:[[
    {field: 'IP', title:'IP地址', width:120, align:'center',sortable:true}, 
    {field: 'CONNECTCOUNT', title:'连接数', width:140, align:'center',sortable:true}, 
    {field: 'CONNECTTYPE', title:'连接类型', width:140, align:'center',sortable:true}, 
    {field: 'ISNORMAL', title:'状态', width:80, align:'center',sortable:true}
    ]],
    rowStyler: function(index,row){
    if (row.ISNORMAL=='异常'){
    return 'color:#f00;';
    }
    }

    });
    }

    var $dialog ;
    function initDialog () {
    $dialog=$('#zhcx_app_dialog').dialog({  
        title: '',  
        width: 500,  
        height: 50,  
        closed: true, 
        closeable: false,
        modal: true  
    }); 
    }

    function showDialog (){
    $('#zhcx_app_dialog').dialog('open');
    }
    function closeDialog (){
    $('#zhcx_app_dialog').dialog('close');
    }
    }