Additional properties added to Route model to improve abstraction, modified Site Settings to support settings moved to the server.
This commit is contained in:
parent
43d166fb7d
commit
a216e2b92e
|
@ -324,6 +324,16 @@
|
||||||
_containertype = (!string.IsNullOrEmpty(site.DefaultContainerType)) ? site.DefaultContainerType : Constants.DefaultContainer;
|
_containertype = (!string.IsNullOrEmpty(site.DefaultContainerType)) ? site.DefaultContainerType : Constants.DefaultContainer;
|
||||||
_admincontainertype = (!string.IsNullOrEmpty(site.AdminContainerType)) ? site.AdminContainerType : Constants.DefaultAdminContainer;
|
_admincontainertype = (!string.IsNullOrEmpty(site.AdminContainerType)) ? site.AdminContainerType : Constants.DefaultAdminContainer;
|
||||||
|
|
||||||
|
_pwaisenabled = site.PwaIsEnabled.ToString();
|
||||||
|
if (site.PwaAppIconFileId != null)
|
||||||
|
{
|
||||||
|
_pwaappiconfileid = site.PwaAppIconFileId.Value;
|
||||||
|
}
|
||||||
|
if (site.PwaSplashIconFileId != null)
|
||||||
|
{
|
||||||
|
_pwasplashiconfileid = site.PwaSplashIconFileId.Value;
|
||||||
|
}
|
||||||
|
|
||||||
var settings = await SettingService.GetSiteSettingsAsync(site.SiteId);
|
var settings = await SettingService.GetSiteSettingsAsync(site.SiteId);
|
||||||
_smtphost = SettingService.GetSetting(settings, "SMTPHost", string.Empty);
|
_smtphost = SettingService.GetSetting(settings, "SMTPHost", string.Empty);
|
||||||
_smtpport = SettingService.GetSetting(settings, "SMTPPort", string.Empty);
|
_smtpport = SettingService.GetSetting(settings, "SMTPPort", string.Empty);
|
||||||
|
@ -332,28 +342,6 @@
|
||||||
_smtppassword = SettingService.GetSetting(settings, "SMTPPassword", string.Empty);
|
_smtppassword = SettingService.GetSetting(settings, "SMTPPassword", string.Empty);
|
||||||
_smtpsender = SettingService.GetSetting(settings, "SMTPSender", string.Empty);
|
_smtpsender = SettingService.GetSetting(settings, "SMTPSender", string.Empty);
|
||||||
|
|
||||||
_pwaisenabled = site.PwaIsEnabled.ToString();
|
|
||||||
|
|
||||||
if (site.PwaAppIconFileId != null)
|
|
||||||
{
|
|
||||||
_pwaappiconfileid = site.PwaAppIconFileId.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (site.PwaSplashIconFileId != null)
|
|
||||||
{
|
|
||||||
_pwasplashiconfileid = site.PwaSplashIconFileId.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
_pwaisenabled = site.PwaIsEnabled.ToString();
|
|
||||||
if (site.PwaAppIconFileId != null)
|
|
||||||
{
|
|
||||||
_pwaappiconfileid = site.PwaAppIconFileId.Value;
|
|
||||||
}
|
|
||||||
if (site.PwaSplashIconFileId != null)
|
|
||||||
{
|
|
||||||
_pwasplashiconfileid = site.PwaSplashIconFileId.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||||
{
|
{
|
||||||
var tenants = await TenantService.GetTenantsAsync();
|
var tenants = await TenantService.GetTenantsAsync();
|
||||||
|
@ -435,8 +423,8 @@
|
||||||
var site = await SiteService.GetSiteAsync(PageState.Site.SiteId);
|
var site = await SiteService.GetSiteAsync(PageState.Site.SiteId);
|
||||||
if (site != null)
|
if (site != null)
|
||||||
{
|
{
|
||||||
|
bool refresh = false;
|
||||||
bool reload = false;
|
bool reload = false;
|
||||||
bool refresh = (site.DefaultThemeType != _themetype || site.DefaultContainerType != _containertype);
|
|
||||||
|
|
||||||
site.Name = _name;
|
site.Name = _name;
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||||
|
@ -446,7 +434,7 @@
|
||||||
site.Runtime = _runtime;
|
site.Runtime = _runtime;
|
||||||
site.RenderMode = _runtime + _prerender;
|
site.RenderMode = _runtime + _prerender;
|
||||||
refresh = true;
|
refresh = true;
|
||||||
reload = true;
|
reload = true; // needs to be reloaded on server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration));
|
site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration));
|
||||||
|
@ -458,25 +446,43 @@
|
||||||
{
|
{
|
||||||
site.LogoFileId = logofileid;
|
site.LogoFileId = logofileid;
|
||||||
}
|
}
|
||||||
var faviconFieldId = _faviconfilemanager.GetFileId();
|
int? faviconFieldId = _faviconfilemanager.GetFileId();
|
||||||
if (faviconFieldId != -1)
|
if (faviconFieldId == -1) faviconFieldId = null;
|
||||||
|
if (site.FaviconFileId != faviconFieldId)
|
||||||
{
|
{
|
||||||
site.FaviconFileId = faviconFieldId;
|
site.FaviconFileId = faviconFieldId;
|
||||||
|
reload = true; // needs to be reloaded on server
|
||||||
}
|
}
|
||||||
|
if (site.DefaultThemeType != _themetype)
|
||||||
|
{
|
||||||
site.DefaultThemeType = _themetype;
|
site.DefaultThemeType = _themetype;
|
||||||
|
refresh = true; // needs to be refreshed on client
|
||||||
|
}
|
||||||
|
if (site.DefaultContainerType != _containertype)
|
||||||
|
{
|
||||||
site.DefaultContainerType = _containertype;
|
site.DefaultContainerType = _containertype;
|
||||||
|
refresh = true; // needs to be refreshed on client
|
||||||
|
}
|
||||||
site.AdminContainerType = _admincontainertype;
|
site.AdminContainerType = _admincontainertype;
|
||||||
|
|
||||||
site.PwaIsEnabled = (_pwaisenabled == null ? true : Boolean.Parse(_pwaisenabled));
|
if (site.PwaIsEnabled.ToString() != _pwaisenabled)
|
||||||
var pwaappiconfileid = _pwaappiconfilemanager.GetFileId();
|
{
|
||||||
if (pwaappiconfileid != -1)
|
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;
|
site.PwaAppIconFileId = pwaappiconfileid;
|
||||||
|
reload = true; // needs to be reloaded on server
|
||||||
}
|
}
|
||||||
var pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId();
|
int? pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId();
|
||||||
if (pwasplashiconfileid != -1)
|
if (pwasplashiconfileid == -1) pwasplashiconfileid = null;
|
||||||
|
if (site.PwaSplashIconFileId != pwasplashiconfileid)
|
||||||
{
|
{
|
||||||
site.PwaSplashIconFileId = pwasplashiconfileid;
|
site.PwaSplashIconFileId = pwasplashiconfileid;
|
||||||
|
reload = true; // needs to be reloaded on server
|
||||||
}
|
}
|
||||||
|
|
||||||
site = await SiteService.UpdateSiteAsync(site);
|
site = await SiteService.UpdateSiteAsync(site);
|
||||||
|
@ -518,7 +524,7 @@
|
||||||
|
|
||||||
if (refresh)
|
if (refresh)
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo(NavigateUrl(), reload); // refresh to show new theme or container
|
NavigationManager.NavigateTo(NavigateUrl(true), reload); // refresh/reload
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -149,16 +149,16 @@ namespace Oqtane.Pages
|
||||||
"var manifest = { " +
|
"var manifest = { " +
|
||||||
"\"name\": \"" + site.Name + "\", " +
|
"\"name\": \"" + site.Name + "\", " +
|
||||||
"\"short_name\": \"" + site.Name + "\", " +
|
"\"short_name\": \"" + site.Name + "\", " +
|
||||||
"\"start_url\": \"" + route.Scheme + "://" + route.Authority + "/\", " +
|
"\"start_url\": \"" + route.SiteUrl + "/\", " +
|
||||||
"\"display\": \"standalone\", " +
|
"\"display\": \"standalone\", " +
|
||||||
"\"background_color\": \"#fff\", " +
|
"\"background_color\": \"#fff\", " +
|
||||||
"\"description\": \"" + site.Name + "\", " +
|
"\"description\": \"" + site.Name + "\", " +
|
||||||
"\"icons\": [{ " +
|
"\"icons\": [{ " +
|
||||||
"\"src\": \"" + route.Scheme + "://" + route.Authority + Utilities.ContentUrl(alias, site.PwaAppIconFileId.Value) + "\", " +
|
"\"src\": \"" + route.RootUrl + Utilities.ContentUrl(alias, site.PwaAppIconFileId.Value) + "\", " +
|
||||||
"\"sizes\": \"192x192\", " +
|
"\"sizes\": \"192x192\", " +
|
||||||
"\"type\": \"image/png\" " +
|
"\"type\": \"image/png\" " +
|
||||||
"}, { " +
|
"}, { " +
|
||||||
"\"src\": \"" + route.Scheme + "://" + route.Authority + Utilities.ContentUrl(alias, site.PwaSplashIconFileId.Value) + "\", " +
|
"\"src\": \"" + route.RootUrl + Utilities.ContentUrl(alias, site.PwaSplashIconFileId.Value) + "\", " +
|
||||||
"\"sizes\": \"512x512\", " +
|
"\"sizes\": \"512x512\", " +
|
||||||
"\"type\": \"image/png\" " +
|
"\"type\": \"image/png\" " +
|
||||||
"}] " +
|
"}] " +
|
||||||
|
|
|
@ -4,12 +4,16 @@ using Oqtane.Shared;
|
||||||
namespace Oqtane.Models
|
namespace Oqtane.Models
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A route is comprised of multiple components:
|
/// A route is comprised of multiple components ( some optional depending on context )
|
||||||
/// {scheme}://{hostname}/{aliaspath}/{pagepath}/*/{moduleid}/{action}/!/{urlparameters}?{query}#{fragment}
|
/// {scheme}://{hostname}/{aliaspath}/{pagepath}/*/{moduleid}/{action}/!/{urlparameters}?{query}#{fragment}
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Route
|
public class Route
|
||||||
{
|
{
|
||||||
// default constructor accepts an absolute route url and alias
|
/// <summary>
|
||||||
|
/// default constructor
|
||||||
|
/// the route parameter can be obtained from NavigationManager.Uri on client or HttpContext.Request.GetEncodedUrl() on server
|
||||||
|
/// the aliaspath parameter can be obtained from PageState.Alias.Path on client or TenantManager.GetAlias().Path on server
|
||||||
|
/// </summary>
|
||||||
public Route(string route, string aliaspath)
|
public Route(string route, string aliaspath)
|
||||||
{
|
{
|
||||||
Uri uri = new Uri(route);
|
Uri uri = new Uri(route);
|
||||||
|
@ -120,5 +124,27 @@ namespace Oqtane.Models
|
||||||
/// A route may contain a fragment located after the # delimiter
|
/// A route may contain a fragment located after the # delimiter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Fragment { get; set; }
|
public string Fragment { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The root url contains the resource identifier for the root of an Oqtane installation ( including scheme )
|
||||||
|
/// </summary>
|
||||||
|
public string RootUrl
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Scheme + "://" + Authority;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The site url contains the resource identifier for the home page of a specific Oqtane site ( including scheme and possibly an alias path )
|
||||||
|
/// </summary>
|
||||||
|
public string SiteUrl
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Scheme + "://" + Authority + ((!string.IsNullOrEmpty(AliasPath)) ? "/" + AliasPath : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user