diff --git a/Oqtane.Client/Themes/Controls/ControlPanel.razor b/Oqtane.Client/Themes/Controls/ControlPanel.razor index 38d5be96..1698a27a 100644 --- a/Oqtane.Client/Themes/Controls/ControlPanel.razor +++ b/Oqtane.Client/Themes/Controls/ControlPanel.razor @@ -129,7 +129,6 @@ List moduledefinitions; Dictionary containers = new Dictionary(); int pagemanagementmoduleid = -1; - string category = ""; string moduledefinitionname = ""; string pane = ""; string title = ""; diff --git a/Oqtane.Server/Controllers/ModuleDefinitionController.cs b/Oqtane.Server/Controllers/ModuleDefinitionController.cs index 8fa846eb..b7ebc057 100644 --- a/Oqtane.Server/Controllers/ModuleDefinitionController.cs +++ b/Oqtane.Server/Controllers/ModuleDefinitionController.cs @@ -12,12 +12,12 @@ namespace Oqtane.Controllers public class ModuleDefinitionController : Controller { private readonly IModuleDefinitionRepository ModuleDefinitions; - private readonly IInstallation Installation; + private readonly IInstallationManager InstallationManager; - public ModuleDefinitionController(IModuleDefinitionRepository ModuleDefinitions, IInstallation Installation) + public ModuleDefinitionController(IModuleDefinitionRepository ModuleDefinitions, IInstallationManager InstallationManager) { this.ModuleDefinitions = ModuleDefinitions; - this.Installation = Installation; + this.InstallationManager = InstallationManager; } // GET: api/ @@ -42,7 +42,7 @@ namespace Oqtane.Controllers [Authorize(Roles = Constants.HostRole)] public void InstallModules() { - Installation.Install("Modules"); + InstallationManager.InstallPackages("Modules"); } } } diff --git a/Oqtane.Server/Controllers/ThemeController.cs b/Oqtane.Server/Controllers/ThemeController.cs index 7cf466b8..a99c4b2e 100644 --- a/Oqtane.Server/Controllers/ThemeController.cs +++ b/Oqtane.Server/Controllers/ThemeController.cs @@ -12,12 +12,12 @@ namespace Oqtane.Controllers public class ThemeController : Controller { private readonly IThemeRepository Themes; - private readonly IInstallation Installation; + private readonly IInstallationManager InstallationManager; - public ThemeController(IThemeRepository Themes, IInstallation Installation) + public ThemeController(IThemeRepository Themes, IInstallationManager InstallationManager) { this.Themes = Themes; - this.Installation = Installation; + this.InstallationManager = InstallationManager; } // GET: api/ @@ -31,7 +31,7 @@ namespace Oqtane.Controllers [Authorize(Roles = Constants.HostRole)] public void InstallThemes() { - Installation.Install("Themes"); + InstallationManager.InstallPackages("Themes"); } } } diff --git a/Oqtane.Server/Infrastructure/IInstallation.cs b/Oqtane.Server/Infrastructure/IInstallation.cs deleted file mode 100644 index c7a501dc..00000000 --- a/Oqtane.Server/Infrastructure/IInstallation.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Oqtane.Infrastructure -{ - public interface IInstallation - { - void Install(string Folders); - } -} diff --git a/Oqtane.Server/Infrastructure/IInstallationManager.cs b/Oqtane.Server/Infrastructure/IInstallationManager.cs new file mode 100644 index 00000000..be673524 --- /dev/null +++ b/Oqtane.Server/Infrastructure/IInstallationManager.cs @@ -0,0 +1,7 @@ +namespace Oqtane.Infrastructure +{ + public interface IInstallationManager + { + void InstallPackages(string Folders); + } +} diff --git a/Oqtane.Server/Infrastructure/Installation.cs b/Oqtane.Server/Infrastructure/InstallationManager.cs similarity index 86% rename from Oqtane.Server/Infrastructure/Installation.cs rename to Oqtane.Server/Infrastructure/InstallationManager.cs index b8dbcb0e..04d7c768 100644 --- a/Oqtane.Server/Infrastructure/Installation.cs +++ b/Oqtane.Server/Infrastructure/InstallationManager.cs @@ -6,18 +6,18 @@ using Microsoft.AspNetCore.Hosting; namespace Oqtane.Infrastructure { - public class Installation : IInstallation + public class InstallationManager : IInstallationManager { private readonly IHostApplicationLifetime HostApplicationLifetime; private readonly IWebHostEnvironment environment; - public Installation(IHostApplicationLifetime HostApplicationLifetime, IWebHostEnvironment environment) + public InstallationManager(IHostApplicationLifetime HostApplicationLifetime, IWebHostEnvironment environment) { this.HostApplicationLifetime = HostApplicationLifetime; this.environment = environment; } - public void Install(string Folders) + public void InstallPackages(string Folders) { bool install = false; string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); @@ -26,6 +26,12 @@ namespace Oqtane.Infrastructure { string folder = Path.Combine(environment.WebRootPath, Folder); + // create folder if it does not exist + if (!Directory.Exists(folder)) + { + Directory.CreateDirectory(folder); + } + // iterate through theme packages foreach (string packagename in Directory.GetFiles(folder, "*.nupkg")) { diff --git a/Oqtane.Server/Startup.cs b/Oqtane.Server/Startup.cs index 6da5e301..ed9b1c39 100644 --- a/Oqtane.Server/Startup.cs +++ b/Oqtane.Server/Startup.cs @@ -147,12 +147,12 @@ namespace Oqtane.Server // register singleton scoped core services services.AddSingleton(Configuration); - services.AddSingleton(); + services.AddSingleton(); // install any modules or themes ServiceProvider sp = services.BuildServiceProvider(); - var Installation = sp.GetRequiredService(); - Installation.Install("Modules,Themes"); + var InstallationManager = sp.GetRequiredService(); + InstallationManager.InstallPackages("Modules,Themes"); // register transient scoped core services services.AddTransient(); @@ -329,6 +329,31 @@ namespace Oqtane.Server // register custom claims principal factory for role claims services.AddTransient, ClaimsPrincipalFactory>(); + services.AddSingleton(); + + // install any modules or themes + ServiceProvider sp = services.BuildServiceProvider(); + var InstallationManager = sp.GetRequiredService(); + InstallationManager.InstallPackages("Modules,Themes"); + + // register transient scoped core services + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + // get list of loaded assemblies Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); string path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); @@ -361,26 +386,6 @@ namespace Oqtane.Server } services.AddMvc().AddModuleAssemblies(moduleassemblies).AddNewtonsoftJson(); - - // register singleton scoped core services - services.AddSingleton(Configuration); - - // register transient scoped core services - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); // dynamically register module services, contexts, and repository classes assemblies = AppDomain.CurrentDomain.GetAssemblies()