improve user experience by delegating application restart responsibility to the host user
This commit is contained in:
parent
fa59ec1b24
commit
5e42ab8cca
|
@ -86,23 +86,15 @@
|
|||
|
||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
AddModuleMessage("Please Note That Once You Select The Create Module Button The Application Must Restart In Order To Complete The Process. If You Create An External Module You Will Need To Compile The Source Code And Then Relaunch Your Site In Order To Make It Functional.", MessageType.Info);
|
||||
}
|
||||
|
||||
private async Task CreateModule()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsValid(_owner) && IsValid(_module) && _template != "-")
|
||||
{
|
||||
ShowProgressIndicator();
|
||||
var interop = new Interop(JSRuntime);
|
||||
await interop.RedirectBrowser(NavigateUrl(), 5);
|
||||
|
||||
var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference };
|
||||
await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition, ModuleState.ModuleId);
|
||||
AddModuleMessage("The Source Code For Your Module Has Been Created And Must Be Compiled In Order To Make It Functional. Once It Has Been Compiled You Must Restart Your Application.", MessageType.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -78,14 +78,12 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
ShowProgressIndicator();
|
||||
var interop = new Interop(JSRuntime);
|
||||
await interop.RedirectBrowser(NavigateUrl(), 10);
|
||||
await ModuleDefinitionService.InstallModuleDefinitionsAsync();
|
||||
AddModuleMessage("Module Installed Successfully. You Must <a href=\"" + NavigateUrl("admin/system") + "\">Restart</a> Your Application To Apply These Changes.", MessageType.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Installating Module");
|
||||
await logger.LogError(ex, "Error Installing Module");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,10 +85,8 @@ else
|
|||
{
|
||||
await PackageService.DownloadPackageAsync(moduledefinitionname, version, "Modules");
|
||||
await logger.LogInformation("Module Downloaded {ModuleDefinitionName} {Version}", moduledefinitionname, version);
|
||||
ShowProgressIndicator();
|
||||
var interop = new Interop(JSRuntime);
|
||||
await interop.RedirectBrowser(NavigateUrl(), 10);
|
||||
await ModuleDefinitionService.InstallModuleDefinitionsAsync();
|
||||
AddModuleMessage("Module Installed Successfully. You Must <a href=\"" + NavigateUrl("admin/system") + "\">Restart</a> Your Application To Apply These Changes.", MessageType.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -101,10 +99,8 @@ else
|
|||
{
|
||||
try
|
||||
{
|
||||
ShowProgressIndicator();
|
||||
var interop = new Interop(JSRuntime);
|
||||
await interop.RedirectBrowser(NavigateUrl(), 10);
|
||||
await ModuleDefinitionService.DeleteModuleDefinitionAsync(moduleDefinition.ModuleDefinitionId, moduleDefinition.SiteId);
|
||||
AddModuleMessage("Module Deleted Successfully. You Must <a href=\"" + NavigateUrl("admin/system") + "\">Restart</a> Your Application To Apply These Changes.", MessageType.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
@namespace Oqtane.Modules.Admin.SystemInfo
|
||||
@inherits ModuleBase
|
||||
@inject ISystemService SystemService
|
||||
@inject IInstallationService InstallationService
|
||||
@inject IStringLocalizer<Index> Localizer
|
||||
|
||||
<table class="table table-borderless">
|
||||
|
@ -53,7 +54,8 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<a class="btn btn-primary" href="swagger/index.html" target="_new">@Localizer["Access Framework API"]</a>
|
||||
<a class="btn btn-primary" href="swagger/index.html" target="_new">@Localizer["Access Framework API"]</a>
|
||||
<ActionDialog Header="Restart Application" Message="@("Are You Sure You Wish To Restart The Application?")" Action="Restart Application" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await RestartApplication())" ResourceKey="RestartApplication" />
|
||||
|
||||
@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");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 <a href=\"" + NavigateUrl("admin/system") + "\">Restart</a> 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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <a href=\"" + NavigateUrl("admin/system") + "\">Restart</a> 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 <a href=\"" + NavigateUrl("admin/system") + "\">Restart</a> Your Application To Apply These Changes.", MessageType.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
@if (!string.IsNullOrEmpty(_message))
|
||||
{
|
||||
<div class="@_classname" role="alert">
|
||||
@_message
|
||||
@((MarkupString)_message)
|
||||
@if (Type == MessageType.Error && PageState != null && UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||
{
|
||||
@((MarkupString)" ")<NavLink href="@NavigateUrl("admin/log")">View Details</NavLink>
|
||||
|
|
|
@ -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<Installation>($"{ApiUrl}/upgrade");
|
||||
}
|
||||
|
||||
public async Task RestartAsync()
|
||||
{
|
||||
await PostAsync($"{ApiUrl}/restart");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Installation> IsInstalled();
|
||||
Task<Installation> Install(InstallConfig config);
|
||||
Task<Installation> Upgrade();
|
||||
Task RestartAsync();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user