Added plugin details page

This commit is contained in:
2025-04-07 17:39:48 +03:00
parent f5d48a398d
commit 2e6b6b9a61
6 changed files with 144 additions and 22 deletions

View File

@@ -16,6 +16,5 @@ public interface IPluginManager
Task<string?> GetDependencyLocation(string dependencyName, string pluginName);
string GenerateDependencyRelativePath(string pluginName, string dependencyPath);
Task InstallPlugin(OnlinePlugin plugin, IProgress<float> progress);
Task<Tuple<Dictionary<string, string>, List<OnlineDependencyInfo>>> GatherInstallDataForPlugin(OnlinePlugin plugin);
Task SetEnabledStatus(string pluginName, bool status);
}

View File

@@ -209,13 +209,14 @@ public sealed class PluginManager : IPluginManager
public async Task InstallPlugin(OnlinePlugin plugin, IProgress<float> progress)
{
List<OnlineDependencyInfo> dependencies = await _PluginRepository.GetDependenciesForPlugin(plugin.Id);
string? pluginsFolder = _Configuration.Get<string>("PluginFolder");
if (pluginsFolder is null)
{
throw new Exception("Plugin folder not found");
}
List<OnlineDependencyInfo> dependencies = await _PluginRepository.GetDependenciesForPlugin(plugin.Id);
string downloadLocation = $"{pluginsFolder}/{plugin.Name}.dll";
IProgress<float> downloadProgress = new Progress<float>(progress.Report);
@@ -237,25 +238,6 @@ public sealed class PluginManager : IPluginManager
LocalPlugin localPlugin = LocalPlugin.FromOnlineInfo(plugin, dependencies, downloadLocation);
await AppendPluginToDatabase(localPlugin);
}
public async Task<Tuple<Dictionary<string, string>, List<OnlineDependencyInfo>>> GatherInstallDataForPlugin(OnlinePlugin plugin)
{
List<OnlineDependencyInfo> dependencies = await _PluginRepository.GetDependenciesForPlugin(plugin.Id);
string? pluginsFolder = _Configuration.Get<string>("PluginFolder");
if (pluginsFolder is null)
{
throw new Exception("Plugin folder not found");
}
string downloadLocation = $"{pluginsFolder}/{plugin.Name}.dll";
var downloads = new Dictionary<string, string> { { downloadLocation, plugin.DownloadLink } };
foreach(var dependency in dependencies)
{
string dependencyLocation = GenerateDependencyRelativePath(plugin.Name, dependency.DownloadLocation);
downloads.Add(dependencyLocation, dependency.DownloadLink);
}
return (downloads, dependencies).ToTuple();
}
public async Task SetEnabledStatus(string pluginName, bool status)
{