commit
dc2c46e878
|
@ -54,7 +54,6 @@
|
|||
List<Folder> _folders;
|
||||
int _folderId = -1;
|
||||
List<File> _files;
|
||||
Uri _uri;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
|
@ -66,7 +65,6 @@
|
|||
_folderId = _folders[0].FolderId;
|
||||
await GetFiles();
|
||||
}
|
||||
_uri = new Uri(NavigationManager.Uri);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -70,7 +70,9 @@
|
|||
string _permissions;
|
||||
string _pageId;
|
||||
|
||||
#pragma warning disable 649
|
||||
PermissionGrid _permissionGrid;
|
||||
#pragma warning restore 649
|
||||
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
object _settings;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
@inject IPageService PageService
|
||||
@inject IThemeService ThemeService
|
||||
|
||||
@if (Themes != null)
|
||||
@if (_themeList != null)
|
||||
{
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
<input class="form-control" @bind="@_name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -20,7 +20,7 @@
|
|||
<label for="Name" class="control-label">Path: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@path" />
|
||||
<input class="form-control" @bind="@_path" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -30,7 +30,7 @@
|
|||
<td>
|
||||
<select class="form-control" @onchange="(e => ParentChanged(e))">
|
||||
<option value="-1"><Site Root></option>
|
||||
@foreach (Page page in pages)
|
||||
@foreach (Page page in _pageList)
|
||||
{
|
||||
<option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||
}
|
||||
|
@ -42,20 +42,20 @@
|
|||
<label for="Name" class="control-label">Insert: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@insert">
|
||||
<select class="form-control" @bind="@_insert">
|
||||
<option value="<<">At Beginning</option>
|
||||
@if (children != null && children.Count > 0)
|
||||
@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 == ">"))
|
||||
@if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">"))
|
||||
{
|
||||
<select class="form-control" @bind="@childid">
|
||||
<select class="form-control" @bind="@_childid">
|
||||
<option value="-1"><Select Page></option>
|
||||
@foreach (Page page in children)
|
||||
@foreach (Page page in _children)
|
||||
{
|
||||
<option value="@(page.PageId)">@(page.Name)</option>
|
||||
}
|
||||
|
@ -68,7 +68,7 @@
|
|||
<label for="Name" class="control-label">Navigation? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isnavigation">
|
||||
<select class="form-control" @bind="@_isnavigation">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
|
@ -79,7 +79,7 @@
|
|||
<label for="Name" class="control-label">Personalizable? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@ispersonalizable">
|
||||
<select class="form-control" @bind="@_ispersonalizable">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
|
@ -90,7 +90,7 @@
|
|||
<label for="Name" class="control-label">Default Mode? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@mode">
|
||||
<select class="form-control" @bind="@_mode">
|
||||
<option value="view">View Mode</option>
|
||||
<option value="edit">Edit Mode</option>
|
||||
</select>
|
||||
|
@ -103,7 +103,7 @@
|
|||
<td>
|
||||
<select class="form-control" @onchange="(e => ThemeChanged(e))">
|
||||
<option value=""><Select Theme></option>
|
||||
@foreach (KeyValuePair<string, string> item in themes)
|
||||
@foreach (KeyValuePair<string, string> item in _themes)
|
||||
{
|
||||
<option value="@item.Key">@item.Value</option>
|
||||
}
|
||||
|
@ -115,9 +115,9 @@
|
|||
<label for="Name" class="control-label">Layout: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@layouttype">
|
||||
<select class="form-control" @bind="@_layouttype">
|
||||
<option value=""><Select Layout></option>
|
||||
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
||||
@foreach (KeyValuePair<string, string> panelayout in _panelayouts)
|
||||
{
|
||||
<option value="@panelayout.Key">@panelayout.Value</option>
|
||||
}
|
||||
|
@ -129,7 +129,7 @@
|
|||
<label for="Name" class="control-label">Icon: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@icon" />
|
||||
<input class="form-control" @bind="@_icon" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -137,7 +137,7 @@
|
|||
<label for="Name" class="control-label">Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" />
|
||||
<PermissionGrid EntityName="Page" Permissions="@_permissions" @ref="_permissionGrid" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -148,45 +148,45 @@
|
|||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
Dictionary<string, string> _themes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
|
||||
|
||||
List<Theme> Themes;
|
||||
List<Page> pages;
|
||||
string name;
|
||||
string path = "";
|
||||
string parentid;
|
||||
string insert = ">>";
|
||||
List<Page> children;
|
||||
int childid = -1;
|
||||
string isnavigation = "True";
|
||||
string ispersonalizable = "False";
|
||||
string mode = "view";
|
||||
string themetype = "";
|
||||
string layouttype = "";
|
||||
string icon = "";
|
||||
string permissions = "";
|
||||
List<Theme> _themeList;
|
||||
List<Page> _pageList;
|
||||
string _name;
|
||||
string _path = "";
|
||||
string _parentid;
|
||||
string _insert = ">>";
|
||||
List<Page> _children;
|
||||
int _childid = -1;
|
||||
string _isnavigation = "True";
|
||||
string _ispersonalizable = "False";
|
||||
string _mode = "view";
|
||||
string _themetype = "";
|
||||
string _layouttype = "";
|
||||
string _icon = "";
|
||||
string _permissions = "";
|
||||
|
||||
PermissionGrid permissiongrid;
|
||||
PermissionGrid _permissionGrid;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
Themes = await ThemeService.GetThemesAsync();
|
||||
pages = PageState.Pages;
|
||||
children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
_themeList = await ThemeService.GetThemesAsync();
|
||||
_pageList = PageState.Pages;
|
||||
_children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
|
||||
themes = ThemeService.GetThemeTypes(Themes);
|
||||
themetype = PageState.Site.DefaultThemeType;
|
||||
_themes = ThemeService.GetThemeTypes(_themeList);
|
||||
_themetype = PageState.Site.DefaultThemeType;
|
||||
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(Themes, themetype);
|
||||
layouttype = PageState.Site.DefaultLayoutType;
|
||||
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
|
||||
_layouttype = PageState.Site.DefaultLayoutType;
|
||||
|
||||
List<PermissionString> permissionstrings = new List<PermissionString>();
|
||||
permissionstrings.Add(new PermissionString { PermissionName = PermissionNames.View, Permissions = Constants.AdminRole });
|
||||
permissionstrings.Add(new PermissionString { PermissionName = PermissionNames.Edit, Permissions = Constants.AdminRole });
|
||||
permissions = UserSecurity.SetPermissionStrings(permissionstrings);
|
||||
_permissions = UserSecurity.SetPermissionStrings(permissionstrings);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -199,20 +199,20 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
parentid = (string)e.Value;
|
||||
if (parentid == "-1")
|
||||
_parentid = (string)e.Value;
|
||||
if (_parentid == "-1")
|
||||
{
|
||||
children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
_children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
children = PageState.Pages.Where(item => item.ParentId == int.Parse(parentid)).ToList();
|
||||
_children = PageState.Pages.Where(item => item.ParentId == int.Parse(_parentid)).ToList();
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Child Pages For Parent {PageId} {Error}", parentid, ex.Message);
|
||||
await logger.LogError(ex, "Error Loading Child Pages For Parent {PageId} {Error}", _parentid, ex.Message);
|
||||
AddModuleMessage("Error Loading Child Pages For Parent", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
@ -221,20 +221,20 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
themetype = (string)e.Value;
|
||||
if (themetype != "")
|
||||
_themetype = (string)e.Value;
|
||||
if (_themetype != "")
|
||||
{
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(Themes, themetype);
|
||||
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
|
||||
}
|
||||
else
|
||||
{
|
||||
panelayouts = new Dictionary<string, string>();
|
||||
_panelayouts = new Dictionary<string, string>();
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", themetype, ex.Message);
|
||||
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", _themetype, ex.Message);
|
||||
AddModuleMessage("Error Loading Pane Layouts For Theme", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
@ -244,61 +244,61 @@
|
|||
Page page = null;
|
||||
try
|
||||
{
|
||||
if (name != "" && !string.IsNullOrEmpty(themetype) && (panelayouts.Count == 0 || !string.IsNullOrEmpty(layouttype)))
|
||||
if (_name != "" && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)))
|
||||
{
|
||||
page = new Page();
|
||||
page.SiteId = PageState.Page.SiteId;
|
||||
page.Name = name;
|
||||
if (path == "")
|
||||
page.Name = _name;
|
||||
if (_path == "")
|
||||
{
|
||||
path = name;
|
||||
_path = _name;
|
||||
}
|
||||
if (path.Contains("/"))
|
||||
if (_path.Contains("/"))
|
||||
{
|
||||
path = path.Substring(path.LastIndexOf("/") + 1);
|
||||
_path = _path.Substring(_path.LastIndexOf("/") + 1);
|
||||
}
|
||||
if (string.IsNullOrEmpty(parentid))
|
||||
if (string.IsNullOrEmpty(_parentid))
|
||||
{
|
||||
page.ParentId = null;
|
||||
page.Path = Utilities.GetFriendlyUrl(path);
|
||||
page.Path = Utilities.GetFriendlyUrl(_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
page.ParentId = Int32.Parse(parentid);
|
||||
page.ParentId = Int32.Parse(_parentid);
|
||||
Page parent = PageState.Pages.Where(item => item.PageId == page.ParentId).FirstOrDefault();
|
||||
if (parent.Path == "")
|
||||
{
|
||||
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(path);
|
||||
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(path);
|
||||
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path);
|
||||
}
|
||||
}
|
||||
Page child;
|
||||
switch (insert)
|
||||
switch (_insert)
|
||||
{
|
||||
case "<<":
|
||||
page.Order = 0;
|
||||
break;
|
||||
case "<":
|
||||
child = PageState.Pages.Where(item => item.PageId == childid).FirstOrDefault();
|
||||
child = PageState.Pages.Where(item => item.PageId == _childid).FirstOrDefault();
|
||||
page.Order = child.Order - 1;
|
||||
break;
|
||||
case ">":
|
||||
child = PageState.Pages.Where(item => item.PageId == childid).FirstOrDefault();
|
||||
child = PageState.Pages.Where(item => item.PageId == _childid).FirstOrDefault();
|
||||
page.Order = child.Order + 1;
|
||||
break;
|
||||
case ">>":
|
||||
page.Order = int.MaxValue;
|
||||
break;
|
||||
}
|
||||
page.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation));
|
||||
page.EditMode = (mode == "edit" ? true : false);
|
||||
page.ThemeType = themetype;
|
||||
page.LayoutType = (layouttype == null ? "" : layouttype);
|
||||
page.Icon = (icon == null ? "" : icon);
|
||||
page.Permissions = permissiongrid.GetPermissions();
|
||||
page.IsNavigation = (_isnavigation == null ? true : Boolean.Parse(_isnavigation));
|
||||
page.EditMode = (_mode == "edit" ? true : false);
|
||||
page.ThemeType = _themetype;
|
||||
page.LayoutType = (_layouttype == null ? "" : _layouttype);
|
||||
page.Icon = (_icon == null ? "" : _icon);
|
||||
page.Permissions = _permissionGrid.GetPermissions();
|
||||
|
||||
if (page.ThemeType == PageState.Site.DefaultThemeType)
|
||||
{
|
||||
|
@ -308,7 +308,7 @@
|
|||
{
|
||||
page.LayoutType = "";
|
||||
}
|
||||
page.IsPersonalizable = (ispersonalizable == null ? false : Boolean.Parse(ispersonalizable));
|
||||
page.IsPersonalizable = (_ispersonalizable == null ? false : Boolean.Parse(_ispersonalizable));
|
||||
page.UserId = null;
|
||||
|
||||
page = await PageService.AddPageAsync(page);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
@inject IPageService PageService
|
||||
@inject IThemeService ThemeService
|
||||
|
||||
@if (Themes != null)
|
||||
@if (_themeList != null)
|
||||
{
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
<input class="form-control" @bind="@_name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -20,7 +20,7 @@
|
|||
<label for="Name" class="control-label">Path: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@path" />
|
||||
<input class="form-control" @bind="@_path" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -30,9 +30,9 @@
|
|||
<td>
|
||||
<select class="form-control" @onchange="(e => ParentChanged(e))">
|
||||
<option value="-1"><Site Root></option>
|
||||
@foreach (Page page in pages)
|
||||
@foreach (Page page in _pageList)
|
||||
{
|
||||
if (page.PageId.ToString() == parentid)
|
||||
if (page.PageId.ToString() == _parentid)
|
||||
{
|
||||
<option value="@(page.PageId)" selected>@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||
}
|
||||
|
@ -49,24 +49,24 @@
|
|||
<label for="Name" class="control-label">Move: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@insert">
|
||||
@if (parentid == currentparentid)
|
||||
<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)
|
||||
@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 == ">"))
|
||||
@if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">"))
|
||||
{
|
||||
<select class="form-control" @bind="@childid">
|
||||
<select class="form-control" @bind="@_childid">
|
||||
<option value="-1"><Select Page></option>
|
||||
@foreach (Page page in children)
|
||||
@foreach (Page page in _children)
|
||||
{
|
||||
<option value="@(page.PageId)">@(page.Name)</option>
|
||||
}
|
||||
|
@ -79,7 +79,7 @@
|
|||
<label for="Name" class="control-label">Navigation? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isnavigation">
|
||||
<select class="form-control" @bind="@_isnavigation">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
|
@ -90,7 +90,7 @@
|
|||
<label for="Name" class="control-label">Personalizable? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@ispersonalizable">
|
||||
<select class="form-control" @bind="@_ispersonalizable">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
|
@ -101,7 +101,7 @@
|
|||
<label for="Name" class="control-label">Default Mode? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@mode">
|
||||
<select class="form-control" @bind="@_mode">
|
||||
<option value="view">View Mode</option>
|
||||
<option value="edit">Edit Mode</option>
|
||||
</select>
|
||||
|
@ -114,9 +114,9 @@
|
|||
<td>
|
||||
<select class="form-control" @onchange="(e => ThemeChanged(e))">
|
||||
<option value=""><Select Theme></option>
|
||||
@foreach (KeyValuePair<string, string> item in themes)
|
||||
@foreach (KeyValuePair<string, string> item in _themes)
|
||||
{
|
||||
if (item.Key == themetype)
|
||||
if (item.Key == _themetype)
|
||||
{
|
||||
<option value="@item.Key" selected>@item.Value</option>
|
||||
}
|
||||
|
@ -133,9 +133,9 @@
|
|||
<label for="Name" class="control-label">Layout: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@layouttype">
|
||||
<select class="form-control" @bind="@_layouttype">
|
||||
<option value=""><Select Layout></option>
|
||||
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
||||
@foreach (KeyValuePair<string, string> panelayout in _panelayouts)
|
||||
{
|
||||
<option value="@panelayout.Key">@panelayout.Value</option>
|
||||
}
|
||||
|
@ -147,7 +147,7 @@
|
|||
<label for="Name" class="control-label">Icon: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@icon" />
|
||||
<input class="form-control" @bind="@_icon" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -155,7 +155,7 @@
|
|||
<label for="Name" class="control-label">Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" />
|
||||
<PermissionGrid EntityName="Page" Permissions="@_permissions" @ref="_permissionGrid" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -163,89 +163,91 @@
|
|||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
<br />
|
||||
<br />
|
||||
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon" DeletedBy="@deletedby" DeletedOn="@deletedon"></AuditInfo>
|
||||
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon" DeletedBy="@_deletedby" DeletedOn="@_deletedon"></AuditInfo>
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
Dictionary<string, string> _themes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
|
||||
|
||||
List<Theme> Themes;
|
||||
List<Page> pages;
|
||||
int PageId;
|
||||
string name;
|
||||
string path;
|
||||
string currentparentid;
|
||||
string parentid;
|
||||
string insert = "=";
|
||||
List<Page> children;
|
||||
int childid = -1;
|
||||
string isnavigation;
|
||||
string ispersonalizable;
|
||||
string mode;
|
||||
string themetype;
|
||||
string layouttype;
|
||||
string icon;
|
||||
string permissions;
|
||||
string createdby;
|
||||
DateTime createdon;
|
||||
string modifiedby;
|
||||
DateTime modifiedon;
|
||||
string deletedby;
|
||||
DateTime? deletedon;
|
||||
List<Theme> _themeList;
|
||||
List<Page> _pageList;
|
||||
int _pageId;
|
||||
string _name;
|
||||
string _path;
|
||||
string _currentparentid;
|
||||
string _parentid;
|
||||
string _insert = "=";
|
||||
List<Page> _children;
|
||||
int _childid = -1;
|
||||
string _isnavigation;
|
||||
string _ispersonalizable;
|
||||
string _mode;
|
||||
string _themetype;
|
||||
string _layouttype;
|
||||
string _icon;
|
||||
string _permissions;
|
||||
string _createdby;
|
||||
DateTime _createdon;
|
||||
string _modifiedby;
|
||||
DateTime _modifiedon;
|
||||
string _deletedby;
|
||||
DateTime? _deletedon;
|
||||
|
||||
PermissionGrid permissiongrid;
|
||||
#pragma warning disable 649
|
||||
PermissionGrid _permissionGrid;
|
||||
#pragma warning restore 649
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
Themes = await ThemeService.GetThemesAsync();
|
||||
pages = PageState.Pages;
|
||||
children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
_themeList = await ThemeService.GetThemesAsync();
|
||||
_pageList = PageState.Pages;
|
||||
_children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
|
||||
themes = ThemeService.GetThemeTypes(Themes);
|
||||
_themes = ThemeService.GetThemeTypes(_themeList);
|
||||
|
||||
PageId = Int32.Parse(PageState.QueryString["id"]);
|
||||
Page page = PageState.Pages.FirstOrDefault(item => item.PageId == PageId);
|
||||
_pageId = Int32.Parse(PageState.QueryString["id"]);
|
||||
Page page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId);
|
||||
if (page != null)
|
||||
{
|
||||
name = page.Name;
|
||||
path = page.Path;
|
||||
if (path.Contains("/"))
|
||||
_name = page.Name;
|
||||
_path = page.Path;
|
||||
if (_path.Contains("/"))
|
||||
{
|
||||
path = path.Substring(path.LastIndexOf("/") + 1);
|
||||
_path = _path.Substring(_path.LastIndexOf("/") + 1);
|
||||
}
|
||||
if (page.ParentId == null)
|
||||
{
|
||||
parentid = "";
|
||||
_parentid = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
parentid = page.ParentId.ToString();
|
||||
_parentid = page.ParentId.ToString();
|
||||
}
|
||||
currentparentid = parentid;
|
||||
isnavigation = page.IsNavigation.ToString();
|
||||
ispersonalizable = page.IsPersonalizable.ToString();
|
||||
mode = (page.EditMode) ? "edit" : "view";
|
||||
themetype = page.ThemeType;
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(Themes, themetype);
|
||||
layouttype = page.LayoutType;
|
||||
icon = page.Icon;
|
||||
permissions = page.Permissions;
|
||||
createdby = page.CreatedBy;
|
||||
createdon = page.CreatedOn;
|
||||
modifiedby = page.ModifiedBy;
|
||||
modifiedon = page.ModifiedOn;
|
||||
deletedby = page.DeletedBy;
|
||||
deletedon = page.DeletedOn;
|
||||
_currentparentid = _parentid;
|
||||
_isnavigation = page.IsNavigation.ToString();
|
||||
_ispersonalizable = page.IsPersonalizable.ToString();
|
||||
_mode = (page.EditMode) ? "edit" : "view";
|
||||
_themetype = page.ThemeType;
|
||||
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
|
||||
_layouttype = page.LayoutType;
|
||||
_icon = page.Icon;
|
||||
_permissions = page.Permissions;
|
||||
_createdby = page.CreatedBy;
|
||||
_createdon = page.CreatedOn;
|
||||
_modifiedby = page.ModifiedBy;
|
||||
_modifiedon = page.ModifiedOn;
|
||||
_deletedby = page.DeletedBy;
|
||||
_deletedon = page.DeletedOn;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Page {PageId} {Error}", PageId, ex.Message);
|
||||
await logger.LogError(ex, "Error Loading Page {PageId} {Error}", _pageId, ex.Message);
|
||||
AddModuleMessage("Error Loading Page", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
@ -254,28 +256,28 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
parentid = (string)e.Value;
|
||||
if (parentid == "-1")
|
||||
_parentid = (string)e.Value;
|
||||
if (_parentid == "-1")
|
||||
{
|
||||
children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
_children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
children = PageState.Pages.Where(item => item.ParentId == int.Parse(parentid)).ToList();
|
||||
_children = PageState.Pages.Where(item => item.ParentId == int.Parse(_parentid)).ToList();
|
||||
}
|
||||
if (parentid == currentparentid)
|
||||
if (_parentid == _currentparentid)
|
||||
{
|
||||
insert = "=";
|
||||
_insert = "=";
|
||||
}
|
||||
else
|
||||
{
|
||||
insert = ">>";
|
||||
_insert = ">>";
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Child Pages For Parent {PageId} {Error}", parentid, ex.Message);
|
||||
await logger.LogError(ex, "Error Loading Child Pages For Parent {PageId} {Error}", _parentid, ex.Message);
|
||||
AddModuleMessage("Error Loading Child Pages For Parent", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
@ -284,20 +286,20 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
themetype = (string)e.Value;
|
||||
if (themetype != "")
|
||||
_themetype = (string)e.Value;
|
||||
if (_themetype != "")
|
||||
{
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(Themes, themetype);
|
||||
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
|
||||
}
|
||||
else
|
||||
{
|
||||
panelayouts = new Dictionary<string, string>();
|
||||
_panelayouts = new Dictionary<string, string>();
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", themetype, ex.Message);
|
||||
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", _themetype, ex.Message);
|
||||
AddModuleMessage("Error Loading Pane Layouts For Theme", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
@ -307,52 +309,52 @@
|
|||
Page page = null;
|
||||
try
|
||||
{
|
||||
if (name != "" && !string.IsNullOrEmpty(themetype) && (panelayouts.Count == 0 || !string.IsNullOrEmpty(layouttype)))
|
||||
if (_name != "" && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)))
|
||||
{
|
||||
page = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
|
||||
page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId);
|
||||
string currentPath = page.Path;
|
||||
|
||||
page.Name = name;
|
||||
if (path == "" && name.ToLower() != "home")
|
||||
page.Name = _name;
|
||||
if (_path == "" && _name.ToLower() != "home")
|
||||
{
|
||||
path = name;
|
||||
_path = _name;
|
||||
}
|
||||
if (path.Contains("/"))
|
||||
if (_path.Contains("/"))
|
||||
{
|
||||
path = path.Substring(path.LastIndexOf("/") + 1);
|
||||
_path = _path.Substring(_path.LastIndexOf("/") + 1);
|
||||
}
|
||||
if (string.IsNullOrEmpty(parentid))
|
||||
if (string.IsNullOrEmpty(_parentid))
|
||||
{
|
||||
page.ParentId = null;
|
||||
page.Path = Utilities.GetFriendlyUrl(path);
|
||||
page.Path = Utilities.GetFriendlyUrl(_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
page.ParentId = Int32.Parse(parentid);
|
||||
page.ParentId = Int32.Parse(_parentid);
|
||||
Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == page.ParentId);
|
||||
if (parent.Path == "")
|
||||
{
|
||||
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(path);
|
||||
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(path);
|
||||
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path);
|
||||
}
|
||||
}
|
||||
if (insert != "=")
|
||||
if (_insert != "=")
|
||||
{
|
||||
Page child;
|
||||
switch (insert)
|
||||
switch (_insert)
|
||||
{
|
||||
case "<<":
|
||||
page.Order = 0;
|
||||
break;
|
||||
case "<":
|
||||
child = PageState.Pages.FirstOrDefault(item => item.PageId == childid);
|
||||
child = PageState.Pages.FirstOrDefault(item => item.PageId == _childid);
|
||||
if (child != null) page.Order = child.Order - 1;
|
||||
break;
|
||||
case ">":
|
||||
child = PageState.Pages.FirstOrDefault(item => item.PageId == childid);
|
||||
child = PageState.Pages.FirstOrDefault(item => item.PageId == _childid);
|
||||
if (child != null) page.Order = child.Order + 1;
|
||||
break;
|
||||
case ">>":
|
||||
|
@ -360,12 +362,12 @@
|
|||
break;
|
||||
}
|
||||
}
|
||||
page.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation));
|
||||
page.EditMode = (mode == "edit" ? true : false);
|
||||
page.ThemeType = themetype;
|
||||
page.LayoutType = layouttype ?? "";
|
||||
page.Icon = icon ?? "";
|
||||
page.Permissions = permissiongrid.GetPermissions();
|
||||
page.IsNavigation = (_isnavigation == null || Boolean.Parse(_isnavigation));
|
||||
page.EditMode = (_mode == "edit");
|
||||
page.ThemeType = _themetype;
|
||||
page.LayoutType = _layouttype ?? "";
|
||||
page.Icon = _icon ?? "";
|
||||
page.Permissions = _permissionGrid.GetPermissions();
|
||||
|
||||
if (page.ThemeType == PageState.Site.DefaultThemeType)
|
||||
{
|
||||
|
@ -375,22 +377,22 @@
|
|||
{
|
||||
page.LayoutType = "";
|
||||
}
|
||||
page.IsPersonalizable = (ispersonalizable != null && Boolean.Parse(ispersonalizable));
|
||||
page.IsPersonalizable = (_ispersonalizable != null && Boolean.Parse(_ispersonalizable));
|
||||
page.UserId = null;
|
||||
|
||||
page = await PageService.UpdatePageAsync(page);
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, page.ParentId);
|
||||
if (currentparentid == "")
|
||||
if (_currentparentid == "")
|
||||
{
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, int.Parse(currentparentid));
|
||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, int.Parse(_currentparentid));
|
||||
}
|
||||
|
||||
// update child paths
|
||||
if (parentid != currentparentid)
|
||||
if (_parentid != _currentparentid)
|
||||
{
|
||||
foreach (Page p in PageState.Pages.Where(item => item.Path.StartsWith(currentPath)))
|
||||
{
|
||||
|
|
|
@ -24,18 +24,18 @@
|
|||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
private async Task DeletePage(Page Page)
|
||||
private async Task DeletePage(Page page)
|
||||
{
|
||||
try
|
||||
{
|
||||
Page.IsDeleted = true;
|
||||
await PageService.UpdatePageAsync(Page);
|
||||
await logger.LogInformation("Page Deleted {Page}", Page);
|
||||
page.IsDeleted = true;
|
||||
await PageService.UpdatePageAsync(page);
|
||||
await logger.LogInformation("Page Deleted {Page}", page);
|
||||
NavigationManager.NavigateTo(NavigateUrl("admin/pages"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Deleting Page {Page} {Error}", Page, ex.Message);
|
||||
await logger.LogError(ex, "Error Deleting Page {Page} {Error}", page, ex.Message);
|
||||
AddModuleMessage("Error Deleting Page", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<label class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
<input class="form-control" @bind="@_name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -17,7 +17,7 @@
|
|||
<label class="control-label">Title: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@title" />
|
||||
<input class="form-control" @bind="@_title" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<label class="control-label">Description: </label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea class="form-control" @bind="@description" rows="5" />
|
||||
<textarea class="form-control" @bind="@_description" rows="5"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -33,7 +33,7 @@
|
|||
<label class="control-label">Category: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@category" />
|
||||
<input class="form-control" @bind="@_category" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -41,7 +41,7 @@
|
|||
<label class="control-label">Order: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@vieworder" />
|
||||
<input class="form-control" @bind="@_vieworder" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -49,7 +49,7 @@
|
|||
<label class="control-label">Length: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@maxlength" />
|
||||
<input class="form-control" @bind="@_maxlength" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -57,7 +57,7 @@
|
|||
<label class="control-label">Default Value: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@defaultvalue" />
|
||||
<input class="form-control" @bind="@_defaultvalue" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -65,7 +65,7 @@
|
|||
<label class="control-label">Required? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isrequired">
|
||||
<select class="form-control" @bind="@_isrequired">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
|
@ -76,7 +76,7 @@
|
|||
<label class="control-label">Private? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isprivate">
|
||||
<select class="form-control" @bind="@_isprivate">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
|
@ -90,16 +90,16 @@
|
|||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
public override string Actions { get { return "Add,Edit"; } }
|
||||
|
||||
int profileid = -1;
|
||||
string name = "";
|
||||
string title = "";
|
||||
string description = "";
|
||||
string category = "";
|
||||
string vieworder = "0";
|
||||
string maxlength = "0";
|
||||
string defaultvalue = "";
|
||||
string isrequired = "False";
|
||||
string isprivate = "False";
|
||||
int _profileid = -1;
|
||||
string _name = "";
|
||||
string _title = "";
|
||||
string _description = "";
|
||||
string _category = "";
|
||||
string _vieworder = "0";
|
||||
string _maxlength = "0";
|
||||
string _defaultvalue = "";
|
||||
string _isrequired = "False";
|
||||
string _isprivate = "False";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
@ -107,25 +107,25 @@
|
|||
{
|
||||
if (PageState.QueryString.ContainsKey("id"))
|
||||
{
|
||||
profileid = Int32.Parse(PageState.QueryString["id"]);
|
||||
Profile profile = await ProfileService.GetProfileAsync(profileid);
|
||||
_profileid = Int32.Parse(PageState.QueryString["id"]);
|
||||
Profile profile = await ProfileService.GetProfileAsync(_profileid);
|
||||
if (profile != null)
|
||||
{
|
||||
name = profile.Name;
|
||||
title = profile.Title;
|
||||
description = profile.Description;
|
||||
category = profile.Category;
|
||||
vieworder = profile.ViewOrder.ToString();
|
||||
maxlength = profile.MaxLength.ToString();
|
||||
defaultvalue = profile.DefaultValue;
|
||||
isrequired = profile.IsRequired.ToString();
|
||||
isprivate = profile.IsPrivate.ToString();
|
||||
_name = profile.Name;
|
||||
_title = profile.Title;
|
||||
_description = profile.Description;
|
||||
_category = profile.Category;
|
||||
_vieworder = profile.ViewOrder.ToString();
|
||||
_maxlength = profile.MaxLength.ToString();
|
||||
_defaultvalue = profile.DefaultValue;
|
||||
_isrequired = profile.IsRequired.ToString();
|
||||
_isprivate = profile.IsPrivate.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Profile {ProfileId} {Error}", profileid, ex.Message);
|
||||
await logger.LogError(ex, "Error Loading Profile {ProfileId} {Error}", _profileid, ex.Message);
|
||||
AddModuleMessage("Error Loading Profile", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
@ -135,30 +135,30 @@
|
|||
try
|
||||
{
|
||||
Profile profile;
|
||||
if (profileid != -1)
|
||||
if (_profileid != -1)
|
||||
{
|
||||
profile = await ProfileService.GetProfileAsync(profileid);
|
||||
profile = await ProfileService.GetProfileAsync(_profileid);
|
||||
}
|
||||
else
|
||||
{
|
||||
profile = new Profile();
|
||||
}
|
||||
profile.Name = name;
|
||||
profile.Title = title;
|
||||
profile.Description = description;
|
||||
profile.Category = category;
|
||||
profile.ViewOrder = int.Parse(vieworder);
|
||||
profile.MaxLength = int.Parse(maxlength);
|
||||
profile.DefaultValue = defaultvalue;
|
||||
profile.IsRequired = (isrequired == null ? false : Boolean.Parse(isrequired));
|
||||
profile.IsPrivate = (isprivate == null ? false : Boolean.Parse(isprivate));
|
||||
profile.Name = _name;
|
||||
profile.Title = _title;
|
||||
profile.Description = _description;
|
||||
profile.Category = _category;
|
||||
profile.ViewOrder = int.Parse(_vieworder);
|
||||
profile.MaxLength = int.Parse(_maxlength);
|
||||
profile.DefaultValue = _defaultvalue;
|
||||
profile.IsRequired = (_isrequired == null ? false : Boolean.Parse(_isrequired));
|
||||
profile.IsPrivate = (_isprivate == null ? false : Boolean.Parse(_isprivate));
|
||||
profile = await ProfileService.UpdateProfileAsync(profile);
|
||||
await logger.LogInformation("Profile Saved {Profile}", profile);
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Saving Profile {ProfleId} {Error}", profileid, ex.Message);
|
||||
await logger.LogError(ex, "Error Saving Profile {ProfleId} {Error}", _profileid, ex.Message);
|
||||
AddModuleMessage("Error Saving Profile", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
@inherits ModuleBase
|
||||
@inject IProfileService ProfileService
|
||||
|
||||
@if (Profiles == null)
|
||||
@if (_profiles == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ else
|
|||
{
|
||||
<ActionLink Action="Add" Security="SecurityAccessLevel.Admin" Text="Add Profile" />
|
||||
|
||||
<Pager Items="@Profiles">
|
||||
<Pager Items="@_profiles">
|
||||
<Header>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
|
@ -27,25 +27,25 @@ else
|
|||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
List<Profile> Profiles;
|
||||
List<Profile> _profiles;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
|
||||
_profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
|
||||
}
|
||||
|
||||
private async Task DeleteProfile(int ProfileId)
|
||||
private async Task DeleteProfile(int profileId)
|
||||
{
|
||||
try
|
||||
{
|
||||
await ProfileService.DeleteProfileAsync(ProfileId);
|
||||
await logger.LogInformation("Profile Deleted {ProfileId}", ProfileId);
|
||||
await ProfileService.DeleteProfileAsync(profileId);
|
||||
await logger.LogInformation("Profile Deleted {ProfileId}", profileId);
|
||||
AddModuleMessage("Profile Deleted", MessageType.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Deleting Profile {ProfileId} {Error}", ProfileId, ex.Message);
|
||||
await logger.LogError(ex, "Error Deleting Profile {ProfileId} {Error}", profileId, ex.Message);
|
||||
AddModuleMessage("Error Deleting Profile", MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
|
||||
<div class="tab-content">
|
||||
<div id="Pages" class="tab-pane fade show active" role="tabpanel">
|
||||
@if (pages == null)
|
||||
@if (_pages == null)
|
||||
{
|
||||
<br />
|
||||
<p>No Deleted Pages</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Pager Items="@pages">
|
||||
<Pager Items="@_pages">
|
||||
<Header>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
|
@ -49,14 +49,14 @@
|
|||
}
|
||||
</div>
|
||||
<div id="Modules" class="tab-pane fade" role="tabpanel">
|
||||
@if (modules == null)
|
||||
@if (_modules == null)
|
||||
{
|
||||
<br />
|
||||
<p>No Deleted Modules</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Pager Items="@modules">
|
||||
<Pager Items="@_modules">
|
||||
<Header>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
|
@ -83,8 +83,8 @@
|
|||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
List<Page> pages;
|
||||
List<Module> modules;
|
||||
List<Page> _pages;
|
||||
List<Module> _modules;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
@ -101,84 +101,84 @@
|
|||
|
||||
private async Task Load()
|
||||
{
|
||||
pages = await PageService.GetPagesAsync(PageState.Site.SiteId);
|
||||
pages = pages.Where(item => item.IsDeleted).ToList();
|
||||
_pages = await PageService.GetPagesAsync(PageState.Site.SiteId);
|
||||
_pages = _pages.Where(item => item.IsDeleted).ToList();
|
||||
|
||||
modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
|
||||
modules = modules.Where(item => item.IsDeleted).ToList();
|
||||
_modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
|
||||
_modules = _modules.Where(item => item.IsDeleted).ToList();
|
||||
}
|
||||
|
||||
private async Task RestorePage(Page Page)
|
||||
private async Task RestorePage(Page page)
|
||||
{
|
||||
try
|
||||
{
|
||||
Page.IsDeleted = false;
|
||||
await PageService.UpdatePageAsync(Page);
|
||||
await logger.LogInformation("Page Restored {Page}", Page);
|
||||
page.IsDeleted = false;
|
||||
await PageService.UpdatePageAsync(page);
|
||||
await logger.LogInformation("Page Restored {Page}", page);
|
||||
await Load();
|
||||
StateHasChanged();
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Restoring Deleted Page {Page} {Error}", Page, ex.Message);
|
||||
await logger.LogError(ex, "Error Restoring Deleted Page {Page} {Error}", page, ex.Message);
|
||||
AddModuleMessage("Error Restoring Deleted Page", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeletePage(Page Page)
|
||||
private async Task DeletePage(Page page)
|
||||
{
|
||||
try
|
||||
{
|
||||
await PageService.DeletePageAsync(Page.PageId);
|
||||
await logger.LogInformation("Page Permanently Deleted {Page}", Page);
|
||||
await PageService.DeletePageAsync(page.PageId);
|
||||
await logger.LogInformation("Page Permanently Deleted {Page}", page);
|
||||
await Load();
|
||||
StateHasChanged();
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Permanently Deleting Page {Page} {Error}", Page, ex.Message);
|
||||
await logger.LogError(ex, "Error Permanently Deleting Page {Page} {Error}", page, ex.Message);
|
||||
AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RestoreModule(Module Module)
|
||||
private async Task RestoreModule(Module module)
|
||||
{
|
||||
try
|
||||
{
|
||||
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(Module.PageModuleId);
|
||||
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(module.PageModuleId);
|
||||
pagemodule.IsDeleted = false;
|
||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||
await logger.LogInformation("Module Restored {Module}", Module);
|
||||
await logger.LogInformation("Module Restored {Module}", module);
|
||||
await Load();
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Restoring Deleted Module {Module} {Error}", Module, ex.Message);
|
||||
await logger.LogError(ex, "Error Restoring Deleted Module {Module} {Error}", module, ex.Message);
|
||||
AddModuleMessage("Error Restoring Deleted Module", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeleteModule(Module Module)
|
||||
private async Task DeleteModule(Module module)
|
||||
{
|
||||
try
|
||||
{
|
||||
await PageModuleService.DeletePageModuleAsync(Module.PageModuleId);
|
||||
await PageModuleService.DeletePageModuleAsync(module.PageModuleId);
|
||||
// check if there are any remaining module instances in the site
|
||||
modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
|
||||
if (!modules.Exists(item => item.ModuleId == Module.ModuleId))
|
||||
_modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
|
||||
if (!_modules.Exists(item => item.ModuleId == module.ModuleId))
|
||||
{
|
||||
await ModuleService.DeleteModuleAsync(Module.ModuleId);
|
||||
await ModuleService.DeleteModuleAsync(module.ModuleId);
|
||||
}
|
||||
await logger.LogInformation("Module Permanently Deleted {Module}", Module);
|
||||
await logger.LogInformation("Module Permanently Deleted {Module}", module);
|
||||
await Load();
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Permanently Deleting Module {Module} {Error}", Module, ex.Message);
|
||||
await logger.LogError(ex, "Error Permanently Deleting Module {Module} {Error}", module, ex.Message);
|
||||
AddModuleMessage("Error Permanently Deleting Module", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,31 +3,31 @@
|
|||
@inject NavigationManager NavigationManager
|
||||
@inject IUserService UserService
|
||||
|
||||
@if (Message != "")
|
||||
@if (_message != "")
|
||||
{
|
||||
<ModuleMessage Message="@Message" Type="MessageType.Info" />
|
||||
<ModuleMessage Message="@_message" Type="MessageType.Info" />
|
||||
}
|
||||
|
||||
<div class="container">
|
||||
<div class="form-group">
|
||||
<label for="Username" class="control-label">Username: </label>
|
||||
<input type="text" class="form-control" placeholder="Username" @bind="@Username" />
|
||||
<input type="text" class="form-control" placeholder="Username" @bind="@_username" id="Username"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="Password" class="control-label">Password: </label>
|
||||
<input type="password" class="form-control" placeholder="Password" @bind="@Password" />
|
||||
<input type="password" class="form-control" placeholder="Password" @bind="@_password" id="Password"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="Password" class="control-label">Confirm Password: </label>
|
||||
<input type="password" class="form-control" placeholder="Password" @bind="@Confirm" />
|
||||
<label for="Confirm" class="control-label">Confirm Password: </label>
|
||||
<input type="password" class="form-control" placeholder="Password" @bind="@_confirm"id="Confirm" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="Username" class="control-label">Email: </label>
|
||||
<input type="text" class="form-control" placeholder="Email" @bind="@Email" />
|
||||
<label for="Email" class="control-label">Email: </label>
|
||||
<input type="text" class="form-control" placeholder="Email" @bind="@_email" id="Email"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="DisplayName" class="control-label">Full Name: </label>
|
||||
<input type="text" class="form-control" placeholder="Full Name" @bind="@DisplayName" />
|
||||
<input type="text" class="form-control" placeholder="Full Name" @bind="@_displayName" id="DisplayName"/>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary" @onclick="Register">Register</button>
|
||||
<button type="button" class="btn btn-secondary" @onclick="Cancel">Cancel</button>
|
||||
|
@ -36,38 +36,40 @@
|
|||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } }
|
||||
|
||||
string Message = "Please Note That Registration Requires A Valid Email Address In Order To Verify Your Identity";
|
||||
string Username = "";
|
||||
string Password = "";
|
||||
string Confirm = "";
|
||||
string Email = "";
|
||||
string DisplayName = "";
|
||||
string _message = "Please Note That Registration Requires A Valid Email Address In Order To Verify Your Identity";
|
||||
string _username = "";
|
||||
string _password = "";
|
||||
string _confirm = "";
|
||||
string _email = "";
|
||||
string _displayName = "";
|
||||
|
||||
private async Task Register()
|
||||
{
|
||||
try
|
||||
{
|
||||
Message = "";
|
||||
if (Username != "" && Password != "" && Confirm != "" && Email != "")
|
||||
_message = "";
|
||||
if (_username != "" && _password != "" && _confirm != "" && _email != "")
|
||||
{
|
||||
if (Password == Confirm)
|
||||
if (_password == _confirm)
|
||||
{
|
||||
User user = new User();
|
||||
user.SiteId = PageState.Site.SiteId;
|
||||
user.Username = Username;
|
||||
user.DisplayName = (DisplayName == "" ? Username : DisplayName);
|
||||
user.Email = Email;
|
||||
user.Password = Password;
|
||||
User user = new User
|
||||
{
|
||||
SiteId = PageState.Site.SiteId,
|
||||
Username = _username,
|
||||
DisplayName = (_displayName == "" ? _username : _displayName),
|
||||
Email = _email,
|
||||
Password = _password
|
||||
};
|
||||
user = await UserService.AddUserAsync(user);
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
await logger.LogInformation("User Created {Username} {Email}", Username, Email);
|
||||
await logger.LogInformation("User Created {Username} {Email}", _username, _email);
|
||||
AddModuleMessage("User Account Created. Please Check Your Email For Verification Instructions.", MessageType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
await logger.LogError("Error Adding User {Username} {Email}", Username, Email);
|
||||
await logger.LogError("Error Adding User {Username} {Email}", _username, _email);
|
||||
AddModuleMessage("Error Adding User. Please Ensure Password Meets Complexity Requirements And Username Is Not Already In Use.", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +85,7 @@
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", Username, Email, ex.Message);
|
||||
await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", _username, _email, ex.Message);
|
||||
AddModuleMessage("Error Adding User", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<label class="control-label">Description: </label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea class="form-control" @bind="@description" rows="5" />
|
||||
<textarea class="form-control" @bind="@description" rows="5"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<label class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
<input class="form-control" @bind="@_name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -17,7 +17,7 @@
|
|||
<label class="control-label">Description: </label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea class="form-control" @bind="@description" rows="5" />
|
||||
<textarea class="form-control" @bind="@_description" rows="5"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<label class="control-label">Auto Assigned? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isautoassigned">
|
||||
<select class="form-control" @bind="@_isautoassigned">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
|
@ -36,7 +36,7 @@
|
|||
<label class="control-label">System Role? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@issystem">
|
||||
<select class="form-control" @bind="@_issystem">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
|
@ -49,40 +49,40 @@
|
|||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
int roleid;
|
||||
string name = "";
|
||||
string description = "";
|
||||
string isautoassigned = "False";
|
||||
string issystem = "False";
|
||||
int _roleid;
|
||||
string _name = "";
|
||||
string _description = "";
|
||||
string _isautoassigned = "False";
|
||||
string _issystem = "False";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
roleid = Int32.Parse(PageState.QueryString["id"]);
|
||||
Role role = await RoleService.GetRoleAsync(roleid);
|
||||
_roleid = Int32.Parse(PageState.QueryString["id"]);
|
||||
Role role = await RoleService.GetRoleAsync(_roleid);
|
||||
if (role != null)
|
||||
{
|
||||
name = role.Name;
|
||||
description = role.Description;
|
||||
isautoassigned = role.IsAutoAssigned.ToString();
|
||||
issystem = role.IsSystem.ToString();
|
||||
_name = role.Name;
|
||||
_description = role.Description;
|
||||
_isautoassigned = role.IsAutoAssigned.ToString();
|
||||
_issystem = role.IsSystem.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Role {RoleId} {Error}", roleid, ex.Message);
|
||||
await logger.LogError(ex, "Error Loading Role {RoleId} {Error}", _roleid, ex.Message);
|
||||
AddModuleMessage("Error Loading Role", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveRole()
|
||||
{
|
||||
Role role = await RoleService.GetRoleAsync(roleid);
|
||||
role.Name = name;
|
||||
role.Description = description;
|
||||
role.IsAutoAssigned = (isautoassigned == null ? false : Boolean.Parse(isautoassigned));
|
||||
role.IsSystem = (issystem == null ? false : Boolean.Parse(issystem));
|
||||
Role role = await RoleService.GetRoleAsync(_roleid);
|
||||
role.Name = _name;
|
||||
role.Description = _description;
|
||||
role.IsAutoAssigned = (_isautoassigned != null && Boolean.Parse(_isautoassigned));
|
||||
role.IsSystem = (_issystem != null && Boolean.Parse(_issystem));
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
@inherits ModuleBase
|
||||
@inject IRoleService RoleService
|
||||
|
||||
@if (Roles == null)
|
||||
@if (_roles == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ else
|
|||
{
|
||||
<ActionLink Action="Add" Text="Add Role" />
|
||||
|
||||
<Pager Items="@Roles">
|
||||
<Pager Items="@_roles">
|
||||
<Header>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
|
@ -27,25 +27,25 @@ else
|
|||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
List<Role> Roles;
|
||||
List<Role> _roles;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
Roles = await RoleService.GetRolesAsync(PageState.Site.SiteId);
|
||||
_roles = await RoleService.GetRolesAsync(PageState.Site.SiteId);
|
||||
}
|
||||
|
||||
private async Task DeleteRole(Role Role)
|
||||
private async Task DeleteRole(Role role)
|
||||
{
|
||||
try
|
||||
{
|
||||
await RoleService.DeleteRoleAsync(Role.RoleId);
|
||||
await logger.LogInformation("Role Deleted {Role}", Role);
|
||||
await RoleService.DeleteRoleAsync(role.RoleId);
|
||||
await logger.LogInformation("Role Deleted {Role}", role);
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Deleting Role {Role} {Error}", Role, ex.Message);
|
||||
await logger.LogError(ex, "Error Deleting Role {Role} {Error}", role, ex.Message);
|
||||
AddModuleMessage("Error Deleting Role", MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
@inject IThemeService ThemeService
|
||||
@inject ISettingService SettingService
|
||||
|
||||
@if (themes != null)
|
||||
@if (_themes != null)
|
||||
{
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
|
@ -15,7 +15,7 @@
|
|||
<label class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
<input class="form-control" @bind="@_name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -23,7 +23,7 @@
|
|||
<label class="control-label">Tenant: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@tenant" readonly />
|
||||
<input class="form-control" @bind="@_tenant" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -31,7 +31,7 @@
|
|||
<label class="control-label">Aliases: </label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea class="form-control" @bind="@urls" rows="3" />
|
||||
<textarea class="form-control" @bind="@_urls" rows="3"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -39,7 +39,7 @@
|
|||
<label class="control-label">Logo: </label>
|
||||
</td>
|
||||
<td>
|
||||
<FileManager FileId="@logofileid.ToString()" @ref="filemanager" />
|
||||
<FileManager FileId="@_logofileid.ToString()" @ref="_filemanager" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -49,9 +49,9 @@
|
|||
<td>
|
||||
<select class="form-control" @onchange="(e => ThemeChanged(e))">
|
||||
<option value=""><Select Theme></option>
|
||||
@foreach (KeyValuePair<string, string> item in themes)
|
||||
@foreach (KeyValuePair<string, string> item in _themes)
|
||||
{
|
||||
if (item.Key == themetype)
|
||||
if (item.Key == _themetype)
|
||||
{
|
||||
<option value="@item.Key" selected>@item.Value</option>
|
||||
}
|
||||
|
@ -68,9 +68,9 @@
|
|||
<label class="control-label">Default Layout: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@layouttype">
|
||||
<select class="form-control" @bind="@_layouttype">
|
||||
<option value=""><Select Layout></option>
|
||||
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
||||
@foreach (KeyValuePair<string, string> panelayout in _panelayouts)
|
||||
{
|
||||
<option value="@panelayout.Key">@panelayout.Value</option>
|
||||
}
|
||||
|
@ -82,9 +82,9 @@
|
|||
<label class="control-label">Default Container: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@containertype">
|
||||
<select class="form-control" @bind="@_containertype">
|
||||
<option value=""><Select Container></option>
|
||||
@foreach (KeyValuePair<string, string> container in containers)
|
||||
@foreach (KeyValuePair<string, string> container in _containers)
|
||||
{
|
||||
<option value="@container.Key">@container.Value</option>
|
||||
}
|
||||
|
@ -96,7 +96,7 @@
|
|||
<label class="control-label">Is Deleted? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isdeleted">
|
||||
<select class="form-control" @bind="@_isdeleted">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
|
@ -114,7 +114,7 @@
|
|||
<label class="control-label">Host: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@smtphost" />
|
||||
<input class="form-control" @bind="@_smtphost" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -122,7 +122,7 @@
|
|||
<label class="control-label">Port: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@smtpport" />
|
||||
<input class="form-control" @bind="@_smtpport" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -130,7 +130,7 @@
|
|||
<label class="control-label">SSL Enabled: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@smtpssl" />
|
||||
<input class="form-control" @bind="@_smtpssl" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -138,7 +138,7 @@
|
|||
<label class="control-label">Username: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@smtpusername" />
|
||||
<input class="form-control" @bind="@_smtpusername" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -146,7 +146,7 @@
|
|||
<label class="control-label">Password: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" class="form-control" @bind="@smtppassword" />
|
||||
<input type="password" class="form-control" @bind="@_smtppassword" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -156,85 +156,85 @@
|
|||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
<br />
|
||||
<br />
|
||||
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon" DeletedBy="@deletedby" DeletedOn="@deletedon"></AuditInfo>
|
||||
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon" DeletedBy="@_deletedby" DeletedOn="@_deletedon"></AuditInfo>
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
Dictionary<string, string> themes;
|
||||
Dictionary<string, string> panelayouts;
|
||||
Dictionary<string, string> containers;
|
||||
Dictionary<string, string> _themes;
|
||||
Dictionary<string, string> _panelayouts;
|
||||
Dictionary<string, string> _containers;
|
||||
|
||||
List<Theme> Themes;
|
||||
string name = "";
|
||||
List<Tenant> tenants;
|
||||
string tenant = "";
|
||||
List<Alias> aliases;
|
||||
string urls = "";
|
||||
int logofileid = -1;
|
||||
FileManager filemanager;
|
||||
string themetype;
|
||||
string layouttype;
|
||||
string containertype;
|
||||
List<Theme> _themeList;
|
||||
string _name = "";
|
||||
List<Tenant> _tenantList;
|
||||
string _tenant = "";
|
||||
List<Alias> _aliasList;
|
||||
string _urls = "";
|
||||
int _logofileid = -1;
|
||||
FileManager _filemanager;
|
||||
string _themetype;
|
||||
string _layouttype;
|
||||
string _containertype;
|
||||
|
||||
string smtphost = "";
|
||||
string smtpport = "";
|
||||
string smtpssl = "";
|
||||
string smtpusername = "";
|
||||
string smtppassword = "";
|
||||
string _smtphost = "";
|
||||
string _smtpport = "";
|
||||
string _smtpssl = "";
|
||||
string _smtpusername = "";
|
||||
string _smtppassword = "";
|
||||
|
||||
string createdby;
|
||||
DateTime createdon;
|
||||
string modifiedby;
|
||||
DateTime modifiedon;
|
||||
string deletedby;
|
||||
DateTime? deletedon;
|
||||
string isdeleted;
|
||||
string _createdby;
|
||||
DateTime _createdon;
|
||||
string _modifiedby;
|
||||
DateTime _modifiedon;
|
||||
string _deletedby;
|
||||
DateTime? _deletedon;
|
||||
string _isdeleted;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
Themes = await ThemeService.GetThemesAsync();
|
||||
aliases = await AliasService.GetAliasesAsync();
|
||||
_themeList = await ThemeService.GetThemesAsync();
|
||||
_aliasList = await AliasService.GetAliasesAsync();
|
||||
Site site = await SiteService.GetSiteAsync(PageState.Site.SiteId, PageState.Alias);
|
||||
if (site != null)
|
||||
{
|
||||
name = site.Name;
|
||||
tenants = await TenantService.GetTenantsAsync();
|
||||
tenant = tenants.Find(item => item.TenantId == site.TenantId).Name;
|
||||
foreach (Alias alias in aliases.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
|
||||
_name = site.Name;
|
||||
_tenantList = await TenantService.GetTenantsAsync();
|
||||
_tenant = _tenantList.Find(item => item.TenantId == site.TenantId).Name;
|
||||
foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
|
||||
{
|
||||
urls += alias.Name + "\n";
|
||||
_urls += alias.Name + "\n";
|
||||
}
|
||||
if (site.LogoFileId != null)
|
||||
{
|
||||
logofileid = site.LogoFileId.Value;
|
||||
_logofileid = site.LogoFileId.Value;
|
||||
}
|
||||
themetype = site.DefaultThemeType;
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(Themes, themetype);
|
||||
layouttype = site.DefaultLayoutType;
|
||||
containertype = site.DefaultContainerType;
|
||||
_themetype = site.DefaultThemeType;
|
||||
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
|
||||
_layouttype = site.DefaultLayoutType;
|
||||
_containertype = site.DefaultContainerType;
|
||||
|
||||
Dictionary<string, string> settings = await SettingService.GetSiteSettingsAsync(site.SiteId);
|
||||
smtphost = SettingService.GetSetting(settings, "SMTPHost", "");
|
||||
smtpport = SettingService.GetSetting(settings, "SMTPPort", "");
|
||||
smtpssl = SettingService.GetSetting(settings, "SMTPSSL", "");
|
||||
smtpusername = SettingService.GetSetting(settings, "SMTPUsername", "");
|
||||
smtppassword = SettingService.GetSetting(settings, "SMTPPassword", "");
|
||||
_smtphost = SettingService.GetSetting(settings, "SMTPHost", "");
|
||||
_smtpport = SettingService.GetSetting(settings, "SMTPPort", "");
|
||||
_smtpssl = SettingService.GetSetting(settings, "SMTPSSL", "");
|
||||
_smtpusername = SettingService.GetSetting(settings, "SMTPUsername", "");
|
||||
_smtppassword = SettingService.GetSetting(settings, "SMTPPassword", "");
|
||||
|
||||
createdby = site.CreatedBy;
|
||||
createdon = site.CreatedOn;
|
||||
modifiedby = site.ModifiedBy;
|
||||
modifiedon = site.ModifiedOn;
|
||||
deletedby = site.DeletedBy;
|
||||
deletedon = site.DeletedOn;
|
||||
isdeleted = site.IsDeleted.ToString();
|
||||
_createdby = site.CreatedBy;
|
||||
_createdon = site.CreatedOn;
|
||||
_modifiedby = site.ModifiedBy;
|
||||
_modifiedon = site.ModifiedOn;
|
||||
_deletedby = site.DeletedBy;
|
||||
_deletedon = site.DeletedOn;
|
||||
_isdeleted = site.IsDeleted.ToString();
|
||||
}
|
||||
|
||||
themes = ThemeService.GetThemeTypes(Themes);
|
||||
containers = ThemeService.GetContainerTypes(Themes);
|
||||
_themes = ThemeService.GetThemeTypes(_themeList);
|
||||
_containers = ThemeService.GetContainerTypes(_themeList);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -247,20 +247,20 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
themetype = (string)e.Value;
|
||||
if (themetype != "")
|
||||
_themetype = (string)e.Value;
|
||||
if (_themetype != "")
|
||||
{
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(Themes, themetype);
|
||||
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
|
||||
}
|
||||
else
|
||||
{
|
||||
panelayouts = new Dictionary<string, string>();
|
||||
_panelayouts = new Dictionary<string, string>();
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", themetype, ex.Message);
|
||||
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", _themetype, ex.Message);
|
||||
AddModuleMessage("Error Loading Pane Layouts For Theme", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
@ -269,12 +269,12 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
if (name != "" && urls != "" && !string.IsNullOrEmpty(themetype) && (panelayouts.Count == 0 || !string.IsNullOrEmpty(layouttype)) && !string.IsNullOrEmpty(containertype))
|
||||
if (_name != "" && _urls != "" && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype))
|
||||
{
|
||||
bool unique = true;
|
||||
foreach (string name in urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
if (aliases.Exists(item => item.Name == name && item.SiteId != PageState.Alias.SiteId && item.TenantId != PageState.Alias.TenantId))
|
||||
if (_aliasList.Exists(item => item.Name == name && item.SiteId != PageState.Alias.SiteId && item.TenantId != PageState.Alias.TenantId))
|
||||
{
|
||||
unique = false;
|
||||
}
|
||||
|
@ -284,23 +284,23 @@
|
|||
Site site = await SiteService.GetSiteAsync(PageState.Site.SiteId, PageState.Alias);
|
||||
if (site != null)
|
||||
{
|
||||
site.Name = name;
|
||||
site.Name = _name;
|
||||
site.LogoFileId = null;
|
||||
int logofileid = filemanager.GetFileId();
|
||||
int logofileid = _filemanager.GetFileId();
|
||||
if (logofileid != -1)
|
||||
{
|
||||
site.LogoFileId = logofileid;
|
||||
}
|
||||
site.DefaultThemeType = themetype;
|
||||
site.DefaultLayoutType = (layouttype == null ? "" : layouttype);
|
||||
site.DefaultContainerType = containertype;
|
||||
site.IsDeleted = (isdeleted == null ? true : Boolean.Parse(isdeleted));
|
||||
site.DefaultThemeType = _themetype;
|
||||
site.DefaultLayoutType = (_layouttype == null ? "" : _layouttype);
|
||||
site.DefaultContainerType = _containertype;
|
||||
site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted));
|
||||
|
||||
site = await SiteService.UpdateSiteAsync(site, PageState.Alias);
|
||||
|
||||
urls = urls.Replace("\n", ",");
|
||||
string[] names = urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (Alias alias in aliases.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
|
||||
_urls = _urls.Replace("\n", ",");
|
||||
string[] names = _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
|
||||
{
|
||||
if (!names.Contains(alias.Name))
|
||||
{
|
||||
|
@ -309,7 +309,7 @@
|
|||
}
|
||||
foreach (string name in names)
|
||||
{
|
||||
if (!aliases.Exists(item => item.Name == name))
|
||||
if (!_aliasList.Exists(item => item.Name == name))
|
||||
{
|
||||
Alias alias = new Alias();
|
||||
alias.Name = name;
|
||||
|
@ -320,11 +320,11 @@
|
|||
}
|
||||
|
||||
Dictionary<string, string> settings = await SettingService.GetSiteSettingsAsync(site.SiteId);
|
||||
SettingService.SetSetting(settings, "SMTPHost", smtphost);
|
||||
SettingService.SetSetting(settings, "SMTPPort", smtpport);
|
||||
SettingService.SetSetting(settings, "SMTPSSL", smtpssl);
|
||||
SettingService.SetSetting(settings, "SMTPUsername", smtpusername);
|
||||
SettingService.SetSetting(settings, "SMTPPassword", smtppassword);
|
||||
SettingService.SetSetting(settings, "SMTPHost", _smtphost);
|
||||
SettingService.SetSetting(settings, "SMTPPort", _smtpport);
|
||||
SettingService.SetSetting(settings, "SMTPSSL", _smtpssl);
|
||||
SettingService.SetSetting(settings, "SMTPUsername", _smtpusername);
|
||||
SettingService.SetSetting(settings, "SMTPPassword", _smtppassword);
|
||||
await SettingService.UpdateSiteSettingsAsync(settings, site.SiteId);
|
||||
|
||||
await logger.LogInformation("Site Saved {Site}", site);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
@inject IThemeService ThemeService
|
||||
@inject IUserService UserService
|
||||
|
||||
@if (tenants == null)
|
||||
@if (_tenants == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ else
|
|||
<td>
|
||||
<select class="form-control" @onchange="(e => TenantChanged(e))">
|
||||
<option value="-1"><Select Tenant></option>
|
||||
@foreach (Tenant tenant in tenants)
|
||||
@foreach (Tenant tenant in _tenants)
|
||||
{
|
||||
<option value="@tenant.TenantId">@tenant.Name</option>
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ else
|
|||
<label class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
<input class="form-control" @bind="@_name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -41,7 +41,7 @@ else
|
|||
<label class="control-label">Aliases: </label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea class="form-control" @bind="@urls" rows="3" />
|
||||
<textarea class="form-control" @bind="@_urls" rows="3"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -51,7 +51,7 @@ else
|
|||
<td>
|
||||
<select class="form-control" @onchange="(e => ThemeChanged(e))">
|
||||
<option value=""><Select Theme></option>
|
||||
@foreach (KeyValuePair<string, string> item in themes)
|
||||
@foreach (KeyValuePair<string, string> item in _themes)
|
||||
{
|
||||
<option value="@item.Key">@item.Value</option>
|
||||
}
|
||||
|
@ -63,9 +63,9 @@ else
|
|||
<label class="control-label">Default Layout: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@layouttype">
|
||||
<select class="form-control" @bind="@_layouttype">
|
||||
<option value=""><Select Layout></option>
|
||||
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
||||
@foreach (KeyValuePair<string, string> panelayout in _panelayouts)
|
||||
{
|
||||
<option value="@panelayout.Key">@panelayout.Value</option>
|
||||
}
|
||||
|
@ -77,23 +77,23 @@ else
|
|||
<label class="control-label">Default Container: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@containertype">
|
||||
<select class="form-control" @bind="@_containertype">
|
||||
<option value=""><Select Container></option>
|
||||
@foreach (KeyValuePair<string, string>container in containers)
|
||||
@foreach (KeyValuePair<string, string>container in _containers)
|
||||
{
|
||||
<option value="@container.Key">@container.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@if (!isinitialized)
|
||||
@if (!_isinitialized)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label">Host Username:</label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@username" readonly />
|
||||
<input class="form-control" @bind="@_username" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -101,7 +101,7 @@ else
|
|||
<label class="control-label">Host Password:</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" class="form-control" @bind="@password" />
|
||||
<input type="password" class="form-control" @bind="@_password" />
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
@ -113,50 +113,50 @@ else
|
|||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
Dictionary<string, string> containers = new Dictionary<string, string>();
|
||||
Dictionary<string, string> _themes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
|
||||
Dictionary<string, string> _containers = new Dictionary<string, string>();
|
||||
|
||||
List<Theme> Themes;
|
||||
List<Tenant> tenants;
|
||||
string tenantid = "-1";
|
||||
string name = "";
|
||||
string urls = "";
|
||||
string themetype = "";
|
||||
string layouttype = "";
|
||||
string containertype = "";
|
||||
bool isinitialized = true;
|
||||
string username = "";
|
||||
string password = "";
|
||||
List<Theme> _themeList;
|
||||
List<Tenant> _tenants;
|
||||
string _tenantid = "-1";
|
||||
string _name = "";
|
||||
string _urls = "";
|
||||
string _themetype = "";
|
||||
string _layouttype = "";
|
||||
string _containertype = "";
|
||||
bool _isinitialized = true;
|
||||
string _username = "";
|
||||
string _password = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Themes = await ThemeService.GetThemesAsync();
|
||||
tenants = await TenantService.GetTenantsAsync();
|
||||
urls = PageState.Alias.Name;
|
||||
themes = ThemeService.GetThemeTypes(Themes);
|
||||
containers = ThemeService.GetContainerTypes(Themes);
|
||||
username = Constants.HostUser;
|
||||
_themeList = await ThemeService.GetThemesAsync();
|
||||
_tenants = await TenantService.GetTenantsAsync();
|
||||
_urls = PageState.Alias.Name;
|
||||
_themes = ThemeService.GetThemeTypes(_themeList);
|
||||
_containers = ThemeService.GetContainerTypes(_themeList);
|
||||
_username = Constants.HostUser;
|
||||
}
|
||||
|
||||
private async void TenantChanged(ChangeEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
tenantid = (string)e.Value;
|
||||
if (tenantid != "-1")
|
||||
_tenantid = (string)e.Value;
|
||||
if (_tenantid != "-1")
|
||||
{
|
||||
Tenant tenant = tenants.Where(item => item.TenantId == int.Parse(tenantid)).FirstOrDefault();
|
||||
Tenant tenant = _tenants.Where(item => item.TenantId == int.Parse(_tenantid)).FirstOrDefault();
|
||||
if (tenant != null)
|
||||
{
|
||||
isinitialized = tenant.IsInitialized;
|
||||
_isinitialized = tenant.IsInitialized;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Tenant {TenantId} {Error}", tenantid, ex.Message);
|
||||
await logger.LogError(ex, "Error Loading Tenant {TenantId} {Error}", _tenantid, ex.Message);
|
||||
AddModuleMessage("Error Loading Tenant", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
@ -165,31 +165,31 @@ else
|
|||
{
|
||||
try
|
||||
{
|
||||
themetype = (string)e.Value;
|
||||
if (themetype != "")
|
||||
_themetype = (string)e.Value;
|
||||
if (_themetype != "")
|
||||
{
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(Themes, themetype);
|
||||
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
|
||||
}
|
||||
else
|
||||
{
|
||||
panelayouts = new Dictionary<string, string>();
|
||||
_panelayouts = new Dictionary<string, string>();
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", themetype, ex.Message);
|
||||
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", _themetype, ex.Message);
|
||||
AddModuleMessage("Error Loading Pane Layouts For Theme", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveSite()
|
||||
{
|
||||
if (tenantid != "-1" && name != "" && urls != "" && !string.IsNullOrEmpty(themetype) && (panelayouts.Count == 0 || !string.IsNullOrEmpty(layouttype)) && !string.IsNullOrEmpty(containertype))
|
||||
if (_tenantid != "-1" && _name != "" && _urls != "" && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype))
|
||||
{
|
||||
bool unique = true;
|
||||
List<Alias> aliases = await AliasService.GetAliasesAsync();
|
||||
foreach (string name in urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
if (aliases.Exists(item => item.Name == name))
|
||||
{
|
||||
|
@ -200,12 +200,12 @@ else
|
|||
{
|
||||
bool isvalid = true;
|
||||
|
||||
if (!isinitialized)
|
||||
if (!_isinitialized)
|
||||
{
|
||||
User user = new User();
|
||||
user.SiteId = PageState.Site.SiteId;
|
||||
user.Username = username;
|
||||
user.Password = password;
|
||||
user.Username = _username;
|
||||
user.Password = _password;
|
||||
user = await UserService.LoginUserAsync(user, false, false);
|
||||
isvalid = user.IsAuthenticated;
|
||||
}
|
||||
|
@ -215,24 +215,24 @@ else
|
|||
ShowProgressIndicator();
|
||||
|
||||
aliases = new List<Alias>();
|
||||
urls = urls.Replace("\n", ",");
|
||||
foreach (string name in urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
_urls = _urls.Replace("\n", ",");
|
||||
foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
Alias alias = new Alias();
|
||||
alias.Name = name;
|
||||
alias.TenantId = int.Parse(tenantid);
|
||||
alias.TenantId = int.Parse(_tenantid);
|
||||
alias.SiteId = -1;
|
||||
alias = await AliasService.AddAliasAsync(alias);
|
||||
aliases.Add(alias);
|
||||
}
|
||||
|
||||
Site site = new Site();
|
||||
site.TenantId = int.Parse(tenantid);
|
||||
site.Name = name;
|
||||
site.TenantId = int.Parse(_tenantid);
|
||||
site.Name = _name;
|
||||
site.LogoFileId = null;
|
||||
site.DefaultThemeType = themetype;
|
||||
site.DefaultLayoutType = (layouttype == null ? "" : layouttype);
|
||||
site.DefaultContainerType = containertype;
|
||||
site.DefaultThemeType = _themetype;
|
||||
site.DefaultLayoutType = (_layouttype == null ? "" : _layouttype);
|
||||
site.DefaultContainerType = _containertype;
|
||||
site = await SiteService.AddSiteAsync(site, aliases[0]);
|
||||
|
||||
foreach (Alias alias in aliases)
|
||||
|
@ -241,19 +241,19 @@ else
|
|||
await AliasService.UpdateAliasAsync(alias);
|
||||
}
|
||||
|
||||
if (!isinitialized)
|
||||
if (!_isinitialized)
|
||||
{
|
||||
User user = new User();
|
||||
user.SiteId = site.SiteId;
|
||||
user.Username = username;
|
||||
user.Password = password;
|
||||
user.Username = _username;
|
||||
user.Password = _password;
|
||||
user.Email = PageState.User.Email;
|
||||
user.DisplayName = PageState.User.DisplayName;
|
||||
user = await UserService.AddUserAsync(user, aliases[0]);
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
Tenant tenant = tenants.Where(item => item.TenantId == int.Parse(tenantid)).FirstOrDefault();
|
||||
Tenant tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantid));
|
||||
tenant.IsInitialized = true;
|
||||
await TenantService.UpdateTenantAsync(tenant);
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ else
|
|||
}
|
||||
else
|
||||
{
|
||||
await logger.LogError("Invalid Password Entered For Host {Username}", username);
|
||||
await logger.LogError("Invalid Password Entered For Host {Username}", _username);
|
||||
AddModuleMessage("Invalid Host Password", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
@inject IAliasService AliasService
|
||||
@inject IThemeService ThemeService
|
||||
|
||||
@if (themes != null)
|
||||
@if (_themes != null)
|
||||
{
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
|
@ -14,7 +14,7 @@
|
|||
<label class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
<input class="form-control" @bind="@_name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -22,7 +22,7 @@
|
|||
<label class="control-label">Tenant: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@tenant" readonly />
|
||||
<input class="form-control" @bind="@_tenant" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -30,7 +30,7 @@
|
|||
<label class="control-label">Aliases: </label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea class="form-control" @bind="@urls" rows="3" />
|
||||
<textarea class="form-control" @bind="@_urls" rows="3" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -40,9 +40,9 @@
|
|||
<td>
|
||||
<select class="form-control" @onchange="(e => ThemeChanged(e))">
|
||||
<option value=""><Select Theme></option>
|
||||
@foreach (KeyValuePair<string, string> item in themes)
|
||||
@foreach (KeyValuePair<string, string> item in _themes)
|
||||
{
|
||||
if (item.Key == themetype)
|
||||
if (item.Key == _themetype)
|
||||
{
|
||||
<option value="@item.Key" selected>@item.Value</option>
|
||||
}
|
||||
|
@ -59,9 +59,9 @@
|
|||
<label class="control-label">Default Layout: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@layouttype">
|
||||
<select class="form-control" @bind="@_layouttype">
|
||||
<option value=""><Select Layout></option>
|
||||
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
||||
@foreach (KeyValuePair<string, string> panelayout in _panelayouts)
|
||||
{
|
||||
<option value="@panelayout.Key">@panelayout.Value</option>
|
||||
}
|
||||
|
@ -73,9 +73,9 @@
|
|||
<label class="control-label">Default Container: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@containertype">
|
||||
<select class="form-control" @bind="@_containertype">
|
||||
<option value=""><Select Container></option>
|
||||
@foreach (KeyValuePair<string, string> container in containers)
|
||||
@foreach (KeyValuePair<string, string> container in _containers)
|
||||
{
|
||||
<option value="@container.Key">@container.Value</option>
|
||||
}
|
||||
|
@ -87,7 +87,7 @@
|
|||
<label class="control-label">Is Deleted? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isdeleted">
|
||||
<select class="form-control" @bind="@_isdeleted">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
|
@ -99,73 +99,73 @@
|
|||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
<br />
|
||||
<br />
|
||||
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon" DeletedBy="@deletedby" DeletedOn="@deletedon"></AuditInfo>
|
||||
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon" DeletedBy="@_deletedby" DeletedOn="@_deletedon"></AuditInfo>
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
Dictionary<string, string> themes;
|
||||
Dictionary<string, string> panelayouts;
|
||||
Dictionary<string, string> containers;
|
||||
Dictionary<string, string> _themes;
|
||||
Dictionary<string, string> _panelayouts;
|
||||
Dictionary<string, string> _containers;
|
||||
|
||||
Alias Alias;
|
||||
List<Theme> Themes;
|
||||
string name = "";
|
||||
List<Tenant> tenants;
|
||||
string tenant = "";
|
||||
List<Alias> aliases;
|
||||
string urls = "";
|
||||
string themetype;
|
||||
string layouttype;
|
||||
string containertype;
|
||||
Alias _alias;
|
||||
List<Theme> _themeList;
|
||||
string _name = "";
|
||||
List<Tenant> _tenantList;
|
||||
string _tenant = "";
|
||||
List<Alias> _aliasList;
|
||||
string _urls = "";
|
||||
string _themetype;
|
||||
string _layouttype;
|
||||
string _containertype;
|
||||
|
||||
string createdby;
|
||||
DateTime createdon;
|
||||
string modifiedby;
|
||||
DateTime modifiedon;
|
||||
string deletedby;
|
||||
DateTime? deletedon;
|
||||
string isdeleted;
|
||||
string _createdby;
|
||||
DateTime _createdon;
|
||||
string _modifiedby;
|
||||
DateTime _modifiedon;
|
||||
string _deletedby;
|
||||
DateTime? _deletedon;
|
||||
string _isdeleted;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
Themes = await ThemeService.GetThemesAsync();
|
||||
aliases = await AliasService.GetAliasesAsync();
|
||||
_themeList = await ThemeService.GetThemesAsync();
|
||||
_aliasList = await AliasService.GetAliasesAsync();
|
||||
|
||||
Alias = aliases.Find(item => item.AliasId == Int32.Parse(PageState.QueryString["id"]));
|
||||
Site site = await SiteService.GetSiteAsync(Alias.SiteId, Alias);
|
||||
_alias = _aliasList.Find(item => item.AliasId == Int32.Parse(PageState.QueryString["id"]));
|
||||
Site site = await SiteService.GetSiteAsync(_alias.SiteId, _alias);
|
||||
if (site != null)
|
||||
{
|
||||
name = site.Name;
|
||||
tenants = await TenantService.GetTenantsAsync();
|
||||
tenant = tenants.Find(item => item.TenantId == site.TenantId).Name;
|
||||
foreach (Alias alias in aliases.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
|
||||
_name = site.Name;
|
||||
_tenantList = await TenantService.GetTenantsAsync();
|
||||
_tenant = _tenantList.Find(item => item.TenantId == site.TenantId).Name;
|
||||
foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
|
||||
{
|
||||
urls += alias.Name + "\n";
|
||||
_urls += alias.Name + "\n";
|
||||
}
|
||||
themetype = site.DefaultThemeType;
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(Themes, themetype);
|
||||
layouttype = site.DefaultLayoutType;
|
||||
containertype = site.DefaultContainerType;
|
||||
_themetype = site.DefaultThemeType;
|
||||
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
|
||||
_layouttype = site.DefaultLayoutType;
|
||||
_containertype = site.DefaultContainerType;
|
||||
|
||||
createdby = site.CreatedBy;
|
||||
createdon = site.CreatedOn;
|
||||
modifiedby = site.ModifiedBy;
|
||||
modifiedon = site.ModifiedOn;
|
||||
deletedby = site.DeletedBy;
|
||||
deletedon = site.DeletedOn;
|
||||
isdeleted = site.IsDeleted.ToString();
|
||||
_createdby = site.CreatedBy;
|
||||
_createdon = site.CreatedOn;
|
||||
_modifiedby = site.ModifiedBy;
|
||||
_modifiedon = site.ModifiedOn;
|
||||
_deletedby = site.DeletedBy;
|
||||
_deletedon = site.DeletedOn;
|
||||
_isdeleted = site.IsDeleted.ToString();
|
||||
}
|
||||
|
||||
themes = ThemeService.GetThemeTypes(Themes);
|
||||
containers = ThemeService.GetContainerTypes(Themes);
|
||||
_themes = ThemeService.GetThemeTypes(_themeList);
|
||||
_containers = ThemeService.GetContainerTypes(_themeList);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await Log(Alias, LogLevel.Error, "", ex, "Error Loading Site {SiteId} {Error}", Alias.SiteId, ex.Message);
|
||||
await Log(_alias, LogLevel.Error, "", ex, "Error Loading Site {SiteId} {Error}", _alias.SiteId, ex.Message);
|
||||
AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
@ -174,20 +174,20 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
themetype = (string)e.Value;
|
||||
if (themetype != "")
|
||||
_themetype = (string)e.Value;
|
||||
if (_themetype != "")
|
||||
{
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(Themes, themetype);
|
||||
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
|
||||
}
|
||||
else
|
||||
{
|
||||
panelayouts = new Dictionary<string, string>();
|
||||
_panelayouts = new Dictionary<string, string>();
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", themetype, ex.Message);
|
||||
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", _themetype, ex.Message);
|
||||
AddModuleMessage("Error Loading Pane Layouts For Theme", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
@ -196,33 +196,33 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
if (name != "" && urls != "" && !string.IsNullOrEmpty(themetype) && (panelayouts.Count == 0 || !string.IsNullOrEmpty(layouttype)) && !string.IsNullOrEmpty(containertype))
|
||||
if (_name != "" && _urls != "" && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype))
|
||||
{
|
||||
bool unique = true;
|
||||
foreach (string name in urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
if (aliases.Exists(item => item.Name == name && item.SiteId != Alias.SiteId && item.TenantId != Alias.TenantId))
|
||||
if (_aliasList.Exists(item => item.Name == name && item.SiteId != _alias.SiteId && item.TenantId != _alias.TenantId))
|
||||
{
|
||||
unique = false;
|
||||
}
|
||||
}
|
||||
if (unique)
|
||||
{
|
||||
Site site = await SiteService.GetSiteAsync(Alias.SiteId, Alias);
|
||||
Site site = await SiteService.GetSiteAsync(_alias.SiteId, _alias);
|
||||
if (site != null)
|
||||
{
|
||||
site.Name = name;
|
||||
site.Name = _name;
|
||||
site.LogoFileId = null;
|
||||
site.DefaultThemeType = themetype;
|
||||
site.DefaultLayoutType = (layouttype == null ? "" : layouttype);
|
||||
site.DefaultContainerType = containertype;
|
||||
site.IsDeleted = (isdeleted == null ? true : Boolean.Parse(isdeleted));
|
||||
site.DefaultThemeType = _themetype;
|
||||
site.DefaultLayoutType = _layouttype ?? "";
|
||||
site.DefaultContainerType = _containertype;
|
||||
site.IsDeleted = (_isdeleted == null || Boolean.Parse(_isdeleted));
|
||||
|
||||
site = await SiteService.UpdateSiteAsync(site, Alias);
|
||||
site = await SiteService.UpdateSiteAsync(site, _alias);
|
||||
|
||||
urls = urls.Replace("\n", ",");
|
||||
string[] names = urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (Alias alias in aliases.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
|
||||
_urls = _urls.Replace("\n", ",");
|
||||
string[] names = _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
|
||||
{
|
||||
if (!names.Contains(alias.Name))
|
||||
{
|
||||
|
@ -231,17 +231,19 @@
|
|||
}
|
||||
foreach (string name in names)
|
||||
{
|
||||
if (!aliases.Exists(item => item.Name == name))
|
||||
if (!_aliasList.Exists(item => item.Name == name))
|
||||
{
|
||||
Alias alias = new Alias();
|
||||
alias.Name = name;
|
||||
alias.TenantId = site.TenantId;
|
||||
alias.SiteId = site.SiteId;
|
||||
Alias alias = new Alias
|
||||
{
|
||||
Name = name,
|
||||
TenantId = site.TenantId,
|
||||
SiteId = site.SiteId
|
||||
};
|
||||
await AliasService.AddAliasAsync(alias);
|
||||
}
|
||||
}
|
||||
|
||||
await Log(Alias, LogLevel.Information,PermissionNames.Edit, null, "Site Saved {Site}", site);
|
||||
await Log(_alias, LogLevel.Information,PermissionNames.Edit, null, "Site Saved {Site}", site);
|
||||
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
|
@ -258,7 +260,7 @@
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await Log(Alias, LogLevel.Error, "", ex, "Error Saving Site {SiteId} {Error}", Alias.SiteId, ex.Message);
|
||||
await Log(_alias, LogLevel.Error, "", ex, "Error Saving Site {SiteId} {Error}", _alias.SiteId, ex.Message);
|
||||
AddModuleMessage("Error Saving Site", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
@inject IAliasService AliasService
|
||||
@inject ISiteService SiteService
|
||||
|
||||
@if (sites == null)
|
||||
@if (_sites == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ else
|
|||
{
|
||||
<ActionLink Action="Add" Text="Add Site" />
|
||||
|
||||
<Pager Items="@sites">
|
||||
<Pager Items="@_sites">
|
||||
<Header>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
|
@ -21,7 +21,7 @@ else
|
|||
<Row>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.AliasId.ToString())" /></td>
|
||||
<td><ActionDialog Header="Delete Site" Message="@("Are You Sure You Wish To Delete The " + context.Name + " Site?")" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteSite(context))" /></td>
|
||||
<td><a href="@(scheme + context.Name)">@context.Name</a></td>
|
||||
<td><a href="@(_scheme + context.Name)">@context.Name</a></td>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
||||
|
@ -29,37 +29,37 @@ else
|
|||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
List<Alias> sites;
|
||||
string scheme;
|
||||
List<Alias> _sites;
|
||||
string _scheme;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
Uri uri = new Uri(NavigationManager.Uri);
|
||||
scheme = uri.Scheme + "://";
|
||||
_scheme = uri.Scheme + "://";
|
||||
|
||||
List<Alias> aliases = await AliasService.GetAliasesAsync();
|
||||
sites = new List<Alias>();
|
||||
_sites = new List<Alias>();
|
||||
foreach (Alias alias in aliases)
|
||||
{
|
||||
if (!sites.Exists(item => item.TenantId == alias.TenantId && item.SiteId == alias.SiteId))
|
||||
if (!_sites.Exists(item => item.TenantId == alias.TenantId && item.SiteId == alias.SiteId))
|
||||
{
|
||||
sites.Add(alias);
|
||||
_sites.Add(alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeleteSite(Alias Alias)
|
||||
private async Task DeleteSite(Alias alias)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Alias.SiteId != PageState.Site.SiteId || Alias.TenantId != PageState.Site.TenantId)
|
||||
if (alias.SiteId != PageState.Site.SiteId || alias.TenantId != PageState.Site.TenantId)
|
||||
{
|
||||
await SiteService.DeleteSiteAsync(Alias.SiteId, Alias);
|
||||
await Log(Alias, LogLevel.Information, "", null, "Site Deleted {SiteId}", Alias.SiteId);
|
||||
await SiteService.DeleteSiteAsync(alias.SiteId, alias);
|
||||
await Log(alias, LogLevel.Information, "", null, "Site Deleted {SiteId}", alias.SiteId);
|
||||
List<Alias> aliases = await AliasService.GetAliasesAsync();
|
||||
foreach (Alias alias in aliases.Where(item => item.SiteId == Alias.SiteId && item.TenantId == Alias.TenantId).ToList())
|
||||
foreach (Alias a in aliases.Where(item => item.SiteId == alias.SiteId && item.TenantId == alias.TenantId))
|
||||
{
|
||||
await AliasService.DeleteAliasAsync(alias.AliasId);
|
||||
await AliasService.DeleteAliasAsync(a.AliasId);
|
||||
}
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ else
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await Log(Alias, LogLevel.Error, "", ex, "Error Deleting Site {SiteId} {Error}", Alias.SiteId, ex.Message);
|
||||
await Log(alias, LogLevel.Error, "", ex, "Error Deleting Site {SiteId} {Error}", alias.SiteId, ex.Message);
|
||||
AddModuleMessage("Error Deleting Site", MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@namespace Oqtane.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
|
||||
@if (visible)
|
||||
@if (_visible)
|
||||
{
|
||||
<div class="app-admin-modal">
|
||||
<div class="modal" tabindex="-1" role="dialog">
|
||||
|
@ -26,7 +26,7 @@
|
|||
</div>
|
||||
</div>
|
||||
}
|
||||
@if (authorized)
|
||||
@if (_authorized)
|
||||
{
|
||||
if (Disabled)
|
||||
{
|
||||
|
@ -66,9 +66,9 @@
|
|||
[Parameter]
|
||||
public Action OnClick { get; set; } // required if an Action is specified - executes a method in the calling component
|
||||
|
||||
bool visible = false;
|
||||
bool editmode = true;
|
||||
bool authorized = false;
|
||||
bool _visible = false;
|
||||
bool _editmode = true;
|
||||
bool _authorized = false;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
|
@ -82,15 +82,15 @@
|
|||
}
|
||||
if (!string.IsNullOrEmpty(EditMode))
|
||||
{
|
||||
editmode = bool.Parse(EditMode);
|
||||
_editmode = bool.Parse(EditMode);
|
||||
}
|
||||
authorized = IsAuthorized();
|
||||
_authorized = IsAuthorized();
|
||||
}
|
||||
|
||||
private bool IsAuthorized()
|
||||
{
|
||||
bool authorized = false;
|
||||
if (PageState.EditMode || !editmode)
|
||||
if (PageState.EditMode || !_editmode)
|
||||
{
|
||||
SecurityAccessLevel security = SecurityAccessLevel.Host;
|
||||
if (Security == null)
|
||||
|
@ -135,7 +135,7 @@
|
|||
|
||||
private void DisplayModal()
|
||||
{
|
||||
visible = !visible;
|
||||
_visible = !_visible;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
@inherits ModuleBase
|
||||
@inject IUserService UserService
|
||||
|
||||
@if (authorized)
|
||||
@if (_authorized)
|
||||
{
|
||||
if (Disabled)
|
||||
{
|
||||
<NavLink class="@classname" href="@url" style="@style" disabled>@text</NavLink>
|
||||
<NavLink class="@_classname" href="@_url" style="@_style" disabled>@_text</NavLink>
|
||||
}
|
||||
else
|
||||
{
|
||||
<NavLink class="@classname" href="@url" style="@style">@text</NavLink>
|
||||
<NavLink class="@_classname" href="@_url" style="@_style">@_text</NavLink>
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,50 +39,50 @@
|
|||
[Parameter]
|
||||
public string EditMode { get; set; } // optional - specifies if a user must be in edit mode to see the action - default is true
|
||||
|
||||
string text = "";
|
||||
string url = "";
|
||||
string parameters = "";
|
||||
string classname = "btn btn-primary";
|
||||
string style = "";
|
||||
bool editmode = true;
|
||||
bool authorized = false;
|
||||
string _text = "";
|
||||
string _url = "";
|
||||
string _parameters = "";
|
||||
string _classname = "btn btn-primary";
|
||||
string _style = "";
|
||||
bool _editmode = true;
|
||||
bool _authorized = false;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
text = Action;
|
||||
_text = Action;
|
||||
if (!string.IsNullOrEmpty(Text))
|
||||
{
|
||||
text = Text;
|
||||
_text = Text;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Parameters))
|
||||
{
|
||||
parameters = Parameters;
|
||||
_parameters = Parameters;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Class))
|
||||
{
|
||||
classname = Class;
|
||||
_classname = Class;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Style))
|
||||
{
|
||||
style = Style;
|
||||
_style = Style;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(EditMode))
|
||||
{
|
||||
editmode = bool.Parse(EditMode);
|
||||
_editmode = bool.Parse(EditMode);
|
||||
}
|
||||
|
||||
url = EditUrl(Action, parameters);
|
||||
authorized = IsAuthorized();
|
||||
_url = EditUrl(Action, _parameters);
|
||||
_authorized = IsAuthorized();
|
||||
}
|
||||
|
||||
private bool IsAuthorized()
|
||||
{
|
||||
bool authorized = false;
|
||||
if (PageState.EditMode || !editmode)
|
||||
if (PageState.EditMode || !_editmode)
|
||||
{
|
||||
SecurityAccessLevel security = SecurityAccessLevel.Host;
|
||||
if (Security == null)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
@namespace Oqtane.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
|
||||
@if (text != "")
|
||||
@if (_text != "")
|
||||
{
|
||||
@((MarkupString)@text)
|
||||
@((MarkupString)_text)
|
||||
}
|
||||
|
||||
@code {
|
||||
|
@ -31,51 +31,51 @@
|
|||
[Parameter]
|
||||
public string Style { get; set; }
|
||||
|
||||
string text = "";
|
||||
string _text = "";
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
text = "";
|
||||
_text = "";
|
||||
if (!String.IsNullOrEmpty(CreatedBy) || CreatedOn != null)
|
||||
{
|
||||
text += "<p style=\"" + Style + "\">Created ";
|
||||
_text += "<p style=\"" + Style + "\">Created ";
|
||||
if (!String.IsNullOrEmpty(CreatedBy))
|
||||
{
|
||||
text += " by <b>" + CreatedBy + "</b>";
|
||||
_text += " by <b>" + CreatedBy + "</b>";
|
||||
}
|
||||
if (CreatedOn != null)
|
||||
{
|
||||
text += " on <b>" + CreatedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
||||
_text += " on <b>" + CreatedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
||||
}
|
||||
text += "</p>";
|
||||
_text += "</p>";
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(ModifiedBy) || ModifiedOn != null)
|
||||
{
|
||||
text += "<p style=\"" + Style + "\">Last modified ";
|
||||
_text += "<p style=\"" + Style + "\">Last modified ";
|
||||
if (!String.IsNullOrEmpty(ModifiedBy))
|
||||
{
|
||||
text += " by <b>" + ModifiedBy + "</b>";
|
||||
_text += " by <b>" + ModifiedBy + "</b>";
|
||||
}
|
||||
if (ModifiedOn != null)
|
||||
{
|
||||
text += " on <b>" + ModifiedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
||||
_text += " on <b>" + ModifiedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
||||
}
|
||||
text += "</p>";
|
||||
_text += "</p>";
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(DeletedBy) || DeletedOn.HasValue)
|
||||
{
|
||||
text += "<p style=\"" + Style + "\">Deleted ";
|
||||
_text += "<p style=\"" + Style + "\">Deleted ";
|
||||
if (!String.IsNullOrEmpty(DeletedBy))
|
||||
{
|
||||
text += " by <b>" + DeletedBy + "</b>";
|
||||
_text += " by <b>" + DeletedBy + "</b>";
|
||||
}
|
||||
if (DeletedOn != null)
|
||||
{
|
||||
text += " on <b>" + DeletedOn.Value.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
||||
_text += " on <b>" + DeletedOn.Value.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
||||
}
|
||||
text += "</p>";
|
||||
_text += "</p>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
@inherits ModuleBase
|
||||
@inject IFolderService FolderService
|
||||
@inject IFileService FileService
|
||||
@inject IJSRuntime jsRuntime
|
||||
@inject IJSRuntime JsRuntime
|
||||
|
||||
@if (folders != null)
|
||||
@if (_folders != null)
|
||||
{
|
||||
<div class="container-fluid px-0">
|
||||
<div class="row">
|
||||
|
@ -15,9 +15,9 @@
|
|||
{
|
||||
<option value="-1"><Select Folder></option>
|
||||
}
|
||||
@foreach (Folder folder in folders)
|
||||
@foreach (Folder folder in _folders)
|
||||
{
|
||||
if (folder.FolderId == folderid)
|
||||
if (folder.FolderId == _folderid)
|
||||
{
|
||||
<option value="@(folder.FolderId)" selected>@(new string('-', folder.Level * 2))@(folder.Name)</option>
|
||||
}
|
||||
|
@ -28,14 +28,14 @@
|
|||
}
|
||||
</select>
|
||||
</div>
|
||||
@if (showfiles)
|
||||
@if (_showfiles)
|
||||
{
|
||||
<div>
|
||||
<select class="form-control" @onchange="(e => FileChanged(e))">
|
||||
<option value="-1"><Select File></option>
|
||||
@foreach (File file in files)
|
||||
@foreach (File file in _files)
|
||||
{
|
||||
if (file.FileId == fileid)
|
||||
if (file.FileId == _fileid)
|
||||
{
|
||||
<option value="@(file.FileId)" selected>@(file.Name)</option>
|
||||
}
|
||||
|
@ -47,33 +47,33 @@
|
|||
</select>
|
||||
</div>
|
||||
}
|
||||
@if (haseditpermission)
|
||||
@if (_haseditpermission)
|
||||
{
|
||||
<div>
|
||||
@if (uploadmultiple)
|
||||
@if (_uploadmultiple)
|
||||
{
|
||||
<input type="file" id="@fileinputid" name="file" accept="@filter" multiple />
|
||||
<input type="file" id="@_fileinputid" name="file" accept="@_filter" multiple />
|
||||
}
|
||||
else
|
||||
{
|
||||
<input type="file" id="@fileinputid" name="file" accept="@filter" />
|
||||
<input type="file" id="@_fileinputid" name="file" accept="@_filter" />
|
||||
}
|
||||
<span id="@progressinfoid"></span><progress id="@progressbarid" style="width: 150px; visibility: hidden;"></progress>
|
||||
<span id="@_progressinfoid"></span><progress id="@_progressbarid" style="width: 150px; visibility: hidden;"></progress>
|
||||
<span class="float-right">
|
||||
<button type="button" class="btn btn-success" @onclick="UploadFile">Upload</button>
|
||||
@if (showfiles && GetFileId() != -1)
|
||||
@if (_showfiles && GetFileId() != -1)
|
||||
{
|
||||
<button type="button" class="btn btn-danger" @onclick="DeleteFile">Delete</button>
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
@((MarkupString)@message)
|
||||
@((MarkupString)_message)
|
||||
}
|
||||
</div>
|
||||
@if (@image != "")
|
||||
@if (_image != "")
|
||||
{
|
||||
<div class="col-auto">
|
||||
@((MarkupString)@image)
|
||||
@((MarkupString)_image)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
@ -99,143 +99,142 @@
|
|||
[Parameter]
|
||||
public string UploadMultiple { get; set; } // optional - enable multiple file uploads - default false
|
||||
|
||||
string id;
|
||||
List<Folder> folders;
|
||||
int folderid = -1;
|
||||
List<File> files = new List<File>();
|
||||
int fileid = -1;
|
||||
bool showfiles = true;
|
||||
string fileinputid = "";
|
||||
string progressinfoid = "";
|
||||
string progressbarid = "";
|
||||
string filter = "*";
|
||||
bool uploadmultiple = false;
|
||||
bool haseditpermission = false;
|
||||
string message = "";
|
||||
string image = "";
|
||||
string _id;
|
||||
List<Folder> _folders;
|
||||
int _folderid = -1;
|
||||
List<File> _files = new List<File>();
|
||||
int _fileid = -1;
|
||||
bool _showfiles = true;
|
||||
string _fileinputid = "";
|
||||
string _progressinfoid = "";
|
||||
string _progressbarid = "";
|
||||
string _filter = "*";
|
||||
bool _uploadmultiple = false;
|
||||
bool _haseditpermission = false;
|
||||
string _message = "";
|
||||
string _image = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Folder))
|
||||
{
|
||||
folders = new List<Folder>();
|
||||
folders.Add(new Folder { FolderId = -1, Name = Folder });
|
||||
folderid = -1;
|
||||
_folders = new List<Folder> {new Folder {FolderId = -1, Name = Folder}};
|
||||
_folderid = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
folders = await FolderService.GetFoldersAsync(ModuleState.SiteId);
|
||||
_folders = await FolderService.GetFoldersAsync(ModuleState.SiteId);
|
||||
if (!string.IsNullOrEmpty(FolderId))
|
||||
{
|
||||
folderid = int.Parse(FolderId);
|
||||
_folderid = int.Parse(FolderId);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(FileId))
|
||||
{
|
||||
fileid = int.Parse(FileId);
|
||||
_fileid = int.Parse(FileId);
|
||||
await SetImage();
|
||||
if (fileid != -1)
|
||||
if (_fileid != -1)
|
||||
{
|
||||
File file = await FileService.GetFileAsync(int.Parse(FileId));
|
||||
if (file != null)
|
||||
{
|
||||
folderid = file.FolderId;
|
||||
_folderid = file.FolderId;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(ShowFiles))
|
||||
{
|
||||
showfiles = bool.Parse(ShowFiles);
|
||||
_showfiles = bool.Parse(ShowFiles);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Filter))
|
||||
{
|
||||
filter = "." + Filter.Replace(",",",.");
|
||||
_filter = "." + Filter.Replace(",",",.");
|
||||
}
|
||||
|
||||
await GetFiles();
|
||||
|
||||
// create unique id for component
|
||||
id = Guid.NewGuid().ToString("N");
|
||||
fileinputid = id + "FileInput";
|
||||
progressinfoid = id + "ProgressInfo";
|
||||
progressbarid = id + "ProgressBar";
|
||||
_id = Guid.NewGuid().ToString("N");
|
||||
_fileinputid = _id + "FileInput";
|
||||
_progressinfoid = _id + "ProgressInfo";
|
||||
_progressbarid = _id + "ProgressBar";
|
||||
|
||||
if (!string.IsNullOrEmpty(UploadMultiple))
|
||||
{
|
||||
uploadmultiple = bool.Parse(UploadMultiple);
|
||||
_uploadmultiple = bool.Parse(UploadMultiple);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task GetFiles()
|
||||
{
|
||||
haseditpermission = false;
|
||||
_haseditpermission = false;
|
||||
if (!string.IsNullOrEmpty(Folder))
|
||||
{
|
||||
haseditpermission = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole);
|
||||
files = await FileService.GetFilesAsync(Folder);
|
||||
_haseditpermission = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole);
|
||||
_files = await FileService.GetFilesAsync(Folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
Folder folder = folders.Where(item => item.FolderId == folderid).FirstOrDefault();
|
||||
Folder folder = _folders.FirstOrDefault(item => item.FolderId == _folderid);
|
||||
if (folder != null)
|
||||
{
|
||||
haseditpermission = UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, folder.Permissions);
|
||||
files = await FileService.GetFilesAsync(folderid);
|
||||
_haseditpermission = UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, folder.Permissions);
|
||||
_files = await FileService.GetFilesAsync(_folderid);
|
||||
}
|
||||
else
|
||||
{
|
||||
haseditpermission = false;
|
||||
files = new List<File>();
|
||||
_haseditpermission = false;
|
||||
_files = new List<File>();
|
||||
}
|
||||
}
|
||||
if (filter != "*")
|
||||
if (_filter != "*")
|
||||
{
|
||||
List<File> filtered = new List<File>();
|
||||
foreach (File file in files)
|
||||
foreach (File file in _files)
|
||||
{
|
||||
if (filter.ToUpper().IndexOf("." + file.Extension.ToUpper()) != -1)
|
||||
if (_filter.ToUpper().IndexOf("." + file.Extension.ToUpper()) != -1)
|
||||
{
|
||||
filtered.Add(file);
|
||||
}
|
||||
}
|
||||
files = filtered;
|
||||
_files = filtered;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task FolderChanged(ChangeEventArgs e)
|
||||
{
|
||||
message = "";
|
||||
_message = "";
|
||||
try
|
||||
{
|
||||
folderid = int.Parse((string)e.Value);
|
||||
_folderid = int.Parse((string)e.Value);
|
||||
await GetFiles();
|
||||
fileid = -1;
|
||||
image = "";
|
||||
_fileid = -1;
|
||||
_image = "";
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Files {Error}", ex.Message);
|
||||
message = "<br /><div class=\"alert alert-danger\" role=\"alert\">Error Loading Files</div>";
|
||||
_message = "<br /><div class=\"alert alert-danger\" role=\"alert\">Error Loading Files</div>";
|
||||
}
|
||||
}
|
||||
|
||||
private async Task FileChanged(ChangeEventArgs e)
|
||||
{
|
||||
message = "";
|
||||
fileid = int.Parse((string)e.Value);
|
||||
_message = "";
|
||||
_fileid = int.Parse((string)e.Value);
|
||||
await SetImage();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task SetImage()
|
||||
{
|
||||
image = "";
|
||||
if (fileid != -1)
|
||||
_image = "";
|
||||
if (_fileid != -1)
|
||||
{
|
||||
File file = await FileService.GetFileAsync(fileid);
|
||||
File file = await FileService.GetFileAsync(_fileid);
|
||||
if (file.ImageHeight != 0 && file.ImageWidth != 0)
|
||||
{
|
||||
int maxwidth = 200;
|
||||
|
@ -245,7 +244,7 @@
|
|||
double ratioY = (double)maxheight / (double)file.ImageHeight;
|
||||
double ratio = ratioX < ratioY ? ratioX : ratioY;
|
||||
|
||||
image = "<img src=\"" + ContentUrl(fileid) + "\" alt=\"" + file.Name +
|
||||
_image = "<img src=\"" + ContentUrl(_fileid) + "\" alt=\"" + file.Name +
|
||||
"\" width=\"" + Convert.ToInt32(file.ImageWidth * ratio).ToString() +
|
||||
"\" height=\"" + Convert.ToInt32(file.ImageHeight * ratio).ToString() + "\" />";
|
||||
}
|
||||
|
@ -254,8 +253,8 @@
|
|||
|
||||
private async Task UploadFile()
|
||||
{
|
||||
var interop = new Interop(jsRuntime);
|
||||
string[] upload = await interop.GetFiles(fileinputid);
|
||||
var interop = new Interop(JsRuntime);
|
||||
string[] upload = await interop.GetFiles(_fileinputid);
|
||||
if (upload.Length > 0)
|
||||
{
|
||||
try
|
||||
|
@ -263,23 +262,23 @@
|
|||
string result;
|
||||
if (!string.IsNullOrEmpty(Folder))
|
||||
{
|
||||
result = await FileService.UploadFilesAsync(Folder, upload, id);
|
||||
result = await FileService.UploadFilesAsync(Folder, upload, _id);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await FileService.UploadFilesAsync(folderid, upload, id);
|
||||
result = await FileService.UploadFilesAsync(_folderid, upload, _id);
|
||||
}
|
||||
if (result == "")
|
||||
{
|
||||
await logger.LogInformation("File Upload Succeeded {Files}", upload);
|
||||
message = "<br /><div class=\"alert alert-success\" role=\"alert\">File Upload Succeeded</div>";
|
||||
_message = "<br /><div class=\"alert alert-success\" role=\"alert\">File Upload Succeeded</div>";
|
||||
await GetFiles();
|
||||
if (upload.Length == 1)
|
||||
{
|
||||
File file = files.Where(item => item.Name == upload[0]).FirstOrDefault();
|
||||
File file = _files.Where(item => item.Name == upload[0]).FirstOrDefault();
|
||||
if (file != null)
|
||||
{
|
||||
fileid = file.FileId;
|
||||
_fileid = file.FileId;
|
||||
await SetImage();
|
||||
}
|
||||
}
|
||||
|
@ -288,44 +287,44 @@
|
|||
else
|
||||
{
|
||||
await logger.LogError("File Upload Failed For {Files}", result.Replace(",", ", "));
|
||||
message = "<br /><div class=\"alert alert-danger\" role=\"alert\">File Upload Failed</div>";
|
||||
_message = "<br /><div class=\"alert alert-danger\" role=\"alert\">File Upload Failed</div>";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "File Upload Failed {Error}", ex.Message);
|
||||
message = "<br /><div class=\"alert alert-danger\" role=\"alert\">File Upload Failed</div>";
|
||||
_message = "<br /><div class=\"alert alert-danger\" role=\"alert\">File Upload Failed</div>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "<br /><div class=\"alert alert-warning\" role=\"alert\">You Have Not Selected A File To Upload</div>";
|
||||
_message = "<br /><div class=\"alert alert-warning\" role=\"alert\">You Have Not Selected A File To Upload</div>";
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeleteFile()
|
||||
{
|
||||
message = "";
|
||||
_message = "";
|
||||
try
|
||||
{
|
||||
await FileService.DeleteFileAsync(fileid);
|
||||
await logger.LogInformation("File Deleted {File}", fileid);
|
||||
message = "<br /><div class=\"alert alert-success\" role=\"alert\">File Deleted</div>";
|
||||
await FileService.DeleteFileAsync(_fileid);
|
||||
await logger.LogInformation("File Deleted {File}", _fileid);
|
||||
_message = "<br /><div class=\"alert alert-success\" role=\"alert\">File Deleted</div>";
|
||||
await GetFiles();
|
||||
fileid = -1;
|
||||
_fileid = -1;
|
||||
await SetImage();
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Deleting File {File} {Error}", fileid, ex.Message);
|
||||
message = "<br /><div class=\"alert alert-danger\" role=\"alert\">Error Deleting File</div>";
|
||||
await logger.LogError(ex, "Error Deleting File {File} {Error}", _fileid, ex.Message);
|
||||
_message = "<br /><div class=\"alert alert-danger\" role=\"alert\">Error Deleting File</div>";
|
||||
}
|
||||
}
|
||||
|
||||
public int GetFileId()
|
||||
{
|
||||
return fileid;
|
||||
return _fileid;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@namespace Oqtane.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@typeparam TableItem
|
||||
@typeparam TAbleItem
|
||||
|
||||
<p>
|
||||
@if(Format == "Table")
|
||||
|
@ -36,40 +36,40 @@
|
|||
</div>
|
||||
}
|
||||
<div class="mx-auto text-center">
|
||||
@if (Page > MaxPages)
|
||||
@if (_page > _maxPages)
|
||||
{
|
||||
<button class="btn btn-secondary" @onclick=@(async () => SetPagerSize("back"))><span class="oi oi-media-skip-backward" title="back" aria-hidden="true"></span></button>
|
||||
}
|
||||
@if (EndPage > 1)
|
||||
@if (_endPage > 1)
|
||||
{
|
||||
<button class="btn btn-secondary" @onclick=@(async () => NavigateToPage("previous"))><span class="oi oi-chevron-left" title="previous" aria-hidden="true"></span></button>
|
||||
@for (int i = StartPage; i <= EndPage; i++)
|
||||
@for (int i = _startPage; i <= _endPage; i++)
|
||||
{
|
||||
var pager = i;
|
||||
<button class="btn @((pager == Page) ? "btn-primary" : "btn-link")" @onclick=@(async () => UpdateList(pager))>
|
||||
<button class="btn @((pager == _page) ? "btn-primary" : "btn-link")" @onclick=@(async () => UpdateList(pager))>
|
||||
@pager
|
||||
</button>
|
||||
}
|
||||
<button class="btn btn-secondary" @onclick=@(async () => NavigateToPage("next"))><span class="oi oi-chevron-right" title="next" aria-hidden="true"></span></button>
|
||||
}
|
||||
@if (EndPage < Pages)
|
||||
@if (_endPage < _pages)
|
||||
{
|
||||
<button class="btn btn-secondary" @onclick=@(async () => SetPagerSize("forward"))><span class="oi oi-media-skip-forward" title="forward" aria-hidden="true"></span></button>
|
||||
}
|
||||
@if (EndPage > 1)
|
||||
@if (_endPage > 1)
|
||||
{
|
||||
<span class="btn btn-link disabled">Page @Page of @Pages</span>
|
||||
<span class="btn btn-link disabled">Page @_page of @_pages</span>
|
||||
}
|
||||
</div>
|
||||
</p>
|
||||
|
||||
@code {
|
||||
int Pages = 0;
|
||||
int Page = 1;
|
||||
int MaxItems;
|
||||
int MaxPages;
|
||||
int StartPage;
|
||||
int EndPage;
|
||||
int _pages = 0;
|
||||
int _page = 1;
|
||||
int _maxItems;
|
||||
int _maxPages;
|
||||
int _startPage;
|
||||
int _endPage;
|
||||
|
||||
[Parameter]
|
||||
public string Format { get; set; }
|
||||
|
@ -78,13 +78,13 @@
|
|||
public RenderFragment Header { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public RenderFragment<TableItem> Row { get; set; }
|
||||
public RenderFragment<TAbleItem> Row { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public RenderFragment<TableItem> Detail { get; set; }
|
||||
public RenderFragment<TAbleItem> Detail { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public IEnumerable<TableItem> Items { get; set; }
|
||||
public IEnumerable<TAbleItem> Items { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string PageSize { get; set; }
|
||||
|
@ -95,7 +95,7 @@
|
|||
[Parameter]
|
||||
public string Class { get; set; }
|
||||
|
||||
IEnumerable<TableItem> ItemList { get; set; }
|
||||
IEnumerable<TAbleItem> ItemList { get; set; }
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
|
@ -116,34 +116,34 @@
|
|||
}
|
||||
if (string.IsNullOrEmpty(PageSize))
|
||||
{
|
||||
MaxItems = 10;
|
||||
_maxItems = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
MaxItems = int.Parse(PageSize);
|
||||
_maxItems = int.Parse(PageSize);
|
||||
}
|
||||
if (string.IsNullOrEmpty(DisplayPages))
|
||||
{
|
||||
MaxPages = 5;
|
||||
_maxPages = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
MaxPages = int.Parse(DisplayPages);
|
||||
_maxPages = int.Parse(DisplayPages);
|
||||
}
|
||||
|
||||
if (Items != null)
|
||||
{
|
||||
ItemList = Items.Skip((Page - 1) * MaxItems).Take(MaxItems);
|
||||
Pages = (int)Math.Ceiling(Items.Count() / (decimal)MaxItems);
|
||||
ItemList = Items.Skip((_page - 1) * _maxItems).Take(_maxItems);
|
||||
_pages = (int)Math.Ceiling(Items.Count() / (decimal)_maxItems);
|
||||
}
|
||||
|
||||
SetPagerSize("forward");
|
||||
}
|
||||
|
||||
public void UpdateList(int CurrentPage)
|
||||
public void UpdateList(int currentPage)
|
||||
{
|
||||
ItemList = Items.Skip((CurrentPage - 1) * MaxItems).Take(MaxItems);
|
||||
Page = CurrentPage;
|
||||
ItemList = Items.Skip((currentPage - 1) * _maxItems).Take(_maxItems);
|
||||
_page = currentPage;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
|
@ -151,29 +151,29 @@
|
|||
{
|
||||
if (direction == "forward")
|
||||
{
|
||||
if (EndPage + 1 < Pages)
|
||||
if (_endPage + 1 < _pages)
|
||||
{
|
||||
StartPage = EndPage + 1;
|
||||
_startPage = _endPage + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
StartPage = 1;
|
||||
_startPage = 1;
|
||||
}
|
||||
|
||||
if (EndPage + MaxPages < Pages)
|
||||
if (_endPage + _maxPages < _pages)
|
||||
{
|
||||
EndPage = StartPage + MaxPages - 1;
|
||||
_endPage = _startPage + _maxPages - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
EndPage = Pages;
|
||||
_endPage = _pages;
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
else if (direction == "back")
|
||||
{
|
||||
EndPage = StartPage - 1;
|
||||
StartPage = StartPage - MaxPages;
|
||||
_endPage = _startPage - 1;
|
||||
_startPage = _startPage - _maxPages;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,26 +181,26 @@
|
|||
{
|
||||
if (direction == "next")
|
||||
{
|
||||
if (Page < Pages)
|
||||
if (_page < _pages)
|
||||
{
|
||||
if (Page == EndPage)
|
||||
if (_page == _endPage)
|
||||
{
|
||||
SetPagerSize("forward");
|
||||
}
|
||||
Page += 1;
|
||||
_page += 1;
|
||||
}
|
||||
}
|
||||
else if (direction == "previous")
|
||||
{
|
||||
if (Page > 1)
|
||||
if (_page > 1)
|
||||
{
|
||||
if (Page == StartPage)
|
||||
if (_page == _startPage)
|
||||
{
|
||||
SetPagerSize("back");
|
||||
}
|
||||
Page -= 1;
|
||||
_page -= 1;
|
||||
}
|
||||
}
|
||||
UpdateList(Page);
|
||||
UpdateList(_page);
|
||||
}
|
||||
}
|
|
@ -3,23 +3,23 @@
|
|||
@inject IRoleService RoleService
|
||||
@inject IUserService UserService
|
||||
|
||||
@if (permissions != null)
|
||||
@if (_permissions != null)
|
||||
{
|
||||
<br />
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Role</th>
|
||||
@foreach (PermissionString permission in permissions)
|
||||
@foreach (PermissionString permission in _permissions)
|
||||
{
|
||||
<th style="text-align: center;">@permission.PermissionName @EntityName</th>
|
||||
}
|
||||
</tr>
|
||||
@foreach (Role role in roles)
|
||||
@foreach (Role role in _roles)
|
||||
{
|
||||
<tr>
|
||||
<td>@role.Name</td>
|
||||
@foreach (PermissionString permission in permissions)
|
||||
@foreach (PermissionString permission in _permissions)
|
||||
{
|
||||
var p = permission;
|
||||
<td style="text-align: center;">
|
||||
|
@ -30,25 +30,25 @@
|
|||
}
|
||||
</tbody>
|
||||
</table>
|
||||
@if (@users.Count != 0)
|
||||
@if (_users.Count != 0)
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
@foreach (PermissionString permission in permissions)
|
||||
@foreach (PermissionString permission in _permissions)
|
||||
{
|
||||
<th style="text-align: center;">@permission.PermissionName @EntityName</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (User user in users)
|
||||
@foreach (User user in _users)
|
||||
{
|
||||
string userid = "[" + user.UserId.ToString() + "]";
|
||||
<tr>
|
||||
<td>@user.DisplayName</td>
|
||||
@foreach (PermissionString permission in permissions)
|
||||
@foreach (PermissionString permission in _permissions)
|
||||
{
|
||||
var p = permission;
|
||||
<td style="text-align: center;">
|
||||
|
@ -64,13 +64,13 @@
|
|||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align: right;"><label for="Username" class="control-label">User: </label></td>
|
||||
<td><input type="text" name="Username" class="form-control" placeholder="Enter Username" @bind="@username" /></td>
|
||||
<td><input type="text" name="Username" class="form-control" placeholder="Enter Username" @bind="@_username" /></td>
|
||||
<td style="text-align: left;"><button type="button" class="btn btn-primary" @onclick="AddUser">Add</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br />
|
||||
<ModuleMessage Type="MessageType.Error" Message="@message" />
|
||||
<ModuleMessage Type="MessageType.Error" Message="@_message" />
|
||||
}
|
||||
|
||||
@code {
|
||||
|
@ -83,38 +83,38 @@
|
|||
[Parameter]
|
||||
public string Permissions { get; set; }
|
||||
|
||||
string permissionnames = "";
|
||||
List<Role> roles;
|
||||
List<PermissionString> permissions;
|
||||
List<User> users = new List<User>();
|
||||
string username = "";
|
||||
string message = "";
|
||||
string _permissionnames = "";
|
||||
List<Role> _roles;
|
||||
List<PermissionString> _permissions;
|
||||
List<User> _users = new List<User>();
|
||||
string _username = "";
|
||||
string _message = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (string.IsNullOrEmpty(PermissionNames))
|
||||
{
|
||||
permissionnames = "View,Edit";
|
||||
_permissionnames = "View,Edit";
|
||||
}
|
||||
else
|
||||
{
|
||||
permissionnames = PermissionNames;
|
||||
_permissionnames = PermissionNames;
|
||||
}
|
||||
roles = await RoleService.GetRolesAsync(ModuleState.SiteId);
|
||||
roles.Insert(0, new Role { Name = Constants.AllUsersRole });
|
||||
_roles = await RoleService.GetRolesAsync(ModuleState.SiteId);
|
||||
_roles.Insert(0, new Role { Name = Constants.AllUsersRole });
|
||||
|
||||
if (!string.IsNullOrEmpty(Permissions))
|
||||
{
|
||||
permissions = new List<PermissionString>();
|
||||
foreach (string permissionname in permissionnames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
_permissions = new List<PermissionString>();
|
||||
foreach (string permissionname in _permissionnames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
permissions.Add(new PermissionString { PermissionName = permissionname, Permissions = "" });
|
||||
_permissions.Add(new PermissionString { PermissionName = permissionname, Permissions = "" });
|
||||
}
|
||||
foreach (PermissionString permissionstring in UserSecurity.GetPermissionStrings(Permissions))
|
||||
{
|
||||
if (permissions.Find(item => item.PermissionName == permissionstring.PermissionName) != null)
|
||||
if (_permissions.Find(item => item.PermissionName == permissionstring.PermissionName) != null)
|
||||
{
|
||||
permissions[permissions.FindIndex(item => item.PermissionName == permissionstring.PermissionName)].Permissions = permissionstring.Permissions;
|
||||
_permissions[_permissions.FindIndex(item => item.PermissionName == permissionstring.PermissionName)].Permissions = permissionstring.Permissions;
|
||||
}
|
||||
if (permissionstring.Permissions.Contains("["))
|
||||
{
|
||||
|
@ -123,9 +123,9 @@
|
|||
if (user.Contains("]"))
|
||||
{
|
||||
int userid = int.Parse(user.Substring(0, user.IndexOf("]")));
|
||||
if (users.Where(item => item.UserId == userid).FirstOrDefault() == null)
|
||||
if (_users.Where(item => item.UserId == userid).FirstOrDefault() == null)
|
||||
{
|
||||
users.Add(await UserService.GetUserAsync(userid, ModuleState.SiteId));
|
||||
_users.Add(await UserService.GetUserAsync(userid, ModuleState.SiteId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,15 +134,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
private bool? GetPermissionValue(string Permissions, string SecurityKey)
|
||||
private bool? GetPermissionValue(string permissions, string securityKey)
|
||||
{
|
||||
if ((";" + Permissions + ";").Contains(";" + "!" + SecurityKey + ";"))
|
||||
if ((";" + permissions + ";").Contains(";" + "!" + securityKey + ";"))
|
||||
{
|
||||
return false; // deny permission
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((";" + Permissions + ";").Contains(";" + SecurityKey + ";"))
|
||||
if ((";" + permissions + ";").Contains(";" + securityKey + ";"))
|
||||
{
|
||||
return true; // grant permission
|
||||
}
|
||||
|
@ -153,9 +153,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
private bool GetPermissionDisabled(string RoleName)
|
||||
private bool GetPermissionDisabled(string roleName)
|
||||
{
|
||||
if (RoleName == Constants.AdminRole)
|
||||
if (roleName == Constants.AdminRole)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -167,67 +167,67 @@
|
|||
|
||||
private async Task AddUser()
|
||||
{
|
||||
if (users.Where(item => item.Username == username).FirstOrDefault() == null)
|
||||
if (_users.Where(item => item.Username == _username).FirstOrDefault() == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
User user = await UserService.GetUserAsync(username, ModuleState.SiteId);
|
||||
User user = await UserService.GetUserAsync(_username, ModuleState.SiteId);
|
||||
if (user != null)
|
||||
{
|
||||
users.Add(user);
|
||||
_users.Add(user);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
message = "Username Does Not Exist";
|
||||
_message = "Username Does Not Exist";
|
||||
}
|
||||
}
|
||||
username = "";
|
||||
_username = "";
|
||||
}
|
||||
|
||||
private void PermissionChanged(bool? Value, string PermissionName, string SecurityId)
|
||||
private void PermissionChanged(bool? value, string permissionName, string securityId)
|
||||
{
|
||||
bool? selected = Value;
|
||||
PermissionString permission = permissions.Find(item => item.PermissionName == PermissionName);
|
||||
bool? selected = value;
|
||||
PermissionString permission = _permissions.Find(item => item.PermissionName == permissionName);
|
||||
if (permission != null)
|
||||
{
|
||||
List<string> ids = permission.Permissions.Split(';').ToList();
|
||||
|
||||
ids.Remove(SecurityId); // remove grant permission
|
||||
ids.Remove("!" + SecurityId); // remove deny permission
|
||||
ids.Remove(securityId); // remove grant permission
|
||||
ids.Remove("!" + securityId); // remove deny permission
|
||||
|
||||
switch (selected)
|
||||
{
|
||||
case true:
|
||||
ids.Add(SecurityId); // add grant permission
|
||||
ids.Add(securityId); // add grant permission
|
||||
break;
|
||||
case false:
|
||||
ids.Add("!" + SecurityId); // add deny permission
|
||||
ids.Add("!" + securityId); // add deny permission
|
||||
break;
|
||||
case null:
|
||||
break; // permission not specified
|
||||
}
|
||||
permissions[permissions.FindIndex(item => item.PermissionName == PermissionName)].Permissions = string.Join(";", ids.ToArray());
|
||||
_permissions[_permissions.FindIndex(item => item.PermissionName == permissionName)].Permissions = string.Join(";", ids.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public string GetPermissions()
|
||||
{
|
||||
ValidatePermissions();
|
||||
return UserSecurity.SetPermissionStrings(permissions);
|
||||
return UserSecurity.SetPermissionStrings(_permissions);
|
||||
}
|
||||
|
||||
private void ValidatePermissions()
|
||||
{
|
||||
PermissionString permission;
|
||||
for (int i = 0; i < permissions.Count; i++)
|
||||
for (int i = 0; i < _permissions.Count; i++)
|
||||
{
|
||||
permission = permissions[i];
|
||||
permission = _permissions[i];
|
||||
List<string> ids = permission.Permissions.Split(';').ToList();
|
||||
ids.Remove("!" + Constants.AllUsersRole); // remove deny all users
|
||||
ids.Remove("!" + Constants.RegisteredRole); // remove deny registered users
|
||||
permission.Permissions = string.Join(";", ids.ToArray());
|
||||
permissions[i] = permission;
|
||||
_permissions[i] = permission;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
@namespace Oqtane.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject IJSRuntime JSRuntime
|
||||
@inject IJSRuntime JsRuntime
|
||||
|
||||
@if (filemanagervisible)
|
||||
@if (_filemanagervisible)
|
||||
{
|
||||
<FileManager @ref="filemanager" Filter="@Constants.ImageFiles" />
|
||||
@((MarkupString)@message)
|
||||
<FileManager @ref="_fileManager" Filter="@Constants.ImageFiles" />
|
||||
@((MarkupString)_message)
|
||||
<br />
|
||||
}
|
||||
<div class="row justify-content-center">
|
||||
<button type="button" class="btn btn-success" @onclick="InsertImage">Insert Image</button>
|
||||
@if (filemanagervisible)
|
||||
@if (_filemanagervisible)
|
||||
{
|
||||
@((MarkupString)" ")
|
||||
<button type="button" class="btn btn-secondary" @onclick="CloseFileManager">Close</button>
|
||||
|
@ -18,10 +18,10 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class ="col">
|
||||
<div @ref="@ToolBar">
|
||||
<div @ref="@_toolBar">
|
||||
@ToolbarContent
|
||||
</div>
|
||||
<div @ref="@EditorElement">
|
||||
<div @ref="@_editorElement">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -42,20 +42,20 @@
|
|||
[Parameter]
|
||||
public string DebugLevel { get; set; } = "info";
|
||||
|
||||
private ElementReference EditorElement;
|
||||
private ElementReference ToolBar;
|
||||
bool filemanagervisible = false;
|
||||
FileManager filemanager;
|
||||
string message = "";
|
||||
private ElementReference _editorElement;
|
||||
private ElementReference _toolBar;
|
||||
bool _filemanagervisible = false;
|
||||
FileManager _fileManager;
|
||||
string _message = "";
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
await RichTextEditorInterop.CreateEditor(
|
||||
JSRuntime,
|
||||
EditorElement,
|
||||
ToolBar,
|
||||
JsRuntime,
|
||||
_editorElement,
|
||||
_toolBar,
|
||||
ReadOnly,
|
||||
Placeholder,
|
||||
Theme,
|
||||
|
@ -66,68 +66,68 @@
|
|||
public async Task<string> GetText()
|
||||
{
|
||||
return await RichTextEditorInterop.GetText(
|
||||
JSRuntime,
|
||||
EditorElement);
|
||||
JsRuntime,
|
||||
_editorElement);
|
||||
}
|
||||
|
||||
public async Task<string> GetHTML()
|
||||
public async Task<string> GetHtml()
|
||||
{
|
||||
return await RichTextEditorInterop.GetHTML(
|
||||
JSRuntime,
|
||||
EditorElement);
|
||||
return await RichTextEditorInterop.GetHtml(
|
||||
JsRuntime,
|
||||
_editorElement);
|
||||
}
|
||||
|
||||
public async Task<string> GetContent()
|
||||
{
|
||||
return await RichTextEditorInterop.GetContent(
|
||||
JSRuntime,
|
||||
EditorElement);
|
||||
JsRuntime,
|
||||
_editorElement);
|
||||
}
|
||||
|
||||
public async Task LoadContent(string Content)
|
||||
public async Task LoadContent(string content)
|
||||
{
|
||||
await RichTextEditorInterop.LoadEditorContent(
|
||||
JSRuntime,
|
||||
EditorElement, Content);
|
||||
JsRuntime,
|
||||
_editorElement, content);
|
||||
}
|
||||
|
||||
public async Task EnableEditor(bool mode)
|
||||
{
|
||||
await RichTextEditorInterop.EnableEditor(
|
||||
JSRuntime,
|
||||
EditorElement, mode);
|
||||
JsRuntime,
|
||||
_editorElement, mode);
|
||||
}
|
||||
|
||||
public async Task InsertImage()
|
||||
{
|
||||
if (filemanagervisible)
|
||||
if (_filemanagervisible)
|
||||
{
|
||||
int fileid = filemanager.GetFileId();
|
||||
int fileid = _fileManager.GetFileId();
|
||||
if (fileid != -1)
|
||||
{
|
||||
await RichTextEditorInterop.InsertImage(
|
||||
JSRuntime,
|
||||
EditorElement, ContentUrl(fileid));
|
||||
filemanagervisible = false;
|
||||
message = "";
|
||||
JsRuntime,
|
||||
_editorElement, ContentUrl(fileid));
|
||||
_filemanagervisible = false;
|
||||
_message = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "<br /><div class=\"alert alert-warning\" role=\"alert\">You Must Select An Image To Insert</div>";
|
||||
_message = "<br /><div class=\"alert alert-warning\" role=\"alert\">You Must Select An Image To Insert</div>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
filemanagervisible = true;
|
||||
message = "";
|
||||
_filemanagervisible = true;
|
||||
_message = "";
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
public void CloseFileManager()
|
||||
{
|
||||
filemanagervisible = false;
|
||||
message = "";
|
||||
_filemanagervisible = false;
|
||||
_message = "";
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<CascadingValue Value="this">
|
||||
<div>
|
||||
@foreach (TabPanel tabPanel in TabPanels)
|
||||
@foreach (TabPanel tabPanel in _tabPanels)
|
||||
{
|
||||
<button type="button"
|
||||
class="btn @GetButtonClass(tabPanel)"
|
||||
|
@ -21,12 +21,12 @@
|
|||
public RenderFragment ChildContent { get; set; }
|
||||
|
||||
public TabPanel ActiveTabPanel { get; set; }
|
||||
List<TabPanel> TabPanels = new List<TabPanel>();
|
||||
List<TabPanel> _tabPanels = new List<TabPanel>();
|
||||
|
||||
internal void AddTabPanel(TabPanel tabPanel)
|
||||
{
|
||||
TabPanels.Add(tabPanel);
|
||||
if (TabPanels.Count == 1)
|
||||
_tabPanels.Add(tabPanel);
|
||||
if (_tabPanels.Count == 1)
|
||||
ActiveTabPanel = tabPanel;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@namespace Oqtane.Modules.Controls
|
||||
|
||||
<img src="@src" title="@title" @onclick="SetValue" />
|
||||
<img src="@_src" title="@_title" @onclick="SetValue" />
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
|
@ -12,13 +12,13 @@
|
|||
[Parameter]
|
||||
public Action<bool?> OnChange { get; set; }
|
||||
|
||||
bool? value = null;
|
||||
string title;
|
||||
string src = "";
|
||||
bool? _value = null;
|
||||
string _title;
|
||||
string _src = "";
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
value = Value;
|
||||
_value = Value;
|
||||
SetImage();
|
||||
}
|
||||
|
||||
|
@ -26,38 +26,38 @@
|
|||
{
|
||||
if (!Disabled)
|
||||
{
|
||||
switch (value)
|
||||
switch (_value)
|
||||
{
|
||||
case true:
|
||||
value = false;
|
||||
_value = false;
|
||||
break;
|
||||
case false:
|
||||
value = null;
|
||||
_value = null;
|
||||
break;
|
||||
case null:
|
||||
value = true;
|
||||
_value = true;
|
||||
break;
|
||||
}
|
||||
SetImage();
|
||||
OnChange(value);
|
||||
OnChange(_value);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetImage()
|
||||
{
|
||||
switch (value)
|
||||
switch (_value)
|
||||
{
|
||||
case true:
|
||||
src = "images/checked.png";
|
||||
title = "Permission Granted";
|
||||
_src = "images/checked.png";
|
||||
_title = "Permission Granted";
|
||||
break;
|
||||
case false:
|
||||
src = "images/unchecked.png";
|
||||
title = "Permission Denied";
|
||||
_src = "images/unchecked.png";
|
||||
_title = "Permission Denied";
|
||||
break;
|
||||
case null:
|
||||
src = "images/null.png";
|
||||
title = "";
|
||||
_src = "images/null.png";
|
||||
_title = "";
|
||||
break;
|
||||
}
|
||||
StateHasChanged();
|
||||
|
|
|
@ -158,7 +158,7 @@
|
|||
|
||||
private async Task RawHtmlEditor()
|
||||
{
|
||||
content = await this.RichTextEditorHtml.GetHTML();
|
||||
content = await this.RichTextEditorHtml.GetHtml();
|
||||
RichTextEditorMode = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
@ -167,7 +167,7 @@
|
|||
{
|
||||
if (RichTextEditorMode)
|
||||
{
|
||||
content = await RichTextEditorHtml.GetHTML();
|
||||
content = await RichTextEditorHtml.GetHtml();
|
||||
}
|
||||
|
||||
content = content.Replace(((PageState.Alias.Path == "") ? "/~" : PageState.Alias.Path) + Constants.ContentUrl, Constants.ContentUrl);
|
||||
|
|
|
@ -4,6 +4,7 @@ using Oqtane.Models;
|
|||
using System.Threading.Tasks;
|
||||
using Oqtane.Services;
|
||||
using System;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.UI;
|
||||
|
||||
namespace Oqtane.Modules
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using Microsoft.AspNetCore.Blazor.Hosting;
|
||||
|
||||
namespace Oqtane.Client
|
||||
namespace Oqtane
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Oqtane.Providers
|
|||
identity = new ClaimsIdentity("Identity.Application");
|
||||
identity.AddClaim(new Claim(ClaimTypes.Name, user.Username));
|
||||
identity.AddClaim(new Claim(ClaimTypes.PrimarySid, user.UserId.ToString()));
|
||||
foreach (string role in user.Roles.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
foreach (string role in user.Roles.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
identity.AddClaim(new Claim(ClaimTypes.Role, role));
|
||||
}
|
||||
|
|
|
@ -23,25 +23,25 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Alias"); }
|
||||
}
|
||||
|
||||
public async Task<List<Alias>> GetAliasesAsync()
|
||||
{
|
||||
List<Alias> aliases = await _http.GetJsonAsync<List<Alias>>(apiurl);
|
||||
List<Alias> aliases = await _http.GetJsonAsync<List<Alias>>(Apiurl);
|
||||
return aliases.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Alias> GetAliasAsync(int AliasId)
|
||||
public async Task<Alias> GetAliasAsync(int aliasId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Alias>(apiurl + "/" + AliasId.ToString());
|
||||
return await _http.GetJsonAsync<Alias>(Apiurl + "/" + aliasId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Alias> GetAliasAsync(string Url, DateTime LastSyncDate)
|
||||
public async Task<Alias> GetAliasAsync(string url, DateTime lastSyncDate)
|
||||
{
|
||||
Uri uri = new Uri(Url);
|
||||
Uri uri = new Uri(url);
|
||||
string name = uri.Authority;
|
||||
if (uri.Segments.Count() > 1)
|
||||
{
|
||||
|
@ -51,21 +51,21 @@ namespace Oqtane.Services
|
|||
{
|
||||
name = name.Substring(0, name.Length - 1);
|
||||
}
|
||||
return await _http.GetJsonAsync<Alias>(apiurl + "/name/" + WebUtility.UrlEncode(name) + "?lastsyncdate=" + LastSyncDate.ToString("yyyyMMddHHmmssfff"));
|
||||
return await _http.GetJsonAsync<Alias>(Apiurl + "/name/" + WebUtility.UrlEncode(name) + "?lastsyncdate=" + lastSyncDate.ToString("yyyyMMddHHmmssfff"));
|
||||
}
|
||||
|
||||
public async Task<Alias> AddAliasAsync(Alias alias)
|
||||
{
|
||||
return await _http.PostJsonAsync<Alias>(apiurl, alias);
|
||||
return await _http.PostJsonAsync<Alias>(Apiurl, alias);
|
||||
}
|
||||
|
||||
public async Task<Alias> UpdateAliasAsync(Alias alias)
|
||||
{
|
||||
return await _http.PutJsonAsync<Alias>(apiurl + "/" + alias.AliasId.ToString(), alias);
|
||||
return await _http.PutJsonAsync<Alias>(Apiurl + "/" + alias.AliasId.ToString(), alias);
|
||||
}
|
||||
public async Task DeleteAliasAsync(int AliasId)
|
||||
public async Task DeleteAliasAsync(int aliasId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + AliasId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + aliasId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
|
@ -28,65 +27,65 @@ namespace Oqtane.Services
|
|||
_jsRuntime = jsRuntime;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "File"); }
|
||||
}
|
||||
|
||||
public async Task<List<File>> GetFilesAsync(int FolderId)
|
||||
public async Task<List<File>> GetFilesAsync(int folderId)
|
||||
{
|
||||
return await GetFilesAsync(FolderId.ToString());
|
||||
return await GetFilesAsync(folderId.ToString());
|
||||
}
|
||||
|
||||
public async Task<List<File>> GetFilesAsync(string Folder)
|
||||
public async Task<List<File>> GetFilesAsync(string folder)
|
||||
{
|
||||
return await _http.GetJsonAsync<List<File>>(apiurl + "?folder=" + Folder);
|
||||
return await _http.GetJsonAsync<List<File>>(Apiurl + "?folder=" + folder);
|
||||
}
|
||||
|
||||
public async Task<List<File>> GetFilesAsync(int siteId, string folderPath)
|
||||
{
|
||||
if (!folderPath.EndsWith("\\")) folderPath += "\\";
|
||||
var path = WebUtility.UrlEncode(folderPath);
|
||||
return await _http.GetJsonAsync<List<File>>($"{apiurl}/{siteId}/{path}");
|
||||
return await _http.GetJsonAsync<List<File>>($"{Apiurl}/{siteId}/{path}");
|
||||
}
|
||||
|
||||
public async Task<File> GetFileAsync(int FileId)
|
||||
public async Task<File> GetFileAsync(int fileId)
|
||||
{
|
||||
return await _http.GetJsonAsync<File>(apiurl + "/" + FileId.ToString());
|
||||
return await _http.GetJsonAsync<File>(Apiurl + "/" + fileId.ToString());
|
||||
}
|
||||
|
||||
public async Task<File> AddFileAsync(File File)
|
||||
public async Task<File> AddFileAsync(File file)
|
||||
{
|
||||
return await _http.PostJsonAsync<File>(apiurl, File);
|
||||
return await _http.PostJsonAsync<File>(Apiurl, file);
|
||||
}
|
||||
|
||||
public async Task<File> UpdateFileAsync(File File)
|
||||
public async Task<File> UpdateFileAsync(File file)
|
||||
{
|
||||
return await _http.PutJsonAsync<File>(apiurl + "/" + File.FileId.ToString(), File);
|
||||
return await _http.PutJsonAsync<File>(Apiurl + "/" + file.FileId.ToString(), file);
|
||||
}
|
||||
|
||||
public async Task DeleteFileAsync(int FileId)
|
||||
public async Task DeleteFileAsync(int fileId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + FileId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + fileId.ToString());
|
||||
}
|
||||
|
||||
public async Task<File> UploadFileAsync(string Url, int FolderId)
|
||||
public async Task<File> UploadFileAsync(string url, int folderId)
|
||||
{
|
||||
return await _http.GetJsonAsync<File>(apiurl + "/upload?url=" + WebUtility.UrlEncode(Url) + "&folderid=" +
|
||||
FolderId.ToString());
|
||||
return await _http.GetJsonAsync<File>(Apiurl + "/upload?url=" + WebUtility.UrlEncode(url) + "&folderid=" +
|
||||
folderId.ToString());
|
||||
}
|
||||
|
||||
public async Task<string> UploadFilesAsync(int FolderId, string[] Files, string Id)
|
||||
public async Task<string> UploadFilesAsync(int folderId, string[] files, string id)
|
||||
{
|
||||
return await UploadFilesAsync(FolderId.ToString(), Files, Id);
|
||||
return await UploadFilesAsync(folderId.ToString(), files, id);
|
||||
}
|
||||
|
||||
public async Task<string> UploadFilesAsync(string Folder, string[] Files, string Id)
|
||||
public async Task<string> UploadFilesAsync(string folder, string[] files, string id)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
var interop = new Interop(_jsRuntime);
|
||||
await interop.UploadFiles(apiurl + "/upload", Folder, Id);
|
||||
await interop.UploadFiles(Apiurl + "/upload", folder, id);
|
||||
|
||||
// uploading files is asynchronous so we need to wait for the upload to complete
|
||||
bool success = false;
|
||||
|
@ -96,13 +95,13 @@ namespace Oqtane.Services
|
|||
Thread.Sleep(2000); // wait 2 seconds
|
||||
result = "";
|
||||
|
||||
List<File> files = await GetFilesAsync(Folder);
|
||||
if (files.Count > 0)
|
||||
List<File> fileList = await GetFilesAsync(folder);
|
||||
if (fileList.Count > 0)
|
||||
{
|
||||
success = true;
|
||||
foreach (string file in Files)
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (!files.Exists(item => item.Name == file))
|
||||
if (!fileList.Exists(item => item.Name == file))
|
||||
{
|
||||
success = false;
|
||||
result += file + ",";
|
||||
|
@ -121,9 +120,9 @@ namespace Oqtane.Services
|
|||
return result;
|
||||
}
|
||||
|
||||
public async Task<byte[]> DownloadFileAsync(int FileId)
|
||||
public async Task<byte[]> DownloadFileAsync(int fileId)
|
||||
{
|
||||
return await _http.GetByteArrayAsync(apiurl + "/download/" + FileId.ToString());
|
||||
return await _http.GetByteArrayAsync(Apiurl + "/download/" + fileId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,16 +26,16 @@ namespace Oqtane.Services
|
|||
|
||||
private string ApiUrl => CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Folder");
|
||||
|
||||
public async Task<List<Folder>> GetFoldersAsync(int SiteId)
|
||||
public async Task<List<Folder>> GetFoldersAsync(int siteId)
|
||||
{
|
||||
List<Folder> folders = await _http.GetJsonAsync<List<Folder>>(ApiUrl + "?siteid=" + SiteId.ToString());
|
||||
List<Folder> folders = await _http.GetJsonAsync<List<Folder>>(ApiUrl + "?siteid=" + siteId.ToString());
|
||||
folders = GetFoldersHierarchy(folders);
|
||||
return folders;
|
||||
}
|
||||
|
||||
public async Task<Folder> GetFolderAsync(int FolderId)
|
||||
public async Task<Folder> GetFolderAsync(int folderId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Folder>(ApiUrl + "/" + FolderId.ToString());
|
||||
return await _http.GetJsonAsync<Folder>(ApiUrl + "/" + folderId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Folder> GetFolderAsync(int siteId, [NotNull] string folderPath)
|
||||
|
@ -45,60 +45,61 @@ namespace Oqtane.Services
|
|||
return await _http.GetJsonAsync<Folder>($"{ApiUrl}/{siteId}/{path}");
|
||||
}
|
||||
|
||||
public async Task<Folder> AddFolderAsync(Folder Folder)
|
||||
public async Task<Folder> AddFolderAsync(Folder folder)
|
||||
{
|
||||
return await _http.PostJsonAsync<Folder>(ApiUrl, Folder);
|
||||
return await _http.PostJsonAsync<Folder>(ApiUrl, folder);
|
||||
}
|
||||
|
||||
public async Task<Folder> UpdateFolderAsync(Folder Folder)
|
||||
public async Task<Folder> UpdateFolderAsync(Folder folder)
|
||||
{
|
||||
return await _http.PutJsonAsync<Folder>(ApiUrl + "/" + Folder.FolderId.ToString(), Folder);
|
||||
return await _http.PutJsonAsync<Folder>(ApiUrl + "/" + folder.FolderId.ToString(), folder);
|
||||
}
|
||||
|
||||
public async Task UpdateFolderOrderAsync(int SiteId, int FolderId, int? ParentId)
|
||||
public async Task UpdateFolderOrderAsync(int siteId, int folderId, int? parentId)
|
||||
{
|
||||
await _http.PutJsonAsync(
|
||||
ApiUrl + "/?siteid=" + SiteId.ToString() + "&folderid=" + FolderId.ToString() + "&parentid=" +
|
||||
((ParentId == null) ? "" : ParentId.ToString()), null);
|
||||
ApiUrl + "/?siteid=" + siteId.ToString() + "&folderid=" + folderId.ToString() + "&parentid=" +
|
||||
((parentId == null) ? "" : parentId.ToString()), null);
|
||||
}
|
||||
|
||||
public async Task DeleteFolderAsync(int FolderId)
|
||||
public async Task DeleteFolderAsync(int folderId)
|
||||
{
|
||||
await _http.DeleteAsync(ApiUrl + "/" + FolderId.ToString());
|
||||
await _http.DeleteAsync(ApiUrl + "/" + folderId.ToString());
|
||||
}
|
||||
|
||||
private static List<Folder> GetFoldersHierarchy(List<Folder> Folders)
|
||||
private static List<Folder> GetFoldersHierarchy(List<Folder> folders)
|
||||
{
|
||||
List<Folder> hierarchy = new List<Folder>();
|
||||
Action<List<Folder>, Folder> GetPath = null;
|
||||
GetPath = (List<Folder> folders, Folder folder) =>
|
||||
Action<List<Folder>, Folder> getPath = null;
|
||||
var folders1 = folders;
|
||||
getPath = (folderList, folder) =>
|
||||
{
|
||||
IEnumerable<Folder> children;
|
||||
int level;
|
||||
if (folder == null)
|
||||
{
|
||||
level = -1;
|
||||
children = Folders.Where(item => item.ParentId == null);
|
||||
children = folders1.Where(item => item.ParentId == null);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = folder.Level;
|
||||
children = Folders.Where(item => item.ParentId == folder.FolderId);
|
||||
children = folders1.Where(item => item.ParentId == folder.FolderId);
|
||||
}
|
||||
|
||||
foreach (Folder child in children)
|
||||
{
|
||||
child.Level = level + 1;
|
||||
child.HasChildren = Folders.Any(item => item.ParentId == child.FolderId);
|
||||
child.HasChildren = folders1.Any(item => item.ParentId == child.FolderId);
|
||||
hierarchy.Add(child);
|
||||
GetPath(folders, child);
|
||||
if (getPath != null) getPath(folderList, child);
|
||||
}
|
||||
};
|
||||
Folders = Folders.OrderBy(item => item.Order).ToList();
|
||||
GetPath(Folders, null);
|
||||
folders = folders.OrderBy(item => item.Order).ToList();
|
||||
getPath(folders, null);
|
||||
|
||||
// add any non-hierarchical items to the end of the list
|
||||
foreach (Folder folder in Folders)
|
||||
foreach (Folder folder in folders)
|
||||
{
|
||||
if (hierarchy.Find(item => item.FolderId == folder.FolderId) == null)
|
||||
{
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
using Oqtane.Models;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Services
|
||||
|
@ -21,24 +19,24 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Installation"); }
|
||||
}
|
||||
|
||||
public async Task<GenericResponse> IsInstalled()
|
||||
{
|
||||
return await _http.GetJsonAsync<GenericResponse>(apiurl + "/installed");
|
||||
return await _http.GetJsonAsync<GenericResponse>(Apiurl + "/installed");
|
||||
}
|
||||
|
||||
public async Task<GenericResponse> Install(string connectionstring)
|
||||
{
|
||||
return await _http.PostJsonAsync<GenericResponse>(apiurl, connectionstring);
|
||||
return await _http.PostJsonAsync<GenericResponse>(Apiurl, connectionstring);
|
||||
}
|
||||
|
||||
public async Task<GenericResponse> Upgrade()
|
||||
{
|
||||
return await _http.GetJsonAsync<GenericResponse>(apiurl + "/upgrade");
|
||||
return await _http.GetJsonAsync<GenericResponse>(Apiurl + "/upgrade");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,14 @@ namespace Oqtane.Services
|
|||
{
|
||||
Task<List<Alias>> GetAliasesAsync();
|
||||
|
||||
Task<Alias> GetAliasAsync(int AliasId);
|
||||
Task<Alias> GetAliasAsync(int aliasId);
|
||||
|
||||
Task<Alias> GetAliasAsync(string Url, DateTime LastSyncDate);
|
||||
Task<Alias> GetAliasAsync(string url, DateTime lastSyncDate);
|
||||
|
||||
Task<Alias> AddAliasAsync(Alias Alias);
|
||||
Task<Alias> AddAliasAsync(Alias alias);
|
||||
|
||||
Task<Alias> UpdateAliasAsync(Alias Alias);
|
||||
Task<Alias> UpdateAliasAsync(Alias alias);
|
||||
|
||||
Task DeleteAliasAsync(int AliasId);
|
||||
Task DeleteAliasAsync(int aliasId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,16 +6,16 @@ namespace Oqtane.Services
|
|||
{
|
||||
public interface IFileService
|
||||
{
|
||||
Task<List<File>> GetFilesAsync(int FolderId);
|
||||
Task<List<File>> GetFilesAsync(string Folder);
|
||||
Task<File> GetFileAsync(int FileId);
|
||||
Task<File> AddFileAsync(File File);
|
||||
Task<File> UpdateFileAsync(File File);
|
||||
Task DeleteFileAsync(int FileId);
|
||||
Task<File> UploadFileAsync(string Url, int FolderId);
|
||||
Task<string> UploadFilesAsync(int FolderId, string[] Files, string FileUploadName);
|
||||
Task<string> UploadFilesAsync(string Folder, string[] Files, string FileUploadName);
|
||||
Task<byte[]> DownloadFileAsync(int FileId);
|
||||
Task<List<File>> GetFilesAsync(int folderId);
|
||||
Task<List<File>> GetFilesAsync(string folder);
|
||||
Task<File> GetFileAsync(int fileId);
|
||||
Task<File> AddFileAsync(File file);
|
||||
Task<File> UpdateFileAsync(File file);
|
||||
Task DeleteFileAsync(int fileId);
|
||||
Task<File> UploadFileAsync(string url, int folderId);
|
||||
Task<string> UploadFilesAsync(int folderId, string[] files, string fileUploadName);
|
||||
Task<string> UploadFilesAsync(string folder, string[] files, string fileUploadName);
|
||||
Task<byte[]> DownloadFileAsync(int fileId);
|
||||
|
||||
Task<List<File>> GetFilesAsync(int siteId, string folderPath);
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@ namespace Oqtane.Services
|
|||
{
|
||||
public interface IFolderService
|
||||
{
|
||||
Task<List<Folder>> GetFoldersAsync(int SiteId);
|
||||
Task<Folder> GetFolderAsync(int FolderId);
|
||||
Task<Folder> AddFolderAsync(Folder Folder);
|
||||
Task<Folder> UpdateFolderAsync(Folder Folder);
|
||||
Task UpdateFolderOrderAsync(int SiteId, int FolderId, int? ParentId);
|
||||
Task DeleteFolderAsync(int FolderId);
|
||||
Task<List<Folder>> GetFoldersAsync(int siteId);
|
||||
Task<Folder> GetFolderAsync(int folderId);
|
||||
Task<Folder> AddFolderAsync(Folder folder);
|
||||
Task<Folder> UpdateFolderAsync(Folder folder);
|
||||
Task UpdateFolderOrderAsync(int siteId, int folderId, int? parentId);
|
||||
Task DeleteFolderAsync(int folderId);
|
||||
Task<Folder> GetFolderAsync(int siteId, [NotNull]string folderPath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,12 @@ namespace Oqtane.Services
|
|||
{
|
||||
Task<List<JobLog>> GetJobLogsAsync();
|
||||
|
||||
Task<JobLog> GetJobLogAsync(int JobLogId);
|
||||
Task<JobLog> GetJobLogAsync(int jobLogId);
|
||||
|
||||
Task<JobLog> AddJobLogAsync(JobLog JobLog);
|
||||
Task<JobLog> AddJobLogAsync(JobLog jobLog);
|
||||
|
||||
Task<JobLog> UpdateJobLogAsync(JobLog JobLog);
|
||||
Task<JobLog> UpdateJobLogAsync(JobLog jobLog);
|
||||
|
||||
Task DeleteJobLogAsync(int JobLogId);
|
||||
Task DeleteJobLogAsync(int jobLogId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,16 +8,16 @@ namespace Oqtane.Services
|
|||
{
|
||||
Task<List<Job>> GetJobsAsync();
|
||||
|
||||
Task<Job> GetJobAsync(int JobId);
|
||||
Task<Job> GetJobAsync(int jobId);
|
||||
|
||||
Task<Job> AddJobAsync(Job Job);
|
||||
Task<Job> AddJobAsync(Job job);
|
||||
|
||||
Task<Job> UpdateJobAsync(Job Job);
|
||||
Task<Job> UpdateJobAsync(Job job);
|
||||
|
||||
Task DeleteJobAsync(int JobId);
|
||||
Task DeleteJobAsync(int jobId);
|
||||
|
||||
Task StartJobAsync(int JobId);
|
||||
Task StartJobAsync(int jobId);
|
||||
|
||||
Task StopJobAsync(int JobId);
|
||||
Task StopJobAsync(int jobId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,15 @@ using Oqtane.Shared;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Oqtane.Enums;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface ILogService
|
||||
{
|
||||
Task<List<Log>> GetLogsAsync(int SiteId, string Level, string Function, int Rows);
|
||||
Task<Log> GetLogAsync(int LogId);
|
||||
Task Log(int? PageId, int? ModuleId, int? UserId, string category, string feature, LogFunction function, LogLevel level, Exception exception, string message, params object[] args);
|
||||
Task Log(Alias Alias, int? PageId, int? ModuleId, int? UserId, string category, string feature, LogFunction function, LogLevel level, Exception exception, string message, params object[] args);
|
||||
Task<List<Log>> GetLogsAsync(int siteId, string level, string function, int rows);
|
||||
Task<Log> GetLogAsync(int logId);
|
||||
Task Log(int? pageId, int? moduleId, int? userId, string category, string feature, LogFunction function, LogLevel level, Exception exception, string message, params object[] args);
|
||||
Task Log(Alias alias, int? pageId, int? moduleId, int? userId, string category, string feature, LogFunction function, LogLevel level, Exception exception, string message, params object[] args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ namespace Oqtane.Services
|
|||
{
|
||||
public interface IModuleDefinitionService
|
||||
{
|
||||
Task<List<ModuleDefinition>> GetModuleDefinitionsAsync(int SiteId);
|
||||
Task<ModuleDefinition> GetModuleDefinitionAsync(int ModuleDefinitionId, int SiteId);
|
||||
Task UpdateModuleDefinitionAsync(ModuleDefinition ModuleDefinition);
|
||||
Task<List<ModuleDefinition>> GetModuleDefinitionsAsync(int siteId);
|
||||
Task<ModuleDefinition> GetModuleDefinitionAsync(int moduleDefinitionId, int siteId);
|
||||
Task UpdateModuleDefinitionAsync(ModuleDefinition moduleDefinition);
|
||||
Task InstallModuleDefinitionsAsync();
|
||||
Task DeleteModuleDefinitionAsync(int ModuleDefinitionId, int SiteId);
|
||||
Task LoadModuleDefinitionsAsync(int SiteId);
|
||||
Task DeleteModuleDefinitionAsync(int moduleDefinitionId, int siteId);
|
||||
Task LoadModuleDefinitionsAsync(int siteId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@ namespace Oqtane.Services
|
|||
{
|
||||
public interface IModuleService
|
||||
{
|
||||
Task<List<Module>> GetModulesAsync(int SiteId);
|
||||
Task<Module> GetModuleAsync(int ModuleId);
|
||||
Task<Module> AddModuleAsync(Module Module);
|
||||
Task<Module> UpdateModuleAsync(Module Module);
|
||||
Task DeleteModuleAsync(int ModuleId);
|
||||
Task<bool> ImportModuleAsync(int ModuleId, string Content);
|
||||
Task<string> ExportModuleAsync(int ModuleId);
|
||||
Task<List<Module>> GetModulesAsync(int siteId);
|
||||
Task<Module> GetModuleAsync(int moduleId);
|
||||
Task<Module> AddModuleAsync(Module module);
|
||||
Task<Module> UpdateModuleAsync(Module module);
|
||||
Task DeleteModuleAsync(int moduleId);
|
||||
Task<bool> ImportModuleAsync(int moduleId, string content);
|
||||
Task<string> ExportModuleAsync(int moduleId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ namespace Oqtane.Services
|
|||
{
|
||||
public interface INotificationService
|
||||
{
|
||||
Task<List<Notification>> GetNotificationsAsync(int SiteId, string Direction, int UserId);
|
||||
Task<List<Notification>> GetNotificationsAsync(int siteId, string direction, int userId);
|
||||
|
||||
Task<Notification> GetNotificationAsync(int NotificationId);
|
||||
Task<Notification> GetNotificationAsync(int notificationId);
|
||||
|
||||
Task<Notification> AddNotificationAsync(Notification Notification);
|
||||
Task<Notification> AddNotificationAsync(Notification notification);
|
||||
|
||||
Task<Notification> UpdateNotificationAsync(Notification Notification);
|
||||
Task<Notification> UpdateNotificationAsync(Notification notification);
|
||||
|
||||
Task DeleteNotificationAsync(int NotificationId);
|
||||
Task DeleteNotificationAsync(int notificationId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Oqtane.Services
|
|||
{
|
||||
public interface IPackageService
|
||||
{
|
||||
Task<List<Package>> GetPackagesAsync(string Tag);
|
||||
Task DownloadPackageAsync(string PackageId, string Version, string Folder);
|
||||
Task<List<Package>> GetPackagesAsync(string tag);
|
||||
Task DownloadPackageAsync(string packageId, string version, string folder);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface IPageModuleService
|
||||
{
|
||||
Task<PageModule> GetPageModuleAsync(int PageModuleId);
|
||||
Task<PageModule> GetPageModuleAsync(int PageId, int ModuleId);
|
||||
Task<PageModule> AddPageModuleAsync(PageModule PageModule);
|
||||
Task<PageModule> UpdatePageModuleAsync(PageModule PageModule);
|
||||
Task UpdatePageModuleOrderAsync(int PageId, string Pane);
|
||||
Task DeletePageModuleAsync(int PageModuleId);
|
||||
Task<PageModule> GetPageModuleAsync(int pageModuleId);
|
||||
Task<PageModule> GetPageModuleAsync(int pageId, int moduleId);
|
||||
Task<PageModule> AddPageModuleAsync(PageModule pageModule);
|
||||
Task<PageModule> UpdatePageModuleAsync(PageModule pageModule);
|
||||
Task UpdatePageModuleOrderAsync(int pageId, string pane);
|
||||
Task DeletePageModuleAsync(int pageModuleId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ namespace Oqtane.Services
|
|||
{
|
||||
public interface IPageService
|
||||
{
|
||||
Task<List<Page>> GetPagesAsync(int SiteId);
|
||||
Task<Page> GetPageAsync(int PageId);
|
||||
Task<Page> GetPageAsync(int PageId, int UserId);
|
||||
Task<Page> GetPageAsync(string Path, int SiteId);
|
||||
Task<Page> AddPageAsync(Page Page);
|
||||
Task<Page> AddPageAsync(int PageId, int UserId);
|
||||
Task<Page> UpdatePageAsync(Page Page);
|
||||
Task UpdatePageOrderAsync(int SiteId, int PageId, int? ParentId);
|
||||
Task DeletePageAsync(int PageId);
|
||||
Task<List<Page>> GetPagesAsync(int siteId);
|
||||
Task<Page> GetPageAsync(int pageId);
|
||||
Task<Page> GetPageAsync(int pageId, int userId);
|
||||
Task<Page> GetPageAsync(string path, int siteId);
|
||||
Task<Page> AddPageAsync(Page page);
|
||||
Task<Page> AddPageAsync(int pageId, int userId);
|
||||
Task<Page> UpdatePageAsync(Page page);
|
||||
Task UpdatePageOrderAsync(int siteId, int pageId, int? parentId);
|
||||
Task DeletePageAsync(int pageId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ namespace Oqtane.Services
|
|||
{
|
||||
public interface IProfileService
|
||||
{
|
||||
Task<List<Profile>> GetProfilesAsync(int SiteId);
|
||||
Task<List<Profile>> GetProfilesAsync(int siteId);
|
||||
|
||||
Task<Profile> GetProfileAsync(int ProfileId);
|
||||
Task<Profile> GetProfileAsync(int profileId);
|
||||
|
||||
Task<Profile> AddProfileAsync(Profile Profile);
|
||||
Task<Profile> AddProfileAsync(Profile profile);
|
||||
|
||||
Task<Profile> UpdateProfileAsync(Profile Profile);
|
||||
Task<Profile> UpdateProfileAsync(Profile profile);
|
||||
|
||||
Task DeleteProfileAsync(int ProfileId);
|
||||
Task DeleteProfileAsync(int profileId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ namespace Oqtane.Services
|
|||
{
|
||||
public interface IRoleService
|
||||
{
|
||||
Task<List<Role>> GetRolesAsync(int SiteId);
|
||||
Task<List<Role>> GetRolesAsync(int siteId);
|
||||
|
||||
Task<Role> GetRoleAsync(int RoleId);
|
||||
Task<Role> GetRoleAsync(int roleId);
|
||||
|
||||
Task<Role> AddRoleAsync(Role Role);
|
||||
Task<Role> AddRoleAsync(Role role);
|
||||
|
||||
Task<Role> UpdateRoleAsync(Role Role);
|
||||
Task<Role> UpdateRoleAsync(Role role);
|
||||
|
||||
Task DeleteRoleAsync(int RoleId);
|
||||
Task DeleteRoleAsync(int roleId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,48 +8,48 @@ namespace Oqtane.Services
|
|||
{
|
||||
Task<Dictionary<string, string>> GetHostSettingsAsync();
|
||||
|
||||
Task UpdateHostSettingsAsync(Dictionary<string, string> HostSettings);
|
||||
Task UpdateHostSettingsAsync(Dictionary<string, string> hostSettings);
|
||||
|
||||
Task<Dictionary<string, string>> GetSiteSettingsAsync(int SiteId);
|
||||
Task<Dictionary<string, string>> GetSiteSettingsAsync(int siteId);
|
||||
|
||||
Task UpdateSiteSettingsAsync(Dictionary<string, string> SiteSettings, int SiteId);
|
||||
Task UpdateSiteSettingsAsync(Dictionary<string, string> siteSettings, int siteId);
|
||||
|
||||
Task<Dictionary<string, string>> GetPageSettingsAsync(int PageId);
|
||||
Task<Dictionary<string, string>> GetPageSettingsAsync(int pageId);
|
||||
|
||||
Task UpdatePageSettingsAsync(Dictionary<string, string> PageSettings, int PageId);
|
||||
Task UpdatePageSettingsAsync(Dictionary<string, string> pageSettings, int pageId);
|
||||
|
||||
Task<Dictionary<string, string>> GetPageModuleSettingsAsync(int PageModuleId);
|
||||
Task<Dictionary<string, string>> GetPageModuleSettingsAsync(int pageModuleId);
|
||||
|
||||
Task UpdatePageModuleSettingsAsync(Dictionary<string, string> PageModuleSettings, int PageModuleId);
|
||||
Task UpdatePageModuleSettingsAsync(Dictionary<string, string> pageModuleSettings, int pageModuleId);
|
||||
|
||||
Task<Dictionary<string, string>> GetModuleSettingsAsync(int ModuleId);
|
||||
Task<Dictionary<string, string>> GetModuleSettingsAsync(int moduleId);
|
||||
|
||||
Task UpdateModuleSettingsAsync(Dictionary<string, string> ModuleSettings, int ModuleId);
|
||||
Task UpdateModuleSettingsAsync(Dictionary<string, string> moduleSettings, int moduleId);
|
||||
|
||||
Task<Dictionary<string, string>> GetUserSettingsAsync(int UserId);
|
||||
Task<Dictionary<string, string>> GetUserSettingsAsync(int userId);
|
||||
|
||||
Task UpdateUserSettingsAsync(Dictionary<string, string> UserSettings, int UserId);
|
||||
Task UpdateUserSettingsAsync(Dictionary<string, string> userSettings, int userId);
|
||||
|
||||
Task<Dictionary<string, string>> GetFolderSettingsAsync(int FolderId);
|
||||
Task<Dictionary<string, string>> GetFolderSettingsAsync(int folderId);
|
||||
|
||||
Task UpdateFolderSettingsAsync(Dictionary<string, string> FolderSettings, int FolderId);
|
||||
Task UpdateFolderSettingsAsync(Dictionary<string, string> folderSettings, int folderId);
|
||||
|
||||
Task<Dictionary<string, string>> GetSettingsAsync(string EntityName, int EntityId);
|
||||
Task<Dictionary<string, string>> GetSettingsAsync(string entityName, int entityId);
|
||||
|
||||
Task UpdateSettingsAsync(Dictionary<string, string> Settings, string EntityName, int EntityId);
|
||||
Task UpdateSettingsAsync(Dictionary<string, string> settings, string entityName, int entityId);
|
||||
|
||||
|
||||
Task<Setting> GetSettingAsync(int SettingId);
|
||||
Task<Setting> GetSettingAsync(int settingId);
|
||||
|
||||
Task<Setting> AddSettingAsync(Setting Setting);
|
||||
Task<Setting> AddSettingAsync(Setting setting);
|
||||
|
||||
Task<Setting> UpdateSettingAsync(Setting Setting);
|
||||
Task<Setting> UpdateSettingAsync(Setting setting);
|
||||
|
||||
Task DeleteSettingAsync(int SettingId);
|
||||
Task DeleteSettingAsync(int settingId);
|
||||
|
||||
|
||||
string GetSetting(Dictionary<string, string> Settings, string SettingName, string DefaultValue);
|
||||
string GetSetting(Dictionary<string, string> settings, string settingName, string defaultValue);
|
||||
|
||||
Dictionary<string, string> SetSetting(Dictionary<string, string> Settings, string SettingName, string SettingValue);
|
||||
Dictionary<string, string> SetSetting(Dictionary<string, string> settings, string settingName, string settingValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ namespace Oqtane.Services
|
|||
{
|
||||
public interface ISiteService
|
||||
{
|
||||
Task<List<Site>> GetSitesAsync(Alias Alias);
|
||||
Task<List<Site>> GetSitesAsync(Alias alias);
|
||||
|
||||
Task<Site> GetSiteAsync(int SiteId, Alias Alias);
|
||||
Task<Site> GetSiteAsync(int siteId, Alias alias);
|
||||
|
||||
Task<Site> AddSiteAsync(Site Site, Alias Alias);
|
||||
Task<Site> AddSiteAsync(Site site, Alias alias);
|
||||
|
||||
Task<Site> UpdateSiteAsync(Site Site, Alias Alias);
|
||||
Task<Site> UpdateSiteAsync(Site site, Alias alias);
|
||||
|
||||
Task DeleteSiteAsync(int SiteId, Alias Alias);
|
||||
Task DeleteSiteAsync(int siteId, Alias alias);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,12 @@ namespace Oqtane.Services
|
|||
{
|
||||
Task<List<Tenant>> GetTenantsAsync();
|
||||
|
||||
Task<Tenant> GetTenantAsync(int TenantId);
|
||||
Task<Tenant> GetTenantAsync(int tenantId);
|
||||
|
||||
Task<Tenant> AddTenantAsync(Tenant Tenant);
|
||||
Task<Tenant> AddTenantAsync(Tenant tenant);
|
||||
|
||||
Task<Tenant> UpdateTenantAsync(Tenant Tenant);
|
||||
Task<Tenant> UpdateTenantAsync(Tenant tenant);
|
||||
|
||||
Task DeleteTenantAsync(int TenantId);
|
||||
Task DeleteTenantAsync(int tenantId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ namespace Oqtane.Services
|
|||
public interface IThemeService
|
||||
{
|
||||
Task<List<Theme>> GetThemesAsync();
|
||||
Dictionary<string, string> GetThemeTypes(List<Theme> Themes);
|
||||
Dictionary<string, string> GetPaneLayoutTypes(List<Theme> Themes, string ThemeName);
|
||||
Dictionary<string, string> GetContainerTypes(List<Theme> Themes);
|
||||
Dictionary<string, string> GetThemeTypes(List<Theme> themes);
|
||||
Dictionary<string, string> GetPaneLayoutTypes(List<Theme> themes, string themeName);
|
||||
Dictionary<string, string> GetContainerTypes(List<Theme> themes);
|
||||
Task InstallThemesAsync();
|
||||
Task DeleteThemeAsync(string ThemeName);
|
||||
Task DeleteThemeAsync(string themeName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ namespace Oqtane.Services
|
|||
{
|
||||
public interface IUserRoleService
|
||||
{
|
||||
Task<List<UserRole>> GetUserRolesAsync(int SiteId);
|
||||
Task<UserRole> GetUserRoleAsync(int UserRoleId);
|
||||
Task<UserRole> AddUserRoleAsync(UserRole UserRole);
|
||||
Task<UserRole> UpdateUserRoleAsync(UserRole UserRole);
|
||||
Task DeleteUserRoleAsync(int UserRoleId);
|
||||
Task<List<UserRole>> GetUserRolesAsync(int siteId);
|
||||
Task<UserRole> GetUserRoleAsync(int userRoleId);
|
||||
Task<UserRole> AddUserRoleAsync(UserRole userRole);
|
||||
Task<UserRole> UpdateUserRoleAsync(UserRole userRole);
|
||||
Task DeleteUserRoleAsync(int userRoleId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface IUserService
|
||||
{
|
||||
Task<User> GetUserAsync(int UserId, int SiteId);
|
||||
Task<User> GetUserAsync(int userId, int siteId);
|
||||
|
||||
Task<User> GetUserAsync(string Username, int SiteId);
|
||||
Task<User> GetUserAsync(string username, int siteId);
|
||||
|
||||
Task<User> AddUserAsync(User User);
|
||||
Task<User> AddUserAsync(User user);
|
||||
|
||||
Task<User> AddUserAsync(User User, Alias Alias);
|
||||
Task<User> AddUserAsync(User user, Alias alias);
|
||||
|
||||
Task<User> UpdateUserAsync(User User);
|
||||
Task<User> UpdateUserAsync(User user);
|
||||
|
||||
Task DeleteUserAsync(int UserId);
|
||||
Task DeleteUserAsync(int userId);
|
||||
|
||||
Task<User> LoginUserAsync(User User, bool SetCookie, bool IsPersistent);
|
||||
Task<User> LoginUserAsync(User user, bool setCookie, bool isPersistent);
|
||||
|
||||
Task LogoutUserAsync(User User);
|
||||
Task LogoutUserAsync(User user);
|
||||
|
||||
Task<User> VerifyEmailAsync(User User, string Token);
|
||||
Task<User> VerifyEmailAsync(User user, string token);
|
||||
|
||||
Task ForgotPasswordAsync(User User);
|
||||
Task ForgotPasswordAsync(User user);
|
||||
|
||||
Task<User> ResetPasswordAsync(User User, string Token);
|
||||
Task<User> ResetPasswordAsync(User user, string token);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,34 +21,34 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "JobLog"); }
|
||||
}
|
||||
|
||||
public async Task<List<JobLog>> GetJobLogsAsync()
|
||||
{
|
||||
List<JobLog> Joblogs = await _http.GetJsonAsync<List<JobLog>>(apiurl);
|
||||
return Joblogs.OrderBy(item => item.StartDate).ToList();
|
||||
List<JobLog> joblogs = await _http.GetJsonAsync<List<JobLog>>(Apiurl);
|
||||
return joblogs.OrderBy(item => item.StartDate).ToList();
|
||||
}
|
||||
|
||||
public async Task<JobLog> GetJobLogAsync(int JobLogId)
|
||||
public async Task<JobLog> GetJobLogAsync(int jobLogId)
|
||||
{
|
||||
return await _http.GetJsonAsync<JobLog>(apiurl + "/" + JobLogId.ToString());
|
||||
return await _http.GetJsonAsync<JobLog>(Apiurl + "/" + jobLogId.ToString());
|
||||
}
|
||||
|
||||
public async Task<JobLog> AddJobLogAsync(JobLog Joblog)
|
||||
public async Task<JobLog> AddJobLogAsync(JobLog joblog)
|
||||
{
|
||||
return await _http.PostJsonAsync<JobLog>(apiurl, Joblog);
|
||||
return await _http.PostJsonAsync<JobLog>(Apiurl, joblog);
|
||||
}
|
||||
|
||||
public async Task<JobLog> UpdateJobLogAsync(JobLog Joblog)
|
||||
public async Task<JobLog> UpdateJobLogAsync(JobLog joblog)
|
||||
{
|
||||
return await _http.PutJsonAsync<JobLog>(apiurl + "/" + Joblog.JobLogId.ToString(), Joblog);
|
||||
return await _http.PutJsonAsync<JobLog>(Apiurl + "/" + joblog.JobLogId.ToString(), joblog);
|
||||
}
|
||||
public async Task DeleteJobLogAsync(int JobLogId)
|
||||
public async Task DeleteJobLogAsync(int jobLogId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + JobLogId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + jobLogId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,44 +21,44 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Job"); }
|
||||
}
|
||||
|
||||
public async Task<List<Job>> GetJobsAsync()
|
||||
{
|
||||
List<Job> Jobs = await _http.GetJsonAsync<List<Job>>(apiurl);
|
||||
return Jobs.OrderBy(item => item.Name).ToList();
|
||||
List<Job> jobs = await _http.GetJsonAsync<List<Job>>(Apiurl);
|
||||
return jobs.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Job> GetJobAsync(int JobId)
|
||||
public async Task<Job> GetJobAsync(int jobId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Job>(apiurl + "/" + JobId.ToString());
|
||||
return await _http.GetJsonAsync<Job>(Apiurl + "/" + jobId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Job> AddJobAsync(Job Job)
|
||||
public async Task<Job> AddJobAsync(Job job)
|
||||
{
|
||||
return await _http.PostJsonAsync<Job>(apiurl, Job);
|
||||
return await _http.PostJsonAsync<Job>(Apiurl, job);
|
||||
}
|
||||
|
||||
public async Task<Job> UpdateJobAsync(Job Job)
|
||||
public async Task<Job> UpdateJobAsync(Job job)
|
||||
{
|
||||
return await _http.PutJsonAsync<Job>(apiurl + "/" + Job.JobId.ToString(), Job);
|
||||
return await _http.PutJsonAsync<Job>(Apiurl + "/" + job.JobId.ToString(), job);
|
||||
}
|
||||
public async Task DeleteJobAsync(int JobId)
|
||||
public async Task DeleteJobAsync(int jobId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + JobId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + jobId.ToString());
|
||||
}
|
||||
|
||||
public async Task StartJobAsync(int JobId)
|
||||
public async Task StartJobAsync(int jobId)
|
||||
{
|
||||
await _http.GetAsync(apiurl + "/start/" + JobId.ToString());
|
||||
await _http.GetAsync(Apiurl + "/start/" + jobId.ToString());
|
||||
}
|
||||
|
||||
public async Task StopJobAsync(int JobId)
|
||||
public async Task StopJobAsync(int jobId)
|
||||
{
|
||||
await _http.GetAsync(apiurl + "/stop/" + JobId.ToString());
|
||||
await _http.GetAsync(Apiurl + "/stop/" + jobId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Net.Http;
|
|||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
|
||||
|
@ -22,40 +23,40 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Log"); }
|
||||
}
|
||||
|
||||
public async Task<List<Log>> GetLogsAsync(int SiteId, string Level, string Function, int Rows)
|
||||
public async Task<List<Log>> GetLogsAsync(int siteId, string level, string function, int rows)
|
||||
{
|
||||
return await _http.GetJsonAsync<List<Log>>(apiurl + "?siteid=" + SiteId.ToString() + "&level=" + Level + "&function=" + Function + "&rows=" + Rows.ToString());
|
||||
return await _http.GetJsonAsync<List<Log>>(Apiurl + "?siteid=" + siteId.ToString() + "&level=" + level + "&function=" + function + "&rows=" + rows.ToString());
|
||||
}
|
||||
|
||||
public async Task<Log> GetLogAsync(int LogId)
|
||||
public async Task<Log> GetLogAsync(int logId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Log>(apiurl + "/" + LogId.ToString());
|
||||
return await _http.GetJsonAsync<Log>(Apiurl + "/" + logId.ToString());
|
||||
}
|
||||
|
||||
public async Task Log(int? PageId, int? ModuleId, int? UserId, string category, string feature, LogFunction function, LogLevel level, Exception exception, string message, params object[] args)
|
||||
public async Task Log(int? pageId, int? moduleId, int? userId, string category, string feature, LogFunction function, LogLevel level, Exception exception, string message, params object[] args)
|
||||
{
|
||||
await Log(null, PageId, ModuleId, UserId, category, feature, function, level, exception, message, args);
|
||||
await Log(null, pageId, moduleId, userId, category, feature, function, level, exception, message, args);
|
||||
}
|
||||
|
||||
public async Task Log(Alias Alias, int? PageId, int? ModuleId, int? UserId, string category, string feature, LogFunction function, LogLevel level, Exception exception, string message, params object[] args)
|
||||
public async Task Log(Alias alias, int? pageId, int? moduleId, int? userId, string category, string feature, LogFunction function, LogLevel level, Exception exception, string message, params object[] args)
|
||||
{
|
||||
Log log = new Log();
|
||||
if (Alias == null)
|
||||
if (alias == null)
|
||||
{
|
||||
log.SiteId = _siteState.Alias.SiteId;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.SiteId = Alias.SiteId;
|
||||
log.SiteId = alias.SiteId;
|
||||
}
|
||||
log.PageId = PageId;
|
||||
log.ModuleId = ModuleId;
|
||||
log.UserId = UserId;
|
||||
log.PageId = pageId;
|
||||
log.ModuleId = moduleId;
|
||||
log.UserId = userId;
|
||||
log.Url = _navigationManager.Uri;
|
||||
log.Category = category;
|
||||
log.Feature = feature;
|
||||
|
@ -68,7 +69,7 @@ namespace Oqtane.Services
|
|||
log.Message = message;
|
||||
log.MessageTemplate = "";
|
||||
log.Properties = JsonSerializer.Serialize(args);
|
||||
await _http.PostJsonAsync(CreateCrossTenantUrl(apiurl, Alias), log);
|
||||
await _http.PostJsonAsync(CreateCrossTenantUrl(Apiurl, alias), log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,41 +26,41 @@ namespace Oqtane.Services
|
|||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "ModuleDefinition"); }
|
||||
}
|
||||
|
||||
public async Task<List<ModuleDefinition>> GetModuleDefinitionsAsync(int SiteId)
|
||||
public async Task<List<ModuleDefinition>> GetModuleDefinitionsAsync(int siteId)
|
||||
{
|
||||
List<ModuleDefinition> moduledefinitions = await _http.GetJsonAsync<List<ModuleDefinition>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
List<ModuleDefinition> moduledefinitions = await _http.GetJsonAsync<List<ModuleDefinition>>(Apiurl + "?siteid=" + siteId.ToString());
|
||||
return moduledefinitions.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<ModuleDefinition> GetModuleDefinitionAsync(int ModuleDefinitionId, int SiteId)
|
||||
public async Task<ModuleDefinition> GetModuleDefinitionAsync(int moduleDefinitionId, int siteId)
|
||||
{
|
||||
return await _http.GetJsonAsync<ModuleDefinition>(apiurl + "/" + ModuleDefinitionId.ToString() + "?siteid=" + SiteId.ToString());
|
||||
return await _http.GetJsonAsync<ModuleDefinition>(Apiurl + "/" + moduleDefinitionId.ToString() + "?siteid=" + siteId.ToString());
|
||||
}
|
||||
|
||||
public async Task UpdateModuleDefinitionAsync(ModuleDefinition ModuleDefinition)
|
||||
public async Task UpdateModuleDefinitionAsync(ModuleDefinition moduleDefinition)
|
||||
{
|
||||
await _http.PutJsonAsync(apiurl + "/" + ModuleDefinition.ModuleDefinitionId.ToString(), ModuleDefinition);
|
||||
await _http.PutJsonAsync(Apiurl + "/" + moduleDefinition.ModuleDefinitionId.ToString(), moduleDefinition);
|
||||
}
|
||||
|
||||
public async Task InstallModuleDefinitionsAsync()
|
||||
{
|
||||
await _http.GetJsonAsync<List<string>>(apiurl + "/install");
|
||||
await _http.GetJsonAsync<List<string>>(Apiurl + "/install");
|
||||
}
|
||||
|
||||
public async Task DeleteModuleDefinitionAsync(int ModuleDefinitionId, int SiteId)
|
||||
public async Task DeleteModuleDefinitionAsync(int moduleDefinitionId, int siteId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + ModuleDefinitionId.ToString() + "?siteid=" + SiteId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + moduleDefinitionId.ToString() + "?siteid=" + siteId.ToString());
|
||||
}
|
||||
|
||||
public async Task LoadModuleDefinitionsAsync(int SiteId)
|
||||
public async Task LoadModuleDefinitionsAsync(int siteId)
|
||||
{
|
||||
// get list of modules from the server
|
||||
List<ModuleDefinition> moduledefinitions = await GetModuleDefinitionsAsync(SiteId);
|
||||
List<ModuleDefinition> moduledefinitions = await GetModuleDefinitionsAsync(siteId);
|
||||
|
||||
// download assemblies to browser when running client-side Blazor
|
||||
var authstateprovider = (IdentityAuthenticationStateProvider)_serviceProvider.GetService(typeof(IdentityAuthenticationStateProvider));
|
||||
|
@ -80,7 +80,7 @@ namespace Oqtane.Services
|
|||
if (assemblies.Where(item => item.FullName.StartsWith(assemblyname + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await _http.GetByteArrayAsync(apiurl + "/load/" + assemblyname + ".dll");
|
||||
var bytes = await _http.GetByteArrayAsync(Apiurl + "/load/" + assemblyname + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ namespace Oqtane.Services
|
|||
if (assemblies.Where(item => item.FullName.StartsWith(moduledefinition.AssemblyName + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await _http.GetByteArrayAsync(apiurl + "/load/" + moduledefinition.AssemblyName + ".dll");
|
||||
var bytes = await _http.GetByteArrayAsync(Apiurl + "/load/" + moduledefinition.AssemblyName + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,48 +21,48 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Module"); }
|
||||
}
|
||||
|
||||
public async Task<List<Module>> GetModulesAsync(int SiteId)
|
||||
public async Task<List<Module>> GetModulesAsync(int siteId)
|
||||
{
|
||||
List<Module> modules = await _http.GetJsonAsync<List<Module>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
List<Module> modules = await _http.GetJsonAsync<List<Module>>(Apiurl + "?siteid=" + siteId.ToString());
|
||||
modules = modules
|
||||
.OrderBy(item => item.Order)
|
||||
.ToList();
|
||||
return modules;
|
||||
}
|
||||
|
||||
public async Task<Module> GetModuleAsync(int ModuleId)
|
||||
public async Task<Module> GetModuleAsync(int moduleId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Module>(apiurl + "/" + ModuleId.ToString());
|
||||
return await _http.GetJsonAsync<Module>(Apiurl + "/" + moduleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Module> AddModuleAsync(Module Module)
|
||||
public async Task<Module> AddModuleAsync(Module module)
|
||||
{
|
||||
return await _http.PostJsonAsync<Module>(apiurl, Module);
|
||||
return await _http.PostJsonAsync<Module>(Apiurl, module);
|
||||
}
|
||||
|
||||
public async Task<Module> UpdateModuleAsync(Module Module)
|
||||
public async Task<Module> UpdateModuleAsync(Module module)
|
||||
{
|
||||
return await _http.PutJsonAsync<Module>(apiurl + "/" + Module.ModuleId.ToString(), Module);
|
||||
return await _http.PutJsonAsync<Module>(Apiurl + "/" + module.ModuleId.ToString(), module);
|
||||
}
|
||||
|
||||
public async Task DeleteModuleAsync(int ModuleId)
|
||||
public async Task DeleteModuleAsync(int moduleId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + ModuleId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + moduleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<bool> ImportModuleAsync(int ModuleId, string Content)
|
||||
public async Task<bool> ImportModuleAsync(int moduleId, string content)
|
||||
{
|
||||
return await _http.PostJsonAsync<bool>(apiurl + "/import?moduleid=" + ModuleId, Content);
|
||||
return await _http.PostJsonAsync<bool>(Apiurl + "/import?moduleid=" + moduleId, content);
|
||||
}
|
||||
|
||||
public async Task<string> ExportModuleAsync(int ModuleId)
|
||||
public async Task<string> ExportModuleAsync(int moduleId)
|
||||
{
|
||||
return await _http.GetStringAsync(apiurl + "/export?moduleid=" + ModuleId.ToString());
|
||||
return await _http.GetStringAsync(Apiurl + "/export?moduleid=" + moduleId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,35 +21,35 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Notification"); }
|
||||
}
|
||||
|
||||
public async Task<List<Notification>> GetNotificationsAsync(int SiteId, string Direction, int UserId)
|
||||
public async Task<List<Notification>> GetNotificationsAsync(int siteId, string direction, int userId)
|
||||
{
|
||||
string querystring = "?siteid=" + SiteId.ToString() + "&direction=" + Direction.ToLower() + "&userid=" + UserId.ToString();
|
||||
List<Notification> Notifications = await _http.GetJsonAsync<List<Notification>>(apiurl + querystring);
|
||||
return Notifications.OrderByDescending(item => item.CreatedOn).ToList();
|
||||
string querystring = "?siteid=" + siteId.ToString() + "&direction=" + direction.ToLower() + "&userid=" + userId.ToString();
|
||||
List<Notification> notifications = await _http.GetJsonAsync<List<Notification>>(Apiurl + querystring);
|
||||
return notifications.OrderByDescending(item => item.CreatedOn).ToList();
|
||||
}
|
||||
|
||||
public async Task<Notification> GetNotificationAsync(int NotificationId)
|
||||
public async Task<Notification> GetNotificationAsync(int notificationId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Notification>(apiurl + "/" + NotificationId.ToString());
|
||||
return await _http.GetJsonAsync<Notification>(Apiurl + "/" + notificationId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Notification> AddNotificationAsync(Notification Notification)
|
||||
public async Task<Notification> AddNotificationAsync(Notification notification)
|
||||
{
|
||||
return await _http.PostJsonAsync<Notification>(apiurl, Notification);
|
||||
return await _http.PostJsonAsync<Notification>(Apiurl, notification);
|
||||
}
|
||||
|
||||
public async Task<Notification> UpdateNotificationAsync(Notification Notification)
|
||||
public async Task<Notification> UpdateNotificationAsync(Notification notification)
|
||||
{
|
||||
return await _http.PutJsonAsync<Notification>(apiurl + "/" + Notification.NotificationId.ToString(), Notification);
|
||||
return await _http.PutJsonAsync<Notification>(Apiurl + "/" + notification.NotificationId.ToString(), notification);
|
||||
}
|
||||
public async Task DeleteNotificationAsync(int NotificationId)
|
||||
public async Task DeleteNotificationAsync(int notificationId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + NotificationId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + notificationId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,20 +21,20 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Package"); }
|
||||
}
|
||||
|
||||
public async Task<List<Package>> GetPackagesAsync(string Tag)
|
||||
public async Task<List<Package>> GetPackagesAsync(string tag)
|
||||
{
|
||||
List<Package> packages = await _http.GetJsonAsync<List<Package>>(apiurl + "?tag=" + Tag);
|
||||
List<Package> packages = await _http.GetJsonAsync<List<Package>>(Apiurl + "?tag=" + tag);
|
||||
return packages.OrderByDescending(item => item.Downloads).ToList();
|
||||
}
|
||||
|
||||
public async Task DownloadPackageAsync(string PackageId, string Version, string Folder)
|
||||
public async Task DownloadPackageAsync(string packageId, string version, string folder)
|
||||
{
|
||||
await _http.PostJsonAsync(apiurl + "?packageid=" + PackageId + "&version=" + Version + "&folder=" + Folder, null);
|
||||
await _http.PostJsonAsync(Apiurl + "?packageid=" + packageId + "&version=" + version + "&folder=" + folder, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
@ -21,39 +19,39 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "PageModule"); }
|
||||
}
|
||||
|
||||
public async Task<PageModule> GetPageModuleAsync(int PageModuleId)
|
||||
public async Task<PageModule> GetPageModuleAsync(int pageModuleId)
|
||||
{
|
||||
return await _http.GetJsonAsync<PageModule>(apiurl + "/" + PageModuleId.ToString());
|
||||
return await _http.GetJsonAsync<PageModule>(Apiurl + "/" + pageModuleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<PageModule> GetPageModuleAsync(int PageId, int ModuleId)
|
||||
public async Task<PageModule> GetPageModuleAsync(int pageId, int moduleId)
|
||||
{
|
||||
return await _http.GetJsonAsync<PageModule>(apiurl + "/" + PageId.ToString() + "/" + ModuleId.ToString());
|
||||
return await _http.GetJsonAsync<PageModule>(Apiurl + "/" + pageId.ToString() + "/" + moduleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<PageModule> AddPageModuleAsync(PageModule PageModule)
|
||||
public async Task<PageModule> AddPageModuleAsync(PageModule pageModule)
|
||||
{
|
||||
return await _http.PostJsonAsync<PageModule>(apiurl, PageModule);
|
||||
return await _http.PostJsonAsync<PageModule>(Apiurl, pageModule);
|
||||
}
|
||||
|
||||
public async Task<PageModule> UpdatePageModuleAsync(PageModule PageModule)
|
||||
public async Task<PageModule> UpdatePageModuleAsync(PageModule pageModule)
|
||||
{
|
||||
return await _http.PutJsonAsync<PageModule>(apiurl + "/" + PageModule.PageModuleId.ToString(), PageModule);
|
||||
return await _http.PutJsonAsync<PageModule>(Apiurl + "/" + pageModule.PageModuleId.ToString(), pageModule);
|
||||
}
|
||||
|
||||
public async Task UpdatePageModuleOrderAsync(int PageId, string Pane)
|
||||
public async Task UpdatePageModuleOrderAsync(int pageId, string pane)
|
||||
{
|
||||
await _http.PutJsonAsync(apiurl + "/?pageid=" + PageId.ToString() + "&pane=" + Pane, null);
|
||||
await _http.PutJsonAsync(Apiurl + "/?pageid=" + pageId.ToString() + "&pane=" + pane, null);
|
||||
}
|
||||
|
||||
public async Task DeletePageModuleAsync(int PageModuleId)
|
||||
public async Task DeletePageModuleAsync(int pageModuleId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + PageModuleId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + pageModuleId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,33 +23,33 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Page"); }
|
||||
}
|
||||
|
||||
public async Task<List<Page>> GetPagesAsync(int SiteId)
|
||||
public async Task<List<Page>> GetPagesAsync(int siteId)
|
||||
{
|
||||
List<Page> pages = await _http.GetJsonAsync<List<Page>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
List<Page> pages = await _http.GetJsonAsync<List<Page>>(Apiurl + "?siteid=" + siteId.ToString());
|
||||
pages = GetPagesHierarchy(pages);
|
||||
return pages;
|
||||
}
|
||||
|
||||
public async Task<Page> GetPageAsync(int PageId)
|
||||
public async Task<Page> GetPageAsync(int pageId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString());
|
||||
return await _http.GetJsonAsync<Page>(Apiurl + "/" + pageId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Page> GetPageAsync(int PageId, int UserId)
|
||||
public async Task<Page> GetPageAsync(int pageId, int userId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString() + "?userid=" + UserId.ToString());
|
||||
return await _http.GetJsonAsync<Page>(Apiurl + "/" + pageId.ToString() + "?userid=" + userId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Page> GetPageAsync(string Path, int SiteId)
|
||||
public async Task<Page> GetPageAsync(string path, int siteId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _http.GetJsonAsync<Page>(apiurl + "/path/" + SiteId.ToString() + "?path=" + WebUtility.UrlEncode(Path));
|
||||
return await _http.GetJsonAsync<Page>(Apiurl + "/path/" + siteId.ToString() + "?path=" + WebUtility.UrlEncode(path));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -57,62 +57,62 @@ namespace Oqtane.Services
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<Page> AddPageAsync(Page Page)
|
||||
public async Task<Page> AddPageAsync(Page page)
|
||||
{
|
||||
return await _http.PostJsonAsync<Page>(apiurl, Page);
|
||||
return await _http.PostJsonAsync<Page>(Apiurl, page);
|
||||
}
|
||||
|
||||
public async Task<Page> AddPageAsync(int PageId, int UserId)
|
||||
public async Task<Page> AddPageAsync(int pageId, int userId)
|
||||
{
|
||||
return await _http.PostJsonAsync<Page>(apiurl + "/" + PageId.ToString() + "?userid=" + UserId.ToString(), null);
|
||||
return await _http.PostJsonAsync<Page>(Apiurl + "/" + pageId.ToString() + "?userid=" + userId.ToString(), null);
|
||||
}
|
||||
|
||||
public async Task<Page> UpdatePageAsync(Page Page)
|
||||
public async Task<Page> UpdatePageAsync(Page page)
|
||||
{
|
||||
return await _http.PutJsonAsync<Page>(apiurl + "/" + Page.PageId.ToString(), Page);
|
||||
return await _http.PutJsonAsync<Page>(Apiurl + "/" + page.PageId.ToString(), page);
|
||||
}
|
||||
|
||||
public async Task UpdatePageOrderAsync(int SiteId, int PageId, int? ParentId)
|
||||
public async Task UpdatePageOrderAsync(int siteId, int pageId, int? parentId)
|
||||
{
|
||||
await _http.PutJsonAsync(apiurl + "/?siteid=" + SiteId.ToString() + "&pageid=" + PageId.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)
|
||||
public async Task DeletePageAsync(int pageId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + PageId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + pageId.ToString());
|
||||
}
|
||||
|
||||
private static List<Page> GetPagesHierarchy(List<Page> Pages)
|
||||
private static List<Page> GetPagesHierarchy(List<Page> pages)
|
||||
{
|
||||
List<Page> hierarchy = new List<Page>();
|
||||
Action<List<Page>, Page> GetPath = null;
|
||||
GetPath = (List<Page> pages, Page page) =>
|
||||
Action<List<Page>, Page> getPath = null;
|
||||
getPath = (pageList, page) =>
|
||||
{
|
||||
IEnumerable<Page> children;
|
||||
int level;
|
||||
if (page == null)
|
||||
{
|
||||
level = -1;
|
||||
children = Pages.Where(item => item.ParentId == null);
|
||||
children = pages.Where(item => item.ParentId == null);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = page.Level;
|
||||
children = Pages.Where(item => item.ParentId == page.PageId);
|
||||
children = pages.Where(item => item.ParentId == page.PageId);
|
||||
}
|
||||
foreach (Page child in children)
|
||||
{
|
||||
child.Level = level + 1;
|
||||
child.HasChildren = Pages.Where(item => item.ParentId == child.PageId).Any();
|
||||
child.HasChildren = pages.Any(item => item.ParentId == child.PageId);
|
||||
hierarchy.Add(child);
|
||||
GetPath(pages, child);
|
||||
getPath(pageList, child);
|
||||
}
|
||||
};
|
||||
Pages = Pages.OrderBy(item => item.Order).ToList();
|
||||
GetPath(Pages, null);
|
||||
pages = pages.OrderBy(item => item.Order).ToList();
|
||||
getPath(pages, null);
|
||||
|
||||
// add any non-hierarchical items to the end of the list
|
||||
foreach (Page page in Pages)
|
||||
foreach (Page page in pages)
|
||||
{
|
||||
if (hierarchy.Find(item => item.PageId == page.PageId) == null)
|
||||
{
|
||||
|
|
|
@ -21,34 +21,34 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Profile"); }
|
||||
}
|
||||
|
||||
public async Task<List<Profile>> GetProfilesAsync(int SiteId)
|
||||
public async Task<List<Profile>> GetProfilesAsync(int siteId)
|
||||
{
|
||||
List<Profile> Profiles = await _http.GetJsonAsync<List<Profile>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
return Profiles.OrderBy(item => item.ViewOrder).ToList();
|
||||
List<Profile> profiles = await _http.GetJsonAsync<List<Profile>>(Apiurl + "?siteid=" + siteId.ToString());
|
||||
return profiles.OrderBy(item => item.ViewOrder).ToList();
|
||||
}
|
||||
|
||||
public async Task<Profile> GetProfileAsync(int ProfileId)
|
||||
public async Task<Profile> GetProfileAsync(int profileId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Profile>(apiurl + "/" + ProfileId.ToString());
|
||||
return await _http.GetJsonAsync<Profile>(Apiurl + "/" + profileId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Profile> AddProfileAsync(Profile Profile)
|
||||
public async Task<Profile> AddProfileAsync(Profile profile)
|
||||
{
|
||||
return await _http.PostJsonAsync<Profile>(apiurl, Profile);
|
||||
return await _http.PostJsonAsync<Profile>(Apiurl, profile);
|
||||
}
|
||||
|
||||
public async Task<Profile> UpdateProfileAsync(Profile Profile)
|
||||
public async Task<Profile> UpdateProfileAsync(Profile profile)
|
||||
{
|
||||
return await _http.PutJsonAsync<Profile>(apiurl + "/" + Profile.SiteId.ToString(), Profile);
|
||||
return await _http.PutJsonAsync<Profile>(Apiurl + "/" + profile.SiteId.ToString(), profile);
|
||||
}
|
||||
public async Task DeleteProfileAsync(int ProfileId)
|
||||
public async Task DeleteProfileAsync(int profileId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + ProfileId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + profileId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,34 +21,34 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Role"); }
|
||||
}
|
||||
|
||||
public async Task<List<Role>> GetRolesAsync(int SiteId)
|
||||
public async Task<List<Role>> GetRolesAsync(int siteId)
|
||||
{
|
||||
List<Role> Roles = await _http.GetJsonAsync<List<Role>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
return Roles.OrderBy(item => item.Name).ToList();
|
||||
List<Role> roles = await _http.GetJsonAsync<List<Role>>(Apiurl + "?siteid=" + siteId.ToString());
|
||||
return roles.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Role> GetRoleAsync(int RoleId)
|
||||
public async Task<Role> GetRoleAsync(int roleId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Role>(apiurl + "/" + RoleId.ToString());
|
||||
return await _http.GetJsonAsync<Role>(Apiurl + "/" + roleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Role> AddRoleAsync(Role Role)
|
||||
public async Task<Role> AddRoleAsync(Role role)
|
||||
{
|
||||
return await _http.PostJsonAsync<Role>(apiurl, Role);
|
||||
return await _http.PostJsonAsync<Role>(Apiurl, role);
|
||||
}
|
||||
|
||||
public async Task<Role> UpdateRoleAsync(Role Role)
|
||||
public async Task<Role> UpdateRoleAsync(Role role)
|
||||
{
|
||||
return await _http.PutJsonAsync<Role>(apiurl + "/" + Role.RoleId.ToString(), Role);
|
||||
return await _http.PutJsonAsync<Role>(Apiurl + "/" + role.RoleId.ToString(), role);
|
||||
}
|
||||
public async Task DeleteRoleAsync(int RoleId)
|
||||
public async Task DeleteRoleAsync(int roleId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + RoleId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + roleId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Setting"); }
|
||||
}
|
||||
|
@ -31,93 +31,93 @@ namespace Oqtane.Services
|
|||
return await GetSettingsAsync("Host", -1);
|
||||
}
|
||||
|
||||
public async Task UpdateHostSettingsAsync(Dictionary<string, string> HostSettings)
|
||||
public async Task UpdateHostSettingsAsync(Dictionary<string, string> hostSettings)
|
||||
{
|
||||
await UpdateSettingsAsync(HostSettings, "Host", -1);
|
||||
await UpdateSettingsAsync(hostSettings, "Host", -1);
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, string>> GetSiteSettingsAsync(int SiteId)
|
||||
public async Task<Dictionary<string, string>> GetSiteSettingsAsync(int siteId)
|
||||
{
|
||||
return await GetSettingsAsync("Site", SiteId);
|
||||
return await GetSettingsAsync("Site", siteId);
|
||||
}
|
||||
|
||||
public async Task UpdateSiteSettingsAsync(Dictionary<string, string> SiteSettings, int SiteId)
|
||||
public async Task UpdateSiteSettingsAsync(Dictionary<string, string> siteSettings, int siteId)
|
||||
{
|
||||
await UpdateSettingsAsync(SiteSettings, "Site", SiteId);
|
||||
await UpdateSettingsAsync(siteSettings, "Site", siteId);
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, string>> GetPageSettingsAsync(int PageId)
|
||||
public async Task<Dictionary<string, string>> GetPageSettingsAsync(int pageId)
|
||||
{
|
||||
return await GetSettingsAsync("Page", PageId);
|
||||
return await GetSettingsAsync("Page", pageId);
|
||||
}
|
||||
|
||||
public async Task UpdatePageSettingsAsync(Dictionary<string, string> PageSettings, int PageId)
|
||||
public async Task UpdatePageSettingsAsync(Dictionary<string, string> pageSettings, int pageId)
|
||||
{
|
||||
await UpdateSettingsAsync(PageSettings, "Page", PageId);
|
||||
await UpdateSettingsAsync(pageSettings, "Page", pageId);
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, string>> GetPageModuleSettingsAsync(int PageModuleId)
|
||||
public async Task<Dictionary<string, string>> GetPageModuleSettingsAsync(int pageModuleId)
|
||||
{
|
||||
return await GetSettingsAsync("PageModule", PageModuleId);
|
||||
return await GetSettingsAsync("PageModule", pageModuleId);
|
||||
}
|
||||
|
||||
public async Task UpdatePageModuleSettingsAsync(Dictionary<string, string> PageModuleSettings, int PageModuleId)
|
||||
public async Task UpdatePageModuleSettingsAsync(Dictionary<string, string> pageModuleSettings, int pageModuleId)
|
||||
{
|
||||
await UpdateSettingsAsync(PageModuleSettings, "PageModule", PageModuleId);
|
||||
await UpdateSettingsAsync(pageModuleSettings, "PageModule", pageModuleId);
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, string>> GetModuleSettingsAsync(int ModuleId)
|
||||
public async Task<Dictionary<string, string>> GetModuleSettingsAsync(int moduleId)
|
||||
{
|
||||
return await GetSettingsAsync("Module", ModuleId);
|
||||
return await GetSettingsAsync("Module", moduleId);
|
||||
}
|
||||
|
||||
public async Task UpdateModuleSettingsAsync(Dictionary<string, string> ModuleSettings, int ModuleId)
|
||||
public async Task UpdateModuleSettingsAsync(Dictionary<string, string> moduleSettings, int moduleId)
|
||||
{
|
||||
await UpdateSettingsAsync(ModuleSettings, "Module", ModuleId);
|
||||
await UpdateSettingsAsync(moduleSettings, "Module", moduleId);
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, string>> GetUserSettingsAsync(int UserId)
|
||||
public async Task<Dictionary<string, string>> GetUserSettingsAsync(int userId)
|
||||
{
|
||||
return await GetSettingsAsync("User", UserId);
|
||||
return await GetSettingsAsync("User", userId);
|
||||
}
|
||||
|
||||
public async Task UpdateUserSettingsAsync(Dictionary<string, string> UserSettings, int UserId)
|
||||
public async Task UpdateUserSettingsAsync(Dictionary<string, string> userSettings, int userId)
|
||||
{
|
||||
await UpdateSettingsAsync(UserSettings, "User", UserId);
|
||||
await UpdateSettingsAsync(userSettings, "User", userId);
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, string>> GetFolderSettingsAsync(int FolderId)
|
||||
public async Task<Dictionary<string, string>> GetFolderSettingsAsync(int folderId)
|
||||
{
|
||||
return await GetSettingsAsync("Folder", FolderId);
|
||||
return await GetSettingsAsync("Folder", folderId);
|
||||
}
|
||||
|
||||
public async Task UpdateFolderSettingsAsync(Dictionary<string, string> FolderSettings, int FolderId)
|
||||
public async Task UpdateFolderSettingsAsync(Dictionary<string, string> folderSettings, int folderId)
|
||||
{
|
||||
await UpdateSettingsAsync(FolderSettings, "Folder", FolderId);
|
||||
await UpdateSettingsAsync(folderSettings, "Folder", folderId);
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, string>> GetSettingsAsync(string EntityName, int EntityId)
|
||||
public async Task<Dictionary<string, string>> GetSettingsAsync(string entityName, int entityId)
|
||||
{
|
||||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||||
List<Setting> Settings = await _http.GetJsonAsync<List<Setting>>(apiurl + "?entityname=" + EntityName + "&entityid=" + EntityId.ToString());
|
||||
foreach(Setting setting in Settings.OrderBy(item => item.SettingName).ToList())
|
||||
List<Setting> settings = await _http.GetJsonAsync<List<Setting>>(Apiurl + "?entityname=" + entityName + "&entityid=" + entityId.ToString());
|
||||
foreach(Setting setting in settings.OrderBy(item => item.SettingName).ToList())
|
||||
{
|
||||
dictionary.Add(setting.SettingName, setting.SettingValue);
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
public async Task UpdateSettingsAsync(Dictionary<string, string> Settings, string EntityName, int EntityId)
|
||||
public async Task UpdateSettingsAsync(Dictionary<string, string> settings, string entityName, int entityId)
|
||||
{
|
||||
List<Setting> settings = await _http.GetJsonAsync<List<Setting>>(apiurl + "?entityname=" + EntityName + "&entityid=" + EntityId.ToString());
|
||||
foreach (KeyValuePair<string, string> kvp in Settings)
|
||||
List<Setting> settingsList = await _http.GetJsonAsync<List<Setting>>(Apiurl + "?entityname=" + entityName + "&entityid=" + entityId.ToString());
|
||||
foreach (KeyValuePair<string, string> kvp in settings)
|
||||
{
|
||||
Setting setting = settings.Where(item => item.SettingName == kvp.Key).FirstOrDefault();
|
||||
Setting setting = settingsList.FirstOrDefault(item => item.SettingName == kvp.Key);
|
||||
if (setting == null)
|
||||
{
|
||||
setting = new Setting();
|
||||
setting.EntityName = EntityName;
|
||||
setting.EntityId = EntityId;
|
||||
setting.EntityName = entityName;
|
||||
setting.EntityId = entityId;
|
||||
setting.SettingName = kvp.Key;
|
||||
setting.SettingValue = kvp.Value;
|
||||
setting = await AddSettingAsync(setting);
|
||||
|
@ -134,48 +134,48 @@ namespace Oqtane.Services
|
|||
}
|
||||
|
||||
|
||||
public async Task<Setting> GetSettingAsync(int SettingId)
|
||||
public async Task<Setting> GetSettingAsync(int settingId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Setting>(apiurl + "/" + SettingId.ToString());
|
||||
return await _http.GetJsonAsync<Setting>(Apiurl + "/" + settingId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Setting> AddSettingAsync(Setting Setting)
|
||||
public async Task<Setting> AddSettingAsync(Setting setting)
|
||||
{
|
||||
return await _http.PostJsonAsync<Setting>(apiurl, Setting);
|
||||
return await _http.PostJsonAsync<Setting>(Apiurl, setting);
|
||||
}
|
||||
|
||||
public async Task<Setting> UpdateSettingAsync(Setting Setting)
|
||||
public async Task<Setting> UpdateSettingAsync(Setting setting)
|
||||
{
|
||||
return await _http.PutJsonAsync<Setting>(apiurl + "/" + Setting.SettingId.ToString(), Setting);
|
||||
return await _http.PutJsonAsync<Setting>(Apiurl + "/" + setting.SettingId.ToString(), setting);
|
||||
}
|
||||
|
||||
public async Task DeleteSettingAsync(int SettingId)
|
||||
public async Task DeleteSettingAsync(int settingId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + SettingId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + settingId.ToString());
|
||||
}
|
||||
|
||||
|
||||
public string GetSetting(Dictionary<string, string> Settings, string SettingName, string DefaultValue)
|
||||
public string GetSetting(Dictionary<string, string> settings, string settingName, string defaultValue)
|
||||
{
|
||||
string value = DefaultValue;
|
||||
if (Settings.ContainsKey(SettingName))
|
||||
string value = defaultValue;
|
||||
if (settings.ContainsKey(settingName))
|
||||
{
|
||||
value = Settings[SettingName];
|
||||
value = settings[settingName];
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public Dictionary<string, string> SetSetting(Dictionary<string, string> Settings, string SettingName, string SettingValue)
|
||||
public Dictionary<string, string> SetSetting(Dictionary<string, string> settings, string settingName, string settingValue)
|
||||
{
|
||||
if (Settings.ContainsKey(SettingName))
|
||||
if (settings.ContainsKey(settingName))
|
||||
{
|
||||
Settings[SettingName] = SettingValue;
|
||||
settings[settingName] = settingValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Add(SettingName, SettingValue);
|
||||
settings.Add(settingName, settingValue);
|
||||
}
|
||||
return Settings;
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,35 +21,35 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Site"); }
|
||||
}
|
||||
|
||||
public async Task<List<Site>> GetSitesAsync(Alias Alias)
|
||||
public async Task<List<Site>> GetSitesAsync(Alias alias)
|
||||
{
|
||||
List<Site> sites = await _http.GetJsonAsync<List<Site>>(CreateCrossTenantUrl(apiurl, Alias));
|
||||
List<Site> sites = await _http.GetJsonAsync<List<Site>>(CreateCrossTenantUrl(Apiurl, alias));
|
||||
return sites.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Site> GetSiteAsync(int SiteId, Alias Alias)
|
||||
public async Task<Site> GetSiteAsync(int siteId, Alias alias)
|
||||
{
|
||||
return await _http.GetJsonAsync<Site>(CreateCrossTenantUrl(apiurl + "/" + SiteId.ToString(), Alias));
|
||||
return await _http.GetJsonAsync<Site>(CreateCrossTenantUrl(Apiurl + "/" + siteId.ToString(), alias));
|
||||
}
|
||||
|
||||
public async Task<Site> AddSiteAsync(Site Site, Alias Alias)
|
||||
public async Task<Site> AddSiteAsync(Site site, Alias alias)
|
||||
{
|
||||
return await _http.PostJsonAsync<Site>(CreateCrossTenantUrl(apiurl, Alias), Site);
|
||||
return await _http.PostJsonAsync<Site>(CreateCrossTenantUrl(Apiurl, alias), site);
|
||||
}
|
||||
|
||||
public async Task<Site> UpdateSiteAsync(Site Site, Alias Alias)
|
||||
public async Task<Site> UpdateSiteAsync(Site site, Alias alias)
|
||||
{
|
||||
return await _http.PutJsonAsync<Site>(CreateCrossTenantUrl(apiurl + "/" + Site.SiteId.ToString(), Alias), Site);
|
||||
return await _http.PutJsonAsync<Site>(CreateCrossTenantUrl(Apiurl + "/" + site.SiteId.ToString(), alias), site);
|
||||
}
|
||||
|
||||
public async Task DeleteSiteAsync(int SiteId, Alias Alias)
|
||||
public async Task DeleteSiteAsync(int siteId, Alias alias)
|
||||
{
|
||||
await _http.DeleteAsync(CreateCrossTenantUrl(apiurl + "/" + SiteId.ToString(), Alias));
|
||||
await _http.DeleteAsync(CreateCrossTenantUrl(Apiurl + "/" + siteId.ToString(), alias));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,35 +21,35 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Tenant"); }
|
||||
}
|
||||
|
||||
public async Task<List<Tenant>> GetTenantsAsync()
|
||||
{
|
||||
List<Tenant> tenants = await _http.GetJsonAsync<List<Tenant>>(apiurl);
|
||||
List<Tenant> tenants = await _http.GetJsonAsync<List<Tenant>>(Apiurl);
|
||||
return tenants.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Tenant> GetTenantAsync(int TenantId)
|
||||
public async Task<Tenant> GetTenantAsync(int tenantId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Tenant>(apiurl + "/" + TenantId.ToString());
|
||||
return await _http.GetJsonAsync<Tenant>(Apiurl + "/" + tenantId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Tenant> AddTenantAsync(Tenant Tenant)
|
||||
public async Task<Tenant> AddTenantAsync(Tenant tenant)
|
||||
{
|
||||
return await _http.PostJsonAsync<Tenant>(apiurl, Tenant);
|
||||
return await _http.PostJsonAsync<Tenant>(Apiurl, tenant);
|
||||
}
|
||||
|
||||
public async Task<Tenant> UpdateTenantAsync(Tenant Tenant)
|
||||
public async Task<Tenant> UpdateTenantAsync(Tenant tenant)
|
||||
{
|
||||
return await _http.PutJsonAsync<Tenant>(apiurl + "/" + Tenant.TenantId.ToString(), Tenant);
|
||||
return await _http.PutJsonAsync<Tenant>(Apiurl + "/" + tenant.TenantId.ToString(), tenant);
|
||||
}
|
||||
|
||||
public async Task DeleteTenantAsync(int TenantId)
|
||||
public async Task DeleteTenantAsync(int tenantId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + TenantId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + tenantId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Theme"); }
|
||||
}
|
||||
|
||||
public async Task<List<Theme>> GetThemesAsync()
|
||||
{
|
||||
List<Theme> themes = await _http.GetJsonAsync<List<Theme>>(apiurl);
|
||||
List<Theme> themes = await _http.GetJsonAsync<List<Theme>>(Apiurl);
|
||||
|
||||
// get list of loaded assemblies
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
|
@ -45,7 +45,7 @@ namespace Oqtane.Services
|
|||
if (assemblies.Where(item => item.FullName.StartsWith(assemblyname + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await _http.GetByteArrayAsync(apiurl + "/load/" + assemblyname + ".dll");
|
||||
var bytes = await _http.GetByteArrayAsync(Apiurl + "/load/" + assemblyname + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace Oqtane.Services
|
|||
if (assemblies.Where(item => item.FullName.StartsWith(theme.AssemblyName + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await _http.GetByteArrayAsync(apiurl + "/load/" + theme.AssemblyName + ".dll");
|
||||
var bytes = await _http.GetByteArrayAsync(Apiurl + "/load/" + theme.AssemblyName + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
|
@ -61,10 +61,10 @@ namespace Oqtane.Services
|
|||
return themes.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public Dictionary<string, string> GetThemeTypes(List<Theme> Themes)
|
||||
public Dictionary<string, string> GetThemeTypes(List<Theme> themes)
|
||||
{
|
||||
var selectableThemes = new Dictionary<string, string>();
|
||||
foreach (Theme theme in Themes)
|
||||
foreach (Theme theme in themes)
|
||||
{
|
||||
foreach (string themecontrol in theme.ThemeControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
|
@ -74,12 +74,12 @@ namespace Oqtane.Services
|
|||
return selectableThemes;
|
||||
}
|
||||
|
||||
public Dictionary<string, string> GetPaneLayoutTypes(List<Theme> Themes, string ThemeName)
|
||||
public Dictionary<string, string> GetPaneLayoutTypes(List<Theme> themes, string themeName)
|
||||
{
|
||||
var selectablePaneLayouts = new Dictionary<string, string>();
|
||||
foreach (Theme theme in Themes)
|
||||
foreach (Theme theme in themes)
|
||||
{
|
||||
if (ThemeName.StartsWith(theme.ThemeName))
|
||||
if (themeName.StartsWith(theme.ThemeName))
|
||||
{
|
||||
foreach (string panelayout in theme.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
|
@ -90,10 +90,10 @@ namespace Oqtane.Services
|
|||
return selectablePaneLayouts;
|
||||
}
|
||||
|
||||
public Dictionary<string, string> GetContainerTypes(List<Theme> Themes)
|
||||
public Dictionary<string, string> GetContainerTypes(List<Theme> themes)
|
||||
{
|
||||
var selectableContainers = new Dictionary<string, string>();
|
||||
foreach (Theme theme in Themes)
|
||||
foreach (Theme theme in themes)
|
||||
{
|
||||
foreach (string container in theme.ContainerControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
|
@ -105,12 +105,12 @@ namespace Oqtane.Services
|
|||
|
||||
public async Task InstallThemesAsync()
|
||||
{
|
||||
await _http.GetJsonAsync<List<string>>(apiurl + "/install");
|
||||
await _http.GetJsonAsync<List<string>>(Apiurl + "/install");
|
||||
}
|
||||
|
||||
public async Task DeleteThemeAsync(string ThemeName)
|
||||
public async Task DeleteThemeAsync(string themeName)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + ThemeName);
|
||||
await _http.DeleteAsync(Apiurl + "/" + themeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
@ -21,34 +20,34 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "UserRole"); }
|
||||
}
|
||||
|
||||
public async Task<List<UserRole>> GetUserRolesAsync(int SiteId)
|
||||
public async Task<List<UserRole>> GetUserRolesAsync(int siteId)
|
||||
{
|
||||
return await _http.GetJsonAsync<List<UserRole>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
return await _http.GetJsonAsync<List<UserRole>>(Apiurl + "?siteid=" + siteId.ToString());
|
||||
}
|
||||
|
||||
public async Task<UserRole> GetUserRoleAsync(int UserRoleId)
|
||||
public async Task<UserRole> GetUserRoleAsync(int userRoleId)
|
||||
{
|
||||
return await _http.GetJsonAsync<UserRole>(apiurl + "/" + UserRoleId.ToString());
|
||||
return await _http.GetJsonAsync<UserRole>(Apiurl + "/" + userRoleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<UserRole> AddUserRoleAsync(UserRole UserRole)
|
||||
public async Task<UserRole> AddUserRoleAsync(UserRole userRole)
|
||||
{
|
||||
return await _http.PostJsonAsync<UserRole>(apiurl, UserRole);
|
||||
return await _http.PostJsonAsync<UserRole>(Apiurl, userRole);
|
||||
}
|
||||
|
||||
public async Task<UserRole> UpdateUserRoleAsync(UserRole UserRole)
|
||||
public async Task<UserRole> UpdateUserRoleAsync(UserRole userRole)
|
||||
{
|
||||
return await _http.PutJsonAsync<UserRole>(apiurl + "/" + UserRole.UserRoleId.ToString(), UserRole);
|
||||
return await _http.PutJsonAsync<UserRole>(Apiurl + "/" + userRole.UserRoleId.ToString(), userRole);
|
||||
}
|
||||
|
||||
public async Task DeleteUserRoleAsync(int UserRoleId)
|
||||
public async Task DeleteUserRoleAsync(int userRoleId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + UserRoleId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + userRoleId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,26 +19,26 @@ namespace Oqtane.Services
|
|||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "User"); }
|
||||
}
|
||||
|
||||
public async Task<User> GetUserAsync(int UserId, int SiteId)
|
||||
public async Task<User> GetUserAsync(int userId, int siteId)
|
||||
{
|
||||
return await _http.GetJsonAsync<User>(apiurl + "/" + UserId.ToString() + "?siteid=" + SiteId.ToString());
|
||||
return await _http.GetJsonAsync<User>(Apiurl + "/" + userId.ToString() + "?siteid=" + siteId.ToString());
|
||||
}
|
||||
|
||||
public async Task<User> GetUserAsync(string Username, int SiteId)
|
||||
public async Task<User> GetUserAsync(string username, int siteId)
|
||||
{
|
||||
return await _http.GetJsonAsync<User>(apiurl + "/name/" + Username + "?siteid=" + SiteId.ToString());
|
||||
return await _http.GetJsonAsync<User>(Apiurl + "/name/" + username + "?siteid=" + siteId.ToString());
|
||||
}
|
||||
|
||||
public async Task<User> AddUserAsync(User User)
|
||||
public async Task<User> AddUserAsync(User user)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _http.PostJsonAsync<User>(apiurl, User);
|
||||
return await _http.PostJsonAsync<User>(Apiurl, user);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -46,11 +46,11 @@ namespace Oqtane.Services
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<User> AddUserAsync(User User, Alias Alias)
|
||||
public async Task<User> AddUserAsync(User user, Alias alias)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _http.PostJsonAsync<User>(CreateCrossTenantUrl(apiurl, Alias), User);
|
||||
return await _http.PostJsonAsync<User>(CreateCrossTenantUrl(Apiurl, alias), user);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -58,39 +58,39 @@ namespace Oqtane.Services
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<User> UpdateUserAsync(User User)
|
||||
public async Task<User> UpdateUserAsync(User user)
|
||||
{
|
||||
return await _http.PutJsonAsync<User>(apiurl + "/" + User.UserId.ToString(), User);
|
||||
return await _http.PutJsonAsync<User>(Apiurl + "/" + user.UserId.ToString(), user);
|
||||
}
|
||||
public async Task DeleteUserAsync(int UserId)
|
||||
public async Task DeleteUserAsync(int userId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + UserId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + userId.ToString());
|
||||
}
|
||||
|
||||
public async Task<User> LoginUserAsync(User User, bool SetCookie, bool IsPersistent)
|
||||
public async Task<User> LoginUserAsync(User user, bool setCookie, bool isPersistent)
|
||||
{
|
||||
return await _http.PostJsonAsync<User>(apiurl + "/login?setcookie=" + SetCookie.ToString() + "&persistent=" + IsPersistent.ToString(), User);
|
||||
return await _http.PostJsonAsync<User>(Apiurl + "/login?setcookie=" + setCookie.ToString() + "&persistent=" + isPersistent.ToString(), user);
|
||||
}
|
||||
|
||||
public async Task LogoutUserAsync(User User)
|
||||
public async Task LogoutUserAsync(User user)
|
||||
{
|
||||
// best practices recommend post is preferrable to get for logout
|
||||
await _http.PostJsonAsync(apiurl + "/logout", User);
|
||||
await _http.PostJsonAsync(Apiurl + "/logout", user);
|
||||
}
|
||||
|
||||
public async Task<User> VerifyEmailAsync(User User, string Token)
|
||||
public async Task<User> VerifyEmailAsync(User user, string token)
|
||||
{
|
||||
return await _http.PostJsonAsync<User>(apiurl + "/verify?token=" + Token, User);
|
||||
return await _http.PostJsonAsync<User>(Apiurl + "/verify?token=" + token, user);
|
||||
}
|
||||
|
||||
public async Task ForgotPasswordAsync(User User)
|
||||
public async Task ForgotPasswordAsync(User user)
|
||||
{
|
||||
await _http.PostJsonAsync(apiurl + "/forgot", User);
|
||||
await _http.PostJsonAsync(Apiurl + "/forgot", user);
|
||||
}
|
||||
|
||||
public async Task<User> ResetPasswordAsync(User User, string Token)
|
||||
public async Task<User> ResetPasswordAsync(User user, string token)
|
||||
{
|
||||
return await _http.PostJsonAsync<User>(apiurl + "/reset?token=" + Token, User);
|
||||
return await _http.PostJsonAsync<User>(Apiurl + "/reset?token=" + token, user);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
@namespace Oqtane.Themes.Controls
|
||||
@using Oqtane.Enums
|
||||
@inherits ThemeControlBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IUserService UserService
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Oqtane.Themes
|
|||
Url = ThemePath() + Url;
|
||||
}
|
||||
var interop = new Interop(JSRuntime);
|
||||
await interop.IncludeCSS("Theme", Url);
|
||||
await interop.IncludeCss("Theme", Url);
|
||||
}
|
||||
|
||||
public string NavigateUrl()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@namespace Oqtane.UI
|
||||
|
||||
<CascadingValue Value="@ModuleState">
|
||||
<CascadingValue Value="@_moduleState">
|
||||
@DynamicComponent
|
||||
</CascadingValue>
|
||||
|
||||
|
@ -13,13 +13,13 @@
|
|||
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
Module ModuleState;
|
||||
Module _moduleState;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
ModuleState = Module; // passed in from Pane component
|
||||
string container = ModuleState.ContainerType;
|
||||
if (PageState.ModuleId != -1 && PageState.Action != "" && ModuleState.UseAdminContainer)
|
||||
_moduleState = Module; // passed in from Pane component
|
||||
string container = _moduleState.ContainerType;
|
||||
if (PageState.ModuleId != -1 && PageState.Action != "" && _moduleState.UseAdminContainer)
|
||||
{
|
||||
container = Constants.DefaultAdminContainer;
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Title" class="control-label" style="font-weight: bold">Database Type: </label>
|
||||
<label class="control-label" style="font-weight: bold">Database Type: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="custom-select" @bind="@DatabaseType">
|
||||
<select class="custom-select" @bind="@_databaseType">
|
||||
<option value="LocalDB">Local Database</option>
|
||||
<option value="SQLServer">SQL Server</option>
|
||||
</select>
|
||||
|
@ -29,23 +29,23 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Title" class="control-label" style="font-weight: bold">Server: </label>
|
||||
<label class="control-label" style="font-weight: bold">Server: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control" @bind="@ServerName" />
|
||||
<input type="text" class="form-control" @bind="@_serverName" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Title" class="control-label" style="font-weight: bold">Database: </label>
|
||||
<label class="control-label" style="font-weight: bold">Database: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control" @bind="@DatabaseName" />
|
||||
<input type="text" class="form-control" @bind="@_databaseName" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Title" class="control-label" style="font-weight: bold">Integrated Security: </label>
|
||||
<label class="control-label" style="font-weight: bold">Integrated Security: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="custom-select" @onchange="SetIntegratedSecurity">
|
||||
|
@ -54,20 +54,20 @@
|
|||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="@IntegratedSecurityDisplay">
|
||||
<tr style="@_integratedSecurityDisplay">
|
||||
<td>
|
||||
<label for="Title" class="control-label" style="font-weight: bold">Username: </label>
|
||||
<label class="control-label" style="font-weight: bold">Username: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control" @bind="@Username" />
|
||||
<input type="text" class="form-control" @bind="@_username" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="@IntegratedSecurityDisplay">
|
||||
<tr style="@_integratedSecurityDisplay">
|
||||
<td>
|
||||
<label for="Title" class="control-label" style="font-weight: bold">Password: </label>
|
||||
<label class="control-label" style="font-weight: bold">Password: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" class="form-control" @bind="@Password" />
|
||||
<input type="password" class="form-control" @bind="@_password" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -79,34 +79,34 @@
|
|||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Title" class="control-label" style="font-weight: bold">Username: </label>
|
||||
<label class="control-label" style="font-weight: bold">Username: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control" @bind="@HostUsername" readonly />
|
||||
<input type="text" class="form-control" @bind="@_hostUsername" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Title" class="control-label" style="font-weight: bold">Password: </label>
|
||||
<label class="control-label" style="font-weight: bold">Password: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" class="form-control" @bind="@HostPassword" />
|
||||
<input type="password" class="form-control" @bind="@_hostPassword" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Title" class="control-label" style="font-weight: bold">Confirm: </label>
|
||||
<label class="control-label" style="font-weight: bold">Confirm: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" class="form-control" @bind="@ConfirmPassword" />
|
||||
<input type="password" class="form-control" @bind="@_confirmPassword" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Title" class="control-label" style="font-weight: bold">Email: </label>
|
||||
<label class="control-label" style="font-weight: bold">Email: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control" @bind="@HostEmail" />
|
||||
<input type="text" class="form-control" @bind="@_hostEmail" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -117,61 +117,61 @@
|
|||
<div class="row">
|
||||
<div class="mx-auto text-center">
|
||||
<button type="button" class="btn btn-success" @onclick="Install">Install Now</button><br /><br />
|
||||
@((MarkupString)@Message)
|
||||
@((MarkupString)_message)
|
||||
</div>
|
||||
<div class="app-progress-indicator" style="@LoadingDisplay"></div>
|
||||
<div class="app-progress-indicator" style="@_loadingDisplay"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private string DatabaseType = "LocalDB";
|
||||
private string ServerName = "(LocalDb)\\MSSQLLocalDB";
|
||||
private string DatabaseName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
|
||||
private string Username = "";
|
||||
private string Password = "";
|
||||
private string HostUsername = Constants.HostUser;
|
||||
private string HostPassword = "";
|
||||
private string ConfirmPassword = "";
|
||||
private string HostEmail = "";
|
||||
private string Message = "";
|
||||
private string _databaseType = "LocalDB";
|
||||
private string _serverName = "(LocalDb)\\MSSQLLocalDB";
|
||||
private string _databaseName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
|
||||
private string _username = "";
|
||||
private string _password = "";
|
||||
private string _hostUsername = Constants.HostUser;
|
||||
private string _hostPassword = "";
|
||||
private string _confirmPassword = "";
|
||||
private string _hostEmail = "";
|
||||
private string _message = "";
|
||||
|
||||
private string IntegratedSecurityDisplay = "display: none;";
|
||||
private string LoadingDisplay = "display: none;";
|
||||
private string _integratedSecurityDisplay = "display: none;";
|
||||
private string _loadingDisplay = "display: none;";
|
||||
|
||||
private void SetIntegratedSecurity(ChangeEventArgs e)
|
||||
{
|
||||
if (Convert.ToBoolean((string)e.Value))
|
||||
{
|
||||
IntegratedSecurityDisplay = "display: none;";
|
||||
_integratedSecurityDisplay = "display: none;";
|
||||
}
|
||||
else
|
||||
{
|
||||
IntegratedSecurityDisplay = "";
|
||||
_integratedSecurityDisplay = "";
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Install()
|
||||
{
|
||||
if (HostUsername != "" && HostPassword.Length >= 6 && HostPassword == ConfirmPassword && HostEmail != "")
|
||||
if (_hostUsername != "" && _hostPassword.Length >= 6 && _hostPassword == _confirmPassword && _hostEmail != "")
|
||||
{
|
||||
LoadingDisplay = "";
|
||||
_loadingDisplay = "";
|
||||
StateHasChanged();
|
||||
|
||||
string connectionstring = "";
|
||||
if (DatabaseType == "LocalDB")
|
||||
if (_databaseType == "LocalDB")
|
||||
{
|
||||
connectionstring = "Data Source=" + ServerName + ";AttachDbFilename=|DataDirectory|\\" + DatabaseName + ".mdf;Initial Catalog=" + DatabaseName + ";Integrated Security=SSPI;";
|
||||
connectionstring = "Data Source=" + _serverName + ";AttachDbFilename=|DataDirectory|\\" + _databaseName + ".mdf;Initial Catalog=" + _databaseName + ";Integrated Security=SSPI;";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionstring = "Data Source=" + ServerName + ";Initial Catalog=" + DatabaseName + ";";
|
||||
if (IntegratedSecurityDisplay == "display: none;")
|
||||
connectionstring = "Data Source=" + _serverName + ";Initial Catalog=" + _databaseName + ";";
|
||||
if (_integratedSecurityDisplay == "display: none;")
|
||||
{
|
||||
connectionstring += "Integrated Security=SSPI;";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionstring += "User ID=" + Username + ";Password=" + Password;
|
||||
connectionstring += "User ID=" + _username + ";Password=" + _password;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -189,23 +189,23 @@
|
|||
|
||||
User user = new User();
|
||||
user.SiteId = site.SiteId;
|
||||
user.Username = HostUsername;
|
||||
user.Password = HostPassword;
|
||||
user.Email = HostEmail;
|
||||
user.DisplayName = HostUsername;
|
||||
user.Username = _hostUsername;
|
||||
user.Password = _hostPassword;
|
||||
user.Email = _hostEmail;
|
||||
user.DisplayName = _hostUsername;
|
||||
user = await UserService.AddUserAsync(user);
|
||||
|
||||
NavigationManager.NavigateTo("", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Message = "<div class=\"alert alert-danger\" role=\"alert\">" + response.Message + "</div>";
|
||||
LoadingDisplay = "display: none;";
|
||||
_message = "<div class=\"alert alert-danger\" role=\"alert\">" + response.Message + "</div>";
|
||||
_loadingDisplay = "display: none;";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Message = "<div class=\"alert alert-danger\" role=\"alert\">Please Enter All Fields And Ensure Passwords Match And Are Greater Than 5 Characters In Length</div>";
|
||||
_message = "<div class=\"alert alert-danger\" role=\"alert\">Please Enter All Fields And Ensure Passwords Match And Are Greater Than 5 Characters In Length</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace Oqtane.UI
|
|||
}
|
||||
}
|
||||
|
||||
public Task IncludeCSS(string id, string url)
|
||||
public Task IncludeCss(string id, string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
@namespace Oqtane.UI
|
||||
|
||||
<ModuleMessage Message="@message" Type="MessageType.Error" />
|
||||
<ModuleMessage Message="@_message" Type="MessageType.Error" />
|
||||
<CascadingValue Value="this">
|
||||
<ModuleMessage @ref="modulemessage" />
|
||||
<ModuleMessage @ref="ModuleMessage" />
|
||||
@DynamicComponent
|
||||
</CascadingValue>
|
||||
@if (progressindicator)
|
||||
@if (_progressindicator)
|
||||
{
|
||||
<div class="app-progress-indicator"></div>
|
||||
}
|
||||
|
@ -17,12 +17,12 @@
|
|||
[CascadingParameter]
|
||||
private Module ModuleState { get; set; }
|
||||
|
||||
private ModuleMessage modulemessage { get; set; }
|
||||
string message;
|
||||
private ModuleMessage ModuleMessage { get; set; }
|
||||
string _message;
|
||||
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
bool progressindicator = false;
|
||||
bool _progressindicator = false;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
|
@ -48,12 +48,12 @@
|
|||
else
|
||||
{
|
||||
// module does not exist with typename specified
|
||||
message = "Module Does Not Have A Component Named " + Utilities.GetTypeNameLastSegment(typename, 0) + ".razor";
|
||||
_message = "Module Does Not Have A Component Named " + Utilities.GetTypeNameLastSegment(typename, 0) + ".razor";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "Something is wrong with moduletype";
|
||||
_message = "Something is wrong with moduletype";
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -61,20 +61,20 @@
|
|||
|
||||
public void AddModuleMessage(string message, MessageType type)
|
||||
{
|
||||
progressindicator = false;
|
||||
_progressindicator = false;
|
||||
StateHasChanged();
|
||||
modulemessage.SetModuleMessage(message, type);
|
||||
ModuleMessage.SetModuleMessage(message, type);
|
||||
}
|
||||
|
||||
public void ShowProgressIndicator()
|
||||
{
|
||||
progressindicator = true;
|
||||
_progressindicator = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
public void HideProgressIndicator()
|
||||
{
|
||||
progressindicator = false;
|
||||
_progressindicator = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
@inject IModuleService ModuleService
|
||||
@inject IModuleDefinitionService ModuleDefinitionService
|
||||
|
||||
<div class="@paneadminborder">
|
||||
@if (panetitle != "")
|
||||
<div class="@_paneadminborder">
|
||||
@if (_panetitle != "")
|
||||
{
|
||||
@((MarkupString)panetitle)
|
||||
@((MarkupString)_panetitle)
|
||||
}
|
||||
@DynamicComponent
|
||||
</div>
|
||||
|
@ -20,20 +20,20 @@
|
|||
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
string paneadminborder = "";
|
||||
string panetitle = "";
|
||||
string _paneadminborder = "";
|
||||
string _panetitle = "";
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (PageState.EditMode && !PageState.Page.EditMode && UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, PageState.Page.Permissions) && Name != Constants.AdminPane)
|
||||
{
|
||||
paneadminborder = "app-pane-admin-border";
|
||||
panetitle = "<div class=\"app-pane-admin-title\">" + Name + " Pane</div>";
|
||||
_paneadminborder = "app-pane-admin-border";
|
||||
_panetitle = "<div class=\"app-pane-admin-title\">" + Name + " Pane</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
paneadminborder = "";
|
||||
panetitle = "";
|
||||
_paneadminborder = "";
|
||||
_panetitle = "";
|
||||
}
|
||||
|
||||
DynamicComponent = builder =>
|
||||
|
@ -42,12 +42,12 @@
|
|||
{
|
||||
if (Name.ToLower() == Constants.AdminPane.ToLower())
|
||||
{
|
||||
Module module = PageState.Modules.Where(item => item.ModuleId == PageState.ModuleId).FirstOrDefault();
|
||||
Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
|
||||
if (module != null)
|
||||
{
|
||||
string typename = module.ModuleType;
|
||||
// check for core module actions component
|
||||
if (Constants.DefaultModuleActions.Contains(PageState.Action))
|
||||
// check for core module actions component
|
||||
if (Constants.DefaultModuleActions.Contains(PageState.Action))
|
||||
{
|
||||
typename = Constants.DefaultModuleActionsTemplate.Replace(Constants.ActionToken, PageState.Action);
|
||||
}
|
||||
|
@ -57,21 +57,21 @@
|
|||
bool authorized = false;
|
||||
if (Constants.DefaultModuleActions.Contains(PageState.Action))
|
||||
{
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, PageState.Page.Permissions);
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.Permissions);
|
||||
}
|
||||
else
|
||||
{
|
||||
// verify security access level for this module control
|
||||
switch (module.SecurityAccessLevel)
|
||||
// verify security access level for this module control
|
||||
switch (module.SecurityAccessLevel)
|
||||
{
|
||||
case SecurityAccessLevel.Anonymous:
|
||||
authorized = true;
|
||||
break;
|
||||
case SecurityAccessLevel.View:
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, module.Permissions);
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions);
|
||||
break;
|
||||
case SecurityAccessLevel.Edit:
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, module.Permissions);
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, module.Permissions);
|
||||
break;
|
||||
case SecurityAccessLevel.Admin:
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole);
|
||||
|
@ -94,7 +94,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
// module control does not exist with name specified
|
||||
// module control does not exist with name specified
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,11 +103,11 @@
|
|||
{
|
||||
if (PageState.ModuleId != -1)
|
||||
{
|
||||
Module module = PageState.Modules.Where(item => item.ModuleId == PageState.ModuleId).FirstOrDefault();
|
||||
Module 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
|
||||
if (UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, module.Permissions))
|
||||
// check if user is authorized to view module
|
||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions))
|
||||
{
|
||||
builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
|
||||
builder.AddAttribute(1, "Module", module);
|
||||
|
@ -119,8 +119,8 @@
|
|||
{
|
||||
foreach (Module module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId && item.Pane.ToLower() == Name.ToLower() && !item.IsDeleted).OrderBy(x => x.Order).ToArray())
|
||||
{
|
||||
// check if user is authorized to view module
|
||||
if (UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, module.Permissions))
|
||||
// check if user is authorized to view module
|
||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions))
|
||||
{
|
||||
builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
|
||||
builder.AddAttribute(1, "Module", module);
|
||||
|
@ -129,7 +129,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Oqtane.UI
|
|||
quillElement);
|
||||
}
|
||||
|
||||
internal static ValueTask<string> GetHTML(
|
||||
internal static ValueTask<string> GetHtml(
|
||||
IJSRuntime jsRuntime,
|
||||
ElementReference quillElement)
|
||||
{
|
||||
|
@ -51,11 +51,11 @@ namespace Oqtane.UI
|
|||
internal static ValueTask<object> LoadEditorContent(
|
||||
IJSRuntime jsRuntime,
|
||||
ElementReference quillElement,
|
||||
string Content)
|
||||
string content)
|
||||
{
|
||||
return jsRuntime.InvokeAsync<object>(
|
||||
"interop.loadQuillContent",
|
||||
quillElement, Content);
|
||||
quillElement, content);
|
||||
}
|
||||
|
||||
internal static ValueTask<object> EnableEditor(
|
||||
|
@ -70,11 +70,11 @@ namespace Oqtane.UI
|
|||
internal static ValueTask<object> InsertImage(
|
||||
IJSRuntime jsRuntime,
|
||||
ElementReference quillElement,
|
||||
string ImageURL)
|
||||
string imageUrl)
|
||||
{
|
||||
return jsRuntime.InvokeAsync<object>(
|
||||
"interop.insertQuillImage",
|
||||
quillElement, ImageURL);
|
||||
quillElement, imageUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
@inject IModuleService ModuleService
|
||||
@inject IModuleDefinitionService ModuleDefinitionService
|
||||
@inject ILogService LogService
|
||||
@using System.Diagnostics.CodeAnalysis
|
||||
@using Oqtane.Enums
|
||||
@implements IHandleAfterRender
|
||||
|
||||
@DynamicComponent
|
||||
|
@ -23,7 +25,7 @@
|
|||
[Parameter]
|
||||
public Action<PageState> OnStateChange { get; set; }
|
||||
|
||||
PageState pagestate;
|
||||
PageState _pagestate;
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
string _absoluteUri;
|
||||
|
@ -65,6 +67,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "StringIndexOfIsCultureSpecific.1")]
|
||||
private async Task Refresh()
|
||||
{
|
||||
Alias alias = null;
|
||||
|
@ -235,18 +238,20 @@
|
|||
{
|
||||
page = await ProcessPage(page, site, user);
|
||||
|
||||
pagestate = new PageState();
|
||||
pagestate.Alias = alias;
|
||||
pagestate.Site = site;
|
||||
pagestate.Pages = pages;
|
||||
pagestate.Page = page;
|
||||
pagestate.User = user;
|
||||
pagestate.Uri = new Uri(_absoluteUri, UriKind.Absolute);
|
||||
pagestate.QueryString = querystring;
|
||||
pagestate.ModuleId = moduleid;
|
||||
pagestate.Action = action;
|
||||
_pagestate = new PageState
|
||||
{
|
||||
Alias = alias,
|
||||
Site = site,
|
||||
Pages = pages,
|
||||
Page = page,
|
||||
User = user,
|
||||
Uri = new Uri(_absoluteUri, UriKind.Absolute),
|
||||
QueryString = querystring,
|
||||
ModuleId = moduleid,
|
||||
Action = action
|
||||
};
|
||||
|
||||
if (PageState != null && (PageState.ModuleId != pagestate.ModuleId || PageState.Action != pagestate.Action))
|
||||
if (PageState != null && (PageState.ModuleId != _pagestate.ModuleId || PageState.Action != _pagestate.Action))
|
||||
{
|
||||
reload = Reload.Page;
|
||||
}
|
||||
|
@ -254,17 +259,17 @@
|
|||
if (PageState == null || reload >= Reload.Page)
|
||||
{
|
||||
modules = await ModuleService.GetModulesAsync(site.SiteId);
|
||||
modules = ProcessModules(modules, page.PageId, pagestate.ModuleId, pagestate.Action, page.Panes, site.DefaultContainerType);
|
||||
modules = ProcessModules(modules, page.PageId, _pagestate.ModuleId, _pagestate.Action, page.Panes, site.DefaultContainerType);
|
||||
}
|
||||
else
|
||||
{
|
||||
modules = PageState.Modules;
|
||||
}
|
||||
pagestate.Modules = modules;
|
||||
pagestate.EditMode = editmode;
|
||||
pagestate.LastSyncDate = lastsyncdate;
|
||||
_pagestate.Modules = modules;
|
||||
_pagestate.EditMode = editmode;
|
||||
_pagestate.LastSyncDate = lastsyncdate;
|
||||
|
||||
OnStateChange?.Invoke(pagestate);
|
||||
OnStateChange?.Invoke(_pagestate);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
@namespace Oqtane.UI
|
||||
@inject IJSRuntime jsRuntime
|
||||
@inject IJSRuntime JsRuntime
|
||||
|
||||
@DynamicComponent
|
||||
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Globalization;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -49,11 +50,11 @@ namespace Oqtane.Controllers
|
|||
name = WebUtility.UrlDecode(name);
|
||||
List<Alias> aliases = _aliases.GetAliases().ToList();
|
||||
Alias alias = null;
|
||||
alias = aliases.Where(item => item.Name == name).FirstOrDefault();
|
||||
if (alias == null && name.Contains("/"))
|
||||
alias = aliases.FirstOrDefault(item => item.Name == name);
|
||||
if (name != null && (alias == null && name.Contains("/")))
|
||||
{
|
||||
// lookup alias without folder name
|
||||
alias = aliases.Find(item => item.Name == name.Substring(0, name.IndexOf("/")));
|
||||
alias = aliases.Find(item => item.Name == name.Substring(0, name.IndexOf("/", StringComparison.Ordinal)));
|
||||
}
|
||||
if (alias == null && aliases.Count > 0)
|
||||
{
|
||||
|
@ -71,27 +72,27 @@ namespace Oqtane.Controllers
|
|||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public Alias Post([FromBody] Alias Alias)
|
||||
public Alias Post([FromBody] Alias alias)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Alias = _aliases.AddAlias(Alias);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Alias Added {Alias}", Alias);
|
||||
alias = _aliases.AddAlias(alias);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Alias Added {Alias}", alias);
|
||||
}
|
||||
return Alias;
|
||||
return alias;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public Alias Put(int id, [FromBody] Alias Alias)
|
||||
public Alias Put(int id, [FromBody] Alias alias)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Alias = _aliases.UpdateAlias(Alias);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Alias Updated {Alias}", Alias);
|
||||
alias = _aliases.UpdateAlias(alias);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Alias Updated {Alias}", alias);
|
||||
}
|
||||
return Alias;
|
||||
return alias;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using System;
|
||||
|
@ -15,6 +13,11 @@ using Oqtane.Security;
|
|||
using System.Linq;
|
||||
using System.Drawing;
|
||||
using System.Net;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
|
||||
// ReSharper disable StringIndexOfIsCultureSpecific.1
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -61,14 +64,15 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
foreach (string file in Directory.GetFiles(folder))
|
||||
{
|
||||
files.Add(new Models.File { Name = Path.GetFileName(file), Extension = Path.GetExtension(file).Replace(".","") });
|
||||
files.Add(new Models.File {Name = Path.GetFileName(file), Extension = Path.GetExtension(file)?.Replace(".", "")});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
|
||||
// GET: api/<controller>/siteId/folderPath
|
||||
[HttpGet("{siteId}/{path}")]
|
||||
public IEnumerable<Models.File> Get(int siteId, string path)
|
||||
|
@ -95,6 +99,7 @@ namespace Oqtane.Controllers
|
|||
HttpContext.Response.StatusCode = 401;
|
||||
return null;
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
|
@ -103,7 +108,7 @@ namespace Oqtane.Controllers
|
|||
public Models.File Get(int id)
|
||||
{
|
||||
Models.File file = _files.GetFile(id);
|
||||
if (_userPermissions.IsAuthorized(User,PermissionNames.View, file.Folder.Permissions))
|
||||
if (_userPermissions.IsAuthorized(User, PermissionNames.View, file.Folder.Permissions))
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
@ -118,20 +123,21 @@ namespace Oqtane.Controllers
|
|||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Models.File Put(int id, [FromBody] Models.File File)
|
||||
public Models.File Put(int id, [FromBody] Models.File file)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, File.Folder.FolderId, PermissionNames.Edit))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, file.Folder.FolderId, PermissionNames.Edit))
|
||||
{
|
||||
File = _files.UpdateFile(File);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "File Updated {File}", File);
|
||||
file = _files.UpdateFile(file);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "File Updated {File}", file);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update File {File}", File);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update File {File}", file);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
File = null;
|
||||
file = null;
|
||||
}
|
||||
return File;
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
|
@ -149,6 +155,7 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
System.IO.File.Delete(filepath);
|
||||
}
|
||||
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "File Deleted {File}", file);
|
||||
}
|
||||
else
|
||||
|
@ -164,24 +171,25 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
Models.File file = null;
|
||||
Folder folder = _folders.GetFolder(int.Parse(folderid));
|
||||
if (folder != null && _userPermissions.IsAuthorized(User,PermissionNames.Edit, folder.Permissions))
|
||||
if (folder != null && _userPermissions.IsAuthorized(User, PermissionNames.Edit, folder.Permissions))
|
||||
{
|
||||
string folderpath = GetFolderPath(folder);
|
||||
CreateDirectory(folderpath);
|
||||
string filename = url.Substring(url.LastIndexOf("/") + 1);
|
||||
string folderPath = GetFolderPath(folder);
|
||||
CreateDirectory(folderPath);
|
||||
string filename = url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1);
|
||||
// check for allowable file extensions
|
||||
if (Constants.UploadableFiles.Contains(Path.GetExtension(filename).Replace(".", "")))
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = new System.Net.WebClient();
|
||||
var client = new WebClient();
|
||||
// remove file if it already exists
|
||||
if (System.IO.File.Exists(folderpath + filename))
|
||||
if (System.IO.File.Exists(folderPath + filename))
|
||||
{
|
||||
System.IO.File.Delete(folderpath + filename);
|
||||
System.IO.File.Delete(folderPath + filename);
|
||||
}
|
||||
client.DownloadFile(url, folderpath + filename);
|
||||
_files.AddFile(CreateFile(filename, folder.FolderId, folderpath + filename));
|
||||
|
||||
client.DownloadFile(url, folderPath + filename);
|
||||
_files.AddFile(CreateFile(filename, folder.FolderId, folderPath + filename));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -197,45 +205,47 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Download File {Url} {FolderId}", url, folderid);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
file = null;
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
// POST api/<controller>/upload
|
||||
[HttpPost("upload")]
|
||||
public async Task UploadFile(string folder, IFormFile file)
|
||||
{
|
||||
if (file.Length > 0)
|
||||
{
|
||||
string folderpath = "";
|
||||
int folderid = -1;
|
||||
if (int.TryParse(folder, out folderid))
|
||||
string folderPath = "";
|
||||
|
||||
if (int.TryParse(folder, out int folderId))
|
||||
{
|
||||
Folder Folder = _folders.GetFolder(folderid);
|
||||
if (Folder != null && _userPermissions.IsAuthorized(User,PermissionNames.Edit, Folder.Permissions))
|
||||
Folder virtualFolder = _folders.GetFolder(folderId);
|
||||
if (virtualFolder != null && _userPermissions.IsAuthorized(User, PermissionNames.Edit, virtualFolder.Permissions))
|
||||
{
|
||||
folderpath = GetFolderPath(Folder);
|
||||
folderPath = GetFolderPath(virtualFolder);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (User.IsInRole(Constants.HostRole))
|
||||
{
|
||||
folderpath = GetFolderPath(folder);
|
||||
folderPath = GetFolderPath(folder);
|
||||
}
|
||||
}
|
||||
if (folderpath != "")
|
||||
|
||||
if (folderPath != "")
|
||||
{
|
||||
CreateDirectory(folderpath);
|
||||
using (var stream = new FileStream(Path.Combine(folderpath, file.FileName), FileMode.Create))
|
||||
CreateDirectory(folderPath);
|
||||
using (var stream = new FileStream(Path.Combine(folderPath, file.FileName), FileMode.Create))
|
||||
{
|
||||
await file.CopyToAsync(stream);
|
||||
}
|
||||
string upload = await MergeFile(folderpath, file.FileName);
|
||||
if (upload != "" && folderid != -1)
|
||||
|
||||
string upload = await MergeFile(folderPath, file.FileName);
|
||||
if (upload != "" && folderId != -1)
|
||||
{
|
||||
_files.AddFile(CreateFile(upload, folderid, folderpath + upload));
|
||||
_files.AddFile(CreateFile(upload, folderId, folderPath + upload));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -252,19 +262,19 @@ namespace Oqtane.Controllers
|
|||
|
||||
// parse the filename which is in the format of filename.ext.part_x_y
|
||||
string token = ".part_";
|
||||
string parts = Path.GetExtension(filename).Replace(token, ""); // returns "x_y"
|
||||
int totalparts = int.Parse(parts.Substring(parts.IndexOf("_") + 1));
|
||||
filename = filename.Substring(0, filename.IndexOf(token)); // base filename
|
||||
string[] fileparts = Directory.GetFiles(folder, filename + token + "*"); // list of all file parts
|
||||
string parts = Path.GetExtension(filename)?.Replace(token, ""); // returns "x_y"
|
||||
int totalparts = int.Parse(parts?.Substring(parts.IndexOf("_") + 1));
|
||||
filename = filename?.Substring(0, filename.IndexOf(token)); // base filename
|
||||
string[] fileParts = Directory.GetFiles(folder, filename + token + "*"); // list of all file parts
|
||||
|
||||
// if all of the file parts exist ( note that file parts can arrive out of order )
|
||||
if (fileparts.Length == totalparts && CanAccessFiles(fileparts))
|
||||
if (fileParts.Length == totalparts && CanAccessFiles(fileParts))
|
||||
{
|
||||
// merge file parts
|
||||
bool success = true;
|
||||
using (var stream = new FileStream(Path.Combine(folder, filename + ".tmp"), FileMode.Create))
|
||||
{
|
||||
foreach (string filepart in fileparts)
|
||||
foreach (string filepart in fileParts)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -283,13 +293,13 @@ namespace Oqtane.Controllers
|
|||
// delete file parts and rename file
|
||||
if (success)
|
||||
{
|
||||
foreach (string filepart in fileparts)
|
||||
foreach (string filepart in fileParts)
|
||||
{
|
||||
System.IO.File.Delete(filepart);
|
||||
}
|
||||
|
||||
// check for allowable file extensions
|
||||
if (!Constants.UploadableFiles.Contains(Path.GetExtension(filename).Replace(".", "")))
|
||||
if (!Constants.UploadableFiles.Contains(Path.GetExtension(filename)?.Replace(".", "")))
|
||||
{
|
||||
System.IO.File.Delete(Path.Combine(folder, filename + ".tmp"));
|
||||
}
|
||||
|
@ -300,17 +310,19 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
System.IO.File.Delete(Path.Combine(folder, filename));
|
||||
}
|
||||
|
||||
// rename file now that the entire process is completed
|
||||
System.IO.File.Move(Path.Combine(folder, filename + ".tmp"), Path.Combine(folder, filename));
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "File Uploaded {File}", Path.Combine(folder, filename));
|
||||
}
|
||||
|
||||
merged = filename;
|
||||
}
|
||||
}
|
||||
|
||||
// clean up file parts which are more than 2 hours old ( which can happen if a prior file upload failed )
|
||||
fileparts = Directory.GetFiles(folder, "*" + token + "*");
|
||||
foreach (string filepart in fileparts)
|
||||
fileParts = Directory.GetFiles(folder, "*" + token + "*");
|
||||
foreach (string filepart in fileParts)
|
||||
{
|
||||
DateTime createddate = System.IO.File.GetCreationTime(filepart).ToUniversalTime();
|
||||
if (createddate < DateTime.UtcNow.AddHours(-2))
|
||||
|
@ -331,7 +343,7 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
int attempts = 0;
|
||||
bool locked = true;
|
||||
while (attempts < 5 && locked == true)
|
||||
while (attempts < 5 && locked)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -339,7 +351,7 @@ namespace Oqtane.Controllers
|
|||
locked = false;
|
||||
}
|
||||
catch // file is locked by another process
|
||||
{
|
||||
{
|
||||
Thread.Sleep(1000); // wait 1 second
|
||||
}
|
||||
finally
|
||||
|
@ -349,13 +361,16 @@ namespace Oqtane.Controllers
|
|||
stream.Close();
|
||||
}
|
||||
}
|
||||
|
||||
attempts += 1;
|
||||
}
|
||||
|
||||
if (locked && canaccess)
|
||||
{
|
||||
canaccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
return canaccess;
|
||||
}
|
||||
|
||||
|
@ -364,7 +379,7 @@ namespace Oqtane.Controllers
|
|||
public IActionResult Download(int id)
|
||||
{
|
||||
Models.File file = _files.GetFile(id);
|
||||
if (file != null && _userPermissions.IsAuthorized(User,PermissionNames.View, file.Folder.Permissions))
|
||||
if (file != null && _userPermissions.IsAuthorized(User, PermissionNames.View, file.Folder.Permissions))
|
||||
{
|
||||
string filepath = GetFolderPath(file.Folder) + file.Name;
|
||||
if (System.IO.File.Exists(filepath))
|
||||
|
@ -402,7 +417,7 @@ namespace Oqtane.Controllers
|
|||
if (!Directory.Exists(folderpath))
|
||||
{
|
||||
string path = "";
|
||||
string[] folders = folderpath.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] folders = folderpath.Split(new[] {'\\'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string folder in folders)
|
||||
{
|
||||
path += folder + "\\";
|
||||
|
@ -422,7 +437,7 @@ namespace Oqtane.Controllers
|
|||
|
||||
FileInfo fileinfo = new FileInfo(filepath);
|
||||
file.Extension = fileinfo.Extension.ToLower().Replace(".", "");
|
||||
file.Size = (int)fileinfo.Length;
|
||||
file.Size = (int) fileinfo.Length;
|
||||
file.ImageHeight = 0;
|
||||
file.ImageWidth = 0;
|
||||
|
||||
|
@ -434,6 +449,7 @@ namespace Oqtane.Controllers
|
|||
file.ImageHeight = image.Height;
|
||||
file.ImageWidth = image.Width;
|
||||
}
|
||||
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Security;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
|
@ -86,14 +87,14 @@ namespace Oqtane.Controllers
|
|||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Folder Post([FromBody] Folder Folder)
|
||||
public Folder Post([FromBody] Folder folder)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
string permissions;
|
||||
if (Folder.ParentId != null)
|
||||
if (folder.ParentId != null)
|
||||
{
|
||||
permissions = _folders.GetFolder(Folder.ParentId.Value).Permissions;
|
||||
permissions = _folders.GetFolder(folder.ParentId.Value).Permissions;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -101,46 +102,46 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
if (_userPermissions.IsAuthorized(User,PermissionNames.Edit, permissions))
|
||||
{
|
||||
if (string.IsNullOrEmpty(Folder.Path) && Folder.ParentId != null)
|
||||
if (string.IsNullOrEmpty(folder.Path) && folder.ParentId != null)
|
||||
{
|
||||
Folder parent = _folders.GetFolder(Folder.ParentId.Value);
|
||||
Folder.Path = parent.Path + Folder.Name + "\\";
|
||||
Folder parent = _folders.GetFolder(folder.ParentId.Value);
|
||||
folder.Path = parent.Path + folder.Name + "\\";
|
||||
}
|
||||
Folder = _folders.AddFolder(Folder);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Folder Added {Folder}", Folder);
|
||||
folder = _folders.AddFolder(folder);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Folder Added {Folder}", folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Folder {Folder}", Folder);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Folder {Folder}", folder);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Folder = null;
|
||||
folder = null;
|
||||
}
|
||||
}
|
||||
return Folder;
|
||||
return folder;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Folder Put(int id, [FromBody] Folder Folder)
|
||||
public Folder Put(int id, [FromBody] Folder folder)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, Folder.FolderId, PermissionNames.Edit))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, folder.FolderId, PermissionNames.Edit))
|
||||
{
|
||||
if (string.IsNullOrEmpty(Folder.Path) && Folder.ParentId != null)
|
||||
if (string.IsNullOrEmpty(folder.Path) && folder.ParentId != null)
|
||||
{
|
||||
Folder parent = _folders.GetFolder(Folder.ParentId.Value);
|
||||
Folder.Path = parent.Path + Folder.Name + "\\";
|
||||
Folder parent = _folders.GetFolder(folder.ParentId.Value);
|
||||
folder.Path = parent.Path + folder.Name + "\\";
|
||||
}
|
||||
Folder = _folders.UpdateFolder(Folder);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Folder Updated {Folder}", Folder);
|
||||
folder = _folders.UpdateFolder(folder);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Folder Updated {Folder}", folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Folder {Folder}", Folder);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Folder {Folder}", folder);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Folder = null;
|
||||
folder = null;
|
||||
}
|
||||
return Folder;
|
||||
return folder;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/?siteid=x&folderid=y&parentid=z
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
using DbUp;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using System;
|
||||
|
@ -13,6 +11,9 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
|
||||
// ReSharper disable StringIndexOfIsCultureSpecific.1
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -30,7 +31,7 @@ namespace Oqtane.Controllers
|
|||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
public GenericResponse Post([FromBody] string connectionstring)
|
||||
public GenericResponse Post([FromBody] string connectionString)
|
||||
{
|
||||
var response = new GenericResponse { Success = false, Message = "" };
|
||||
|
||||
|
@ -38,7 +39,7 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
bool master = false;
|
||||
string defaultconnectionstring = _config.GetConnectionString("DefaultConnection");
|
||||
if (string.IsNullOrEmpty(defaultconnectionstring) || connectionstring == defaultconnectionstring)
|
||||
if (string.IsNullOrEmpty(defaultconnectionstring) || connectionString == defaultconnectionstring)
|
||||
{
|
||||
master = true;
|
||||
}
|
||||
|
@ -52,9 +53,9 @@ namespace Oqtane.Controllers
|
|||
if (!exists)
|
||||
{
|
||||
string datadirectory = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
|
||||
connectionstring = connectionstring.Replace("|DataDirectory|", datadirectory);
|
||||
connectionString = connectionString.Replace("|DataDirectory|", datadirectory);
|
||||
|
||||
SqlConnection connection = new SqlConnection(connectionstring);
|
||||
SqlConnection connection = new SqlConnection(connectionString);
|
||||
try
|
||||
{
|
||||
using (connection)
|
||||
|
@ -73,7 +74,7 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
string masterConnectionString = "";
|
||||
string databaseName = "";
|
||||
string[] fragments = connectionstring.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] fragments = connectionString.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string fragment in fragments)
|
||||
{
|
||||
if (fragment.ToLower().Contains("initial catalog=") || fragment.ToLower().Contains("database="))
|
||||
|
@ -95,7 +96,7 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
connection.Open();
|
||||
SqlCommand command;
|
||||
if (connectionstring.ToLower().Contains("attachdbfilename=")) // LocalDB
|
||||
if (connectionString.ToLower().Contains("attachdbfilename=")) // LocalDB
|
||||
{
|
||||
command = new SqlCommand("CREATE DATABASE [" + databaseName + "] ON ( NAME = '" + databaseName + "', FILENAME = '" + datadirectory + "\\" + databaseName + ".mdf')", connection);
|
||||
}
|
||||
|
@ -126,11 +127,11 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
initializationScript = reader.ReadToEnd();
|
||||
}
|
||||
initializationScript = initializationScript.Replace("{ConnectionString}", connectionstring.Replace(datadirectory, "|DataDirectory|"));
|
||||
initializationScript = initializationScript.Replace("{ConnectionString}", connectionString.Replace(datadirectory, "|DataDirectory|"));
|
||||
initializationScript = initializationScript.Replace("{Alias}", HttpContext.Request.Host.Value);
|
||||
}
|
||||
|
||||
var dbUpgradeConfig = DeployChanges.To.SqlDatabase(connectionstring)
|
||||
var dbUpgradeConfig = DeployChanges.To.SqlDatabase(connectionString)
|
||||
.WithScript(new DbUp.Engine.SqlScript("Master.sql", initializationScript))
|
||||
.WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly()); // tenant scripts should be added to /Scripts folder as Embedded Resources
|
||||
var dbUpgrade = dbUpgradeConfig.Build();
|
||||
|
@ -151,9 +152,9 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
config = reader.ReadToEnd();
|
||||
}
|
||||
connectionstring = connectionstring.Replace(datadirectory, "|DataDirectory|");
|
||||
connectionstring = connectionstring.Replace(@"\", @"\\");
|
||||
config = config.Replace("DefaultConnection\": \"", "DefaultConnection\": \"" + connectionstring);
|
||||
connectionString = connectionString.Replace(datadirectory, "|DataDirectory|");
|
||||
connectionString = connectionString.Replace(@"\", @"\\");
|
||||
config = config.Replace("DefaultConnection\": \"", "DefaultConnection\": \"" + connectionString);
|
||||
using (StreamWriter writer = new StreamWriter(Directory.GetCurrentDirectory() + "\\appsettings.json"))
|
||||
{
|
||||
writer.WriteLine(config);
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
using System;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -44,27 +45,27 @@ namespace Oqtane.Controllers
|
|||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public Job Post([FromBody] Job Job)
|
||||
public Job Post([FromBody] Job job)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Job = _jobs.AddJob(Job);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Job Added {Job}", Job);
|
||||
job = _jobs.AddJob(job);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Job Added {Job}", job);
|
||||
}
|
||||
return Job;
|
||||
return job;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public Job Put(int id, [FromBody] Job Job)
|
||||
public Job Put(int id, [FromBody] Job job)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Job = _jobs.UpdateJob(Job);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Job Updated {Job}", Job);
|
||||
job = _jobs.UpdateJob(job);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Job Updated {Job}", job);
|
||||
}
|
||||
return Job;
|
||||
return job;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -39,27 +40,27 @@ namespace Oqtane.Controllers
|
|||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public JobLog Post([FromBody] JobLog JobLog)
|
||||
public JobLog Post([FromBody] JobLog jobLog)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
JobLog = _jobLogs.AddJobLog(JobLog);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Job Log Added {JobLog}", JobLog);
|
||||
jobLog = _jobLogs.AddJobLog(jobLog);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Job Log Added {JobLog}", jobLog);
|
||||
}
|
||||
return JobLog;
|
||||
return jobLog;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public JobLog Put(int id, [FromBody] JobLog JobLog)
|
||||
public JobLog Put(int id, [FromBody] JobLog jobLog)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
JobLog = _jobLogs.UpdateJobLog(JobLog);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Job Log Updated {JobLog}", JobLog);
|
||||
jobLog = _jobLogs.UpdateJobLog(jobLog);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Job Log Updated {JobLog}", jobLog);
|
||||
}
|
||||
return JobLog;
|
||||
return jobLog;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Infrastructure;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
|
@ -39,11 +39,11 @@ namespace Oqtane.Controllers
|
|||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
public void Post([FromBody] Log Log)
|
||||
public void Post([FromBody] Log log)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_logger.Log(Log);
|
||||
_logger.Log(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Security;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
|
@ -31,15 +31,15 @@ namespace Oqtane.Controllers
|
|||
|
||||
// GET: api/<controller>?siteid=x
|
||||
[HttpGet]
|
||||
public IEnumerable<Models.Module> Get(string siteid)
|
||||
public IEnumerable<Module> Get(string siteid)
|
||||
{
|
||||
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(int.Parse(siteid)).ToList();
|
||||
List<Models.Module> modules = new List<Models.Module>();
|
||||
List<Module> modules = new List<Module>();
|
||||
foreach (PageModule pagemodule in _pageModules.GetPageModules(int.Parse(siteid)))
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(User,PermissionNames.View, pagemodule.Module.Permissions))
|
||||
{
|
||||
Models.Module module = new Models.Module();
|
||||
Module module = new Module();
|
||||
module.SiteId = pagemodule.Module.SiteId;
|
||||
module.ModuleDefinitionName = pagemodule.Module.ModuleDefinitionName;
|
||||
module.Permissions = pagemodule.Module.Permissions;
|
||||
|
@ -67,9 +67,9 @@ namespace Oqtane.Controllers
|
|||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
public Models.Module Get(int id)
|
||||
public Module Get(int id)
|
||||
{
|
||||
Models.Module module = _modules.GetModule(id);
|
||||
Module module = _modules.GetModule(id);
|
||||
if (_userPermissions.IsAuthorized(User,PermissionNames.View, module.Permissions))
|
||||
{
|
||||
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(module.SiteId).ToList();
|
||||
|
@ -87,39 +87,39 @@ namespace Oqtane.Controllers
|
|||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Models.Module Post([FromBody] Models.Module Module)
|
||||
public Module Post([FromBody] Module module)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, Module.PageId, PermissionNames.Edit))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, module.PageId, PermissionNames.Edit))
|
||||
{
|
||||
Module = _modules.AddModule(Module);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Module Added {Module}", Module);
|
||||
module = _modules.AddModule(module);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Module Added {Module}", module);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Module {Module}", Module);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Module {Module}", module);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Module = null;
|
||||
module = null;
|
||||
}
|
||||
return Module;
|
||||
return module;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Models.Module Put(int id, [FromBody] Models.Module Module)
|
||||
public Module Put(int id, [FromBody] Module module)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Module, Module.ModuleId, PermissionNames.Edit))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Module, module.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
Module = _modules.UpdateModule(Module);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Updated {Module}", Module);
|
||||
module = _modules.UpdateModule(module);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Updated {Module}", module);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Module {Module}", Module);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Module {Module}", module);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Module = null;
|
||||
module = null;
|
||||
}
|
||||
return Module;
|
||||
return module;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
|
@ -160,12 +160,12 @@ namespace Oqtane.Controllers
|
|||
// POST api/<controller>/import?moduleid=x
|
||||
[HttpPost("import")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public bool Import(int moduleid, [FromBody] string Content)
|
||||
public bool Import(int moduleid, [FromBody] string content)
|
||||
{
|
||||
bool success = false;
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Module, moduleid, PermissionNames.Edit))
|
||||
{
|
||||
success = _modules.ImportModule(moduleid, Content);
|
||||
success = _modules.ImportModule(moduleid, content);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Infrastructure;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Security;
|
||||
// ReSharper disable StringIndexOfIsCultureSpecific.1
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -66,12 +68,12 @@ namespace Oqtane.Controllers
|
|||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public void Put(int id, [FromBody] ModuleDefinition ModuleDefinition)
|
||||
public void Put(int id, [FromBody] ModuleDefinition moduleDefinition)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_moduleDefinitions.UpdateModuleDefinition(ModuleDefinition);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Definition Updated {ModuleDefinition}", ModuleDefinition);
|
||||
_moduleDefinitions.UpdateModuleDefinition(moduleDefinition);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Definition Updated {ModuleDefinition}", moduleDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Security;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
|
@ -49,38 +49,38 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Notification Get(int id)
|
||||
{
|
||||
Notification Notification = _notifications.GetNotification(id);
|
||||
if (!(IsAuthorized(Notification.FromUserId) || IsAuthorized(Notification.ToUserId)))
|
||||
Notification notification = _notifications.GetNotification(id);
|
||||
if (!(IsAuthorized(notification.FromUserId) || IsAuthorized(notification.ToUserId)))
|
||||
{
|
||||
Notification = null;
|
||||
notification = null;
|
||||
}
|
||||
return Notification;
|
||||
return notification;
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Notification Post([FromBody] Notification Notification)
|
||||
public Notification Post([FromBody] Notification notification)
|
||||
{
|
||||
if (IsAuthorized(Notification.FromUserId))
|
||||
if (IsAuthorized(notification.FromUserId))
|
||||
{
|
||||
Notification = _notifications.AddNotification(Notification);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Notification Added {Notification}", Notification);
|
||||
notification = _notifications.AddNotification(notification);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Notification Added {Notification}", notification);
|
||||
}
|
||||
return Notification;
|
||||
return notification;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Notification Put(int id, [FromBody] Notification Notification)
|
||||
public Notification Put(int id, [FromBody] Notification notification)
|
||||
{
|
||||
if (IsAuthorized(Notification.FromUserId))
|
||||
if (IsAuthorized(notification.FromUserId))
|
||||
{
|
||||
Notification = _notifications.UpdateNotification(Notification);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Notification Updated {Folder}", Notification);
|
||||
notification = _notifications.UpdateNotification(notification);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Notification Updated {Folder}", notification);
|
||||
}
|
||||
return Notification;
|
||||
return notification;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
|
@ -88,8 +88,8 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Notification Notification = _notifications.GetNotification(id);
|
||||
if (IsAuthorized(Notification.FromUserId) || IsAuthorized(Notification.ToUserId))
|
||||
Notification notification = _notifications.GetNotification(id);
|
||||
if (IsAuthorized(notification.FromUserId) || IsAuthorized(notification.ToUserId))
|
||||
{
|
||||
_notifications.DeleteNotification(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Notification Deleted {NotificationId}", id);
|
||||
|
|
|
@ -11,6 +11,7 @@ using System.Linq;
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Shared;
|
||||
// ReSharper disable PartialTypeWithSinglePart
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using System.Linq;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Security;
|
||||
using System.Net;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -99,14 +100,14 @@ namespace Oqtane.Controllers
|
|||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Page Post([FromBody] Page Page)
|
||||
public Page Post([FromBody] Page page)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
string permissions;
|
||||
if (Page.ParentId != null)
|
||||
if (page.ParentId != null)
|
||||
{
|
||||
permissions = _pages.GetPage(Page.ParentId.Value).Permissions;
|
||||
permissions = _pages.GetPage(page.ParentId.Value).Permissions;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -115,18 +116,18 @@ namespace Oqtane.Controllers
|
|||
|
||||
if (_userPermissions.IsAuthorized(User,PermissionNames.Edit, permissions))
|
||||
{
|
||||
Page = _pages.AddPage(Page);
|
||||
_syncManager.AddSyncEvent(EntityNames.Site, Page.SiteId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Added {Page}", Page);
|
||||
page = _pages.AddPage(page);
|
||||
_syncManager.AddSyncEvent(EntityNames.Site, page.SiteId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Added {Page}", page);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Page {Page}", Page);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Page {Page}", page);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Page = null;
|
||||
page = null;
|
||||
}
|
||||
}
|
||||
return Page;
|
||||
return page;
|
||||
}
|
||||
|
||||
// POST api/<controller>/5?userid=x
|
||||
|
@ -195,21 +196,21 @@ namespace Oqtane.Controllers
|
|||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Page Put(int id, [FromBody] Page Page)
|
||||
public Page Put(int id, [FromBody] Page page)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, Page.PageId, PermissionNames.Edit))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, page.PageId, PermissionNames.Edit))
|
||||
{
|
||||
Page = _pages.UpdatePage(Page);
|
||||
_syncManager.AddSyncEvent(EntityNames.Site, Page.SiteId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Updated {Page}", Page);
|
||||
page = _pages.UpdatePage(page);
|
||||
_syncManager.AddSyncEvent(EntityNames.Site, page.SiteId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Updated {Page}", page);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Page {Page}", Page);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Page {Page}", page);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Page = null;
|
||||
page = null;
|
||||
}
|
||||
return Page;
|
||||
return page;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/?siteid=x&pageid=y&parentid=z
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using System.Linq;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Security;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
|
@ -14,15 +15,13 @@ namespace Oqtane.Controllers
|
|||
public class PageModuleController : Controller
|
||||
{
|
||||
private readonly IPageModuleRepository _pageModules;
|
||||
private readonly IModuleRepository _modules;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ISyncManager _syncManager;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public PageModuleController(IPageModuleRepository pageModules, IModuleRepository modules, IUserPermissions userPermissions, ISyncManager syncManager, ILogManager logger)
|
||||
public PageModuleController(IPageModuleRepository pageModules, IUserPermissions userPermissions, ISyncManager syncManager, ILogManager logger)
|
||||
{
|
||||
_pageModules = pageModules;
|
||||
_modules = modules;
|
||||
_userPermissions = userPermissions;
|
||||
_syncManager = syncManager;
|
||||
_logger = logger;
|
||||
|
@ -65,41 +64,41 @@ namespace Oqtane.Controllers
|
|||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public PageModule Post([FromBody] PageModule PageModule)
|
||||
public PageModule Post([FromBody] PageModule pageModule)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, PageModule.PageId, PermissionNames.Edit))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, pageModule.PageId, PermissionNames.Edit))
|
||||
{
|
||||
PageModule = _pageModules.AddPageModule(PageModule);
|
||||
_syncManager.AddSyncEvent(EntityNames.Page, PageModule.PageId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Module Added {PageModule}", PageModule);
|
||||
pageModule = _pageModules.AddPageModule(pageModule);
|
||||
_syncManager.AddSyncEvent(EntityNames.Page, pageModule.PageId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Module Added {PageModule}", pageModule);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add PageModule {PageModule}", PageModule);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add PageModule {PageModule}", pageModule);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
PageModule = null;
|
||||
pageModule = null;
|
||||
}
|
||||
return PageModule;
|
||||
return pageModule;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public PageModule Put(int id, [FromBody] PageModule PageModule)
|
||||
public PageModule Put(int id, [FromBody] PageModule pageModule)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Module, PageModule.ModuleId, PermissionNames.Edit))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Module, pageModule.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
PageModule = _pageModules.UpdatePageModule(PageModule);
|
||||
_syncManager.AddSyncEvent(EntityNames.Page, PageModule.PageId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Module Updated {PageModule}", PageModule);
|
||||
pageModule = _pageModules.UpdatePageModule(pageModule);
|
||||
_syncManager.AddSyncEvent(EntityNames.Page, pageModule.PageId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Module Updated {PageModule}", pageModule);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update PageModule {PageModule}", PageModule);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update PageModule {PageModule}", pageModule);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
PageModule = null;
|
||||
pageModule = null;
|
||||
}
|
||||
return PageModule;
|
||||
return pageModule;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/?pageid=x&pane=y
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -37,27 +38,27 @@ namespace Oqtane.Controllers
|
|||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public Profile Post([FromBody] Profile Profile)
|
||||
public Profile Post([FromBody] Profile profile)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Profile = _profiles.AddProfile(Profile);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Profile Added {Profile}", Profile);
|
||||
profile = _profiles.AddProfile(profile);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Profile Added {Profile}", profile);
|
||||
}
|
||||
return Profile;
|
||||
return profile;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public Profile Put(int id, [FromBody] Profile Profile)
|
||||
public Profile Put(int id, [FromBody] Profile profile)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Profile = _profiles.UpdateProfile(Profile);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Profile Updated {Profile}", Profile);
|
||||
profile = _profiles.UpdateProfile(profile);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Profile Updated {Profile}", profile);
|
||||
}
|
||||
return Profile;
|
||||
return profile;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -39,27 +40,27 @@ namespace Oqtane.Controllers
|
|||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public Role Post([FromBody] Role Role)
|
||||
public Role Post([FromBody] Role role)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Role = _roles.AddRole(Role);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Role Added {Role}", Role);
|
||||
role = _roles.AddRole(role);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Role Added {Role}", role);
|
||||
}
|
||||
return Role;
|
||||
return role;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public Role Put(int id, [FromBody] Role Role)
|
||||
public Role Put(int id, [FromBody] Role role)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Role = _roles.UpdateRole(Role);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Role Updated {Role}", Role);
|
||||
role = _roles.UpdateRole(role);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Role Updated {Role}", role);
|
||||
}
|
||||
return Role;
|
||||
return role;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Security;
|
||||
using Oqtane.Infrastructure;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -62,38 +62,38 @@ namespace Oqtane.Controllers
|
|||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
public Setting Post([FromBody] Setting Setting)
|
||||
public Setting Post([FromBody] Setting setting)
|
||||
{
|
||||
if (ModelState.IsValid && IsAuthorized(Setting.EntityName, Setting.EntityId, PermissionNames.Edit))
|
||||
if (ModelState.IsValid && IsAuthorized(setting.EntityName, setting.EntityId, PermissionNames.Edit))
|
||||
{
|
||||
Setting = _settings.AddSetting(Setting);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Setting Added {Setting}", Setting);
|
||||
setting = _settings.AddSetting(setting);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Setting Added {Setting}", setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Setting {Setting}", Setting);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Setting {Setting}", setting);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Setting = null;
|
||||
setting = null;
|
||||
}
|
||||
return Setting;
|
||||
return setting;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
public Setting Put(int id, [FromBody] Setting Setting)
|
||||
public Setting Put(int id, [FromBody] Setting setting)
|
||||
{
|
||||
if (ModelState.IsValid && IsAuthorized(Setting.EntityName, Setting.EntityId, PermissionNames.Edit))
|
||||
if (ModelState.IsValid && IsAuthorized(setting.EntityName, setting.EntityId, PermissionNames.Edit))
|
||||
{
|
||||
Setting = _settings.UpdateSetting(Setting);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Setting Updated {Setting}", Setting);
|
||||
setting = _settings.UpdateSetting(setting);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Setting Updated {Setting}", setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Setting {Setting}", Setting);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Setting {Setting}", setting);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Setting = null;
|
||||
setting = null;
|
||||
}
|
||||
return Setting;
|
||||
return setting;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
|
@ -113,15 +113,15 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
private bool IsAuthorized(string EntityName, int EntityId, string PermissionName)
|
||||
private bool IsAuthorized(string entityName, int entityId, string permissionName)
|
||||
{
|
||||
bool authorized = false;
|
||||
if (EntityName == EntityNames.PageModule)
|
||||
if (entityName == EntityNames.PageModule)
|
||||
{
|
||||
EntityName = EntityNames.Module;
|
||||
EntityId = _pageModules.GetPageModule(EntityId).ModuleId;
|
||||
entityName = EntityNames.Module;
|
||||
entityId = _pageModules.GetPageModule(entityId).ModuleId;
|
||||
}
|
||||
switch (EntityName)
|
||||
switch (entityName)
|
||||
{
|
||||
case EntityNames.Host:
|
||||
authorized = User.IsInRole(Constants.HostRole);
|
||||
|
@ -132,13 +132,13 @@ namespace Oqtane.Controllers
|
|||
case EntityNames.Page:
|
||||
case EntityNames.Module:
|
||||
case EntityNames.Folder:
|
||||
authorized = _userPermissions.IsAuthorized(User, EntityName, EntityId, PermissionName);
|
||||
authorized = _userPermissions.IsAuthorized(User, entityName, entityId, permissionName);
|
||||
break;
|
||||
case EntityNames.User:
|
||||
authorized = true;
|
||||
if (PermissionName == PermissionNames.Edit)
|
||||
if (permissionName == PermissionNames.Edit)
|
||||
{
|
||||
authorized = User.IsInRole(Constants.AdminRole) || (_userPermissions.GetUser(User).UserId == EntityId);
|
||||
authorized = User.IsInRole(Constants.AdminRole) || (_userPermissions.GetUser(User).UserId == entityId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -16,15 +15,13 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
private readonly ISiteRepository _sites;
|
||||
private readonly ITenantResolver _tenants;
|
||||
private readonly IWebHostEnvironment _environment;
|
||||
private readonly ISyncManager _syncManager;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public SiteController(ISiteRepository sites, ITenantResolver tenants, IWebHostEnvironment environment, ISyncManager syncManager, ILogManager logger)
|
||||
public SiteController(ISiteRepository sites, ITenantResolver tenants, ISyncManager syncManager, ILogManager logger)
|
||||
{
|
||||
_sites = sites;
|
||||
_tenants = tenants;
|
||||
_environment = environment;
|
||||
_syncManager = syncManager;
|
||||
_logger = logger;
|
||||
}
|
||||
|
@ -46,7 +43,7 @@ namespace Oqtane.Controllers
|
|||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
public Site Post([FromBody] Site Site)
|
||||
public Site Post([FromBody] Site site)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
|
@ -56,7 +53,7 @@ namespace Oqtane.Controllers
|
|||
// provision initial site during installation
|
||||
authorized = true;
|
||||
Tenant tenant = _tenants.GetTenant();
|
||||
Site.TenantId = tenant.TenantId;
|
||||
site.TenantId = tenant.TenantId;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -64,25 +61,25 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
if (authorized)
|
||||
{
|
||||
Site = _sites.AddSite(Site);
|
||||
_logger.Log(Site.SiteId, LogLevel.Information, this, LogFunction.Create, "Site Added {Site}", Site);
|
||||
site = _sites.AddSite(site);
|
||||
_logger.Log(site.SiteId, LogLevel.Information, this, LogFunction.Create, "Site Added {Site}", site);
|
||||
}
|
||||
}
|
||||
return Site;
|
||||
return site;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public Site Put(int id, [FromBody] Site Site)
|
||||
public Site Put(int id, [FromBody] Site site)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Site = _sites.UpdateSite(Site);
|
||||
_syncManager.AddSyncEvent(EntityNames.Site, Site.SiteId);
|
||||
_logger.Log(Site.SiteId, LogLevel.Information, this, LogFunction.Update, "Site Updated {Site}", Site);
|
||||
site = _sites.UpdateSite(site);
|
||||
_syncManager.AddSyncEvent(EntityNames.Site, site.SiteId);
|
||||
_logger.Log(site.SiteId, LogLevel.Information, this, LogFunction.Update, "Site Updated {Site}", site);
|
||||
}
|
||||
return Site;
|
||||
return site;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -39,27 +40,27 @@ namespace Oqtane.Controllers
|
|||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public Tenant Post([FromBody] Tenant Tenant)
|
||||
public Tenant Post([FromBody] Tenant tenant)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Tenant = _tenants.AddTenant(Tenant);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Tenant Added {TenantId}", Tenant.TenantId);
|
||||
tenant = _tenants.AddTenant(tenant);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Tenant Added {TenantId}", tenant.TenantId);
|
||||
}
|
||||
return Tenant;
|
||||
return tenant;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public Tenant Put(int id, [FromBody] Tenant Tenant)
|
||||
public Tenant Put(int id, [FromBody] Tenant tenant)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Tenant = _tenants.UpdateTenant(Tenant);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Tenant Updated {TenantId}", Tenant.TenantId);
|
||||
tenant = _tenants.UpdateTenant(tenant);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Tenant Updated {TenantId}", tenant.TenantId);
|
||||
}
|
||||
return Tenant;
|
||||
return tenant;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
|
||||
// ReSharper disable StringIndexOfIsCultureSpecific.1
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
|
|
@ -2,17 +2,17 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Net;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -73,43 +73,39 @@ namespace Oqtane.Controllers
|
|||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
public async Task<User> Post([FromBody] User User)
|
||||
public async Task<User> Post([FromBody] User user)
|
||||
{
|
||||
User user = null;
|
||||
User newUser = null;
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
bool verified = true;
|
||||
// users created by non-administrators must be verified
|
||||
if (!base.User.IsInRole(Constants.AdminRole) && User.Username != Constants.HostUser)
|
||||
{
|
||||
verified = false;
|
||||
}
|
||||
// users created by non-administrators must be verified
|
||||
bool verified = !(!User.IsInRole(Constants.AdminRole) && user.Username != Constants.HostUser);
|
||||
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(User.Username);
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(user.Username);
|
||||
if (identityuser == null)
|
||||
{
|
||||
identityuser = new IdentityUser();
|
||||
identityuser.UserName = User.Username;
|
||||
identityuser.Email = User.Email;
|
||||
identityuser.UserName = user.Username;
|
||||
identityuser.Email = user.Email;
|
||||
identityuser.EmailConfirmed = verified;
|
||||
var result = await _identityUserManager.CreateAsync(identityuser, User.Password);
|
||||
var result = await _identityUserManager.CreateAsync(identityuser, user.Password);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
User.LastLoginOn = null;
|
||||
User.LastIPAddress = "";
|
||||
user = _users.AddUser(User);
|
||||
user.LastLoginOn = null;
|
||||
user.LastIPAddress = "";
|
||||
newUser = _users.AddUser(user);
|
||||
if (!verified)
|
||||
{
|
||||
Notification notification = new Notification();
|
||||
notification.SiteId = User.SiteId;
|
||||
notification.SiteId = user.SiteId;
|
||||
notification.FromUserId = null;
|
||||
notification.ToUserId = user.UserId;
|
||||
notification.ToUserId = newUser.UserId;
|
||||
notification.ToEmail = "";
|
||||
notification.Subject = "User Account Verification";
|
||||
string token = await _identityUserManager.GenerateEmailConfirmationTokenAsync(identityuser);
|
||||
string url = HttpContext.Request.Scheme + "://" + _tenants.GetAlias().Name + "/login?name=" + User.Username + "&token=" + WebUtility.UrlEncode(token);
|
||||
notification.Body = "Dear " + User.DisplayName + ",\n\nIn Order To Complete The Registration Of Your User Account Please Click The Link Displayed Below:\n\n" + url + "\n\nThank You!";
|
||||
string url = HttpContext.Request.Scheme + "://" + _tenants.GetAlias().Name + "/login?name=" + user.Username + "&token=" + WebUtility.UrlEncode(token);
|
||||
notification.Body = "Dear " + user.DisplayName + ",\n\nIn Order To Complete The Registration Of Your User Account Please Click The Link Displayed Below:\n\n" + url + "\n\nThank You!";
|
||||
notification.ParentId = null;
|
||||
notification.CreatedOn = DateTime.UtcNow;
|
||||
notification.IsDelivered = false;
|
||||
|
@ -118,11 +114,11 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
|
||||
// assign to host role if this is the host user ( initial installation )
|
||||
if (User.Username == Constants.HostUser)
|
||||
if (user.Username == Constants.HostUser)
|
||||
{
|
||||
int hostroleid = _roles.GetRoles(User.SiteId, true).Where(item => item.Name == Constants.HostRole).FirstOrDefault().RoleId;
|
||||
int hostroleid = _roles.GetRoles(user.SiteId, true).Where(item => item.Name == Constants.HostRole).FirstOrDefault().RoleId;
|
||||
UserRole userrole = new UserRole();
|
||||
userrole.UserId = user.UserId;
|
||||
userrole.UserId = newUser.UserId;
|
||||
userrole.RoleId = hostroleid;
|
||||
userrole.EffectiveDate = null;
|
||||
userrole.ExpiryDate = null;
|
||||
|
@ -130,75 +126,79 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
|
||||
// add folder for user
|
||||
Folder folder = _folders.GetFolder(User.SiteId, "Users\\");
|
||||
Folder folder = _folders.GetFolder(user.SiteId, "Users\\");
|
||||
if (folder != null)
|
||||
{
|
||||
_folders.AddFolder(new Folder { SiteId = folder.SiteId, ParentId = folder.FolderId, Name = "My Folder", Path = folder.Path + user.UserId.ToString() + "\\", Order = 1, IsSystem = true,
|
||||
Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"[" + user.UserId.ToString() + "]\"},{\"PermissionName\":\"View\",\"Permissions\":\"All Users\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"[" + user.UserId.ToString() + "]\"}]" });
|
||||
_folders.AddFolder(new Folder { SiteId = folder.SiteId, ParentId = folder.FolderId, Name = "My Folder", Path = folder.Path + newUser.UserId.ToString() + "\\", Order = 1, IsSystem = true,
|
||||
Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"[" + newUser.UserId.ToString() + "]\"},{\"PermissionName\":\"View\",\"Permissions\":\"All Users\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"[" + newUser.UserId.ToString() + "]\"}]" });
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = await _identitySignInManager.CheckPasswordSignInAsync(identityuser, User.Password, false);
|
||||
var result = await _identitySignInManager.CheckPasswordSignInAsync(identityuser, user.Password, false);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
user = _users.GetUser(User.Username);
|
||||
newUser = _users.GetUser(user.Username);
|
||||
}
|
||||
}
|
||||
|
||||
if (user != null && User.Username != Constants.HostUser)
|
||||
if (newUser != null && user.Username != Constants.HostUser)
|
||||
{
|
||||
// add auto assigned roles to user for site
|
||||
List<Role> roles = _roles.GetRoles(User.SiteId).Where(item => item.IsAutoAssigned == true).ToList();
|
||||
List<Role> roles = _roles.GetRoles(user.SiteId).Where(item => item.IsAutoAssigned).ToList();
|
||||
foreach (Role role in roles)
|
||||
{
|
||||
UserRole userrole = new UserRole();
|
||||
userrole.UserId = user.UserId;
|
||||
userrole.UserId = newUser.UserId;
|
||||
userrole.RoleId = role.RoleId;
|
||||
userrole.EffectiveDate = null;
|
||||
userrole.ExpiryDate = null;
|
||||
_userRoles.AddUserRole(userrole);
|
||||
}
|
||||
}
|
||||
user.Password = ""; // remove sensitive information
|
||||
_logger.Log(User.SiteId, LogLevel.Information, this, LogFunction.Create, "User Added {User}", user);
|
||||
|
||||
if (newUser != null)
|
||||
{
|
||||
newUser.Password = ""; // remove sensitive information
|
||||
_logger.Log(user.SiteId, LogLevel.Information, this, LogFunction.Create, "User Added {User}", newUser);
|
||||
}
|
||||
}
|
||||
|
||||
return user;
|
||||
return newUser;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize]
|
||||
public async Task<User> Put(int id, [FromBody] User User)
|
||||
public async Task<User> Put(int id, [FromBody] User user)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (base.User.IsInRole(Constants.AdminRole) || base.User.Identity.Name == User.Username)
|
||||
if (User.IsInRole(Constants.AdminRole) || User.Identity.Name == user.Username)
|
||||
{
|
||||
if (User.Password != "")
|
||||
if (user.Password != "")
|
||||
{
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(User.Username);
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(user.Username);
|
||||
if (identityuser != null)
|
||||
{
|
||||
identityuser.PasswordHash = _identityUserManager.PasswordHasher.HashPassword(identityuser, User.Password);
|
||||
identityuser.PasswordHash = _identityUserManager.PasswordHasher.HashPassword(identityuser, user.Password);
|
||||
await _identityUserManager.UpdateAsync(identityuser);
|
||||
}
|
||||
}
|
||||
User = _users.UpdateUser(User);
|
||||
_syncManager.AddSyncEvent(EntityNames.User, User.UserId);
|
||||
User.Password = ""; // remove sensitive information
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "User Updated {User}", User);
|
||||
user = _users.UpdateUser(user);
|
||||
_syncManager.AddSyncEvent(EntityNames.User, user.UserId);
|
||||
user.Password = ""; // remove sensitive information
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "User Updated {User}", user);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update User {User}", User);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update User {User}", user);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
User = null;
|
||||
user = null;
|
||||
}
|
||||
}
|
||||
return User;
|
||||
return user;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5?siteid=x
|
||||
|
@ -222,147 +222,147 @@ namespace Oqtane.Controllers
|
|||
|
||||
// POST api/<controller>/login
|
||||
[HttpPost("login")]
|
||||
public async Task<User> Login([FromBody] User User, bool SetCookie, bool IsPersistent)
|
||||
public async Task<User> Login([FromBody] User user, bool setCookie, bool isPersistent)
|
||||
{
|
||||
User user = new Models.User { Username = User.Username, IsAuthenticated = false };
|
||||
User loginUser = new User { Username = user.Username, IsAuthenticated = false };
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(User.Username);
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(user.Username);
|
||||
if (identityuser != null)
|
||||
{
|
||||
var result = await _identitySignInManager.CheckPasswordSignInAsync(identityuser, User.Password, false);
|
||||
var result = await _identitySignInManager.CheckPasswordSignInAsync(identityuser, user.Password, false);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
user = _users.GetUser(identityuser.UserName);
|
||||
if (user != null)
|
||||
loginUser = _users.GetUser(identityuser.UserName);
|
||||
if (loginUser != null)
|
||||
{
|
||||
if (identityuser.EmailConfirmed)
|
||||
{
|
||||
user.IsAuthenticated = true;
|
||||
user.LastLoginOn = DateTime.UtcNow;
|
||||
user.LastIPAddress = HttpContext.Connection.RemoteIpAddress.ToString();
|
||||
_users.UpdateUser(user);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Login Successful {Username}", User.Username);
|
||||
if (SetCookie)
|
||||
loginUser.IsAuthenticated = true;
|
||||
loginUser.LastLoginOn = DateTime.UtcNow;
|
||||
loginUser.LastIPAddress = HttpContext.Connection.RemoteIpAddress.ToString();
|
||||
_users.UpdateUser(loginUser);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Login Successful {Username}", user.Username);
|
||||
if (setCookie)
|
||||
{
|
||||
await _identitySignInManager.SignInAsync(identityuser, IsPersistent);
|
||||
await _identitySignInManager.SignInAsync(identityuser, isPersistent);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Not Verified {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Not Verified {Username}", user.Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "User Login Failed {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "User Login Failed {Username}", user.Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return user;
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
// POST api/<controller>/logout
|
||||
[HttpPost("logout")]
|
||||
[Authorize]
|
||||
public async Task Logout([FromBody] User User)
|
||||
public async Task Logout([FromBody] User user)
|
||||
{
|
||||
await HttpContext.SignOutAsync(IdentityConstants.ApplicationScheme);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Logout {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Logout {Username}", user.Username);
|
||||
}
|
||||
|
||||
// POST api/<controller>/verify
|
||||
[HttpPost("verify")]
|
||||
public async Task<User> Verify([FromBody] User User, string token)
|
||||
public async Task<User> Verify([FromBody] User user, string token)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(User.Username);
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(user.Username);
|
||||
if (identityuser != null)
|
||||
{
|
||||
var result = await _identityUserManager.ConfirmEmailAsync(identityuser, token);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "Email Verified For {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "Email Verified For {Username}", user.Username);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Email Verification Failed For {Username}", User.Username);
|
||||
User = null;
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Email Verification Failed For {Username}", user.Username);
|
||||
user = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Email Verification Failed For {Username}", User.Username);
|
||||
User = null;
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Email Verification Failed For {Username}", user.Username);
|
||||
user = null;
|
||||
}
|
||||
}
|
||||
return User;
|
||||
return user;
|
||||
}
|
||||
|
||||
// POST api/<controller>/forgot
|
||||
[HttpPost("forgot")]
|
||||
public async Task Forgot([FromBody] User User)
|
||||
public async Task Forgot([FromBody] User user)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(User.Username);
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(user.Username);
|
||||
if (identityuser != null)
|
||||
{
|
||||
Notification notification = new Notification();
|
||||
notification.SiteId = User.SiteId;
|
||||
notification.SiteId = user.SiteId;
|
||||
notification.FromUserId = null;
|
||||
notification.ToUserId = User.UserId;
|
||||
notification.ToUserId = user.UserId;
|
||||
notification.ToEmail = "";
|
||||
notification.Subject = "User Password Reset";
|
||||
string token = await _identityUserManager.GeneratePasswordResetTokenAsync(identityuser);
|
||||
string url = HttpContext.Request.Scheme + "://" + _tenants.GetAlias().Name + "/reset?name=" + User.Username + "&token=" + WebUtility.UrlEncode(token);
|
||||
notification.Body = "Dear " + User.DisplayName + ",\n\nPlease Click The Link Displayed Below To Reset Your Password:\n\n" + url + "\n\nThank You!";
|
||||
string url = HttpContext.Request.Scheme + "://" + _tenants.GetAlias().Name + "/reset?name=" + user.Username + "&token=" + WebUtility.UrlEncode(token);
|
||||
notification.Body = "Dear " + user.DisplayName + ",\n\nPlease Click The Link Displayed Below To Reset Your Password:\n\n" + url + "\n\nThank You!";
|
||||
notification.ParentId = null;
|
||||
notification.CreatedOn = DateTime.UtcNow;
|
||||
notification.IsDelivered = false;
|
||||
notification.DeliveredOn = null;
|
||||
_notifications.AddNotification(notification);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "Password Reset Notification Sent For {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "Password Reset Notification Sent For {Username}", user.Username);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Password Reset Notification Failed For {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Password Reset Notification Failed For {Username}", user.Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// POST api/<controller>/reset
|
||||
[HttpPost("reset")]
|
||||
public async Task<User> Reset([FromBody] User User, string token)
|
||||
public async Task<User> Reset([FromBody] User user, string token)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(User.Username);
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(user.Username);
|
||||
if (identityuser != null && !string.IsNullOrEmpty(token))
|
||||
{
|
||||
var result = await _identityUserManager.ResetPasswordAsync(identityuser, token, User.Password);
|
||||
var result = await _identityUserManager.ResetPasswordAsync(identityuser, token, user.Password);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "Password Reset For {Username}", User.Username);
|
||||
User.Password = "";
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "Password Reset For {Username}", user.Username);
|
||||
user.Password = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Password Reset Failed For {Username}", User.Username);
|
||||
User = null;
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Password Reset Failed For {Username}", user.Username);
|
||||
user = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Password Reset Failed For {Username}", User.Username);
|
||||
User = null;
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Password Reset Failed For {Username}", user.Username);
|
||||
user = null;
|
||||
}
|
||||
}
|
||||
return User;
|
||||
return user;
|
||||
}
|
||||
|
||||
// GET api/<controller>/current
|
||||
|
@ -382,10 +382,10 @@ namespace Oqtane.Controllers
|
|||
return user;
|
||||
}
|
||||
|
||||
private string GetUserRoles(int UserId, int SiteId)
|
||||
private string GetUserRoles(int userId, int siteId)
|
||||
{
|
||||
string roles = "";
|
||||
List<UserRole> userroles = _userRoles.GetUserRoles(UserId, SiteId).ToList();
|
||||
List<UserRole> userroles = _userRoles.GetUserRoles(userId, siteId).ToList();
|
||||
foreach (UserRole userrole in userroles)
|
||||
{
|
||||
roles += userrole.Role.Name + ";";
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user