测试结果
@@ -114,9 +209,145 @@
}
}
- // 页面加载时清空结果
+ // 统计配置相关函数
+ function loadGlobalConfig() {
+ logResult('加载全局统计配置...');
+ $.get('/Statistics/GetGlobalStatisticsConfig', function(response) {
+ if (response.success) {
+ const config = response.data;
+ document.getElementById('globalSamples').checked = config.defaultSamples;
+ document.getElementById('globalRf').checked = config.defaultRf;
+ logResult('全局配置已加载: ' + JSON.stringify(config, null, 2));
+ } else {
+ logResult('加载全局配置失败: ' + response.message);
+ }
+ }).fail(function(xhr, status, error) {
+ logResult('加载全局配置错误: ' + error);
+ });
+ }
+
+ function saveGlobalConfig() {
+ const config = {
+ defaultSamples: document.getElementById('globalSamples').checked,
+ defaultRf: document.getElementById('globalRf').checked,
+ clientConfigs: []
+ };
+
+ logResult('保存全局统计配置...');
+ $.ajax({
+ url: '/Statistics/SetGlobalStatisticsConfig',
+ type: 'POST',
+ contentType: 'application/json',
+ data: JSON.stringify(config),
+ success: function(response) {
+ logResult('响应: ' + JSON.stringify(response, null, 2));
+ },
+ error: function(xhr, status, error) {
+ logResult('错误: ' + error);
+ }
+ });
+ }
+
+ function loadClientConfig() {
+ const clientName = document.getElementById('clientName').value;
+ if (!clientName) {
+ logResult('请输入客户端名称');
+ return;
+ }
+
+ logResult('加载客户端统计配置: ' + clientName);
+ $.get('/Statistics/GetClientStatisticsConfig', { clientName: clientName }, function(response) {
+ if (response.success && response.data) {
+ const config = response.data;
+ document.getElementById('clientName').value = config.clientName;
+ document.getElementById('clientIp').value = config.ipAddress;
+ document.getElementById('clientSamples').checked = config.enableSamples;
+ document.getElementById('clientRf').checked = config.enableRf;
+ document.getElementById('clientEnabled').checked = config.isEnabled;
+ document.getElementById('clientDescription').value = config.description;
+ logResult('客户端配置已加载: ' + JSON.stringify(config, null, 2));
+ } else {
+ logResult('客户端配置未找到或加载失败');
+ }
+ }).fail(function(xhr, status, error) {
+ logResult('加载客户端配置错误: ' + error);
+ });
+ }
+
+ function saveClientConfig() {
+ const config = {
+ clientName: document.getElementById('clientName').value,
+ ipAddress: document.getElementById('clientIp').value,
+ enableSamples: document.getElementById('clientSamples').checked,
+ enableRf: document.getElementById('clientRf').checked,
+ isEnabled: document.getElementById('clientEnabled').checked,
+ description: document.getElementById('clientDescription').value
+ };
+
+ if (!config.clientName) {
+ logResult('请输入客户端名称');
+ return;
+ }
+
+ logResult('保存客户端统计配置...');
+ $.ajax({
+ url: '/Statistics/SetClientStatisticsConfig',
+ type: 'POST',
+ contentType: 'application/json',
+ data: JSON.stringify(config),
+ success: function(response) {
+ logResult('响应: ' + JSON.stringify(response, null, 2));
+ loadAllClientConfigs(); // 刷新配置列表
+ },
+ error: function(xhr, status, error) {
+ logResult('错误: ' + error);
+ }
+ });
+ }
+
+ function loadAllClientConfigs() {
+ logResult('加载所有客户端配置...');
+ $.get('/Statistics/GetAllClientStatisticsConfigs', function(response) {
+ if (response.success) {
+ const configs = response.data;
+ const tbody = document.getElementById('configTableBody');
+ tbody.innerHTML = '';
+
+ configs.forEach(function(config) {
+ const row = document.createElement('tr');
+ row.innerHTML = `
+ ${config.clientName} |
+ ${config.ipAddress} |
+ ${config.enableSamples ? '是' : '否'} |
+ ${config.enableRf ? '是' : '否'} |
+ ${config.isEnabled ? '是' : '否'} |
+ ${config.description} |
+
+
+ |
+ `;
+ tbody.appendChild(row);
+ });
+
+ logResult('配置列表已更新,共 ' + configs.length + ' 个配置');
+ } else {
+ logResult('加载配置列表失败: ' + response.message);
+ }
+ }).fail(function(xhr, status, error) {
+ logResult('加载配置列表错误: ' + error);
+ });
+ }
+
+ function editConfig(clientName) {
+ document.getElementById('clientName').value = clientName;
+ loadClientConfig();
+ }
+
+ // 页面加载时初始化
$(document).ready(function() {
document.getElementById('testResult').textContent = '';
+ loadGlobalConfig();
+ loadAllClientConfigs();
});
}
\ No newline at end of file
diff --git a/LTEMvcApp/statistics_config.json b/LTEMvcApp/statistics_config.json
new file mode 100644
index 0000000..54bf085
--- /dev/null
+++ b/LTEMvcApp/statistics_config.json
@@ -0,0 +1,22 @@
+{
+ "defaultSamples": false,
+ "defaultRf": false,
+ "clientConfigs": [
+ {
+ "ipAddress": "192.168.13.12",
+ "clientName": "TestClient1",
+ "enableSamples": true,
+ "enableRf": false,
+ "isEnabled": true,
+ "description": "测试客户端1 - 启用samples"
+ },
+ {
+ "ipAddress": "192.168.13.13",
+ "clientName": "TestClient2",
+ "enableSamples": false,
+ "enableRf": true,
+ "isEnabled": true,
+ "description": "测试客户端2 - 启用rf"
+ }
+ ]
+}
\ No newline at end of file