Added plugin details page
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -69,6 +69,35 @@ public class PluginsController : Controller
|
||||
return RedirectToAction("InstalledPlugins");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> GetPluginDetails(string? pluginName)
|
||||
{
|
||||
if (pluginName == null)
|
||||
{
|
||||
_logger.Log("The plugin name is invalid", this);
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_logger.Log($"Gathering information about {pluginName}", this);
|
||||
|
||||
var pluginData = await _pluginManager.GetPluginDataByName(pluginName);
|
||||
if (pluginData is null)
|
||||
{
|
||||
_logger.Log($"Plugin {pluginName} not found", this);
|
||||
return NotFound("Plugin not found");
|
||||
}
|
||||
|
||||
PluginDetailsViewModel model = new PluginDetailsViewModel
|
||||
{
|
||||
PluginName = pluginName,
|
||||
Author = pluginData.Author,
|
||||
Description = pluginData.Description,
|
||||
Version = pluginData.Version
|
||||
};
|
||||
|
||||
return View("PluginDetails", model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> InstallPlugin(int pluginId)
|
||||
{
|
||||
|
||||
9
WebUI/Models/PluginDetailsViewModel.cs
Normal file
9
WebUI/Models/PluginDetailsViewModel.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace WebUI.Models;
|
||||
|
||||
public class PluginDetailsViewModel
|
||||
{
|
||||
public string PluginName { get; set; }
|
||||
public string Version { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Author { get; set; }
|
||||
}
|
||||
@@ -24,7 +24,9 @@
|
||||
<form method="post" asp-action="DeletePlugin" asp-route-pluginName="@plugin.Name">
|
||||
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
|
||||
</form>
|
||||
<button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#pluginDetailsModal-@plugin.Name">Details</button>
|
||||
<form method="post" asp-action="GetPluginDetails" asp-route-pluginName="@plugin.Name">
|
||||
<button type="submit" class="btn btn-info btn-sm" data-toggle="modal">Details</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
101
WebUI/Views/Plugins/PluginDetails.cshtml
Normal file
101
WebUI/Views/Plugins/PluginDetails.cshtml
Normal file
@@ -0,0 +1,101 @@
|
||||
@model PluginDetailsViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Plugin Details";
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>@ViewData["Title"]</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Arial', sans-serif;
|
||||
background-color: #f4f7fc;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 800px;
|
||||
margin: 50px auto;
|
||||
padding: 20px;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.5rem;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2rem;
|
||||
color: #444;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.plugin-info {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.plugin-info p {
|
||||
font-size: 1.1rem;
|
||||
color: #666;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.plugin-info strong {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.footer {
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
font-size: 0.9rem;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
background-color: #007BFF;
|
||||
color: white;
|
||||
padding: 15px;
|
||||
border-radius: 8px 8px 0 0;
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
background-color: #f8f9fa;
|
||||
padding: 10px;
|
||||
border-radius: 0 0 8px 8px;
|
||||
color: #888;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h1>@Model.PluginName</h1>
|
||||
<h2>Version: @Model.Version</h2>
|
||||
</div>
|
||||
|
||||
<div class="plugin-info">
|
||||
<h3>Description</h3>
|
||||
<p>@Model.Description</p>
|
||||
<p><strong>Author:</strong> @Model.Author</p>
|
||||
</div>
|
||||
|
||||
<div class="card-footer footer">
|
||||
<small>Plugin Details</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user