diff --git a/Oqtane.Client/Modules/Admin/Languages/Add.razor b/Oqtane.Client/Modules/Admin/Languages/Add.razor index 342c7d1f..5a667f16 100644 --- a/Oqtane.Client/Modules/Admin/Languages/Add.razor +++ b/Oqtane.Client/Modules/Admin/Languages/Add.razor @@ -48,7 +48,7 @@ else
- +
@@ -119,18 +119,17 @@ else AddModuleMessage(Localizer["Error.Language.Add"], MessageType.Error); } } - else - { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); - } - } + else + { + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + } + } private async Task InstallTranslations() - { - try - { - await PackageService.InstallPackagesAsync(); - AddModuleMessage(string.Format(Localizer["Success.Language.Install"], NavigateUrl("admin/system")), MessageType.Success); + { + try + { + AddModuleMessage(string.Format(Localizer["Success.Language.Install"], NavigateUrl("admin/system")), MessageType.Success); } catch (Exception ex) { diff --git a/Oqtane.Client/Modules/Admin/Languages/Index.razor b/Oqtane.Client/Modules/Admin/Languages/Index.razor index 1cb92e69..9fffea60 100644 --- a/Oqtane.Client/Modules/Admin/Languages/Index.razor +++ b/Oqtane.Client/Modules/Admin/Languages/Index.razor @@ -56,10 +56,6 @@ else } - @if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host) && _install) - { - - } } @if (_package != null) @@ -106,7 +102,6 @@ else private List _languages; private List _packages; private Package _package; - private bool _install = false; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; @@ -167,9 +162,8 @@ else { await PackageService.DownloadPackageAsync(_package.PackageId, _package.Version, Constants.PackagesFolder); await logger.LogInformation("Language Package {Name} {Version} Downloaded Successfully", _package.PackageId, _package.Version); - AddModuleMessage(Localizer["Success.Language.Download"], MessageType.Success); + AddModuleMessage(string.Format(Localizer["Success.Language.Download"], NavigateUrl("admin/system")), MessageType.Success); _package = null; - _install = true; StateHasChanged(); } catch (Exception ex) @@ -184,19 +178,4 @@ else _package = null; StateHasChanged(); } - - private async Task InstallTranslations() - { - try - { - await PackageService.InstallPackagesAsync(); - AddModuleMessage(string.Format(Localizer["Success.Language.Install"], NavigateUrl("admin/system")), MessageType.Success); - _install = false; - StateHasChanged(); - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Installing Translations"); - } - } } diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor index 70723195..0ac63c11 100644 --- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor +++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor @@ -111,9 +111,7 @@
} - @SharedLocalizer["Cancel"] -

@@ -236,7 +234,7 @@ { await PackageService.DownloadPackageAsync(_packageid, _packageversion, Constants.PackagesFolder); await logger.LogInformation("Package {PackageId} {Version} Downloaded Successfully", _packageid, _packageversion); - AddModuleMessage(Localizer["Success.Module.Download"], MessageType.Success); + AddModuleMessage(string.Format(Localizer["Success.Module.Download"], NavigateUrl("admin/system")), MessageType.Success); _productname = ""; _packagelicense = ""; StateHasChanged(); @@ -247,17 +245,4 @@ AddModuleMessage(Localizer["Error.Module.Download"], MessageType.Error); } } - - private async Task InstallModules() - { - try - { - await ModuleDefinitionService.InstallModuleDefinitionsAsync(); - AddModuleMessage(string.Format(Localizer["Success.Module.Install"], NavigateUrl("admin/system")), MessageType.Success); - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Installing Modules"); - } - } } diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor index 66818a3c..44f2ede6 100644 --- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor +++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor @@ -131,10 +131,6 @@ - @if (_install) - { - - } } else { @@ -224,7 +220,6 @@ private List _packages; private List _languages; private Package _package; - private bool _install = false; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; @@ -366,9 +361,8 @@ { await PackageService.DownloadPackageAsync(_package.PackageId, _package.Version, Constants.PackagesFolder); await logger.LogInformation("Package {PackageId} {Version} Downloaded Successfully", _package.PackageId, _package.Version); - AddModuleMessage(Localizer["Success.Translation.Download"], MessageType.Success); + AddModuleMessage(string.Format(Localizer["Success.Translation.Download"], NavigateUrl("admin/system")), MessageType.Success); _package = null; - _install = true; StateHasChanged(); } catch (Exception ex) @@ -377,19 +371,4 @@ AddModuleMessage(Localizer["Error.Translation.Download"], MessageType.Error); } } - - private async Task InstallTranslations() - { - try - { - await PackageService.InstallPackagesAsync(); - AddModuleMessage(string.Format(Localizer["Success.Translation.Install"], NavigateUrl("admin/system")), MessageType.Success); - _install = false; - StateHasChanged(); - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Installing Translations"); - } - } } diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor index dcde0c2c..1df05879 100644 --- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor +++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor @@ -149,7 +149,6 @@ else { await PackageService.DownloadPackageAsync(packagename, version, Constants.PackagesFolder); await logger.LogInformation("Module Downloaded {ModuleDefinitionName} {Version}", packagename, version); - await ModuleDefinitionService.InstallModuleDefinitionsAsync(); AddModuleMessage(string.Format(Localizer["Success.Module.Install"], NavigateUrl("admin/system")), MessageType.Success); } catch (Exception ex) diff --git a/Oqtane.Client/Modules/Admin/Themes/Add.razor b/Oqtane.Client/Modules/Admin/Themes/Add.razor index f3ca2c98..dca90274 100644 --- a/Oqtane.Client/Modules/Admin/Themes/Add.razor +++ b/Oqtane.Client/Modules/Admin/Themes/Add.razor @@ -111,9 +111,7 @@
} - @SharedLocalizer["Cancel"] -

@@ -236,7 +234,7 @@ { await PackageService.DownloadPackageAsync(_packageid, _version, Constants.PackagesFolder); await logger.LogInformation("Package {PackageId} {Version} Downloaded Successfully", _packageid, _version); - AddModuleMessage(Localizer["Success.Theme.Download"], MessageType.Success); + AddModuleMessage(string.Format(Localizer["Success.Theme.Download"], NavigateUrl("admin/system")), MessageType.Success); _productname = ""; _license = ""; StateHasChanged(); @@ -247,17 +245,4 @@ AddModuleMessage(Localizer["Error.Theme.Download"], MessageType.Error); } } - - private async Task InstallThemes() - { - try - { - await ThemeService.InstallThemesAsync(); - AddModuleMessage(string.Format(Localizer["Success.Theme.Install"], NavigateUrl("admin/system")), MessageType.Success); - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Installing Theme"); - } - } } diff --git a/Oqtane.Client/Modules/Admin/Themes/Index.razor b/Oqtane.Client/Modules/Admin/Themes/Index.razor index e613f553..61b25d58 100644 --- a/Oqtane.Client/Modules/Admin/Themes/Index.razor +++ b/Oqtane.Client/Modules/Admin/Themes/Index.razor @@ -116,7 +116,6 @@ else { await PackageService.DownloadPackageAsync(packagename, version, Constants.PackagesFolder); await logger.LogInformation("Theme Downloaded {ThemeName} {Version}", packagename, version); - await ThemeService.InstallThemesAsync(); AddModuleMessage(string.Format(Localizer["Success.Theme.Install"], NavigateUrl("admin/system")), MessageType.Success); } catch (Exception ex) diff --git a/Oqtane.Client/Resources/Modules/Admin/Languages/Add.resx b/Oqtane.Client/Resources/Modules/Admin/Languages/Add.resx index 643636ab..a200a84d 100644 --- a/Oqtane.Client/Resources/Modules/Admin/Languages/Add.resx +++ b/Oqtane.Client/Resources/Modules/Admin/Languages/Add.resx @@ -133,10 +133,10 @@ Default? - Translations Installed Successfully. You Must <a href={0}>Restart</a> Your Application To Apply These Changes. + You Must <a href={0}>Restart</a> To Complete The Installation. - Upload one or more translation packages. Once they are uploaded click Install to complete the installation. + Upload one or more translation packages. Once they are uploaded click Install. Translation diff --git a/Oqtane.Client/Resources/Modules/Admin/Languages/Index.resx b/Oqtane.Client/Resources/Modules/Admin/Languages/Index.resx index 416c4b84..9b031c07 100644 --- a/Oqtane.Client/Resources/Modules/Admin/Languages/Index.resx +++ b/Oqtane.Client/Resources/Modules/Admin/Languages/Index.resx @@ -133,14 +133,11 @@ Delete Language - Translation Downloaded Successfully. Click Install To Complete Installation. + Translation Downloaded Successfully. You Must <a href={0}>Restart</a> Your Application To Complete The Installation. Error Downloading Translation - - Translation Installed Successfully. You Must <a href={0}>Restart</a> Your Application To Apply These Changes. - Default diff --git a/Oqtane.Client/Resources/Modules/Admin/ModuleDefinitions/Add.resx b/Oqtane.Client/Resources/Modules/Admin/ModuleDefinitions/Add.resx index 6307e0d7..7527202c 100644 --- a/Oqtane.Client/Resources/Modules/Admin/ModuleDefinitions/Add.resx +++ b/Oqtane.Client/Resources/Modules/Admin/ModuleDefinitions/Add.resx @@ -123,11 +123,8 @@ Error Loading Packages - - Module Installed Successfully. You Must <a href={0}>Restart</a> Your Application To Apply These Changes. - - Module Downloaded Successfully. Click Install To Complete Installation. + Module Downloaded Successfully. You Must <a href={0}>Restart</a> Your Application To Complete The Installation. Error Downloading Module diff --git a/Oqtane.Client/Resources/Modules/Admin/ModuleDefinitions/Edit.resx b/Oqtane.Client/Resources/Modules/Admin/ModuleDefinitions/Edit.resx index 70e2547a..83a55354 100644 --- a/Oqtane.Client/Resources/Modules/Admin/ModuleDefinitions/Edit.resx +++ b/Oqtane.Client/Resources/Modules/Admin/ModuleDefinitions/Edit.resx @@ -211,10 +211,7 @@ No Translations Exist For This Module Or Package Service Is Disabled - Translation Downloaded Successfully. Click Install To Complete Installation. - - - Translation Installed Successfully. You Must <a href={0}>Restart</a> Your Application To Apply These Changes. + Translation Downloaded Successfully. You Must <a href={0}>Restart</a> Your Application To Complete The Installation. Translations diff --git a/Oqtane.Client/Resources/Modules/Admin/Themes/Add.resx b/Oqtane.Client/Resources/Modules/Admin/Themes/Add.resx index f6b6079b..2a2c0d5a 100644 --- a/Oqtane.Client/Resources/Modules/Admin/Themes/Add.resx +++ b/Oqtane.Client/Resources/Modules/Admin/Themes/Add.resx @@ -123,11 +123,8 @@ Theme: - - Theme Installed Successfully. You Must <a href={0}>Restart</a> Your Application To Apply These Changes. - - Theme Downloaded Successfully. Click Install To Complete Installation. + Theme Downloaded Successfully. You Must <a href={0}>Restart</a> Your Application To Complete The Installation. Error Downloading Theme diff --git a/Oqtane.Client/Services/Interfaces/IModuleDefinitionService.cs b/Oqtane.Client/Services/Interfaces/IModuleDefinitionService.cs index 0d8d8333..fbf2fafb 100644 --- a/Oqtane.Client/Services/Interfaces/IModuleDefinitionService.cs +++ b/Oqtane.Client/Services/Interfaces/IModuleDefinitionService.cs @@ -33,13 +33,6 @@ namespace Oqtane.Services /// Task UpdateModuleDefinitionAsync(ModuleDefinition moduleDefinition); - - /// - /// Installs all module definitions located in //TODO: 2dm where? - /// - /// - Task InstallModuleDefinitionsAsync(); - /// /// Deletes a module definition /// diff --git a/Oqtane.Client/Services/Interfaces/IThemeService.cs b/Oqtane.Client/Services/Interfaces/IThemeService.cs index 31bd63d4..4d8d17c6 100644 --- a/Oqtane.Client/Services/Interfaces/IThemeService.cs +++ b/Oqtane.Client/Services/Interfaces/IThemeService.cs @@ -39,12 +39,6 @@ namespace Oqtane.Services /// List GetContainerControls(List themes, string themeName); - /// - /// Installs all themes located in //TODO: 2dm where? - /// - /// - Task InstallThemesAsync(); - /// /// Deletes a theme /// diff --git a/Oqtane.Client/Services/ModuleDefinitionService.cs b/Oqtane.Client/Services/ModuleDefinitionService.cs index 3416e25b..97f70532 100644 --- a/Oqtane.Client/Services/ModuleDefinitionService.cs +++ b/Oqtane.Client/Services/ModuleDefinitionService.cs @@ -34,11 +34,6 @@ namespace Oqtane.Services await PutJsonAsync($"{Apiurl}/{moduleDefinition.ModuleDefinitionId}", moduleDefinition); } - public async Task InstallModuleDefinitionsAsync() - { - await GetJsonAsync>($"{Apiurl}/install"); - } - public async Task DeleteModuleDefinitionAsync(int moduleDefinitionId, int siteId) { await DeleteAsync($"{Apiurl}/{moduleDefinitionId}?siteid={siteId}"); diff --git a/Oqtane.Client/Services/ThemeService.cs b/Oqtane.Client/Services/ThemeService.cs index a62b779f..e678841c 100644 --- a/Oqtane.Client/Services/ThemeService.cs +++ b/Oqtane.Client/Services/ThemeService.cs @@ -38,11 +38,6 @@ namespace Oqtane.Services .SelectMany(item => item.Containers).ToList(); } - public async Task InstallThemesAsync() - { - await GetJsonAsync>($"{ApiUrl}/install"); - } - public async Task DeleteThemeAsync(string themeName) { await DeleteAsync($"{ApiUrl}/{themeName}"); diff --git a/Oqtane.Server/Controllers/InstallationController.cs b/Oqtane.Server/Controllers/InstallationController.cs index 25976fc9..cd646c4d 100644 --- a/Oqtane.Server/Controllers/InstallationController.cs +++ b/Oqtane.Server/Controllers/InstallationController.cs @@ -103,6 +103,7 @@ namespace Oqtane.Controllers [HttpGet("list")] public List List() { + // could check environment.EnvironmentName to return actual file names instead return GetAssemblyList().Select(item => item.HashedName).ToList(); } diff --git a/Oqtane.Server/Controllers/ModuleDefinitionController.cs b/Oqtane.Server/Controllers/ModuleDefinitionController.cs index db8612e9..a0e6a6a2 100644 --- a/Oqtane.Server/Controllers/ModuleDefinitionController.cs +++ b/Oqtane.Server/Controllers/ModuleDefinitionController.cs @@ -268,14 +268,6 @@ namespace Oqtane.Controllers } } - [HttpGet("install")] - [Authorize(Roles = RoleNames.Host)] - public void InstallModules() - { - _logger.Log(LogLevel.Information, this, LogFunction.Create, "Modules Installed"); - _installationManager.InstallPackages(); - } - // GET: api//templates [HttpGet("templates")] [Authorize(Roles = RoleNames.Host)] diff --git a/Oqtane.Server/Controllers/ThemeController.cs b/Oqtane.Server/Controllers/ThemeController.cs index 690db812..7ddad124 100644 --- a/Oqtane.Server/Controllers/ThemeController.cs +++ b/Oqtane.Server/Controllers/ThemeController.cs @@ -41,14 +41,6 @@ namespace Oqtane.Controllers return _themes.GetThemes(); } - [HttpGet("install")] - [Authorize(Roles = RoleNames.Host)] - public void InstallThemes() - { - _logger.Log(LogLevel.Information, this, LogFunction.Create, "Themes Installed"); - _installationManager.InstallPackages(); - } - // DELETE api//xxx [HttpDelete("{themename}")] [Authorize(Roles = RoleNames.Host)] diff --git a/Oqtane.Server/Infrastructure/InstallationManager.cs b/Oqtane.Server/Infrastructure/InstallationManager.cs index 2221675f..fa856456 100644 --- a/Oqtane.Server/Infrastructure/InstallationManager.cs +++ b/Oqtane.Server/Infrastructure/InstallationManager.cs @@ -12,6 +12,8 @@ using System.Threading.Tasks; using System.Xml; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Oqtane.Controllers; using Oqtane.Shared; // ReSharper disable AssignNullToNotNullAttribute @@ -21,21 +23,27 @@ namespace Oqtane.Infrastructure { private readonly IHostApplicationLifetime _hostApplicationLifetime; private readonly IWebHostEnvironment _environment; + private readonly ILogger _filelogger; - public InstallationManager(IHostApplicationLifetime hostApplicationLifetime, IWebHostEnvironment environment) + public InstallationManager(IHostApplicationLifetime hostApplicationLifetime, IWebHostEnvironment environment, ILogger filelogger) { _hostApplicationLifetime = hostApplicationLifetime; _environment = environment; + _filelogger = filelogger; } public void InstallPackages() { - InstallPackages(_environment.WebRootPath, _environment.ContentRootPath); + var errors = InstallPackages(_environment.WebRootPath, _environment.ContentRootPath); + if (!string.IsNullOrEmpty(errors)) + { + _filelogger.LogError(errors); + } } - public static bool InstallPackages(string webRootPath, string contentRootPath) + public static string InstallPackages(string webRootPath, string contentRootPath) { - bool install = true; + string errors = ""; string binPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location); string sourceFolder = Path.Combine(contentRootPath, "Packages"); @@ -172,16 +180,14 @@ namespace Oqtane.Infrastructure } catch (Exception ex) { - // problem installing package - logging is not possible as this is a static method - Debug.WriteLine($"Oqtane Error: Installing Package {packagename} - {ex}"); - install = false; + errors += $"Error Installing Package {packagename} - {ex.Message}. "; } // remove package File.Delete(packagename); } - return install; + return errors; } private static string ExtractFile(ZipArchiveEntry entry, string folder, int ignoreLeadingSegments) @@ -300,7 +306,7 @@ namespace Oqtane.Infrastructure if (packageversion != "" && Version.Parse(Constants.Version).CompareTo(Version.Parse(packageversion)) <= 0 && packageurl != "") { // install Oqtane.Framework and Oqtane.Updater nuget packages - InstallPackages(); + InstallPackages(_environment.WebRootPath, _environment.ContentRootPath); // download upgrade zip package Uri uri = new Uri(packageurl); string upgradepackage = Path.Combine(folder, uri.Segments[uri.Segments.Length - 1]); diff --git a/Oqtane.Server/Startup.cs b/Oqtane.Server/Startup.cs index 6ee68ec6..bc8a0aac 100644 --- a/Oqtane.Server/Startup.cs +++ b/Oqtane.Server/Startup.cs @@ -16,6 +16,7 @@ using Oqtane.Repository; using Oqtane.Security; using Oqtane.Shared; using Microsoft.AspNetCore.HttpOverrides; +using Microsoft.Extensions.Logging; namespace Oqtane { @@ -24,6 +25,7 @@ namespace Oqtane private readonly bool _useSwagger; private readonly IWebHostEnvironment _env; private readonly string[] _installedCultures; + private string _configureServicesErrors; public IConfigurationRoot Configuration { get; } @@ -85,7 +87,7 @@ namespace Oqtane .AddOqtaneSingletonServices(); // install any modules or themes ( this needs to occur BEFORE the assemblies are loaded into the app domain ) - InstallationManager.InstallPackages(_env.WebRootPath, _env.ContentRootPath); + _configureServicesErrors += InstallationManager.InstallPackages(_env.WebRootPath, _env.ContentRootPath); // register transient scoped core services services.AddOqtaneTransientServices(); @@ -142,8 +144,13 @@ namespace Oqtane } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISyncManager sync) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISyncManager sync, ILogger logger) { + if (!string.IsNullOrEmpty(_configureServicesErrors)) + { + logger.LogError(_configureServicesErrors); + } + ServiceActivator.Configure(app.ApplicationServices); if (env.IsDevelopment())