Merge remote-tracking branch 'oqtane/dev' into dev
This commit is contained in:
commit
3491dde94a
|
@ -9,6 +9,7 @@ using Oqtane.UI;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.JSInterop;
|
using Microsoft.JSInterop;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Oqtane.Themes;
|
||||||
|
|
||||||
namespace Oqtane.Modules
|
namespace Oqtane.Modules
|
||||||
{
|
{
|
||||||
|
@ -70,12 +71,28 @@ namespace Oqtane.Modules
|
||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
if (Resources != null && Resources.Exists(item => item.ResourceType == ResourceType.Script))
|
List<Resource> resources = null;
|
||||||
|
var type = GetType();
|
||||||
|
if (type.BaseType == typeof(ModuleBase))
|
||||||
|
{
|
||||||
|
if (PageState.Page.Resources != null)
|
||||||
|
{
|
||||||
|
resources = PageState.Page.Resources.Where(item => item.ResourceType == ResourceType.Script && item.Namespace == type.Namespace).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // modulecontrolbase
|
||||||
|
{
|
||||||
|
if (Resources != null)
|
||||||
|
{
|
||||||
|
resources = Resources.Where(item => item.ResourceType == ResourceType.Script).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resources != null &&resources.Any())
|
||||||
{
|
{
|
||||||
var interop = new Interop(JSRuntime);
|
var interop = new Interop(JSRuntime);
|
||||||
var scripts = new List<object>();
|
var scripts = new List<object>();
|
||||||
var inline = 0;
|
var inline = 0;
|
||||||
foreach (Resource resource in Resources.Where(item => item.ResourceType == ResourceType.Script))
|
foreach (Resource resource in resources)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(resource.Url))
|
if (!string.IsNullOrEmpty(resource.Url))
|
||||||
{
|
{
|
||||||
|
@ -104,6 +121,7 @@ namespace Oqtane.Modules
|
||||||
}
|
}
|
||||||
|
|
||||||
// url methods
|
// url methods
|
||||||
|
|
||||||
public string NavigateUrl()
|
public string NavigateUrl()
|
||||||
{
|
{
|
||||||
return NavigateUrl(PageState.Page.Path);
|
return NavigateUrl(PageState.Page.Path);
|
||||||
|
|
|
@ -6,6 +6,7 @@ using Oqtane.UI;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Oqtane.Themes
|
namespace Oqtane.Themes
|
||||||
|
@ -33,12 +34,28 @@ namespace Oqtane.Themes
|
||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
if (Resources != null && Resources.Exists(item => item.ResourceType == ResourceType.Script))
|
List<Resource> resources = null;
|
||||||
|
var type = GetType();
|
||||||
|
if (type.BaseType == typeof(ThemeBase))
|
||||||
|
{
|
||||||
|
if (PageState.Page.Resources != null)
|
||||||
|
{
|
||||||
|
resources = PageState.Page.Resources.Where(item => item.ResourceType == ResourceType.Script && item.Namespace == type.Namespace).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // themecontrolbase, containerbase
|
||||||
|
{
|
||||||
|
if (Resources != null)
|
||||||
|
{
|
||||||
|
resources = Resources.Where(item => item.ResourceType == ResourceType.Script).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resources != null && resources.Any())
|
||||||
{
|
{
|
||||||
var interop = new Interop(JSRuntime);
|
var interop = new Interop(JSRuntime);
|
||||||
var scripts = new List<object>();
|
var scripts = new List<object>();
|
||||||
var inline = 0;
|
var inline = 0;
|
||||||
foreach (Resource resource in Resources.Where(item => item.ResourceType == ResourceType.Script))
|
foreach (Resource resource in resources)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(resource.Url))
|
if (!string.IsNullOrEmpty(resource.Url))
|
||||||
{
|
{
|
||||||
|
|
|
@ -333,10 +333,11 @@
|
||||||
// fallback to default Oqtane theme
|
// fallback to default Oqtane theme
|
||||||
page.ThemeType = Constants.DefaultTheme;
|
page.ThemeType = Constants.DefaultTheme;
|
||||||
themetype = Type.GetType(Constants.DefaultTheme);
|
themetype = Type.GetType(Constants.DefaultTheme);
|
||||||
|
theme = site.Themes.FirstOrDefault(item => item.Themes.Any(item => item.TypeName == page.ThemeType));
|
||||||
}
|
}
|
||||||
|
|
||||||
string panes = "";
|
string panes = "";
|
||||||
if (themetype != null)
|
if (themetype != null && theme != null)
|
||||||
{
|
{
|
||||||
// get resources for theme (ITheme)
|
// get resources for theme (ITheme)
|
||||||
page.Resources = ManagePageResources(page.Resources, theme.Resources, ResourceLevel.Page, alias, "Themes", Utilities.GetTypeName(theme.ThemeName));
|
page.Resources = ManagePageResources(page.Resources, theme.Resources, ResourceLevel.Page, alias, "Themes", Utilities.GetTypeName(theme.ThemeName));
|
||||||
|
@ -522,9 +523,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure resource does not exist already
|
// ensure resource does not exist already
|
||||||
if (!pageresources.Any(item => item.Url.ToLower() == resource.Url.ToLower()))
|
if (!pageresources.Exists(item => item.Url.ToLower() == resource.Url.ToLower()))
|
||||||
{
|
{
|
||||||
resource.Level = level;
|
resource.Level = level;
|
||||||
|
resource.Namespace = name;
|
||||||
pageresources.Add(resource);
|
pageresources.Add(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,10 +105,9 @@
|
||||||
|
|
||||||
if (PageState.Page.Resources != null)
|
if (PageState.Page.Resources != null)
|
||||||
{
|
{
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
|
|
||||||
if (PageState.Page.Resources.Exists(item => item.ResourceType == ResourceType.Stylesheet))
|
if (PageState.Page.Resources.Exists(item => item.ResourceType == ResourceType.Stylesheet))
|
||||||
{
|
{
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
string batch = DateTime.UtcNow.ToString("yyyyMMddHHmmssfff");
|
string batch = DateTime.UtcNow.ToString("yyyyMMddHHmmssfff");
|
||||||
var links = new List<object>();
|
var links = new List<object>();
|
||||||
foreach (Resource resource in PageState.Page.Resources.Where(item => item.ResourceType == ResourceType.Stylesheet))
|
foreach (Resource resource in PageState.Page.Resources.Where(item => item.ResourceType == ResourceType.Stylesheet))
|
||||||
|
@ -125,28 +124,28 @@
|
||||||
await interop.RemoveElementsById("app-stylesheet-module-", "", "app-stylesheet-module-" + batch + "-00");
|
await interop.RemoveElementsById("app-stylesheet-module-", "", "app-stylesheet-module-" + batch + "-00");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageState.Page.Resources.Exists(item => item.ResourceType == ResourceType.Script))
|
//if (PageState.Page.Resources.Exists(item => item.ResourceType == ResourceType.Script))
|
||||||
{
|
//{
|
||||||
var scripts = new List<object>();
|
// var scripts = new List<object>();
|
||||||
var inline = 0;
|
// var inline = 0;
|
||||||
foreach (Resource resource in PageState.Page.Resources.Where(item => item.ResourceType == ResourceType.Script && item.Level != ResourceLevel.Site))
|
// foreach (Resource resource in PageState.Page.Resources.Where(item => item.ResourceType == ResourceType.Script && item.Level != ResourceLevel.Site))
|
||||||
{
|
// {
|
||||||
if (!string.IsNullOrEmpty(resource.Url))
|
// if (!string.IsNullOrEmpty(resource.Url))
|
||||||
{
|
// {
|
||||||
var url = (resource.Url.Contains("://")) ? resource.Url : PageState.Alias.BaseUrl + resource.Url;
|
// var url = (resource.Url.Contains("://")) ? resource.Url : PageState.Alias.BaseUrl + resource.Url;
|
||||||
scripts.Add(new { href = url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", es6module = resource.ES6Module, location = resource.Location.ToString().ToLower() });
|
// scripts.Add(new { href = url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", es6module = resource.ES6Module, location = resource.Location.ToString().ToLower() });
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
inline += 1;
|
// inline += 1;
|
||||||
await interop.IncludeScript(GetType().Namespace.ToLower() + inline.ToString(), "", "", "", resource.Content, resource.Location.ToString().ToLower());
|
// await interop.IncludeScript(GetType().Namespace.ToLower() + inline.ToString(), "", "", "", resource.Content, resource.Location.ToString().ToLower());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (scripts.Any())
|
// if (scripts.Any())
|
||||||
{
|
// {
|
||||||
await interop.IncludeScripts(scripts.ToArray());
|
// await interop.IncludeScripts(scripts.ToArray());
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,10 @@ namespace Oqtane.Models
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Content { get; set; }
|
public string Content { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The namespace of the component that declared the resource - only used in SiteRouter
|
||||||
|
/// </summary>
|
||||||
|
public string Namespace { get; set; }
|
||||||
|
|
||||||
[Obsolete("ResourceDeclaration is deprecated", false)]
|
[Obsolete("ResourceDeclaration is deprecated", false)]
|
||||||
public ResourceDeclaration Declaration { get; set; }
|
public ResourceDeclaration Declaration { get; set; }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user