fixes for framework upgrade, fixes for control panel CSS styles, added AllPages attrubute for Modules, bumped version to 0.9.1 to test upgrades

This commit is contained in:
Shaun Walker 2020-05-07 14:38:24 -04:00
parent c394c6ea7a
commit d7ad175cd7
18 changed files with 95 additions and 47 deletions

View File

@ -32,6 +32,17 @@
</select>
</td>
</tr>
<tr>
<td>
<Label For="allpages" HelpText="Indicate if this module should be displayed on all pages">Display On All Pages? </Label>
</td>
<td>
<select id="allpages" class="form-control" @bind="@_allPages">
<option value="True">Yes</option>
<option value="False">No</option>
</select>
</td>
</tr>
<tr>
<td>
<Label For="page" HelpText="The page that the module is on">Page: </Label>
@ -77,6 +88,7 @@
private Dictionary<string, string> _containers;
private string _title;
private string _containerType;
private string _allPages = "false";
private string _permissionNames = "";
private string _permissions;
private string _pageId;
@ -95,6 +107,7 @@
_title = ModuleState.Title;
_containers = ThemeService.GetContainerTypes(await ThemeService.GetThemesAsync());
_containerType = ModuleState.ContainerType;
_allPages = ModuleState.AllPages.ToString();
_permissions = ModuleState.Permissions;
_permissionNames = ModuleState.ModuleDefinition.PermissionNames;
_pageId = ModuleState.PageId.ToString();
@ -120,18 +133,18 @@
private async Task SaveModule()
{
var module = ModuleState;
module.Permissions = _permissionGrid.GetPermissions();
await ModuleService.UpdateModuleAsync(module);
var pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
pagemodule.PageId = int.Parse(_pageId);
pagemodule.Title = _title;
pagemodule.ContainerType = _containerType;
await PageModuleService.UpdatePageModuleAsync(pagemodule);
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
var module = ModuleState;
module.AllPages = bool.Parse(_allPages);
module.Permissions = _permissionGrid.GetPermissions();
await ModuleService.UpdateModuleAsync(module);
if (_settingsModuleType != null)
{
var moduleType = Type.GetType(ModuleState.ModuleType);

View File

@ -11,29 +11,27 @@
<TabPanel Name="Download">
@if (_upgradeavailable)
{
<ModuleMessage Type="MessageType.Info" Message="Download a new version of the framework. Once you are ready click Install to complete the installation."></ModuleMessage>
@("Framework") @_package.Version <button type="button" class="btn btn-success" @onclick=@(async () => await Download(Constants.PackageId, Constants.Version))>Download</button>
<ModuleMessage Type="MessageType.Info" Message="Select The Upgrade Button To Install a New Framework Version"></ModuleMessage>
@("Framework") @_package.Version <button type="button" class="btn btn-success" @onclick=@(async () => await Download(Constants.PackageId, Constants.Version))>Upgrade</button>
}
else
{
<ModuleMessage Type="MessageType.Info" Message="Framework Is Already Up To Date"></ModuleMessage>
}
</TabPanel>
@if (_upgradeavailable)
{
<TabPanel Name="Upload">
<table class="table table-borderless">
<tr>
<td>
<Label HelpText="Upload a new framework package. Once it is uploaded click Install to complete the installation.">Framework: </Label>
<Label HelpText="Upload a framework package and select Install to complete the installation">Framework: </Label>
</td>
<td>
<FileManager Filter="nupkg" ShowFiles="false" Folder="Framework" />
</td>
</tr>
</table>
<button type="button" class="btn btn-success" @onclick="Upgrade">Install</button>
</TabPanel>
}
</TabStrip>
}

View File

@ -6,7 +6,7 @@
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
<Configurations>Debug;Release</Configurations>
<Version>0.9.0</Version>
<Version>0.9.1</Version>
<Product>Oqtane</Product>
<Authors>Shaun Walker</Authors>
<Company>.NET Foundation</Company>

View File

@ -16,7 +16,7 @@
<div class="@CardClass">
<div class="@HeaderClass">
Control Panel
<span class="font-weight-bold">Control Panel</span>
<button type="button" class="close" @onclick="HideControlPanel" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
@ -245,17 +245,17 @@
{
if (string.IsNullOrEmpty(ButtonClass))
{
ButtonClass = "btn-outline-primary";
ButtonClass = "btn-outline-secondary";
}
if (string.IsNullOrEmpty(CardClass))
{
CardClass = "card bg-secondary mb-3";
CardClass = "card border-secondary mb-3";
}
if (string.IsNullOrEmpty(HeaderClass))
{
HeaderClass = "card-header text-white";
HeaderClass = "card-header";
}
if (string.IsNullOrEmpty(BodyClass))
@ -361,6 +361,7 @@
module.SiteId = PageState.Site.SiteId;
module.PageId = PageState.Page.PageId;
module.ModuleDefinitionName = _moduleDefinitionName;
module.AllPages = false;
module.Permissions = PageState.Page.Permissions;
module = await ModuleService.AddModuleAsync(module);
_moduleId = module.ModuleId.ToString();

View File

@ -3,7 +3,7 @@
<main role="main">
<nav class="navbar navbar-expand-md navbar-dark bg-primary fixed-top">
<Logo /><Menu Orientation="Horizontal" /><div class="ml-md-auto"><UserProfile /> <Login /> <ControlPanel ButtonClass="btn-outline-secondary" CardClass="bg-light" /></div>
<Logo /><Menu Orientation="Horizontal" /><div class="ml-md-auto"><UserProfile /> <Login /> <ControlPanel /></div>
</nav>
<div class="container">
<PaneLayout />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Oqtane.Framework</id>
<version>0.9.0</version>
<version>0.9.1</version>
<authors>Shaun Walker</authors>
<owners>.NET Foundation</owners>
<title>Oqtane Framework</title>

View File

@ -16,14 +16,16 @@ namespace Oqtane.Controllers
{
private readonly IModuleRepository _modules;
private readonly IPageModuleRepository _pageModules;
private readonly IPageRepository _pages;
private readonly IModuleDefinitionRepository _moduleDefinitions;
private readonly IUserPermissions _userPermissions;
private readonly ILogManager _logger;
public ModuleController(IModuleRepository modules, IPageModuleRepository pageModules, IModuleDefinitionRepository moduleDefinitions, IUserPermissions userPermissions, ILogManager logger)
public ModuleController(IModuleRepository modules, IPageModuleRepository pageModules, IPageRepository pages, IModuleDefinitionRepository moduleDefinitions, IUserPermissions userPermissions, ILogManager logger)
{
_modules = modules;
_pageModules = pageModules;
_pages = pages;
_moduleDefinitions = moduleDefinitions;
_userPermissions = userPermissions;
_logger = logger;
@ -42,6 +44,7 @@ namespace Oqtane.Controllers
Module module = new Module();
module.SiteId = pagemodule.Module.SiteId;
module.ModuleDefinitionName = pagemodule.Module.ModuleDefinitionName;
module.AllPages = pagemodule.Module.AllPages;
module.Permissions = pagemodule.Module.Permissions;
module.CreatedBy = pagemodule.Module.CreatedBy;
module.CreatedOn = pagemodule.Module.CreatedOn;
@ -111,7 +114,20 @@ namespace Oqtane.Controllers
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Module, module.ModuleId, PermissionNames.Edit))
{
module = _modules.UpdateModule(module);
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Updated {Module}", module);
if (module.AllPages)
{
var pageModule = _pageModules.GetPageModules(module.SiteId).FirstOrDefault(item => item.ModuleId == module.ModuleId);
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Updated {Module}", module);
var pages = _pages.GetPages(module.SiteId).ToList();
foreach (Page page in pages)
{
if (page.PageId != pageModule.PageId && !page.EditMode)
{
_pageModules.AddPageModule(new PageModule { PageId = page.PageId, ModuleId = pageModule.ModuleId, Title = pageModule.Title, Pane = pageModule.Pane, Order = pageModule.Order, ContainerType = pageModule.ContainerType });
}
}
}
}
else
{

View File

@ -124,6 +124,16 @@ namespace Oqtane.Controllers
page = _pages.AddPage(page);
_syncManager.AddSyncEvent(_tenants.GetTenant().TenantId, EntityNames.Site, page.SiteId);
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Added {Page}", page);
if (!page.EditMode)
{
var modules = _modules.GetModules(page.SiteId).Where(item => item.AllPages).ToList();
foreach (Module module in modules)
{
var pageModule = _pageModules.GetPageModules(page.SiteId).FirstOrDefault(item => item.ModuleId == module.ModuleId);
_pageModules.AddPageModule(new PageModule { PageId = page.PageId, ModuleId = pageModule.ModuleId, Title = pageModule.Title, Pane = pageModule.Pane, Order = pageModule.Order, ContainerType = pageModule.ContainerType });
}
}
}
else
{
@ -174,6 +184,7 @@ namespace Oqtane.Controllers
module.SiteId = page.SiteId;
module.PageId = page.PageId;
module.ModuleDefinitionName = pm.Module.ModuleDefinitionName;
module.AllPages = false;
module.Permissions = new List<Permission> {
new Permission(PermissionNames.View, userid, true),
new Permission(PermissionNames.Edit, userid, true)

View File

@ -180,17 +180,17 @@ namespace Oqtane.Infrastructure
private void FinishUpgrade()
{
string folder = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
// check if upgrade application exists
string folder = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
if (folder == null || !File.Exists(Path.Combine(folder, "Oqtane.Upgrade.exe"))) return;
// run upgrade application
var process = new Process
{
StartInfo =
{
FileName = Path.Combine(folder, "Oqtane.Upgrade.exe"),
Arguments = "",
Arguments = "\"" + _environment.ContentRootPath + "\" \"" + _environment.WebRootPath + "\"",
ErrorDialog = false,
UseShellExecute = false,
CreateNoWindow = true,

View File

@ -4,7 +4,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>7.3</LangVersion>
<Configurations>Debug;Release</Configurations>
<Version>0.9.0</Version>
<Version>0.9.1</Version>
<Product>Oqtane</Product>
<Authors>Shaun Walker</Authors>
<Company>.NET Foundation</Company>
@ -17,10 +17,15 @@
<RootNamespace>Oqtane</RootNamespace>
</PropertyGroup>
<ItemGroup>
<None Remove="Scripts\Tenant.0.9.1.sql" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Modules\HtmlText\Scripts\HtmlText.1.0.0.sql" />
<EmbeddedResource Include="Modules\HtmlText\Scripts\HtmlText.Uninstall.sql" />
<EmbeddedResource Include="Scripts\Master.0.9.0.sql" />
<EmbeddedResource Include="Scripts\Tenant.0.9.1.sql" />
<EmbeddedResource Include="Scripts\Tenant.0.9.0.sql" />
</ItemGroup>

View File

@ -775,6 +775,7 @@ namespace Oqtane.Repository
{
SiteId = site.SiteId,
ModuleDefinitionName = pagetemplatemodule.ModuleDefinitionName,
AllPages = false,
Permissions = pagetemplatemodule.ModulePermissions,
};
module = _moduleRepository.AddModule(module);

View File

@ -0,0 +1,14 @@
/*
migration script
*/
ALTER TABLE [dbo].[Module] ADD
[AllPages] [bit] NULL
GO
UPDATE [dbo].[Module]
SET [AllPages] = 0
GO

View File

@ -28,16 +28,6 @@ app {
width: 100%; /* 100% width */
}
/* Pad the navigation links */
.app-controlpanel .nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
}
.app-controlpanel .card-body .control-label {
color: white;
}
/* Admin Modal */
.app-admin-modal .modal {
position: fixed; /* Stay in place */

View File

@ -9,6 +9,7 @@ namespace Oqtane.Models
public int ModuleId { get; set; }
public int SiteId { get; set; }
public string ModuleDefinitionName { get; set; }
public bool AllPages { get; set; }
public string CreatedBy { get; set; }
public DateTime CreatedOn { get; set; }

View File

@ -4,7 +4,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>7.3</LangVersion>
<Configurations>Debug;Release</Configurations>
<Version>0.9.0</Version>
<Version>0.9.1</Version>
<Product>Oqtane</Product>
<Authors>Shaun Walker</Authors>
<Company>.NET Foundation</Company>

View File

@ -3,8 +3,8 @@
public class Constants
{
public const string PackageId = "Oqtane.Framework";
public const string Version = "0.9.0";
public const string ReleaseVersions = "0.9.0";
public const string Version = "0.9.1";
public const string ReleaseVersions = "0.9.0,0.9.1";
public const string PageComponent = "Oqtane.UI.ThemeBuilder, Oqtane.Client";
public const string ContainerComponent = "Oqtane.UI.ContainerBuilder, Oqtane.Client";

View File

@ -4,7 +4,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>7.3</LangVersion>
<OutputType>Exe</OutputType>
<Version>0.9.0</Version>
<Version>0.9.1</Version>
<Product>Oqtane</Product>
<Authors>Shaun Walker</Authors>
<Company>.NET Foundation</Company>

View File

@ -10,14 +10,12 @@ namespace Oqtane.Upgrade
{
static void Main(string[] args)
{
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
// assumes that the application executable must be deployed to the /bin of the Oqtane.Server project
if (binfolder.Contains(Path.Combine("Oqtane.Server", "bin")))
// requires 2 arguments - the contentrootpath and the webrootpath of the site
if (args.Length == 2)
{
// ie. binfolder = Oqtane.Server\bin\Debug\netcoreapp3.0\
string rootfolder = Directory.GetParent(binfolder).Parent.Parent.FullName;
string deployfolder = Path.Combine(rootfolder, Path.Combine("wwwroot","Framework"));
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
string rootfolder = args[0];
string deployfolder = Path.Combine(args[1], "Framework");
if (Directory.Exists(deployfolder))
{
@ -87,7 +85,7 @@ namespace Oqtane.Upgrade
success = false;
}
if (success)
if (success)
{
// clean up backup
foreach (string file in files)
@ -99,7 +97,7 @@ namespace Oqtane.Upgrade
}
}
}
else
else
{
// restore on failure
foreach (string file in files)