Browse Source

11111

feature/MultiClientLog
root 1 month ago
parent
commit
c73512d636
  1. 58
      LTEMvcApp/Views/Home/Index.cshtml

58
LTEMvcApp/Views/Home/Index.cshtml

@ -407,33 +407,53 @@
} }
function startTestClient(address) { function startTestClient(address) {
var row = $('tr').filter(function() {
return $(this).find('td:eq(1)').text().trim() === address;
});
$.ajax({ $.ajax({
url: '/api/testconfig/start', url: '/api/testconfig/start',
type: 'POST', type: 'POST',
contentType: 'application/json', contentType: 'application/json',
data: JSON.stringify({ address: address }), data: JSON.stringify({ address: address }),
success: function() { success: function() {
alert('启动请求已发送!页面将在2秒后刷新。'); showToast('启动请求已发送!', 'success');
setTimeout(() => location.reload(), 2000); // 更新当前行状态
row.find('td').eq(2).html('<span class="status-dot status-running"></span><span class="status-text">运行</span>');
// 更新按钮状态
row.find('.btn-primary').addClass('disabled');
row.find('.btn-danger').removeClass('disabled');
row.find('.btn-info').removeClass('disabled');
row.find('.btn-warning').addClass('disabled');
row.find('.btn-outline-danger').addClass('disabled');
}, },
error: function(xhr) { error: function(xhr) {
alert('启动失败:' + xhr.responseText); showToast('启动失败:' + xhr.responseText, 'error');
} }
}); });
} }
function stopTestClient(address) { function stopTestClient(address) {
var row = $('tr').filter(function() {
return $(this).find('td:eq(1)').text().trim() === address;
});
$.ajax({ $.ajax({
url: '/api/testconfig/stop', url: '/api/testconfig/stop',
type: 'POST', type: 'POST',
contentType: 'application/json', contentType: 'application/json',
data: JSON.stringify({ address: address }), data: JSON.stringify({ address: address }),
success: function() { success: function() {
alert('停止请求已发送!页面将在2秒后刷新。'); showToast('停止请求已发送!', 'success');
setTimeout(() => location.reload(), 2000); // 更新当前行状态
row.find('td').eq(2).html('<span class="status-dot status-stopped"></span><span class="status-text">停止</span>');
// 更新按钮状态
row.find('.btn-primary').removeClass('disabled');
row.find('.btn-danger').addClass('disabled');
row.find('.btn-info').addClass('disabled');
row.find('.btn-warning').removeClass('disabled');
row.find('.btn-outline-danger').removeClass('disabled');
}, },
error: function(xhr) { error: function(xhr) {
alert('停止失败:' + xhr.responseText); showToast('停止失败:' + xhr.responseText, 'error');
} }
}); });
} }
@ -471,9 +491,16 @@
data: JSON.stringify({ ip: ip, port: port, key: key }), data: JSON.stringify({ ip: ip, port: port, key: key }),
success: function(response) { success: function(response) {
showToast('网络启动成功', 'success'); showToast('网络启动成功', 'success');
// 立即更新状态列 // 解析嵌套的response字段
if (response && response.data === 1) { if (response && response.response) {
row.find('td').eq(6).html('<span class="status-dot status-running"></span><span class="status-text">运行</span>'); try {
var innerResponse = JSON.parse(response.response);
if (innerResponse && innerResponse.data === 1) {
row.find('td').eq(6).html('<span class="status-dot status-running"></span><span class="status-text">运行</span>');
}
} catch (e) {
console.log('解析响应数据失败:', e);
}
} }
loadAllNetworkConfigs(); loadAllNetworkConfigs();
}, },
@ -508,9 +535,16 @@
data: JSON.stringify({ ip: ip, port: port, key: key }), data: JSON.stringify({ ip: ip, port: port, key: key }),
success: function(response) { success: function(response) {
showToast('网络停止成功', 'success'); showToast('网络停止成功', 'success');
// 只要isSuccess为true就立即更新状态 // 解析嵌套的response字段
if (response && response.isSuccess) { if (response && response.response) {
row.find('td').eq(6).html('<span class="status-dot status-stopped"></span><span class="status-text">停止</span>'); try {
var innerResponse = JSON.parse(response.response);
if (innerResponse && innerResponse.isSuccess) {
row.find('td').eq(6).html('<span class="status-dot status-stopped"></span><span class="status-text">停止</span>');
}
} catch (e) {
console.log('解析响应数据失败:', e);
}
} }
loadAllNetworkConfigs(); loadAllNetworkConfigs();
}, },

Loading…
Cancel
Save