Improved page reload efficiency, refactored NavigateUrl and EditUrl helpers, added antiforgery token and returnurl to Logout scenario, fixed PageModule service call api url, modified rendering engine to allow for component differentiation
This commit is contained in:
@ -16,32 +16,38 @@ namespace Oqtane.Themes
|
||||
|
||||
public string NavigateUrl()
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState);
|
||||
}
|
||||
|
||||
public string NavigateUrl(bool reload)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState, reload);
|
||||
return NavigateUrl(PageState.Page.Path);
|
||||
}
|
||||
|
||||
public string NavigateUrl(string path)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState, path);
|
||||
}
|
||||
|
||||
public string NavigateUrl(string path, bool reload)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState, path, reload);
|
||||
return Utilities.NavigateUrl(PageState.Alias.Path, path);
|
||||
}
|
||||
|
||||
public string EditUrl(string action)
|
||||
{
|
||||
return Utilities.EditUrl(PageState, ModuleState, action, "");
|
||||
return EditUrl(ModuleState.ModuleId, action);
|
||||
}
|
||||
|
||||
public string EditUrl(string action, string parameters)
|
||||
{
|
||||
return Utilities.EditUrl(PageState, ModuleState, action, parameters);
|
||||
return EditUrl(ModuleState.ModuleId, action, parameters);
|
||||
}
|
||||
|
||||
public string EditUrl(int moduleid, string action)
|
||||
{
|
||||
return EditUrl(moduleid, action, "");
|
||||
}
|
||||
|
||||
public string EditUrl(int moduleid, string action, string parameters)
|
||||
{
|
||||
return EditUrl(PageState.Page.Path, moduleid, action, parameters);
|
||||
}
|
||||
|
||||
public string EditUrl(string path, int moduleid, string action, string parameters)
|
||||
{
|
||||
return Utilities.EditUrl(PageState.Alias.Path, path, moduleid, action, parameters);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,9 @@
|
||||
pagemodule.Order = 0;
|
||||
pagemodule.ContainerType = containertype;
|
||||
await PageModuleService.AddPageModuleAsync(pagemodule);
|
||||
UriHelper.NavigateTo(NavigateUrl(true));
|
||||
|
||||
PageState.Reload = Constants.ReloadPage;
|
||||
UriHelper.NavigateTo(NavigateUrl());
|
||||
}
|
||||
|
||||
private string PageUrl(string action)
|
||||
@ -130,13 +132,13 @@
|
||||
switch (action)
|
||||
{
|
||||
case "Add":
|
||||
url = "admin/pages?mid=" + pagemanagementmoduleid.ToString() + "&ctl=" + action;
|
||||
url = EditUrl("admin/pages", pagemanagementmoduleid, action, "");
|
||||
break;
|
||||
case "Edit":
|
||||
url = "admin/pages?mid=" + pagemanagementmoduleid.ToString() + "&ctl=" + action + "&id=" + PageState.Page.PageId.ToString();
|
||||
url = EditUrl("admin/pages", pagemanagementmoduleid, action, "id=" + PageState.Page.PageId.ToString());
|
||||
break;
|
||||
case "Delete":
|
||||
url = "admin/pages?mid=" + pagemanagementmoduleid.ToString() + "&ctl=" + action + "&id=" + PageState.Page.PageId.ToString();
|
||||
url = EditUrl("admin/pages", pagemanagementmoduleid, action, "id=" + PageState.Page.PageId.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,12 @@
|
||||
@code {
|
||||
private void LoginUser()
|
||||
{
|
||||
UriHelper.NavigateTo(NavigateUrl("login?returnurl=" + PageState.Page.Path));
|
||||
string returnurl = PageState.Alias.Path;
|
||||
if (PageState.Page.Path != "/")
|
||||
{
|
||||
returnurl += "/" + PageState.Page.Path;
|
||||
}
|
||||
UriHelper.NavigateTo("login?returnurl=" + returnurl);
|
||||
}
|
||||
|
||||
private async Task LogoutUser()
|
||||
@ -38,13 +43,16 @@
|
||||
{
|
||||
// server-side Blazor
|
||||
var interop = new Interop(jsRuntime);
|
||||
await interop.SubmitForm("/logout/", "");
|
||||
string antiforgerytoken = await interop.GetElementByName("__RequestVerificationToken");
|
||||
var fields = new { __RequestVerificationToken = antiforgerytoken, returnurl = (PageState.Alias.Path + "/" + PageState.Page.Path) };
|
||||
await interop.SubmitForm("/logout/", fields);
|
||||
}
|
||||
else
|
||||
{
|
||||
// client-side Blazor
|
||||
authstateprovider.NotifyAuthenticationChanged();
|
||||
UriHelper.NavigateTo(NavigateUrl("login", true));
|
||||
PageState.Reload = Constants.ReloadPage;
|
||||
UriHelper.NavigateTo(NavigateUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
@using Oqtane.Themes
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Shared
|
||||
@inherits ContainerBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject IUserService UserService
|
||||
@ -58,7 +59,7 @@
|
||||
pagemodule.Order = ModuleState.Order;
|
||||
pagemodule.ContainerType = ModuleState.ContainerType;
|
||||
|
||||
string path = PageState.Page.Path + "?reload=true";
|
||||
string url = NavigateUrl();
|
||||
switch (action)
|
||||
{
|
||||
case "up":
|
||||
@ -70,8 +71,7 @@
|
||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||
break;
|
||||
case "settings":
|
||||
if (path == "") { path += "/"; }
|
||||
path = PageState.Page.Path + "?mid=" + pagemodule.ModuleId.ToString() + "&ctl=Settings";
|
||||
url = EditUrl(pagemodule.ModuleId, "Settings");
|
||||
break;
|
||||
case "delete":
|
||||
await PageModuleService.DeletePageModuleAsync(pagemodule.PageModuleId);
|
||||
@ -81,7 +81,8 @@
|
||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||
break;
|
||||
}
|
||||
UriHelper.NavigateTo(NavigateUrl(path));
|
||||
PageState.Reload = Constants.ReloadPage;
|
||||
UriHelper.NavigateTo(url);
|
||||
}
|
||||
|
||||
public class ActionViewModel
|
||||
|
@ -12,22 +12,12 @@ namespace Oqtane.Themes
|
||||
|
||||
public string NavigateUrl()
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState);
|
||||
}
|
||||
|
||||
public string NavigateUrl(bool reload)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState, reload);
|
||||
return NavigateUrl(PageState.Page.Path);
|
||||
}
|
||||
|
||||
public string NavigateUrl(string path)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState, path);
|
||||
}
|
||||
|
||||
public string NavigateUrl(string path, bool reload)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState, path, reload);
|
||||
return Utilities.NavigateUrl(PageState.Alias.Path, path);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,22 +10,27 @@ namespace Oqtane.Themes
|
||||
|
||||
public string NavigateUrl()
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState);
|
||||
}
|
||||
|
||||
public string NavigateUrl(bool reload)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState, reload);
|
||||
return NavigateUrl(PageState.Page.Path);
|
||||
}
|
||||
|
||||
public string NavigateUrl(string path)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState, path);
|
||||
return Utilities.NavigateUrl(PageState.Alias.Path, path);
|
||||
}
|
||||
|
||||
public string NavigateUrl(string path, bool reload)
|
||||
public string EditUrl(int moduleid, string action)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState, path, reload);
|
||||
return EditUrl(moduleid, action, "");
|
||||
}
|
||||
|
||||
public string EditUrl(int moduleid, string action, string parameters)
|
||||
{
|
||||
return EditUrl(PageState.Page.Path, moduleid, action, parameters);
|
||||
}
|
||||
|
||||
public string EditUrl(string path, int moduleid, string action, string parameters)
|
||||
{
|
||||
return Utilities.EditUrl(PageState.Alias.Path, path, moduleid, action, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user