This commit is contained in:
Flaminel
2025-05-15 22:09:42 +03:00
parent 374f0f72a7
commit 57326b2f8e
22 changed files with 132 additions and 159 deletions

View File

@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
using IConfigurationManager = Infrastructure.Configuration.IConfigurationManager;
using Infrastructure.Configuration;
namespace Executable.Controllers;
@@ -9,11 +9,11 @@ namespace Executable.Controllers;
public class ConfigFilesController : ControllerBase
{
private readonly ILogger<ConfigFilesController> _logger;
private readonly IConfigurationManager _configManager;
private readonly IConfigManager _configManager;
public ConfigFilesController(
ILogger<ConfigFilesController> logger,
IConfigurationManager configManager)
IConfigManager configManager)
{
_logger = logger;
_configManager = configManager;

View File

@@ -13,13 +13,13 @@ namespace Executable.Controllers;
public class StatusController : ControllerBase
{
private readonly ILogger<StatusController> _logger;
private readonly IConfigurationManager _configManager;
private readonly IConfigManager _configManager;
private readonly DownloadServiceFactory _downloadServiceFactory;
private readonly ArrClientFactory _arrClientFactory;
public StatusController(
ILogger<StatusController> logger,
IConfigurationManager configManager,
IConfigManager configManager,
DownloadServiceFactory downloadServiceFactory,
ArrClientFactory arrClientFactory)
{
@@ -60,29 +60,24 @@ public class StatusController : ControllerBase
},
DownloadClient = new
{
LegacyType = downloadClientConfig.DownloadClient.ToString(),
ConfiguredClientCount = downloadClientConfig.Clients.Count,
EnabledClientCount = downloadClientConfig.Clients.Count(c => c.Enabled),
IsConfigured = downloadClientConfig.DownloadClient != Common.Enums.DownloadClient.None &&
downloadClientConfig.DownloadClient != Common.Enums.DownloadClient.Disabled ||
downloadClientConfig.Clients.Any(c => c.Enabled)
// TODO
},
MediaManagers = new
{
Sonarr = new
{
IsEnabled = sonarrConfig.Enabled,
InstanceCount = sonarrConfig.Instances?.Count ?? 0
InstanceCount = sonarrConfig.Instances.Count
},
Radarr = new
{
IsEnabled = radarrConfig.Enabled,
InstanceCount = radarrConfig.Instances?.Count ?? 0
InstanceCount = radarrConfig.Instances.Count
},
Lidarr = new
{
IsEnabled = lidarrConfig.Enabled,
InstanceCount = lidarrConfig.Instances?.Count ?? 0
InstanceCount = lidarrConfig.Instances.Count
}
}
};
@@ -102,6 +97,7 @@ public class StatusController : ControllerBase
try
{
var downloadClientConfig = await _configManager.GetDownloadClientConfigAsync();
if (downloadClientConfig == null)
{
return NotFound("Download client configuration not found");
@@ -115,54 +111,20 @@ public class StatusController : ControllerBase
var clientsStatus = new List<object>();
foreach (var client in downloadClientConfig.Clients)
{
try
clientsStatus.Add(new
{
clientsStatus.Add(new
{
Id = client.Id,
Name = client.Name,
Type = client.Type.ToString(),
Host = client.Host,
Port = client.Port,
Enabled = client.Enabled,
IsConnected = client.Enabled, // We can't check connection status without implementing test methods
Status = client.Enabled ? "Enabled" : "Disabled"
});
}
catch (Exception ex)
{
clientsStatus.Add(new
{
Id = client.Id,
Name = client.Name,
Type = client.Type.ToString(),
Host = client.Host,
Port = client.Port,
Enabled = client.Enabled,
IsConnected = false,
Status = $"Error: {ex.Message}"
});
}
client.Id,
client.Name,
client.Type,
client.Host,
client.Port,
client.Enabled,
IsConnected = client.Enabled, // We can't check connection status without implementing test methods
});
}
result["Clients"] = clientsStatus;
}
else if (downloadClientConfig.DownloadClient != Common.Enums.DownloadClient.None &&
downloadClientConfig.DownloadClient != Common.Enums.DownloadClient.Disabled)
{
// Legacy configuration
result["LegacyClient"] = new
{
Type = downloadClientConfig.DownloadClient.ToString(),
Host = downloadClientConfig.Host,
Port = downloadClientConfig.Port,
IsConnected = true // We can't check without implementing test methods in clients
};
}
else
{
result["Status"] = "No download clients configured";
}
return Ok(result);
}