@@ -894,19 +894,19 @@ namespace LTEMvcApp.Services
{
foreach (var client in _clients.Values)
{
- UpdateClientStatisticsConfig(client.Config.Name);
+ UpdateClientStatisticsConfig(client.Config.Address);
}
}
///
/// 更新指定客户端的统计配置
///
- /// 客户端名称
- private void UpdateClientStatisticsConfig(string clientName)
+ /// 客户端IP地址
+ private void UpdateClientStatisticsConfig(string ipAddress)
{
- if (_clients.TryGetValue(clientName, out var client))
+ if (_clients.TryGetValue(ipAddress, out var client))
{
- var config = GetClientStatisticsConfig(clientName);
+ var config = GetStatisticsConfigByIp(ipAddress);
if (config != null && config.IsEnabled)
{
client.SetStatisticsConfig(config.EnableSamples, config.EnableRf);
diff --git a/LTEMvcApp/Views/Statistics/Config.cshtml b/LTEMvcApp/Views/Statistics/Config.cshtml
index 40226a7..11858da 100644
--- a/LTEMvcApp/Views/Statistics/Config.cshtml
+++ b/LTEMvcApp/Views/Statistics/Config.cshtml
@@ -322,25 +322,25 @@
${client.address} |
-
+
|
-
+
|
-
+
|
-
@@ -365,19 +365,19 @@
}
// 更新配置(实时保存到服务器)
- function updateConfig(clientName, field, value) {
- console.log(`更新配置: ${clientName} - ${field} = ${value}`);
+ function updateConfig(ipAddress, field, value) {
+ console.log(`更新配置: ${ipAddress} - ${field} = ${value}`);
if (field === 'samples') {
// 更新Samples参数
$.ajax({
- url: `/api/config/statistics/${encodeURIComponent(clientName)}/samples`,
+ url: `/api/config/statistics/${encodeURIComponent(ipAddress)}/samples`,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(value),
success: function(response) {
if (response.success) {
- console.log(`客户端 ${clientName} Samples参数已更新`);
+ console.log(`客户端 ${ipAddress} Samples参数已更新`);
} else {
console.error('更新Samples参数失败:', response.message);
showAlert('danger', `更新Samples参数失败: ${response.message}`);
@@ -391,13 +391,13 @@
} else if (field === 'rf') {
// 更新RF参数
$.ajax({
- url: `/api/config/statistics/${encodeURIComponent(clientName)}/rf`,
+ url: `/api/config/statistics/${encodeURIComponent(ipAddress)}/rf`,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(value),
success: function(response) {
if (response.success) {
- console.log(`客户端 ${clientName} RF参数已更新`);
+ console.log(`客户端 ${ipAddress} RF参数已更新`);
} else {
console.error('更新RF参数失败:', response.message);
showAlert('danger', `更新RF参数失败: ${response.message}`);
@@ -410,29 +410,28 @@
});
} else if (field === 'enabled') {
// 更新启用状态
- saveClientConfig(clientName);
+ saveClientConfig(ipAddress);
}
}
// 保存客户端配置
- function saveClientConfig(clientName) {
+ function saveClientConfig(ipAddress) {
const config = {
- clientName: clientName,
- ipAddress: '', // 将从客户端列表获取
- enableSamples: document.getElementById(`samples_${clientName}`).checked,
- enableRf: document.getElementById(`rf_${clientName}`).checked,
- isEnabled: document.getElementById(`enabled_${clientName}`).checked
+ ipAddress: ipAddress,
+ enableSamples: document.getElementById(`samples_${ipAddress}`).checked,
+ enableRf: document.getElementById(`rf_${ipAddress}`).checked,
+ isEnabled: document.getElementById(`enabled_${ipAddress}`).checked
};
- // 从已加载的客户端列表中获取IP地址
+ // 从已加载的客户端列表中获取客户端名称
const tbody = document.getElementById('clientConfigTableBody');
const rows = tbody.getElementsByTagName('tr');
for (let row of rows) {
- const nameCell = row.querySelector('td:first-child strong');
- if (nameCell && nameCell.textContent === clientName) {
- const ipCell = row.querySelector('td:nth-child(2) code');
- if (ipCell) {
- config.ipAddress = ipCell.textContent;
+ const ipCell = row.querySelector('td:nth-child(2) code');
+ if (ipCell && ipCell.textContent === ipAddress) {
+ const nameCell = row.querySelector('td:first-child strong');
+ if (nameCell) {
+ config.clientName = nameCell.textContent;
}
break;
}
@@ -440,14 +439,14 @@
console.log('保存客户端统计配置:', config);
$.ajax({
- url: `/api/config/statistics/${encodeURIComponent(clientName)}`,
+ url: `/api/config/statistics/${encodeURIComponent(ipAddress)}`,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(config),
success: function(response) {
console.log('客户端配置保存响应:', response);
if (response.success) {
- showAlert('success', `客户端 ${clientName} 配置已保存`);
+ showAlert('success', `客户端 ${ipAddress} 配置已保存`);
} else {
showAlert('danger', `保存失败: ${response.message}`);
}
@@ -470,7 +469,7 @@
// 将配置转换为字典,方便查找
configs.forEach(function(config) {
- configDict[config.clientName] = config;
+ configDict[config.ipAddress] = config;
});
// 更新表格中的配置
@@ -478,15 +477,15 @@
const rows = tbody.getElementsByTagName('tr');
for (let row of rows) {
- const nameCell = row.querySelector('td:first-child strong');
- if (nameCell) {
- const clientName = nameCell.textContent;
- const config = configDict[clientName];
+ const ipCell = row.querySelector('td:nth-child(2) code');
+ if (ipCell) {
+ const ipAddress = ipCell.textContent;
+ const config = configDict[ipAddress];
if (config) {
- row.querySelector(`#samples_${clientName}`).checked = config.enableSamples;
- row.querySelector(`#rf_${clientName}`).checked = config.enableRf;
- row.querySelector(`#enabled_${clientName}`).checked = config.isEnabled;
+ row.querySelector(`#samples_${ipAddress}`).checked = config.enableSamples;
+ row.querySelector(`#rf_${ipAddress}`).checked = config.enableRf;
+ row.querySelector(`#enabled_${ipAddress}`).checked = config.isEnabled;
}
}
}
|