Updated the WebUI by creating new page for viewing the installed plugins
This commit is contained in:
@@ -27,12 +27,43 @@ public class PluginsController : Controller
|
||||
foreach (var plugin in plugins)
|
||||
{
|
||||
OnlinePluginViewModel pluginViewModel = new OnlinePluginViewModel();
|
||||
pluginViewModel.Name = plugin.PluginName;
|
||||
pluginViewModel.Description = plugin.PluginDescription;
|
||||
pluginViewModel.Author = plugin.PluginAuthor;
|
||||
pluginViewModel.Version = plugin.LatestVersion;
|
||||
pluginViewModel.DownloadUrl = plugin.PluginLink;
|
||||
pluginViewModel.Name = plugin.Name;
|
||||
pluginViewModel.Description = plugin.Description;
|
||||
pluginViewModel.Author = plugin.Author;
|
||||
pluginViewModel.Version = plugin.Version;
|
||||
pluginViewModel.DownloadUrl = plugin.DownloadLink;
|
||||
|
||||
pluginViewModels.Add(pluginViewModel);
|
||||
}
|
||||
|
||||
return View(pluginViewModels);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> InstalledPlugins()
|
||||
{
|
||||
_logger.Log("Getting plugins page", this);
|
||||
var plugins = await _pluginManager.GetInstalledPlugins();
|
||||
_logger.Log($"{plugins.Count} Plugins loaded", this);
|
||||
List<InstalledPluginViewModel> pluginViewModels = new List<InstalledPluginViewModel>();
|
||||
foreach (var plugin in plugins)
|
||||
{
|
||||
InstalledPluginViewModel pluginViewModel = new InstalledPluginViewModel();
|
||||
pluginViewModel.Name = plugin.PluginName;
|
||||
pluginViewModel.Version = plugin.PluginVersion;
|
||||
pluginViewModel.IsOfflineAdded = plugin.IsOfflineAdded;
|
||||
|
||||
pluginViewModels.Add(pluginViewModel);
|
||||
}
|
||||
|
||||
return View(pluginViewModels);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> DeletePlugin(string pluginName)
|
||||
{
|
||||
_logger.Log($"Deleting plugin {pluginName}", this);
|
||||
//TODO: Implement delete plugin
|
||||
return RedirectToAction("InstalledPlugins");
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class SettingsController : Controller
|
||||
{
|
||||
Token = _configuration.Get<string>("token", string.Empty),
|
||||
Prefix = _configuration.Get<string>("prefix", string.Empty),
|
||||
ServerIds = _configuration.Get<List<ulong>>("serverIds", new List<ulong>()),
|
||||
ServerIds = _configuration.Get<List<ulong>>("ServerIds", new List<ulong>()),
|
||||
};
|
||||
|
||||
return View(model);
|
||||
|
||||
8
WebUI/Models/InstalledPluginViewModel.cs
Normal file
8
WebUI/Models/InstalledPluginViewModel.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace WebUI.Models;
|
||||
|
||||
public class InstalledPluginViewModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Version { get; set; }
|
||||
public bool IsOfflineAdded { get; set; }
|
||||
}
|
||||
@@ -136,7 +136,7 @@ builder.Services.AddSingleton<IPluginManager>(sp =>
|
||||
IConfiguration configuration = sp.GetRequiredService<IConfiguration>();
|
||||
|
||||
Directory.CreateDirectory(configuration.Get<string>("PluginFolder", defaultPluginFolder));
|
||||
string pluginDatabaseFile = configuration.Get<string>("PluginDatabaseFile", defaultPluginDatabaseFile);
|
||||
string pluginDatabaseFile = configuration.Get<string>("PluginDatabase", defaultPluginDatabaseFile);
|
||||
Directory.CreateDirectory(new FileInfo(pluginDatabaseFile).DirectoryName);
|
||||
|
||||
IPluginManager pluginManager = new PluginManager(pluginRepository, logger, configuration);
|
||||
|
||||
32
WebUI/Views/Plugins/InstalledPlugins.cshtml
Normal file
32
WebUI/Views/Plugins/InstalledPlugins.cshtml
Normal file
@@ -0,0 +1,32 @@
|
||||
@model List<InstalledPluginViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Installed Plugins";
|
||||
}
|
||||
|
||||
<h2>@ViewData["Title"]</h2>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Version</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var plugin in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@plugin.Name</td>
|
||||
<td>@plugin.Version</td>
|
||||
<td>
|
||||
<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>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -20,10 +20,13 @@
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Settings" asp-action="Index">Settings</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Plugins" asp-action="OnlinePlugins">View Online Repository</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Plugins" asp-action="InstalledPlugins">View Installed Plugins</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user