From 9d01b1f136ff237c182455c7ecc40b1d66624c70 Mon Sep 17 00:00:00 2001 From: root <295172551@qq.com> Date: Sat, 28 Jun 2025 16:37:23 +0800 Subject: [PATCH] ffds --- LTEMvcApp/Controllers/HomeController.cs | 8 - LTEMvcApp/Views/Statistics/Index.cshtml | 252 ++++++++++++++++++++++++ 2 files changed, 252 insertions(+), 8 deletions(-) diff --git a/LTEMvcApp/Controllers/HomeController.cs b/LTEMvcApp/Controllers/HomeController.cs index 67941f8..824cc02 100644 --- a/LTEMvcApp/Controllers/HomeController.cs +++ b/LTEMvcApp/Controllers/HomeController.cs @@ -297,12 +297,4 @@ public class HomeController : Controller ViewBag.IpGroups = ipGroups; return View(); } - - /// - /// 统计测试页面 - /// - public IActionResult StatisticsTest() - { - return View(); - } } diff --git a/LTEMvcApp/Views/Statistics/Index.cshtml b/LTEMvcApp/Views/Statistics/Index.cshtml index c787f0d..7abd2ed 100644 --- a/LTEMvcApp/Views/Statistics/Index.cshtml +++ b/LTEMvcApp/Views/Statistics/Index.cshtml @@ -137,6 +137,108 @@ + + +
+
+
+
+

统计配置管理

+
+
+
+
+
+
+
全局统计配置
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+ + +
+
+
+
+
+
+
客户端特定配置
+
+
+
+ + +
+
+ + +
+
+ +
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+ + +
+
+
+
+ +
+
+
配置列表
+ +
+ + + + + + + + + + + + + + +
客户端名称IP地址SamplesRF启用描述操作
+
+
+
+
+
+
+
@section Scripts { @@ -150,6 +252,10 @@ loadSummary(); loadAllStats(); startRefreshTimer(); + + // 新增的配置管理初始化 + loadGlobalConfig(); + loadAllClientConfigs(); }); // 加载统计摘要 @@ -340,5 +446,151 @@ clearInterval(refreshTimer); } }); + + // 统计配置管理相关函数 + function loadGlobalConfig() { + console.log('加载全局统计配置...'); + $.get('/Statistics/GetGlobalStatisticsConfig', function(response) { + if (response.success) { + const config = response.data; + document.getElementById('globalSamples').checked = config.defaultSamples; + document.getElementById('globalRf').checked = config.defaultRf; + console.log('全局配置已加载:', config); + } else { + console.error('加载全局配置失败:', response.message); + } + }).fail(function(xhr, status, error) { + console.error('加载全局配置错误:', error); + }); + } + + function saveGlobalConfig() { + const config = { + defaultSamples: document.getElementById('globalSamples').checked, + defaultRf: document.getElementById('globalRf').checked, + clientConfigs: [] + }; + + console.log('保存全局统计配置...'); + $.ajax({ + url: '/Statistics/SetGlobalStatisticsConfig', + type: 'POST', + contentType: 'application/json', + data: JSON.stringify(config), + success: function(response) { + console.log('全局配置保存响应:', response); + if (response.success) { + alert('全局配置已保存'); + } else { + alert('保存失败: ' + response.message); + } + }, + error: function(xhr, status, error) { + console.error('保存全局配置错误:', error); + alert('保存失败: ' + error); + } + }); + } + + function loadClientConfig() { + const clientName = document.getElementById('clientName').value; + if (!clientName) { + alert('请输入客户端名称'); + return; + } + + console.log('加载客户端统计配置:', 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; + console.log('客户端配置已加载:', config); + } else { + console.log('客户端配置未找到或加载失败'); + } + }).fail(function(xhr, status, error) { + console.error('加载客户端配置错误:', 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) { + alert('请输入客户端名称'); + return; + } + + console.log('保存客户端统计配置...'); + $.ajax({ + url: '/Statistics/SetClientStatisticsConfig', + type: 'POST', + contentType: 'application/json', + data: JSON.stringify(config), + success: function(response) { + console.log('客户端配置保存响应:', response); + if (response.success) { + alert('客户端配置已保存'); + loadAllClientConfigs(); // 刷新配置列表 + } else { + alert('保存失败: ' + response.message); + } + }, + error: function(xhr, status, error) { + console.error('保存客户端配置错误:', error); + alert('保存失败: ' + error); + } + }); + } + + function loadAllClientConfigs() { + console.log('加载所有客户端配置...'); + $.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); + }); + + console.log('配置列表已更新,共', configs.length, '个配置'); + } else { + console.error('加载配置列表失败:', response.message); + } + }).fail(function(xhr, status, error) { + console.error('加载配置列表错误:', error); + }); + } + + function editConfig(clientName) { + document.getElementById('clientName').value = clientName; + loadClientConfig(); + } } \ No newline at end of file