Merge remote-tracking branch 'oqtane/dev' into dev
This commit is contained in:
commit
3a1f378e2d
@ -5,9 +5,7 @@
|
|||||||
@inject SiteState SiteState
|
@inject SiteState SiteState
|
||||||
|
|
||||||
<span class="app-moduletitle">
|
<span class="app-moduletitle">
|
||||||
<a id="@ModuleState.PageModuleId.ToString()">
|
|
||||||
@((MarkupString)title)
|
@((MarkupString)title)
|
||||||
</a>
|
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
@ -479,7 +479,11 @@
|
|||||||
PageState.EditMode = true;
|
PageState.EditMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Page.Path, "edit=" + ((PageState.EditMode) ? "true" : "false")));
|
// preserve other querystring parameters
|
||||||
|
if (PageState.QueryString.ContainsKey("edit")) PageState.QueryString.Remove("edit");
|
||||||
|
PageState.QueryString.Add("edit", PageState.EditMode.ToString().ToLower());
|
||||||
|
var url = PageState.Route.AbsolutePath + Utilities.CreateQueryString(PageState.QueryString);
|
||||||
|
NavigationManager.NavigateTo(url);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
@if (_visible)
|
@if (_visible)
|
||||||
{
|
{
|
||||||
|
<a id="@ModuleState.PageModuleId.ToString()"></a>
|
||||||
<CascadingValue Value="@ModuleState">
|
<CascadingValue Value="@ModuleState">
|
||||||
@if (_useadminborder)
|
@if (_useadminborder)
|
||||||
{
|
{
|
||||||
@ -16,6 +17,7 @@
|
|||||||
@DynamicComponent
|
@DynamicComponent
|
||||||
}
|
}
|
||||||
</CascadingValue>
|
</CascadingValue>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
@ -38,7 +40,7 @@
|
|||||||
protected override void OnParametersSet()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
string container = ModuleState.ContainerType;
|
string container = ModuleState.ContainerType;
|
||||||
if (PageState.ModuleId != -1 && ModuleState.UseAdminContainer)
|
if (PageState.ModuleId != -1 && PageState.Route.Action != "" && ModuleState.UseAdminContainer)
|
||||||
{
|
{
|
||||||
container = (!string.IsNullOrEmpty(PageState.Site.AdminContainerType)) ? PageState.Site.AdminContainerType : Constants.DefaultAdminContainer;
|
container = (!string.IsNullOrEmpty(PageState.Site.AdminContainerType)) ? PageState.Site.AdminContainerType : Constants.DefaultAdminContainer;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ namespace Oqtane.UI
|
|||||||
public int VisitorId { get; set; }
|
public int VisitorId { get; set; }
|
||||||
public string RemoteIPAddress { get; set; }
|
public string RemoteIPAddress { get; set; }
|
||||||
public string ReturnUrl { get; set; }
|
public string ReturnUrl { get; set; }
|
||||||
|
public bool IsInternalNavigation { get; set; }
|
||||||
|
|
||||||
public List<Page> Pages
|
public List<Page> Pages
|
||||||
{
|
{
|
||||||
|
@ -43,10 +43,11 @@ else
|
|||||||
|
|
||||||
DynamicComponent = builder =>
|
DynamicComponent = builder =>
|
||||||
{
|
{
|
||||||
if (PageState.ModuleId != -1 && PageState.Action != Constants.DefaultAction)
|
foreach (Module module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId))
|
||||||
|
{
|
||||||
|
var pane = module.Pane;
|
||||||
|
if (module.ModuleId == PageState.ModuleId && PageState.Action != Constants.DefaultAction)
|
||||||
{
|
{
|
||||||
// action route needs to inject module control into specific pane
|
|
||||||
string pane = "";
|
|
||||||
if (PageState.Page.Panes.FindIndex(item => item.Equals(PaneNames.Default, StringComparison.OrdinalIgnoreCase)) != -1)
|
if (PageState.Page.Panes.FindIndex(item => item.Equals(PaneNames.Default, StringComparison.OrdinalIgnoreCase)) != -1)
|
||||||
{
|
{
|
||||||
pane = PaneNames.Default;
|
pane = PaneNames.Default;
|
||||||
@ -54,16 +55,13 @@ else
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
pane = PaneNames.Admin;
|
pane = PaneNames.Admin;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// pane matches current pane
|
||||||
if (Name.ToLower() == pane.ToLower())
|
if (Name.ToLower() == pane.ToLower())
|
||||||
{
|
{
|
||||||
Module module = PageState.Modules.FirstOrDefault(item => item.PageId == PageState.Page.PageId && item.ModuleId == PageState.ModuleId);
|
if (module.ModuleId == PageState.ModuleId && PageState.Action != Constants.DefaultAction)
|
||||||
if (module == null)
|
|
||||||
{
|
|
||||||
module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
|
|
||||||
}
|
|
||||||
if (module != null)
|
|
||||||
{
|
{
|
||||||
var moduleType = Type.GetType(module.ModuleType);
|
var moduleType = Type.GetType(module.ModuleType);
|
||||||
if (moduleType != null)
|
if (moduleType != null)
|
||||||
@ -100,23 +98,10 @@ else
|
|||||||
CreateComponent(builder, module);
|
CreateComponent(builder, module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// module type does not exist
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (PageState.ModuleId != -1)
|
if (PageState.ModuleId == -1 || PageState.ModuleId == module.ModuleId)
|
||||||
{
|
|
||||||
Module module = PageState.Modules.FirstOrDefault(item => item.PageId == PageState.Page.PageId && item.ModuleId == PageState.ModuleId);
|
|
||||||
if (module == null)
|
|
||||||
{
|
|
||||||
module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
|
|
||||||
}
|
|
||||||
if (module != null && module.Pane.ToLower() == Name.ToLower())
|
|
||||||
{
|
{
|
||||||
// check if user is authorized to view module
|
// check if user is authorized to view module
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.PermissionList))
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.PermissionList))
|
||||||
@ -125,16 +110,6 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (Module module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId && item.Pane.ToLower() == Name.ToLower()))
|
|
||||||
{
|
|
||||||
// check if user is authorized to view module
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.PermissionList))
|
|
||||||
{
|
|
||||||
CreateComponent(builder, module);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _absoluteUri;
|
private string _absoluteUri;
|
||||||
|
private bool _isInternalNavigation = false;
|
||||||
private bool _navigationInterceptionEnabled;
|
private bool _navigationInterceptionEnabled;
|
||||||
private PageState _pagestate;
|
private PageState _pagestate;
|
||||||
private string _error = "";
|
private string _error = "";
|
||||||
@ -72,6 +73,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void LocationChanged(object sender, LocationChangedEventArgs args)
|
||||||
|
{
|
||||||
|
_absoluteUri = args.Location;
|
||||||
|
_isInternalNavigation = true;
|
||||||
|
await Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
Task IHandleAfterRender.OnAfterRenderAsync()
|
||||||
|
{
|
||||||
|
if (!_navigationInterceptionEnabled)
|
||||||
|
{
|
||||||
|
_navigationInterceptionEnabled = true;
|
||||||
|
return NavigationInterception.EnableNavigationInterceptionAsync();
|
||||||
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "StringIndexOfIsCultureSpecific.1")]
|
[SuppressMessage("ReSharper", "StringIndexOfIsCultureSpecific.1")]
|
||||||
private async Task Refresh()
|
private async Task Refresh()
|
||||||
{
|
{
|
||||||
@ -87,7 +105,7 @@
|
|||||||
Route route = new Route(_absoluteUri, SiteState.Alias.Path);
|
Route route = new Route(_absoluteUri, SiteState.Alias.Path);
|
||||||
int moduleid = (int.TryParse(route.ModuleId, out moduleid)) ? moduleid : -1;
|
int moduleid = (int.TryParse(route.ModuleId, out moduleid)) ? moduleid : -1;
|
||||||
var action = (!string.IsNullOrEmpty(route.Action)) ? route.Action : Constants.DefaultAction;
|
var action = (!string.IsNullOrEmpty(route.Action)) ? route.Action : Constants.DefaultAction;
|
||||||
var querystring = ParseQueryString(route.Query);
|
var querystring = Utilities.ParseQueryString(route.Query);
|
||||||
var returnurl = "";
|
var returnurl = "";
|
||||||
if (querystring.ContainsKey("returnurl"))
|
if (querystring.ContainsKey("returnurl"))
|
||||||
{
|
{
|
||||||
@ -233,7 +251,8 @@
|
|||||||
Runtime = runtime,
|
Runtime = runtime,
|
||||||
VisitorId = VisitorId,
|
VisitorId = VisitorId,
|
||||||
RemoteIPAddress = SiteState.RemoteIPAddress,
|
RemoteIPAddress = SiteState.RemoteIPAddress,
|
||||||
ReturnUrl = returnurl
|
ReturnUrl = returnurl,
|
||||||
|
IsInternalNavigation = _isInternalNavigation
|
||||||
};
|
};
|
||||||
|
|
||||||
OnStateChange?.Invoke(_pagestate);
|
OnStateChange?.Invoke(_pagestate);
|
||||||
@ -278,56 +297,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void LocationChanged(object sender, LocationChangedEventArgs args)
|
|
||||||
{
|
|
||||||
_absoluteUri = args.Location;
|
|
||||||
await Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
Task IHandleAfterRender.OnAfterRenderAsync()
|
|
||||||
{
|
|
||||||
if (!_navigationInterceptionEnabled)
|
|
||||||
{
|
|
||||||
_navigationInterceptionEnabled = true;
|
|
||||||
return NavigationInterception.EnableNavigationInterceptionAsync();
|
|
||||||
}
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dictionary<string, string> ParseQueryString(string query)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> querystring = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); // case insensistive keys
|
|
||||||
if (!string.IsNullOrEmpty(query))
|
|
||||||
{
|
|
||||||
if (query.StartsWith("?"))
|
|
||||||
{
|
|
||||||
query = query.Substring(1); // ignore "?"
|
|
||||||
}
|
|
||||||
foreach (string kvp in query.Split('&', StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
|
||||||
if (kvp != "")
|
|
||||||
{
|
|
||||||
if (kvp.Contains("="))
|
|
||||||
{
|
|
||||||
string[] pair = kvp.Split('=');
|
|
||||||
if (!querystring.ContainsKey(pair[0]))
|
|
||||||
{
|
|
||||||
querystring.Add(pair[0], pair[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!querystring.ContainsKey(kvp))
|
|
||||||
{
|
|
||||||
querystring.Add(kvp, "true"); // default parameter when no value is provided
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return querystring;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<Page> ProcessPage(Page page, Site site, User user, Alias alias)
|
private async Task<Page> ProcessPage(Page page, Site site, User user, Alias alias)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -411,11 +380,16 @@
|
|||||||
if ((module.PageId == page.PageId || module.ModuleId == moduleid))
|
if ((module.PageId == page.PageId || module.ModuleId == moduleid))
|
||||||
{
|
{
|
||||||
var typename = Constants.ErrorModule;
|
var typename = Constants.ErrorModule;
|
||||||
|
|
||||||
if (module.ModuleDefinition != null && (module.ModuleDefinition.Runtimes == "" || module.ModuleDefinition.Runtimes.Contains(Runtime)))
|
if (module.ModuleDefinition != null && (module.ModuleDefinition.Runtimes == "" || module.ModuleDefinition.Runtimes.Contains(Runtime)))
|
||||||
{
|
{
|
||||||
typename = module.ModuleDefinition.ControlTypeTemplate;
|
typename = module.ModuleDefinition.ControlTypeTemplate;
|
||||||
|
|
||||||
// handle default action
|
// handle default action
|
||||||
|
if (moduleid != module.ModuleId)
|
||||||
|
{
|
||||||
|
action = Constants.DefaultAction;
|
||||||
|
}
|
||||||
if (action == Constants.DefaultAction && !string.IsNullOrEmpty(module.ModuleDefinition.DefaultAction))
|
if (action == Constants.DefaultAction && !string.IsNullOrEmpty(module.ModuleDefinition.DefaultAction))
|
||||||
{
|
{
|
||||||
action = module.ModuleDefinition.DefaultAction;
|
action = module.ModuleDefinition.DefaultAction;
|
||||||
|
@ -38,7 +38,7 @@ namespace Oqtane.Models
|
|||||||
PageTemplateModules = new List<PageTemplateModule>();
|
PageTemplateModules = new List<PageTemplateModule>();
|
||||||
|
|
||||||
// properties used by IModule
|
// properties used by IModule
|
||||||
AliasName = "*";
|
AliasName = "";
|
||||||
Version = "*";
|
Version = "*";
|
||||||
Update = false;
|
Update = false;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -438,28 +439,50 @@ namespace Oqtane.Shared
|
|||||||
|
|
||||||
public static Dictionary<string, string> ParseQueryString(string query)
|
public static Dictionary<string, string> ParseQueryString(string query)
|
||||||
{
|
{
|
||||||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
Dictionary<string, string> querystring = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); // case insensistive keys
|
||||||
if (!string.IsNullOrEmpty(query))
|
if (!string.IsNullOrEmpty(query))
|
||||||
{
|
{
|
||||||
query = query.Substring(1);
|
if (query.StartsWith("?"))
|
||||||
string str = query;
|
|
||||||
char[] separator = new char[1] { '&' };
|
|
||||||
foreach (string key in str.Split(separator, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
{
|
||||||
if (key != "")
|
query = query.Substring(1); // ignore "?"
|
||||||
|
}
|
||||||
|
foreach (string kvp in query.Split('&', StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
if (key.Contains("="))
|
if (kvp != "")
|
||||||
{
|
{
|
||||||
string[] strArray = key.Split('=', StringSplitOptions.None);
|
if (kvp.Contains("="))
|
||||||
dictionary.Add(strArray[0], strArray[1]);
|
{
|
||||||
|
string[] pair = kvp.Split('=');
|
||||||
|
if (!querystring.ContainsKey(pair[0]))
|
||||||
|
{
|
||||||
|
querystring.Add(pair[0], pair[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dictionary.Add(key, "true");
|
{
|
||||||
|
if (!querystring.ContainsKey(kvp))
|
||||||
|
{
|
||||||
|
querystring.Add(kvp, "true"); // default parameter when no value is provided
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return querystring;
|
||||||
|
}
|
||||||
|
|
||||||
return dictionary;
|
public static string CreateQueryString(Dictionary<string, string> parameters)
|
||||||
|
{
|
||||||
|
var querystring = "";
|
||||||
|
if (parameters.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var kvp in parameters)
|
||||||
|
{
|
||||||
|
querystring += (querystring == "") ? "?" : "&";
|
||||||
|
querystring += kvp.Key + "=" + kvp.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return querystring;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string LogMessage(object @class, string message)
|
public static string LogMessage(object @class, string message)
|
||||||
|
Reference in New Issue
Block a user