added HybridEnabled field to Site table to indicate if .NET MAUI hybrid applications can be integrated

This commit is contained in:
sbwalker 2023-12-04 16:35:03 -05:00
parent 08f691ee0d
commit 2e4656ae8b
6 changed files with 79 additions and 25 deletions

View File

@ -311,7 +311,7 @@
<Section Name="Hosting" Heading="Hosting Model" ResourceKey="Hosting">
<div class="container">
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="runtime" HelpText="The Blazor runtime hosting model" ResourceKey="Runtime">Runtime: </Label>
<Label Class="col-sm-3" For="runtime" HelpText="The Blazor runtime hosting model for the site" ResourceKey="Runtime">Runtime: </Label>
<div class="col-sm-9">
<select id="runtime" class="form-select" @bind="@_runtime" required>
<option value="Server">@SharedLocalizer["BlazorServer"]</option>
@ -328,6 +328,15 @@
</select>
</div>
</div>
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="hybridenabled" HelpText="Specifies if the site can be integrated with an external .NET MAUI hybrid application" ResourceKey="HybridEnabled">Hybrid Enabled? </Label>
<div class="col-sm-9">
<select id="hybridenabled" class="form-select" @bind="@_hybridenabled" required>
<option value="True">@SharedLocalizer["Yes"]</option>
<option value="False">@SharedLocalizer["No"]</option>
</select>
</div>
</div>
</div>
</Section>
<Section Name="TenantInformation" Heading="Database" ResourceKey="TenantInformation">
@ -407,6 +416,7 @@
private string _defaultalias;
private string _runtime = "";
private string _prerender = "";
private string _hybridenabled = "";
private string _tenant = string.Empty;
private string _database = string.Empty;
private string _connectionstring = string.Empty;
@ -490,6 +500,7 @@
// hosting model
_runtime = site.Runtime;
_prerender = site.RenderMode.Replace(_runtime, "");
_hybridenabled = site.HybridEnabled.ToString();
// database
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
@ -599,34 +610,35 @@
}
// PWA
if (site.PwaIsEnabled.ToString() != _pwaisenabled)
{
site.PwaIsEnabled = Boolean.Parse(_pwaisenabled);
reload = true; // needs to be reloaded on server
}
int? pwaappiconfileid = _pwaappiconfilemanager.GetFileId();
if (pwaappiconfileid == -1) pwaappiconfileid = null;
if (site.PwaAppIconFileId != pwaappiconfileid)
{
site.PwaAppIconFileId = pwaappiconfileid;
reload = true; // needs to be reloaded on server
}
int? pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId();
if (pwasplashiconfileid == -1) pwasplashiconfileid = null;
if (site.PwaSplashIconFileId != pwasplashiconfileid)
{
site.PwaSplashIconFileId = pwasplashiconfileid;
reload = true; // needs to be reloaded on server
}
if (site.PwaIsEnabled.ToString() != _pwaisenabled)
{
site.PwaIsEnabled = Boolean.Parse(_pwaisenabled);
reload = true; // needs to be reloaded on server
}
int? pwaappiconfileid = _pwaappiconfilemanager.GetFileId();
if (pwaappiconfileid == -1) pwaappiconfileid = null;
if (site.PwaAppIconFileId != pwaappiconfileid)
{
site.PwaAppIconFileId = pwaappiconfileid;
reload = true; // needs to be reloaded on server
}
int? pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId();
if (pwasplashiconfileid == -1) pwasplashiconfileid = null;
if (site.PwaSplashIconFileId != pwasplashiconfileid)
{
site.PwaSplashIconFileId = pwasplashiconfileid;
reload = true; // needs to be reloaded on server
}
// hosting model
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
{
if (site.Runtime != _runtime || site.RenderMode != _runtime + _prerender)
if (site.Runtime != _runtime || site.RenderMode != _runtime + _prerender || site.HybridEnabled != bool.Parse(_hybridenabled))
{
site.Runtime = _runtime;
site.RenderMode = _runtime + _prerender;
reload = true; // needs to be reloaded on server
site.HybridEnabled = bool.Parse(_hybridenabled);
reload = true; // needs to be reloaded on serve
}
}

View File

@ -283,7 +283,7 @@
<value>Prerender? </value>
</data>
<data name="Runtime.HelpText" xml:space="preserve">
<value>The Blazor runtime hosting model</value>
<value>The Blazor runtime hosting model for the site</value>
</data>
<data name="Runtime.Text" xml:space="preserve">
<value>Runtime: </value>
@ -417,4 +417,10 @@
<data name="UploadableFileExtensions.Text" xml:space="preserve">
<value>Uploadable File Extensions:</value>
</data>
<data name="HybridEnabled.HelpText" xml:space="preserve">
<value>Specifies if the site can be integrated with an external .NET MAUI hybrid application</value>
</data>
<data name="HybridEnabled.Text" xml:space="preserve">
<value>Hybrid Enabled?</value>
</data>
</root>

View File

@ -119,7 +119,7 @@ namespace Oqtane.Controllers
var assemblyList = new List<ClientAssembly>();
var site = _sites.GetSite(alias.SiteId);
if (site != null && site.Runtime == "WebAssembly")
if (site != null && (site.Runtime == "WebAssembly" || site.HybridEnabled))
{
var binFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
@ -201,7 +201,7 @@ namespace Oqtane.Controllers
private byte[] GetZIP(string list, Alias alias)
{
var site = _sites.GetSite(alias.SiteId);
if (site != null && site.Runtime == "WebAssembly")
if (site != null && (site.Runtime == "WebAssembly" || site.HybridEnabled))
{
var binFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

View File

@ -555,6 +555,7 @@ namespace Oqtane.Infrastructure
SiteTemplateType = install.SiteTemplate,
Runtime = (!string.IsNullOrEmpty(install.Runtime)) ? install.Runtime : _configManager.GetSection("Runtime").Value,
RenderMode = (!string.IsNullOrEmpty(install.RenderMode)) ? install.RenderMode : _configManager.GetSection("RenderMode").Value,
HybridEnabled = false
};
site = sites.AddSite(site);

View File

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Oqtane.Databases.Interfaces;
using Oqtane.Migrations.EntityBuilders;
using Oqtane.Repository;
namespace Oqtane.Migrations.Tenant
{
[DbContext(typeof(TenantDBContext))]
[Migration("Tenant.05.00.01.00")]
public class AddSiteHybridEnabled : MultiDatabaseMigration
{
public AddSiteHybridEnabled(IDatabase database) : base(database)
{
}
protected override void Up(MigrationBuilder migrationBuilder)
{
var siteEntityBuilder = new SiteEntityBuilder(migrationBuilder, ActiveDatabase);
siteEntityBuilder.AddBooleanColumn("HybridEnabled", true);
siteEntityBuilder.UpdateColumn("HybridEnabled", "0", "bool", ""); // default to false
}
protected override void Down(MigrationBuilder migrationBuilder)
{
var siteEntityBuilder = new SiteEntityBuilder(migrationBuilder, ActiveDatabase);
siteEntityBuilder.DropColumn("HybridEnabled");
}
}
}

View File

@ -78,6 +78,11 @@ namespace Oqtane.Models
/// </summary>
public string RenderMode { get; set; }
/// <summary>
/// Indicates if a site can be integrated with an external .NET MAUI hybrid application
/// </summary>
public bool HybridEnabled { get; set; }
/// <summary>
/// Keeps track of site configuration changes and is used by the ISiteMigration interface
/// </summary>