Support for user personalizable pages
This commit is contained in:
@ -4,130 +4,141 @@
|
||||
@inject IPageService PageService
|
||||
@inject IThemeService ThemeService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Path: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@path" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Parent: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @onchange="(e => ParentChanged(e))">
|
||||
<option value="-1"><Site Root></option>
|
||||
@foreach (Page page in pages)
|
||||
{
|
||||
<option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Insert: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@insert">
|
||||
<option value="<<">At Beginning</option>
|
||||
@if (children != null && children.Count > 0)
|
||||
{
|
||||
<option value="<">Before</option>
|
||||
<option value=">">After</option>
|
||||
}
|
||||
<option value=">>">At End</option>
|
||||
</select>
|
||||
@if (children != null && children.Count > 0 && (insert == "<" || insert == ">"))
|
||||
{
|
||||
<select class="form-control" @bind="@childid">
|
||||
<option value="-1"><Select Page></option>
|
||||
@foreach (Page page in children)
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Path: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@path" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Parent: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @onchange="(e => ParentChanged(e))">
|
||||
<option value="-1"><Site Root></option>
|
||||
@foreach (Page page in pages)
|
||||
{
|
||||
<option value="@(page.PageId)">@(page.Name)</option>
|
||||
<option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||
}
|
||||
</select>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Navigation? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isnavigation">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Default Mode? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@mode">
|
||||
<option value="view">View Mode</option>
|
||||
<option value="edit">Edit Mode</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Theme: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @onchange="(e => ThemeChanged(e))">
|
||||
<option value=""><Select Theme></option>
|
||||
@foreach (KeyValuePair<string, string> item in themes)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Insert: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@insert">
|
||||
<option value="<<">At Beginning</option>
|
||||
@if (children != null && children.Count > 0)
|
||||
{
|
||||
<option value="<">Before</option>
|
||||
<option value=">">After</option>
|
||||
}
|
||||
<option value=">>">At End</option>
|
||||
</select>
|
||||
@if (children != null && children.Count > 0 && (insert == "<" || insert == ">"))
|
||||
{
|
||||
<option value="@item.Key">@item.Value</option>
|
||||
<select class="form-control" @bind="@childid">
|
||||
<option value="-1"><Select Page></option>
|
||||
@foreach (Page page in children)
|
||||
{
|
||||
<option value="@(page.PageId)">@(page.Name)</option>
|
||||
}
|
||||
</select>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Layout: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@layouttype">
|
||||
<option value=""><Select Layout></option>
|
||||
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
||||
{
|
||||
<option value="@panelayout.Key">@panelayout.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Icon: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@icon" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Navigation? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isnavigation">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Personalizable? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@ispersonalizable">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Default Mode? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@mode">
|
||||
<option value="view">View Mode</option>
|
||||
<option value="edit">Edit Mode</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Theme: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @onchange="(e => ThemeChanged(e))">
|
||||
<option value=""><Select Theme></option>
|
||||
@foreach (KeyValuePair<string, string> item in themes)
|
||||
{
|
||||
<option value="@item.Key">@item.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Layout: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@layouttype">
|
||||
<option value=""><Select Layout></option>
|
||||
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
||||
{
|
||||
<option value="@panelayout.Key">@panelayout.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Icon: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@icon" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="SavePage">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@ -145,6 +156,7 @@
|
||||
List<Page> children;
|
||||
int childid = -1;
|
||||
string isnavigation = "True";
|
||||
string ispersonalizable = "False";
|
||||
string mode = "view";
|
||||
string themetype = "";
|
||||
string layouttype = "";
|
||||
@ -291,9 +303,11 @@
|
||||
{
|
||||
page.LayoutType = "";
|
||||
}
|
||||
page.IsPersonalizable = (ispersonalizable == null ? false : Boolean.Parse(ispersonalizable));
|
||||
page.UserId = null;
|
||||
|
||||
await PageService.AddPageAsync(page);
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.ParentId);
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, page.ParentId);
|
||||
|
||||
await logger.LogInformation("Page Added {Page}", page);
|
||||
NavigationManager.NavigateTo(NavigateUrl(page.Path, Reload.Site));
|
||||
|
@ -4,148 +4,159 @@
|
||||
@inject IPageService PageService
|
||||
@inject IThemeService ThemeService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Path: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@path" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Parent: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @onchange="(e => ParentChanged(e))">
|
||||
<option value="-1"><Site Root></option>
|
||||
@foreach (Page page in pages)
|
||||
{
|
||||
if (page.PageId.ToString() == parentid)
|
||||
{
|
||||
<option value="@(page.PageId)" selected>@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||
}
|
||||
else
|
||||
{
|
||||
<option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Move : </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@insert">
|
||||
@if (parentid == currentparentid)
|
||||
{
|
||||
<option value="="><Maintain Current Location></option>
|
||||
}
|
||||
<option value="<<">To Beginning</option>
|
||||
@if (children != null && children.Count > 0)
|
||||
{
|
||||
<option value="<">Before</option>
|
||||
<option value=">">After</option>
|
||||
}
|
||||
<option value=">>">To End</option>
|
||||
</select>
|
||||
@if (children != null && children.Count > 0 && (insert == "<" || insert == ">"))
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Path: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@path" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Parent: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @onchange="(e => ParentChanged(e))">
|
||||
<option value="-1"><Site Root></option>
|
||||
@foreach (Page page in pages)
|
||||
{
|
||||
<select class="form-control" @bind="@childid">
|
||||
<option value="-1"><Select Page></option>
|
||||
@foreach (Page page in children)
|
||||
{
|
||||
<option value="@(page.PageId)">@(page.Name)</option>
|
||||
}
|
||||
</select>
|
||||
if (page.PageId.ToString() == parentid)
|
||||
{
|
||||
<option value="@(page.PageId)" selected>@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||
}
|
||||
else
|
||||
{
|
||||
<option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||
}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Navigation? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isnavigation">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Default Mode? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@mode">
|
||||
<option value="view">View Mode</option>
|
||||
<option value="edit">Edit Mode</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Theme: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @onchange="(e => ThemeChanged(e))">
|
||||
<option value=""><Select Theme></option>
|
||||
@foreach (KeyValuePair<string, string> item in themes)
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Move : </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@insert">
|
||||
@if (parentid == currentparentid)
|
||||
{
|
||||
<option value="="><Maintain Current Location></option>
|
||||
}
|
||||
<option value="<<">To Beginning</option>
|
||||
@if (children != null && children.Count > 0)
|
||||
{
|
||||
<option value="<">Before</option>
|
||||
<option value=">">After</option>
|
||||
}
|
||||
<option value=">>">To End</option>
|
||||
</select>
|
||||
@if (children != null && children.Count > 0 && (insert == "<" || insert == ">"))
|
||||
{
|
||||
<select class="form-control" @bind="@childid">
|
||||
<option value="-1"><Select Page></option>
|
||||
@foreach (Page page in children)
|
||||
{
|
||||
if (item.Key == themetype)
|
||||
{
|
||||
<option value="@item.Key" selected>@item.Value</option>
|
||||
}
|
||||
else
|
||||
{
|
||||
<option value="@item.Key">@item.Value</option>
|
||||
}
|
||||
<option value="@(page.PageId)">@(page.Name)</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Layout: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@layouttype">
|
||||
<option value=""><Select Layout></option>
|
||||
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Navigation? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isnavigation">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Personalizable? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@ispersonalizable">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Default Mode? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@mode">
|
||||
<option value="view">View Mode</option>
|
||||
<option value="edit">Edit Mode</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Theme: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @onchange="(e => ThemeChanged(e))">
|
||||
<option value=""><Select Theme></option>
|
||||
@foreach (KeyValuePair<string, string> item in themes)
|
||||
{
|
||||
if (item.Key == themetype)
|
||||
{
|
||||
<option value="@panelayout.Key">@panelayout.Value</option>
|
||||
<option value="@item.Key" selected>@item.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Icon: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@icon" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
else
|
||||
{
|
||||
<option value="@item.Key">@item.Value</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Layout: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@layouttype">
|
||||
<option value=""><Select Layout></option>
|
||||
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
||||
{
|
||||
<option value="@panelayout.Key">@panelayout.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Icon: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@icon" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="SavePage">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
<br />
|
||||
@ -168,6 +179,7 @@
|
||||
List<Page> children;
|
||||
int childid = -1;
|
||||
string isnavigation;
|
||||
string ispersonalizable;
|
||||
string mode;
|
||||
string themetype;
|
||||
string layouttype;
|
||||
@ -211,6 +223,7 @@
|
||||
}
|
||||
currentparentid = parentid;
|
||||
isnavigation = page.IsNavigation.ToString();
|
||||
ispersonalizable = page.IsPersonalizable.ToString();
|
||||
mode = (page.EditMode) ? "edit" : "view";
|
||||
themetype = page.ThemeType;
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes, themetype);
|
||||
@ -357,16 +370,18 @@
|
||||
{
|
||||
page.LayoutType = "";
|
||||
}
|
||||
page.IsPersonalizable = (ispersonalizable == null ? false : Boolean.Parse(ispersonalizable));
|
||||
page.UserId = null;
|
||||
|
||||
await PageService.UpdatePageAsync(page);
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.ParentId);
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, page.ParentId);
|
||||
if (currentparentid == "")
|
||||
{
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, null);
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, int.Parse(currentparentid));
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, int.Parse(currentparentid));
|
||||
}
|
||||
|
||||
// update child paths
|
||||
|
@ -8,9 +8,10 @@ namespace Oqtane.Services
|
||||
{
|
||||
Task<List<Page>> GetPagesAsync(int SiteId);
|
||||
Task<Page> GetPageAsync(int PageId);
|
||||
Task<Page> GetPageAsync(int PageId, int UserId);
|
||||
Task<Page> AddPageAsync(Page Page);
|
||||
Task<Page> UpdatePageAsync(Page Page);
|
||||
Task UpdatePageOrderAsync(int SiteId, int? ParentId);
|
||||
Task UpdatePageOrderAsync(int SiteId, int PageId, int? ParentId);
|
||||
Task DeletePageAsync(int PageId);
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,11 @@ namespace Oqtane.Services
|
||||
return await http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Page> GetPageAsync(int PageId, int UserId)
|
||||
{
|
||||
return await http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString() + "?userid=" + UserId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Page> AddPageAsync(Page Page)
|
||||
{
|
||||
return await http.PostJsonAsync<Page>(apiurl, Page);
|
||||
@ -49,9 +54,9 @@ namespace Oqtane.Services
|
||||
return await http.PutJsonAsync<Page>(apiurl + "/" + Page.PageId.ToString(), Page);
|
||||
}
|
||||
|
||||
public async Task UpdatePageOrderAsync(int SiteId, int? ParentId)
|
||||
public async Task UpdatePageOrderAsync(int SiteId, int PageId, int? ParentId)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/?siteid=" + SiteId.ToString() + "&parentid=" + ((ParentId == null) ? "" : ParentId.ToString()), null);
|
||||
await http.PutJsonAsync(apiurl + "/?siteid=" + SiteId.ToString() + "&pageid=" + PageId.ToString() + "&parentid=" + ((ParentId == null) ? "" : ParentId.ToString()), null);
|
||||
}
|
||||
|
||||
public async Task DeletePageAsync(int PageId)
|
||||
|
@ -218,11 +218,11 @@
|
||||
|
||||
if (page != null)
|
||||
{
|
||||
page = ProcessPage(page, site);
|
||||
|
||||
// check if user is authorized to view page
|
||||
if (UserSecurity.IsAuthorized(user, "View", page.Permissions))
|
||||
{
|
||||
page = await ProcessPage(page, site, user);
|
||||
|
||||
pagestate = new PageState();
|
||||
pagestate.ModuleDefinitions = moduledefinitions;
|
||||
pagestate.Themes = themes;
|
||||
@ -260,11 +260,16 @@
|
||||
else
|
||||
{
|
||||
// user is not authorized to view page
|
||||
if (path != "")
|
||||
{
|
||||
NavigationManager.NavigateTo("");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// page does not exist
|
||||
NavigationManager.NavigateTo("");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -313,10 +318,16 @@
|
||||
return querystring;
|
||||
}
|
||||
|
||||
private Page ProcessPage(Page page, Site site)
|
||||
private async Task<Page> ProcessPage(Page page, Site site, User user)
|
||||
{
|
||||
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;
|
||||
|
@ -21,10 +21,13 @@
|
||||
</div>
|
||||
<div class="@BodyClass">
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item px-3"><button type="button" class="btn btn-primary btn-block mx-auto" @onclick=@(async () => Navigate("Admin"))>Admin Dashboard</button></li>
|
||||
<li class="nav-item px-3"> </li>
|
||||
<li class="nav-item px-3"><button type="button" class="btn btn-primary btn-block mx-auto" @onclick=@(async () => Navigate("Add"))>Add Page</button></li>
|
||||
<li class="nav-item px-3"><button type="button" class="btn btn-primary btn-block mx-auto" @onclick=@(async () => Navigate("Edit"))>Edit Page</button></li>
|
||||
@if (UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole))
|
||||
{
|
||||
<li class="nav-item px-3"><button type="button" class="btn btn-primary btn-block mx-auto" @onclick=@(async () => Navigate("Admin"))>Admin Dashboard</button></li>
|
||||
<li class="nav-item px-3"> </li>
|
||||
<li class="nav-item px-3"><button type="button" class="btn btn-primary btn-block mx-auto" @onclick=@(async () => Navigate("Add"))>Add Page</button></li>
|
||||
<li class="nav-item px-3"><button type="button" class="btn btn-primary btn-block mx-auto" @onclick=@(async () => Navigate("Edit"))>Edit Page</button></li>
|
||||
}
|
||||
<li class="nav-item px-3">
|
||||
<button class="btn btn-primary btn-block mx-auto" @onclick="ConfirmDelete">Delete Page</button>
|
||||
@if (deleteconfirmation)
|
||||
@ -146,19 +149,26 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions) || (PageState.Page.IsPersonalizable && PageState.User != null))
|
||||
{
|
||||
@if (PageState.EditMode)
|
||||
{
|
||||
<button type="button" class="btn @ButtonClass active" data-toggle="button" aria-pressed="true" autocomplete="off" @onclick="(async () => ToggleEditMode(PageState.EditMode))">
|
||||
<button type="button" class="btn @ButtonClass active" data-toggle="button" aria-pressed="true" autocomplete="off" @onclick="(async () => await ToggleEditMode(PageState.EditMode))">
|
||||
<span class="oi oi-pencil"></span>
|
||||
</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="button" class="btn @ButtonClass" data-toggle="button" aria-pressed="false" autocomplete="off" @onclick="(async () => ToggleEditMode(PageState.EditMode))">
|
||||
<button type="button" class="btn @ButtonClass" data-toggle="button" aria-pressed="false" autocomplete="off" @onclick="(async () => await ToggleEditMode(PageState.EditMode))">
|
||||
<span class="oi oi-pencil"></span>
|
||||
</button>
|
||||
}
|
||||
}
|
||||
|
||||
@if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions))
|
||||
{
|
||||
<button type="button" class="btn @ButtonClass" @onclick="ShowControlPanel">
|
||||
<span class="oi oi-menu"></span>
|
||||
</button>
|
||||
@ -292,7 +302,7 @@
|
||||
}
|
||||
|
||||
PageModule pagemodule = new PageModule();
|
||||
pagemodule.PageId = string.IsNullOrWhiteSpace(pageid) ? PageState.Page.PageId : int.Parse(pageid);
|
||||
pagemodule.PageId = string.IsNullOrEmpty(pageid) ? PageState.Page.PageId : int.Parse(pageid);
|
||||
pagemodule.ModuleId = int.Parse(moduleid);
|
||||
pagemodule.Title = title;
|
||||
if (pagemodule.Title == "")
|
||||
@ -330,7 +340,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleEditMode(bool EditMode)
|
||||
private async Task ToggleEditMode(bool EditMode)
|
||||
{
|
||||
if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions))
|
||||
{
|
||||
@ -346,6 +356,16 @@
|
||||
}
|
||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Page.Path, "edit=" + ((PageState.EditMode) ? "1" : "0"), Reload.Page));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PageState.Page.IsPersonalizable && PageState.User != null)
|
||||
{
|
||||
await CreatePersonalizedPage();
|
||||
PageState.EditMode = true;
|
||||
PageState.DesignMode = true;
|
||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Page.Path, "edit=" + ((PageState.EditMode) ? "1" : "0"), Reload.Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowControlPanel()
|
||||
@ -413,14 +433,86 @@
|
||||
Page page = PageState.Page;
|
||||
try
|
||||
{
|
||||
page.IsDeleted = true;
|
||||
await PageService.UpdatePageAsync(page);
|
||||
await logger.Log(page.PageId, null, PageState.User.UserId, this.GetType().AssemblyQualifiedName, "ControlPanel", LogFunction.Delete, LogLevel.Information, null, "Page Deleted {Page}", page);
|
||||
NavigationManager.NavigateTo(NavigateUrl("", Reload.Site));
|
||||
if (page.UserId == null)
|
||||
{
|
||||
page.IsDeleted = true;
|
||||
await PageService.UpdatePageAsync(page);
|
||||
await logger.Log(page.PageId, null, PageState.User.UserId, this.GetType().AssemblyQualifiedName, "ControlPanel", LogFunction.Delete, LogLevel.Information, null, "Page Deleted {Page}", page);
|
||||
NavigationManager.NavigateTo(NavigateUrl("", Reload.Site));
|
||||
}
|
||||
else // personalized page
|
||||
{
|
||||
await PageService.DeletePageAsync(page.PageId);
|
||||
await logger.Log(page.PageId, null, PageState.User.UserId, this.GetType().AssemblyQualifiedName, "ControlPanel", LogFunction.Delete, LogLevel.Information, null, "Page Deleted {Page}", page);
|
||||
NavigationManager.NavigateTo(NavigateUrl(Reload.Page));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.Log(page.PageId, null, PageState.User.UserId, this.GetType().AssemblyQualifiedName, "ControlPanel", LogFunction.Delete, LogLevel.Information, ex, "Page Deleted {Page} {Error}", page, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CreatePersonalizedPage()
|
||||
{
|
||||
Page page = new Page();
|
||||
page.SiteId = PageState.Page.SiteId;
|
||||
page.Name = PageState.Page.Name;
|
||||
page.Path = PageState.Page.Path;
|
||||
page.ParentId = PageState.Page.ParentId;
|
||||
page.Order = 0;
|
||||
page.IsNavigation = false;
|
||||
page.EditMode = false;
|
||||
page.ThemeType = PageState.Page.ThemeType;
|
||||
if (page.ThemeType == PageState.Site.DefaultThemeType)
|
||||
{
|
||||
page.ThemeType = "";
|
||||
}
|
||||
page.LayoutType = PageState.Page.LayoutType;
|
||||
if (page.LayoutType == PageState.Site.DefaultLayoutType)
|
||||
{
|
||||
page.LayoutType = "";
|
||||
}
|
||||
page.Icon = PageState.Page.Icon;
|
||||
List<PermissionString> permissions = new List<PermissionString>();
|
||||
permissions.Add(new PermissionString { PermissionName = "View", Permissions = "[" + PageState.User.UserId.ToString() + "]" });
|
||||
permissions.Add(new PermissionString { PermissionName = "Edit", Permissions = "[" + PageState.User.UserId.ToString() + "]" });
|
||||
page.Permissions = UserSecurity.SetPermissionStrings(permissions);
|
||||
page.IsPersonalizable = false;
|
||||
page.UserId = PageState.User.UserId;
|
||||
page = await PageService.AddPageAsync(page);
|
||||
|
||||
// copy modules
|
||||
foreach (Module m in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId && !item.IsDeleted))
|
||||
{
|
||||
Module module = new Module();
|
||||
module.SiteId = m.SiteId;
|
||||
module.ModuleDefinitionName = m.ModuleDefinitionName;
|
||||
permissions = new List<PermissionString>();
|
||||
permissions.Add(new PermissionString { PermissionName = "View", Permissions = "[" + PageState.User.UserId.ToString() + "]" });
|
||||
permissions.Add(new PermissionString { PermissionName = "Edit", Permissions = "[" + PageState.User.UserId.ToString() + "]" });
|
||||
module.Permissions = UserSecurity.SetPermissionStrings(permissions);
|
||||
module = await ModuleService.AddModuleAsync(module);
|
||||
|
||||
string content = await ModuleService.ExportModuleAsync(m.ModuleId);
|
||||
if (content != "")
|
||||
{
|
||||
await ModuleService.ImportModuleAsync(module.ModuleId, content);
|
||||
}
|
||||
|
||||
PageModule pagemodule = new PageModule();
|
||||
pagemodule.PageId = page.PageId;
|
||||
pagemodule.ModuleId = module.ModuleId;
|
||||
pagemodule.Title = m.Title;
|
||||
pagemodule.Pane = m.Pane;
|
||||
pagemodule.Order = m.Order;
|
||||
pagemodule.ContainerType = m.ContainerType;
|
||||
if (pagemodule.ContainerType == PageState.Site.DefaultContainerType)
|
||||
{
|
||||
pagemodule.ContainerType = "";
|
||||
}
|
||||
|
||||
await PageModuleService.AddPageModuleAsync(pagemodule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user