|
|
@ -322,25 +322,25 @@ |
|
|
|
<td><code>${client.address}</code></td> |
|
|
|
<td> |
|
|
|
<div class="form-check d-flex justify-content-center"> |
|
|
|
<input class="form-check-input" type="checkbox" id="samples_${client.name}" |
|
|
|
onchange="updateConfig('${client.name}', 'samples', this.checked)"> |
|
|
|
<input class="form-check-input" type="checkbox" id="samples_${client.address}" |
|
|
|
onchange="updateConfig('${client.address}', 'samples', this.checked)"> |
|
|
|
</div> |
|
|
|
</td> |
|
|
|
<td> |
|
|
|
<div class="form-check d-flex justify-content-center"> |
|
|
|
<input class="form-check-input" type="checkbox" id="rf_${client.name}" |
|
|
|
onchange="updateConfig('${client.name}', 'rf', this.checked)"> |
|
|
|
<input class="form-check-input" type="checkbox" id="rf_${client.address}" |
|
|
|
onchange="updateConfig('${client.address}', 'rf', this.checked)"> |
|
|
|
</div> |
|
|
|
</td> |
|
|
|
<td> |
|
|
|
<div class="form-check d-flex justify-content-center"> |
|
|
|
<input class="form-check-input" type="checkbox" id="enabled_${client.name}" checked |
|
|
|
onchange="updateConfig('${client.name}', 'enabled', this.checked)"> |
|
|
|
<input class="form-check-input" type="checkbox" id="enabled_${client.address}" checked |
|
|
|
onchange="updateConfig('${client.address}', 'enabled', this.checked)"> |
|
|
|
</div> |
|
|
|
</td> |
|
|
|
<td> |
|
|
|
<div class="btn-group btn-group-sm"> |
|
|
|
<button class="btn btn-success" onclick="saveClientConfig('${client.name}')" title="保存"> |
|
|
|
<button class="btn btn-success" onclick="saveClientConfig('${client.address}')" title="保存"> |
|
|
|
<i class="fas fa-save"></i> |
|
|
|
</button> |
|
|
|
</div> |
|
|
@ -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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|