improve user experience by delegating application restart responsibility to the host user
This commit is contained in:
		| @ -68,6 +68,14 @@ namespace Oqtane.Controllers | ||||
|             return installation; | ||||
|         } | ||||
|  | ||||
|         // GET api/<controller>/restart | ||||
|         [HttpPost("restart")] | ||||
|         [Authorize(Roles = RoleNames.Host)] | ||||
|         public void Restart() | ||||
|         { | ||||
|             _installationManager.RestartApplication(); | ||||
|         } | ||||
|  | ||||
|         // GET api/<controller>/load | ||||
|         [HttpGet("load")] | ||||
|         public IActionResult Load() | ||||
|  | ||||
| @ -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/<controller>/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(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|  | ||||
| @ -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/<controller>/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(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|  | ||||
| @ -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 | ||||
|             } | ||||
|         } | ||||
|  | ||||
|  | ||||
| @ -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(); | ||||
|     } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker