|
|
@@ -3,15 +3,15 @@ using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
using System.Windows.Media;
|
|
|
using System.Windows.Media.Animation;
|
|
|
-using QuickIP.Client.Models;
|
|
|
-using QuickIP.Client.Services;
|
|
|
+using NetworkTool.Client.Models;
|
|
|
+using NetworkTool.Client.Services;
|
|
|
|
|
|
-namespace QuickIP.Client;
|
|
|
+namespace NetworkTool.Client;
|
|
|
|
|
|
public partial class DeviceDetailsWindow : Window
|
|
|
{
|
|
|
private const int ApplyConfirmationTimeoutSeconds = 20;
|
|
|
- private readonly AgentApiService _agentApiService = new();
|
|
|
+ private readonly ServerApiService _serverApiService = new();
|
|
|
private readonly string _baseAddress;
|
|
|
private readonly string _localIPv4;
|
|
|
private readonly string _password;
|
|
|
@@ -46,16 +46,16 @@ public partial class DeviceDetailsWindow : Window
|
|
|
private async Task LoadRemoteDetailsAsync()
|
|
|
{
|
|
|
ClearDetails();
|
|
|
- var device = await _agentApiService.GetDeviceInfoAsync(_baseAddress, _password, _localIPv4);
|
|
|
+ var device = await _serverApiService.GetDeviceInfoAsync(_baseAddress, _password, _localIPv4);
|
|
|
if (device is not null)
|
|
|
{
|
|
|
RemoteDeviceIdTextBlock.Text = device.DeviceId;
|
|
|
RemoteHostnameTextBlock.Text = device.Hostname;
|
|
|
RemoteOsVersionTextBlock.Text = device.OSVersion;
|
|
|
- RemoteAgentVersionTextBlock.Text = device.AgentVersion;
|
|
|
+ RemoteServerVersionTextBlock.Text = device.ServerVersion;
|
|
|
}
|
|
|
|
|
|
- var interfaces = await _agentApiService.GetInterfacesAsync(_baseAddress, _password, _localIPv4);
|
|
|
+ var interfaces = await _serverApiService.GetInterfacesAsync(_baseAddress, _password, _localIPv4);
|
|
|
if (interfaces is null)
|
|
|
{
|
|
|
ShowStatusMessage("设备已连接,但暂时无法读取 Linux 接口列表。");
|
|
|
@@ -79,7 +79,7 @@ public partial class DeviceDetailsWindow : Window
|
|
|
RemoteDeviceIdTextBlock.Text = "-";
|
|
|
RemoteHostnameTextBlock.Text = "-";
|
|
|
RemoteOsVersionTextBlock.Text = "-";
|
|
|
- RemoteAgentVersionTextBlock.Text = "-";
|
|
|
+ RemoteServerVersionTextBlock.Text = "-";
|
|
|
RemoteTargetInterfaceComboBox.ItemsSource = null;
|
|
|
RemoteConfigInterfaceTextBlock.Text = "-";
|
|
|
RemoteConfigIpTextBlock.Text = "-";
|
|
|
@@ -120,7 +120,7 @@ public partial class DeviceDetailsWindow : Window
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- var result = await _agentApiService.GetInterfaceConfigAsync(_baseAddress, _password, _localIPv4, interfaceName);
|
|
|
+ var result = await _serverApiService.GetInterfaceConfigAsync(_baseAddress, _password, _localIPv4, interfaceName);
|
|
|
if (!result.Success || result.Data is null)
|
|
|
{
|
|
|
RemoteConfigInterfaceTextBlock.Text = interfaceName;
|
|
|
@@ -180,7 +180,7 @@ public partial class DeviceDetailsWindow : Window
|
|
|
SetBusyState(true, "正在校验配置,请稍候...");
|
|
|
try
|
|
|
{
|
|
|
- var result = await _agentApiService.ValidateInterfaceConfigAsync(_baseAddress, _password, _localIPv4, request);
|
|
|
+ var result = await _serverApiService.ValidateInterfaceConfigAsync(_baseAddress, _password, _localIPv4, request);
|
|
|
_configValidated = result.Success && result.Data?.Valid == true;
|
|
|
if (result.Data is not null)
|
|
|
{
|
|
|
@@ -228,7 +228,7 @@ public partial class DeviceDetailsWindow : Window
|
|
|
SetBusyState(true, "正在提交并应用配置,请稍候...");
|
|
|
try
|
|
|
{
|
|
|
- var applyResult = await _agentApiService.ApplyInterfaceConfigAsync(_baseAddress, _password, _localIPv4, request);
|
|
|
+ var applyResult = await _serverApiService.ApplyInterfaceConfigAsync(_baseAddress, _password, _localIPv4, request);
|
|
|
if (!applyResult.Success || applyResult.Data is null)
|
|
|
{
|
|
|
ShowStatusMessage($"提交配置任务失败:{applyResult.Message}");
|
|
|
@@ -251,7 +251,7 @@ public partial class DeviceDetailsWindow : Window
|
|
|
for (var i = 0; i < 20; i++)
|
|
|
{
|
|
|
await Task.Delay(1000);
|
|
|
- var result = await _agentApiService.GetTaskAsync(_baseAddress, _password, _localIPv4, taskId);
|
|
|
+ var result = await _serverApiService.GetTaskAsync(_baseAddress, _password, _localIPv4, taskId);
|
|
|
if (!result.Success || result.Data is null)
|
|
|
{
|
|
|
if (result.StatusCode is null)
|
|
|
@@ -274,12 +274,12 @@ public partial class DeviceDetailsWindow : Window
|
|
|
var confirm = ShowApplyConfirmationDialog(ApplyConfirmationTimeoutSeconds);
|
|
|
if (confirm)
|
|
|
{
|
|
|
- var confirmResult = await _agentApiService.ConfirmApplyTaskAsync(_baseAddress, _password, _localIPv4, taskId);
|
|
|
+ var confirmResult = await _serverApiService.ConfirmApplyTaskAsync(_baseAddress, _password, _localIPv4, taskId);
|
|
|
ShowStatusMessage(confirmResult.Success ? "已发送保留配置确认。" : $"发送确认失败:{confirmResult.Message}");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- var cancelResult = await _agentApiService.CancelApplyTaskAsync(_baseAddress, _password, _localIPv4, taskId);
|
|
|
+ var cancelResult = await _serverApiService.CancelApplyTaskAsync(_baseAddress, _password, _localIPv4, taskId);
|
|
|
ShowStatusMessage(cancelResult.Success ? "已取消保留配置,正在回滚。" : $"发送取消失败:{cancelResult.Message}");
|
|
|
}
|
|
|
}
|
|
|
@@ -391,7 +391,7 @@ public partial class DeviceDetailsWindow : Window
|
|
|
await ExecuteSystemActionAsync(
|
|
|
"重启设备",
|
|
|
"设备将立即重启,当前窗口和连接可能马上中断。是否继续?",
|
|
|
- () => _agentApiService.RebootAsync(_baseAddress, _password, _localIPv4));
|
|
|
+ () => _serverApiService.RebootAsync(_baseAddress, _password, _localIPv4));
|
|
|
}
|
|
|
|
|
|
private async void ShutdownButton_OnClick(object sender, RoutedEventArgs e)
|
|
|
@@ -399,7 +399,7 @@ public partial class DeviceDetailsWindow : Window
|
|
|
await ExecuteSystemActionAsync(
|
|
|
"关闭设备",
|
|
|
"设备将立即关机,当前窗口和连接可能马上中断。是否继续?",
|
|
|
- () => _agentApiService.ShutdownAsync(_baseAddress, _password, _localIPv4));
|
|
|
+ () => _serverApiService.ShutdownAsync(_baseAddress, _password, _localIPv4));
|
|
|
}
|
|
|
|
|
|
private async Task ExecuteSystemActionAsync(string title, string confirmMessage, Func<Task<ApiCallResult<RemoteSystemActionResponse>>> action)
|