Localizer
-@Localizer["Access Framework API"]
+@Localizer["Access Framework API"]
+
@code {
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
@@ -79,4 +81,19 @@
_servertime = systeminfo["servertime"];
}
}
-}
+
+ private async Task RestartApplication()
+ {
+ try
+ {
+ ShowProgressIndicator();
+ var interop = new Interop(JSRuntime);
+ await interop.RedirectBrowser(NavigateUrl(""), 10);
+ await InstallationService.RestartAsync();
+ }
+ catch (Exception ex)
+ {
+ await logger.LogError(ex, "Error Restarting Application");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Oqtane.Client/Modules/Admin/Themes/Add.razor b/Oqtane.Client/Modules/Admin/Themes/Add.razor
index 6ab6fde3..fa896dd4 100644
--- a/Oqtane.Client/Modules/Admin/Themes/Add.razor
+++ b/Oqtane.Client/Modules/Admin/Themes/Add.razor
@@ -78,14 +78,12 @@
{
try
{
- ShowProgressIndicator();
- var interop = new Interop(JSRuntime);
- await interop.RedirectBrowser(NavigateUrl(), 10);
await ThemeService.InstallThemesAsync();
+ AddModuleMessage("Theme Installed Successfully. You Must Restart Your Application To Apply These Changes.", MessageType.Success);
}
catch (Exception ex)
{
- await logger.LogError(ex, "Error Installating Theme");
+ 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 758dddb4..8b64bff8 100644
--- a/Oqtane.Client/Modules/Admin/Themes/Index.razor
+++ b/Oqtane.Client/Modules/Admin/Themes/Index.razor
@@ -86,10 +86,8 @@ else
{
await PackageService.DownloadPackageAsync(themename, version, "Themes");
await logger.LogInformation("Theme Downloaded {ThemeName} {Version}", themename, version);
- ShowProgressIndicator();
- var interop = new Interop(JSRuntime);
- await interop.RedirectBrowser(NavigateUrl(), 10);
await ThemeService.InstallThemesAsync();
+ AddModuleMessage("Theme Installed Successfully. You Must Restart Your Application To Apply These Changes.", MessageType.Success);
}
catch (Exception ex)
{
@@ -102,10 +100,8 @@ else
{
try
{
- ShowProgressIndicator();
- var interop = new Interop(JSRuntime);
- await interop.RedirectBrowser(NavigateUrl(), 10);
await ThemeService.DeleteThemeAsync(Theme.ThemeName);
+ AddModuleMessage("Theme Deleted Successfully. You Must Restart Your Application To Apply These Changes.", MessageType.Success);
}
catch (Exception ex)
{
diff --git a/Oqtane.Client/Modules/Controls/ModuleMessage.razor b/Oqtane.Client/Modules/Controls/ModuleMessage.razor
index ee846b13..04a1056e 100644
--- a/Oqtane.Client/Modules/Controls/ModuleMessage.razor
+++ b/Oqtane.Client/Modules/Controls/ModuleMessage.razor
@@ -5,7 +5,7 @@
@if (!string.IsNullOrEmpty(_message))
{
- @_message
+ @((MarkupString)_message)
@if (Type == MessageType.Error && PageState != null && UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
{
@((MarkupString)" ")View Details
diff --git a/Oqtane.Client/Services/InstallationService.cs b/Oqtane.Client/Services/InstallationService.cs
index 8515abe2..c6900c59 100644
--- a/Oqtane.Client/Services/InstallationService.cs
+++ b/Oqtane.Client/Services/InstallationService.cs
@@ -1,4 +1,4 @@
-using Oqtane.Models;
+using Oqtane.Models;
using System.Threading.Tasks;
using System.Net.Http;
using Oqtane.Shared;
@@ -25,5 +25,10 @@ namespace Oqtane.Services
{
return await GetJsonAsync($"{ApiUrl}/upgrade");
}
+
+ public async Task RestartAsync()
+ {
+ await PostAsync($"{ApiUrl}/restart");
+ }
}
}
diff --git a/Oqtane.Client/Services/Interfaces/IInstallationService.cs b/Oqtane.Client/Services/Interfaces/IInstallationService.cs
index c9eeaca8..da9222e9 100644
--- a/Oqtane.Client/Services/Interfaces/IInstallationService.cs
+++ b/Oqtane.Client/Services/Interfaces/IInstallationService.cs
@@ -1,4 +1,4 @@
-using Oqtane.Models;
+using Oqtane.Models;
using System.Threading.Tasks;
using Oqtane.Shared;
@@ -9,5 +9,6 @@ namespace Oqtane.Services
Task IsInstalled();
Task Install(InstallConfig config);
Task Upgrade();
+ Task RestartAsync();
}
}
diff --git a/Oqtane.Server/Controllers/InstallationController.cs b/Oqtane.Server/Controllers/InstallationController.cs
index 7aaf537c..cac15728 100644
--- a/Oqtane.Server/Controllers/InstallationController.cs
+++ b/Oqtane.Server/Controllers/InstallationController.cs
@@ -68,6 +68,14 @@ namespace Oqtane.Controllers
return installation;
}
+ // GET api//restart
+ [HttpPost("restart")]
+ [Authorize(Roles = RoleNames.Host)]
+ public void Restart()
+ {
+ _installationManager.RestartApplication();
+ }
+
// GET api//load
[HttpGet("load")]
public IActionResult Load()
diff --git a/Oqtane.Server/Controllers/ModuleDefinitionController.cs b/Oqtane.Server/Controllers/ModuleDefinitionController.cs
index 421f54a8..e30fffee 100644
--- a/Oqtane.Server/Controllers/ModuleDefinitionController.cs
+++ b/Oqtane.Server/Controllers/ModuleDefinitionController.cs
@@ -96,7 +96,7 @@ namespace Oqtane.Controllers
public void InstallModules()
{
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Modules Installed");
- _installationManager.InstallPackages("Modules", true);
+ _installationManager.InstallPackages("Modules");
}
// DELETE api//5?siteid=x
@@ -159,9 +159,6 @@ namespace Oqtane.Controllers
// remove module definition
_moduleDefinitions.DeleteModuleDefinition(id, siteid);
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Definition {ModuleDefinitionName} Deleted", moduledefinition.Name);
-
- // restart application
- _installationManager.RestartApplication();
}
}
}
@@ -205,8 +202,6 @@ namespace Oqtane.Controllers
resources.Add(Utilities.PathCombine("Modules", moduleDefinition.Owner + "." + moduleDefinition.Name, "Scripts", moduleDefinition.Owner + "." + moduleDefinition.Name + ".Uninstall.sql"));
EmbedResourceFiles(Utilities.PathCombine(rootPath, "Oqtane.Server", "Oqtane.Server.csproj"), resources);
}
-
- _installationManager.RestartApplication();
}
}
diff --git a/Oqtane.Server/Controllers/ThemeController.cs b/Oqtane.Server/Controllers/ThemeController.cs
index 0aa6916c..07ed6152 100644
--- a/Oqtane.Server/Controllers/ThemeController.cs
+++ b/Oqtane.Server/Controllers/ThemeController.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Oqtane.Models;
using Microsoft.AspNetCore.Authorization;
@@ -45,7 +45,7 @@ namespace Oqtane.Controllers
public void InstallThemes()
{
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Themes Installed");
- _installationManager.InstallPackages("Themes", true);
+ _installationManager.InstallPackages("Themes");
}
// DELETE api//xxx
@@ -79,8 +79,6 @@ namespace Oqtane.Controllers
Directory.Delete(folder, true);
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Theme Resource Folder Removed For {ThemeName}", theme.ThemeName);
}
-
- _installationManager.RestartApplication();
}
}
diff --git a/Oqtane.Server/Infrastructure/InstallationManager.cs b/Oqtane.Server/Infrastructure/InstallationManager.cs
index 00fb0895..60910484 100644
--- a/Oqtane.Server/Infrastructure/InstallationManager.cs
+++ b/Oqtane.Server/Infrastructure/InstallationManager.cs
@@ -26,15 +26,11 @@ namespace Oqtane.Infrastructure
_cache = cache;
}
- public void InstallPackages(string folders, bool restart)
+ public void InstallPackages(string folders)
{
- var webRootPath = _environment.WebRootPath;
-
- var install = InstallPackages(folders, webRootPath);
-
- if (install && restart)
+ if (!InstallPackages(folders, _environment.WebRootPath))
{
- RestartApplication();
+ // error installing packages
}
}
diff --git a/Oqtane.Server/Infrastructure/Interfaces/IInstallationManager.cs b/Oqtane.Server/Infrastructure/Interfaces/IInstallationManager.cs
index f34165f0..b491987c 100644
--- a/Oqtane.Server/Infrastructure/Interfaces/IInstallationManager.cs
+++ b/Oqtane.Server/Infrastructure/Interfaces/IInstallationManager.cs
@@ -1,8 +1,8 @@
-namespace Oqtane.Infrastructure
+namespace Oqtane.Infrastructure
{
public interface IInstallationManager
{
- void InstallPackages(string folders, bool restart);
+ void InstallPackages(string folders);
void UpgradeFramework();
void RestartApplication();
}