Merge pull request #2863 from sbwalker/dev
improvements for personalized pages
This commit is contained in:
@ -23,14 +23,6 @@ namespace Oqtane.Services
|
||||
/// <returns></returns>
|
||||
Task<Page> GetPageAsync(int pageId);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a specific page personalized for the given user
|
||||
/// </summary>
|
||||
/// <param name="pageId"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<Page> GetPageAsync(int pageId, int userId);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a specific page by its defined path
|
||||
/// </summary>
|
||||
|
@ -25,11 +25,6 @@ namespace Oqtane.Services
|
||||
return await GetJsonAsync<Page>($"{Apiurl}/{pageId}");
|
||||
}
|
||||
|
||||
public async Task<Page> GetPageAsync(int pageId, int userId)
|
||||
{
|
||||
return await GetJsonAsync<Page>($"{Apiurl}/{pageId}?userid={userId}");
|
||||
}
|
||||
|
||||
public async Task<Page> GetPageAsync(string path, int siteId)
|
||||
{
|
||||
try
|
||||
|
@ -489,9 +489,9 @@
|
||||
{
|
||||
if (PageState.Page.IsPersonalizable && PageState.User != null)
|
||||
{
|
||||
await PageService.AddPageAsync(PageState.Page.PageId, PageState.User.UserId);
|
||||
var page = await PageService.AddPageAsync(PageState.Page.PageId, PageState.User.UserId);
|
||||
PageState.EditMode = true;
|
||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Page.Path, "edit=" + ((PageState.EditMode) ? "true" : "false")));
|
||||
NavigationManager.NavigateTo(NavigateUrl(page.Path, "edit=" + ((PageState.EditMode) ? "true" : "false")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -221,6 +221,23 @@
|
||||
page = site.Pages.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
if (page == null)
|
||||
{
|
||||
// look for personalized page
|
||||
page = await PageService.GetPageAsync(route.PagePath, site.SiteId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user != null && page.IsPersonalizable)
|
||||
{
|
||||
page = await PageService.GetPageAsync(route.PagePath + "/" + user.Username, site.SiteId);
|
||||
if (page != null)
|
||||
{
|
||||
// redirect to the personalized page
|
||||
NavigationManager.NavigateTo(Utilities.NavigateUrl(SiteState.Alias.Path, route.PagePath + "/" + user.Username, ""), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (page != null)
|
||||
{
|
||||
@ -228,7 +245,7 @@
|
||||
if (UserSecurity.IsAuthorized(user, PermissionNames.View, page.PermissionList))
|
||||
{
|
||||
// load additional metadata for current page
|
||||
page = await ProcessPage(page, site, user, SiteState.Alias);
|
||||
page = ProcessPage(page, site, user, SiteState.Alias);
|
||||
|
||||
// load additional metadata for modules
|
||||
(page, site.Modules) = ProcessModules(page, site.Modules, moduleid, action, (!string.IsNullOrEmpty(page.DefaultContainerType)) ? page.DefaultContainerType : site.DefaultContainerType, SiteState.Alias);
|
||||
@ -297,16 +314,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<Page> ProcessPage(Page page, Site site, User user, Alias alias)
|
||||
private Page ProcessPage(Page page, Site site, User user, Alias alias)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (page.IsPersonalizable && user != null)
|
||||
{
|
||||
// load the personalized page
|
||||
page = await PageService.GetPageAsync(page.PageId, user.UserId);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(page.ThemeType))
|
||||
{
|
||||
page.ThemeType = site.DefaultThemeType;
|
||||
|
Reference in New Issue
Block a user