Merge pull request #48 from sbwalker/master
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:
commit
4969838a15
|
@ -73,7 +73,8 @@ private async Task Login()
|
||||||
{
|
{
|
||||||
// client-side Blazor
|
// client-side Blazor
|
||||||
authstateprovider.NotifyAuthenticationChanged();
|
authstateprovider.NotifyAuthenticationChanged();
|
||||||
UriHelper.NavigateTo(NavigateUrl(ReturnUrl, true));
|
PageState.Reload = Constants.ReloadPage;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl(ReturnUrl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -85,6 +86,6 @@ private async Task Login()
|
||||||
private void Cancel()
|
private void Cancel()
|
||||||
{
|
{
|
||||||
string ReturnUrl = PageState.QueryString["returnurl"];
|
string ReturnUrl = PageState.QueryString["returnurl"];
|
||||||
UriHelper.NavigateTo(NavigateUrl(ReturnUrl));
|
UriHelper.NavigateTo(ReturnUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@
|
||||||
pagemodule.ContainerType = containertype;
|
pagemodule.ContainerType = containertype;
|
||||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
|
|
||||||
UriHelper.NavigateTo(NavigateUrl(true));
|
PageState.Reload = Constants.ReloadPage;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,6 +170,7 @@
|
||||||
p.ViewPermissions = viewpermissions;
|
p.ViewPermissions = viewpermissions;
|
||||||
p.EditPermissions = editpermissions;
|
p.EditPermissions = editpermissions;
|
||||||
await PageService.AddPageAsync(p);
|
await PageService.AddPageAsync(p);
|
||||||
UriHelper.NavigateTo(NavigateUrl(path, true));
|
PageState.Reload = Constants.ReloadSite;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl(path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,7 @@
|
||||||
private async Task DeletePage()
|
private async Task DeletePage()
|
||||||
{
|
{
|
||||||
await PageService.DeletePageAsync(Int32.Parse(PageState.QueryString["id"]));
|
await PageService.DeletePageAsync(Int32.Parse(PageState.QueryString["id"]));
|
||||||
UriHelper.NavigateTo(NavigateUrl("", true));
|
PageState.Reload = Constants.ReloadSite;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,24 +16,29 @@
|
||||||
<input type="password" name="Password" class="form-control" placeholder="Password" @bind="@Password" />
|
<input type="password" name="Password" class="form-control" placeholder="Password" @bind="@Password" />
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="btn btn-primary" @onclick="@RegisterUser">Register</button>
|
<button type="button" class="btn btn-primary" @onclick="@RegisterUser">Register</button>
|
||||||
<NavLink class="btn btn-secondary" href="/">Cancel</NavLink>
|
<button type="button" class="btn btn-secondary" @onclick="@Cancel">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Anonymous; } }
|
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Anonymous; } }
|
||||||
|
|
||||||
public string Username { get; set; } = "";
|
public string Username { get; set; } = "";
|
||||||
public string Password { get; set; } = "";
|
public string Password { get; set; } = "";
|
||||||
|
|
||||||
private async Task RegisterUser()
|
private async Task RegisterUser()
|
||||||
{
|
{
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.Username = Username;
|
user.Username = Username;
|
||||||
user.DisplayName = Username;
|
user.DisplayName = Username;
|
||||||
user.Roles = "Administrators;";
|
user.Roles = "Administrators;";
|
||||||
user.IsSuperUser = false;
|
user.IsSuperUser = false;
|
||||||
user.Password = Password;
|
user.Password = Password;
|
||||||
await UserService.AddUserAsync(user);
|
await UserService.AddUserAsync(user);
|
||||||
UriHelper.NavigateTo("");
|
UriHelper.NavigateTo("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Cancel()
|
||||||
|
{
|
||||||
|
UriHelper.NavigateTo(NavigateUrl("")); // navigate to home
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
htmltext.Content = content;
|
htmltext.Content = content;
|
||||||
await htmltextservice.AddHtmlTextAsync(htmltext);
|
await htmltextservice.AddHtmlTextAsync(htmltext);
|
||||||
}
|
}
|
||||||
UriHelper.NavigateTo(NavigateUrl(true));
|
PageState.Reload = Constants.ReloadPage;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,32 +20,37 @@ namespace Oqtane.Modules
|
||||||
|
|
||||||
public string NavigateUrl()
|
public string NavigateUrl()
|
||||||
{
|
{
|
||||||
return Utilities.NavigateUrl(PageState);
|
return NavigateUrl(PageState.Page.Path);
|
||||||
}
|
|
||||||
|
|
||||||
public string NavigateUrl(bool reload)
|
|
||||||
{
|
|
||||||
return Utilities.NavigateUrl(PageState, reload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string NavigateUrl(string 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)
|
|
||||||
{
|
|
||||||
return Utilities.NavigateUrl(PageState, path, reload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string EditUrl(string action)
|
public string EditUrl(string action)
|
||||||
{
|
{
|
||||||
return Utilities.EditUrl(PageState, ModuleState, action, "");
|
return EditUrl(ModuleState.ModuleId, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string EditUrl(string action, string parameters)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Oqtane.Services
|
||||||
|
|
||||||
private string apiurl
|
private string apiurl
|
||||||
{
|
{
|
||||||
get { return CreateApiUrl(sitestate.Alias, "PageModule", urihelper.GetAbsoluteUri()); }
|
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "PageModule"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<PageModule>> GetPageModulesAsync()
|
public async Task<List<PageModule>> GetPageModulesAsync()
|
||||||
|
|
|
@ -13,5 +13,9 @@
|
||||||
|
|
||||||
public const string AllUsersRole = "All Users";
|
public const string AllUsersRole = "All Users";
|
||||||
public const string AdminRole = "Administrators";
|
public const string AdminRole = "Administrators";
|
||||||
|
|
||||||
|
public const int ReloadApplication = 3;
|
||||||
|
public const int ReloadSite = 2;
|
||||||
|
public const int ReloadPage = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,26 +21,32 @@
|
||||||
{
|
{
|
||||||
DynamicComponent = builder =>
|
DynamicComponent = builder =>
|
||||||
{
|
{
|
||||||
Type containerType = Type.GetType(container);
|
if (ModuleState != null)
|
||||||
if (containerType != null)
|
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, containerType);
|
Type containerType = Type.GetType(container);
|
||||||
builder.CloseComponent();
|
if (containerType != null)
|
||||||
}
|
{
|
||||||
else
|
builder.OpenComponent(ModuleState.ModuleId, containerType); // set sequence to moduleid so that component tree is able to differentiate
|
||||||
{
|
builder.CloseComponent();
|
||||||
// container does not exist with type specified
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// container does not exist with type specified
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Task OnParametersSetAsync()
|
protected override Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
ModuleState = Module; // passed in from Pane component
|
if (PageState.Page.PageId == Module.PageId)
|
||||||
container = ModuleState.ContainerType;
|
|
||||||
if (PageState.ModuleId != -1 && PageState.Control != "")
|
|
||||||
{
|
{
|
||||||
container = Constants.DefaultAdminContainer;
|
ModuleState = Module; // passed in from Pane component
|
||||||
|
container = ModuleState.ContainerType;
|
||||||
|
if (PageState.ModuleId != -1 && PageState.Control != "")
|
||||||
|
{
|
||||||
|
container = Constants.DefaultAdminContainer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
Type moduleType = Type.GetType(typename);
|
Type moduleType = Type.GetType(typename);
|
||||||
if (moduleType != null)
|
if (moduleType != null)
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, moduleType);
|
builder.OpenComponent(ModuleState.ModuleId, moduleType); // set sequence to moduleid so that component tree is able to differentiate
|
||||||
builder.CloseComponent();
|
builder.CloseComponent();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -19,5 +19,6 @@ namespace Oqtane.Shared
|
||||||
public Dictionary<string, string> QueryString { get; set; }
|
public Dictionary<string, string> QueryString { get; set; }
|
||||||
public int ModuleId { get; set; }
|
public int ModuleId { get; set; }
|
||||||
public string Control { get; set; }
|
public string Control { get; set; }
|
||||||
|
public int Reload { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
DynamicComponent = builder =>
|
DynamicComponent = builder =>
|
||||||
{
|
{
|
||||||
if (pagestate != null)
|
if (PageState != null)
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, Type.GetType(Constants.DefaultPage));
|
builder.OpenComponent(0, Type.GetType(Constants.DefaultPage));
|
||||||
builder.CloseComponent();
|
builder.CloseComponent();
|
||||||
|
@ -75,38 +75,54 @@
|
||||||
List<Module> modules;
|
List<Module> modules;
|
||||||
int moduleid = -1;
|
int moduleid = -1;
|
||||||
string control = "";
|
string control = "";
|
||||||
|
int reload = 0;
|
||||||
|
|
||||||
bool reload = false;
|
if (PageState != null)
|
||||||
if (PageState == null)
|
|
||||||
{
|
{
|
||||||
|
reload = PageState.Reload;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PageState == null || reload == Constants.ReloadApplication)
|
||||||
|
{
|
||||||
|
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync();
|
||||||
|
themes = await ThemeService.GetThemesAsync();
|
||||||
aliases = await AliasService.GetAliasesAsync();
|
aliases = await AliasService.GetAliasesAsync();
|
||||||
alias = null;
|
alias = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
moduledefinitions = PageState.ModuleDefinitions;
|
||||||
|
themes = PageState.Themes;
|
||||||
aliases = PageState.Aliases;
|
aliases = PageState.Aliases;
|
||||||
alias = PageState.Alias;
|
alias = PageState.Alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if site has changed
|
||||||
if (alias == null || GetAlias(_absoluteUri, aliases).Name != alias.Name)
|
if (alias == null || GetAlias(_absoluteUri, aliases).Name != alias.Name)
|
||||||
{
|
{
|
||||||
alias = GetAlias(_absoluteUri, aliases);
|
alias = GetAlias(_absoluteUri, aliases);
|
||||||
SiteState.Alias = alias; // set state for services
|
SiteState.Alias = alias; // set state for services
|
||||||
reload = true;
|
reload = Constants.ReloadSite;
|
||||||
}
|
}
|
||||||
if (PageState == null || reload == true)
|
if (PageState == null || reload <= Constants.ReloadSite)
|
||||||
{
|
{
|
||||||
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync();
|
|
||||||
themes = await ThemeService.GetThemesAsync();
|
|
||||||
site = await SiteService.GetSiteAsync(alias.SiteId);
|
site = await SiteService.GetSiteAsync(alias.SiteId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
moduledefinitions = PageState.ModuleDefinitions;
|
|
||||||
themes = PageState.Themes;
|
|
||||||
site = PageState.Site;
|
site = PageState.Site;
|
||||||
}
|
}
|
||||||
if (site != null || reload == true)
|
if (site != null)
|
||||||
{
|
{
|
||||||
|
if (PageState == null || reload >= Constants.ReloadSite)
|
||||||
|
{
|
||||||
|
pages = await PageService.GetPagesAsync(site.SiteId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pages = PageState.Pages;
|
||||||
|
}
|
||||||
|
|
||||||
// get Url path and querystring
|
// get Url path and querystring
|
||||||
string path = new Uri(_absoluteUri).PathAndQuery.Substring(1);
|
string path = new Uri(_absoluteUri).PathAndQuery.Substring(1);
|
||||||
|
|
||||||
|
@ -148,13 +164,23 @@
|
||||||
// remove trailing slash so it can be used as a key for Pages
|
// remove trailing slash so it can be used as a key for Pages
|
||||||
if (path.EndsWith("/")) path = path.Substring(0, path.Length - 1);
|
if (path.EndsWith("/")) path = path.Substring(0, path.Length - 1);
|
||||||
|
|
||||||
if (querystring.ContainsKey("reload"))
|
if (PageState == null || reload >= Constants.ReloadPage)
|
||||||
{
|
{
|
||||||
reload = true;
|
page = pages.Where(item => item.Path == path).FirstOrDefault();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
page = PageState.Page;
|
||||||
|
}
|
||||||
|
// check if page has changed
|
||||||
|
if (page.Path != path)
|
||||||
|
{
|
||||||
|
page = pages.Where(item => item.Path == path).FirstOrDefault();
|
||||||
|
reload = Constants.ReloadPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
user = null;
|
user = null;
|
||||||
if (PageState == null || reload == true)
|
if (PageState == null || reload >= Constants.ReloadPage)
|
||||||
{
|
{
|
||||||
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||||
if (authState.User.Identity.IsAuthenticated)
|
if (authState.User.Identity.IsAuthenticated)
|
||||||
|
@ -167,29 +193,6 @@
|
||||||
user = PageState.User;
|
user = PageState.User;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageState == null || reload == true)
|
|
||||||
{
|
|
||||||
pages = await PageService.GetPagesAsync(site.SiteId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pages = PageState.Pages;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PageState == null || reload == true)
|
|
||||||
{
|
|
||||||
page = pages.Where(item => item.Path == path).FirstOrDefault();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
page = PageState.Page;
|
|
||||||
}
|
|
||||||
if (page.Path != path)
|
|
||||||
{
|
|
||||||
page = pages.Where(item => item.Path == path).FirstOrDefault();
|
|
||||||
reload = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (page != null)
|
if (page != null)
|
||||||
{
|
{
|
||||||
// check if user is authorized to view page
|
// check if user is authorized to view page
|
||||||
|
@ -211,10 +214,10 @@
|
||||||
|
|
||||||
if (PageState != null && (PageState.ModuleId != pagestate.ModuleId || PageState.Control != pagestate.Control))
|
if (PageState != null && (PageState.ModuleId != pagestate.ModuleId || PageState.Control != pagestate.Control))
|
||||||
{
|
{
|
||||||
reload = true;
|
reload = Constants.ReloadPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageState == null || reload == true)
|
if (PageState == null || reload >= Constants.ReloadPage)
|
||||||
{
|
{
|
||||||
modules = await ModuleService.GetModulesAsync(page.PageId);
|
modules = await ModuleService.GetModulesAsync(page.PageId);
|
||||||
modules = ProcessModules(modules, moduledefinitions, pagestate.Control, page.Panes);
|
modules = ProcessModules(modules, moduledefinitions, pagestate.Control, page.Panes);
|
||||||
|
@ -224,6 +227,7 @@
|
||||||
modules = PageState.Modules;
|
modules = PageState.Modules;
|
||||||
}
|
}
|
||||||
pagestate.Modules = modules;
|
pagestate.Modules = modules;
|
||||||
|
pagestate.Reload = 0;
|
||||||
|
|
||||||
OnStateChange?.Invoke(pagestate);
|
OnStateChange?.Invoke(pagestate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,52 +5,37 @@ namespace Oqtane.Shared
|
||||||
{
|
{
|
||||||
public class Utilities
|
public class Utilities
|
||||||
{
|
{
|
||||||
public static string NavigateUrl(PageState pagestate)
|
|
||||||
{
|
|
||||||
return NavigateUrl(pagestate, pagestate.Page.Path, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string NavigateUrl(PageState pagestate, bool reload)
|
public static string NavigateUrl(string alias, string path)
|
||||||
{
|
{
|
||||||
return NavigateUrl(pagestate, pagestate.Page.Path, reload);
|
string url = "";
|
||||||
}
|
if (alias != "")
|
||||||
|
|
||||||
public static string NavigateUrl(PageState pagestate, string path)
|
|
||||||
{
|
|
||||||
return NavigateUrl(pagestate, path, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string NavigateUrl(PageState pagestate, string path, bool reload)
|
|
||||||
{
|
|
||||||
string url = pagestate.Alias.Path + "/" + path;
|
|
||||||
if (reload)
|
|
||||||
{
|
{
|
||||||
if (url.Contains("?"))
|
url += alias + "/";
|
||||||
{
|
}
|
||||||
url += "&reload=true";
|
if (path != "")
|
||||||
}
|
{
|
||||||
else
|
url += path + "/";
|
||||||
{
|
}
|
||||||
url += "?reload=true";
|
if (!url.StartsWith("/"))
|
||||||
}
|
{
|
||||||
|
url = "/" + url;
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string EditUrl(PageState pagestate, Module modulestate, string action)
|
public static string EditUrl(string alias, string path, int moduleid, string action, string parameters)
|
||||||
{
|
{
|
||||||
return EditUrl(pagestate, modulestate, action, "");
|
string url = NavigateUrl(alias, path);
|
||||||
}
|
if ( url == "/" )
|
||||||
|
|
||||||
public static string EditUrl(PageState pagestate, Module modulestate, string action, string parameters)
|
|
||||||
{
|
|
||||||
string url = pagestate.Alias.Path;
|
|
||||||
if (pagestate.Page.Path != "")
|
|
||||||
{
|
{
|
||||||
url += "/" + pagestate.Page.Path;
|
url = "";
|
||||||
}
|
}
|
||||||
url += "/" + modulestate.ModuleId.ToString();
|
if (moduleid != -1)
|
||||||
if (action != "")
|
{
|
||||||
|
url += "/" + moduleid.ToString();
|
||||||
|
}
|
||||||
|
if (moduleid != -1 && action != "")
|
||||||
{
|
{
|
||||||
url += "/" + action;
|
url += "/" + action;
|
||||||
}
|
}
|
||||||
|
@ -58,6 +43,10 @@ namespace Oqtane.Shared
|
||||||
{
|
{
|
||||||
url += "?" + parameters;
|
url += "?" + parameters;
|
||||||
}
|
}
|
||||||
|
if (!url.StartsWith("/"))
|
||||||
|
{
|
||||||
|
url = "/" + url;
|
||||||
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,32 +16,38 @@ namespace Oqtane.Themes
|
||||||
|
|
||||||
public string NavigateUrl()
|
public string NavigateUrl()
|
||||||
{
|
{
|
||||||
return Utilities.NavigateUrl(PageState);
|
return NavigateUrl(PageState.Page.Path);
|
||||||
}
|
|
||||||
|
|
||||||
public string NavigateUrl(bool reload)
|
|
||||||
{
|
|
||||||
return Utilities.NavigateUrl(PageState, reload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string NavigateUrl(string 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)
|
|
||||||
{
|
|
||||||
return Utilities.NavigateUrl(PageState, path, reload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string EditUrl(string action)
|
public string EditUrl(string action)
|
||||||
{
|
{
|
||||||
return Utilities.EditUrl(PageState, ModuleState, action, "");
|
return EditUrl(ModuleState.ModuleId, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string EditUrl(string action, string parameters)
|
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.Order = 0;
|
||||||
pagemodule.ContainerType = containertype;
|
pagemodule.ContainerType = containertype;
|
||||||
await PageModuleService.AddPageModuleAsync(pagemodule);
|
await PageModuleService.AddPageModuleAsync(pagemodule);
|
||||||
UriHelper.NavigateTo(NavigateUrl(true));
|
|
||||||
|
PageState.Reload = Constants.ReloadPage;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
private string PageUrl(string action)
|
private string PageUrl(string action)
|
||||||
|
@ -130,13 +132,13 @@
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case "Add":
|
case "Add":
|
||||||
url = "admin/pages?mid=" + pagemanagementmoduleid.ToString() + "&ctl=" + action;
|
url = EditUrl("admin/pages", pagemanagementmoduleid, action, "");
|
||||||
break;
|
break;
|
||||||
case "Edit":
|
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;
|
break;
|
||||||
case "Delete":
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,12 @@
|
||||||
@code {
|
@code {
|
||||||
private void LoginUser()
|
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()
|
private async Task LogoutUser()
|
||||||
|
@ -38,13 +43,16 @@
|
||||||
{
|
{
|
||||||
// server-side Blazor
|
// server-side Blazor
|
||||||
var interop = new Interop(jsRuntime);
|
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
|
else
|
||||||
{
|
{
|
||||||
// client-side Blazor
|
// client-side Blazor
|
||||||
authstateprovider.NotifyAuthenticationChanged();
|
authstateprovider.NotifyAuthenticationChanged();
|
||||||
UriHelper.NavigateTo(NavigateUrl("login", true));
|
PageState.Reload = Constants.ReloadPage;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
@using Oqtane.Themes
|
@using Oqtane.Themes
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
|
@using Oqtane.Shared
|
||||||
@inherits ContainerBase
|
@inherits ContainerBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
@ -58,7 +59,7 @@
|
||||||
pagemodule.Order = ModuleState.Order;
|
pagemodule.Order = ModuleState.Order;
|
||||||
pagemodule.ContainerType = ModuleState.ContainerType;
|
pagemodule.ContainerType = ModuleState.ContainerType;
|
||||||
|
|
||||||
string path = PageState.Page.Path + "?reload=true";
|
string url = NavigateUrl();
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case "up":
|
case "up":
|
||||||
|
@ -70,8 +71,7 @@
|
||||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
break;
|
break;
|
||||||
case "settings":
|
case "settings":
|
||||||
if (path == "") { path += "/"; }
|
url = EditUrl(pagemodule.ModuleId, "Settings");
|
||||||
path = PageState.Page.Path + "?mid=" + pagemodule.ModuleId.ToString() + "&ctl=Settings";
|
|
||||||
break;
|
break;
|
||||||
case "delete":
|
case "delete":
|
||||||
await PageModuleService.DeletePageModuleAsync(pagemodule.PageModuleId);
|
await PageModuleService.DeletePageModuleAsync(pagemodule.PageModuleId);
|
||||||
|
@ -81,7 +81,8 @@
|
||||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
UriHelper.NavigateTo(NavigateUrl(path));
|
PageState.Reload = Constants.ReloadPage;
|
||||||
|
UriHelper.NavigateTo(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ActionViewModel
|
public class ActionViewModel
|
||||||
|
|
|
@ -12,22 +12,12 @@ namespace Oqtane.Themes
|
||||||
|
|
||||||
public string NavigateUrl()
|
public string NavigateUrl()
|
||||||
{
|
{
|
||||||
return Utilities.NavigateUrl(PageState);
|
return NavigateUrl(PageState.Page.Path);
|
||||||
}
|
|
||||||
|
|
||||||
public string NavigateUrl(bool reload)
|
|
||||||
{
|
|
||||||
return Utilities.NavigateUrl(PageState, reload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string NavigateUrl(string 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)
|
|
||||||
{
|
|
||||||
return Utilities.NavigateUrl(PageState, path, reload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,22 +10,27 @@ namespace Oqtane.Themes
|
||||||
|
|
||||||
public string NavigateUrl()
|
public string NavigateUrl()
|
||||||
{
|
{
|
||||||
return Utilities.NavigateUrl(PageState);
|
return NavigateUrl(PageState.Page.Path);
|
||||||
}
|
|
||||||
|
|
||||||
public string NavigateUrl(bool reload)
|
|
||||||
{
|
|
||||||
return Utilities.NavigateUrl(PageState, reload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string NavigateUrl(string 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,12 @@ namespace Oqtane.Pages
|
||||||
await HttpContext.SignInAsync(IdentityConstants.ApplicationScheme, new ClaimsPrincipal(claimsIdentity), authProperties);
|
await HttpContext.SignInAsync(IdentityConstants.ApplicationScheme, new ClaimsPrincipal(claimsIdentity), authProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
return LocalRedirect(Url.Content("~/" + returnurl));
|
string url = "~/";
|
||||||
|
if (returnurl != "/")
|
||||||
|
{
|
||||||
|
url = Url.Content("~/" + returnurl);
|
||||||
|
}
|
||||||
|
return LocalRedirect(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,15 +12,19 @@ using Oqtane.Models;
|
||||||
|
|
||||||
namespace Oqtane.Pages
|
namespace Oqtane.Pages
|
||||||
{
|
{
|
||||||
[IgnoreAntiforgeryToken(Order = 1001)]
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public class LogoutModel : PageModel
|
public class LogoutModel : PageModel
|
||||||
{
|
{
|
||||||
public async Task<IActionResult> OnPostAsync()
|
public async Task<IActionResult> OnPostAsync(string returnurl)
|
||||||
{
|
{
|
||||||
await HttpContext.SignOutAsync(IdentityConstants.ApplicationScheme);
|
await HttpContext.SignOutAsync(IdentityConstants.ApplicationScheme);
|
||||||
|
|
||||||
return LocalRedirect(Url.Content("~/"));
|
string url = "~/";
|
||||||
|
if (returnurl != "/")
|
||||||
|
{
|
||||||
|
url = Url.Content("~/" + returnurl);
|
||||||
|
}
|
||||||
|
return LocalRedirect(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -183,6 +183,12 @@ GO
|
||||||
INSERT [dbo].[Page] ([PageId], [SiteId], [Name], [Path], [ThemeType], [Icon], [Panes], [ViewPermissions], [EditPermissions], [ParentId], [Order], [IsNavigation], [LayoutType])
|
INSERT [dbo].[Page] ([PageId], [SiteId], [Name], [Path], [ThemeType], [Icon], [Panes], [ViewPermissions], [EditPermissions], [ParentId], [Order], [IsNavigation], [LayoutType])
|
||||||
VALUES (13, 2, N'Page2', N'page2', N'Oqtane.Client.Themes.Theme2.Theme2, Oqtane.Client', N'oi-home', N'Top;Bottom', N'All Users', N'Administrators', NULL, 1, 1, N'')
|
VALUES (13, 2, N'Page2', N'page2', N'Oqtane.Client.Themes.Theme2.Theme2, Oqtane.Client', N'oi-home', N'Top;Bottom', N'All Users', N'Administrators', NULL, 1, 1, N'')
|
||||||
GO
|
GO
|
||||||
|
INSERT [dbo].[Page] ([PageId], [SiteId], [Name], [Path], [ThemeType], [Icon], [Panes], [ViewPermissions], [EditPermissions], [ParentId], [Order], [IsNavigation], [LayoutType])
|
||||||
|
VALUES (14, 2, N'Login', N'login', N'Oqtane.Client.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', N'All Users', N'Administrators', NULL, 1, 0, N'')
|
||||||
|
GO
|
||||||
|
INSERT [dbo].[Page] ([PageId], [SiteId], [Name], [Path], [ThemeType], [Icon], [Panes], [ViewPermissions], [EditPermissions], [ParentId], [Order], [IsNavigation], [LayoutType])
|
||||||
|
VALUES (15, 2, N'Register', N'register', N'Oqtane.Client.Themes.Theme2.Theme2, Oqtane.Client', N'', N'Top;Bottom', N'All Users', N'Administrators', NULL, 1, 0, N'')
|
||||||
|
GO
|
||||||
SET IDENTITY_INSERT [dbo].[Page] OFF
|
SET IDENTITY_INSERT [dbo].[Page] OFF
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
@ -239,6 +245,12 @@ GO
|
||||||
INSERT [dbo].[Module] ([ModuleId], [SiteId], [ModuleDefinitionName], [ViewPermissions], [EditPermissions])
|
INSERT [dbo].[Module] ([ModuleId], [SiteId], [ModuleDefinitionName], [ViewPermissions], [EditPermissions])
|
||||||
VALUES (17, 2, N'Oqtane.Client.Modules.HtmlText, Oqtane.Client', N'All Users', N'Administrators')
|
VALUES (17, 2, N'Oqtane.Client.Modules.HtmlText, Oqtane.Client', N'All Users', N'Administrators')
|
||||||
GO
|
GO
|
||||||
|
INSERT [dbo].[Module] ([ModuleId], [SiteId], [ModuleDefinitionName], [ViewPermissions], [EditPermissions])
|
||||||
|
VALUES (18, 2, N'Oqtane.Client.Modules.Admin.Login, Oqtane.Client', N'All Users', N'Administrators')
|
||||||
|
GO
|
||||||
|
INSERT [dbo].[Module] ([ModuleId], [SiteId], [ModuleDefinitionName], [ViewPermissions], [EditPermissions])
|
||||||
|
VALUES (19, 2, N'Oqtane.Client.Modules.Admin.Register, Oqtane.Client', N'All Users', N'Administrators')
|
||||||
|
GO
|
||||||
SET IDENTITY_INSERT [dbo].[Module] OFF
|
SET IDENTITY_INSERT [dbo].[Module] OFF
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
@ -295,6 +307,12 @@ GO
|
||||||
INSERT [dbo].[PageModule] ([PageModuleId], [PageId], [ModuleId], [Title], [Pane], [Order], [ContainerType])
|
INSERT [dbo].[PageModule] ([PageModuleId], [PageId], [ModuleId], [Title], [Pane], [Order], [ContainerType])
|
||||||
VALUES (17, 13, 17, N'Text', N'Top', 1, N'Oqtane.Client.Themes.Theme2.Container2, Oqtane.Client')
|
VALUES (17, 13, 17, N'Text', N'Top', 1, N'Oqtane.Client.Themes.Theme2.Container2, Oqtane.Client')
|
||||||
GO
|
GO
|
||||||
|
INSERT [dbo].[PageModule] ([PageModuleId], [PageId], [ModuleId], [Title], [Pane], [Order], [ContainerType])
|
||||||
|
VALUES (18, 14, 18, N'Login', N'Top', 0, N'Oqtane.Client.Themes.Theme2.Container2, Oqtane.Client')
|
||||||
|
GO
|
||||||
|
INSERT [dbo].[PageModule] ([PageModuleId], [PageId], [ModuleId], [Title], [Pane], [Order], [ContainerType])
|
||||||
|
VALUES (19, 15, 19, N'Register', N'Top', 0, N'Oqtane.Client.Themes.Theme2.Container2, Oqtane.Client')
|
||||||
|
GO
|
||||||
SET IDENTITY_INSERT [dbo].[PageModule] OFF
|
SET IDENTITY_INSERT [dbo].[PageModule] OFF
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user