var confC = null; var confS = null; var methodC = []; var methodP = []; $(function () { //checkAll('checkboxAllS'); //checkAll('checkboxAllC'); $('#serverSubmit').click(function () { //$('#pageIndexS').val(1); //loadServer(); serverTable.fnReloadAjax(); return false; }); $('#doRefresh').click(function () { $('#refresh').val(true); //loadServer(); serverTable.fnReloadAjax(); return false; }); $('#clientRefresh').click(function () { $('#cRefresh').val(true); //loadClient(); clientTable.fnReloadAjax(); return false; }); $('#clientSubmit').click(function () { //$('#pageIndexC').val(1); //loadClient(); clientTable.fnReloadAjax(); return false; }); var currentPage = parseIntById('pageIndexS'); var totalPages = parseIntById('totalPageS'); if (hasText(totalPages) && totalPages > 0) { initPagingServer(currentPage, totalPages); } var currentPage = parseIntById('pageIndexC'); var totalPages = parseIntById('totalPageC'); if (hasText(totalPages) && totalPages > 0) { initPagingClient(currentPage, totalPages); } $('#export').click(function () { window.location = "/iface/manage/export/" + $('#resId').val() + "?interfaceName=" + $('#interfaceName').val(); }); $('#import').click(function () { $("#importDialog").removeClass('hide'); $("#importDialog").dialog( { modal: true, //蒙层(弹出会影响页面大小) title: '导入服务', overlay: { opacity: 0.5 }, buttons: { '取消': function () { $(this).dialog('close'); }, '确定': function () { doImport(); } } } ); }); $('#refreshRegistry').click(function () { $.ajax({ url: '/iface/manage/refresh', data: { interfaceId: $('#resId').val(), interfaceName: $('#interfaceName').val() }, contentType: 'application/x-www-form-urlencoded', success: function (result) { if (result.code != 1) { warning(result.msg); } else { success('操作成功'); } } }); }); $('#refreshProvider').click(function () { var url = '/iface/manage/refresh/' + $('#interfaceName').val() + '/provider/' + $('#resId').val(); refreshSubscribe(url); }); $('#refreshConfig').click(function () { var url = '/iface/manage/refresh/' + $('#interfaceName').val() + '/config/' + $('#resId').val() + "/0"; refreshSubscribe(url); }); $('#refreshServerConfig').click(function () { var url = '/iface/manage/refresh/' + $('#interfaceName').val() + '/config/' + $('#resId').val() + "/1"; refreshServerConfig(url); }); $('#pinPointConfig_c').click(function () { if (!hasChecked('clientTbody')) { warning("请至少选择一个调用方进行操作!"); return false; } $('#pinConfigCTable_method').empty(); methodC = []; var clients = []; var trs = getAllTrByChecked('clientTbody'); for (var i = 0; i < trs.length; i++) { var client = { id: trs[i].children(':eq(0)').find("input").val(), ip: trs[i].attr('ip').trim(), alias: trs[i].attr('alias').trim(), pid: trs[i].attr('pid').trim(), protocol: trs[i].attr('data-protocol'), startTime: trs[i].attr('startTime'), safVer: trs[i].attr('jsfversion').trim() }; clients.push(client); } $.ajax({ url: '/iface/manage/clientCfg/' + $('#interfaceName').val() + '/clients', data: JSON.stringify(clients), success: function (result) { setCtable_iface(); if (result.code == 1) { var configs = result.content; if (configs != null && configs.length != 0) { confC = configs; for (var i = 0; i < trs.length; i++) { var timeout = '', retries = '', concurrents = '', l = '', m = false, cluster = '', mockref = null, cache = false, cacheref = null; var c = configs[i]; if (c != null) { timeout = c['timeout']; retries = c['retries']; concurrents = c['concurrents']; l = c['loadbalance']; m = c['mock']; cluster = c['cluster']; mockref = c['mockref']; cache = c['cache']; cacheref = c['cacheref']; } $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(4)').find('select option[value=' + m + ']').attr('selected', true); $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(4)').find('input').val(m); if (!hasText(mockref)) { $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(4)').find('select').attr('disabled', true); } else { $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(4)').find('select').attr('disabled', false); } $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(1)').find('input').eq(0).val(timeout); $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(1)').find('input').eq(1).val(timeout); $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(2)').find('input').eq(0).val(retries); $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(2)').find('input').eq(1).val(retries); $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(5)').find('input').eq(0).val(concurrents); $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(5)').find('input').eq(1).val(concurrents); $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(3)').find('select option[value=' + l + ']').attr('selected', true); $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(3)').find('input').val(l); $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(6)').find('select option[value=' + cluster + ']').attr('selected', true); $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(6)').find('input').val(cluster); $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(7)').find('select option[value=' + cache + ']').attr('selected', true); $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(7)').find('input').val(cache); if (!hasText(cacheref)) { $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(7)').find('select').attr('disabled', true); } else { $('#pinConfigCTable_iface').children(':eq(' + i + ')').children(':eq(7)').find('select').attr('disabled', false); } } } } checkShowAttr(null); $('#pinConfigModal_c').modal('show'); } }); }); $('#addCMethod').click(function () { var method = $('#attr_method_c', parent.document).val(); if ($.inArray(method, methodC) > -1) { return } methodC.push(method); var trs = getAllTrByChecked('clientTbody'); for (var i = trs.length - 1; i >= 0; i--) { var t = '', r = '', con = '', m = false, mockref = null, cache = false, cacheref = null; var t_ = '', r_ = '', con_ = '', m_ = false, cache_ = false; if (confC != null && confC[i] != null) { var c = confC[i]; if (c != null) { t = c['timeout']; r = c['retries']; con = c['concurrents']; m = c['mock']; mockref = c['mockref']; cache = c['cache']; cacheref = c['cacheref']; } var methodCfg = confC[i]['methods']; if (methodCfg != null && methodCfg[method] != null) { var mc = methodCfg[method]; t_ = mc.timeout; r_ = mc.retries; con_ = mc.concurrents; m_ = mc.mock; cache_ = mc.cache_; } if (!hasText(t_)) { t_ = t; } if (!hasText(r_)) { r_ = r; } if (!hasText(con_)) { con_ = con; } if (!hasText(m_)) { m_ = m; } if (!hasText(cache_)) { cache_ = cache; } } var html = '<tr>'; html += '<td><span>' + trs[i].attr('ip') + ':' + trs[i].attr('pid') + '</span></td>'; html += '<td>' + method + '</td>'; html += '<td><input type="text" style="width:50px;" /><input type="hidden" /></td>'; html += '<td><input type="text" style="width:50px;" /><input type="hidden" /></td>'; html += '<td>' + '<select style="width: 70px;" disabled="disabled">' + '<option value=false>否</option>' + '<option value=true>是</option>' + '</select><input type="hidden" value="false"/>' + '</td>'; html += '<td><input type="text" style="width:50px;" /><input type="hidden" /></td>'; html += '<td>' + '<select style="width: 70px;" disabled="disabled">' + '<option value=false>否</option>' + '<option value=true>是</option>' + '</select><input type="hidden" value="false">' + '</td>'; html += '</tr>'; $('#pinConfigCTable_method', parent.document).prepend(html); $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(2)').find('input').eq(0).val(t_); $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(2)').find('input').eq(1).val(t_); $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(3)').find('input').eq(0).val(r_); $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(3)').find('input').eq(1).val(r_); $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(4)').find('select option[value=' + m_ + ']').attr('selected', true); $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(4)').find('input').val(m_); if (!hasText(mockref)) { $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(4)').find('select').attr('disabled', true); } else { $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(4)').find('select').attr('disabled', false); } $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(5)').find('input').eq(0).val(con_); $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(5)').find('input').eq(1).val(con_); $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(6)').find('select option[value=' + cache_ + ']').attr('selected', true); $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(6)').find('input').val(cache_); if (!hasText(cacheref)) { $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(6)').find('select').attr('disabled', true); } else { $('#pinConfigCTable_method', parent.document).children(':eq(0)').children(':eq(6)').find('select').attr('disabled', false); } } }); $('#addPMethod').click(function () { var method = $('#attr_method_p', parent.document).val(); if ($.inArray(method, methodP) > -1) { return } methodP.push(method); var trs = getAllTrByChecked('serverTbody'); for (var i = trs.length - 1; i >= 0; i--) { var m = false, con = '', mockref = null, cache = false, cacheref = null; var m_ = false, con_ = '', cache_ = false; if (confS != null && confS[i] != null) { var c = confS[i]; if (c != null) { con = c.concurrents; m = c.mock; mockref = c.mockref; cacheref = c.cacheref; cache = c.cache; } var methodCfg = confS[i]['methods']; if (methodCfg != null && methodCfg[method] != null) { var mc = methodCfg[method]; m_ = mc.mock; con_ = mc.concurrents; cache_ = mc.cache; } if (!hasText(m_)) { m_ = m; } if (!hasText(con_)) { con_ = con; } if (!hasText(cache_)) { cache_ = cache; } } var html = '<tr>'; html += '<td><span>' + trs[i].attr('data-ip') + ':' + trs[i].attr('data-port') + '</span></td>'; html += '<td>' + method + '</td>'; html += '<td>' + '<select style="width: 70px;" disabled="disabled">' + '<option value=false>否</option>' + '<option value=true>是</option>' + '</select><input type="hidden" value="false">' + '</td>'; html += '<td><input type="text" style="width:50px;" /></td>'; html += '<td>' + '<select style="width: 70px;" disabled="disabled">' + '<option value=false>否</option>' + '<option value=true>是</option>' + '</select><input type="hidden" value="false">' + '</td>'; html += '</tr>'; $('#pinConfigPTable_method', parent.document).prepend(html); $('#pinConfigPTable_method', parent.document).children(':eq(0)').children(':eq(2)').find('select option[value=' + m_ + ']').attr('selected', true); $('#pinConfigPTable_method', parent.document).children(':eq(0)').children(':eq(2)').find('input').val(m_); if (!hasText(mockref)) { $('#pinConfigPTable_method', parent.document).children(':eq(0)').children(':eq(2)').find('select').attr('disabled', true); } else { $('#pinConfigPTable_method', parent.document).children(':eq(0)').children(':eq(2)').find('select').attr('disabled', false); } $('#pinConfigPTable_method', parent.document).children(':eq(0)').children(':eq(3)').find('input').eq(0).val(con_); $('#pinConfigPTable_method', parent.document).children(':eq(0)').children(':eq(3)').find('input').eq(1).val(con_); $('#pinConfigPTable_method', parent.document).children(':eq(0)').children(':eq(4)').find('select option[value=' + cache_ + ']').attr('selected', true); $('#pinConfigPTable_method', parent.document).children(':eq(0)').children(':eq(4)').find('input').val(cache_); if (!hasText(cacheref)) { $('#pinConfigPTable_method', parent.document).children(':eq(0)').children(':eq(4)').find('select').attr('disabled', true); } else { $('#pinConfigPTable_method', parent.document).children(':eq(0)').children(':eq(4)').find('select').attr('disabled', false); } } }); $('#pinPointConfig_p').click(function () { if (!hasChecked('serverTbody')) { warning("请至少选择一个提供方进行操作!"); return false; } $('#pinConfigPTable_method').empty(); methodP = []; var servers = []; var trs = getAllTrByChecked('serverTbody'); for (var i = 0; i < trs.length; i++) { var server = { id: trs[i].children(':eq(0)').find("input").val(), ip: trs[i].attr('data-ip').trim(), port: trs[i].attr('data-port').trim(), alias: trs[i].attr('alias').trim(), protocol: trs[i].attr('data-protocol'), pid: trs[i].attr('pid'), startTime: trs[i].attr('data-startTime1'), safVer: trs[i].attr('jsfversion').trim(), interfaceId: $('#interfaceId').val() }; servers.push(server); } $.ajax({ url: '/iface/manage/serverCfg/' + $('#interfaceName').val() + '/servers', data: JSON.stringify(servers), success: function (result) { setPtable_iface(); if (result.code == 1) { var configs = result.content; if (configs != null && configs.length != 0) { confS = configs; for (var i = 0; i < trs.length; i++) { var weight = '', concurrents = '', mock = false, mockref = null, cache = false, cacheref = null, coreThreads = '', maxThreads = ''; var c = configs[i]; if (c != null) { weight = c['weight']; concurrents = c['concurrents']; mock = c['mock']; mockref = c['mockref']; cache = c['cache']; cacheref = c['cacheref']; coreThreads = c['coreThreads']; maxThreads = c['maxThreads']; } $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(1)').find('select option[value=' + mock + ']').attr('selected', true); $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(1)').find('input').val(mock); if (!hasText(mockref)) { $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(1)').find('select').attr('disabled', true); } else { $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(1)').find('select').attr('disabled', false); } $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(2)').find('input').eq(0).val(concurrents); $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(2)').find('input').eq(1).val(concurrents); $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(3)').find('input').eq(0).val(weight); $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(3)').find('input').eq(1).val(weight); $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(4)').find('select option[value=' + cache + ']').attr('selected', true); $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(4)').find('input').val(cache); if (!hasText(cacheref)) { $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(4)').find('select').attr('disabled', true); } else { $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(4)').find('select').attr('disabled', false); } var jsfVersion = trs[i].attr('jv'); if (hasText(jsfVersion)) { var version = 0; try { version = jsfVersion.substring(3); version = parseInt(version); } catch (e) { //$("#coreThreadsTh").hide(); //$("#maxThreadsTh").hide(); } if (version >= 1601) { $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(5)').find('input').eq(0).val(coreThreads); $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(5)').find('input').eq(1).val(coreThreads); $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(6)').find('input').eq(0).val(maxThreads); $('#pinConfigPTable_iface').children(':eq(' + i + ')').children(':eq(6)').find('input').eq(1).val(maxThreads); //$("#coreThreadsTh").hide(); //$("#maxThreadsTh").show(); } else { //$("#coreThreadsTh").hide(); //$("#maxThreadsTh").hide(); } } else { //$("#coreThreadsTh").hide(); //$("#maxThreadsTh").hide(); } } } } checkShowAttr(null); $("input[name='tipThread']").each(function () { $(this).popover({ title: '温馨提示', placement: 'left', content: "修改此业务线程池大小将会影响该端口下全部接口,请谨慎操作。\r\n 参见 http://jpcloud.jd.com/pages/viewpage.action?pageId=10671257#JSF客户端用户手册-线程池类型" }); }); $('#pinConfigModal_p').modal('show'); } }); }); $('#attr_method_client').hide(); $('#attr_method_server').hide(); $('#saveClientAttr').click(function () { var url = '/iface/manage/' + $('#interfaceName').val() + '/pinconfig_c/' + $('#resId').val(); var trs = getAllTrByChecked('clientTbody'); var clients = []; var jsfVers = []; for (var i = 0; i < trs.length; i++) { jsfVers.push(trs[i].attr('jsfVer').trim()); var client = { id: trs[i].children(':eq(0)').find("input").val(), ip: trs[i].attr('ip').trim(), alias: trs[i].attr('alias'), pid: trs[i].attr('pid').trim(), protocol: trs[i].attr('data-protocol'), insKey: trs[i].attr('insKey'), startTime: trs[i].attr('startTime'), safVer: trs[i].attr('jsfversion').trim() }; clients.push(client); } var objects = []; var attrs = []; var trs = $('#pinConfigCTable_iface', parent.document).children('tr'); for (var i = 0; i < trs.length; i++) { var attr = {}; var oldT = $(trs[i]).children(':eq(1)').find("input").eq(1).val(); var newT = $(trs[i]).children(':eq(1)').find("input").eq(0).val(); if (oldT != newT) { attr['timeout'] = newT; } var oldR = $(trs[i]).children(':eq(2)').find("input").eq(1).val(); var newR = $(trs[i]).children(':eq(2)').find("input").eq(0).val(); if (newR != oldR) { attr['retries'] = newR; } var oldL = $(trs[i]).children(':eq(3)').find("input").val(); var newL = $(trs[i]).children(':eq(3)').find("select").val(); if (oldL != newL) { attr['loadbalance'] = newL; } var oldM = $(trs[i]).children(':eq(4)').find("input").val(); var newM = $(trs[i]).children(':eq(4)').find("select").val(); if (oldM != newM && jsfVers[i].indexOf('JSF') >= 0 && jsfVers[i] < 'JSF1200') { attr['mock'] = newM; } var oldCon = $(trs[i]).children(':eq(5)').find("input").eq(1).val(); var newCon = $(trs[i]).children(':eq(5)').find("input").eq(0).val(); if (oldCon != newCon && jsfVers[i] < "JSF1200") { attr['concurrents'] = newCon; } var oldC = $(trs[i]).children(':eq(6)').find("input").val(); var newC = $(trs[i]).children(':eq(6)').find("select").val(); if (oldC != newC) { attr['cluster'] = newC; } var oldCache = $(trs[i]).children(':eq(7)').find("input").val(); var newCache = $(trs[i]).children(':eq(7)').find("select").val(); if (oldCache != newCache) { attr['cache'] = newCache; } attrs.push(attr); } var trs_ = $('#pinConfigCTable_method', parent.document).children('tr'); for (var i = 0; i < trs.length; i++) { for (var j = i; j < methodC.length * trs.length; j += trs.length) { var method = $(trs_[j]).children(':eq(1)').text().trim(); var oldT_ = $(trs_[j]).children(':eq(2)').find("input").eq(1).val(); var newT_ = $(trs_[j]).children(':eq(2)').find("input").eq(0).val(); if (oldT_ != newT_) { attrs[i]['.' + method + '.timeout'] = newT_; } var oldR_ = $(trs_[j]).children(':eq(3)').find("input").eq(1).val(); var newR_ = $(trs_[j]).children(':eq(3)').find("input").eq(0).val(); if (oldR_ != newR_) { attrs[i]['.' + method + '.retries'] = newR_; } var oldM_ = $(trs_[j]).children(':eq(4)').find("input").val(); var newM_ = $(trs_[j]).children(':eq(4)').find("select").val(); if (oldM_ != newM_) { attrs[i]['.' + method + '.mock'] = newM_; } var oldCon_ = $(trs_[j]).children(':eq(5)').find("input").eq(1).val(); var newCon_ = $(trs_[j]).children(':eq(5)').find("input").eq(0).val(); if (oldCon_ != newCon_) { attrs[i]['.' + method + '.concurrents'] = newCon_; } var oldCache_ = $(trs_[j]).children(':eq(6)').find("input").val(); var newCache_ = $(trs_[j]).children(':eq(6)').find("select").val(); if (oldCache_ != newCache_) { attrs[i]['.' + method + '.cache'] = newCache_; } } } objects.push(clients); objects.push(attrs); $('#pinConfigModal_c', parent.document).modal('hide'); $.ajax({ url: url, data: JSON.stringify(objects), success: function (result) { _successFun(result, function () { $('#clientSubmit').trigger('click'); if (result.code != 1) { warning(result.msg); } else { $('#pinConfigCTable_method').empty(); methodC = []; } }); } }); }); $('#saveServerAttr').click(function () { var objects = []; var attrs = []; var url = '/iface/manage/' + $('#interfaceName').val() + '/pinconfig_s/' + $('#resId').val(); var jsfVers = []; var trs = getAllTrByChecked('serverTbody'); var servers = []; var safServerSets = []; var serverConfigs = []; var interfaceId = $('#interfaceId').val(); for (var i = 0; i < trs.length; i++) { var ip = trs[i].attr('data-ip').trim(); var port = trs[i].attr('data-port').trim(); var alias = trs[i].attr('alias').trim(); var protocol = trs[i].attr('data-protocol'); jsfVers.push(trs[i].attr('jv').trim()); var server = { id: trs[i].children(':eq(0)').find("input").val(), pid: trs[i].attr('pid'), uniqKey: trs[i].attr('uniqKey'), startTime: trs[i].attr('data-startTime1'), safVer: trs[i].attr('jsfversion').trim(), ip: ip, port: port, alias: alias, protocol: protocol, interfaceId: interfaceId }; servers.push(server); var serverUnikey = ip + ';' + port + ';' + alias + ';' + protocol + ';' + interfaceId; var safServerSet = { interfaceId: $('#resId').val(), serverUnikey: serverUnikey }; safServerSets.push(safServerSet); } var trs_ = $('#pinConfigPTable_iface', parent.document).children('tr'); for (var i = 0; i < trs_.length; i++) { var attr = {}; var newMock = $(trs_[i]).children(':eq(1)').find("input").val(); var oldMock = $(trs_[i]).children(':eq(1)').find("select").val(); if (newMock != oldMock && jsfVers[i].indexOf('JSF') >= 0 && jsfVers[i] < 'JSF1200') { attr['mock'] = newMock; } var oldCon = $(trs_[i]).children(':eq(2)').find("input").eq(1).val(); var newCon = $(trs_[i]).children(':eq(2)').find("input").eq(0).val(); if (oldCon != newCon) { attr['concurrents'] = newCon; } var oldW = $(trs_[i]).children(':eq(3)').find("input").eq(1).val(); var newW = $(trs_[i]).children(':eq(3)').find("input").eq(0).val(); if (oldW != newW) { attr['weight'] = newW; } var oldCache = $(trs_[i]).children(':eq(4)').find("input").val(); var newCache = $(trs_[i]).children(':eq(4)').find("select").val(); if (oldCache != newCache) { attr['cache'] = newCache; } var serverConfig = {}; var oldCoreThreads = $(trs_[i]).children(':eq(5)').find("input").eq(1).val(); var newCoreThreads = $(trs_[i]).children(':eq(5)').find("input").eq(0).val(); if (oldCoreThreads != newCoreThreads) { serverConfig['coreThreads'] = newCoreThreads; } var oldMaxThreads = $(trs_[i]).children(':eq(6)').find("input").eq(1).val(); var newMaxThreads = $(trs_[i]).children(':eq(6)').find("input").eq(0).val(); if (oldMaxThreads != newMaxThreads) { serverConfig['maxThreads'] = newMaxThreads; } serverConfigs.push(serverConfig); attrs.push(attr); } var trs = $('#pinConfigPTable_method', parent.document).children('tr'); for (var i = 0; i < trs_.length; i++) { for (var j = i; j < methodP.length * trs_.length; j += trs_.length) { var method = $(trs[j]).children(':eq(1)').text().trim(); var oldM_ = $(trs[j]).children(':eq(2)').find("input").val(); var newM_ = $(trs[j]).children(':eq(2)').find("select").val(); if (oldM_ != newM_) { attrs[i]['.' + method + '.mock'] = newM_; } var oldCon_ = $(trs[j]).children(':eq(3)').find("input").eq(1).val(); var newCon_ = $(trs[j]).children(':eq(3)').find("input").eq(0).val(); if (oldCon_ != newCon_) { attrs[i]['.' + method + '.concurrents'] = newCon_; } var oldCache_ = $(trs[j]).children(':eq(4)').find("input").val(); var newCache_ = $(trs[j]).children(':eq(4)').find("select").val(); if (oldCache_ != newCache_) { attrs[i]['.' + method + '.cache'] = newCache_; } } } objects.push(servers); objects.push(attrs); objects.push(safServerSets); objects.push(serverConfigs); $('#pinConfigModal_p', parent.document).modal('hide'); $.ajax({ url: url, data: JSON.stringify(objects), success: function (result) { _successFun(result, function () { $('#serverSubmit').trigger('click'); if (result.code != 1) { warning(result.msg); } else { $('#pinConfigPTable_method').empty(); methodP = []; } }); } }); }); $('#testSubscribe').click(function () { $('#testSubModal').modal('show'); }); var testSubscribeTable = $("#testSubTable").dataTable({ "searching": false, "ordering": false, "processing": false, "columns": [ { "title": "主机" }, { "title": "端口" }, { "title": "别名" }, { "title": "协议" } ], "language": { "emptyTable": "表中数据为空", "info": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项", "infoEmpty": "显示第 0 至 0 项结果,共 0 项", "infoFiltered": "(由 _MAX_ 项结果过滤)", "infoPostFix": "", "thousands": ",", "lengthMenu": "显示 _MENU_ 项结果", "loadingRecords": "载入中...", "processing": "处理中...", "search": "接口名:", "zeroRecords": "没有匹配结果", "paginate": { "first": "首页", "last": "末页", "next": "下一页", "previous": "上一页" }, "aria": { "sortAscending": ": 以升序排列此列", "sortDescending": ": 以降序排列此列" } } }); $('#getSubUrl').click(function () { var protocol = $('#subProtocol', parent.document).val(); var text = $("#subProtocol", parent.document).find("option:selected").text().trim(); var alias = $('#subAlias', parent.document).val(); var key = $('#subRegistry', parent.document).val(); var subIp = $('#subIp', parent.document).val(); $.ajax({ url: '/iface/manage/testSubscribe', contentType: 'application/x-www-form-urlencoded', data: { interfaceName: $('#interfaceName').val(), protocol: protocol, alias: alias, key: key, subIp:subIp }, type: 'POST', async: false, success: function (result) { if (result.code == 1) { testSubscribeTable.fnClearTable(); var servers = result.content.providers; if (servers != null && servers.length > 0) { for (var i = 0; i < servers.length; i++) { testSubscribeTable.fnAddData([servers[i].ip, servers[i].port, servers[i].alias, text]);//add new row } } var time; try { var version = result.content.configs["interface.alias.version"]; if (version != "null" && version != "0") { var date = new Date(parseInt(version)); time = date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); $('#divTestAliasVersion', parent.document).html("<b>alias版本号:</b>" + version + " ( " + time + " )"); } else { $('#divTestAliasVersion', parent.document).html(""); } } catch(e) {} } else { $('#testSubModal', parent.document).modal('hide'); warning(result.msg); } } }); }); $('#attr_method_p').change(function () { checkShowAttr(parent.document); }); $('#attr_method_c').change(function () { checkShowAttr(parent.document); }); $('#chgAlias').click(function () { if (!hasChecked('clientTbody')) { warning("请至少选择一个节点进行操作!"); return false; } /** var alias = []; var serverTrs = $('#serverTbody').children('tr'); if(serverTrs == null || serverTrs.length == 0){ warning("无提供者!"); return false; } for(var i = 0; i < serverTrs.length; i++){ var a = $(serverTrs[i]).children(':eq(3)').text(); if(hasText(a) && $.inArray(a, alias) < 0){ alias.push(a); } a = $(serverTrs[i]).children(':eq(4)').text(); if(hasText(a)){ var split = a.split(','); for(var j = 0; j < split.length; j++){ if($.inArray(split[j].trim(), alias) < 0){ alias.push(split[j].trim()); } } } } */ var clientTrs = getAllTrByChecked('clientTbody'); $('#chgAliasTbody').empty(); //$('#aliasToChange').empty(); for (var i = 0; i < clientTrs.length; i++) { var html = '<tr>'; html += '<td><span>' + clientTrs[i].attr('ip') + '</span></td>'; html += '<td><span>' + clientTrs[i].attr('alias') + '</span></td>'; html += '<td><span>' + clientTrs[i].attr('pid') + '</span></td>'; html += '<td><span>' + clientTrs[i].children(':eq(6)').text() + '</span></td>'; html += '</tr>'; $('#chgAliasTbody').append(html); } /** for(var i = 0; i < alias.length; i++){ $('#aliasToChange').append("<option value='"+alias[i]+"'>"+alias[i]+"</option>"); }*/ $('#chgAliasModal').modal('show'); }); $('#doChglAlias').click(function () { var url = '/iface/manage/' + $('#interfaceName').val() + '/client_chgalias/' + $('#resId').val(); var trs = getAllTrByChecked('clientTbody'); var clients = []; var attrs = []; for (var i = 0; i < trs.length; i++) { var client = { id: trs[i].children(':eq(0)').find("input").val(), ip: trs[i].attr('ip').trim(), alias: trs[i].attr('alias').trim(), pid: trs[i].attr('pid').trim(), protocol: trs[i].attr('data-protocol'), insKey: trs[i].attr('insKey'), startTime: trs[i].attr('startTime'), safVer: trs[i].attr('jsfversion').trim() }; clients.push(client); var attr = {}; attr['alias'] = $('#aliasToChange', parent.document).val(); attrs.push(attr); } var objects = []; objects.push(clients); objects.push(attrs); $.ajax({ url: url, data: JSON.stringify(objects), success: function (result) { $('#chgAliasModal', parent.document).modal('hide'); _successFun(result, function () { if (result.code != 1) { warning(result.msg); } }); } }); }); $('#stopConsumer').click(function () { stopConsumer(); }); $('#displayTab a').click(function (e) { e.preventDefault();//阻止a链接的跳转行为 $(this).tab('show');//显示当前选中的链接及关联的content var id = $(this).attr('metrics'); if (id == "superAdminView") { $('#superAdminView', parent.document).addClass('active'); $('#nomalClientView', parent.document).removeClass('active'); } else { $('#superAdminView', parent.document).removeClass('active'); $('#nomalClientView', parent.document).addClass('active'); } }); $('#displayTab a:first').trigger('click'); $('#displayTab_client a').click(function (e) { e.preventDefault();//阻止a链接的跳转行为 $(this).tab('show');//显示当前选中的链接及关联的content var id = $(this).attr('metrics'); if (id == "superAdminView_client") { $('#superAdminView_client', parent.document).addClass('active'); $('#nomalClientView_client', parent.document).removeClass('active'); } else { $('#superAdminView_client', parent.document).removeClass('active'); $('#nomalClientView_client', parent.document).addClass('active'); } }); $('#displayTab_client a:first').trigger('click'); $("#r-alias").on("change", function () { relationsModal($("#interfaceName1", parent.document).attr("iface"), $("#r-alias", parent.document).val(), 1); }); $("#checkAll").on("click", function () {//全选 if ($(this).attr('value') == 0) { $("#input[name='checkList']").prop("checked", true); $("#serverTable").find(':checkbox').not('[disabled]').prop('checked', true); $(this).attr('value', 1); } else { $("#serverTable").find(':checkbox').not('[disabled]').prop('checked', false); $(this).attr('value', 0); } }); serverTable = $("#serverTable").dataTable({ "searching": false, "ordering": false, //"bLengthChange": true, //"iDisplayLength" : 10, "processing": false, "serverSide": true, "scrollY": 500, "scrollCollapse": true, "ajax": { "url": "/iface/manage/server/detail/new", "type": "POST", "contentType": "application/x-www-form-urlencoded; charset=UTF-8", "data" : function(d) { d.refresh = $("#refresh").val(), d.interfaceName = $("#interfaceName").val(), d.interfaceId = $("#interfaceId").val(), d.ip = $("#ip").val(), d.serverAlias = $("#serverAlias").val(), d.safVer = $("#safVer").val(), d.src = $("#src").val(), d.isdead = $("#isdead").val(), d.room = $("#room").val() }, "dataSrc": function (json) { serverTableExtData = json.content.ext; $('#updateTime').html(serverTableExtData.updateTime); json.draw = json.content.data.draw; json.recordsTotal = json.content.data.recordsTotal; json.recordsFiltered = json.content.data.recordsFiltered; json.data = json.content.data.data; return json.data; } }, "columns": [ {"data": "check", "visible" : true}, {"data": "ip", "visible" : true}, {"data": "port", "visible" : true}, {"data": "alias", "visible" : true}, {"data": "relateAlias", "visible" : true}, {"data": "protocol", "visible" : true}, {"data": "jsfVersion", "visible" : true}, {"data": "room", "visible" : true}, {"data": "pid", "visible" : true}, {"data": "status", "visible" : true}, {"data": "opt", "visible" : true}, {"data": "id", "visible" : false}, {"data": "preDeploy", "visible" : false}, {"data": "insRoom", "visible" : false}, {"data": "hasRepRelateAlias", "visible" : false}, {"data": "srcType", "visible" : false} ], "columnDefs": [ { orderable: false, "data": "id", "render": function (data, type, full) { return '<input type="checkbox" name="checkList" value="' + full.id + '">'; }, targets: 0 }, { "targets": [1], "data": "ip", "render": function (data, type, full) { var isPredeploy = full.preDeploy; var ipTd = ""; if (hasText(isPredeploy) && isPredeploy == 1) { ipTd = '<div style="color:green;" title="取消操作在:更多-预发布取消">' + data + ' <span class="label label-info">预发布</span></div>'; } else { ipTd = '<div title="">' + data + '</td>'; } return ipTd; } }, { "targets": [3], "data": "alias", "render": function (data, type, full) { var alias = data; if (full.hasRepRelateAlias == 1) { alias = '<s title="被替换(不被订阅)">' + data + '</s>'; } return alias; } }, { "targets": [4], "data": "relateAlias", "render": function (data, type, full) { var relateAlias = ''; if (data != null && data.length != 0) { for (var j = 0; j < data.length; j++) { if (data[j].aliasType == 1) { relateAlias = relateAlias + '<span title="替换">' + data[j].aliasName + '</span>'; } else { relateAlias = relateAlias + '<span title="追加">' + data[j].aliasName + '</span>'; } if (j < data.length - 1) { relateAlias = relateAlias + ' , '; } } } return relateAlias; } }, { "targets": [5], "data": "protocol", "render": function (data, type, full) { return serverTableExtData.protocol[data]; } }, { "targets": [7], "data": "room", "render": function (data, type, full) { return serverTableExtData.computerRoom[data]; } }, { "targets": [9], "data": "status", "render": function (data, type, full) { var online = ''; if (data == 1 && full.optType == 1) { online = '<span class="label label-success" title="正常(被订阅,有心跳)">正常</span>'; } else if (data == 1 && full.optType == 0) { online = '<span class="label label-warning" title="下线(不被订阅,有心跳)">下线</span>'; } else if (data == 0 && full.optType == 1) { online = '<span class="label label-important" title="无心跳(被订阅,与注册中心断开连接)">无心跳</span>'; } else { online = '<span class="label label-inverse" title="死亡并下线(不被订阅,无心跳)">死亡</span>'; } return online; } }, { "targets": [10], "data": "id", "render": function (data, type, full) { var gotest = ""; if (ENV) { gotest = '<a class="btn" href="http://et.jd.com/saf/index.shtml?interfaceName='+$("#interfaceName").val()+'&protocol='+serverTableExtData.protocol[full.protocol]+'&alias='+full.alias+'" target="_blank">去测试</a> '; } var invoke = ''; if(serverTableExtData.superAdmin){ invoke = '<button class="btn" onclick="javascript:showInvoke(this);" name="invoke">方法调用</button>'; } return gotest+ '<button class="btn" onclick="javascript:serverDetail(this);" name="detail">详情</button> '+ '<button class="btn" onclick="javascript:serverCfg(this);" name="serverCfg">配置</button> ' + invoke } } ], "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) { $(nRow).attr('preDeploy',aData.preDeploy); $(nRow).attr('jv',aData.jsfVersion); $(nRow).attr('alias',aData.alias); $(nRow).attr('data-protocol',aData.protocol); $(nRow).attr('jsfversion',aData.safVer); $(nRow).attr('data-ip',aData.ip); $(nRow).attr('data-port',aData.port); $(nRow).attr('data-appPath',aData.appPath); $(nRow).attr('data-contextPath',aData.contextPath); $(nRow).attr('data-startTime1',aData.startTime); $(nRow).attr('data-startTime',formatDate(aData.startTime)); $(nRow).attr('data-updateTime',formatDate(aData.updateTime)); $(nRow).attr('data-weight',aData.weight); $(nRow).attr('pid',aData.pid); $(nRow).attr('data-insKey',aData.insKey); }, "drawCallback": function( settings ) { var api = this.api(); $(api.table().body()).attr('id', "serverTbody"); }, "language": { "url": "../../../js/plugins/dataTables/i18n/Chinese.json" }, "dom": 'tr<"row-fluid"<"span3"i><"span3"l><"span6"p>>' }); $("#checkAll2").on("click", function () {//全选 if ($(this).attr('value') == 0) { $("#input[name='checkList']").prop("checked", true); $("#clientTable").find(':checkbox').not('[disabled]').prop('checked', true); $(this).attr('value', 1); } else { $("#clientTable").find(':checkbox').not('[disabled]').prop('checked', false); $(this).attr('value', 0); } }); if (!ENV) { mockVisible = false; } else { mockVisible = true; } clientTable = $("#clientTable").dataTable({ "searching": false, "ordering": false, //"bLengthChange": true, //"iDisplayLength" : 10, "processing": false, "serverSide": true, "scrollY": 500, "scrollCollapse": true, "ajax": { "url": "/iface/manage/client/detail/new", "type": "POST", "contentType": "application/x-www-form-urlencoded; charset=UTF-8", "data" : function(d) { d.refresh = $("#cRefresh").val(), d.interfaceName = $("#cInterfaceName").val(), d.interfaceId = $("#cInterfaceId").val(), d.ip = $("#cIp").val(), d.alias = $("#cAlias").val(), d.safVer = $("#cSafVer").val(), d.clientStatus = $("#clientStatus").val(), d.appName = $("#appName").val() }, "dataSrc": function (json) { clientTableExtData = json.content.ext; json.draw = json.content.data.draw; json.recordsTotal = json.content.data.recordsTotal; json.recordsFiltered = json.content.data.recordsFiltered; json.data = json.content.data.data; return json.data; } }, "columns": [ {"data": "check", "visible" : true}, {"data": "ip", "visible" : true}, {"data": "alias", "visible" : true}, {"data": "pid", "visible" : true}, {"data": "jsfVersion", "visible" : true}, {"data": "srcType", "visible" : true}, {"data": "protocol", "visible" : true}, {"data": "appName", "visible" : true}, {"data": "status", "visible" : true}, {"data": "inblacklist", "visible" : true}, {"data": "mock", "visible" : mockVisible}, {"data": "opt", "visible" : true}, {"data": "id", "visible" : false}, {"data": "insRoom", "visible" : false}, {"data": "ifaceMockOpen", "visible" : false}, {"data": "appId", "visible" : false} ], "columnDefs": [ { orderable: false, "data": "id", "render": function (data, type, full) { return '<input type="checkbox" name="checkList" value="' + full.id + '">'; }, targets: 0 }, { "targets": [1], "data": "ip", "render": function (data, type, full) { var insRoom = clientTableExtData.computerRoom[full.insRoom]; var ipTd = '<div title="' + insRoom + '">' + data + '</div>'; return ipTd; } }, { "targets": [6], "data": "protocol", "render": function (data, type, full) { var client_pro = clientTableExtData.protocol[data]; if (!hasText(client_pro)) { client_pro = '未知'; } return client_pro; } }, { "targets": [5], "data": "srcType", "render": function (data, type, full) { var src = ""; if (data == 1) { src = 'registry'; } else if (data == 2) { src = 'manual'; } else { src = 'zookeeper'; } return src; } }, { "targets": [7], "data": "appName", "render": function (data, type, full) { var appName = full.appName == null ? "" : full.appName; var appId = full.appId == null ? "" : full.appId; return '<a title="'+appId+'" appId="'+appId+'" appName="'+appName+'" onclick="javascript:showApp(this);" href="javascript:void(0);">' + appName + '</a>'; } }, { "targets": [8], "data": "status", "render": function (data, type, full) { var online; if (data == 1) { online = '<span class="label label-success" title="正常">正常</span>'; } else { online = '<span class="label label-important" title="与注册中心断开连接">无心跳</span>'; } return online; } }, { "targets": [9], "data": "inblacklist", "render": function (data, type, full) { var blacklist = clientTableExtData.blacklist; var inblacklist = isInblacklist(blacklist, full.ip) ? '<font color=red><strong>是</strong></font>' : '<font color=green><strong>否</strong></font>'; return inblacklist; } }, { "targets": [10], "data": "mock", "render": function (data, type, full) { var mockOpened = mockIsOpened(full.ifaceMockOpen) ? '<font color=red><strong>开启</strong></font>' : '<font color=green><strong>关闭</strong></font>'; return mockOpened; }, "visible" : mockVisible }, { "targets": [11], "data": "id", "render": function (data, type, full) { return '<button class="btn" name="viewClient" onclick="javascript:clientCfg(this);">查看配置</button> <button class="btn" name="clientip" onclick="javascript:clientipinfo(this);">负责人</button>'; } } ], "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) { $(nRow).attr('jsfversion',aData.safVer); $(nRow).attr('pid',aData.pid); $(nRow).attr('alias',aData.alias); $(nRow).attr('ip',aData.ip); $(nRow).attr('data-apppath',aData.appPath); $(nRow).attr('data-urldesc',aData.safUrlDesc); $(nRow).attr('data-protocol',aData.protocol); $(nRow).attr('startTime',aData.startTime); $(nRow).attr('jsfVer',aData.jsfVersion); }, "drawCallback": function( settings ) { var api = this.api(); $(api.table().body()).attr('id', "clientTbody"); }, "language": { "url": "../../../js/plugins/dataTables/i18n/Chinese.json" }, "dom": 'tr<"row-fluid"<"span3"i><"span3"l><"span6"p>>' }); }); var serverTable; var serverTableExtData; var mockVisible = true; //test env function getAllCheckboxByChecked() { var checkboxs = []; $("#serverTable").find(':checkbox:checked').each(function () { var row = $(this); if (row.attr("id") != 'checkAll') { checkboxs.push(row.val()); } }); return checkboxs; } var clientTable; var clientTableExtData; function getAllCheckboxByChecked2() { var checkboxs = []; $("#serverTable").find(':checkbox:checked').each(function () { var row = $(this); if (row.attr("id") != 'checkAll2') { checkboxs.push(row.val()); } }); return checkboxs; } // 对Date的扩展,将 Date 转化为指定格式的String // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) // 例子: // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 Date.prototype.Format = function(fmt) { //author: meizz var o = { "M+" : this.getMonth()+1, //月份 "d+" : this.getDate(), //日 "h+" : this.getHours(), //小时 "m+" : this.getMinutes(), //分 "s+" : this.getSeconds(), //秒 "q+" : Math.floor((this.getMonth()+3)/3), //季度 "S" : this.getMilliseconds() //毫秒 }; if(/(y+)/.test(fmt)) fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); for(var k in o) if(new RegExp("("+ k +")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length))); return fmt; } function clientipinfo(obj) { $('#clientipApp').html(''); var ip = $(obj).parents('tr').children(':eq(1)').text().trim(); $.ajax({ url: '/iface/manage/getConsumerApp', type: 'post', contentType: 'application/x-www-form-urlencoded', timeout: 20000, data: { ip: ip, }, success: function (result) { if (result.code == 1) { var res = result.content; if (res != null) { var table = $(res['ipInfo']); var th = table.children('thead').children('tr').children('th'); if (th != null && th.length != 0) { $(th[th.length - 1]).remove(); } var td = table.children('tbody').children('tr').children('td'); if (td != null && td.length != 0) { $(td[td.length - 1]).remove(); } $('#clientipApp').append(table); $('#clientipApp').append(res['ipAppInfo']); } else { $('#clientipApp').html('未取得任何内容'); } $('#clientipModal').modal('show'); } else { warning(result.msg); } } }); } function stopConsumer() { if (!hasChecked('clientTbody')) { warning("请至少选择一个调用方进行操作!"); return false; } var trs = getAllTrByChecked('clientTbody'); var clients = []; for (var i = 0; i < trs.length; i++) { var client = { ip: trs[i].attr('ip').trim(), alias: trs[i].attr('alias').trim(), interfaceName: $('#interfaceName').val(), interfaceId: $('#resId').val() }; clients.push(client); } ensure("该ip将被加入调用黑名单, 继续?", function () { $.ajax({ url: '/iface/manage/stopConsumer/' + $('#resId').val(), data: JSON.stringify(clients), success: function (result) { _successFun(result, function () { $('#clientSubmit').trigger('click'); }); }, error: function (XMLHttpRequest, textStatus, errorThrown) { closeModel(); } }); }); } function checkShowAttr(obj) { var method1 = $('#attr_method_c', obj).val(); if (hasText(method1)) { $('#addCMethod', obj).show(); $('#pinConfigCTable_method', obj).parents('table').show(); } else { $('#pinConfigCTable_method', obj).empty(); $('#pinConfigCTable_method', obj).parents('table').hide(); $('#addCMethod', obj).hide(); } var method2 = $('#attr_method_p', obj).val(); if (hasText(method2)) { $('#addPMethod', obj).show(); $('#pinConfigPTable_method', obj).parents('table').show(); } else { $('#pinConfigPTable_method', obj).empty(); $('#pinConfigPTable_method', obj).parents('table').hide(); $('#addPMethod', obj).hide(); } } function refreshSubscribe(url) { if (!hasChecked('clientTbody')) { warning("请至少选择一个调用方进行操作!"); return false; } var trs = getAllTrByChecked('clientTbody'); var clients = []; for (var i = 0; i < trs.length; i++) { var client = { id: trs[i].children(':eq(0)').find("input").val(), ip: trs[i].attr('ip').trim(), pid: trs[i].attr('pid').trim(), startTime: trs[i].attr('startTime'), safVer: trs[i].attr('jsfversion').trim(), }; clients.push(client); } $.ajax({ url: url, data: JSON.stringify(clients), success: function (result) { _successFun(result, function () { if (result.code != 1) { warning(result.msg); } }); } }); } function refreshServerConfig(url) { if (!hasChecked('serverTbody')) { warning("请至少选择一个调用方进行操作!"); return false; } var trs = getAllTrByChecked('serverTbody'); var servers = []; for (var i = 0; i < trs.length; i++) { var server = { id: trs[i].children(':eq(0)').find("input").val(), ip: trs[i].attr('data-ip').trim(), pid: trs[i].attr('pid').trim(), startTime: trs[i].attr('data-startTime1'), safVer: trs[i].attr('jsfversion').trim(), interfaceId: $('#interfaceId').val() }; servers.push(server); } $.ajax({ url: url, data: JSON.stringify(servers), success: function (result) { _successFun(result, function () { if (result.code != 1) { warning(result.msg); } }); } }); } function initPagingServer(currentPage, totalPages) { $('#pageServer').bootstrapPaginator({ alignment: 'right', numberOfPages: 7, currentPage: currentPage, totalPages: totalPages, useBootstrapTooltip: true, itemTexts: function (type, page, current) { switch (type) { case "first": return '<span style="cursor:pointer"><img src="/css/images/page_first.gif"/></span>'; case "prev": return '<span style="cursor:pointer"><img src="/css/images/page_prev.gif"/></span>'; case "next": return '<span style="cursor:pointer"><img src="/css/images/page_next.gif"/></span>'; case "last": return '<span style="cursor:pointer"><img src="/css/images/page_last.gif"/></span>'; case "page": return '<span style="cursor:pointer">' + page + '</span>'; return page; } }, onPageClicked: function (event, originalEvent, type, page) { $('#pageIndexS').val(page); loadServer(); } }); } function initPagingClient(currentPage, totalPages) { $('#pageClient').bootstrapPaginator({ alignment: 'right', numberOfPages: 7, currentPage: parseIntById('pageIndexC'), totalPages: parseIntById('totalPageC'), useBootstrapTooltip: true, itemTexts: function (type, page, current) { switch (type) { case "first": return '<span style="cursor:pointer"><img src="/css/images/page_first.gif"/></span>'; case "prev": return '<span style="cursor:pointer"><img src="/css/images/page_prev.gif"/></span>'; case "next": return '<span style="cursor:pointer"><img src="/css/images/page_next.gif"/></span>'; case "last": return '<span style="cursor:pointer"><img src="/css/images/page_last.gif"/></span>'; case "page": return '<span style="cursor:pointer">' + page + '</span>'; } }, onPageClicked: function (event, originalEvent, type, page) { $('#pageIndexC').val(page); loadClient(); } }); } function loadServer() { $.ajax({ url: "/iface/manage/server/detail/", // 提交的页面 contentType: 'application/x-www-form-urlencoded', data: $('#serverForm').serialize(), // 从表单中获取数据 type: 'POST', async: true, success: function (msg) { if (msg.code == 1) { createServers(msg); var paging = msg.content.paging; if (paging != null && paging.result != null && paging.result.length != 0) { $('#pageS').html('共' + paging.totalPage + '页 ' + paging.totalRecord + '记录'); $('#totalPageS').val(paging.totalPage); } if (paging.totalPage > 0) { $('#pageServer_').show(); initPagingServer(parseIntById('pageIndexS'), paging.totalPage); } else { $('#pageServer_').hide(); } } else { warning(msg.msg); return; } } }); } function loadClient() { $.ajax({ url: "/iface/manage/client/detail", // 提交的页面 contentType: 'application/x-www-form-urlencoded', data: $('#clientForm').serialize(), // 从表单中获取数据 type: 'POST', async: true, success: function (msg) { if (msg.code == 1) { createClients(msg); var paging = msg.content.paging; if (paging != null && paging.result != null && paging.result.length != 0) { $('#pageC').html('共' + paging.totalPage + '页 ' + paging.totalRecord + '记录'); $('#totalPageC').val(paging.totalPage); } if (paging.totalPage > 0) { $('#pageClient_').show(); initPagingClient(parseIntById('pageIndexc'), paging.totalPage); } else { $('#pageClient_').hide(); } } else { warning(msg.msg); return; } } }); } function doImport() { var value = $('#serverFile').val(); if (!hasText(value)) { $('#serverFile').parents('div[class=control-group]').addClass('error'); $('#serverFile').nextAll('span').removeClass('hide'); return false; } else { $('#serverFile').parents('div[class^=control-group]').removeClass('error'); $('#serverFile').nextAll('span').addClass('hide'); } $('#importForm').ajaxSubmit({ contentType: 'application/x-www-form-urlencoded', data: { interfaceName: $('#interfaceName').val(), serverFile: value }, success: function (result) { $("#importDialog").dialog('close'); $("#importDialog").addClass('hide'); _successFun(result, function () { if (result.code == 1) { $('#serverSubmit').trigger('click'); } }); } }); } function clearClientPoint() { $('#attr_timeout_c').val(''); $('#attr_alias_c').val(''); $('#attr_retries_c').val(''); $('#attr_loadbalance_c').val(''); $('#attr_cluster_c').val(''); $('#attr_concurrents_c').val(''); $('#attr_method_concurrents_c').val(''); $('#attr_method_retries_c').val(''); $('#attr_method_timeout_c').val(''); } function clearServerPoint() { $('#attr_alias_p').val(''); $('#attr_weight_p').val(''); $('#attr_concurrents_p').val(''); $('#attr_method_p').val(''); $('#attr_method_concurrents_p').val(''); } function setCtable_iface() { $('#pinConfigCTable_iface').empty(); var trs = getAllTrByChecked('clientTbody'); for (var i = 0; i < trs.length; i++) { var html = '<tr>'; html += '<td><span>' + trs[i].attr('ip') + ':' + trs[i].attr('pid') + '</span></td>'; html += '<td><input type="text" style="width:50px;" /><input type="hidden" /></td>'; html += '<td><input type="text" style="width:50px;" /><input type="hidden" /></td>'; html += '<td>' + '<select style="width: 70px;">' + '<option value="random">随机</option>' + '<option value="roundrobin">轮询</option>' + '<option value="leastactive">最少活跃数</option>' + '<option value="localpref">本地优先</option>' + '</select><input type="hidden" />' + '</td>'; html += '<td>' + '<select style="width: 70px;" disabled="disabled">' + '<option value=false>否</option>' + '<option value=true>是</option>' + '</select><input type="hidden" value="false"/>' + '</td>'; html += '<td><input type="text" style="width:50px;" /><input type="hidden" /></td>'; html += '<td>' + '<select style="width: 70px;">' + '<option value="failover">失败重试</option>' + '<option value="failfast">失败忽略</option>' + '<option value="broadcast">广播调用</option>' + '</select><input type="hidden" />' + '</td>'; html += '<td>' + '<select style="width: 70px;" disabled="disabled">' + '<option value=false>否</option>' + '<option value=true>是</option>' + '</select><input type="hidden" value="false"/>' + '</td>'; html += '</tr>'; $('#pinConfigCTable_iface').append(html); } } function setPtable_iface() { var trs = getAllTrByChecked('serverTbody'); $('#pinConfigPTable_iface').empty(); for (var i = 0; i < trs.length; i++) { var html = '<tr>'; html += '<td><span>' + trs[i].attr('data-ip') + ':' + trs[i].attr('data-port') + '</span></td>'; html += '<td>' + '<select style="width: 70px;" disabled="disabled">' + '<option value=false>否</option>' + '<option value=true>是</option>' + '</select><input type="hidden" value="false"/>' + '</td>'; html += '<td><input type="text" style="width:50px;" /><input type="hidden" /></td>'; html += '<td><input type="text" style="width:50px;" /><input type="hidden" /></td>'; html += '<td>' + '<select style="width: 70px;" disabled="disabled">' + '<option value=false>否</option>' + '<option value=true>是</option>' + '</select><input type="hidden" value="false"/>' + '</td>'; var jsfVersion = trs[i].attr('jv'); var is1601 = false; if (hasText(jsfVersion)) { var version = 0; try { version = jsfVersion.substring(3); version = parseInt(version); } catch (e) { $("#coreThreadsTh").hide(); $("#maxThreadsTh").hide(); } if (version >= 1601) { //TODO is1601 = true; html += '<td style="display:none"><input type="text" style="width:50px;" /><input type="hidden" /></td>'; html += '<td><input name="tipThread" rel="popover" type="text" style="width:50px;" /><input type="hidden" /></td>'; $("#coreThreadsTh").hide(); $("#maxThreadsTh").show(); } else { $("#coreThreadsTh").hide(); $("#maxThreadsTh").hide(); } } else { $("#coreThreadsTh").hide(); $("#maxThreadsTh").hide(); } html += '</tr>'; $('#pinConfigPTable_iface').append(html); } } function relationsModal(iface, alias, from) { var params = { interfaceName: iface, alias: alias }; $.ajax({ url: '/iface/manage/relations', contentType: 'application/x-www-form-urlencoded', data: params, success: function (result) { if (result.code == 1) { $('#appName1').html(result.content.appName); var apps = result.content.appClients; if (from == 0) { $('#consumerTbody').empty(); } if (from == 1) { $('#consumerTbody', parent.document).empty(); } var html = ''; var noappsum = 0; var totalIns = 0; for (var i = 0; i < apps.length; i++) { var appName = apps[i].appName; var appLevel = apps[i].appLevel; if (!hasText(appLevel)) { appLevel = ''; } if (!hasText(appName)) { appName = ''; } if (!hasText(apps[i].appId)) { try { noappsum = noappsum + apps[i].appClientCnt; } catch (e) { } } else { html += '<tr>' + '<td>' + apps[i].appId + '</td>' + '<td>' + appName + '</td>' + '<td>' + apps[i].appClientCnt + '</td>' + '<td>' + appLevel + '</td>' + '<tr/>'; } totalIns = totalIns + apps[i].appClientCnt; } if (noappsum > 0) { html += '<tr>' + '<td>其他</td>' + '<td>其他</td>' + '<td>' + noappsum + '</td>' + '<td>其他</td>' + '<tr/>'; } if (from == 0) { $('#totalIns').html(totalIns); $('#consumerTbody').append(html); } if (from == 1) { $('#totalIns', parent.document).html(totalIns); $('#consumerTbody', parent.document).append(html); } $('#relationsModal').modal('show'); } else { warning(result.msg); } } }); } function refleshInsSum(iface) { $.ajax({ url: '/iface/manage/refleshInsSum', contentType: 'application/x-www-form-urlencoded', data: { interfaceName: iface }, success: function (result) { if (result.code != 1) { warning(result.msg); } else { layer.alert("刷新同步成功", 6); } } }); }
相关推荐
JavaScript学习指南 JavaScript,一种广泛应用于网页和网络应用的脚本语言,是互联网上最流行的编程语言之一。它主要用于客户端的交互式网页开发,也可以在服务器端通过Node.js平台进行后端开发。JavaScript与Java...
Web前端学习资料,Javascript学习
JavaScript,作为WEB标签所指的,是用于创建交互式网页的脚本语言。它通常与HTML和CSS一起使用,构建动态、响应式的用户体验。 JavaScript的核心概念包括变量、数据类型、运算符、控制结构(如条件语句和循环)、...
相当于免费”表明这是一份JavaScript的学习资源,而描述中的“来自于软件公司的JAVA教程,9个课时打包奉送”却提到了JAVA,这里可能是一个小错误,因为标题中的"Javascript"通常指的是JavaScript,而非Java。...
### 面向对象JavaScript精要 #### 一、书籍概览 本书《面向对象JavaScript...通过学习本书,读者可以全面掌握面向对象编程的基本概念,并学会如何将这些概念应用到JavaScript中,从而编写出更加健壮、可维护的代码。
JavaScript,一种广泛应用于Web开发的脚本语言,是学习网页动态功能实现的关键。"javascript 学习利器"这个主题,意味着我们将深入探讨一系列有助于高效掌握JavaScript的工具、资源和实践方法。 首先,JavaScript的...
值类型是指数据在内存中的存储方式,JavaScript中有七种基本值类型:Undefined、Null、Boolean、Number、BigInt、String和Symbol。其中,Undefined和Null是特殊的数据类型,而Boolean、Number、BigInt、String和...
“javascript5.5.chm”可能指的是JavaScript 5.5版本的相关文档,这个版本包含了ECMAScript 5的一些特性。ECMAScript是JavaScript的标准,5.5可能是对5.1或5.0的一个小更新。这个文档可能会详细介绍新增的语法特性,...
JavaScript逆向是指通过分析和理解经过混淆的JavaScript代码,以及对代码执行过程的回溯和逆向学习,来揭示代码的真实意图和功能。猿人学JS混淆是一种常见的JavaScript混淆技术,通过对代码进行重构、变量名替换、...
画图软件可能指的是利用JavaScript进行图形绘制的例子,例如使用Canvas API或SVG(可缩放矢量图形)进行图形绘制。Canvas提供了丰富的绘图方法,可以创建2D图形,而SVG则适用于创建复杂的矢量图形,两者在网页设计和...
JavaScript 学习 - 提高篇 在本节课程中,我们将深入探讨 JavaScript 中的对象、函数、constructor 函数等高级概念。 JavaScript 中的对象 在 JavaScript 中,对象是一组数据的键值集合,类似于 Java 中的 ...
由于其语法简洁且易于学习,JavaScript成为初学者入门编程的首选语言之一。以下是对JavaScript的一些核心知识点的详细介绍: 1. **基础语法**:JavaScript的基础语法包括变量(var、let、const)、数据类型(如字符...
《JavaScript.chm》很可能是对JavaScript语言全面的介绍,包括ECMAScript规范、DOM(Document Object Model)操作、事件处理、AJAX(异步JavaScript和XML,现在更常指异步数据交换)以及面向对象编程。 《Jscript...
JavaScript手册还会涵盖DOM操作、BOM(浏览器对象模型)接口、事件处理、AJAX(异步JavaScript和XML,现在通常指xhr或fetch API)以及面向对象编程等内容。此外,随着版本的更新,像ES6、ES7乃至ES2022的新特性,如...
此外,标签“javascript 资料”表明这个压缩包中可能包含了其他与JavaScript相关的学习资源,如“LAMP兄弟连 原创PHP”可能是一个关于PHP的教程,LAMP通常指的是Linux、Apache、MySQL和PHP的组合,是搭建Web服务器的...
标题中的“ppk谈JavaScript”可能指的是Peter-Paul Koch(ppk)的一本书,他在JavaScript社区中是一位知名专家,特别在移动浏览器和跨平台兼容性方面有深入研究。ppk的书籍通常会涵盖JavaScript的基础知识,以及如何...
标题中的"javascript学习源码"指的是提供了一个学习JavaScript编程的资源,可能是某个项目或特定功能的源代码。这样的源码可以帮助初学者理解实际的编程实践,看到如何将理论知识应用到实际代码中。对于"javascript...
标题中的“javascript学习”指的是对这种语言的学习过程。JavaScript的学习涵盖了多个方面,包括但不限于语法、数据类型、变量、运算符、函数、控制语句等。 1. **JavaScript基础**(01 JavaScript基础.pdf):这是...
学习JavaScript对于那些已经熟悉其他编程语言的开发者来说同样重要,因为它是Web开发中无可替代的技术。 在HTML文档中,JavaScript代码通常被包含在标签内。开发人员可以选择将这些标签放置在HTML页面的头部或底部...