fixing spacing
This commit is contained in:
parent
72c154b048
commit
e42a687c9b
|
@ -27,7 +27,7 @@
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="url" HelpText="Enter the url of the file you wish to download" ResourceKey="Url">Url: </Label>
|
<Label Class="col-sm-3" For="url" HelpText="Enter the url of the file you wish to download" ResourceKey="Url">Url: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="url" class="form-control" @bind="@url" required/>
|
<input id="url" class="form-control" @bind="@url" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
@ -50,67 +50,67 @@
|
||||||
</TabStrip>
|
</TabStrip>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private string url = string.Empty;
|
private string url = string.Empty;
|
||||||
private List<Folder> _folders;
|
private List<Folder> _folders;
|
||||||
private int _folderId = -1;
|
private int _folderId = -1;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
_folders = await FolderService.GetFoldersAsync(ModuleState.SiteId);
|
||||||
|
|
||||||
|
if (PageState.QueryString.ContainsKey("id"))
|
||||||
{
|
{
|
||||||
_folders = await FolderService.GetFoldersAsync(ModuleState.SiteId);
|
_folderId = int.Parse(PageState.QueryString["id"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (PageState.QueryString.ContainsKey("id"))
|
private async Task Download()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
if (url == string.Empty || _folderId == -1)
|
||||||
{
|
{
|
||||||
_folderId = int.Parse(PageState.QueryString["id"]);
|
AddModuleMessage(Localizer["Message.Required.UrlFolder"], MessageType.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var filename = url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1);
|
||||||
|
|
||||||
|
if (!Constants.UploadableFiles.Split(',')
|
||||||
|
.Contains(Path.GetExtension(filename).ToLower().Replace(".", "")))
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Download.InvalidExtension"], MessageType.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!filename.IsPathOrFileValid())
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Required.UrlName"], MessageType.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await FileService.UploadFileAsync(url, _folderId);
|
||||||
|
await logger.LogInformation("File Downloaded Successfully From Url {Url}", url);
|
||||||
|
AddModuleMessage(Localizer["Success.Download.File"], MessageType.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Downloading File From Url {Url} {Error}", url, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Download.InvalidUrl"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private async Task Download()
|
|
||||||
{
|
{
|
||||||
validated = true;
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
if (url == string.Empty || _folderId == -1)
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Required.UrlFolder"], MessageType.Warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var filename = url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1);
|
|
||||||
|
|
||||||
if (!Constants.UploadableFiles.Split(',')
|
|
||||||
.Contains(Path.GetExtension(filename).ToLower().Replace(".", "")))
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Download.InvalidExtension"], MessageType.Warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!filename.IsPathOrFileValid())
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Required.UrlName"], MessageType.Warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await FileService.UploadFileAsync(url, _folderId);
|
|
||||||
await logger.LogInformation("File Downloaded Successfully From Url {Url}", url);
|
|
||||||
AddModuleMessage(Localizer["Success.Download.File"], MessageType.Success);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Downloading File From Url {Url} {Error}", url, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Download.InvalidUrl"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -42,80 +42,79 @@
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private int _fileId = -1;
|
private int _fileId = -1;
|
||||||
private string _name;
|
private string _name;
|
||||||
private List<Folder> _folders;
|
private List<Folder> _folders;
|
||||||
private int _folderId = -1;
|
private int _folderId = -1;
|
||||||
private int _size;
|
private int _size;
|
||||||
private string _createdBy;
|
private string _createdBy;
|
||||||
private DateTime _createdOn;
|
private DateTime _createdOn;
|
||||||
private string _modifiedBy;
|
private string _modifiedBy;
|
||||||
private DateTime _modifiedOn;
|
private DateTime _modifiedOn;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
public override string Title => "File Management";
|
public override string Title => "File Management";
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId);
|
||||||
|
_fileId = Int32.Parse(PageState.QueryString["id"]);
|
||||||
|
File file = await FileService.GetFileAsync(_fileId);
|
||||||
|
if (file != null)
|
||||||
{
|
{
|
||||||
try
|
_name = file.Name;
|
||||||
{
|
_folderId = file.FolderId;
|
||||||
_folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId);
|
_size = file.Size;
|
||||||
_fileId = Int32.Parse(PageState.QueryString["id"]);
|
_createdBy = file.CreatedBy;
|
||||||
File file = await FileService.GetFileAsync(_fileId);
|
_createdOn = file.CreatedOn;
|
||||||
if (file != null)
|
_modifiedBy = file.ModifiedBy;
|
||||||
{
|
_modifiedOn = file.ModifiedOn;
|
||||||
_name = file.Name;
|
|
||||||
_folderId = file.FolderId;
|
|
||||||
_size = file.Size;
|
|
||||||
_createdBy = file.CreatedBy;
|
|
||||||
_createdOn = file.CreatedOn;
|
|
||||||
_modifiedBy = file.ModifiedBy;
|
|
||||||
_modifiedOn = file.ModifiedOn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading File {FileId} {Error}", _fileId, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.File.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading File {FileId} {Error}", _fileId, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.File.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task SaveFile()
|
private async Task SaveFile()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
validated = true;
|
if (_name.IsPathOrFileValid())
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
{
|
||||||
try
|
File file = await FileService.GetFileAsync(_fileId);
|
||||||
{
|
file.Name = _name;
|
||||||
if (_name.IsPathOrFileValid())
|
file.FolderId = _folderId;
|
||||||
{
|
file = await FileService.UpdateFileAsync(file);
|
||||||
File file = await FileService.GetFileAsync(_fileId);
|
await logger.LogInformation("File Saved {File}", file);
|
||||||
file.Name = _name;
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
file.FolderId = _folderId;
|
|
||||||
file = await FileService.UpdateFileAsync(file);
|
|
||||||
await logger.LogInformation("File Saved {File}", file);
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.File.InvalidName"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Saving File {FileId} {Error}", _fileId, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.File.Save"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
AddModuleMessage(Localizer["Message.File.InvalidName"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Saving File {FileId} {Error}", _fileId, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.File.Save"], MessageType.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,247 +8,247 @@
|
||||||
|
|
||||||
@if (_folders != null)
|
@if (_folders != null)
|
||||||
{
|
{
|
||||||
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="parent" HelpText="Select the parent folder" ResourceKey="Parent">Parent: </Label>
|
<Label Class="col-sm-3" For="parent" HelpText="Select the parent folder" ResourceKey="Parent">Parent: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<select id="parent" class="form-select" @bind="@_parentId" required>
|
<select id="parent" class="form-select" @bind="@_parentId" required>
|
||||||
|
@if (PageState.QueryString.ContainsKey("id"))
|
||||||
|
{
|
||||||
|
<option value="-1"><@Localizer["NoParent"]></option>
|
||||||
|
}
|
||||||
|
@foreach (Folder folder in _folders)
|
||||||
|
{
|
||||||
|
<option value="@(folder.FolderId)">@(new string('-', folder.Level * 2))@(folder.Name)</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="name" HelpText="Enter the folder name" ResourceKey="Name">Name: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="name" class="form-control" @bind="@_name" maxlength="256" required />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="type" HelpText="Select the folder type. Private folders are only accessible by authorized users. Public folders can be accessed by all users" ResourceKey="Name">Type: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
@if (PageState.QueryString.ContainsKey("id"))
|
@if (PageState.QueryString.ContainsKey("id"))
|
||||||
{
|
{
|
||||||
<option value="-1"><@Localizer["NoParent"]></option>
|
<input id="type" class="form-control" readonly @bind="@_type" />
|
||||||
}
|
}
|
||||||
@foreach (Folder folder in _folders)
|
else
|
||||||
{
|
{
|
||||||
<option value="@(folder.FolderId)">@(new string('-', folder.Level * 2))@(folder.Name)</option>
|
<select id="type" class="form-select" @bind="@_type" required>
|
||||||
|
<option value="@FolderTypes.Private">@Localizer[FolderTypes.Private]</option>
|
||||||
|
<option value="@FolderTypes.Public">@Localizer[FolderTypes.Public]</option>
|
||||||
|
</select>
|
||||||
}
|
}
|
||||||
</select>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="col-sm-12">
|
||||||
<Label Class="col-sm-3" For="name" HelpText="Enter the folder name" ResourceKey="Name">Name: </Label>
|
<Label Class="col-sm-3" For="permissions" HelpText="Select the permissions you want for the folder" ResourceKey="Permissions">Permissions: </Label>
|
||||||
<div class="col-sm-9">
|
<PermissionGrid EntityName="@EntityNames.Folder" PermissionNames="@(PermissionNames.Browse + "," + PermissionNames.View + "," + PermissionNames.Edit)" Permissions="@_permissions" @ref="_permissionGrid" />
|
||||||
<input id="name" class="form-control" @bind="@_name" maxlength="256" required />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="type" HelpText="Select the folder type. Private folders are only accessible by authorized users. Public folders can be accessed by all users" ResourceKey="Name">Type: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
@if (PageState.QueryString.ContainsKey("id"))
|
|
||||||
{
|
|
||||||
<input id="type" class="form-control" readonly @bind="@_type" />
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<select id="type" class="form-select" @bind="@_type" required>
|
|
||||||
<option value="@FolderTypes.Private">@Localizer[FolderTypes.Private]</option>
|
|
||||||
<option value="@FolderTypes.Public">@Localizer[FolderTypes.Public]</option>
|
|
||||||
</select>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<div class="col-sm-12">
|
|
||||||
<Label Class="col-sm-3" For="permissions" HelpText="Select the permissions you want for the folder" ResourceKey="Permissions">Permissions: </Label>
|
|
||||||
<PermissionGrid EntityName="@EntityNames.Folder" PermissionNames="@(PermissionNames.Browse + "," + PermissionNames.View + "," + PermissionNames.Edit)" Permissions="@_permissions" @ref="_permissionGrid" />
|
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
@if (!_isSystem)
|
@if (!_isSystem)
|
||||||
{
|
{
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveFolder">@SharedLocalizer["Save"]</button>
|
<button type="button" class="btn btn-success" @onclick="SaveFolder">@SharedLocalizer["Save"]</button>
|
||||||
@((MarkupString)" ")
|
@((MarkupString)" ")
|
||||||
}
|
}
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
@if (!_isSystem && PageState.QueryString.ContainsKey("id"))
|
@if (!_isSystem && PageState.QueryString.ContainsKey("id"))
|
||||||
{
|
{
|
||||||
@((MarkupString)" ")
|
@((MarkupString)" ")
|
||||||
<ActionDialog Header="Delete Folder" Message="Are You Sure You Wish To Delete This Folder?" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteFolder())" ResourceKey="DeleteFolder" />
|
<ActionDialog Header="Delete Folder" Message="Are You Sure You Wish To Delete This Folder?" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteFolder())" ResourceKey="DeleteFolder" />
|
||||||
}
|
}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
@if (PageState.QueryString.ContainsKey("id"))
|
@if (PageState.QueryString.ContainsKey("id"))
|
||||||
{
|
{
|
||||||
<AuditInfo CreatedBy="@_createdBy" CreatedOn="@_createdOn" ModifiedBy="@_modifiedBy" ModifiedOn="@_modifiedOn"></AuditInfo>
|
<AuditInfo CreatedBy="@_createdBy" CreatedOn="@_createdOn" ModifiedBy="@_modifiedBy" ModifiedOn="@_modifiedOn"></AuditInfo>
|
||||||
}
|
}
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private List<Folder> _folders;
|
private List<Folder> _folders;
|
||||||
private int _folderId = -1;
|
private int _folderId = -1;
|
||||||
private int _parentId = -1;
|
private int _parentId = -1;
|
||||||
private string _name;
|
private string _name;
|
||||||
private string _type = FolderTypes.Private;
|
private string _type = FolderTypes.Private;
|
||||||
private bool _isSystem;
|
private bool _isSystem;
|
||||||
private string _permissions = string.Empty;
|
private string _permissions = string.Empty;
|
||||||
private string _createdBy;
|
private string _createdBy;
|
||||||
private DateTime _createdOn;
|
private DateTime _createdOn;
|
||||||
private string _modifiedBy;
|
private string _modifiedBy;
|
||||||
private DateTime _modifiedOn;
|
private DateTime _modifiedOn;
|
||||||
|
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
private PermissionGrid _permissionGrid;
|
private PermissionGrid _permissionGrid;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
public override string Title => "Folder Management";
|
public override string Title => "Folder Management";
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
_folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId);
|
||||||
|
|
||||||
|
if (PageState.QueryString.ContainsKey("id"))
|
||||||
{
|
{
|
||||||
_folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId);
|
_folderId = Int32.Parse(PageState.QueryString["id"]);
|
||||||
|
Folder folder = await FolderService.GetFolderAsync(_folderId);
|
||||||
if (PageState.QueryString.ContainsKey("id"))
|
if (folder != null)
|
||||||
{
|
{
|
||||||
_folderId = Int32.Parse(PageState.QueryString["id"]);
|
_parentId = folder.ParentId ?? -1;
|
||||||
Folder folder = await FolderService.GetFolderAsync(_folderId);
|
_name = folder.Name;
|
||||||
if (folder != null)
|
_type = folder.Type;
|
||||||
{
|
_isSystem = folder.IsSystem;
|
||||||
_parentId = folder.ParentId ?? -1;
|
_permissions = folder.Permissions;
|
||||||
_name = folder.Name;
|
_createdBy = folder.CreatedBy;
|
||||||
_type = folder.Type;
|
_createdOn = folder.CreatedOn;
|
||||||
_isSystem = folder.IsSystem;
|
_modifiedBy = folder.ModifiedBy;
|
||||||
_permissions = folder.Permissions;
|
_modifiedOn = folder.ModifiedOn;
|
||||||
_createdBy = folder.CreatedBy;
|
|
||||||
_createdOn = folder.CreatedOn;
|
|
||||||
_modifiedBy = folder.ModifiedBy;
|
|
||||||
_modifiedOn = folder.ModifiedOn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_parentId = _folders[0].FolderId;
|
|
||||||
_permissions = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Folder {FolderId} {Error}", _folderId, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Folder.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SaveFolder()
|
|
||||||
{
|
|
||||||
validated = true;
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
if (_name == string.Empty || _parentId == -1)
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Required.FolderParent"], MessageType.Warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_name.IsPathOrFileValid())
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Folder.InvalidName"], MessageType.Warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Folder folder;
|
|
||||||
if (_folderId != -1)
|
|
||||||
{
|
|
||||||
folder = await FolderService.GetFolderAsync(_folderId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
folder = new Folder();
|
|
||||||
}
|
|
||||||
|
|
||||||
folder.SiteId = PageState.Site.SiteId;
|
|
||||||
|
|
||||||
if (_parentId == -1)
|
|
||||||
{
|
|
||||||
folder.ParentId = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
folder.ParentId = _parentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
folder.Name = _name;
|
|
||||||
folder.Type = _type;
|
|
||||||
folder.IsSystem = _isSystem;
|
|
||||||
folder.Permissions = _permissionGrid.GetPermissions();
|
|
||||||
|
|
||||||
if (_folderId != -1)
|
|
||||||
{
|
|
||||||
folder = await FolderService.UpdateFolderAsync(folder);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
folder = await FolderService.AddFolderAsync(folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (folder != null)
|
|
||||||
{
|
|
||||||
await FolderService.UpdateFolderOrderAsync(folder.SiteId, folder.FolderId, folder.ParentId);
|
|
||||||
await logger.LogInformation("Folder Saved {Folder}", folder);
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Error.Folder.Save"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Saving Folder {FolderId} {Error}", _folderId, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Folder.Save"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
_parentId = _folders[0].FolderId;
|
||||||
|
_permissions = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
private async Task DeleteFolder()
|
|
||||||
{
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Folder {FolderId} {Error}", _folderId, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Folder.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveFolder()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
if (_name == string.Empty || _parentId == -1)
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Required.FolderParent"], MessageType.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_name.IsPathOrFileValid())
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Folder.InvalidName"], MessageType.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool isparent = false;
|
Folder folder;
|
||||||
foreach (Folder folder in _folders)
|
if (_folderId != -1)
|
||||||
{
|
{
|
||||||
if (folder.ParentId == _folderId)
|
folder = await FolderService.GetFolderAsync(_folderId);
|
||||||
{
|
|
||||||
isparent = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isparent)
|
|
||||||
{
|
|
||||||
var files = await FileService.GetFilesAsync(_folderId);
|
|
||||||
if (files.Count == 0)
|
|
||||||
{
|
|
||||||
await FolderService.DeleteFolderAsync(_folderId);
|
|
||||||
await logger.LogInformation("Folder Deleted {Folder}", _folderId);
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Folder.Files.InvalidDelete"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Folder.Subfolders.InvalidDelete"], MessageType.Warning);
|
folder = new Folder();
|
||||||
|
}
|
||||||
|
|
||||||
|
folder.SiteId = PageState.Site.SiteId;
|
||||||
|
|
||||||
|
if (_parentId == -1)
|
||||||
|
{
|
||||||
|
folder.ParentId = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
folder.ParentId = _parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
folder.Name = _name;
|
||||||
|
folder.Type = _type;
|
||||||
|
folder.IsSystem = _isSystem;
|
||||||
|
folder.Permissions = _permissionGrid.GetPermissions();
|
||||||
|
|
||||||
|
if (_folderId != -1)
|
||||||
|
{
|
||||||
|
folder = await FolderService.UpdateFolderAsync(folder);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
folder = await FolderService.AddFolderAsync(folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (folder != null)
|
||||||
|
{
|
||||||
|
await FolderService.UpdateFolderOrderAsync(folder.SiteId, folder.FolderId, folder.ParentId);
|
||||||
|
await logger.LogInformation("Folder Saved {Folder}", folder);
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Error.Folder.Save"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Deleting Folder {Folder} {Error}", _folderId, ex.Message);
|
await logger.LogError(ex, "Error Saving Folder {FolderId} {Error}", _folderId, ex.Message);
|
||||||
AddModuleMessage(Localizer["Error.Folder.Delete"], MessageType.Error);
|
AddModuleMessage(Localizer["Error.Folder.Save"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task DeleteFolder()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bool isparent = false;
|
||||||
|
foreach (Folder folder in _folders)
|
||||||
|
{
|
||||||
|
if (folder.ParentId == _folderId)
|
||||||
|
{
|
||||||
|
isparent = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isparent)
|
||||||
|
{
|
||||||
|
var files = await FileService.GetFilesAsync(_folderId);
|
||||||
|
if (files.Count == 0)
|
||||||
|
{
|
||||||
|
await FolderService.DeleteFolderAsync(_folderId);
|
||||||
|
await logger.LogInformation("Folder Deleted {Folder}", _folderId);
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Folder.Files.InvalidDelete"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Folder.Subfolders.InvalidDelete"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Deleting Folder {Folder} {Error}", _folderId, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Folder.Delete"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -52,66 +52,66 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<Folder> _folders;
|
private List<Folder> _folders;
|
||||||
private int _folderId = -1;
|
private int _folderId = -1;
|
||||||
private List<File> _files;
|
private List<File> _files;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
_folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId);
|
||||||
{
|
|
||||||
_folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId);
|
|
||||||
|
|
||||||
if (_folderId == -1 && _folders.Count > 0)
|
if (_folderId == -1 && _folders.Count > 0)
|
||||||
{
|
|
||||||
_folderId = _folders[0].FolderId;
|
|
||||||
await GetFiles();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Files {Error}", ex.Message);
|
_folderId = _folders[0].FolderId;
|
||||||
AddModuleMessage(Localizer["Error.File.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task GetFiles()
|
|
||||||
{
|
|
||||||
_files = await FileService.GetFilesAsync(_folderId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void FolderChanged(ChangeEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_folderId = int.Parse((string)e.Value);
|
|
||||||
await GetFiles();
|
await GetFiles();
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Files {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.File.Load"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
private async Task DeleteFile(File file)
|
|
||||||
{
|
{
|
||||||
try
|
await logger.LogError(ex, "Error Loading Files {Error}", ex.Message);
|
||||||
{
|
AddModuleMessage(Localizer["Error.File.Load"], MessageType.Error);
|
||||||
await FileService.DeleteFileAsync(file.FileId);
|
|
||||||
await logger.LogInformation("File Deleted {File}", file.Name);
|
|
||||||
AddModuleMessage(string.Format(Localizer["Success.File.Delete"], file.Name), MessageType.Success);
|
|
||||||
await GetFiles();
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Deleting File {File} {Error}", file.Name, ex.Message);
|
|
||||||
AddModuleMessage(string.Format(Localizer["Error.File.Delete"], file.Name), MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task GetFiles()
|
||||||
|
{
|
||||||
|
_files = await FileService.GetFilesAsync(_folderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void FolderChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_folderId = int.Parse((string)e.Value);
|
||||||
|
await GetFiles();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Files {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.File.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteFile(File file)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await FileService.DeleteFileAsync(file.FileId);
|
||||||
|
await logger.LogInformation("File Deleted {File}", file.Name);
|
||||||
|
AddModuleMessage(string.Format(Localizer["Success.File.Delete"], file.Name), MessageType.Success);
|
||||||
|
await GetFiles();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Deleting File {File} {Error}", file.Name, ex.Message);
|
||||||
|
AddModuleMessage(string.Format(Localizer["Error.File.Delete"], file.Name), MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="type" HelpText="The fully qualified job type name" ResourceKey="Type">Type: </Label>
|
<Label Class="col-sm-3" For="type" HelpText="The fully qualified job type name" ResourceKey="Type">Type: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="type" class="form-control" @bind="@_jobType" readonly/>
|
<input id="type" class="form-control" @bind="@_jobType" readonly />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
@ -73,115 +73,113 @@
|
||||||
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
|
private int _jobId;
|
||||||
|
private string _name = string.Empty;
|
||||||
|
private string _jobType = string.Empty;
|
||||||
|
private string _isEnabled = "True";
|
||||||
|
private string _interval = string.Empty;
|
||||||
|
private string _frequency = string.Empty;
|
||||||
|
private string _startDate = string.Empty;
|
||||||
|
private string _endDate = string.Empty;
|
||||||
|
private string _retentionHistory = string.Empty;
|
||||||
|
private string _nextExecution = string.Empty;
|
||||||
|
private string createdby;
|
||||||
|
private DateTime createdon;
|
||||||
|
private string modifiedby;
|
||||||
|
private DateTime modifiedon;
|
||||||
|
|
||||||
private int _jobId;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
private string _name = string.Empty;
|
|
||||||
private string _jobType = string.Empty;
|
|
||||||
private string _isEnabled = "True";
|
|
||||||
private string _interval = string.Empty;
|
|
||||||
private string _frequency = string.Empty;
|
|
||||||
private string _startDate = string.Empty;
|
|
||||||
private string _endDate = string.Empty;
|
|
||||||
private string _retentionHistory = string.Empty;
|
|
||||||
private string _nextExecution = string.Empty;
|
|
||||||
private string createdby;
|
|
||||||
private DateTime createdon;
|
|
||||||
private string modifiedby;
|
|
||||||
private DateTime modifiedon;
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
protected override async Task OnInitializedAsync()
|
try
|
||||||
{
|
{
|
||||||
try
|
_jobId = Int32.Parse(PageState.QueryString["id"]);
|
||||||
|
Job job = await JobService.GetJobAsync(_jobId);
|
||||||
|
if (job != null)
|
||||||
{
|
{
|
||||||
_jobId = Int32.Parse(PageState.QueryString["id"]);
|
_name = job.Name;
|
||||||
Job job = await JobService.GetJobAsync(_jobId);
|
_jobType = job.JobType;
|
||||||
if (job != null)
|
_isEnabled = job.IsEnabled.ToString();
|
||||||
{
|
_interval = job.Interval.ToString();
|
||||||
_name = job.Name;
|
_frequency = job.Frequency;
|
||||||
_jobType = job.JobType;
|
_startDate = (job.StartDate != null) ? job.StartDate.ToString() : string.Empty;
|
||||||
_isEnabled = job.IsEnabled.ToString();
|
_endDate = (job.EndDate != null) ? job.EndDate.ToString() : string.Empty;
|
||||||
_interval = job.Interval.ToString();
|
_retentionHistory = job.RetentionHistory.ToString();
|
||||||
_frequency = job.Frequency;
|
_nextExecution = job.NextExecution.ToString();
|
||||||
_startDate = (job.StartDate != null) ? job.StartDate.ToString() : string.Empty;
|
createdby = job.CreatedBy;
|
||||||
_endDate = (job.EndDate != null) ? job.EndDate.ToString() : string.Empty;
|
createdon = job.CreatedOn;
|
||||||
_retentionHistory = job.RetentionHistory.ToString();
|
modifiedby = job.ModifiedBy;
|
||||||
_nextExecution = job.NextExecution.ToString();
|
modifiedon = job.ModifiedOn;
|
||||||
createdby = job.CreatedBy;
|
|
||||||
createdon = job.CreatedOn;
|
|
||||||
modifiedby = job.ModifiedBy;
|
|
||||||
modifiedon = job.ModifiedOn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Job {JobId} {Error}", _jobId, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Job.Load"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
private async Task SaveJob()
|
|
||||||
{
|
{
|
||||||
validated = true;
|
await logger.LogError(ex, "Error Loading Job {JobId} {Error}", _jobId, ex.Message);
|
||||||
var interop = new Interop(JSRuntime);
|
AddModuleMessage(Localizer["Error.Job.Load"], MessageType.Error);
|
||||||
if (await interop.FormValid(form))
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveJob()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
var job = await JobService.GetJobAsync(_jobId);
|
||||||
|
job.Name = _name;
|
||||||
|
job.JobType = _jobType;
|
||||||
|
job.IsEnabled = Boolean.Parse(_isEnabled);
|
||||||
|
job.Frequency = _frequency;
|
||||||
|
job.Interval = int.Parse(_interval);
|
||||||
|
|
||||||
|
if (_startDate == string.Empty)
|
||||||
{
|
{
|
||||||
var job = await JobService.GetJobAsync(_jobId);
|
job.StartDate = null;
|
||||||
job.Name = _name;
|
|
||||||
job.JobType = _jobType;
|
|
||||||
job.IsEnabled = Boolean.Parse(_isEnabled);
|
|
||||||
job.Frequency = _frequency;
|
|
||||||
job.Interval = int.Parse(_interval);
|
|
||||||
|
|
||||||
if (_startDate == string.Empty)
|
|
||||||
{
|
|
||||||
job.StartDate = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
job.StartDate = DateTime.Parse(_startDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_endDate == string.Empty)
|
|
||||||
{
|
|
||||||
job.EndDate = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
job.EndDate = DateTime.Parse(_endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_nextExecution == string.Empty)
|
|
||||||
{
|
|
||||||
job.NextExecution = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
job.NextExecution = DateTime.Parse(_nextExecution);
|
|
||||||
}
|
|
||||||
|
|
||||||
job.RetentionHistory = int.Parse(_retentionHistory);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
job = await JobService.UpdateJobAsync(job);
|
|
||||||
await logger.LogInformation("Job Updated {Job}", job);
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Udate Job {Job} {Error}", job, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Job.Update"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.JobInfo"], MessageType.Warning);
|
job.StartDate = DateTime.Parse(_startDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_endDate == string.Empty)
|
||||||
|
{
|
||||||
|
job.EndDate = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
job.EndDate = DateTime.Parse(_endDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_nextExecution == string.Empty)
|
||||||
|
{
|
||||||
|
job.NextExecution = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
job.NextExecution = DateTime.Parse(_nextExecution);
|
||||||
|
}
|
||||||
|
|
||||||
|
job.RetentionHistory = int.Parse(_retentionHistory);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
job = await JobService.UpdateJobAsync(job);
|
||||||
|
await logger.LogInformation("Job Updated {Job}", job);
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Udate Job {Job} {Error}", job, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Job.Update"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Required.JobInfo"], MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -10,132 +10,132 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<ActionLink Action="Log" Class="btn btn-secondary" Text="View Logs" ResourceKey="ViewJobs" />
|
<ActionLink Action="Log" Class="btn btn-secondary" Text="View Logs" ResourceKey="ViewJobs" />
|
||||||
<button type="button" class="btn btn-secondary" @onclick="(async () => await Refresh())">Refresh</button>
|
<button type="button" class="btn btn-secondary" @onclick="(async () => await Refresh())">Refresh</button>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<Pager Items="@_jobs">
|
<Pager Items="@_jobs">
|
||||||
<Header>
|
<Header>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th>@SharedLocalizer["Name"]</th>
|
<th>@SharedLocalizer["Name"]</th>
|
||||||
<th>@SharedLocalizer["Status"]</th>
|
<th>@SharedLocalizer["Status"]</th>
|
||||||
<th>@Localizer["Frequency"]</th>
|
<th>@Localizer["Frequency"]</th>
|
||||||
<th>@Localizer["NextExecution"]</th>
|
<th>@Localizer["NextExecution"]</th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.JobId.ToString())" ResourceKey="EditJob" /></td>
|
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.JobId.ToString())" ResourceKey="EditJob" /></td>
|
||||||
<td><ActionDialog Header="Delete Job" Message="Are You Sure You Wish To Delete This Job?" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteJob(context))" ResourceKey="DeleteJob" /></td>
|
<td><ActionDialog Header="Delete Job" Message="Are You Sure You Wish To Delete This Job?" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteJob(context))" ResourceKey="DeleteJob" /></td>
|
||||||
<td><ActionLink Action="Log" Class="btn btn-secondary" Parameters="@($"id=" + context.JobId.ToString())" ResourceKey="JobLog" /></td>
|
<td><ActionLink Action="Log" Class="btn btn-secondary" Parameters="@($"id=" + context.JobId.ToString())" ResourceKey="JobLog" /></td>
|
||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
<td>@DisplayStatus(context.IsEnabled, context.IsExecuting)</td>
|
<td>@DisplayStatus(context.IsEnabled, context.IsExecuting)</td>
|
||||||
<td>@DisplayFrequency(context.Interval, context.Frequency)</td>
|
<td>@DisplayFrequency(context.Interval, context.Frequency)</td>
|
||||||
<td>@context.NextExecution</td>
|
<td>@context.NextExecution</td>
|
||||||
<td>
|
<td>
|
||||||
@if (context.IsStarted)
|
@if (context.IsStarted)
|
||||||
{
|
|
||||||
<button type="button" class="btn btn-danger" @onclick="(async () => await StopJob(context.JobId))">@Localizer["Stop"]</button>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<button type="button" class="btn btn-success" @onclick="(async () => await StartJob(context.JobId))">@Localizer["Start"]</button>
|
|
||||||
}
|
|
||||||
</td>
|
|
||||||
</Row>
|
|
||||||
</Pager>
|
|
||||||
}
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private List<Job> _jobs;
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
|
||||||
{
|
|
||||||
_jobs = await JobService.GetJobsAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
private string DisplayStatus(bool isEnabled, bool isExecuting)
|
|
||||||
{
|
|
||||||
var status = string.Empty;
|
|
||||||
if (!isEnabled)
|
|
||||||
{
|
|
||||||
status = Localizer["Disabled"];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (isExecuting)
|
|
||||||
{
|
{
|
||||||
status = Localizer["Executing"];
|
<button type="button" class="btn btn-danger" @onclick="(async () => await StopJob(context.JobId))">@Localizer["Stop"]</button>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
status = Localizer["Idle"];
|
<button type="button" class="btn btn-success" @onclick="(async () => await StartJob(context.JobId))">@Localizer["Start"]</button>
|
||||||
}
|
}
|
||||||
}
|
</td>
|
||||||
|
</Row>
|
||||||
|
</Pager>
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
@code {
|
||||||
}
|
private List<Job> _jobs;
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||||
|
|
||||||
private string DisplayFrequency(int interval, string frequency)
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
_jobs = await JobService.GetJobsAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string DisplayStatus(bool isEnabled, bool isExecuting)
|
||||||
|
{
|
||||||
|
var status = string.Empty;
|
||||||
|
if (!isEnabled)
|
||||||
|
{
|
||||||
|
status = Localizer["Disabled"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (isExecuting)
|
||||||
{
|
{
|
||||||
var result = $"{Localizer["Every"]} {interval.ToString()} ";
|
status = Localizer["Executing"];
|
||||||
switch (frequency)
|
|
||||||
{
|
|
||||||
case "m":
|
|
||||||
result += Localizer["Minute"];
|
|
||||||
break;
|
|
||||||
case "H":
|
|
||||||
result += Localizer["Hour"];
|
|
||||||
break;
|
|
||||||
case "d":
|
|
||||||
result += Localizer["Day"];
|
|
||||||
break;
|
|
||||||
case "M":
|
|
||||||
result += Localizer["Month"];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (interval > 1)
|
|
||||||
{
|
|
||||||
result += Localizer["s"];
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private async Task DeleteJob(Job job)
|
|
||||||
{
|
{
|
||||||
try
|
status = Localizer["Idle"];
|
||||||
{
|
|
||||||
await JobService.DeleteJobAsync(job.JobId);
|
|
||||||
await logger.LogInformation("Job Deleted {Job}", job);
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Deleting Job {Job} {Error}", job, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Job.Delete"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task StartJob(int jobId)
|
|
||||||
{
|
|
||||||
await JobService.StartJobAsync(jobId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task StopJob(int jobId)
|
|
||||||
{
|
|
||||||
await JobService.StopJobAsync(jobId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Refresh()
|
|
||||||
{
|
|
||||||
_jobs = await JobService.GetJobsAsync();
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private string DisplayFrequency(int interval, string frequency)
|
||||||
|
{
|
||||||
|
var result = $"{Localizer["Every"]} {interval.ToString()} ";
|
||||||
|
switch (frequency)
|
||||||
|
{
|
||||||
|
case "m":
|
||||||
|
result += Localizer["Minute"];
|
||||||
|
break;
|
||||||
|
case "H":
|
||||||
|
result += Localizer["Hour"];
|
||||||
|
break;
|
||||||
|
case "d":
|
||||||
|
result += Localizer["Day"];
|
||||||
|
break;
|
||||||
|
case "M":
|
||||||
|
result += Localizer["Month"];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (interval > 1)
|
||||||
|
{
|
||||||
|
result += Localizer["s"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteJob(Job job)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await JobService.DeleteJobAsync(job.JobId);
|
||||||
|
await logger.LogInformation("Job Deleted {Job}", job);
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Deleting Job {Job} {Error}", job, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Job.Delete"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task StartJob(int jobId)
|
||||||
|
{
|
||||||
|
await JobService.StartJobAsync(jobId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task StopJob(int jobId)
|
||||||
|
{
|
||||||
|
await JobService.StopJobAsync(jobId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Refresh()
|
||||||
|
{
|
||||||
|
_jobs = await JobService.GetJobsAsync();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -15,240 +15,240 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabPanel Name="Manage" ResourceKey="Manage">
|
<TabPanel Name="Manage" ResourceKey="Manage">
|
||||||
@if (_availableCultures.Count() == 0)
|
@if (_availableCultures.Count() == 0)
|
||||||
|
{
|
||||||
|
<ModuleMessage Type="MessageType.Info" Message="@_message"></ModuleMessage>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
|
<div class="container">
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="name" HelpText="Name Of The Language" ResourceKey="Name">Name:</Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="_code" class="form-select" @bind="@_code" required>
|
||||||
|
@foreach (var culture in _availableCultures)
|
||||||
|
{
|
||||||
|
<option value="@culture.Name">@culture.DisplayName</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="default" HelpText="Indicates Whether Or Not This Language Is The Default For The Site" ResourceKey="IsDefault">Default?</Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="default" class="form-select" @bind="@_isDefault" required>
|
||||||
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn btn-success" @onclick="SaveLanguage">@SharedLocalizer["Save"]</button>
|
||||||
|
</form>
|
||||||
|
}
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
</TabPanel>
|
||||||
|
<TabPanel Name="Download" ResourceKey="Download" Security="SecurityAccessLevel.Host">
|
||||||
|
<ModuleMessage Type="MessageType.Info" Message="Download one or more translations from the list below. Once you are ready click Install to complete the installation."></ModuleMessage>
|
||||||
|
<div class="container">
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="search" class="form-control" placeholder="@SharedLocalizer["Search.Hint"]" @bind="@_search" />
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<button type="button" class="btn btn-primary" @onclick="Search">@SharedLocalizer["Search"]</button>
|
||||||
|
<button type="button" class="btn btn-secondary" @onclick="Reset">@SharedLocalizer["Reset"]</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (_packages != null)
|
||||||
|
{
|
||||||
|
@if (_packages.Count > 0)
|
||||||
{
|
{
|
||||||
<ModuleMessage Type="MessageType.Info" Message="@_message"></ModuleMessage>
|
<Pager Items="@_packages">
|
||||||
|
<Row>
|
||||||
|
<td>
|
||||||
|
<h3 style="display: inline;"><a href="@context.ProductUrl" target="_new">@context.Name</a></h3> by: <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
||||||
|
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
||||||
|
<strong>@(String.Format("{0:n0}", context.Downloads))</strong> @SharedLocalizer["Search.Downloads"] | @SharedLocalizer["Search.Released"]: <strong>@context.ReleaseDate.ToString("MMM dd, yyyy")</strong> | @SharedLocalizer["Search.Version"]: <strong>@context.Version</strong> | @SharedLocalizer["Search.Source"]: <strong>@context.PackageUrl</strong>
|
||||||
|
</td>
|
||||||
|
<td style="vertical-align: middle;">
|
||||||
|
<button type="button" class="btn btn-primary" @onclick=@(async () => await DownloadLanguage(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
||||||
|
</td>
|
||||||
|
</Row>
|
||||||
|
</Pager>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
<br />
|
||||||
<div class="container">
|
<div class="mx-auto text-center">
|
||||||
<div class="row mb-1 align-items-center">
|
@Localizer["Search.NoResults"]
|
||||||
<Label Class="col-sm-3" For="name" HelpText="Name Of The Language" ResourceKey="Name">Name:</Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="_code" class="form-select" @bind="@_code" required>
|
|
||||||
@foreach (var culture in _availableCultures)
|
|
||||||
{
|
|
||||||
<option value="@culture.Name">@culture.DisplayName</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="default" HelpText="Indicates Whether Or Not This Language Is The Default For The Site" ResourceKey="IsDefault">Default?</Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="default" class="form-select" @bind="@_isDefault" required>
|
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveLanguage">@SharedLocalizer["Save"]</button>
|
|
||||||
</form>
|
|
||||||
}
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
</TabPanel>
|
|
||||||
<TabPanel Name="Download" ResourceKey="Download" Security="SecurityAccessLevel.Host">
|
|
||||||
<ModuleMessage Type="MessageType.Info" Message="Download one or more translations from the list below. Once you are ready click Install to complete the installation."></ModuleMessage>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="search" class="form-control" placeholder="@SharedLocalizer["Search.Hint"]" @bind="@_search"/>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<button type="button" class="btn btn-primary" @onclick="Search">@SharedLocalizer["Search"]</button>
|
|
||||||
<button type="button" class="btn btn-secondary" @onclick="Reset">@SharedLocalizer["Reset"]</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
@if (_packages != null)
|
|
||||||
{
|
|
||||||
@if (_packages.Count > 0)
|
|
||||||
{
|
|
||||||
<Pager Items="@_packages">
|
|
||||||
<Row>
|
|
||||||
<td>
|
|
||||||
<h3 style="display: inline;"><a href="@context.ProductUrl" target="_new">@context.Name</a></h3> by: <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
|
||||||
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
|
||||||
<strong>@(String.Format("{0:n0}", context.Downloads))</strong> @SharedLocalizer["Search.Downloads"] | @SharedLocalizer["Search.Released"]: <strong>@context.ReleaseDate.ToString("MMM dd, yyyy")</strong> | @SharedLocalizer["Search.Version"]: <strong>@context.Version</strong> | @SharedLocalizer["Search.Source"]: <strong>@context.PackageUrl</strong>
|
|
||||||
</td>
|
|
||||||
<td style="vertical-align: middle;">
|
|
||||||
<button type="button" class="btn btn-primary" @onclick=@(async () => await DownloadLanguage(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
|
||||||
</td>
|
|
||||||
</Row>
|
|
||||||
</Pager>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<br />
|
|
||||||
<div class="mx-auto text-center">
|
|
||||||
@Localizer["Search.NoResults"]
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
<button type="button" class="btn btn-success" @onclick="InstallLanguages">@SharedLocalizer["Install"]</button>
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
}
|
}
|
||||||
</TabPanel>
|
|
||||||
<TabPanel Name="Upload" ResourceKey="Upload" Security="SecurityAccessLevel.Host">
|
|
||||||
<div class="container">
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" HelpText="Upload one or more translations. Once they are uploaded click Install to complete the installation." ResourceKey="Module">Language: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<FileManager Filter="nupkg" ShowFiles="false" Folder="Packages" UploadMultiple="true" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button type="button" class="btn btn-success" @onclick="InstallLanguages">@SharedLocalizer["Install"]</button>
|
<button type="button" class="btn btn-success" @onclick="InstallLanguages">@SharedLocalizer["Install"]</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
</TabPanel>
|
}
|
||||||
</TabStrip>
|
</TabPanel>
|
||||||
|
<TabPanel Name="Upload" ResourceKey="Upload" Security="SecurityAccessLevel.Host">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" HelpText="Upload one or more translations. Once they are uploaded click Install to complete the installation." ResourceKey="Module">Language: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<FileManager Filter="nupkg" ShowFiles="false" Folder="Packages" UploadMultiple="true" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn btn-success" @onclick="InstallLanguages">@SharedLocalizer["Install"]</button>
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
</TabPanel>
|
||||||
|
</TabStrip>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
|
|
||||||
private string _code = string.Empty;
|
private string _code = string.Empty;
|
||||||
private string _isDefault = "False";
|
private string _isDefault = "False";
|
||||||
private string _message;
|
private string _message;
|
||||||
private IEnumerable<Culture> _supportedCultures;
|
private IEnumerable<Culture> _supportedCultures;
|
||||||
private IEnumerable<Culture> _availableCultures;
|
private IEnumerable<Culture> _availableCultures;
|
||||||
private List<Package> _packages;
|
private List<Package> _packages;
|
||||||
private string _search = "";
|
private string _search = "";
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
var languages = await LanguageService.GetLanguagesAsync(PageState.Site.SiteId);
|
||||||
|
var languagesCodes = languages.Select(l => l.Code).ToList();
|
||||||
|
|
||||||
|
_supportedCultures = await LocalizationService.GetCulturesAsync();
|
||||||
|
_availableCultures = _supportedCultures
|
||||||
|
.Where(c => !c.Name.Equals(Constants.DefaultCulture) && !languagesCodes.Contains(c.Name));
|
||||||
|
await LoadTranslations();
|
||||||
|
|
||||||
|
if (_supportedCultures.Count() == 1)
|
||||||
|
{
|
||||||
|
_message = Localizer["OnlyEnglish"];
|
||||||
|
}
|
||||||
|
else if (_availableCultures.Count() == 0)
|
||||||
|
{
|
||||||
|
_message = Localizer["AllLanguages"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadTranslations()
|
||||||
|
{
|
||||||
|
_packages = await PackageService.GetPackagesAsync("translation", _search);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Search()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await LoadTranslations();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error On Search");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Reset()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_search = "";
|
||||||
|
await LoadTranslations();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error On Reset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveLanguage()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
var language = new Language
|
||||||
{
|
{
|
||||||
var languages = await LanguageService.GetLanguagesAsync(PageState.Site.SiteId);
|
SiteId = PageState.Page.SiteId,
|
||||||
var languagesCodes = languages.Select(l => l.Code).ToList();
|
Name = CultureInfo.GetCultureInfo(_code).DisplayName,
|
||||||
|
Code = _code,
|
||||||
|
IsDefault = (_isDefault == null ? false : Boolean.Parse(_isDefault))
|
||||||
|
};
|
||||||
|
|
||||||
_supportedCultures = await LocalizationService.GetCulturesAsync();
|
try
|
||||||
_availableCultures = _supportedCultures
|
{
|
||||||
.Where(c => !c.Name.Equals(Constants.DefaultCulture) && !languagesCodes.Contains(c.Name));
|
language = await LanguageService.AddLanguageAsync(language);
|
||||||
await LoadTranslations();
|
|
||||||
|
|
||||||
if (_supportedCultures.Count() == 1)
|
if (language.IsDefault)
|
||||||
{
|
{
|
||||||
_message = Localizer["OnlyEnglish"];
|
await SetCultureAsync(language.Code);
|
||||||
}
|
|
||||||
else if (_availableCultures.Count() == 0)
|
|
||||||
{
|
|
||||||
_message = Localizer["AllLanguages"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await logger.LogInformation("Language Added {Language}", language);
|
||||||
|
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
private async Task LoadTranslations()
|
|
||||||
{
|
{
|
||||||
_packages = await PackageService.GetPackagesAsync("translation", _search);
|
await logger.LogError(ex, "Error Adding Language {Language} {Error}", language, ex.Message);
|
||||||
}
|
AddModuleMessage(Localizer["Error.Language.Add"], MessageType.Error);
|
||||||
|
|
||||||
private async Task Search()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await LoadTranslations();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error On Search");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Reset()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_search = "";
|
|
||||||
await LoadTranslations();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error On Reset");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SaveLanguage()
|
|
||||||
{
|
|
||||||
validated = true;
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
var language = new Language
|
|
||||||
{
|
|
||||||
SiteId = PageState.Page.SiteId,
|
|
||||||
Name = CultureInfo.GetCultureInfo(_code).DisplayName,
|
|
||||||
Code = _code,
|
|
||||||
IsDefault = (_isDefault == null ? false : Boolean.Parse(_isDefault))
|
|
||||||
};
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
language = await LanguageService.AddLanguageAsync(language);
|
|
||||||
|
|
||||||
if (language.IsDefault)
|
|
||||||
{
|
|
||||||
await SetCultureAsync(language.Code);
|
|
||||||
}
|
|
||||||
|
|
||||||
await logger.LogInformation("Language Added {Language}", language);
|
|
||||||
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Adding Language {Language} {Error}", language, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Language.Add"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task InstallLanguages()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await PackageService.InstallPackagesAsync();
|
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Language.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Installing Translations");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DownloadLanguage(string packageid, string version)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
|
||||||
await logger.LogInformation("Language Paclage {Name} {Version} Downloaded Successfully", packageid, version);
|
|
||||||
AddModuleMessage(Localizer["Success.Language.Download"], MessageType.Success);
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Downloading Translation {Name} {Version}", packageid, version);
|
|
||||||
AddModuleMessage(Localizer["Error.Language.Download"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SetCultureAsync(string culture)
|
|
||||||
{
|
|
||||||
if (culture != CultureInfo.CurrentUICulture.Name)
|
|
||||||
{
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
var localizationCookieValue = CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture));
|
|
||||||
await interop.SetCookie(CookieRequestCultureProvider.DefaultCookieName, localizationCookieValue, 360);
|
|
||||||
|
|
||||||
NavigationManager.NavigateTo(NavigationManager.Uri, forceLoad: true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InstallLanguages()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await PackageService.InstallPackagesAsync();
|
||||||
|
AddModuleMessage(string.Format(Localizer["Success.Language.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Installing Translations");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DownloadLanguage(string packageid, string version)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
||||||
|
await logger.LogInformation("Language Paclage {Name} {Version} Downloaded Successfully", packageid, version);
|
||||||
|
AddModuleMessage(Localizer["Success.Language.Download"], MessageType.Success);
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Downloading Translation {Name} {Version}", packageid, version);
|
||||||
|
AddModuleMessage(Localizer["Error.Language.Download"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SetCultureAsync(string culture)
|
||||||
|
{
|
||||||
|
if (culture != CultureInfo.CurrentUICulture.Name)
|
||||||
|
{
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
var localizationCookieValue = CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture));
|
||||||
|
await interop.SetCookie(CookieRequestCultureProvider.DefaultCookieName, localizationCookieValue, 360);
|
||||||
|
|
||||||
|
NavigationManager.NavigateTo(NavigationManager.Uri, forceLoad: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,101 +12,101 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<ActionLink Action="Add" Text="Add Language" ResourceKey="AddLanguage" />
|
<ActionLink Action="Add" Text="Add Language" ResourceKey="AddLanguage" />
|
||||||
|
|
||||||
<Pager Items="@_languages">
|
<Pager Items="@_languages">
|
||||||
<Header>
|
<Header>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th>@SharedLocalizer["Name"]</th>
|
<th>@SharedLocalizer["Name"]</th>
|
||||||
<th>@Localizer["Code"]</th>
|
<th>@Localizer["Code"]</th>
|
||||||
<th>@Localizer["Default"]</th>
|
<th>@Localizer["Default"]</th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><ActionDialog Header="Delete Language" Message="@string.Format(Localizer["Confirm.Language.Delete"], context.Name)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteLanguage(context))" Disabled="@((context.IsDefault && _languages.Count > 2) || context.Code == Constants.DefaultCulture)" ResourceKey="DeleteLanguage" /></td>
|
<td><ActionDialog Header="Delete Language" Message="@string.Format(Localizer["Confirm.Language.Delete"], context.Name)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteLanguage(context))" Disabled="@((context.IsDefault && _languages.Count > 2) || context.Code == Constants.DefaultCulture)" ResourceKey="DeleteLanguage" /></td>
|
||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
<td>@context.Code</td>
|
<td>@context.Code</td>
|
||||||
<td><TriStateCheckBox Value="@(context.IsDefault)" Disabled="true"></TriStateCheckBox></td>
|
<td><TriStateCheckBox Value="@(context.IsDefault)" Disabled="true"></TriStateCheckBox></td>
|
||||||
<td>
|
<td>
|
||||||
@if (UpgradeAvailable(context.Code))
|
@if (UpgradeAvailable(context.Code))
|
||||||
{
|
{
|
||||||
<button type="button" class="btn btn-success" @onclick=@(async () => await DownloadLanguage(context.Code))>@SharedLocalizer["Upgrade"]</button>
|
<button type="button" class="btn btn-success" @onclick=@(async () => await DownloadLanguage(context.Code))>@SharedLocalizer["Upgrade"]</button>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private List<Language> _languages;
|
||||||
|
private List<Package> _packages;
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
_languages = await LanguageService.GetLanguagesAsync(PageState.Site.SiteId);
|
||||||
|
|
||||||
|
var cultures = await LocalizationService.GetCulturesAsync();
|
||||||
|
var culture = cultures.First(c => c.Name.Equals(Constants.DefaultCulture));
|
||||||
|
|
||||||
|
// Adds English as default language
|
||||||
|
_languages.Insert(0, new Language { Name = culture.DisplayName, Code = culture.Name, IsDefault = !_languages.Any(l => l.IsDefault) });
|
||||||
|
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||||
|
{
|
||||||
|
_packages = await PackageService.GetPackagesAsync("translation");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
private async Task DeleteLanguage(Language language)
|
||||||
private List<Language> _languages;
|
{
|
||||||
private List<Package> _packages;
|
try
|
||||||
|
{
|
||||||
|
await LanguageService.DeleteLanguageAsync(language.LanguageId);
|
||||||
|
await logger.LogInformation("Language Deleted {Language}", language);
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Deleting Language {Language} {Error}", language, ex.Message);
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
AddModuleMessage(Localizer["Error.Language.Delete"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool UpgradeAvailable(string code)
|
||||||
|
{
|
||||||
|
var upgradeavailable = false;
|
||||||
|
if (_packages != null)
|
||||||
|
{
|
||||||
|
var package = _packages.Where(item => item.PackageId == (Constants.PackageId + ".Client." + code)).FirstOrDefault();
|
||||||
|
if (package != null)
|
||||||
{
|
{
|
||||||
_languages = await LanguageService.GetLanguagesAsync(PageState.Site.SiteId);
|
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(Constants.Version)) > 0);
|
||||||
|
|
||||||
var cultures = await LocalizationService.GetCulturesAsync();
|
|
||||||
var culture = cultures.First(c => c.Name.Equals(Constants.DefaultCulture));
|
|
||||||
|
|
||||||
// Adds English as default language
|
|
||||||
_languages.Insert(0, new Language { Name = culture.DisplayName, Code = culture.Name, IsDefault = !_languages.Any(l => l.IsDefault) });
|
|
||||||
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
|
||||||
{
|
|
||||||
_packages = await PackageService.GetPackagesAsync("translation");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeleteLanguage(Language language)
|
}
|
||||||
|
return upgradeavailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DownloadLanguage(string code)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||||
{
|
{
|
||||||
try
|
await PackageService.DownloadPackageAsync(Constants.PackageId + ".Client." + code, Constants.Version, "Packages");
|
||||||
{
|
await logger.LogInformation("Translation Downloaded {Code} {Version}", code, Constants.Version);
|
||||||
await LanguageService.DeleteLanguageAsync(language.LanguageId);
|
await PackageService.InstallPackagesAsync();
|
||||||
await logger.LogInformation("Language Deleted {Language}", language);
|
AddModuleMessage(string.Format(Localizer["Success.Language.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
||||||
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Deleting Language {Language} {Error}", language, ex.Message);
|
|
||||||
|
|
||||||
AddModuleMessage(Localizer["Error.Language.Delete"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool UpgradeAvailable(string code)
|
|
||||||
{
|
|
||||||
var upgradeavailable = false;
|
|
||||||
if (_packages != null)
|
|
||||||
{
|
|
||||||
var package = _packages.Where(item => item.PackageId == (Constants.PackageId + ".Client." + code)).FirstOrDefault();
|
|
||||||
if (package != null)
|
|
||||||
{
|
|
||||||
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(Constants.Version)) > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return upgradeavailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DownloadLanguage(string code)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
|
||||||
{
|
|
||||||
await PackageService.DownloadPackageAsync(Constants.PackageId + ".Client." + code, Constants.Version, "Packages");
|
|
||||||
await logger.LogInformation("Translation Downloaded {Code} {Version}", code, Constants.Version);
|
|
||||||
await PackageService.InstallPackagesAsync();
|
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Language.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Downloading Translation {Code} {Version} {Error}", code, Constants.Version, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Language.Download"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Downloading Translation {Code} {Version} {Error}", code, Constants.Version, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Language.Download"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -46,13 +46,13 @@
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
|
private bool validated = false;
|
||||||
private string _returnUrl = string.Empty;
|
private string _returnUrl = string.Empty;
|
||||||
private string _message = string.Empty;
|
private string _message = string.Empty;
|
||||||
private MessageType _type = MessageType.Info;
|
private MessageType _type = MessageType.Info;
|
||||||
private string _username = string.Empty;
|
private string _username = string.Empty;
|
||||||
private string _password = string.Empty;
|
private string _password = string.Empty;
|
||||||
private bool _remember = false;
|
private bool _remember = false;
|
||||||
private bool validated = false;
|
|
||||||
|
|
||||||
private ElementReference login;
|
private ElementReference login;
|
||||||
private ElementReference username;
|
private ElementReference username;
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
|
||||||
|
|
||||||
public override List<Resource> Resources => new List<Resource>()
|
public override List<Resource> Resources => new List<Resource>()
|
||||||
{
|
{
|
||||||
new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" }
|
new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,246 +9,246 @@
|
||||||
@inject IStringLocalizer<Detail> Localizer
|
@inject IStringLocalizer<Detail> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
|
|
||||||
<div class="col-sm-9">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
|
|
||||||
<div class="col-sm-9">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
|
|
||||||
<div class="col-sm-9">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
|
|
||||||
<div class="col-sm-9">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
|
|
||||||
<div class="col-sm-9">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
|
|
||||||
<div class="col-sm-9">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
|
|
||||||
<div class="col-sm-9">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
|
|
||||||
<div class="col-sm-9">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
|
|
||||||
<div class="col-sm-9">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
|
|
||||||
<div class="col-sm-9">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="dateTime" HelpText="The date and time of this log" ResourceKey="DateTime">Date/Time: </Label>
|
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="dateTime" class="form-control" @bind="@_logDate" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="level" HelpText="The level of this log" ResourceKey="Level">Level: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="level" class="form-control" @bind="@_level" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="feature" HelpText="The feature that was affected" ResourceKey="Feature">Feature: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="feature" class="form-control" @bind="@_feature" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="function" HelpText="The function that was performed" ResourceKey="Function">Function: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="function" class="form-control" @bind="@_function" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="category" HelpText="The categories that were affected" ResourceKey="Category">Category: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="category" class="form-control" @bind="@_category" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@if (_pageName != string.Empty)
|
|
||||||
{
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="page" HelpText="The page that was affected" ResourceKey="Page">Page: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="page" class="form-control" @bind="@_pageName" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@if (_moduleTitle != string.Empty)
|
|
||||||
{
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="module" HelpText="The module that was affected" ResourceKey="Module">Module: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="module" class="form-control" @bind="@_moduleTitle" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@if (_username != string.Empty)
|
|
||||||
{
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="user" HelpText="The user that caused this log" ResourceKey="User">User: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="user" class="form-control" @bind="@_username" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="url" HelpText="The url the log comes from" ResourceKey="Url">Url: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="url" class="form-control" @bind="@_url" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="template" HelpText="What the log is about" ResourceKey="Template">Template: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="template" class="form-control" @bind="@_template" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="message" HelpText="The message that the system generated" ResourceKey="Message">Message: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea id="message" class="form-control" @bind="@_message" rows="5" readonly></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@if (!string.IsNullOrEmpty(_exception))
|
|
||||||
{
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="exception" HelpText="The exceptions generated by the system" ResourceKey="Exception">Exception: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea id="exception" class="form-control" @bind="@_exception" rows="5" readonly></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="properties" HelpText="The properties that were affected" ResourceKey="Properties">Properties: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea id="properties" class="form-control" @bind="@_properties" rows="5" readonly></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="server" HelpText="The server that was affected" ResourceKey="Server">Server: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="server" class="form-control" @bind="@_server" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<div class="col-sm-9">
|
||||||
|
|
||||||
@code {
|
</div>
|
||||||
private int _logId;
|
</div>
|
||||||
private string _logDate = string.Empty;
|
<div class="row mb-1 align-items-center">
|
||||||
private string _level = string.Empty;
|
|
||||||
private string _feature = string.Empty;
|
|
||||||
private string _function = string.Empty;
|
|
||||||
private string _category = string.Empty;
|
|
||||||
private string _pageName = string.Empty;
|
|
||||||
private string _moduleTitle = string.Empty;
|
|
||||||
private string _username = string.Empty;
|
|
||||||
private string _url = string.Empty;
|
|
||||||
private string _template = string.Empty;
|
|
||||||
private string _message = string.Empty;
|
|
||||||
private string _exception = string.Empty;
|
|
||||||
private string _properties = string.Empty;
|
|
||||||
private string _server = string.Empty;
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
<div class="col-sm-9">
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
|
||||||
|
<div class="col-sm-9">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
|
||||||
|
<div class="col-sm-9">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
|
||||||
|
<div class="col-sm-9">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
|
||||||
|
<div class="col-sm-9">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
|
||||||
|
<div class="col-sm-9">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
|
||||||
|
<div class="col-sm-9">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
|
||||||
|
<div class="col-sm-9">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="dateTime" HelpText="The date and time of this log" ResourceKey="DateTime">Date/Time: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="dateTime" class="form-control" @bind="@_logDate" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="level" HelpText="The level of this log" ResourceKey="Level">Level: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="level" class="form-control" @bind="@_level" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="feature" HelpText="The feature that was affected" ResourceKey="Feature">Feature: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="feature" class="form-control" @bind="@_feature" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="function" HelpText="The function that was performed" ResourceKey="Function">Function: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="function" class="form-control" @bind="@_function" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="category" HelpText="The categories that were affected" ResourceKey="Category">Category: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="category" class="form-control" @bind="@_category" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (_pageName != string.Empty)
|
||||||
|
{
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="page" HelpText="The page that was affected" ResourceKey="Page">Page: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="page" class="form-control" @bind="@_pageName" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if (_moduleTitle != string.Empty)
|
||||||
|
{
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="module" HelpText="The module that was affected" ResourceKey="Module">Module: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="module" class="form-control" @bind="@_moduleTitle" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if (_username != string.Empty)
|
||||||
|
{
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="user" HelpText="The user that caused this log" ResourceKey="User">User: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="user" class="form-control" @bind="@_username" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="url" HelpText="The url the log comes from" ResourceKey="Url">Url: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="url" class="form-control" @bind="@_url" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="template" HelpText="What the log is about" ResourceKey="Template">Template: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="template" class="form-control" @bind="@_template" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="message" HelpText="The message that the system generated" ResourceKey="Message">Message: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<textarea id="message" class="form-control" @bind="@_message" rows="5" readonly></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (!string.IsNullOrEmpty(_exception))
|
||||||
|
{
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="exception" HelpText="The exceptions generated by the system" ResourceKey="Exception">Exception: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<textarea id="exception" class="form-control" @bind="@_exception" rows="5" readonly></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="properties" HelpText="The properties that were affected" ResourceKey="Properties">Properties: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<textarea id="properties" class="form-control" @bind="@_properties" rows="5" readonly></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="server" HelpText="The server that was affected" ResourceKey="Server">Server: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="server" class="form-control" @bind="@_server" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private int _logId;
|
||||||
|
private string _logDate = string.Empty;
|
||||||
|
private string _level = string.Empty;
|
||||||
|
private string _feature = string.Empty;
|
||||||
|
private string _function = string.Empty;
|
||||||
|
private string _category = string.Empty;
|
||||||
|
private string _pageName = string.Empty;
|
||||||
|
private string _moduleTitle = string.Empty;
|
||||||
|
private string _username = string.Empty;
|
||||||
|
private string _url = string.Empty;
|
||||||
|
private string _template = string.Empty;
|
||||||
|
private string _message = string.Empty;
|
||||||
|
private string _exception = string.Empty;
|
||||||
|
private string _properties = string.Empty;
|
||||||
|
private string _server = string.Empty;
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
_logId = Int32.Parse(PageState.QueryString["id"]);
|
||||||
|
var log = await LogService.GetLogAsync(_logId);
|
||||||
|
if (log != null)
|
||||||
{
|
{
|
||||||
_logId = Int32.Parse(PageState.QueryString["id"]);
|
_logDate = log.LogDate.ToString(CultureInfo.CurrentCulture);
|
||||||
var log = await LogService.GetLogAsync(_logId);
|
_level = log.Level;
|
||||||
if (log != null)
|
_feature = log.Feature;
|
||||||
|
_function = log.Function;
|
||||||
|
_category = log.Category;
|
||||||
|
|
||||||
|
if (log.PageId != null)
|
||||||
{
|
{
|
||||||
_logDate = log.LogDate.ToString(CultureInfo.CurrentCulture);
|
var page = await PageService.GetPageAsync(log.PageId.Value);
|
||||||
_level = log.Level;
|
if (page != null)
|
||||||
_feature = log.Feature;
|
|
||||||
_function = log.Function;
|
|
||||||
_category = log.Category;
|
|
||||||
|
|
||||||
if (log.PageId != null)
|
|
||||||
{
|
{
|
||||||
var page = await PageService.GetPageAsync(log.PageId.Value);
|
_pageName = page.Name;
|
||||||
if (page != null)
|
|
||||||
{
|
|
||||||
_pageName = page.Name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log.PageId != null && log.ModuleId != null)
|
|
||||||
{
|
|
||||||
var pagemodule = await PageModuleService.GetPageModuleAsync(log.PageId.Value, log.ModuleId.Value);
|
|
||||||
if (pagemodule != null)
|
|
||||||
{
|
|
||||||
_moduleTitle = pagemodule.Title;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (log.UserId != null)
|
|
||||||
{
|
|
||||||
var user = await UserService.GetUserAsync(log.UserId.Value, PageState.Site.SiteId);
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
_username = user.Username;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_url = log.Url;
|
|
||||||
_template = log.MessageTemplate;
|
|
||||||
_message = log.Message;
|
|
||||||
_exception = log.Exception;
|
|
||||||
_properties = log.Properties;
|
|
||||||
_server = log.Server;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (log.PageId != null && log.ModuleId != null)
|
||||||
|
{
|
||||||
|
var pagemodule = await PageModuleService.GetPageModuleAsync(log.PageId.Value, log.ModuleId.Value);
|
||||||
|
if (pagemodule != null)
|
||||||
|
{
|
||||||
|
_moduleTitle = pagemodule.Title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log.UserId != null)
|
||||||
|
{
|
||||||
|
var user = await UserService.GetUserAsync(log.UserId.Value, PageState.Site.SiteId);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
_username = user.Username;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_url = log.Url;
|
||||||
|
_template = log.MessageTemplate;
|
||||||
|
_message = log.Message;
|
||||||
|
_exception = log.Exception;
|
||||||
|
_properties = log.Properties;
|
||||||
|
_server = log.Server;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
await logger.LogError(ex, "Error Loading Log {LogId} {Error}", _logId, ex.Message);
|
{
|
||||||
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
await logger.LogError(ex, "Error Loading Log {LogId} {Error}", _logId, ex.Message);
|
||||||
}
|
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -10,164 +10,164 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div class="container g-0">
|
<div class="container g-0">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<Label For="level" HelpText="Select the log level for event log items" ResourceKey="Level">Level: </Label><br /><br />
|
<Label For="level" HelpText="Select the log level for event log items" ResourceKey="Level">Level: </Label><br /><br />
|
||||||
<select id="level" class="form-select" @onchange="(e => LevelChanged(e))">
|
<select id="level" class="form-select" @onchange="(e => LevelChanged(e))">
|
||||||
<option value="-"><@Localizer["AllLevels"]></option>
|
<option value="-"><@Localizer["AllLevels"]></option>
|
||||||
<option value="Trace">@Localizer["Trace"]</option>
|
<option value="Trace">@Localizer["Trace"]</option>
|
||||||
<option value="Debug">@Localizer["Debug"]</option>
|
<option value="Debug">@Localizer["Debug"]</option>
|
||||||
<option value="Information">@Localizer["Information"]</option>
|
<option value="Information">@Localizer["Information"]</option>
|
||||||
<option value="Warning">@Localizer["Warning"]</option>
|
<option value="Warning">@Localizer["Warning"]</option>
|
||||||
<option value="Error">@Localizer["Error"]</option>
|
<option value="Error">@Localizer["Error"]</option>
|
||||||
<option value="Critical">@Localizer["Critical"]</option>
|
<option value="Critical">@Localizer["Critical"]</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<Label For="function" HelpText="Select the function for event log items" ResourceKey="Function">Function: </Label><br /><br />
|
<Label For="function" HelpText="Select the function for event log items" ResourceKey="Function">Function: </Label><br /><br />
|
||||||
<select id="function" class="form-select" @onchange="(e => FunctionChanged(e))">
|
<select id="function" class="form-select" @onchange="(e => FunctionChanged(e))">
|
||||||
<option value="-"><@Localizer["AllFunctions"]></option>
|
<option value="-"><@Localizer["AllFunctions"]></option>
|
||||||
<option value="Create">@Localizer["Create"]</option>
|
<option value="Create">@Localizer["Create"]</option>
|
||||||
<option value="Read">@Localizer["Read"]</option>
|
<option value="Read">@Localizer["Read"]</option>
|
||||||
<option value="Update">@SharedLocalizer["Update"]</option>
|
<option value="Update">@SharedLocalizer["Update"]</option>
|
||||||
<option value="Delete">@SharedLocalizer["Delete"]</option>
|
<option value="Delete">@SharedLocalizer["Delete"]</option>
|
||||||
<option value="Security">@Localizer["Security"]</option>
|
<option value="Security">@Localizer["Security"]</option>
|
||||||
<option value="Other">@Localizer["Other"]</option>
|
<option value="Other">@Localizer["Other"]</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<Label For="rows" HelpText="Select the maximum number of event log items to review. Please note that if you choose more than 10 items the information will be split into pages." ResourceKey="Rows">Maximum Items: </Label><br /><br />
|
<Label For="rows" HelpText="Select the maximum number of event log items to review. Please note that if you choose more than 10 items the information will be split into pages." ResourceKey="Rows">Maximum Items: </Label><br /><br />
|
||||||
<select id="rows" class="form-select" @onchange="(e => RowsChanged(e))">
|
<select id="rows" class="form-select" @onchange="(e => RowsChanged(e))">
|
||||||
<option value="10">10</option>
|
<option value="10">10</option>
|
||||||
<option value="50">50</option>
|
<option value="50">50</option>
|
||||||
<option value="100">100</option>
|
<option value="100">100</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@if (_logs.Any())
|
@if (_logs.Any())
|
||||||
|
{
|
||||||
|
<Pager Items="@_logs">
|
||||||
|
<Header>
|
||||||
|
<th style="width: 1px;"> </th>
|
||||||
|
<th>@Localizer["Date"]</th>
|
||||||
|
<th>@Localizer["Level"]</th>
|
||||||
|
<th>@Localizer["Feature"]</th>
|
||||||
|
<th>@Localizer["Function"]</th>
|
||||||
|
</Header>
|
||||||
|
<Row>
|
||||||
|
<td class="@GetClass(context.Function)"><ActionLink Action="Detail" Parameters="@($"id=" + context.LogId.ToString())" ResourceKey="LogDetails" /></td>
|
||||||
|
<td class="@GetClass(context.Function)">@context.LogDate</td>
|
||||||
|
<td class="@GetClass(context.Function)">@context.Level</td>
|
||||||
|
<td class="@GetClass(context.Function)">@context.Feature</td>
|
||||||
|
<td class="@GetClass(context.Function)">@context.Function</td>
|
||||||
|
</Row>
|
||||||
|
</Pager>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<p><em>@Localizer["NoLogs"]</em></p>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private string _level = "-";
|
||||||
|
private string _function = "-";
|
||||||
|
private string _rows = "10";
|
||||||
|
private List<Log> _logs;
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
<Pager Items="@_logs">
|
await GetLogs();
|
||||||
<Header>
|
|
||||||
<th style="width: 1px;"> </th>
|
|
||||||
<th>@Localizer["Date"]</th>
|
|
||||||
<th>@Localizer["Level"]</th>
|
|
||||||
<th>@Localizer["Feature"]</th>
|
|
||||||
<th>@Localizer["Function"]</th>
|
|
||||||
</Header>
|
|
||||||
<Row>
|
|
||||||
<td class="@GetClass(context.Function)"><ActionLink Action="Detail" Parameters="@($"id=" + context.LogId.ToString())" ResourceKey="LogDetails" /></td>
|
|
||||||
<td class="@GetClass(context.Function)">@context.LogDate</td>
|
|
||||||
<td class="@GetClass(context.Function)">@context.Level</td>
|
|
||||||
<td class="@GetClass(context.Function)">@context.Feature</td>
|
|
||||||
<td class="@GetClass(context.Function)">@context.Function</td>
|
|
||||||
</Row>
|
|
||||||
</Pager>
|
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
<p><em>@Localizer["NoLogs"]</em></p>
|
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
private async void LevelChanged(ChangeEventArgs e)
|
||||||
private string _level = "-";
|
{
|
||||||
private string _function = "-";
|
try
|
||||||
private string _rows = "10";
|
{
|
||||||
private List<Log> _logs;
|
_level = (string)e.Value;
|
||||||
|
await GetLogs();
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
StateHasChanged();
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await GetLogs();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void LevelChanged(ChangeEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_level = (string)e.Value;
|
|
||||||
await GetLogs();
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void FunctionChanged(ChangeEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_function = (string)e.Value;
|
|
||||||
await GetLogs();
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async void RowsChanged(ChangeEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_rows = (string)e.Value;
|
|
||||||
await GetLogs();
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task GetLogs()
|
|
||||||
{
|
|
||||||
_logs = await LogService.GetLogsAsync(PageState.Site.SiteId, ((_level == "-") ? string.Empty : _level), ((_function == "-") ? string.Empty : _function), int.Parse(_rows));
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetClass(string function)
|
|
||||||
{
|
|
||||||
string classname = string.Empty;
|
|
||||||
switch (function)
|
|
||||||
{
|
|
||||||
case "Create":
|
|
||||||
classname = "table-success";
|
|
||||||
break;
|
|
||||||
case "Read":
|
|
||||||
classname = "table-primary";
|
|
||||||
break;
|
|
||||||
case "Update":
|
|
||||||
classname = "table-warning";
|
|
||||||
break;
|
|
||||||
case "Delete":
|
|
||||||
classname = "table-danger";
|
|
||||||
break;
|
|
||||||
case "Security":
|
|
||||||
classname = "table-secondary";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
classname = string.Empty;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return classname;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void FunctionChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_function = (string)e.Value;
|
||||||
|
await GetLogs();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async void RowsChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_rows = (string)e.Value;
|
||||||
|
await GetLogs();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GetLogs()
|
||||||
|
{
|
||||||
|
_logs = await LogService.GetLogsAsync(PageState.Site.SiteId, ((_level == "-") ? string.Empty : _level), ((_function == "-") ? string.Empty : _function), int.Parse(_rows));
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetClass(string function)
|
||||||
|
{
|
||||||
|
string classname = string.Empty;
|
||||||
|
switch (function)
|
||||||
|
{
|
||||||
|
case "Create":
|
||||||
|
classname = "table-success";
|
||||||
|
break;
|
||||||
|
case "Read":
|
||||||
|
classname = "table-primary";
|
||||||
|
break;
|
||||||
|
case "Update":
|
||||||
|
classname = "table-warning";
|
||||||
|
break;
|
||||||
|
case "Delete":
|
||||||
|
classname = "table-danger";
|
||||||
|
break;
|
||||||
|
case "Security":
|
||||||
|
classname = "table-secondary";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
classname = string.Empty;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return classname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -73,123 +73,123 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<button type="button" class="btn btn-success" @onclick="ActivateModule">@Localizer["Module.Activate"]</button>
|
<button type="button" class="btn btn-success" @onclick="ActivateModule">@Localizer["Module.Activate"]</button>
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private string _moduledefinitionname = string.Empty;
|
private string _moduledefinitionname = string.Empty;
|
||||||
private string _owner = string.Empty;
|
private string _owner = string.Empty;
|
||||||
private string _module = string.Empty;
|
private string _module = string.Empty;
|
||||||
private string _description = string.Empty;
|
private string _description = string.Empty;
|
||||||
private List<Template> _templates;
|
private List<Template> _templates;
|
||||||
private string _template = "-";
|
private string _template = "-";
|
||||||
private string[] _versions;
|
private string[] _versions;
|
||||||
private string _reference = Constants.Version;
|
private string _reference = Constants.Version;
|
||||||
private string _minversion = "2.0.0";
|
private string _minversion = "2.0.0";
|
||||||
private string _location = string.Empty;
|
private string _location = string.Empty;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_moduledefinitionname = SettingService.GetSetting(ModuleState.Settings, "ModuleDefinitionName", "");
|
||||||
|
_templates = await ModuleDefinitionService.GetModuleDefinitionTemplatesAsync();
|
||||||
|
_versions = Constants.ReleaseVersions.Split(',').Where(item => Version.Parse(item).CompareTo(Version.Parse("2.0.0")) >= 0).ToArray();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_moduledefinitionname))
|
||||||
{
|
{
|
||||||
try
|
AddModuleMessage(Localizer["Info.Module.Creator"], MessageType.Info);
|
||||||
{
|
|
||||||
_moduledefinitionname = SettingService.GetSetting(ModuleState.Settings, "ModuleDefinitionName", "");
|
|
||||||
_templates = await ModuleDefinitionService.GetModuleDefinitionTemplatesAsync();
|
|
||||||
_versions = Constants.ReleaseVersions.Split(',').Where(item => Version.Parse(item).CompareTo(Version.Parse("2.0.0")) >= 0).ToArray();
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(_moduledefinitionname))
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Info.Module.Creator"], MessageType.Info);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Info.Module.Activate"], MessageType.Info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Module Creator");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private async Task CreateModule()
|
|
||||||
{
|
{
|
||||||
validated = true;
|
AddModuleMessage(Localizer["Info.Module.Activate"], MessageType.Info);
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference };
|
|
||||||
moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition);
|
|
||||||
|
|
||||||
var settings = ModuleState.Settings;
|
|
||||||
SettingService.SetSetting(settings, "ModuleDefinitionName", moduleDefinition.ModuleDefinitionName);
|
|
||||||
await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId);
|
|
||||||
|
|
||||||
GetLocation();
|
|
||||||
|
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Creating Module");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ActivateModule()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(_moduledefinitionname))
|
|
||||||
{
|
|
||||||
Module module = await ModuleService.GetModuleAsync(ModuleState.ModuleId);
|
|
||||||
module.ModuleDefinitionName = _moduledefinitionname;
|
|
||||||
await ModuleService.UpdateModuleAsync(module);
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Activating Module");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsValid(string name)
|
|
||||||
{
|
|
||||||
// must contain letters, underscores and digits and first character must be letter or underscore
|
|
||||||
return !string.IsNullOrEmpty(name) && name.ToLower() != "module" && Regex.IsMatch(name, "^[A-Za-z_][A-Za-z0-9_]*$");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TemplateChanged(ChangeEventArgs e)
|
|
||||||
{
|
|
||||||
_template = (string)e.Value;
|
|
||||||
_minversion = "2.0.0";
|
|
||||||
if (_template != "-")
|
|
||||||
{
|
|
||||||
var template = _templates.FirstOrDefault(item => item.Name == _template);
|
|
||||||
_minversion = template.Version;
|
|
||||||
}
|
|
||||||
GetLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void GetLocation()
|
|
||||||
{
|
|
||||||
_location = string.Empty;
|
|
||||||
if (_owner != "" && _module != "" && _template != "-")
|
|
||||||
{
|
|
||||||
var template = _templates.FirstOrDefault(item => item.Name == _template);
|
|
||||||
_location = template.Location + _owner + "." + _module;
|
|
||||||
|
|
||||||
}
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Module Creator");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CreateModule()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference };
|
||||||
|
moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition);
|
||||||
|
|
||||||
|
var settings = ModuleState.Settings;
|
||||||
|
SettingService.SetSetting(settings, "ModuleDefinitionName", moduleDefinition.ModuleDefinitionName);
|
||||||
|
await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId);
|
||||||
|
|
||||||
|
GetLocation();
|
||||||
|
|
||||||
|
AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Creating Module");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ActivateModule()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(_moduledefinitionname))
|
||||||
|
{
|
||||||
|
Module module = await ModuleService.GetModuleAsync(ModuleState.ModuleId);
|
||||||
|
module.ModuleDefinitionName = _moduledefinitionname;
|
||||||
|
await ModuleService.UpdateModuleAsync(module);
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Activating Module");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsValid(string name)
|
||||||
|
{
|
||||||
|
// must contain letters, underscores and digits and first character must be letter or underscore
|
||||||
|
return !string.IsNullOrEmpty(name) && name.ToLower() != "module" && Regex.IsMatch(name, "^[A-Za-z_][A-Za-z0-9_]*$");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TemplateChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
_template = (string)e.Value;
|
||||||
|
_minversion = "2.0.0";
|
||||||
|
if (_template != "-")
|
||||||
|
{
|
||||||
|
var template = _templates.FirstOrDefault(item => item.Name == _template);
|
||||||
|
_minversion = template.Version;
|
||||||
|
}
|
||||||
|
GetLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetLocation()
|
||||||
|
{
|
||||||
|
_location = string.Empty;
|
||||||
|
if (_owner != "" && _module != "" && _template != "-")
|
||||||
|
{
|
||||||
|
var template = _templates.FirstOrDefault(item => item.Name == _template);
|
||||||
|
_location = template.Location + _owner + "." + _module;
|
||||||
|
|
||||||
|
}
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,152 +7,152 @@
|
||||||
@inject IStringLocalizer<Add> Localizer
|
@inject IStringLocalizer<Add> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabPanel Name="Download" ResourceKey="Download">
|
<TabPanel Name="Download" ResourceKey="Download">
|
||||||
<ModuleMessage Type="MessageType.Info" Message="Download one or more modules from the list below. Once you are ready click Install to complete the installation."></ModuleMessage>
|
<ModuleMessage Type="MessageType.Info" Message="Download one or more modules from the list below. Once you are ready click Install to complete the installation."></ModuleMessage>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-3"></div>
|
<div class="col-3"></div>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<input id="search" class="form-control" placeholder="@SharedLocalizer["Search.Hint"]" @bind="@_search" />
|
<input id="search" class="form-control" placeholder="@SharedLocalizer["Search.Hint"]" @bind="@_search" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<button type="button" class="btn btn-primary" @onclick="Search">@SharedLocalizer["Search"]</button>
|
<button type="button" class="btn btn-primary" @onclick="Search">@SharedLocalizer["Search"]</button>
|
||||||
<button type="button" class="btn btn-secondary" @onclick="Reset">@SharedLocalizer["Reset"]</button>
|
<button type="button" class="btn btn-secondary" @onclick="Reset">@SharedLocalizer["Reset"]</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-3"></div>
|
<div class="col-3"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (_packages != null)
|
||||||
|
{
|
||||||
|
if (_packages.Count > 0)
|
||||||
|
{
|
||||||
|
<Pager Items="@_packages">
|
||||||
|
<Row>
|
||||||
|
<td>
|
||||||
|
<h3 style="display: inline;"><a href="@context.ProductUrl" target="_new">@context.Name</a></h3> by: <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
||||||
|
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
||||||
|
<strong>@(String.Format("{0:n0}", context.Downloads))</strong> @SharedLocalizer["Search.Downloads"] | @SharedLocalizer["Search.Released"]: <strong>@context.ReleaseDate.ToString("MMM dd, yyyy")</strong> | @SharedLocalizer["Search.Version"]: <strong>@context.Version</strong> | @SharedLocalizer["Search.Source"]: <strong>@context.PackageUrl</strong>
|
||||||
|
</td>
|
||||||
|
<td style="vertical-align: middle;">
|
||||||
|
<button type="button" class="btn btn-primary" @onclick=@(async () => await DownloadModule(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
||||||
|
</td>
|
||||||
|
</Row>
|
||||||
|
</Pager>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<br />
|
||||||
|
<div class="mx-auto text-center">
|
||||||
|
@Localizer["Search.NoResults"]
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</TabPanel>
|
||||||
|
<TabPanel Name="Upload" ResourceKey="Upload">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" HelpText="Upload one or more module packages. Once they are uploaded click Install to complete the installation." ResourceKey="Module">Module: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<FileManager Filter="nupkg" ShowFiles="false" Folder="Packages" UploadMultiple="true" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</TabPanel>
|
||||||
|
</TabStrip>
|
||||||
|
|
||||||
@if (_packages != null)
|
<button type="button" class="btn btn-success" @onclick="InstallModules">@SharedLocalizer["Install"]</button>
|
||||||
{
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
if (_packages.Count > 0)
|
|
||||||
{
|
|
||||||
<Pager Items="@_packages">
|
|
||||||
<Row>
|
|
||||||
<td>
|
|
||||||
<h3 style="display: inline;"><a href="@context.ProductUrl" target="_new">@context.Name</a></h3> by: <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
|
||||||
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
|
||||||
<strong>@(String.Format("{0:n0}", context.Downloads))</strong> @SharedLocalizer["Search.Downloads"] | @SharedLocalizer["Search.Released"]: <strong>@context.ReleaseDate.ToString("MMM dd, yyyy")</strong> | @SharedLocalizer["Search.Version"]: <strong>@context.Version</strong> | @SharedLocalizer["Search.Source"]: <strong>@context.PackageUrl</strong>
|
|
||||||
</td>
|
|
||||||
<td style="vertical-align: middle;">
|
|
||||||
<button type="button" class="btn btn-primary" @onclick=@(async () => await DownloadModule(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
|
||||||
</td>
|
|
||||||
</Row>
|
|
||||||
</Pager>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<br />
|
|
||||||
<div class="mx-auto text-center">
|
|
||||||
@Localizer["Search.NoResults"]
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</TabPanel>
|
|
||||||
<TabPanel Name="Upload" ResourceKey="Upload">
|
|
||||||
<div class="container">
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" HelpText="Upload one or more module packages. Once they are uploaded click Install to complete the installation." ResourceKey="Module">Module: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<FileManager Filter="nupkg" ShowFiles="false" Folder="Packages" UploadMultiple="true" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</TabPanel>
|
|
||||||
</TabStrip>
|
|
||||||
|
|
||||||
<button type="button" class="btn btn-success" @onclick="InstallModules">@SharedLocalizer["Install"]</button>
|
@code {
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
private List<Package> _packages;
|
||||||
|
private string _search = "";
|
||||||
|
|
||||||
@code {
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
private List<Package> _packages;
|
|
||||||
private string _search = "";
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
try
|
||||||
{
|
{
|
||||||
|
await LoadModuleDefinitions();
|
||||||
try
|
|
||||||
{
|
|
||||||
await LoadModuleDefinitions();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Packages {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Package.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
private async Task LoadModuleDefinitions()
|
|
||||||
{
|
{
|
||||||
var moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
await logger.LogError(ex, "Error Loading Packages {Error}", ex.Message);
|
||||||
_packages = await PackageService.GetPackagesAsync("module", _search);
|
AddModuleMessage(Localizer["Error.Package.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_packages != null)
|
private async Task LoadModuleDefinitions()
|
||||||
|
{
|
||||||
|
var moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
||||||
|
_packages = await PackageService.GetPackagesAsync("module", _search);
|
||||||
|
|
||||||
|
if (_packages != null)
|
||||||
|
{
|
||||||
|
foreach (Package package in _packages.ToArray())
|
||||||
{
|
{
|
||||||
foreach (Package package in _packages.ToArray())
|
if (moduledefinitions.Exists(item => item.PackageName == package.PackageId))
|
||||||
{
|
{
|
||||||
if (moduledefinitions.Exists(item => item.PackageName == package.PackageId))
|
_packages.Remove(package);
|
||||||
{
|
|
||||||
_packages.Remove(package);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Search()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await LoadModuleDefinitions();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error On Search");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Reset()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_search = "";
|
|
||||||
await LoadModuleDefinitions();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error On Reset");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task InstallModules()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await ModuleDefinitionService.InstallModuleDefinitionsAsync();
|
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Module.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Installing Module");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DownloadModule(string packageid, string version)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
|
||||||
await logger.LogInformation("Module {ModuleDefinitionName} {Version} Downloaded Successfully", packageid, version);
|
|
||||||
AddModuleMessage(Localizer["Success.Module.Download"], MessageType.Success);
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Downloading Module {ModuleDefinitionName} {Version}", packageid, version);
|
|
||||||
AddModuleMessage(Localizer["Error.Module.Download"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task Search()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await LoadModuleDefinitions();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error On Search");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Reset()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_search = "";
|
||||||
|
await LoadModuleDefinitions();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error On Reset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InstallModules()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ModuleDefinitionService.InstallModuleDefinitionsAsync();
|
||||||
|
AddModuleMessage(string.Format(Localizer["Success.Module.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Installing Module");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DownloadModule(string packageid, string version)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
||||||
|
await logger.LogInformation("Module {ModuleDefinitionName} {Version} Downloaded Successfully", packageid, version);
|
||||||
|
AddModuleMessage(Localizer["Success.Module.Download"], MessageType.Success);
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Downloading Module {ModuleDefinitionName} {Version}", packageid, version);
|
||||||
|
AddModuleMessage(Localizer["Error.Module.Download"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -72,93 +72,93 @@
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private string _owner = string.Empty;
|
private string _owner = string.Empty;
|
||||||
private string _module = string.Empty;
|
private string _module = string.Empty;
|
||||||
private string _description = string.Empty;
|
private string _description = string.Empty;
|
||||||
private List<Template> _templates;
|
private List<Template> _templates;
|
||||||
private string _template = "-";
|
private string _template = "-";
|
||||||
private string[] _versions;
|
private string[] _versions;
|
||||||
private string _reference = Constants.Version;
|
private string _reference = Constants.Version;
|
||||||
private string _minversion = "2.0.0";
|
private string _minversion = "2.0.0";
|
||||||
private string _location = string.Empty;
|
private string _location = string.Empty;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_templates = await ModuleDefinitionService.GetModuleDefinitionTemplatesAsync();
|
||||||
|
_versions = Constants.ReleaseVersions.Split(',').Where(item => Version.Parse(item).CompareTo(Version.Parse("2.0.0")) >= 0).ToArray();
|
||||||
|
AddModuleMessage(Localizer["Info.Module.Development"], MessageType.Info);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Module Creator");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CreateModule()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
if (IsValid(_owner) && IsValid(_module) && _owner != _module && _template != "-")
|
||||||
{
|
{
|
||||||
_templates = await ModuleDefinitionService.GetModuleDefinitionTemplatesAsync();
|
var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference };
|
||||||
_versions = Constants.ReleaseVersions.Split(',').Where(item => Version.Parse(item).CompareTo(Version.Parse("2.0.0")) >= 0).ToArray();
|
moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition);
|
||||||
AddModuleMessage(Localizer["Info.Module.Development"], MessageType.Info);
|
GetLocation();
|
||||||
}
|
AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success);
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Module Creator");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task CreateModule()
|
|
||||||
{
|
|
||||||
validated = true;
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (IsValid(_owner) && IsValid(_module) && _owner != _module && _template != "-")
|
|
||||||
{
|
|
||||||
var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference };
|
|
||||||
moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition);
|
|
||||||
GetLocation();
|
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Require.ValidName"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Creating Module");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
AddModuleMessage(Localizer["Message.Require.ValidName"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
private bool IsValid(string name)
|
|
||||||
{
|
{
|
||||||
// must contain letters, underscores and digits and first character must be letter or underscore
|
await logger.LogError(ex, "Error Creating Module");
|
||||||
return !string.IsNullOrEmpty(name) && name.ToLower() != "module" && Regex.IsMatch(name, "^[A-Za-z_][A-Za-z0-9_]*$");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TemplateChanged(ChangeEventArgs e)
|
|
||||||
{
|
|
||||||
_template = (string)e.Value;
|
|
||||||
_minversion = "2.0.0";
|
|
||||||
if (_template != "-")
|
|
||||||
{
|
|
||||||
var template = _templates.FirstOrDefault(item => item.Name == _template);
|
|
||||||
_minversion = template.Version;
|
|
||||||
}
|
|
||||||
GetLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void GetLocation()
|
|
||||||
{
|
|
||||||
_location = string.Empty;
|
|
||||||
if (_owner != "" && _module != "" && _template != "-")
|
|
||||||
{
|
|
||||||
var template = _templates.FirstOrDefault(item => item.Name == _template);
|
|
||||||
_location = template.Location + _owner + "." + _module;
|
|
||||||
|
|
||||||
}
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsValid(string name)
|
||||||
|
{
|
||||||
|
// must contain letters, underscores and digits and first character must be letter or underscore
|
||||||
|
return !string.IsNullOrEmpty(name) && name.ToLower() != "module" && Regex.IsMatch(name, "^[A-Za-z_][A-Za-z0-9_]*$");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TemplateChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
_template = (string)e.Value;
|
||||||
|
_minversion = "2.0.0";
|
||||||
|
if (_template != "-")
|
||||||
|
{
|
||||||
|
var template = _templates.FirstOrDefault(item => item.Name == _template);
|
||||||
|
_minversion = template.Version;
|
||||||
|
}
|
||||||
|
GetLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetLocation()
|
||||||
|
{
|
||||||
|
_location = string.Empty;
|
||||||
|
if (_owner != "" && _module != "" && _template != "-")
|
||||||
|
{
|
||||||
|
var template = _templates.FirstOrDefault(item => item.Name == _template);
|
||||||
|
_location = template.Location + _owner + "." + _module;
|
||||||
|
|
||||||
|
}
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -74,20 +74,20 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
</Section>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel Name="Permissions" ResourceKey="Permissions">
|
<TabPanel Name="Permissions" ResourceKey="Permissions">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<PermissionGrid EntityName="@EntityNames.ModuleDefinition" PermissionNames="@PermissionNames.Utilize" Permissions="@_permissions" @ref="_permissionGrid" />
|
<PermissionGrid EntityName="@EntityNames.ModuleDefinition" PermissionNames="@PermissionNames.Utilize" Permissions="@_permissions" @ref="_permissionGrid" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</TabPanel>
|
||||||
</TabPanel>
|
</TabStrip>
|
||||||
</TabStrip>
|
<button type="button" class="btn btn-success" @onclick="SaveModuleDefinition">@SharedLocalizer["Save"]</button>
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveModuleDefinition">@SharedLocalizer["Save"]</button>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo>
|
||||||
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
|
@ -12,104 +12,104 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<ActionLink Action="Add" Text="Install Module" ResourceKey="InstallModule" />
|
<ActionLink Action="Add" Text="Install Module" ResourceKey="InstallModule" />
|
||||||
@((MarkupString)" ")
|
@((MarkupString)" ")
|
||||||
<ActionLink Action="Create" Text="Create Module" ResourceKey="CreateModule" Class="btn btn-secondary" />
|
<ActionLink Action="Create" Text="Create Module" ResourceKey="CreateModule" Class="btn btn-secondary" />
|
||||||
|
|
||||||
<Pager Items="@_moduleDefinitions">
|
<Pager Items="@_moduleDefinitions">
|
||||||
<Header>
|
<Header>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th>@SharedLocalizer["Name"]</th>
|
<th>@SharedLocalizer["Name"]</th>
|
||||||
<th>@SharedLocalizer["Version"]</th>
|
<th>@SharedLocalizer["Version"]</th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ModuleDefinitionId.ToString())" ResourceKey="EditModule" /></td>
|
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ModuleDefinitionId.ToString())" ResourceKey="EditModule" /></td>
|
||||||
<td>
|
<td>
|
||||||
@if (context.AssemblyName != "Oqtane.Client")
|
@if (context.AssemblyName != "Oqtane.Client")
|
||||||
{
|
{
|
||||||
<ActionDialog Header="Delete Module" Message="@string.Format(Localizer["Confirm.Module.Delete", context.Name])" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteModule(context))" ResourceKey="DeleteModule" />
|
<ActionDialog Header="Delete Module" Message="@string.Format(Localizer["Confirm.Module.Delete", context.Name])" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteModule(context))" ResourceKey="DeleteModule" />
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
<td>@context.Version</td>
|
<td>@context.Version</td>
|
||||||
<td>
|
<td>
|
||||||
@if (UpgradeAvailable(context.PackageName, context.Version))
|
@if (UpgradeAvailable(context.PackageName, context.Version))
|
||||||
{
|
{
|
||||||
<button type="button" class="btn btn-success" @onclick=@(async () => await DownloadModule(context.PackageName, context.Version))>@SharedLocalizer["Upgrade"]</button>
|
<button type="button" class="btn btn-success" @onclick=@(async () => await DownloadModule(context.PackageName, context.Version))>@SharedLocalizer["Upgrade"]</button>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<ModuleDefinition> _moduleDefinitions;
|
private List<ModuleDefinition> _moduleDefinitions;
|
||||||
private List<Package> _packages;
|
private List<Package> _packages;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_moduleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
||||||
|
_packages = await PackageService.GetPackagesAsync("module");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (_moduleDefinitions == null)
|
||||||
{
|
{
|
||||||
try
|
await logger.LogError(ex, "Error Loading Modules {Error}", ex.Message);
|
||||||
{
|
AddModuleMessage(Localizer["Error.Module.Load"], MessageType.Error);
|
||||||
_moduleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
|
||||||
_packages = await PackageService.GetPackagesAsync("module");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
if (_moduleDefinitions == null)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Modules {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Module.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool UpgradeAvailable(string packagename, string version)
|
|
||||||
{
|
|
||||||
var upgradeavailable = false;
|
|
||||||
if (_packages != null)
|
|
||||||
{
|
|
||||||
var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault();
|
|
||||||
if (package != null)
|
|
||||||
{
|
|
||||||
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return upgradeavailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DownloadModule(string packagename, string version)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await PackageService.DownloadPackageAsync(packagename, version, "Packages");
|
|
||||||
await logger.LogInformation("Module Downloaded {ModuleDefinitionName} {Version}", packagename, version);
|
|
||||||
await ModuleDefinitionService.InstallModuleDefinitionsAsync();
|
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Module.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Downloading Module {ModuleDefinitionName} {Version} {Error}", packagename, version, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Module.Download"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DeleteModule(ModuleDefinition moduleDefinition)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await ModuleDefinitionService.DeleteModuleDefinitionAsync(moduleDefinition.ModuleDefinitionId, moduleDefinition.SiteId);
|
|
||||||
AddModuleMessage(Localizer["Success.Module.Delete"], MessageType.Success);
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Page.Path, true));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Deleting Module {ModuleDefinition} {Error}", moduleDefinition, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Module.Delete"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool UpgradeAvailable(string packagename, string version)
|
||||||
|
{
|
||||||
|
var upgradeavailable = false;
|
||||||
|
if (_packages != null)
|
||||||
|
{
|
||||||
|
var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault();
|
||||||
|
if (package != null)
|
||||||
|
{
|
||||||
|
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return upgradeavailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DownloadModule(string packagename, string version)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await PackageService.DownloadPackageAsync(packagename, version, "Packages");
|
||||||
|
await logger.LogInformation("Module Downloaded {ModuleDefinitionName} {Version}", packagename, version);
|
||||||
|
await ModuleDefinitionService.InstallModuleDefinitionsAsync();
|
||||||
|
AddModuleMessage(string.Format(Localizer["Success.Module.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Downloading Module {ModuleDefinitionName} {Version} {Error}", packagename, version, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Module.Download"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteModule(ModuleDefinition moduleDefinition)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ModuleDefinitionService.DeleteModuleDefinitionAsync(moduleDefinition.ModuleDefinitionId, moduleDefinition.SiteId);
|
||||||
|
AddModuleMessage(Localizer["Success.Module.Delete"], MessageType.Success);
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(PageState.Page.Path, true));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Deleting Module {ModuleDefinition} {Error}", moduleDefinition, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Module.Delete"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -19,25 +19,25 @@
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private string _content = string.Empty;
|
private string _content = string.Empty;
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
public override string Title => "Export Content";
|
public override string Title => "Export Content";
|
||||||
|
|
||||||
|
|
||||||
private async Task ExportModule()
|
private async Task ExportModule()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
validated = true;
|
_content = await ModuleService.ExportModuleAsync(ModuleState.ModuleId);
|
||||||
var interop = new Interop(JSRuntime);
|
}
|
||||||
if (await interop.FormValid(form))
|
else
|
||||||
{
|
{
|
||||||
_content = await ModuleService.ExportModuleAsync(ModuleState.ModuleId);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -20,48 +20,48 @@
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _content = string.Empty;
|
private string _content = string.Empty;
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
public override string Title => "Import Content";
|
public override string Title => "Import Content";
|
||||||
|
|
||||||
private async Task ImportModule()
|
private async Task ImportModule()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
validated = true;
|
if (_content != string.Empty)
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
{
|
||||||
if (_content != string.Empty)
|
try
|
||||||
{
|
{
|
||||||
try
|
bool success = await ModuleService.ImportModuleAsync(ModuleState.ModuleId, _content);
|
||||||
|
if (success)
|
||||||
{
|
{
|
||||||
bool success = await ModuleService.ImportModuleAsync(ModuleState.ModuleId, _content);
|
AddModuleMessage(Localizer["Success.Content.Import"], MessageType.Success);
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Success.Content.Import"], MessageType.Success);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Content.ImportProblem"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Importing Module {ModuleId} {Error}", ModuleState.ModuleId, ex.Message);
|
AddModuleMessage(Localizer["Message.Content.ImportProblem"], MessageType.Warning);
|
||||||
AddModuleMessage(Localizer["Error.Module.Import"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.ImportContent"], MessageType.Warning);
|
await logger.LogError(ex, "Error Importing Module {ModuleId} {Error}", ModuleState.ModuleId, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Module.Import"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
AddModuleMessage(Localizer["Message.Required.ImportContent"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="title" HelpText="Enter the title of the module" ResourceKey="Title">Title: </Label>
|
<Label Class="col-sm-3" For="title" HelpText="Enter the title of the module" ResourceKey="Title">Title: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="title" type="text" name="Title" class="form-control" @bind="@_title" required/>
|
<input id="title" type="text" name="Title" class="form-control" @bind="@_title" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
@ -88,148 +88,148 @@
|
||||||
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
|
||||||
public override string Title => "Module Settings";
|
public override string Title => "Module Settings";
|
||||||
|
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private List<Theme> _themes;
|
private List<Theme> _themes;
|
||||||
private List<ThemeControl> _containers = new List<ThemeControl>();
|
private List<ThemeControl> _containers = new List<ThemeControl>();
|
||||||
private string _title;
|
private string _title;
|
||||||
private string _containerType;
|
private string _containerType;
|
||||||
private string _allPages = "false";
|
private string _allPages = "false";
|
||||||
private string _permissionNames = "";
|
private string _permissionNames = "";
|
||||||
private string _permissions = null;
|
private string _permissions = null;
|
||||||
private string _pageId;
|
private string _pageId;
|
||||||
private PermissionGrid _permissionGrid;
|
private PermissionGrid _permissionGrid;
|
||||||
private Type _moduleSettingsType;
|
private Type _moduleSettingsType;
|
||||||
private object _moduleSettings;
|
private object _moduleSettings;
|
||||||
private string _moduleSettingsTitle = "Module Settings";
|
private string _moduleSettingsTitle = "Module Settings";
|
||||||
private RenderFragment ModuleSettingsComponent { get; set; }
|
private RenderFragment ModuleSettingsComponent { get; set; }
|
||||||
private Type _containerSettingsType;
|
private Type _containerSettingsType;
|
||||||
private object _containerSettings;
|
private object _containerSettings;
|
||||||
private RenderFragment ContainerSettingsComponent { get; set; }
|
private RenderFragment ContainerSettingsComponent { get; set; }
|
||||||
private string createdby;
|
private string createdby;
|
||||||
private DateTime createdon;
|
private DateTime createdon;
|
||||||
private string modifiedby;
|
private string modifiedby;
|
||||||
private DateTime modifiedon;
|
private DateTime modifiedon;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
_title = ModuleState.Title;
|
||||||
|
_themes = await ThemeService.GetThemesAsync();
|
||||||
|
_containers = ThemeService.GetContainerControls(_themes, PageState.Page.ThemeType);
|
||||||
|
_containerType = ModuleState.ContainerType;
|
||||||
|
_allPages = ModuleState.AllPages.ToString();
|
||||||
|
_permissions = ModuleState.Permissions;
|
||||||
|
_permissionNames = ModuleState.ModuleDefinition.PermissionNames;
|
||||||
|
_pageId = ModuleState.PageId.ToString();
|
||||||
|
createdby = ModuleState.CreatedBy;
|
||||||
|
createdon = ModuleState.CreatedOn;
|
||||||
|
modifiedby = ModuleState.ModifiedBy;
|
||||||
|
modifiedon = ModuleState.ModifiedOn;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(ModuleState.ModuleDefinition.SettingsType))
|
||||||
{
|
{
|
||||||
_title = ModuleState.Title;
|
// module settings type explicitly declared in IModule interface
|
||||||
_themes = await ThemeService.GetThemesAsync();
|
_moduleSettingsType = Type.GetType(ModuleState.ModuleDefinition.SettingsType);
|
||||||
_containers = ThemeService.GetContainerControls(_themes, PageState.Page.ThemeType);
|
}
|
||||||
_containerType = ModuleState.ContainerType;
|
else
|
||||||
_allPages = ModuleState.AllPages.ToString();
|
{
|
||||||
_permissions = ModuleState.Permissions;
|
// legacy support - module settings type determined by convention ( ie. existence of a "Settings.razor" component in module )
|
||||||
_permissionNames = ModuleState.ModuleDefinition.PermissionNames;
|
_moduleSettingsType = Type.GetType(ModuleState.ModuleDefinition.ControlTypeTemplate.Replace(Constants.ActionToken, PageState.Action), false, true);
|
||||||
_pageId = ModuleState.PageId.ToString();
|
}
|
||||||
createdby = ModuleState.CreatedBy;
|
if (_moduleSettingsType != null)
|
||||||
createdon = ModuleState.CreatedOn;
|
{
|
||||||
modifiedby = ModuleState.ModifiedBy;
|
var moduleobject = Activator.CreateInstance(_moduleSettingsType) as IModuleControl;
|
||||||
modifiedon = ModuleState.ModifiedOn;
|
if (!string.IsNullOrEmpty(moduleobject.Title))
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(ModuleState.ModuleDefinition.SettingsType))
|
|
||||||
{
|
{
|
||||||
// module settings type explicitly declared in IModule interface
|
_moduleSettingsTitle = moduleobject.Title;
|
||||||
_moduleSettingsType = Type.GetType(ModuleState.ModuleDefinition.SettingsType);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// legacy support - module settings type determined by convention ( ie. existence of a "Settings.razor" component in module )
|
|
||||||
_moduleSettingsType = Type.GetType(ModuleState.ModuleDefinition.ControlTypeTemplate.Replace(Constants.ActionToken, PageState.Action), false, true);
|
|
||||||
}
|
|
||||||
if (_moduleSettingsType != null)
|
|
||||||
{
|
|
||||||
var moduleobject = Activator.CreateInstance(_moduleSettingsType) as IModuleControl;
|
|
||||||
if (!string.IsNullOrEmpty(moduleobject.Title))
|
|
||||||
{
|
|
||||||
_moduleSettingsTitle = moduleobject.Title;
|
|
||||||
}
|
|
||||||
|
|
||||||
ModuleSettingsComponent = builder =>
|
ModuleSettingsComponent = builder =>
|
||||||
|
{
|
||||||
|
builder.OpenComponent(0, _moduleSettingsType);
|
||||||
|
builder.AddComponentReferenceCapture(1, inst => { _moduleSettings = Convert.ChangeType(inst, _moduleSettingsType); });
|
||||||
|
builder.CloseComponent();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var theme = _themes.FirstOrDefault(item => item.Containers.Any(themecontrol => themecontrol.TypeName.Equals(_containerType)));
|
||||||
|
if (theme != null && !string.IsNullOrEmpty(theme.ContainerSettingsType))
|
||||||
|
{
|
||||||
|
_containerSettingsType = Type.GetType(theme.ContainerSettingsType);
|
||||||
|
if (_containerSettingsType != null)
|
||||||
|
{
|
||||||
|
ContainerSettingsComponent = builder =>
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, _moduleSettingsType);
|
builder.OpenComponent(0, _containerSettingsType);
|
||||||
builder.AddComponentReferenceCapture(1, inst => { _moduleSettings = Convert.ChangeType(inst, _moduleSettingsType); });
|
builder.AddComponentReferenceCapture(1, inst => { _containerSettings = Convert.ChangeType(inst, _containerSettingsType); });
|
||||||
builder.CloseComponent();
|
builder.CloseComponent();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var theme = _themes.FirstOrDefault(item => item.Containers.Any(themecontrol => themecontrol.TypeName.Equals(_containerType)));
|
|
||||||
if (theme != null && !string.IsNullOrEmpty(theme.ContainerSettingsType))
|
|
||||||
{
|
|
||||||
_containerSettingsType = Type.GetType(theme.ContainerSettingsType);
|
|
||||||
if (_containerSettingsType != null)
|
|
||||||
{
|
|
||||||
ContainerSettingsComponent = builder =>
|
|
||||||
{
|
|
||||||
builder.OpenComponent(0, _containerSettingsType);
|
|
||||||
builder.AddComponentReferenceCapture(1, inst => { _containerSettings = Convert.ChangeType(inst, _containerSettingsType); });
|
|
||||||
builder.CloseComponent();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task SaveModule()
|
private async Task SaveModule()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
validated = true;
|
if (!string.IsNullOrEmpty(_title))
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(_title))
|
var pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
|
||||||
|
pagemodule.PageId = int.Parse(_pageId);
|
||||||
|
pagemodule.Title = _title;
|
||||||
|
pagemodule.ContainerType = (_containerType != "-") ? _containerType : string.Empty;
|
||||||
|
if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Page.DefaultContainerType)
|
||||||
{
|
{
|
||||||
var pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
|
pagemodule.ContainerType = string.Empty;
|
||||||
pagemodule.PageId = int.Parse(_pageId);
|
|
||||||
pagemodule.Title = _title;
|
|
||||||
pagemodule.ContainerType = (_containerType != "-") ? _containerType : string.Empty;
|
|
||||||
if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Page.DefaultContainerType)
|
|
||||||
{
|
|
||||||
pagemodule.ContainerType = string.Empty;
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Site.DefaultContainerType)
|
|
||||||
{
|
|
||||||
pagemodule.ContainerType = string.Empty;
|
|
||||||
}
|
|
||||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
|
||||||
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
|
||||||
|
|
||||||
var module = ModuleState;
|
|
||||||
module.AllPages = bool.Parse(_allPages);
|
|
||||||
module.Permissions = _permissionGrid.GetPermissions();
|
|
||||||
await ModuleService.UpdateModuleAsync(module);
|
|
||||||
|
|
||||||
if (_moduleSettingsType != null)
|
|
||||||
{
|
|
||||||
if (_moduleSettings is ISettingsControl moduleSettingsControl)
|
|
||||||
{
|
|
||||||
// module settings updated using explicit interface
|
|
||||||
await moduleSettingsControl.UpdateSettings();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// legacy support - module settings updated by convention ( ie. by calling a public method named "UpdateSettings" in settings component )
|
|
||||||
_moduleSettings?.GetType().GetMethod("UpdateSettings")?.Invoke(_moduleSettings, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_containerSettingsType != null && _containerSettings is ISettingsControl containerSettingsControl)
|
|
||||||
{
|
|
||||||
await containerSettingsControl.UpdateSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
}
|
||||||
else
|
if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Site.DefaultContainerType)
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.Title"], MessageType.Warning);
|
pagemodule.ContainerType = string.Empty;
|
||||||
}
|
}
|
||||||
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
||||||
|
|
||||||
|
var module = ModuleState;
|
||||||
|
module.AllPages = bool.Parse(_allPages);
|
||||||
|
module.Permissions = _permissionGrid.GetPermissions();
|
||||||
|
await ModuleService.UpdateModuleAsync(module);
|
||||||
|
|
||||||
|
if (_moduleSettingsType != null)
|
||||||
|
{
|
||||||
|
if (_moduleSettings is ISettingsControl moduleSettingsControl)
|
||||||
|
{
|
||||||
|
// module settings updated using explicit interface
|
||||||
|
await moduleSettingsControl.UpdateSettings();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// legacy support - module settings updated by convention ( ie. by calling a public method named "UpdateSettings" in settings component )
|
||||||
|
_moduleSettings?.GetType().GetMethod("UpdateSettings")?.Invoke(_moduleSettings, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_containerSettingsType != null && _containerSettings is ISettingsControl containerSettingsControl)
|
||||||
|
{
|
||||||
|
await containerSettingsControl.UpdateSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
AddModuleMessage(Localizer["Message.Required.Title"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="Name" HelpText="Enter the page name" ResourceKey="Name">Name: </Label>
|
<Label Class="col-sm-3" For="Name" HelpText="Enter the page name" ResourceKey="Name">Name: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="Name" class="form-control" @bind="@_name" required/>
|
<input id="Name" class="form-control" @bind="@_name" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="Name" HelpText="Enter the page name" ResourceKey="Name">Name: </Label>
|
<Label Class="col-sm-3" For="Name" HelpText="Enter the page name" ResourceKey="Name">Name: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="Name" class="form-control" @bind="@_name" required/>
|
<input id="Name" class="form-control" @bind="@_name" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
@ -168,347 +168,347 @@
|
||||||
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private List<Theme> _themeList;
|
private List<Theme> _themeList;
|
||||||
private List<ThemeControl> _themes = new List<ThemeControl>();
|
private List<ThemeControl> _themes = new List<ThemeControl>();
|
||||||
private List<ThemeControl> _containers = new List<ThemeControl>();
|
private List<ThemeControl> _containers = new List<ThemeControl>();
|
||||||
private List<Page> _pageList;
|
private List<Page> _pageList;
|
||||||
private int _pageId;
|
private int _pageId;
|
||||||
private string _name;
|
private string _name;
|
||||||
private string _title;
|
private string _title;
|
||||||
private string _path;
|
private string _path;
|
||||||
private string _currentparentid;
|
private string _currentparentid;
|
||||||
private string _parentid;
|
private string _parentid;
|
||||||
private string _insert = "=";
|
private string _insert = "=";
|
||||||
private List<Page> _children;
|
private List<Page> _children;
|
||||||
private int _childid = -1;
|
private int _childid = -1;
|
||||||
private string _isnavigation;
|
private string _isnavigation;
|
||||||
private string _isclickable;
|
private string _isclickable;
|
||||||
private string _url;
|
private string _url;
|
||||||
private string _ispersonalizable;
|
private string _ispersonalizable;
|
||||||
private string _themetype;
|
private string _themetype;
|
||||||
private string _containertype = "-";
|
private string _containertype = "-";
|
||||||
private string _icon;
|
private string _icon;
|
||||||
private string _permissions = null;
|
private string _permissions = null;
|
||||||
private string _createdby;
|
private string _createdby;
|
||||||
private DateTime _createdon;
|
private DateTime _createdon;
|
||||||
private string _modifiedby;
|
private string _modifiedby;
|
||||||
private DateTime _modifiedon;
|
private DateTime _modifiedon;
|
||||||
private string _deletedby;
|
private string _deletedby;
|
||||||
private DateTime? _deletedon;
|
private DateTime? _deletedon;
|
||||||
private PermissionGrid _permissionGrid;
|
private PermissionGrid _permissionGrid;
|
||||||
private Type _themeSettingsType;
|
private Type _themeSettingsType;
|
||||||
private object _themeSettings;
|
private object _themeSettings;
|
||||||
private RenderFragment ThemeSettingsComponent { get; set; }
|
private RenderFragment ThemeSettingsComponent { get; set; }
|
||||||
private bool _refresh = false;
|
private bool _refresh = false;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
|
_pageList = PageState.Pages;
|
||||||
|
_children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||||
|
|
||||||
|
_themeList = await ThemeService.GetThemesAsync();
|
||||||
|
_themes = ThemeService.GetThemeControls(_themeList);
|
||||||
|
|
||||||
|
_pageId = Int32.Parse(PageState.QueryString["id"]);
|
||||||
|
var page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId);
|
||||||
|
if (page != null)
|
||||||
|
{
|
||||||
|
_name = page.Name;
|
||||||
|
_title = page.Title;
|
||||||
|
_path = page.Path;
|
||||||
|
|
||||||
|
if (_path.Contains("/"))
|
||||||
|
{
|
||||||
|
_path = _path.Substring(_path.LastIndexOf("/") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (page.ParentId == null)
|
||||||
|
{
|
||||||
|
_parentid = string.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_parentid = page.ParentId.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
_currentparentid = _parentid;
|
||||||
|
_isnavigation = page.IsNavigation.ToString();
|
||||||
|
_isclickable = page.IsClickable.ToString();
|
||||||
|
_url = page.Url;
|
||||||
|
_ispersonalizable = page.IsPersonalizable.ToString();
|
||||||
|
_themetype = page.ThemeType;
|
||||||
|
if (string.IsNullOrEmpty(_themetype))
|
||||||
|
{
|
||||||
|
_themetype = PageState.Site.DefaultThemeType;
|
||||||
|
}
|
||||||
|
_containers = ThemeService.GetContainerControls(_themeList, _themetype);
|
||||||
|
_containertype = page.DefaultContainerType;
|
||||||
|
if (string.IsNullOrEmpty(_containertype))
|
||||||
|
{
|
||||||
|
_containertype = PageState.Site.DefaultContainerType;
|
||||||
|
}
|
||||||
|
_icon = page.Icon;
|
||||||
|
_permissions = page.Permissions;
|
||||||
|
_createdby = page.CreatedBy;
|
||||||
|
_createdon = page.CreatedOn;
|
||||||
|
_modifiedby = page.ModifiedBy;
|
||||||
|
_modifiedon = page.ModifiedOn;
|
||||||
|
_deletedby = page.DeletedBy;
|
||||||
|
_deletedon = page.DeletedOn;
|
||||||
|
|
||||||
|
ThemeSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Page {PageId} {Error}", _pageId, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Page.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void ParentChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_parentid = (string)e.Value;
|
||||||
|
_children = new List<Page>();
|
||||||
|
if (_parentid == "-1")
|
||||||
|
{
|
||||||
|
foreach (Page p in PageState.Pages.Where(item => item.ParentId == null))
|
||||||
|
{
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.Permissions))
|
||||||
|
{
|
||||||
|
_children.Add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (Page p in PageState.Pages.Where(item => item.ParentId == int.Parse(_parentid)))
|
||||||
|
{
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.Permissions))
|
||||||
|
{
|
||||||
|
_children.Add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_parentid == _currentparentid)
|
||||||
|
{
|
||||||
|
_insert = "=";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_insert = ">>";
|
||||||
|
}
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Child Pages For Parent {PageId} {Error}", _parentid, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.ChildPage.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void ThemeChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_themetype = (string)e.Value;
|
||||||
|
_containers = ThemeService.GetContainerControls(_themeList, _themetype);
|
||||||
|
_containertype = "-";
|
||||||
|
ThemeSettings();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", _themetype, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Pane.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ThemeSettings()
|
||||||
|
{
|
||||||
|
_themeSettingsType = null;
|
||||||
|
var theme = _themeList.FirstOrDefault(item => item.Themes.Any(themecontrol => themecontrol.TypeName.Equals(_themetype)));
|
||||||
|
if (theme != null && !string.IsNullOrEmpty(theme.ThemeSettingsType))
|
||||||
|
{
|
||||||
|
_themeSettingsType = Type.GetType(theme.ThemeSettingsType);
|
||||||
|
if (_themeSettingsType != null)
|
||||||
|
{
|
||||||
|
ThemeSettingsComponent = builder =>
|
||||||
|
{
|
||||||
|
builder.OpenComponent(0, _themeSettingsType);
|
||||||
|
builder.AddComponentReferenceCapture(1, inst => { _themeSettings = Convert.ChangeType(inst, _themeSettingsType); });
|
||||||
|
builder.CloseComponent();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
_refresh = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SavePage()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
Page page = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_pageList = PageState.Pages;
|
if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && _containertype != "-")
|
||||||
_children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
|
||||||
|
|
||||||
_themeList = await ThemeService.GetThemesAsync();
|
|
||||||
_themes = ThemeService.GetThemeControls(_themeList);
|
|
||||||
|
|
||||||
_pageId = Int32.Parse(PageState.QueryString["id"]);
|
|
||||||
var page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId);
|
|
||||||
if (page != null)
|
|
||||||
{
|
{
|
||||||
_name = page.Name;
|
page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId);
|
||||||
_title = page.Title;
|
string currentPath = page.Path;
|
||||||
_path = page.Path;
|
|
||||||
|
|
||||||
|
page.Name = _name;
|
||||||
|
page.Title = _title;
|
||||||
|
if (_path == "" && _name.ToLower() != "home")
|
||||||
|
if (_path == string.Empty && _name.ToLower() != "home")
|
||||||
|
{
|
||||||
|
_path = _name;
|
||||||
|
}
|
||||||
if (_path.Contains("/"))
|
if (_path.Contains("/"))
|
||||||
{
|
{
|
||||||
_path = _path.Substring(_path.LastIndexOf("/") + 1);
|
_path = _path.Substring(_path.LastIndexOf("/") + 1);
|
||||||
}
|
}
|
||||||
|
if (string.IsNullOrEmpty(_parentid) || _parentid == "-1")
|
||||||
if (page.ParentId == null)
|
|
||||||
{
|
{
|
||||||
_parentid = string.Empty;
|
page.ParentId = null;
|
||||||
|
page.Path = Utilities.GetFriendlyUrl(_path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_parentid = page.ParentId.ToString();
|
page.ParentId = Int32.Parse(_parentid);
|
||||||
}
|
Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == page.ParentId);
|
||||||
|
if (parent.Path == string.Empty)
|
||||||
_currentparentid = _parentid;
|
|
||||||
_isnavigation = page.IsNavigation.ToString();
|
|
||||||
_isclickable = page.IsClickable.ToString();
|
|
||||||
_url = page.Url;
|
|
||||||
_ispersonalizable = page.IsPersonalizable.ToString();
|
|
||||||
_themetype = page.ThemeType;
|
|
||||||
if (string.IsNullOrEmpty(_themetype))
|
|
||||||
{
|
|
||||||
_themetype = PageState.Site.DefaultThemeType;
|
|
||||||
}
|
|
||||||
_containers = ThemeService.GetContainerControls(_themeList, _themetype);
|
|
||||||
_containertype = page.DefaultContainerType;
|
|
||||||
if (string.IsNullOrEmpty(_containertype))
|
|
||||||
{
|
|
||||||
_containertype = PageState.Site.DefaultContainerType;
|
|
||||||
}
|
|
||||||
_icon = page.Icon;
|
|
||||||
_permissions = page.Permissions;
|
|
||||||
_createdby = page.CreatedBy;
|
|
||||||
_createdon = page.CreatedOn;
|
|
||||||
_modifiedby = page.ModifiedBy;
|
|
||||||
_modifiedon = page.ModifiedOn;
|
|
||||||
_deletedby = page.DeletedBy;
|
|
||||||
_deletedon = page.DeletedOn;
|
|
||||||
|
|
||||||
ThemeSettings();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Page {PageId} {Error}", _pageId, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Page.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void ParentChanged(ChangeEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_parentid = (string)e.Value;
|
|
||||||
_children = new List<Page>();
|
|
||||||
if (_parentid == "-1")
|
|
||||||
{
|
|
||||||
foreach (Page p in PageState.Pages.Where(item => item.ParentId == null))
|
|
||||||
{
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.Permissions))
|
|
||||||
{
|
{
|
||||||
_children.Add(p);
|
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!PagePathIsUnique(page.Path, page.SiteId, page.PageId, _pageList))
|
||||||
|
{
|
||||||
|
AddModuleMessage(string.Format(Localizer["Mesage.Page.PathExists"], _path), MessageType.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_insert != "=")
|
||||||
|
{
|
||||||
|
Page child;
|
||||||
|
switch (_insert)
|
||||||
|
{
|
||||||
|
case "<<":
|
||||||
|
page.Order = 0;
|
||||||
|
break;
|
||||||
|
case "<":
|
||||||
|
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);
|
||||||
|
if (child != null) page.Order = child.Order + 1;
|
||||||
|
break;
|
||||||
|
case ">>":
|
||||||
|
page.Order = int.MaxValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
page.IsNavigation = (_isnavigation == null || Boolean.Parse(_isnavigation));
|
||||||
|
page.IsClickable = (_isclickable == null ? true : Boolean.Parse(_isclickable));
|
||||||
|
page.Url = _url;
|
||||||
|
page.ThemeType = (_themetype != "-") ? _themetype : string.Empty;
|
||||||
|
if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType)
|
||||||
|
{
|
||||||
|
page.ThemeType = string.Empty;
|
||||||
|
}
|
||||||
|
page.DefaultContainerType = (_containertype != "-") ? _containertype : string.Empty;
|
||||||
|
if (!string.IsNullOrEmpty(page.DefaultContainerType) && page.DefaultContainerType == PageState.Site.DefaultContainerType)
|
||||||
|
{
|
||||||
|
page.DefaultContainerType = string.Empty;
|
||||||
|
}
|
||||||
|
page.Icon = _icon ?? string.Empty;
|
||||||
|
page.Permissions = _permissionGrid.GetPermissions();
|
||||||
|
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 == string.Empty)
|
||||||
|
{
|
||||||
|
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, int.Parse(_currentparentid));
|
||||||
|
}
|
||||||
|
|
||||||
|
// update child paths
|
||||||
|
if (_parentid != _currentparentid)
|
||||||
|
{
|
||||||
|
foreach (Page p in PageState.Pages.Where(item => item.Path.StartsWith(currentPath)))
|
||||||
|
{
|
||||||
|
p.Path = p.Path.Replace(currentPath, page.Path);
|
||||||
|
await PageService.UpdatePageAsync(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_themeSettingsType != null && _themeSettings is ISettingsControl themeSettingsControl)
|
||||||
|
{
|
||||||
|
await themeSettingsControl.UpdateSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
await logger.LogInformation("Page Saved {Page}", page);
|
||||||
|
if (PageState.QueryString.ContainsKey("cp"))
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(page.Path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (Page p in PageState.Pages.Where(item => item.ParentId == int.Parse(_parentid)))
|
AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning);
|
||||||
{
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.Permissions))
|
|
||||||
{
|
|
||||||
_children.Add(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (_parentid == _currentparentid)
|
|
||||||
{
|
|
||||||
_insert = "=";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_insert = ">>";
|
|
||||||
}
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Child Pages For Parent {PageId} {Error}", _parentid, ex.Message);
|
await logger.LogError(ex, "Error Saving Page {Page} {Error}", page, ex.Message);
|
||||||
AddModuleMessage(Localizer["Error.ChildPage.Load"], MessageType.Error);
|
AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private async void ThemeChanged(ChangeEventArgs e)
|
|
||||||
{
|
{
|
||||||
try
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
{
|
|
||||||
_themetype = (string)e.Value;
|
|
||||||
_containers = ThemeService.GetContainerControls(_themeList, _themetype);
|
|
||||||
_containertype = "-";
|
|
||||||
ThemeSettings();
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", _themetype, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Pane.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ThemeSettings()
|
|
||||||
{
|
|
||||||
_themeSettingsType = null;
|
|
||||||
var theme = _themeList.FirstOrDefault(item => item.Themes.Any(themecontrol => themecontrol.TypeName.Equals(_themetype)));
|
|
||||||
if (theme != null && !string.IsNullOrEmpty(theme.ThemeSettingsType))
|
|
||||||
{
|
|
||||||
_themeSettingsType = Type.GetType(theme.ThemeSettingsType);
|
|
||||||
if (_themeSettingsType != null)
|
|
||||||
{
|
|
||||||
ThemeSettingsComponent = builder =>
|
|
||||||
{
|
|
||||||
builder.OpenComponent(0, _themeSettingsType);
|
|
||||||
builder.AddComponentReferenceCapture(1, inst => { _themeSettings = Convert.ChangeType(inst, _themeSettingsType); });
|
|
||||||
builder.CloseComponent();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
_refresh = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SavePage()
|
|
||||||
{
|
|
||||||
validated = true;
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
Page page = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && _containertype != "-")
|
|
||||||
{
|
|
||||||
page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId);
|
|
||||||
string currentPath = page.Path;
|
|
||||||
|
|
||||||
page.Name = _name;
|
|
||||||
page.Title = _title;
|
|
||||||
if (_path == "" && _name.ToLower() != "home")
|
|
||||||
if (_path == string.Empty && _name.ToLower() != "home")
|
|
||||||
{
|
|
||||||
_path = _name;
|
|
||||||
}
|
|
||||||
if (_path.Contains("/"))
|
|
||||||
{
|
|
||||||
_path = _path.Substring(_path.LastIndexOf("/") + 1);
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(_parentid) || _parentid == "-1")
|
|
||||||
{
|
|
||||||
page.ParentId = null;
|
|
||||||
page.Path = Utilities.GetFriendlyUrl(_path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
page.ParentId = Int32.Parse(_parentid);
|
|
||||||
Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == page.ParentId);
|
|
||||||
if (parent.Path == string.Empty)
|
|
||||||
{
|
|
||||||
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!PagePathIsUnique(page.Path, page.SiteId, page.PageId, _pageList))
|
|
||||||
{
|
|
||||||
AddModuleMessage(string.Format(Localizer["Mesage.Page.PathExists"], _path), MessageType.Warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_insert != "=")
|
|
||||||
{
|
|
||||||
Page child;
|
|
||||||
switch (_insert)
|
|
||||||
{
|
|
||||||
case "<<":
|
|
||||||
page.Order = 0;
|
|
||||||
break;
|
|
||||||
case "<":
|
|
||||||
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);
|
|
||||||
if (child != null) page.Order = child.Order + 1;
|
|
||||||
break;
|
|
||||||
case ">>":
|
|
||||||
page.Order = int.MaxValue;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
page.IsNavigation = (_isnavigation == null || Boolean.Parse(_isnavigation));
|
|
||||||
page.IsClickable = (_isclickable == null ? true : Boolean.Parse(_isclickable));
|
|
||||||
page.Url = _url;
|
|
||||||
page.ThemeType = (_themetype != "-") ? _themetype : string.Empty;
|
|
||||||
if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType)
|
|
||||||
{
|
|
||||||
page.ThemeType = string.Empty;
|
|
||||||
}
|
|
||||||
page.DefaultContainerType = (_containertype != "-") ? _containertype : string.Empty;
|
|
||||||
if (!string.IsNullOrEmpty(page.DefaultContainerType) && page.DefaultContainerType == PageState.Site.DefaultContainerType)
|
|
||||||
{
|
|
||||||
page.DefaultContainerType = string.Empty;
|
|
||||||
}
|
|
||||||
page.Icon = _icon ?? string.Empty;
|
|
||||||
page.Permissions = _permissionGrid.GetPermissions();
|
|
||||||
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 == string.Empty)
|
|
||||||
{
|
|
||||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, null);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, int.Parse(_currentparentid));
|
|
||||||
}
|
|
||||||
|
|
||||||
// update child paths
|
|
||||||
if (_parentid != _currentparentid)
|
|
||||||
{
|
|
||||||
foreach (Page p in PageState.Pages.Where(item => item.Path.StartsWith(currentPath)))
|
|
||||||
{
|
|
||||||
p.Path = p.Path.Replace(currentPath, page.Path);
|
|
||||||
await PageService.UpdatePageAsync(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_themeSettingsType != null && _themeSettings is ISettingsControl themeSettingsControl)
|
|
||||||
{
|
|
||||||
await themeSettingsControl.UpdateSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
await logger.LogInformation("Page Saved {Page}", page);
|
|
||||||
if (PageState.QueryString.ContainsKey("cp"))
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl(page.Path));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Saving Page {Page} {Error}", page, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Cancel()
|
|
||||||
{
|
|
||||||
if (PageState.QueryString.ContainsKey("cp"))
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool PagePathIsUnique(string pagePath, int siteId, int pageId, List<Page> existingPages)
|
|
||||||
{
|
|
||||||
return !existingPages.Any(page => page.SiteId == siteId && page.Path == pagePath && page.PageId != pageId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Cancel()
|
||||||
|
{
|
||||||
|
if (PageState.QueryString.ContainsKey("cp"))
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool PagePathIsUnique(string pagePath, int siteId, int pageId, List<Page> existingPages)
|
||||||
|
{
|
||||||
|
return !existingPages.Any(page => page.SiteId == siteId && page.Path == pagePath && page.PageId != pageId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,42 +7,42 @@
|
||||||
|
|
||||||
@if (PageState.Pages != null)
|
@if (PageState.Pages != null)
|
||||||
{
|
{
|
||||||
<ActionLink Action="Add" Text="Add Page" ResourceKey="AddPage" />
|
<ActionLink Action="Add" Text="Add Page" ResourceKey="AddPage" />
|
||||||
|
|
||||||
<Pager Items="@PageState.Pages.Where(item => !item.IsDeleted)">
|
<Pager Items="@PageState.Pages.Where(item => !item.IsDeleted)">
|
||||||
<Header>
|
<Header>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th>@SharedLocalizer["Name"]</th>
|
<th>@SharedLocalizer["Name"]</th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.PageId.ToString())" ResourceKey="EditPage" /></td>
|
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.PageId.ToString())" ResourceKey="EditPage" /></td>
|
||||||
<td><ActionDialog Header="Delete Page" Message="@string.Format(Localizer["Confirm.Page.Delete"], context.Name)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeletePage(context))" ResourceKey="DeletePage" /></td>
|
<td><ActionDialog Header="Delete Page" Message="@string.Format(Localizer["Confirm.Page.Delete"], context.Name)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeletePage(context))" ResourceKey="DeletePage" /></td>
|
||||||
<td>@(new string('-', context.Level * 2))@(context.Name)</td>
|
<td>@(new string('-', context.Level * 2))@(context.Name)</td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
|
|
||||||
private async Task DeletePage(Page page)
|
private async Task DeletePage(Page page)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
page.IsDeleted = true;
|
page.IsDeleted = true;
|
||||||
|
|
||||||
await PageService.UpdatePageAsync(page);
|
await PageService.UpdatePageAsync(page);
|
||||||
await logger.LogInformation("Page Deleted {Page}", page);
|
await logger.LogInformation("Page Deleted {Page}", page);
|
||||||
NavigationManager.NavigateTo(NavigateUrl("admin/pages"));
|
NavigationManager.NavigateTo(NavigateUrl("admin/pages"));
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Deleting Page {Page} {Error}", page, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Page.Delete"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Deleting Page {Page} {Error}", page, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Page.Delete"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="name" HelpText="The name of this profile item" ResourceKey="Name">Name: </Label>
|
<Label Class="col-sm-3" For="name" HelpText="The name of this profile item" ResourceKey="Name">Name: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="name" class="form-control" @bind="@_name" required/>
|
<input id="name" class="form-control" @bind="@_name" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="title" HelpText="The title of the profile item to display to the user" ResourceKey="Title">Title: </Label>
|
<Label Class="col-sm-3" For="title" HelpText="The title of the profile item to display to the user" ResourceKey="Title">Title: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="title" class="form-control" @bind="@_title" required/>
|
<input id="title" class="form-control" @bind="@_title" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
@ -28,31 +28,31 @@
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="category" HelpText="The category of this profile item (for grouping)" ResourceKey="Category">Category: </Label>
|
<Label Class="col-sm-3" For="category" HelpText="The category of this profile item (for grouping)" ResourceKey="Category">Category: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="category" class="form-control" @bind="@_category" required/>
|
<input id="category" class="form-control" @bind="@_category" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="order" HelpText="The index order of where this profile item should be displayed" ResourceKey="Order">Order: </Label>
|
<Label Class="col-sm-3" For="order" HelpText="The index order of where this profile item should be displayed" ResourceKey="Order">Order: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="order" class="form-control" @bind="@_vieworder" required/>
|
<input id="order" class="form-control" @bind="@_vieworder" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="length" HelpText="The max number of characters this profile item should accept (enter zero for unlimited)" ResourceKey="Length">Length: </Label>
|
<Label Class="col-sm-3" For="length" HelpText="The max number of characters this profile item should accept (enter zero for unlimited)" ResourceKey="Length">Length: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="length" class="form-control" @bind="@_maxlength" required/>
|
<input id="length" class="form-control" @bind="@_maxlength" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="defaultVal" HelpText="The default value for this profile item" ResourceKey="DefaultValue">Default Value: </Label>
|
<Label Class="col-sm-3" For="defaultVal" HelpText="The default value for this profile item" ResourceKey="DefaultValue">Default Value: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="defaultVal" class="form-control" @bind="@_defaultvalue" required/>
|
<input id="defaultVal" class="form-control" @bind="@_defaultvalue" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="options" HelpText="A comma delimited list of options the user can select from" ResourceKey="Options">Options: </Label>
|
<Label Class="col-sm-3" For="options" HelpText="A comma delimited list of options the user can select from" ResourceKey="Options">Options: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="options" class="form-control" @bind="@_options" required/>
|
<input id="options" class="form-control" @bind="@_options" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
@ -85,113 +85,113 @@
|
||||||
}
|
}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private int _profileid = -1;
|
private int _profileid = -1;
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private string _name = string.Empty;
|
private string _name = string.Empty;
|
||||||
private string _title = string.Empty;
|
private string _title = string.Empty;
|
||||||
private string _description = string.Empty;
|
private string _description = string.Empty;
|
||||||
private string _category = string.Empty;
|
private string _category = string.Empty;
|
||||||
private string _vieworder = "0";
|
private string _vieworder = "0";
|
||||||
private string _maxlength = "0";
|
private string _maxlength = "0";
|
||||||
private string _defaultvalue = string.Empty;
|
private string _defaultvalue = string.Empty;
|
||||||
private string _options = string.Empty;
|
private string _options = string.Empty;
|
||||||
private string _isrequired = "False";
|
private string _isrequired = "False";
|
||||||
private string _isprivate = "False";
|
private string _isprivate = "False";
|
||||||
private string createdby;
|
private string createdby;
|
||||||
private DateTime createdon;
|
private DateTime createdon;
|
||||||
private string modifiedby;
|
private string modifiedby;
|
||||||
private DateTime modifiedon;
|
private DateTime modifiedon;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
public override string Actions => "Add,Edit";
|
public override string Actions => "Add,Edit";
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (PageState.QueryString.ContainsKey("id"))
|
||||||
|
{
|
||||||
|
_profileid = Int32.Parse(PageState.QueryString["id"]);
|
||||||
|
var 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;
|
||||||
|
_options = profile.Options;
|
||||||
|
_isrequired = profile.IsRequired.ToString();
|
||||||
|
_isprivate = profile.IsPrivate.ToString();
|
||||||
|
createdby = profile.CreatedBy;
|
||||||
|
createdon = profile.CreatedOn;
|
||||||
|
modifiedby = profile.ModifiedBy;
|
||||||
|
modifiedon = profile.ModifiedOn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Profile {ProfileId} {Error}", _profileid, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Profile.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveProfile()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (PageState.QueryString.ContainsKey("id"))
|
Profile profile;
|
||||||
|
if (_profileid != -1)
|
||||||
{
|
{
|
||||||
_profileid = Int32.Parse(PageState.QueryString["id"]);
|
profile = await ProfileService.GetProfileAsync(_profileid);
|
||||||
var 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;
|
|
||||||
_options = profile.Options;
|
|
||||||
_isrequired = profile.IsRequired.ToString();
|
|
||||||
_isprivate = profile.IsPrivate.ToString();
|
|
||||||
createdby = profile.CreatedBy;
|
|
||||||
createdon = profile.CreatedOn;
|
|
||||||
modifiedby = profile.ModifiedBy;
|
|
||||||
modifiedon = profile.ModifiedOn;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
profile = new Profile();
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.SiteId = PageState.Site.SiteId;
|
||||||
|
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.Options = _options;
|
||||||
|
profile.IsRequired = (_isrequired == null ? false : Boolean.Parse(_isrequired));
|
||||||
|
profile.IsPrivate = (_isprivate == null ? false : Boolean.Parse(_isprivate));
|
||||||
|
if (_profileid != -1)
|
||||||
|
{
|
||||||
|
profile = await ProfileService.UpdateProfileAsync(profile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
profile = await ProfileService.AddProfileAsync(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
await logger.LogInformation("Profile Saved {Profile}", profile);
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Profile {ProfileId} {Error}", _profileid, ex.Message);
|
await logger.LogError(ex, "Error Saving Profile {ProfleId} {Error}", _profileid, ex.Message);
|
||||||
AddModuleMessage(Localizer["Error.Profile.Load"], MessageType.Error);
|
AddModuleMessage(Localizer["Error.Profile.Save"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private async Task SaveProfile()
|
|
||||||
{
|
{
|
||||||
validated = true;
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Profile profile;
|
|
||||||
if (_profileid != -1)
|
|
||||||
{
|
|
||||||
profile = await ProfileService.GetProfileAsync(_profileid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
profile = new Profile();
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.SiteId = PageState.Site.SiteId;
|
|
||||||
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.Options = _options;
|
|
||||||
profile.IsRequired = (_isrequired == null ? false : Boolean.Parse(_isrequired));
|
|
||||||
profile.IsPrivate = (_isprivate == null ? false : Boolean.Parse(_isprivate));
|
|
||||||
if (_profileid != -1)
|
|
||||||
{
|
|
||||||
profile = await ProfileService.UpdateProfileAsync(profile);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
profile = await ProfileService.AddProfileAsync(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);
|
|
||||||
AddModuleMessage(Localizer["Error.Profile.Save"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -10,56 +10,56 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<ActionLink Action="Add" Security="SecurityAccessLevel.Admin" Text="Add Profile" ResourceKey="AddProfile" />
|
<ActionLink Action="Add" Security="SecurityAccessLevel.Admin" Text="Add Profile" ResourceKey="AddProfile" />
|
||||||
|
|
||||||
<Pager Items="@_profiles">
|
<Pager Items="@_profiles">
|
||||||
<Header>
|
<Header>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th>@SharedLocalizer["Name"]</th>
|
<th>@SharedLocalizer["Name"]</th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ProfileId.ToString())" ResourceKey="EditProfile" /></td>
|
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ProfileId.ToString())" ResourceKey="EditProfile" /></td>
|
||||||
<td><ActionDialog Header="Delete Profile" Message="@string.Format(Localizer["Confirm.Profile.Delete"], context.Name)" Action="Delete" Class="btn btn-danger" OnClick="@(async () => await DeleteProfile(context.ProfileId))" ResourceKey="DeleteProfile" /></td>
|
<td><ActionDialog Header="Delete Profile" Message="@string.Format(Localizer["Confirm.Profile.Delete"], context.Name)" Action="Delete" Class="btn btn-danger" OnClick="@(async () => await DeleteProfile(context.ProfileId))" ResourceKey="DeleteProfile" /></td>
|
||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<Profile> _profiles;
|
private List<Profile> _profiles;
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
await GetProfilesAsync();
|
await GetProfilesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeleteProfile(int profileId)
|
private async Task DeleteProfile(int profileId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await ProfileService.DeleteProfileAsync(profileId);
|
await ProfileService.DeleteProfileAsync(profileId);
|
||||||
await logger.LogInformation("Profile Deleted {ProfileId}", profileId);
|
await logger.LogInformation("Profile Deleted {ProfileId}", profileId);
|
||||||
|
|
||||||
AddModuleMessage(Localizer["Success.Profile.Delete"], MessageType.Success);
|
AddModuleMessage(Localizer["Success.Profile.Delete"], MessageType.Success);
|
||||||
|
|
||||||
await GetProfilesAsync();
|
await GetProfilesAsync();
|
||||||
|
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Deleting Profile {ProfileId} {Error}", profileId, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Profile.Delete"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task GetProfilesAsync()
|
|
||||||
{
|
|
||||||
_profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Deleting Profile {ProfileId} {Error}", profileId, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Profile.Delete"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GetProfilesAsync()
|
||||||
|
{
|
||||||
|
_profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,182 +7,208 @@
|
||||||
@inject IStringLocalizer<Index> Localizer
|
@inject IStringLocalizer<Index> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabPanel Name="Pages" ResourceKey="Pages">
|
<TabPanel Name="Pages" ResourceKey="Pages">
|
||||||
@if (_pages == null)
|
@if (_pages == null)
|
||||||
{
|
|
||||||
<br />
|
|
||||||
<p>@Localizer["NoPage.Deleted"]</p>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<Pager Items="@_pages">
|
|
||||||
<Header>
|
|
||||||
<th style="width: 1px;"> </th>
|
|
||||||
<th style="width: 1px;"> </th>
|
|
||||||
<th>@SharedLocalizer["Name"]</th>
|
|
||||||
<th>@Localizer["DeletedBy"]</th>
|
|
||||||
<th>@Localizer["DeletedOn"]</th>
|
|
||||||
</Header>
|
|
||||||
<Row>
|
|
||||||
<td><button @onclick="@(() => RestorePage(context))" class="btn btn-info" title="Restore">Restore</button></td>
|
|
||||||
<td><ActionDialog Header="Delete Page" Message="@string.Format(Localizer["Confirm.Page.Delete"], context.Name)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeletePage(context))" ResourceKey="DeletePage" /></td>
|
|
||||||
<td>@context.Name</td>
|
|
||||||
<td>@context.DeletedBy</td>
|
|
||||||
<td>@context.DeletedOn</td>
|
|
||||||
</Row>
|
|
||||||
</Pager>
|
|
||||||
@if (_pages.Any())
|
|
||||||
{
|
|
||||||
<div style="text-align:right;">
|
|
||||||
<ActionDialog Header="Delete All Pages" Message="Are You Sure You Wish To Permanently Delete All Pages?" Action="Delete All Pages" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteAllPages())" ResourceKey="DeleteAllPages" />
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</TabPanel>
|
|
||||||
<TabPanel Name="Modules" ResourceKey="Modules">
|
|
||||||
@if (_modules == null)
|
|
||||||
{
|
|
||||||
<br />
|
|
||||||
<p>@Localizer["NoModule.Deleted"]</p>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<Pager Items="@_modules">
|
|
||||||
<Header>
|
|
||||||
<th style="width: 1px;"> </th>
|
|
||||||
<th style="width: 1px;"> </th>
|
|
||||||
<th>@Localizer["Page"]</th>
|
|
||||||
<th>@Localizer["Module"]</th>
|
|
||||||
<th>@Localizer["DeletedBy"]</th>
|
|
||||||
<th>@Localizer["DeletedOn"]</th>
|
|
||||||
</Header>
|
|
||||||
<Row>
|
|
||||||
<td><button @onclick="@(() => RestoreModule(context))" class="btn btn-info" title="Restore">@Localizer["Restore"]</button></td>
|
|
||||||
<td><ActionDialog Header="Delete Module" Message="@string.Format(Localizer["Confirm.Module.Delete"], context.Title)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteModule(context))" ResourceKey="DeleteModule" /></td>
|
|
||||||
<td>@PageState.Pages.Find(item => item.PageId == context.PageId).Name</td>
|
|
||||||
<td>@context.Title</td>
|
|
||||||
<td>@context.DeletedBy</td>
|
|
||||||
<td>@context.DeletedOn</td>
|
|
||||||
</Row>
|
|
||||||
</Pager>
|
|
||||||
@if (_modules.Any())
|
|
||||||
{
|
|
||||||
<div style="text-align:right;">
|
|
||||||
<ActionDialog Header="Delete All Modules" Message="Are You Sure You Wish To Permanently Delete All Modules?" Action="Delete All Modules" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteAllModules())" ResourceKey="DeleteAllModules" />
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
</TabPanel>
|
|
||||||
</TabStrip>
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private List<Page> _pages;
|
|
||||||
private List<Module> _modules;
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
{
|
||||||
try
|
<br />
|
||||||
|
<p>@Localizer["NoPage.Deleted"]</p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<Pager Items="@_pages">
|
||||||
|
<Header>
|
||||||
|
<th style="width: 1px;"> </th>
|
||||||
|
<th style="width: 1px;"> </th>
|
||||||
|
<th>@SharedLocalizer["Name"]</th>
|
||||||
|
<th>@Localizer["DeletedBy"]</th>
|
||||||
|
<th>@Localizer["DeletedOn"]</th>
|
||||||
|
</Header>
|
||||||
|
<Row>
|
||||||
|
<td><button @onclick="@(() => RestorePage(context))" class="btn btn-info" title="Restore">Restore</button></td>
|
||||||
|
<td><ActionDialog Header="Delete Page" Message="@string.Format(Localizer["Confirm.Page.Delete"], context.Name)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeletePage(context))" ResourceKey="DeletePage" /></td>
|
||||||
|
<td>@context.Name</td>
|
||||||
|
<td>@context.DeletedBy</td>
|
||||||
|
<td>@context.DeletedOn</td>
|
||||||
|
</Row>
|
||||||
|
</Pager>
|
||||||
|
@if (_pages.Any())
|
||||||
{
|
{
|
||||||
await Load();
|
<div style="text-align:right;">
|
||||||
}
|
<ActionDialog Header="Delete All Pages" Message="Are You Sure You Wish To Permanently Delete All Pages?" Action="Delete All Pages" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteAllPages())" ResourceKey="DeleteAllPages" />
|
||||||
catch (Exception ex)
|
</div>
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Deleted Pages Or Modules {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.DeletedModulePage.Load"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
</TabPanel>
|
||||||
private async Task Load()
|
<TabPanel Name="Modules" ResourceKey="Modules">
|
||||||
|
@if (_modules == null)
|
||||||
{
|
{
|
||||||
_pages = await PageService.GetPagesAsync(PageState.Site.SiteId);
|
<br />
|
||||||
_pages = _pages.Where(item => item.IsDeleted).ToList();
|
<p>@Localizer["NoModule.Deleted"]</p>
|
||||||
|
|
||||||
_modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
|
|
||||||
_modules = _modules.Where(item => item.IsDeleted).ToList();
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private async Task RestorePage(Page page)
|
|
||||||
{
|
{
|
||||||
try
|
<Pager Items="@_modules">
|
||||||
|
<Header>
|
||||||
|
<th style="width: 1px;"> </th>
|
||||||
|
<th style="width: 1px;"> </th>
|
||||||
|
<th>@Localizer["Page"]</th>
|
||||||
|
<th>@Localizer["Module"]</th>
|
||||||
|
<th>@Localizer["DeletedBy"]</th>
|
||||||
|
<th>@Localizer["DeletedOn"]</th>
|
||||||
|
</Header>
|
||||||
|
<Row>
|
||||||
|
<td><button @onclick="@(() => RestoreModule(context))" class="btn btn-info" title="Restore">@Localizer["Restore"]</button></td>
|
||||||
|
<td><ActionDialog Header="Delete Module" Message="@string.Format(Localizer["Confirm.Module.Delete"], context.Title)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteModule(context))" ResourceKey="DeleteModule" /></td>
|
||||||
|
<td>@PageState.Pages.Find(item => item.PageId == context.PageId).Name</td>
|
||||||
|
<td>@context.Title</td>
|
||||||
|
<td>@context.DeletedBy</td>
|
||||||
|
<td>@context.DeletedOn</td>
|
||||||
|
</Row>
|
||||||
|
</Pager>
|
||||||
|
@if (_modules.Any())
|
||||||
{
|
{
|
||||||
page.IsDeleted = false;
|
<div style="text-align:right;">
|
||||||
await PageService.UpdatePageAsync(page);
|
<ActionDialog Header="Delete All Modules" Message="Are You Sure You Wish To Permanently Delete All Modules?" Action="Delete All Modules" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteAllModules())" ResourceKey="DeleteAllModules" />
|
||||||
await logger.LogInformation("Page Restored {Page}", page);
|
</div>
|
||||||
await Load();
|
|
||||||
StateHasChanged();
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Restoring Deleted Page {Page} {Error}", page, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Page.Restore"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
</TabPanel>
|
||||||
|
</TabStrip>
|
||||||
|
|
||||||
private async Task DeletePage(Page page)
|
@code {
|
||||||
|
private List<Page> _pages;
|
||||||
|
private List<Module> _modules;
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
await Load();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Deleted Pages Or Modules {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.DeletedModulePage.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Load()
|
||||||
|
{
|
||||||
|
_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();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RestorePage(Page page)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
AddModuleMessage(Localizer["Error.Page.Restore"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeletePage(Page page)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
AddModuleMessage(ex.Message, MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteAllPages()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (Page page in _pages)
|
||||||
{
|
{
|
||||||
await PageService.DeletePageAsync(page.PageId);
|
await PageService.DeletePageAsync(page.PageId);
|
||||||
await logger.LogInformation("Page Permanently Deleted {Page}", page);
|
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);
|
|
||||||
AddModuleMessage(ex.Message, MessageType.Error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await logger.LogInformation("Pages Permanently Deleted");
|
||||||
|
await Load();
|
||||||
|
StateHasChanged();
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
private async Task DeleteAllPages()
|
|
||||||
{
|
{
|
||||||
try
|
await logger.LogError(ex, "Error Permanently Deleting Pages {Error}", ex.Message);
|
||||||
{
|
AddModuleMessage(ex.Message, MessageType.Error);
|
||||||
foreach (Page page in _pages)
|
|
||||||
{
|
|
||||||
await PageService.DeletePageAsync(page.PageId);
|
|
||||||
await logger.LogInformation("Page Permanently Deleted {Page}", page);
|
|
||||||
}
|
|
||||||
|
|
||||||
await logger.LogInformation("Pages Permanently Deleted");
|
|
||||||
await Load();
|
|
||||||
StateHasChanged();
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Permanently Deleting Pages {Error}", ex.Message);
|
|
||||||
AddModuleMessage(ex.Message, MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task RestoreModule(Module module)
|
private async Task RestoreModule(Module module)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
var pagemodule = await PageModuleService.GetPageModuleAsync(module.PageModuleId);
|
||||||
{
|
pagemodule.IsDeleted = false;
|
||||||
var pagemodule = await PageModuleService.GetPageModuleAsync(module.PageModuleId);
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
pagemodule.IsDeleted = false;
|
await logger.LogInformation("Module Restored {Module}", module);
|
||||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
await Load();
|
||||||
await logger.LogInformation("Module Restored {Module}", module);
|
StateHasChanged();
|
||||||
await Load();
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Restoring Deleted Module {Module} {Error}", module, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Module.Restore"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
private async Task DeleteModule(Module module)
|
|
||||||
{
|
{
|
||||||
try
|
await logger.LogError(ex, "Error Restoring Deleted Module {Module} {Error}", module, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Module.Restore"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteModule(Module module)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
await ModuleService.DeleteModuleAsync(module.ModuleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
AddModuleMessage(Localizer["Error.Module.Delete"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteAllModules()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (Module module in _modules)
|
||||||
{
|
{
|
||||||
await PageModuleService.DeletePageModuleAsync(module.PageModuleId);
|
await PageModuleService.DeletePageModuleAsync(module.PageModuleId);
|
||||||
// check if there are any remaining module instances in the site
|
// check if there are any remaining module instances in the site
|
||||||
|
@ -192,42 +218,16 @@
|
||||||
{
|
{
|
||||||
await ModuleService.DeleteModuleAsync(module.ModuleId);
|
await ModuleService.DeleteModuleAsync(module.ModuleId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await logger.LogInformation("Module Permanently Deleted {Module}", module);
|
await logger.LogInformation("Modules Permanently Deleted");
|
||||||
await Load();
|
await Load();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Permanently Deleting Module {Module} {Error}", module, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Module.Delete"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
private async Task DeleteAllModules()
|
|
||||||
{
|
{
|
||||||
try
|
await logger.LogError(ex, "Error Permanently Deleting Modules {Error}", ex.Message);
|
||||||
{
|
AddModuleMessage(Localizer["Error.Modules.Delete"], MessageType.Error);
|
||||||
foreach (Module module in _modules)
|
|
||||||
{
|
|
||||||
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))
|
|
||||||
{
|
|
||||||
await ModuleService.DeleteModuleAsync(module.ModuleId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await logger.LogInformation("Modules Permanently Deleted");
|
|
||||||
await Load();
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Permanently Deleting Modules {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Modules.Delete"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -21,31 +21,31 @@
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="username" HelpText="Your username. Note that this field can not be modified once it is saved." ResourceKey="Username"></Label>
|
<Label Class="col-sm-3" For="username" HelpText="Your username. Note that this field can not be modified once it is saved." ResourceKey="Username"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="username" class="form-control" @bind="@_username" required/>
|
<input id="username" class="form-control" @bind="@_username" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="password" HelpText="If you wish to change your password you can enter it here. Please choose a sufficiently secure password." ResourceKey="Password"></Label>
|
<Label Class="col-sm-3" For="password" HelpText="If you wish to change your password you can enter it here. Please choose a sufficiently secure password." ResourceKey="Password"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="password" type="password" class="form-control" @bind="@_password" autocomplete="new-password" required/>
|
<input id="password" type="password" class="form-control" @bind="@_password" autocomplete="new-password" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="confirm" HelpText="If you are changing your password you must enter it again to confirm it matches" ResourceKey="Confirm"></Label>
|
<Label Class="col-sm-3" For="confirm" HelpText="If you are changing your password you must enter it again to confirm it matches" ResourceKey="Confirm"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="confirm" type="password" class="form-control" @bind="@_confirm" autocomplete="new-password" required/>
|
<input id="confirm" type="password" class="form-control" @bind="@_confirm" autocomplete="new-password" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="email" HelpText="Your email address where you wish to receive notifications" ResourceKey="Email"></Label>
|
<Label Class="col-sm-3" For="email" HelpText="Your email address where you wish to receive notifications" ResourceKey="Email"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="email" class="form-control" @bind="@_email" required/>
|
<input id="email" class="form-control" @bind="@_email" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="displayname" HelpText="Your full name" ResourceKey="DisplayName"></Label>
|
<Label Class="col-sm-3" For="displayname" HelpText="Your full name" ResourceKey="DisplayName"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="displayname" class="form-control" @bind="@_displayname" required/>
|
<input id="displayname" class="form-control" @bind="@_displayname" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -55,82 +55,82 @@
|
||||||
</NotAuthorized>
|
</NotAuthorized>
|
||||||
</AuthorizeView>
|
</AuthorizeView>
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<ModuleMessage Message="@Localizer["Info.Registration.Disabled"]" Type="MessageType.Info" />
|
<ModuleMessage Message="@Localizer["Info.Registration.Disabled"]" Type="MessageType.Info" />
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _username = string.Empty;
|
private string _username = string.Empty;
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private string _password = string.Empty;
|
private string _password = string.Empty;
|
||||||
private string _confirm = string.Empty;
|
private string _confirm = string.Empty;
|
||||||
private string _email = string.Empty;
|
private string _email = string.Empty;
|
||||||
private string _displayname = string.Empty;
|
private string _displayname = string.Empty;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
|
||||||
|
|
||||||
private async Task Register()
|
private async Task Register()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
validated = true;
|
bool _isEmailValid = Utilities.IsValidEmail(_email);
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
if (_username != "" && _password != "" && _confirm != "" && _isEmailValid)
|
||||||
{
|
{
|
||||||
try
|
if (_password == _confirm)
|
||||||
{
|
{
|
||||||
bool _isEmailValid = Utilities.IsValidEmail(_email);
|
var user = new User
|
||||||
|
|
||||||
if (_username != "" && _password != "" && _confirm != "" && _isEmailValid)
|
|
||||||
{
|
{
|
||||||
if (_password == _confirm)
|
SiteId = PageState.Site.SiteId,
|
||||||
{
|
Username = _username,
|
||||||
var user = new User
|
DisplayName = (_displayname == string.Empty ? _username : _displayname),
|
||||||
{
|
Email = _email,
|
||||||
SiteId = PageState.Site.SiteId,
|
Password = _password
|
||||||
Username = _username,
|
};
|
||||||
DisplayName = (_displayname == string.Empty ? _username : _displayname),
|
user = await UserService.AddUserAsync(user);
|
||||||
Email = _email,
|
|
||||||
Password = _password
|
|
||||||
};
|
|
||||||
user = await UserService.AddUserAsync(user);
|
|
||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
await logger.LogInformation("User Created {Username} {Email}", _username, _email);
|
await logger.LogInformation("User Created {Username} {Email}", _username, _email);
|
||||||
AddModuleMessage(Localizer["Info.User.AccountCreate"], MessageType.Info);
|
AddModuleMessage(Localizer["Info.User.AccountCreate"], MessageType.Info);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await logger.LogError("Error Adding User {Username} {Email}", _username, _email);
|
|
||||||
AddModuleMessage(Localizer["Error.User.AddInfo"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning);
|
await logger.LogError("Error Adding User {Username} {Email}", _username, _email);
|
||||||
|
AddModuleMessage(Localizer["Error.User.AddInfo"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", _username, _email, ex.Message);
|
AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning);
|
||||||
AddModuleMessage(Localizer["Error.User.Add"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
private void Cancel()
|
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", _username, _email, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.User.Add"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Cancel()
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="Username" class="control-label">@SharedLocalizer["Username"] </label>
|
<label for="Username" class="control-label">@SharedLocalizer["Username"] </label>
|
||||||
<input type="text" class="form-control" placeholder="Username" @bind="@_username" readonly id="Username"/>
|
<input type="text" class="form-control" placeholder="Username" @bind="@_username" readonly id="Username" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="Password" class="control-label">@SharedLocalizer["Password"] </label>
|
<label for="Password" class="control-label">@SharedLocalizer["Password"] </label>
|
||||||
|
@ -24,82 +24,82 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private string _username = string.Empty;
|
private string _username = string.Empty;
|
||||||
private string _password = string.Empty;
|
private string _password = string.Empty;
|
||||||
private string _confirm = string.Empty;
|
private string _confirm = string.Empty;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
if (PageState.QueryString.ContainsKey("name") && PageState.QueryString.ContainsKey("token"))
|
||||||
{
|
{
|
||||||
if (PageState.QueryString.ContainsKey("name") && PageState.QueryString.ContainsKey("token"))
|
_username = PageState.QueryString["name"];
|
||||||
{
|
|
||||||
_username = PageState.QueryString["name"];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private async Task Reset()
|
|
||||||
{
|
|
||||||
validated = true;
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_username != string.Empty && _password != string.Empty && _confirm != string.Empty)
|
|
||||||
{
|
|
||||||
if (_password == _confirm)
|
|
||||||
{
|
|
||||||
var user = new User
|
|
||||||
{
|
|
||||||
SiteId = PageState.Site.SiteId,
|
|
||||||
Username = _username,
|
|
||||||
Password = _password
|
|
||||||
};
|
|
||||||
user = await UserService.ResetPasswordAsync(user, PageState.QueryString["token"]);
|
|
||||||
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
await logger.LogInformation("User Password Reset {Username}", _username);
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl("login"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await logger.LogError("Error Resetting User Password {Username}", _username);
|
|
||||||
AddModuleMessage(Localizer["Error.Password.ResetInfo"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Resetting User Password {Username} {Error}", _username, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Password.Reset"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Cancel()
|
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task Reset()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_username != string.Empty && _password != string.Empty && _confirm != string.Empty)
|
||||||
|
{
|
||||||
|
if (_password == _confirm)
|
||||||
|
{
|
||||||
|
var user = new User
|
||||||
|
{
|
||||||
|
SiteId = PageState.Site.SiteId,
|
||||||
|
Username = _username,
|
||||||
|
Password = _password
|
||||||
|
};
|
||||||
|
user = await UserService.ResetPasswordAsync(user, PageState.QueryString["token"]);
|
||||||
|
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
await logger.LogInformation("User Password Reset {Username}", _username);
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl("login"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await logger.LogError("Error Resetting User Password {Username}", _username);
|
||||||
|
AddModuleMessage(Localizer["Error.Password.ResetInfo"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Resetting User Password {Username} {Error}", _username, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Password.Reset"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Cancel()
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -10,21 +10,21 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<ActionLink Action="Add" Text="Add Role" ResourceKey="AddRole" />
|
<ActionLink Action="Add" Text="Add Role" ResourceKey="AddRole" />
|
||||||
<Pager Items="@_roles">
|
<Pager Items="@_roles">
|
||||||
<Header>
|
<Header>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th>@SharedLocalizer["Name"]</th>
|
<th>@SharedLocalizer["Name"]</th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.RoleId.ToString())" Disabled="@(context.IsSystem)" ResourceKey="Edit" /></td>
|
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.RoleId.ToString())" Disabled="@(context.IsSystem)" ResourceKey="Edit" /></td>
|
||||||
<td><ActionDialog Header="Delete Role" Message="@string.Format(Localizer["Confirm.DeleteUser"], context.Name)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteRole(context))" Disabled="@(context.IsSystem)" ResourceKey="DeleteRole" /></td>
|
<td><ActionDialog Header="Delete Role" Message="@string.Format(Localizer["Confirm.DeleteUser"], context.Name)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteRole(context))" Disabled="@(context.IsSystem)" ResourceKey="DeleteRole" /></td>
|
||||||
<td><ActionLink Action="Users" Parameters="@($"id=" + context.RoleId.ToString())" ResourceKey="Users" /></td>
|
<td><ActionLink Action="Users" Parameters="@($"id=" + context.RoleId.ToString())" ResourceKey="Users" /></td>
|
||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
@ -39,30 +39,30 @@ else
|
||||||
|
|
||||||
private async Task DeleteRole(Role role)
|
private async Task DeleteRole(Role role)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await RoleService.DeleteRoleAsync(role.RoleId);
|
await RoleService.DeleteRoleAsync(role.RoleId);
|
||||||
await logger.LogInformation("Role Deleted {Role}", role);
|
await logger.LogInformation("Role Deleted {Role}", role);
|
||||||
await GetRoles();
|
await GetRoles();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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(Localizer["Error.DeleteRole"], MessageType.Error);
|
AddModuleMessage(Localizer["Error.DeleteRole"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task GetRoles()
|
private async Task GetRoles()
|
||||||
{
|
{
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||||
{
|
{
|
||||||
_roles = await RoleService.GetRolesAsync(PageState.Site.SiteId, true);
|
_roles = await RoleService.GetRolesAsync(PageState.Site.SiteId, true);
|
||||||
_roles = _roles.Where(item => item.Name != RoleNames.Everyone).ToList();
|
_roles = _roles.Where(item => item.Name != RoleNames.Everyone).ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_roles = await RoleService.GetRolesAsync(PageState.Site.SiteId);
|
_roles = await RoleService.GetRolesAsync(PageState.Site.SiteId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,189 +12,189 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="role" HelpText="The role you are assigning users to" ResourceKey="Role">Role: </Label>
|
<Label Class="col-sm-3" For="role" HelpText="The role you are assigning users to" ResourceKey="Role">Role: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="role" class="form-control" @bind="@name" disabled />
|
<input id="role" class="form-control" @bind="@name" disabled />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="user" HelpText="Select a user" ResourceKey="User">User: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="user" class="form-select" @bind="@userid" required>
|
||||||
|
<option value="-1"><@Localizer["User.Select"]></option>
|
||||||
|
@foreach (UserRole userrole in users)
|
||||||
|
{
|
||||||
|
<option value="@(userrole.UserId)">@userrole.User.DisplayName</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="effectiveDate" HelpText="The date that this role assignment is active" ResourceKey="EffectiveDate">Effective Date: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="date" id="effectiveDate" class="form-control" @bind="@effectivedate" required />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="expiryDate" HelpText="The date that this role assignment expires" ResourceKey="ExpiryDate">Expiry Date: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="date" id="expiryDate" class="form-control" @bind="@expirydate" required />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br /><br />
|
||||||
|
<button type="button" class="btn btn-success" @onclick="SaveUserRole">@SharedLocalizer["Save"]</button>
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
<hr class="app-rule" />
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<p align="center">
|
||||||
|
<Pager Items="@userroles">
|
||||||
|
<Header>
|
||||||
|
<th>@Localizer["Users"]</th>
|
||||||
|
<th>@Localizer["Effective"]</th>
|
||||||
|
<th>@Localizer["Expiry"]</th>
|
||||||
|
<th> </th>
|
||||||
|
</Header>
|
||||||
|
<Row>
|
||||||
|
<td>@context.User.DisplayName</td>
|
||||||
|
<td>@context.EffectiveDate</td>
|
||||||
|
<td>@context.ExpiryDate</td>
|
||||||
|
<td>
|
||||||
|
<ActionDialog Header="Remove User" Message="@string.Format(Localizer["Confirm.User.DeleteRole"], context.User.DisplayName)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteUserRole(context.UserRoleId))" Disabled="@(context.Role.IsAutoAssigned || PageState.User.Username == UserNames.Host)" ResourceKey="DeleteUserRole" />
|
||||||
|
</td>
|
||||||
|
</Row>
|
||||||
|
</Pager>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
</form>
|
||||||
<Label Class="col-sm-3" For="user" HelpText="Select a user" ResourceKey="User">User: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="user" class="form-select" @bind="@userid" required>
|
|
||||||
<option value="-1"><@Localizer["User.Select"]></option>
|
|
||||||
@foreach (UserRole userrole in users)
|
|
||||||
{
|
|
||||||
<option value="@(userrole.UserId)">@userrole.User.DisplayName</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="effectiveDate" HelpText="The date that this role assignment is active" ResourceKey="EffectiveDate">Effective Date: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input type="date" id="effectiveDate" class="form-control" @bind="@effectivedate" required />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="expiryDate" HelpText="The date that this role assignment expires" ResourceKey="ExpiryDate">Expiry Date: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input type="date" id="expiryDate" class="form-control" @bind="@expirydate" required />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br /><br />
|
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveUserRole">@SharedLocalizer["Save"]</button>
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
<hr class="app-rule" />
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<p align="center">
|
|
||||||
<Pager Items="@userroles">
|
|
||||||
<Header>
|
|
||||||
<th>@Localizer["Users"]</th>
|
|
||||||
<th>@Localizer["Effective"]</th>
|
|
||||||
<th>@Localizer["Expiry"]</th>
|
|
||||||
<th> </th>
|
|
||||||
</Header>
|
|
||||||
<Row>
|
|
||||||
<td>@context.User.DisplayName</td>
|
|
||||||
<td>@context.EffectiveDate</td>
|
|
||||||
<td>@context.ExpiryDate</td>
|
|
||||||
<td>
|
|
||||||
<ActionDialog Header="Remove User" Message="@string.Format(Localizer["Confirm.User.DeleteRole"], context.User.DisplayName)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteUserRole(context.UserRoleId))" Disabled="@(context.Role.IsAutoAssigned || PageState.User.Username == UserNames.Host)" ResourceKey="DeleteUserRole" />
|
|
||||||
</td>
|
|
||||||
</Row>
|
|
||||||
</Pager>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
|
|
||||||
private int roleid;
|
private int roleid;
|
||||||
private string name = string.Empty;
|
private string name = string.Empty;
|
||||||
private List<UserRole> users;
|
private List<UserRole> users;
|
||||||
private int userid = -1;
|
private int userid = -1;
|
||||||
private DateTime? effectivedate = null;
|
private DateTime? effectivedate = null;
|
||||||
private DateTime? expirydate = null;
|
private DateTime? expirydate = null;
|
||||||
private List<UserRole> userroles;
|
private List<UserRole> userroles;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
roleid = Int32.Parse(PageState.QueryString["id"]);
|
||||||
|
Role role = await RoleService.GetRoleAsync(roleid);
|
||||||
|
name = role.Name;
|
||||||
|
users = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
||||||
|
users = users
|
||||||
|
.Where(u => u.Role.Name == RoleNames.Registered)
|
||||||
|
.OrderBy(u => u.User.DisplayName)
|
||||||
|
.ToList();
|
||||||
|
await GetUserRoles();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Users {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.User.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GetUserRoles()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
userroles = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
||||||
|
userroles = userroles.Where(item => item.RoleId == roleid).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading User Roles {RoleId} {Error}", roleid, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.User.LoadRole"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveUserRole()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
roleid = Int32.Parse(PageState.QueryString["id"]);
|
if (userid != -1)
|
||||||
Role role = await RoleService.GetRoleAsync(roleid);
|
|
||||||
name = role.Name;
|
|
||||||
users = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
|
||||||
users = users
|
|
||||||
.Where(u => u.Role.Name == RoleNames.Registered)
|
|
||||||
.OrderBy(u => u.User.DisplayName)
|
|
||||||
.ToList();
|
|
||||||
await GetUserRoles();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Users {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.User.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task GetUserRoles()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
userroles = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
var userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault();
|
||||||
userroles = userroles.Where(item => item.RoleId == roleid).ToList();
|
if (userrole != null)
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading User Roles {RoleId} {Error}", roleid, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.User.LoadRole"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SaveUserRole()
|
|
||||||
{
|
|
||||||
validated = true;
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (userid != -1)
|
|
||||||
{
|
{
|
||||||
var userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault();
|
userrole.EffectiveDate = effectivedate;
|
||||||
if (userrole != null)
|
userrole.ExpiryDate = expirydate;
|
||||||
{
|
await UserRoleService.UpdateUserRoleAsync(userrole);
|
||||||
userrole.EffectiveDate = effectivedate;
|
|
||||||
userrole.ExpiryDate = expirydate;
|
|
||||||
await UserRoleService.UpdateUserRoleAsync(userrole);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
userrole = new UserRole();
|
|
||||||
userrole.UserId = userid;
|
|
||||||
userrole.RoleId = roleid;
|
|
||||||
userrole.EffectiveDate = effectivedate;
|
|
||||||
userrole.ExpiryDate = expirydate;
|
|
||||||
|
|
||||||
await UserRoleService.AddUserRoleAsync(userrole);
|
|
||||||
}
|
|
||||||
|
|
||||||
await logger.LogInformation("User Assigned To Role {UserRole}", userrole);
|
|
||||||
AddModuleMessage(Localizer["Success.User.AssignedRole"], MessageType.Success);
|
|
||||||
await GetUserRoles();
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.UserSelect"], MessageType.Warning);
|
userrole = new UserRole();
|
||||||
|
userrole.UserId = userid;
|
||||||
|
userrole.RoleId = roleid;
|
||||||
|
userrole.EffectiveDate = effectivedate;
|
||||||
|
userrole.ExpiryDate = expirydate;
|
||||||
|
|
||||||
|
await UserRoleService.AddUserRoleAsync(userrole);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Saving User Roles {RoleId} {Error}", roleid, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.User.SaveRole"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
await logger.LogInformation("User Assigned To Role {UserRole}", userrole);
|
||||||
{
|
AddModuleMessage(Localizer["Success.User.AssignedRole"], MessageType.Success);
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DeleteUserRole(int UserRoleId)
|
|
||||||
{
|
|
||||||
validated = true;
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await UserRoleService.DeleteUserRoleAsync(UserRoleId);
|
|
||||||
await logger.LogInformation("User Removed From Role {UserRoleId}", UserRoleId);
|
|
||||||
AddModuleMessage(Localizer["Confirm.User.RoleRemoved"], MessageType.Success);
|
|
||||||
await GetUserRoles();
|
await GetUserRoles();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Removing User From Role {UserRoleId} {Error}", UserRoleId, ex.Message);
|
AddModuleMessage(Localizer["Message.Required.UserSelect"], MessageType.Warning);
|
||||||
AddModuleMessage(Localizer["Error.User.RemoveRole"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
await logger.LogError(ex, "Error Saving User Roles {RoleId} {Error}", roleid, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.User.SaveRole"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task DeleteUserRole(int UserRoleId)
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await UserRoleService.DeleteUserRoleAsync(UserRoleId);
|
||||||
|
await logger.LogInformation("User Removed From Role {UserRoleId}", UserRoleId);
|
||||||
|
AddModuleMessage(Localizer["Confirm.User.RoleRemoved"], MessageType.Success);
|
||||||
|
await GetUserRoles();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Removing User From Role {UserRoleId} {Error}", UserRoleId, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.User.RemoveRole"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="name" HelpText="Enter the site name" ResourceKey="Name">Name: </Label>
|
<Label Class="col-sm-3" For="name" HelpText="Enter the site name" ResourceKey="Name">Name: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="name" class="form-control" @bind="@_name" maxlength="256" required/>
|
<input id="name" class="form-control" @bind="@_name" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
@ -119,13 +119,13 @@
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="host" HelpText="Enter the host name of the SMTP server" ResourceKey="Host">Host: </Label>
|
<Label Class="col-sm-3" For="host" HelpText="Enter the host name of the SMTP server" ResourceKey="Host">Host: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="host" class="form-control" @bind="@_smtphost"/>
|
<input id="host" class="form-control" @bind="@_smtphost" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="port" HelpText="Enter the port number for the SMTP server. Please note this field is required if you provide a host name." ResourceKey="Port">Port: </Label>
|
<Label Class="col-sm-3" For="port" HelpText="Enter the port number for the SMTP server. Please note this field is required if you provide a host name." ResourceKey="Port">Port: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="port" class="form-control" @bind="@_smtpport" required/>
|
<input id="port" class="form-control" @bind="@_smtpport" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
@ -146,7 +146,7 @@
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="password" HelpText="Enter the password for your SMTP account" ResourceKey="SmtpPassword">Password: </Label>
|
<Label Class="col-sm-3" For="password" HelpText="Enter the password for your SMTP account" ResourceKey="SmtpPassword">Password: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="password" type="password" class="form-control" @bind="@_smtppassword"/>
|
<input id="password" type="password" class="form-control" @bind="@_smtppassword" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
@ -217,362 +217,362 @@
|
||||||
<ActionDialog Header="Delete Site" Message="@Localizer["Confirm.DeleteSite"]" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteSite())" ResourceKey="DeleteSite" />
|
<ActionDialog Header="Delete Site" Message="@Localizer["Confirm.DeleteSite"]" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteSite())" ResourceKey="DeleteSite" />
|
||||||
<br />
|
<br />
|
||||||
<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>
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private bool _initialized = false;
|
private bool _initialized = false;
|
||||||
private List<Theme> _themeList;
|
private List<Theme> _themeList;
|
||||||
private List<ThemeControl> _themes = new List<ThemeControl>();
|
private List<ThemeControl> _themes = new List<ThemeControl>();
|
||||||
private List<ThemeControl> _containers = new List<ThemeControl>();
|
private List<ThemeControl> _containers = new List<ThemeControl>();
|
||||||
private string _name = string.Empty;
|
private string _name = string.Empty;
|
||||||
private List<Alias> _aliasList;
|
private List<Alias> _aliasList;
|
||||||
private string _urls = string.Empty;
|
private string _urls = string.Empty;
|
||||||
private int _logofileid = -1;
|
private int _logofileid = -1;
|
||||||
private FileManager _logofilemanager;
|
private FileManager _logofilemanager;
|
||||||
private int _faviconfileid = -1;
|
private int _faviconfileid = -1;
|
||||||
private FileManager _faviconfilemanager;
|
private FileManager _faviconfilemanager;
|
||||||
private string _themetype = "-";
|
private string _themetype = "-";
|
||||||
private string _containertype = "-";
|
private string _containertype = "-";
|
||||||
private string _admincontainertype = "-";
|
private string _admincontainertype = "-";
|
||||||
private string _allowregistration;
|
private string _allowregistration;
|
||||||
private string _smtphost = string.Empty;
|
private string _smtphost = string.Empty;
|
||||||
private string _smtpport = string.Empty;
|
private string _smtpport = string.Empty;
|
||||||
private string _smtpssl = "False";
|
private string _smtpssl = "False";
|
||||||
private string _smtpusername = string.Empty;
|
private string _smtpusername = string.Empty;
|
||||||
private string _smtppassword = string.Empty;
|
private string _smtppassword = string.Empty;
|
||||||
private string _smtpsender = string.Empty;
|
private string _smtpsender = string.Empty;
|
||||||
private string _pwaisenabled;
|
private string _pwaisenabled;
|
||||||
private int _pwaappiconfileid = -1;
|
private int _pwaappiconfileid = -1;
|
||||||
private FileManager _pwaappiconfilemanager;
|
private FileManager _pwaappiconfilemanager;
|
||||||
private int _pwasplashiconfileid = -1;
|
private int _pwasplashiconfileid = -1;
|
||||||
private FileManager _pwasplashiconfilemanager;
|
private FileManager _pwasplashiconfilemanager;
|
||||||
private string _tenant = string.Empty;
|
private string _tenant = string.Empty;
|
||||||
private string _database = string.Empty;
|
private string _database = string.Empty;
|
||||||
private string _connectionstring = string.Empty;
|
private string _connectionstring = string.Empty;
|
||||||
private string _createdby;
|
private string _createdby;
|
||||||
private DateTime _createdon;
|
private DateTime _createdon;
|
||||||
private string _modifiedby;
|
private string _modifiedby;
|
||||||
private DateTime _modifiedon;
|
private DateTime _modifiedon;
|
||||||
private string _deletedby;
|
private string _deletedby;
|
||||||
private DateTime? _deletedon;
|
private DateTime? _deletedon;
|
||||||
private string _isdeleted;
|
private string _isdeleted;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_themeList = await ThemeService.GetThemesAsync();
|
||||||
|
Site site = await SiteService.GetSiteAsync(PageState.Site.SiteId);
|
||||||
|
if (site != null)
|
||||||
{
|
{
|
||||||
try
|
_name = site.Name;
|
||||||
|
_allowregistration = site.AllowRegistration.ToString();
|
||||||
|
_isdeleted = site.IsDeleted.ToString();
|
||||||
|
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||||
{
|
{
|
||||||
_themeList = await ThemeService.GetThemesAsync();
|
_aliasList = await AliasService.GetAliasesAsync();
|
||||||
Site site = await SiteService.GetSiteAsync(PageState.Site.SiteId);
|
foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
|
||||||
if (site != null)
|
|
||||||
{
|
{
|
||||||
_name = site.Name;
|
_urls += alias.Name + ",";
|
||||||
_allowregistration = site.AllowRegistration.ToString();
|
}
|
||||||
_isdeleted = site.IsDeleted.ToString();
|
_urls = _urls.Substring(0, _urls.Length - 1);
|
||||||
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
}
|
||||||
|
|
||||||
|
if (site.LogoFileId != null)
|
||||||
|
{
|
||||||
|
_logofileid = site.LogoFileId.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (site.FaviconFileId != null)
|
||||||
|
{
|
||||||
|
_faviconfileid = site.FaviconFileId.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
_themes = ThemeService.GetThemeControls(_themeList);
|
||||||
|
_themetype = (!string.IsNullOrEmpty(site.DefaultThemeType)) ? site.DefaultThemeType : Constants.DefaultTheme;
|
||||||
|
_containers = ThemeService.GetContainerControls(_themeList, _themetype);
|
||||||
|
_containertype = (!string.IsNullOrEmpty(site.DefaultContainerType)) ? site.DefaultContainerType : Constants.DefaultContainer;
|
||||||
|
_admincontainertype = (!string.IsNullOrEmpty(site.AdminContainerType)) ? site.AdminContainerType : Constants.DefaultAdminContainer;
|
||||||
|
|
||||||
|
var settings = await SettingService.GetSiteSettingsAsync(site.SiteId);
|
||||||
|
_smtphost = SettingService.GetSetting(settings, "SMTPHost", string.Empty);
|
||||||
|
_smtpport = SettingService.GetSetting(settings, "SMTPPort", string.Empty);
|
||||||
|
_smtpssl = SettingService.GetSetting(settings, "SMTPSSL", "False");
|
||||||
|
_smtpusername = SettingService.GetSetting(settings, "SMTPUsername", string.Empty);
|
||||||
|
_smtppassword = SettingService.GetSetting(settings, "SMTPPassword", string.Empty);
|
||||||
|
_smtpsender = SettingService.GetSetting(settings, "SMTPSender", string.Empty);
|
||||||
|
|
||||||
|
_pwaisenabled = site.PwaIsEnabled.ToString();
|
||||||
|
|
||||||
|
if (site.PwaAppIconFileId != null)
|
||||||
|
{
|
||||||
|
_pwaappiconfileid = site.PwaAppIconFileId.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (site.PwaSplashIconFileId != null)
|
||||||
|
{
|
||||||
|
_pwasplashiconfileid = site.PwaSplashIconFileId.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
_pwaisenabled = site.PwaIsEnabled.ToString();
|
||||||
|
if (site.PwaAppIconFileId != null)
|
||||||
|
{
|
||||||
|
_pwaappiconfileid = site.PwaAppIconFileId.Value;
|
||||||
|
}
|
||||||
|
if (site.PwaSplashIconFileId != null)
|
||||||
|
{
|
||||||
|
_pwasplashiconfileid = site.PwaSplashIconFileId.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||||
|
{
|
||||||
|
var tenants = await TenantService.GetTenantsAsync();
|
||||||
|
var _databases = await DatabaseService.GetDatabasesAsync();
|
||||||
|
var tenant = tenants.Find(item => item.TenantId == site.TenantId);
|
||||||
|
if (tenant != null)
|
||||||
|
{
|
||||||
|
_tenant = tenant.Name;
|
||||||
|
_database = _databases.Find(item => item.DBType == tenant.DBType)?.Name;
|
||||||
|
_connectionstring = tenant.DBConnectionString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_createdby = site.CreatedBy;
|
||||||
|
_createdon = site.CreatedOn;
|
||||||
|
_modifiedby = site.ModifiedBy;
|
||||||
|
_modifiedon = site.ModifiedOn;
|
||||||
|
_deletedby = site.DeletedBy;
|
||||||
|
_deletedon = site.DeletedOn;
|
||||||
|
|
||||||
|
_initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Site {SiteId} {Error}", PageState.Site.SiteId, ex.Message);
|
||||||
|
AddModuleMessage(ex.Message, MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void ThemeChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_themetype = (string)e.Value;
|
||||||
|
if (_themetype != "-")
|
||||||
|
{
|
||||||
|
_containers = ThemeService.GetContainerControls(_themeList, _themetype);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_containers = new List<ThemeControl>();
|
||||||
|
}
|
||||||
|
_containertype = "-";
|
||||||
|
_admincontainertype = Constants.DefaultAdminContainer;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", _themetype, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Theme.LoadPane"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveSite()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-")
|
||||||
|
{
|
||||||
|
var unique = true;
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||||
|
{
|
||||||
|
foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
_aliasList = await AliasService.GetAliasesAsync();
|
if (_aliasList.Exists(item => item.Name == name && item.SiteId != PageState.Alias.SiteId && item.TenantId != PageState.Alias.TenantId))
|
||||||
foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
|
|
||||||
{
|
{
|
||||||
_urls += alias.Name + ",";
|
unique = false;
|
||||||
}
|
|
||||||
_urls = _urls.Substring(0, _urls.Length - 1);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (site.LogoFileId != null)
|
|
||||||
{
|
|
||||||
_logofileid = site.LogoFileId.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (site.FaviconFileId != null)
|
|
||||||
{
|
|
||||||
_faviconfileid = site.FaviconFileId.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
_themes = ThemeService.GetThemeControls(_themeList);
|
|
||||||
_themetype = (!string.IsNullOrEmpty(site.DefaultThemeType)) ? site.DefaultThemeType : Constants.DefaultTheme;
|
|
||||||
_containers = ThemeService.GetContainerControls(_themeList, _themetype);
|
|
||||||
_containertype = (!string.IsNullOrEmpty(site.DefaultContainerType)) ? site.DefaultContainerType : Constants.DefaultContainer;
|
|
||||||
_admincontainertype = (!string.IsNullOrEmpty(site.AdminContainerType)) ? site.AdminContainerType : Constants.DefaultAdminContainer;
|
|
||||||
|
|
||||||
var settings = await SettingService.GetSiteSettingsAsync(site.SiteId);
|
|
||||||
_smtphost = SettingService.GetSetting(settings, "SMTPHost", string.Empty);
|
|
||||||
_smtpport = SettingService.GetSetting(settings, "SMTPPort", string.Empty);
|
|
||||||
_smtpssl = SettingService.GetSetting(settings, "SMTPSSL", "False");
|
|
||||||
_smtpusername = SettingService.GetSetting(settings, "SMTPUsername", string.Empty);
|
|
||||||
_smtppassword = SettingService.GetSetting(settings, "SMTPPassword", string.Empty);
|
|
||||||
_smtpsender = SettingService.GetSetting(settings, "SMTPSender", string.Empty);
|
|
||||||
|
|
||||||
_pwaisenabled = site.PwaIsEnabled.ToString();
|
|
||||||
|
|
||||||
if (site.PwaAppIconFileId != null)
|
|
||||||
{
|
|
||||||
_pwaappiconfileid = site.PwaAppIconFileId.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (site.PwaSplashIconFileId != null)
|
|
||||||
{
|
|
||||||
_pwasplashiconfileid = site.PwaSplashIconFileId.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
_pwaisenabled = site.PwaIsEnabled.ToString();
|
|
||||||
if (site.PwaAppIconFileId != null)
|
|
||||||
{
|
|
||||||
_pwaappiconfileid = site.PwaAppIconFileId.Value;
|
|
||||||
}
|
|
||||||
if (site.PwaSplashIconFileId != null)
|
|
||||||
{
|
|
||||||
_pwasplashiconfileid = site.PwaSplashIconFileId.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
|
||||||
{
|
|
||||||
var tenants = await TenantService.GetTenantsAsync();
|
|
||||||
var _databases = await DatabaseService.GetDatabasesAsync();
|
|
||||||
var tenant = tenants.Find(item => item.TenantId == site.TenantId);
|
|
||||||
if (tenant != null)
|
|
||||||
{
|
|
||||||
_tenant = tenant.Name;
|
|
||||||
_database = _databases.Find(item => item.DBType == tenant.DBType)?.Name;
|
|
||||||
_connectionstring = tenant.DBConnectionString;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_createdby = site.CreatedBy;
|
|
||||||
_createdon = site.CreatedOn;
|
|
||||||
_modifiedby = site.ModifiedBy;
|
|
||||||
_modifiedon = site.ModifiedOn;
|
|
||||||
_deletedby = site.DeletedBy;
|
|
||||||
_deletedon = site.DeletedOn;
|
|
||||||
|
|
||||||
_initialized = true;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Site {SiteId} {Error}", PageState.Site.SiteId, ex.Message);
|
|
||||||
AddModuleMessage(ex.Message, MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void ThemeChanged(ChangeEventArgs e)
|
if (unique)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_themetype = (string)e.Value;
|
|
||||||
if (_themetype != "-")
|
|
||||||
{
|
{
|
||||||
_containers = ThemeService.GetContainerControls(_themeList, _themetype);
|
var site = await SiteService.GetSiteAsync(PageState.Site.SiteId);
|
||||||
}
|
if (site != null)
|
||||||
else
|
|
||||||
{
|
|
||||||
_containers = new List<ThemeControl>();
|
|
||||||
}
|
|
||||||
_containertype = "-";
|
|
||||||
_admincontainertype = Constants.DefaultAdminContainer;
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", _themetype, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Theme.LoadPane"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SaveSite()
|
|
||||||
{
|
|
||||||
validated = true;
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-")
|
|
||||||
{
|
{
|
||||||
var unique = true;
|
bool refresh = (site.DefaultThemeType != _themetype || site.DefaultContainerType != _containertype);
|
||||||
|
|
||||||
|
site.Name = _name;
|
||||||
|
site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration));
|
||||||
|
site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted));
|
||||||
|
|
||||||
|
site.LogoFileId = null;
|
||||||
|
var logofileid = _logofilemanager.GetFileId();
|
||||||
|
if (logofileid != -1)
|
||||||
|
{
|
||||||
|
site.LogoFileId = logofileid;
|
||||||
|
}
|
||||||
|
var faviconFieldId = _faviconfilemanager.GetFileId();
|
||||||
|
if (faviconFieldId != -1)
|
||||||
|
{
|
||||||
|
site.FaviconFileId = faviconFieldId;
|
||||||
|
}
|
||||||
|
site.DefaultThemeType = _themetype;
|
||||||
|
site.DefaultContainerType = _containertype;
|
||||||
|
site.AdminContainerType = _admincontainertype;
|
||||||
|
|
||||||
|
site.PwaIsEnabled = (_pwaisenabled == null ? true : Boolean.Parse(_pwaisenabled));
|
||||||
|
var pwaappiconfileid = _pwaappiconfilemanager.GetFileId();
|
||||||
|
if (pwaappiconfileid != -1)
|
||||||
|
{
|
||||||
|
site.PwaAppIconFileId = pwaappiconfileid;
|
||||||
|
}
|
||||||
|
var pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId();
|
||||||
|
if (pwasplashiconfileid != -1)
|
||||||
|
{
|
||||||
|
site.PwaSplashIconFileId = pwasplashiconfileid;
|
||||||
|
}
|
||||||
|
|
||||||
|
site = await SiteService.UpdateSiteAsync(site);
|
||||||
|
|
||||||
|
var 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, "SMTPSender", _smtpsender);
|
||||||
|
await SettingService.UpdateSiteSettingsAsync(settings, site.SiteId);
|
||||||
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||||
{
|
{
|
||||||
foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
var names = _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
|
||||||
{
|
{
|
||||||
if (_aliasList.Exists(item => item.Name == name && item.SiteId != PageState.Alias.SiteId && item.TenantId != PageState.Alias.TenantId))
|
if (!names.Contains(alias.Name))
|
||||||
{
|
{
|
||||||
unique = false;
|
await AliasService.DeleteAliasAsync(alias.AliasId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string name in names)
|
||||||
|
{
|
||||||
|
if (!_aliasList.Exists(item => item.Name == name))
|
||||||
|
{
|
||||||
|
Alias alias = new Alias();
|
||||||
|
alias.Name = name;
|
||||||
|
alias.TenantId = site.TenantId;
|
||||||
|
alias.SiteId = site.SiteId;
|
||||||
|
await AliasService.AddAliasAsync(alias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unique)
|
await logger.LogInformation("Site Settings Saved {Site}", site);
|
||||||
|
|
||||||
|
if (refresh)
|
||||||
{
|
{
|
||||||
var site = await SiteService.GetSiteAsync(PageState.Site.SiteId);
|
NavigationManager.NavigateTo(NavigateUrl()); // refresh to show new theme or container
|
||||||
if (site != null)
|
|
||||||
{
|
|
||||||
bool refresh = (site.DefaultThemeType != _themetype || site.DefaultContainerType != _containertype);
|
|
||||||
|
|
||||||
site.Name = _name;
|
|
||||||
site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration));
|
|
||||||
site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted));
|
|
||||||
|
|
||||||
site.LogoFileId = null;
|
|
||||||
var logofileid = _logofilemanager.GetFileId();
|
|
||||||
if (logofileid != -1)
|
|
||||||
{
|
|
||||||
site.LogoFileId = logofileid;
|
|
||||||
}
|
|
||||||
var faviconFieldId = _faviconfilemanager.GetFileId();
|
|
||||||
if (faviconFieldId != -1)
|
|
||||||
{
|
|
||||||
site.FaviconFileId = faviconFieldId;
|
|
||||||
}
|
|
||||||
site.DefaultThemeType = _themetype;
|
|
||||||
site.DefaultContainerType = _containertype;
|
|
||||||
site.AdminContainerType = _admincontainertype;
|
|
||||||
|
|
||||||
site.PwaIsEnabled = (_pwaisenabled == null ? true : Boolean.Parse(_pwaisenabled));
|
|
||||||
var pwaappiconfileid = _pwaappiconfilemanager.GetFileId();
|
|
||||||
if (pwaappiconfileid != -1)
|
|
||||||
{
|
|
||||||
site.PwaAppIconFileId = pwaappiconfileid;
|
|
||||||
}
|
|
||||||
var pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId();
|
|
||||||
if (pwasplashiconfileid != -1)
|
|
||||||
{
|
|
||||||
site.PwaSplashIconFileId = pwasplashiconfileid;
|
|
||||||
}
|
|
||||||
|
|
||||||
site = await SiteService.UpdateSiteAsync(site);
|
|
||||||
|
|
||||||
var 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, "SMTPSender", _smtpsender);
|
|
||||||
await SettingService.UpdateSiteSettingsAsync(settings, site.SiteId);
|
|
||||||
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
|
||||||
{
|
|
||||||
var 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))
|
|
||||||
{
|
|
||||||
await AliasService.DeleteAliasAsync(alias.AliasId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (string name in names)
|
|
||||||
{
|
|
||||||
if (!_aliasList.Exists(item => item.Name == name))
|
|
||||||
{
|
|
||||||
Alias alias = new Alias();
|
|
||||||
alias.Name = name;
|
|
||||||
alias.TenantId = site.TenantId;
|
|
||||||
alias.SiteId = site.SiteId;
|
|
||||||
await AliasService.AddAliasAsync(alias);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await logger.LogInformation("Site Settings Saved {Site}", site);
|
|
||||||
|
|
||||||
if (refresh)
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl()); // refresh to show new theme or container
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Success.Settings.SaveSite"], MessageType.Success);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Aliases.Taken"], MessageType.Warning);
|
AddModuleMessage(Localizer["Success.Settings.SaveSite"], MessageType.Success);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Required.SiteName"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Saving Site {SiteId} {Error}", PageState.Site.SiteId, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.SaveSite"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DeleteSite()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var sites = await SiteService.GetSitesAsync();
|
|
||||||
if (sites.Count > 1)
|
|
||||||
{
|
|
||||||
await SiteService.DeleteSiteAsync(PageState.Site.SiteId);
|
|
||||||
await logger.LogInformation("Site Deleted {SiteId}", PageState.Site.SiteId);
|
|
||||||
|
|
||||||
var aliases = await AliasService.GetAliasesAsync();
|
|
||||||
foreach (Alias a in aliases.Where(item => item.SiteId == PageState.Site.SiteId && item.TenantId == PageState.Site.TenantId))
|
|
||||||
{
|
|
||||||
await AliasService.DeleteAliasAsync(a.AliasId);
|
|
||||||
}
|
|
||||||
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl("admin/sites"));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.FailAuth.DeleteSite"], MessageType.Warning);
|
AddModuleMessage(Localizer["Message.Aliases.Taken"], MessageType.Warning);
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Deleting Site {SiteId} {Error}", PageState.Site.SiteId, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.DeleteSite"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SendEmail()
|
|
||||||
{
|
|
||||||
if (_smtphost != "" && _smtpport != "" && _smtpsender != "")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var settings = await SettingService.GetSiteSettingsAsync(PageState.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, "SMTPSender", _smtpsender);
|
|
||||||
await SettingService.UpdateSiteSettingsAsync(settings, PageState.Site.SiteId);
|
|
||||||
await logger.LogInformation("Site SMTP Settings Saved");
|
|
||||||
|
|
||||||
await NotificationService.AddNotificationAsync(new Notification(PageState.Site.SiteId, PageState.User.DisplayName, PageState.User.Email, PageState.User.DisplayName, PageState.User.Email, PageState.Site.Name + " SMTP Configuration Test", "SMTP Server Is Configured Correctly."));
|
|
||||||
AddModuleMessage(Localizer["Info.Smtp.SaveSettings"], MessageType.Info);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Testing SMTP Configuration");
|
|
||||||
AddModuleMessage(Localizer["Error.Smtp.TestConfig"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.required.Smtp"], MessageType.Warning);
|
AddModuleMessage(Localizer["Message.Required.SiteName"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Saving Site {SiteId} {Error}", PageState.Site.SiteId, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.SaveSite"], MessageType.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteSite()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sites = await SiteService.GetSitesAsync();
|
||||||
|
if (sites.Count > 1)
|
||||||
|
{
|
||||||
|
await SiteService.DeleteSiteAsync(PageState.Site.SiteId);
|
||||||
|
await logger.LogInformation("Site Deleted {SiteId}", PageState.Site.SiteId);
|
||||||
|
|
||||||
|
var aliases = await AliasService.GetAliasesAsync();
|
||||||
|
foreach (Alias a in aliases.Where(item => item.SiteId == PageState.Site.SiteId && item.TenantId == PageState.Site.TenantId))
|
||||||
|
{
|
||||||
|
await AliasService.DeleteAliasAsync(a.AliasId);
|
||||||
|
}
|
||||||
|
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl("admin/sites"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.FailAuth.DeleteSite"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Deleting Site {SiteId} {Error}", PageState.Site.SiteId, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.DeleteSite"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SendEmail()
|
||||||
|
{
|
||||||
|
if (_smtphost != "" && _smtpport != "" && _smtpsender != "")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var settings = await SettingService.GetSiteSettingsAsync(PageState.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, "SMTPSender", _smtpsender);
|
||||||
|
await SettingService.UpdateSiteSettingsAsync(settings, PageState.Site.SiteId);
|
||||||
|
await logger.LogInformation("Site SMTP Settings Saved");
|
||||||
|
|
||||||
|
await NotificationService.AddNotificationAsync(new Notification(PageState.Site.SiteId, PageState.User.DisplayName, PageState.User.Email, PageState.User.DisplayName, PageState.User.Email, PageState.Site.Name + " SMTP Configuration Test", "SMTP Server Is Configured Correctly."));
|
||||||
|
AddModuleMessage(Localizer["Info.Smtp.SaveSettings"], MessageType.Info);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Testing SMTP Configuration");
|
||||||
|
AddModuleMessage(Localizer["Error.Smtp.TestConfig"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.required.Smtp"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ else
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="name" HelpText="Enter the name of the site" ResourceKey="Name">Site Name: </Label>
|
<Label Class="col-sm-3" For="name" HelpText="Enter the name of the site" ResourceKey="Name">Site Name: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="name" class="form-control" @bind="@_name" maxlength="256" required/>
|
<input id="name" class="form-control" @bind="@_name" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
@ -103,7 +103,7 @@ else
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="name" HelpText="Enter the name for the tenant" ResourceKey="TenantName">Tenant Name: </Label>
|
<Label Class="col-sm-3" For="name" HelpText="Enter the name for the tenant" ResourceKey="TenantName">Tenant Name: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="name" class="form-control" @bind="@_tenantName" maxlength="256" required/>
|
<input id="name" class="form-control" @bind="@_tenantName" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
@ -137,7 +137,7 @@ else
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="hostPassword" HelpText="Enter the password for the host of this site" ResourceKey="HostPassword">Host Password:</Label>
|
<Label Class="col-sm-3" For="hostPassword" HelpText="Enter the password for the host of this site" ResourceKey="HostPassword">Host Password:</Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="hostPassword" type="password" class="form-control" @bind="@_hostpassword" maxlength="256" required/>
|
<input id="hostPassword" type="password" class="form-control" @bind="@_hostpassword" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@ -149,227 +149,227 @@ else
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<Database> _databases;
|
private List<Database> _databases;
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private string _databaseName = "LocalDB";
|
private string _databaseName = "LocalDB";
|
||||||
private Type _databaseConfigType;
|
private Type _databaseConfigType;
|
||||||
private object _databaseConfig;
|
private object _databaseConfig;
|
||||||
private RenderFragment DatabaseConfigComponent { get; set; }
|
private RenderFragment DatabaseConfigComponent { get; set; }
|
||||||
|
|
||||||
|
|
||||||
private List<Theme> _themeList;
|
private List<Theme> _themeList;
|
||||||
private List<ThemeControl> _themes = new List<ThemeControl>();
|
private List<ThemeControl> _themes = new List<ThemeControl>();
|
||||||
private List<ThemeControl> _containers = new List<ThemeControl>();
|
private List<ThemeControl> _containers = new List<ThemeControl>();
|
||||||
private List<SiteTemplate> _siteTemplates;
|
private List<SiteTemplate> _siteTemplates;
|
||||||
private List<Tenant> _tenants;
|
private List<Tenant> _tenants;
|
||||||
private string _tenantid = "-";
|
private string _tenantid = "-";
|
||||||
|
|
||||||
private string _tenantName = string.Empty;
|
private string _tenantName = string.Empty;
|
||||||
|
|
||||||
private string _hostUserName = UserNames.Host;
|
private string _hostUserName = UserNames.Host;
|
||||||
private string _hostpassword = string.Empty;
|
private string _hostpassword = string.Empty;
|
||||||
|
|
||||||
private string _name = string.Empty;
|
private string _name = string.Empty;
|
||||||
private string _urls = string.Empty;
|
private string _urls = string.Empty;
|
||||||
private string _themetype = "-";
|
private string _themetype = "-";
|
||||||
private string _containertype = "-";
|
private string _containertype = "-";
|
||||||
private string _admincontainertype = "";
|
private string _admincontainertype = "";
|
||||||
private string _sitetemplatetype = "-";
|
private string _sitetemplatetype = "-";
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
_tenants = await TenantService.GetTenantsAsync();
|
||||||
|
_urls = PageState.Alias.Name;
|
||||||
|
_themeList = await ThemeService.GetThemesAsync();
|
||||||
|
_themes = ThemeService.GetThemeControls(_themeList);
|
||||||
|
_siteTemplates = await SiteTemplateService.GetSiteTemplatesAsync();
|
||||||
|
_databases = await DatabaseService.GetDatabasesAsync();
|
||||||
|
LoadDatabaseConfigComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DatabaseChanged(ChangeEventArgs eventArgs)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_databaseName = (string)eventArgs.Value;
|
||||||
|
|
||||||
|
LoadDatabaseConfigComponent();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Error.Database.LoadConfig"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadDatabaseConfigComponent()
|
||||||
|
{
|
||||||
|
var database = _databases.SingleOrDefault(d => d.Name == _databaseName);
|
||||||
|
if (database != null)
|
||||||
|
{
|
||||||
|
_databaseConfigType = Type.GetType(database.ControlType);
|
||||||
|
DatabaseConfigComponent = builder =>
|
||||||
{
|
{
|
||||||
_tenants = await TenantService.GetTenantsAsync();
|
builder.OpenComponent(0, _databaseConfigType);
|
||||||
_urls = PageState.Alias.Name;
|
builder.AddComponentReferenceCapture(1, inst => { _databaseConfig = Convert.ChangeType(inst, _databaseConfigType); });
|
||||||
_themeList = await ThemeService.GetThemesAsync();
|
builder.CloseComponent();
|
||||||
_themes = ThemeService.GetThemeControls(_themeList);
|
};
|
||||||
_siteTemplates = await SiteTemplateService.GetSiteTemplatesAsync();
|
}
|
||||||
_databases = await DatabaseService.GetDatabasesAsync();
|
}
|
||||||
LoadDatabaseConfigComponent();
|
|
||||||
|
private void TenantChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
_tenantid = (string)e.Value;
|
||||||
|
if (string.IsNullOrEmpty(_tenantName))
|
||||||
|
{
|
||||||
|
_tenantName = _name;
|
||||||
|
}
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void ThemeChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_themetype = (string)e.Value;
|
||||||
|
if (_themetype != "-")
|
||||||
|
{
|
||||||
|
_containers = ThemeService.GetContainerControls(_themeList, _themetype);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private void DatabaseChanged(ChangeEventArgs eventArgs)
|
|
||||||
{
|
{
|
||||||
try
|
_containers = new List<ThemeControl>();
|
||||||
{
|
|
||||||
_databaseName = (string)eventArgs.Value;
|
|
||||||
|
|
||||||
LoadDatabaseConfigComponent();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Error.Database.LoadConfig"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
_containertype = "-";
|
||||||
|
_admincontainertype = "";
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Containers For Theme {ThemeType} {Error}", _themetype, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Theme.LoadContainers"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadDatabaseConfigComponent()
|
private async Task SaveSite()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-" && _sitetemplatetype != "-")
|
||||||
{
|
{
|
||||||
var database = _databases.SingleOrDefault(d => d.Name == _databaseName);
|
var duplicates = new List<string>();
|
||||||
if (database != null)
|
var aliases = await AliasService.GetAliasesAsync();
|
||||||
|
foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
_databaseConfigType = Type.GetType(database.ControlType);
|
if (aliases.Exists(item => item.Name == name))
|
||||||
DatabaseConfigComponent = builder =>
|
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, _databaseConfigType);
|
duplicates.Add(name);
|
||||||
builder.AddComponentReferenceCapture(1, inst => { _databaseConfig = Convert.ChangeType(inst, _databaseConfigType); });
|
|
||||||
builder.CloseComponent();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TenantChanged(ChangeEventArgs e)
|
|
||||||
{
|
|
||||||
_tenantid = (string)e.Value;
|
|
||||||
if (string.IsNullOrEmpty(_tenantName))
|
|
||||||
{
|
|
||||||
_tenantName = _name;
|
|
||||||
}
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void ThemeChanged(ChangeEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_themetype = (string)e.Value;
|
|
||||||
if (_themetype != "-")
|
|
||||||
{
|
|
||||||
_containers = ThemeService.GetContainerControls(_themeList, _themetype);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
_containers = new List<ThemeControl>();
|
|
||||||
}
|
|
||||||
_containertype = "-";
|
|
||||||
_admincontainertype = "";
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Containers For Theme {ThemeType} {Error}", _themetype, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Theme.LoadContainers"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SaveSite()
|
if (duplicates.Count == 0)
|
||||||
{
|
|
||||||
validated = true;
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
{
|
||||||
if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-" && _sitetemplatetype != "-")
|
InstallConfig config = new InstallConfig();
|
||||||
|
|
||||||
|
if (_tenantid == "+")
|
||||||
{
|
{
|
||||||
var duplicates = new List<string>();
|
if (!string.IsNullOrEmpty(_tenantName) && _tenants.FirstOrDefault(item => item.Name == _tenantName) == null)
|
||||||
var aliases = await AliasService.GetAliasesAsync();
|
|
||||||
foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
{
|
||||||
if (aliases.Exists(item => item.Name == name))
|
// validate host credentials
|
||||||
|
var user = new User();
|
||||||
|
user.SiteId = PageState.Site.SiteId;
|
||||||
|
user.Username = UserNames.Host;
|
||||||
|
user.Password = _hostpassword;
|
||||||
|
user = await UserService.LoginUserAsync(user, false, false);
|
||||||
|
if (user.IsAuthenticated)
|
||||||
{
|
{
|
||||||
duplicates.Add(name);
|
var connectionString = String.Empty;
|
||||||
}
|
if (_databaseConfig is IDatabaseConfigControl databaseConfigControl)
|
||||||
}
|
|
||||||
|
|
||||||
if (duplicates.Count == 0)
|
|
||||||
{
|
|
||||||
InstallConfig config = new InstallConfig();
|
|
||||||
|
|
||||||
if (_tenantid == "+")
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(_tenantName) && _tenants.FirstOrDefault(item => item.Name == _tenantName) == null)
|
|
||||||
{
|
{
|
||||||
// validate host credentials
|
connectionString = databaseConfigControl.GetConnectionString();
|
||||||
var user = new User();
|
}
|
||||||
user.SiteId = PageState.Site.SiteId;
|
var database = _databases.SingleOrDefault(d => d.Name == _databaseName);
|
||||||
user.Username = UserNames.Host;
|
|
||||||
user.Password = _hostpassword;
|
|
||||||
user = await UserService.LoginUserAsync(user, false, false);
|
|
||||||
if (user.IsAuthenticated)
|
|
||||||
{
|
|
||||||
var connectionString = String.Empty;
|
|
||||||
if (_databaseConfig is IDatabaseConfigControl databaseConfigControl)
|
|
||||||
{
|
|
||||||
connectionString = databaseConfigControl.GetConnectionString();
|
|
||||||
}
|
|
||||||
var database = _databases.SingleOrDefault(d => d.Name == _databaseName);
|
|
||||||
|
|
||||||
if (connectionString != "")
|
if (connectionString != "")
|
||||||
{
|
{
|
||||||
config.TenantName = _tenantName;
|
config.TenantName = _tenantName;
|
||||||
config.DatabaseType = database.DBType;
|
config.DatabaseType = database.DBType;
|
||||||
config.ConnectionString = connectionString;
|
config.ConnectionString = connectionString;
|
||||||
config.HostEmail = user.Email;
|
config.HostEmail = user.Email;
|
||||||
config.HostPassword = _hostpassword;
|
config.HostPassword = _hostpassword;
|
||||||
config.HostName = user.DisplayName;
|
config.HostName = user.DisplayName;
|
||||||
config.IsNewTenant = true;
|
config.IsNewTenant = true;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Error.Required.ServerDatabase"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Error.InvalidPassword"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Error.TenantName.Exists"], MessageType.Error);
|
AddModuleMessage(Localizer["Error.Required.ServerDatabase"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantid));
|
AddModuleMessage(Localizer["Error.InvalidPassword"], MessageType.Error);
|
||||||
if (tenant != null)
|
|
||||||
{
|
|
||||||
config.TenantName = tenant.Name;
|
|
||||||
config.DatabaseType = tenant.DBType;
|
|
||||||
config.ConnectionString = tenant.DBConnectionString;
|
|
||||||
config.IsNewTenant = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(config.TenantName))
|
|
||||||
{
|
|
||||||
config.SiteName = _name;
|
|
||||||
config.Aliases = _urls;
|
|
||||||
config.DefaultTheme = _themetype;
|
|
||||||
config.DefaultContainer = _containertype;
|
|
||||||
config.DefaultAdminContainer = _admincontainertype;
|
|
||||||
config.SiteTemplate = _sitetemplatetype;
|
|
||||||
|
|
||||||
ShowProgressIndicator();
|
|
||||||
|
|
||||||
var installation = await InstallationService.Install(config);
|
|
||||||
if (installation.Success)
|
|
||||||
{
|
|
||||||
var aliasname = config.Aliases.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0];
|
|
||||||
var uri = new Uri(NavigationManager.Uri);
|
|
||||||
NavigationManager.NavigateTo(uri.Scheme + "://" + aliasname, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await logger.LogError("Error Creating Site {Error}", installation.Message);
|
|
||||||
AddModuleMessage(installation.Message, MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(string.Format(Localizer["Message.SiteName.InUse"], string.Join(", ", duplicates.ToArray())), MessageType.Warning);
|
AddModuleMessage(Localizer["Error.TenantName.Exists"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.Tenant"], MessageType.Warning);
|
var tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantid));
|
||||||
|
if (tenant != null)
|
||||||
|
{
|
||||||
|
config.TenantName = tenant.Name;
|
||||||
|
config.DatabaseType = tenant.DBType;
|
||||||
|
config.ConnectionString = tenant.DBConnectionString;
|
||||||
|
config.IsNewTenant = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(config.TenantName))
|
||||||
|
{
|
||||||
|
config.SiteName = _name;
|
||||||
|
config.Aliases = _urls;
|
||||||
|
config.DefaultTheme = _themetype;
|
||||||
|
config.DefaultContainer = _containertype;
|
||||||
|
config.DefaultAdminContainer = _admincontainertype;
|
||||||
|
config.SiteTemplate = _sitetemplatetype;
|
||||||
|
|
||||||
|
ShowProgressIndicator();
|
||||||
|
|
||||||
|
var installation = await InstallationService.Install(config);
|
||||||
|
if (installation.Success)
|
||||||
|
{
|
||||||
|
var aliasname = config.Aliases.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0];
|
||||||
|
var uri = new Uri(NavigationManager.Uri);
|
||||||
|
NavigationManager.NavigateTo(uri.Scheme + "://" + aliasname, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await logger.LogError("Error Creating Site {Error}", installation.Message);
|
||||||
|
AddModuleMessage(installation.Message, MessageType.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
AddModuleMessage(string.Format(Localizer["Message.SiteName.InUse"], string.Join(", ", duplicates.ToArray())), MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Required.Tenant"], MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,51 +12,51 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<ActionLink Action="Add" Text="Add Site" ResourceKey="AddSite" />
|
<ActionLink Action="Add" Text="Add Site" ResourceKey="AddSite" />
|
||||||
|
|
||||||
<Pager Items="@_sites">
|
<Pager Items="@_sites">
|
||||||
<Header>
|
<Header>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th>@SharedLocalizer["Name"]</th>
|
<th>@SharedLocalizer["Name"]</th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><button type="button" class="btn btn-primary" @onclick="@(async () => Edit(context.Name))">@SharedLocalizer["Edit"]</button></td>
|
<td><button type="button" class="btn btn-primary" @onclick="@(async () => Edit(context.Name))">@SharedLocalizer["Edit"]</button></td>
|
||||||
<td><button type="button" class="btn btn-secondary" @onclick="@(async () => Browse(context.Name))">@Localizer["Browse"]</button></td>
|
<td><button type="button" class="btn btn-secondary" @onclick="@(async () => Browse(context.Name))">@Localizer["Browse"]</button></td>
|
||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<Alias> _sites;
|
private List<Alias> _sites;
|
||||||
private string _scheme;
|
private string _scheme;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
var uri = new Uri(NavigationManager.Uri);
|
||||||
|
_scheme = uri.Scheme + "://";
|
||||||
|
|
||||||
|
var aliases = await AliasService.GetAliasesAsync();
|
||||||
|
_sites = new List<Alias>();
|
||||||
|
foreach (Alias alias in aliases)
|
||||||
|
{
|
||||||
|
if (!_sites.Exists(item => item.TenantId == alias.TenantId && item.SiteId == alias.SiteId))
|
||||||
{
|
{
|
||||||
var uri = new Uri(NavigationManager.Uri);
|
_sites.Add(alias);
|
||||||
_scheme = uri.Scheme + "://";
|
|
||||||
|
|
||||||
var aliases = await AliasService.GetAliasesAsync();
|
|
||||||
_sites = new List<Alias>();
|
|
||||||
foreach (Alias alias in aliases)
|
|
||||||
{
|
|
||||||
if (!_sites.Exists(item => item.TenantId == alias.TenantId && item.SiteId == alias.SiteId))
|
|
||||||
{
|
|
||||||
_sites.Add(alias);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Edit(string name)
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo(_scheme + name + "/admin/site/?reload");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Browse(string name)
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo(_scheme + name + "/?reload");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Edit(string name)
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo(_scheme + name + "/admin/site/?reload");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Browse(string name)
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo(_scheme + name + "/?reload");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,158 +13,158 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="tenant" HelpText="Select the tenant for the SQL server" ResourceKey="Tenant">Tenant: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="tenant" class="form-select" value="@_tenantid" @onchange="(e => TenantChanged(e))">
|
||||||
|
<option value="-1"><@Localizer["Tenant.Select"]></option>
|
||||||
|
@foreach (Tenant tenant in _tenants)
|
||||||
|
{
|
||||||
|
<option value="@tenant.TenantId">@tenant.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (_tenantid != "-1")
|
||||||
|
{
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="tenant" HelpText="Select the tenant for the SQL server" ResourceKey="Tenant">Tenant: </Label>
|
<Label Class="col-sm-3" For="database" HelpText="The database for the tenant" ResourceKey="Database">Database: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<select id="tenant" class="form-select" value="@_tenantid" @onchange="(e => TenantChanged(e))">
|
<input id="database" class="form-control" @bind="@_database" readonly />
|
||||||
<option value="-1"><@Localizer["Tenant.Select"]></option>
|
|
||||||
@foreach (Tenant tenant in _tenants)
|
|
||||||
{
|
|
||||||
<option value="@tenant.TenantId">@tenant.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@if (_tenantid != "-1")
|
<div class="row mb-1 align-items-center">
|
||||||
{
|
<Label Class="col-sm-3" For="connectionstring" HelpText="The connection information for the database" ResourceKey="ConnectionString">Connection: </Label>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="col-sm-9">
|
||||||
<Label Class="col-sm-3" For="database" HelpText="The database for the tenant" ResourceKey="Database">Database: </Label>
|
<textarea id="connectionstring" class="form-control" @bind="@_connectionstring" rows="2" readonly></textarea>
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="database" class="form-control" @bind="@_database" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
</div>
|
||||||
<Label Class="col-sm-3" For="connectionstring" HelpText="The connection information for the database" ResourceKey="ConnectionString">Connection: </Label>
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<Label Class="col-sm-3" For="sqlQeury" HelpText="Enter the query for the SQL server" ResourceKey="SqlQuery">SQL Query: </Label>
|
||||||
<textarea id="connectionstring" class="form-control" @bind="@_connectionstring" rows="2" readonly></textarea>
|
<div class="col-sm-9">
|
||||||
</div>
|
<textarea id="sqlQeury" class="form-control" @bind="@_sql" rows="5"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
</div>
|
||||||
<Label Class="col-sm-3" For="sqlQeury" HelpText="Enter the query for the SQL server" ResourceKey="SqlQuery">SQL Query: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea id="sqlQeury" class="form-control" @bind="@_sql" rows="5"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<button type="button" class="btn btn-success" @onclick="Execute">@Localizer["Execute"]</button>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
@if (!string.IsNullOrEmpty(_results))
|
|
||||||
{
|
|
||||||
@((MarkupString)_results)
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
}
|
}
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<button type="button" class="btn btn-success" @onclick="Execute">@Localizer["Execute"]</button>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
@if (!string.IsNullOrEmpty(_results))
|
||||||
|
{
|
||||||
|
@((MarkupString)_results)
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<Tenant> _tenants;
|
private List<Tenant> _tenants;
|
||||||
private string _tenantid = "-1";
|
private string _tenantid = "-1";
|
||||||
private string _database = string.Empty;
|
private string _database = string.Empty;
|
||||||
private string _connectionstring = string.Empty;
|
private string _connectionstring = string.Empty;
|
||||||
private string _sql = string.Empty;
|
private string _sql = string.Empty;
|
||||||
private string _results = string.Empty;
|
private string _results = string.Empty;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_tenants = await TenantService.GetTenantsAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Tenants {Error}", ex.Message);
|
||||||
|
AddModuleMessage(ex.Message, MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void TenantChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_tenantid = (string)e.Value;
|
||||||
|
var tenants = await TenantService.GetTenantsAsync();
|
||||||
|
var _databases = await DatabaseService.GetDatabasesAsync();
|
||||||
|
var tenant = tenants.Find(item => item.TenantId == int.Parse(_tenantid));
|
||||||
|
if (tenant != null)
|
||||||
{
|
{
|
||||||
try
|
_database = _databases.Find(item => item.DBType == tenant.DBType)?.Name;
|
||||||
{
|
_connectionstring = tenant.DBConnectionString;
|
||||||
_tenants = await TenantService.GetTenantsAsync();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Tenants {Error}", ex.Message);
|
|
||||||
AddModuleMessage(ex.Message, MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Tenant {TenantId} {Error}", _tenantid, ex.Message);
|
||||||
|
AddModuleMessage(ex.Message, MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async void TenantChanged(ChangeEventArgs e)
|
private async Task Execute()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_tenantid != "-1" && !string.IsNullOrEmpty(_sql))
|
||||||
{
|
{
|
||||||
try
|
var sqlquery = new SqlQuery { TenantId = int.Parse(_tenantid), Query = _sql };
|
||||||
{
|
sqlquery = await SqlService.ExecuteQueryAsync(sqlquery);
|
||||||
_tenantid = (string)e.Value;
|
_results = DisplayResults(sqlquery.Results);
|
||||||
var tenants = await TenantService.GetTenantsAsync();
|
AddModuleMessage(Localizer["Success.QueryExecuted"], MessageType.Success);
|
||||||
var _databases = await DatabaseService.GetDatabasesAsync();
|
|
||||||
var tenant = tenants.Find(item => item.TenantId == int.Parse(_tenantid));
|
|
||||||
if (tenant != null)
|
|
||||||
{
|
|
||||||
_database = _databases.Find(item => item.DBType == tenant.DBType)?.Name;
|
|
||||||
_connectionstring = tenant.DBConnectionString;
|
|
||||||
}
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Tenant {TenantId} {Error}", _tenantid, ex.Message);
|
|
||||||
AddModuleMessage(ex.Message, MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private async Task Execute()
|
|
||||||
{
|
{
|
||||||
try
|
AddModuleMessage(Localizer["Message.Required.Tenant"], MessageType.Warning);
|
||||||
{
|
|
||||||
if (_tenantid != "-1" && !string.IsNullOrEmpty(_sql))
|
|
||||||
{
|
|
||||||
var sqlquery = new SqlQuery { TenantId = int.Parse(_tenantid), Query = _sql };
|
|
||||||
sqlquery = await SqlService.ExecuteQueryAsync(sqlquery);
|
|
||||||
_results = DisplayResults(sqlquery.Results);
|
|
||||||
AddModuleMessage(Localizer["Success.QueryExecuted"], MessageType.Success);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Required.Tenant"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Executing SQL Query {SQL} {Error}", _sql, ex.Message);
|
|
||||||
AddModuleMessage(ex.Message, MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string DisplayResults(List<Dictionary<string, string>> results)
|
|
||||||
{
|
|
||||||
var table = string.Empty;
|
|
||||||
foreach (Dictionary<string, string> item in results)
|
|
||||||
{
|
|
||||||
if (table == string.Empty)
|
|
||||||
{
|
|
||||||
table = "<div class=\"table-responsive\">";
|
|
||||||
table += "<table class=\"table table-bordered\"><thead><tr>";
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, string> kvp in item)
|
|
||||||
{
|
|
||||||
table += "<th scope=\"col\">" + kvp.Key + "</th>";
|
|
||||||
}
|
|
||||||
|
|
||||||
table += "</tr></thead><tbody>";
|
|
||||||
}
|
|
||||||
|
|
||||||
table += "<tr>";
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, string> kvp in item)
|
|
||||||
{
|
|
||||||
table += "<td>" + kvp.Value + "</td>";
|
|
||||||
}
|
|
||||||
|
|
||||||
table += "</tr>";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (table != string.Empty)
|
|
||||||
{
|
|
||||||
table += "</tbody></table></div>";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
table = Localizer["Return.NoResult"];
|
|
||||||
}
|
|
||||||
|
|
||||||
return table;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Executing SQL Query {SQL} {Error}", _sql, ex.Message);
|
||||||
|
AddModuleMessage(ex.Message, MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string DisplayResults(List<Dictionary<string, string>> results)
|
||||||
|
{
|
||||||
|
var table = string.Empty;
|
||||||
|
foreach (Dictionary<string, string> item in results)
|
||||||
|
{
|
||||||
|
if (table == string.Empty)
|
||||||
|
{
|
||||||
|
table = "<div class=\"table-responsive\">";
|
||||||
|
table += "<table class=\"table table-bordered\"><thead><tr>";
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, string> kvp in item)
|
||||||
|
{
|
||||||
|
table += "<th scope=\"col\">" + kvp.Key + "</th>";
|
||||||
|
}
|
||||||
|
|
||||||
|
table += "</tr></thead><tbody>";
|
||||||
|
}
|
||||||
|
|
||||||
|
table += "<tr>";
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, string> kvp in item)
|
||||||
|
{
|
||||||
|
table += "<td>" + kvp.Value + "</td>";
|
||||||
|
}
|
||||||
|
|
||||||
|
table += "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (table != string.Empty)
|
||||||
|
{
|
||||||
|
table += "</tbody></table></div>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
table = Localizer["Return.NoResult"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -124,105 +124,105 @@
|
||||||
</TabStrip>
|
</TabStrip>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private string _version = string.Empty;
|
private string _version = string.Empty;
|
||||||
private string _clrversion = string.Empty;
|
private string _clrversion = string.Empty;
|
||||||
private string _osversion = string.Empty;
|
private string _osversion = string.Empty;
|
||||||
private string _serverpath = string.Empty;
|
private string _serverpath = string.Empty;
|
||||||
private string _servertime = string.Empty;
|
private string _servertime = string.Empty;
|
||||||
private string _installationid = string.Empty;
|
private string _installationid = string.Empty;
|
||||||
|
|
||||||
private string _runtime = string.Empty;
|
private string _runtime = string.Empty;
|
||||||
private string _rendermode = string.Empty;
|
private string _rendermode = string.Empty;
|
||||||
private string _detailederrors = string.Empty;
|
private string _detailederrors = string.Empty;
|
||||||
private string _logginglevel = string.Empty;
|
private string _logginglevel = string.Empty;
|
||||||
private string _swagger = string.Empty;
|
private string _swagger = string.Empty;
|
||||||
private string _packageservice = string.Empty;
|
private string _packageservice = string.Empty;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
_version = Constants.Version;
|
||||||
|
|
||||||
|
Dictionary<string, string> systeminfo = await SystemService.GetSystemInfoAsync();
|
||||||
|
if (systeminfo != null)
|
||||||
{
|
{
|
||||||
_version = Constants.Version;
|
_clrversion = systeminfo["clrversion"];
|
||||||
|
_osversion = systeminfo["osversion"];
|
||||||
|
_serverpath = systeminfo["serverpath"];
|
||||||
|
_servertime = systeminfo["servertime"];
|
||||||
|
_installationid = systeminfo["installationid"];
|
||||||
|
|
||||||
Dictionary<string, string> systeminfo = await SystemService.GetSystemInfoAsync();
|
_runtime = systeminfo["runtime"];
|
||||||
if (systeminfo != null)
|
_rendermode = systeminfo["rendermode"];
|
||||||
{
|
_detailederrors = systeminfo["detailederrors"];
|
||||||
_clrversion = systeminfo["clrversion"];
|
_logginglevel = systeminfo["logginglevel"];
|
||||||
_osversion = systeminfo["osversion"];
|
_swagger = systeminfo["swagger"];
|
||||||
_serverpath = systeminfo["serverpath"];
|
_packageservice = systeminfo["packageservice"];
|
||||||
_servertime = systeminfo["servertime"];
|
|
||||||
_installationid = systeminfo["installationid"];
|
|
||||||
|
|
||||||
_runtime = systeminfo["runtime"];
|
|
||||||
_rendermode = systeminfo["rendermode"];
|
|
||||||
_detailederrors = systeminfo["detailederrors"];
|
|
||||||
_logginglevel = systeminfo["logginglevel"];
|
|
||||||
_swagger = systeminfo["swagger"];
|
|
||||||
_packageservice = systeminfo["packageservice"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SaveConfig()
|
|
||||||
{
|
|
||||||
validated = true;
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var settings = new Dictionary<string, string>();
|
|
||||||
settings.Add("runtime", _runtime);
|
|
||||||
settings.Add("rendermode", _rendermode);
|
|
||||||
settings.Add("detailederrors", _detailederrors);
|
|
||||||
settings.Add("logginglevel", _logginglevel);
|
|
||||||
settings.Add("swagger", _swagger);
|
|
||||||
settings.Add("packageservice", _packageservice);
|
|
||||||
await SystemService.UpdateSystemInfoAsync(settings);
|
|
||||||
AddModuleMessage(Localizer["Success.UpdateConfig.Restart"], MessageType.Success);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Saving Configuration");
|
|
||||||
AddModuleMessage(Localizer["Error.UpdateConfig"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task RestartApplication()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ShowProgressIndicator();
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
await interop.RedirectBrowser(NavigateUrl(""), 20);
|
|
||||||
await InstallationService.RestartAsync();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Restarting Application");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task RegisterChecked(ChangeEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if ((bool)e.Value)
|
|
||||||
{
|
|
||||||
await InstallationService.RegisterAsync(PageState.User.Email);
|
|
||||||
AddModuleMessage(Localizer["Success.Register"], MessageType.Success);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error On Register");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task SaveConfig()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var settings = new Dictionary<string, string>();
|
||||||
|
settings.Add("runtime", _runtime);
|
||||||
|
settings.Add("rendermode", _rendermode);
|
||||||
|
settings.Add("detailederrors", _detailederrors);
|
||||||
|
settings.Add("logginglevel", _logginglevel);
|
||||||
|
settings.Add("swagger", _swagger);
|
||||||
|
settings.Add("packageservice", _packageservice);
|
||||||
|
await SystemService.UpdateSystemInfoAsync(settings);
|
||||||
|
AddModuleMessage(Localizer["Success.UpdateConfig.Restart"], MessageType.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Saving Configuration");
|
||||||
|
AddModuleMessage(Localizer["Error.UpdateConfig"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RestartApplication()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ShowProgressIndicator();
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
await interop.RedirectBrowser(NavigateUrl(""), 20);
|
||||||
|
await InstallationService.RestartAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Restarting Application");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RegisterChecked(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ((bool)e.Value)
|
||||||
|
{
|
||||||
|
await InstallationService.RegisterAsync(PageState.User.Email);
|
||||||
|
AddModuleMessage(Localizer["Success.Register"], MessageType.Success);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error On Register");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,157 +7,157 @@
|
||||||
@inject IStringLocalizer<Add> Localizer
|
@inject IStringLocalizer<Add> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabPanel Name="Download" ResourceKey="Download">
|
<TabPanel Name="Download" ResourceKey="Download">
|
||||||
<ModuleMessage Type="MessageType.Info" Message="Download one or more themes from the list below. Once you are ready click Install to complete the installation."></ModuleMessage>
|
<ModuleMessage Type="MessageType.Info" Message="Download one or more themes from the list below. Once you are ready click Install to complete the installation."></ModuleMessage>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<input id="search" class="form-control" placeholder="@SharedLocalizer["Search.Hint"]" @bind="@_search" />
|
<input id="search" class="form-control" placeholder="@SharedLocalizer["Search.Hint"]" @bind="@_search" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<button type="button" class="btn btn-primary" @onclick="Search">@SharedLocalizer["Search"]</button>
|
<button type="button" class="btn btn-primary" @onclick="Search">@SharedLocalizer["Search"]</button>
|
||||||
<button type="button" class="btn btn-secondary" @onclick="Reset">@SharedLocalizer["Reset"]</button>
|
<button type="button" class="btn btn-secondary" @onclick="Reset">@SharedLocalizer["Reset"]</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@if (_packages != null)
|
@if (_packages != null)
|
||||||
|
{
|
||||||
|
if (_packages.Count > 0)
|
||||||
{
|
{
|
||||||
if (_packages.Count > 0)
|
<Pager Items="@_packages">
|
||||||
{
|
<Row>
|
||||||
<Pager Items="@_packages">
|
<td>
|
||||||
<Row>
|
<h3 style="display: inline;"><a href="@context.ProductUrl" target="_new">@context.Name</a></h3> @SharedLocalizer["Search.By"]: <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
||||||
<td>
|
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
||||||
<h3 style="display: inline;"><a href="@context.ProductUrl" target="_new">@context.Name</a></h3> @SharedLocalizer["Search.By"]: <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
<strong>@(String.Format("{0:n0}", context.Downloads))</strong> @SharedLocalizer["Search.Downloads"] | @SharedLocalizer["Search.Released"]: <strong>@context.ReleaseDate.ToString("MMM dd, yyyy")</strong> | @SharedLocalizer["Search.Version"]: <strong>@context.Version</strong> | @SharedLocalizer["Search.Source"]: <strong>@context.PackageUrl</strong>
|
||||||
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
</td>
|
||||||
<strong>@(String.Format("{0:n0}", context.Downloads))</strong> @SharedLocalizer["Search.Downloads"] | @SharedLocalizer["Search.Released"]: <strong>@context.ReleaseDate.ToString("MMM dd, yyyy")</strong> | @SharedLocalizer["Search.Version"]: <strong>@context.Version</strong> | @SharedLocalizer["Search.Source"]: <strong>@context.PackageUrl</strong>
|
<td style="vertical-align: middle;">
|
||||||
</td>
|
<button type="button" class="btn btn-primary" @onclick=@(async () => await DownloadTheme(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
||||||
<td style="vertical-align: middle;">
|
</td>
|
||||||
<button type="button" class="btn btn-primary" @onclick=@(async () => await DownloadTheme(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
</Row>
|
||||||
</td>
|
</Pager>
|
||||||
</Row>
|
|
||||||
</Pager>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<br />
|
|
||||||
<div class="mx-auto text-center">
|
|
||||||
@Localizer["Search.NoResults"]
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</TabPanel>
|
else
|
||||||
<TabPanel Name="Upload" ResourceKey="Upload">
|
{
|
||||||
<div class="container">
|
<br />
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="mx-auto text-center">
|
||||||
<Label Class="col-sm-3" HelpText="Upload one or more theme packages. Once they are uploaded click Install to complete the installation." ResourceKey="Theme">Theme: </Label>
|
@Localizer["Search.NoResults"]
|
||||||
<div class="col-sm-9">
|
</div>
|
||||||
<FileManager Filter="nupkg" ShowFiles="false" Folder="Packages" UploadMultiple="@true" />
|
}
|
||||||
|
}
|
||||||
|
</TabPanel>
|
||||||
|
<TabPanel Name="Upload" ResourceKey="Upload">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" HelpText="Upload one or more theme packages. Once they are uploaded click Install to complete the installation." ResourceKey="Theme">Theme: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<FileManager Filter="nupkg" ShowFiles="false" Folder="Packages" UploadMultiple="@true" />
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</TabPanel>
|
</div>
|
||||||
</TabStrip>
|
</TabPanel>
|
||||||
|
</TabStrip>
|
||||||
|
|
||||||
<button type="button" class="btn btn-success" @onclick="InstallThemes">@SharedLocalizer["Install"]</button>
|
<button type="button" class="btn btn-success" @onclick="InstallThemes">@SharedLocalizer["Install"]</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<Package> _packages;
|
private List<Package> _packages;
|
||||||
private string _search = "";
|
private string _search = "";
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
await LoadThemes();
|
||||||
{
|
|
||||||
await LoadThemes();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Packages {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Package.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
private async Task LoadThemes()
|
|
||||||
{
|
{
|
||||||
var themes = await ThemeService.GetThemesAsync();
|
await logger.LogError(ex, "Error Loading Packages {Error}", ex.Message);
|
||||||
_packages = await PackageService.GetPackagesAsync("theme", _search);
|
AddModuleMessage(Localizer["Error.Package.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_packages != null)
|
private async Task LoadThemes()
|
||||||
|
{
|
||||||
|
var themes = await ThemeService.GetThemesAsync();
|
||||||
|
_packages = await PackageService.GetPackagesAsync("theme", _search);
|
||||||
|
|
||||||
|
if (_packages != null)
|
||||||
|
{
|
||||||
|
foreach (Package package in _packages.ToArray())
|
||||||
{
|
{
|
||||||
foreach (Package package in _packages.ToArray())
|
if (themes.Exists(item => item.PackageName == package.PackageId))
|
||||||
{
|
{
|
||||||
if (themes.Exists(item => item.PackageName == package.PackageId))
|
_packages.Remove(package);
|
||||||
{
|
|
||||||
_packages.Remove(package);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Search()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await LoadThemes();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error On Search");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Reset()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_search = "";
|
|
||||||
await LoadThemes();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error On Reset");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task InstallThemes()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await ThemeService.InstallThemesAsync();
|
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Theme.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Installing Theme");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DownloadTheme(string packageid, string version)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
|
||||||
await logger.LogInformation("Theme {ThemeName} {Version} Downloaded Successfully", packageid, version);
|
|
||||||
AddModuleMessage(Localizer["Success.Theme.Download"], MessageType.Success);
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Downloading Module {ThemeName} {Version}", packageid, version);
|
|
||||||
AddModuleMessage(Localizer["Error.Theme.Download"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task Search()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await LoadThemes();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error On Search");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Reset()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_search = "";
|
||||||
|
await LoadThemes();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error On Reset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InstallThemes()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ThemeService.InstallThemesAsync();
|
||||||
|
AddModuleMessage(string.Format(Localizer["Success.Theme.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Installing Theme");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DownloadTheme(string packageid, string version)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
||||||
|
await logger.LogInformation("Theme {ThemeName} {Version} Downloaded Successfully", packageid, version);
|
||||||
|
AddModuleMessage(Localizer["Success.Theme.Download"], MessageType.Success);
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Downloading Module {ThemeName} {Version}", packageid, version);
|
||||||
|
AddModuleMessage(Localizer["Error.Theme.Download"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="owner" HelpText="Enter the name of the organization who is developing this theme. It should not contain spaces or punctuation." ResourceKey="OwnerName">Owner Name: </Label>
|
<Label Class="col-sm-3" For="owner" HelpText="Enter the name of the organization who is developing this theme. It should not contain spaces or punctuation." ResourceKey="OwnerName">Owner Name: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="owner" class="form-control" @bind="@_owner" maxlength="256" required/>
|
<input id="owner" class="form-control" @bind="@_owner" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="module" HelpText="Enter a name for this theme. It should not contain spaces or punctuation." ResourceKey="ThemeName">Theme Name: </Label>
|
<Label Class="col-sm-3" For="module" HelpText="Enter a name for this theme. It should not contain spaces or punctuation." ResourceKey="ThemeName">Theme Name: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="module" class="form-control" @bind="@_theme" maxlength="256" required/>
|
<input id="module" class="form-control" @bind="@_theme" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
@ -68,92 +68,92 @@
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private string _owner = string.Empty;
|
private string _owner = string.Empty;
|
||||||
private string _theme = string.Empty;
|
private string _theme = string.Empty;
|
||||||
private List<Template> _templates;
|
private List<Template> _templates;
|
||||||
private string _template = "-";
|
private string _template = "-";
|
||||||
private string[] _versions;
|
private string[] _versions;
|
||||||
private string _reference = Constants.Version;
|
private string _reference = Constants.Version;
|
||||||
private string _minversion = "2.0.0";
|
private string _minversion = "2.0.0";
|
||||||
private string _location = string.Empty;
|
private string _location = string.Empty;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_templates = await ThemeService.GetThemeTemplatesAsync();
|
||||||
|
_versions = Constants.ReleaseVersions.Split(',').Where(item => Version.Parse(item).CompareTo(Version.Parse("2.0.0")) >= 0).ToArray();
|
||||||
|
AddModuleMessage(Localizer["Info.Theme.CreatorIntent"], MessageType.Info);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Theme Creator");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CreateTheme()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
if (IsValid(_owner) && IsValid(_theme) && _owner != _theme && _template != "-")
|
||||||
{
|
{
|
||||||
_templates = await ThemeService.GetThemeTemplatesAsync();
|
var theme = new Theme { Owner = _owner, Name = _theme, Template = _template, Version = _reference };
|
||||||
_versions = Constants.ReleaseVersions.Split(',').Where(item => Version.Parse(item).CompareTo(Version.Parse("2.0.0")) >= 0).ToArray();
|
theme = await ThemeService.CreateThemeAsync(theme);
|
||||||
AddModuleMessage(Localizer["Info.Theme.CreatorIntent"], MessageType.Info);
|
GetLocation();
|
||||||
}
|
AddModuleMessage(string.Format(Localizer["Success.Theme.Create"], NavigateUrl("admin/system")), MessageType.Success);
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Theme Creator");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task CreateTheme()
|
|
||||||
{
|
|
||||||
validated = true;
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (IsValid(_owner) && IsValid(_theme) && _owner != _theme && _template != "-")
|
|
||||||
{
|
|
||||||
var theme = new Theme { Owner = _owner, Name = _theme, Template = _template, Version = _reference };
|
|
||||||
theme = await ThemeService.CreateThemeAsync(theme);
|
|
||||||
GetLocation();
|
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Theme.Create"], NavigateUrl("admin/system")), MessageType.Success);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Required.ValidName"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Creating Theme");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
AddModuleMessage(Localizer["Message.Required.ValidName"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
private bool IsValid(string name)
|
|
||||||
{
|
{
|
||||||
// must contain letters, underscores and digits and first character must be letter or underscore
|
await logger.LogError(ex, "Error Creating Theme");
|
||||||
return !string.IsNullOrEmpty(name) && name.ToLower() != "theme" && Regex.IsMatch(name, "^[A-Za-z_][A-Za-z0-9_]*$");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TemplateChanged(ChangeEventArgs e)
|
|
||||||
{
|
|
||||||
_template = (string)e.Value;
|
|
||||||
_minversion = "2.0.0";
|
|
||||||
if (_template != "-")
|
|
||||||
{
|
|
||||||
var template = _templates.FirstOrDefault(item => item.Name == _template);
|
|
||||||
_minversion = template.Version;
|
|
||||||
}
|
|
||||||
GetLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void GetLocation()
|
|
||||||
{
|
|
||||||
_location = string.Empty;
|
|
||||||
if (_owner != "" && _theme != "" && _template != "-")
|
|
||||||
{
|
|
||||||
var template = _templates.FirstOrDefault(item => item.Name == _template);
|
|
||||||
_location = template.Location + _owner + "." + _theme;
|
|
||||||
|
|
||||||
}
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsValid(string name)
|
||||||
|
{
|
||||||
|
// must contain letters, underscores and digits and first character must be letter or underscore
|
||||||
|
return !string.IsNullOrEmpty(name) && name.ToLower() != "theme" && Regex.IsMatch(name, "^[A-Za-z_][A-Za-z0-9_]*$");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TemplateChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
_template = (string)e.Value;
|
||||||
|
_minversion = "2.0.0";
|
||||||
|
if (_template != "-")
|
||||||
|
{
|
||||||
|
var template = _templates.FirstOrDefault(item => item.Name == _template);
|
||||||
|
_minversion = template.Version;
|
||||||
|
}
|
||||||
|
GetLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetLocation()
|
||||||
|
{
|
||||||
|
_location = string.Empty;
|
||||||
|
if (_owner != "" && _theme != "" && _template != "-")
|
||||||
|
{
|
||||||
|
var template = _templates.FirstOrDefault(item => item.Name == _template);
|
||||||
|
_location = template.Location + _owner + "." + _theme;
|
||||||
|
|
||||||
|
}
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,104 +13,104 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<ActionLink Action="Add" Text="Install Theme" />
|
<ActionLink Action="Add" Text="Install Theme" />
|
||||||
@((MarkupString)" ")
|
@((MarkupString)" ")
|
||||||
<ActionLink Action="Create" Text="Create Theme" ResourceKey="CreateTheme" Class="btn btn-secondary" />
|
<ActionLink Action="Create" Text="Create Theme" ResourceKey="CreateTheme" Class="btn btn-secondary" />
|
||||||
|
|
||||||
<Pager Items="@_themes">
|
<Pager Items="@_themes">
|
||||||
<Header>
|
<Header>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th scope="col">@SharedLocalizer["Name"]</th>
|
<th scope="col">@SharedLocalizer["Name"]</th>
|
||||||
<th scope="col">@SharedLocalizer["Version"]</th>
|
<th scope="col">@SharedLocalizer["Version"]</th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><ActionLink Action="View" Parameters="@($"name=" + WebUtility.UrlEncode(context.ThemeName))" ResourceKey="ViewTheme" /></td>
|
<td><ActionLink Action="View" Parameters="@($"name=" + WebUtility.UrlEncode(context.ThemeName))" ResourceKey="ViewTheme" /></td>
|
||||||
<td>
|
<td>
|
||||||
@if (context.AssemblyName != "Oqtane.Client")
|
@if (context.AssemblyName != "Oqtane.Client")
|
||||||
{
|
{
|
||||||
<ActionDialog Header="Delete Theme" Message="@string.Format(Localizer["Confirm.Theme.Delete"], context.Name)" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteTheme(context))" ResourceKey="DeleteTheme" />
|
<ActionDialog Header="Delete Theme" Message="@string.Format(Localizer["Confirm.Theme.Delete"], context.Name)" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteTheme(context))" ResourceKey="DeleteTheme" />
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
<td>@context.Version</td>
|
<td>@context.Version</td>
|
||||||
<td>
|
<td>
|
||||||
@if (UpgradeAvailable(context.PackageName, context.Version))
|
@if (UpgradeAvailable(context.PackageName, context.Version))
|
||||||
{
|
{
|
||||||
<button type="button" class="btn btn-success" @onclick=@(async () => await DownloadTheme(context.PackageName, context.Version))>@SharedLocalizer["Upgrade"]</button>
|
<button type="button" class="btn btn-success" @onclick=@(async () => await DownloadTheme(context.PackageName, context.Version))>@SharedLocalizer["Upgrade"]</button>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<Theme> _themes;
|
private List<Theme> _themes;
|
||||||
private List<Package> _packages;
|
private List<Package> _packages;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_themes = await ThemeService.GetThemesAsync();
|
||||||
|
_packages = await PackageService.GetPackagesAsync("theme");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (_themes == null)
|
||||||
{
|
{
|
||||||
try
|
await logger.LogError(ex, "Error Loading Themes {Error}", ex.Message);
|
||||||
{
|
AddModuleMessage(Localizer["Error.Theme.Load"], MessageType.Error);
|
||||||
_themes = await ThemeService.GetThemesAsync();
|
|
||||||
_packages = await PackageService.GetPackagesAsync("theme");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
if (_themes == null)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Themes {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Theme.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool UpgradeAvailable(string packagename, string version)
|
|
||||||
{
|
|
||||||
var upgradeavailable = false;
|
|
||||||
if (_packages != null)
|
|
||||||
{
|
|
||||||
var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault();
|
|
||||||
if (package != null)
|
|
||||||
{
|
|
||||||
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return upgradeavailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DownloadTheme(string packagename, string version)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await PackageService.DownloadPackageAsync(packagename, version, "Packages");
|
|
||||||
await logger.LogInformation("Theme Downloaded {ThemeName} {Version}", packagename, version);
|
|
||||||
await ThemeService.InstallThemesAsync();
|
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Theme.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Downloading Theme {ThemeName} {Version} {Error}", packagename, version, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Theme.Download"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DeleteTheme(Theme Theme)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await ThemeService.DeleteThemeAsync(Theme.ThemeName);
|
|
||||||
AddModuleMessage(Localizer["Success.Theme.Delete"], MessageType.Success);
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Page.Path, true));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Deleting Theme {Theme} {Error}", Theme, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Theme.Delete"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool UpgradeAvailable(string packagename, string version)
|
||||||
|
{
|
||||||
|
var upgradeavailable = false;
|
||||||
|
if (_packages != null)
|
||||||
|
{
|
||||||
|
var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault();
|
||||||
|
if (package != null)
|
||||||
|
{
|
||||||
|
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return upgradeavailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DownloadTheme(string packagename, string version)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await PackageService.DownloadPackageAsync(packagename, version, "Packages");
|
||||||
|
await logger.LogInformation("Theme Downloaded {ThemeName} {Version}", packagename, version);
|
||||||
|
await ThemeService.InstallThemesAsync();
|
||||||
|
AddModuleMessage(string.Format(Localizer["Success.Theme.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Downloading Theme {ThemeName} {Version} {Error}", packagename, version, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Theme.Download"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteTheme(Theme Theme)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ThemeService.DeleteThemeAsync(Theme.ThemeName);
|
||||||
|
AddModuleMessage(Localizer["Success.Theme.Delete"], MessageType.Success);
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(PageState.Page.Path, true));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Deleting Theme {Theme} {Error}", Theme, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Theme.Delete"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,84 +6,84 @@
|
||||||
@inject IStringLocalizer<View> Localizer
|
@inject IStringLocalizer<View> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="name" HelpText="The name of the theme" ResourceKey="Name">Name: </Label>
|
<Label Class="col-sm-3" For="name" HelpText="The name of the theme" ResourceKey="Name">Name: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="name" class="form-control" @bind="@_name" disabled />
|
<input id="name" class="form-control" @bind="@_name" disabled />
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="themename" HelpText="The internal name of the module" ResourceKey="InternalName">Internal Name: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="themename" class="form-control" @bind="@_themeName" disabled />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="version" HelpText="The version of the theme" ResourceKey="Version">Version: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="version" class="form-control" @bind="@_version" disabled />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="owner" HelpText="The owner or creator of the theme" ResourceKey="Owner">Owner: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="owner" class="form-control" @bind="@_owner" disabled />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="url" HelpText="The reference url of the theme" ResourceKey="ReferenceUrl">Reference Url: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="url" class="form-control" @bind="@_url" disabled />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="contact" HelpText="The contact for the theme" ResourceKey="Contact">Contact: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="contact" class="form-control" @bind="@_contact" disabled />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="license" HelpText="The license of the theme" ResourceKey="License">License: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea id="license" class="form-control" @bind="@_license" rows="5" disabled></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="themename" HelpText="The internal name of the module" ResourceKey="InternalName">Internal Name: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="themename" class="form-control" @bind="@_themeName" disabled />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="version" HelpText="The version of the theme" ResourceKey="Version">Version: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="version" class="form-control" @bind="@_version" disabled />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="owner" HelpText="The owner or creator of the theme" ResourceKey="Owner">Owner: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="owner" class="form-control" @bind="@_owner" disabled />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="url" HelpText="The reference url of the theme" ResourceKey="ReferenceUrl">Reference Url: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="url" class="form-control" @bind="@_url" disabled />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="contact" HelpText="The contact for the theme" ResourceKey="Contact">Contact: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="contact" class="form-control" @bind="@_contact" disabled />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="license" HelpText="The license of the theme" ResourceKey="License">License: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<textarea id="license" class="form-control" @bind="@_license" rows="5" disabled></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _themeName = "";
|
private string _themeName = "";
|
||||||
private string _name;
|
private string _name;
|
||||||
private string _version;
|
private string _version;
|
||||||
private string _owner = "";
|
private string _owner = "";
|
||||||
private string _url = "";
|
private string _url = "";
|
||||||
private string _contact = "";
|
private string _contact = "";
|
||||||
private string _license = "";
|
private string _license = "";
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
_themeName = WebUtility.UrlDecode(PageState.QueryString["name"]);
|
||||||
{
|
var themes = await ThemeService.GetThemesAsync();
|
||||||
_themeName = WebUtility.UrlDecode(PageState.QueryString["name"]);
|
var theme = themes.FirstOrDefault(item => item.ThemeName == _themeName);
|
||||||
var themes = await ThemeService.GetThemesAsync();
|
if (theme != null)
|
||||||
var theme = themes.FirstOrDefault(item => item.ThemeName == _themeName);
|
{
|
||||||
if (theme != null)
|
_name = theme.Name;
|
||||||
{
|
_version = theme.Version;
|
||||||
_name = theme.Name;
|
_owner = theme.Owner;
|
||||||
_version = theme.Version;
|
_url = theme.Url;
|
||||||
_owner = theme.Owner;
|
_contact = theme.Contact;
|
||||||
_url = theme.Url;
|
_license = theme.License;
|
||||||
_contact = theme.Contact;
|
}
|
||||||
_license = theme.License;
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
catch (Exception ex)
|
await logger.LogError(ex, "Error Loading Theme {ThemeName} {Error}", _themeName, ex.Message);
|
||||||
{
|
AddModuleMessage(Localizer["Error.Theme.Loading"], MessageType.Error);
|
||||||
await logger.LogError(ex, "Error Loading Theme {ThemeName} {Error}", _themeName, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Theme.Loading"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,92 +7,92 @@
|
||||||
@inject IStringLocalizer<Index> Localizer
|
@inject IStringLocalizer<Index> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabPanel Name="Download" ResourceKey="Download">
|
<TabPanel Name="Download" ResourceKey="Download">
|
||||||
@if (_package != null && _upgradeavailable)
|
@if (_package != null && _upgradeavailable)
|
||||||
{
|
{
|
||||||
<ModuleMessage Type="MessageType.Info" Message="Select The Download Button To Download The Framework Upgrade Package And Then Select Upgrade"></ModuleMessage>
|
<ModuleMessage Type="MessageType.Info" Message="Select The Download Button To Download The Framework Upgrade Package And Then Select Upgrade"></ModuleMessage>
|
||||||
<button type="button" class="btn btn-primary" @onclick=@(async () => await Download(Constants.PackageId, @_package.Version))>@SharedLocalizer["Download"] @_package.Version</button>
|
<button type="button" class="btn btn-primary" @onclick=@(async () => await Download(Constants.PackageId, @_package.Version))>@SharedLocalizer["Download"] @_package.Version</button>
|
||||||
<button type="button" class="btn btn-success" @onclick="Upgrade">@SharedLocalizer["Upgrade"]</button>
|
<button type="button" class="btn btn-success" @onclick="Upgrade">@SharedLocalizer["Upgrade"]</button>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<ModuleMessage Type="MessageType.Info" Message="Framework Is Already Up To Date"></ModuleMessage>
|
<ModuleMessage Type="MessageType.Info" Message="Framework Is Already Up To Date"></ModuleMessage>
|
||||||
}
|
}
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel Name="Upload" ResourceKey="Upload">
|
<TabPanel Name="Upload" ResourceKey="Upload">
|
||||||
<ModuleMessage Type="MessageType.Info" Message="Upload A Framework Package (Oqtane.Framework.version.nupkg) And Then Select Upgrade"></ModuleMessage>
|
<ModuleMessage Type="MessageType.Info" Message="Upload A Framework Package (Oqtane.Framework.version.nupkg) And Then Select Upgrade"></ModuleMessage>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" HelpText="Upload A Framework Package And Then Select Upgrade" ResourceKey="Framework">Framework: </Label>
|
<Label Class="col-sm-3" HelpText="Upload A Framework Package And Then Select Upgrade" ResourceKey="Framework">Framework: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<FileManager Filter="nupkg" ShowFiles="false" Folder="Packages" />
|
<FileManager Filter="nupkg" ShowFiles="false" Folder="Packages" />
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="btn btn-success" @onclick="Upgrade">@SharedLocalizer["Upgrade"]</button>
|
</div>
|
||||||
</TabPanel>
|
<button type="button" class="btn btn-success" @onclick="Upgrade">@SharedLocalizer["Upgrade"]</button>
|
||||||
</TabStrip>
|
</TabPanel>
|
||||||
|
</TabStrip>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private Package _package;
|
private Package _package;
|
||||||
private bool _upgradeavailable = false;
|
private bool _upgradeavailable = false;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
List<Package> packages = await PackageService.GetPackagesAsync("framework");
|
||||||
{
|
if (packages != null)
|
||||||
List<Package> packages = await PackageService.GetPackagesAsync("framework");
|
|
||||||
if (packages != null)
|
|
||||||
{
|
|
||||||
_package = packages.Where(item => item.PackageId.StartsWith(Constants.PackageId)).FirstOrDefault();
|
|
||||||
if (_package != null)
|
|
||||||
{
|
|
||||||
_upgradeavailable = (Version.Parse(_package.Version).CompareTo(Version.Parse(Constants.Version)) > 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_package = new Package { Name = Constants.PackageId, Version = Constants.Version };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// can be caused by no network connection
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Upgrade()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Info.Upgrade.Wait"], MessageType.Info);
|
_package = packages.Where(item => item.PackageId.StartsWith(Constants.PackageId)).FirstOrDefault();
|
||||||
ShowProgressIndicator();
|
if (_package != null)
|
||||||
var interop = new Interop(JSRuntime);
|
{
|
||||||
await interop.RedirectBrowser(NavigateUrl(), 10);
|
_upgradeavailable = (Version.Parse(_package.Version).CompareTo(Version.Parse(Constants.Version)) > 0);
|
||||||
await InstallationService.Upgrade();
|
}
|
||||||
}
|
else
|
||||||
catch (Exception ex)
|
{
|
||||||
{
|
_package = new Package { Name = Constants.PackageId, Version = Constants.Version };
|
||||||
await logger.LogError(ex, "Error Executing Upgrade {Error}", ex.Message);
|
}
|
||||||
AddModuleMessage(Localizer["Error.Upgrade.Execute"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
private async Task Download(string packageid, string version)
|
|
||||||
{
|
{
|
||||||
try
|
// can be caused by no network connection
|
||||||
{
|
|
||||||
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
|
||||||
await PackageService.DownloadPackageAsync(Constants.UpdaterPackageId, version, "Packages");
|
|
||||||
AddModuleMessage(Localizer["Success.Framework.Download"], MessageType.Success);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Downloading Framework Package {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Framework.Download"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task Upgrade()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Info.Upgrade.Wait"], MessageType.Info);
|
||||||
|
ShowProgressIndicator();
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
await interop.RedirectBrowser(NavigateUrl(), 10);
|
||||||
|
await InstallationService.Upgrade();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Executing Upgrade {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Upgrade.Execute"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Download(string packageid, string version)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
||||||
|
await PackageService.DownloadPackageAsync(Constants.UpdaterPackageId, version, "Packages");
|
||||||
|
AddModuleMessage(Localizer["Success.Framework.Download"], MessageType.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Downloading Framework Package {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Framework.Download"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -8,75 +8,75 @@
|
||||||
|
|
||||||
@if (PageState.User != null)
|
@if (PageState.User != null)
|
||||||
{
|
{
|
||||||
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="to" HelpText="Enter the username you wish to send a message to" ResourceKey="To">To: </Label>
|
<Label Class="col-sm-3" For="to" HelpText="Enter the username you wish to send a message to" ResourceKey="To">To: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="to" class="form-control" @bind="@username" maxlength="256" required/>
|
<input id="to" class="form-control" @bind="@username" maxlength="256" required />
|
||||||
</div> >
|
</div> >
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="subject" HelpText="Enter the subject of the message" ResourceKey="Subject">Subject: </Label>
|
<Label Class="col-sm-3" For="subject" HelpText="Enter the subject of the message" ResourceKey="Subject">Subject: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="subject" class="form-control" @bind="@subject" maxlength="256" required/>
|
<input id="subject" class="form-control" @bind="@subject" maxlength="256" required />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="message" HelpText="Enter the message" ResourceKey="Message">Message: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<textarea id="message" class="form-control" @bind="@body" rows="5" required />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<br />
|
||||||
<Label Class="col-sm-3" For="message" HelpText="Enter the message" ResourceKey="Message">Message: </Label>
|
<button type="button" class="btn btn-primary" @onclick="Send">@SharedLocalizer["Send"]</button>
|
||||||
<div class="col-sm-9">
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
<textarea id="message" class="form-control" @bind="@body" rows="5" required/>
|
</form>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<button type="button" class="btn btn-primary" @onclick="Send">@SharedLocalizer["Send"]</button>
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
</form>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private string username = "";
|
private string username = "";
|
||||||
private string subject = "";
|
private string subject = "";
|
||||||
private string body = "";
|
private string body = "";
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
|
||||||
|
|
||||||
public override string Title => "Send Notification";
|
public override string Title => "Send Notification";
|
||||||
|
|
||||||
private async Task Send()
|
private async Task Send()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
validated = true;
|
try
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
{
|
||||||
try
|
var user = await UserService.GetUserAsync(username, PageState.Site.SiteId);
|
||||||
|
if (user != null)
|
||||||
{
|
{
|
||||||
var user = await UserService.GetUserAsync(username, PageState.Site.SiteId);
|
var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, null);
|
||||||
if (user != null)
|
notification = await NotificationService.AddNotificationAsync(notification);
|
||||||
{
|
await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId);
|
||||||
var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, null);
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
notification = await NotificationService.AddNotificationAsync(notification);
|
|
||||||
await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId);
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message);
|
AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning);
|
||||||
AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -17,373 +17,373 @@ else
|
||||||
{
|
{
|
||||||
<br />
|
<br />
|
||||||
}
|
}
|
||||||
<TabStrip>
|
<TabStrip>
|
||||||
<TabPanel Name="Identity" ResourceKey="Identity">
|
<TabPanel Name="Identity" ResourceKey="Identity">
|
||||||
@if (PageState.User != null)
|
@if (PageState.User != null)
|
||||||
{
|
{
|
||||||
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="container">
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="username" HelpText="Your username. Note that this field can not be modified." ResourceKey="Username"></Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="username" class="form-control" @bind="@username" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="password" HelpText="If you wish to change your password you can enter it here. Please choose a sufficiently secure password." ResourceKey="Password"></Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="password" type="password" class="form-control" @bind="@password" autocomplete="new-password" maxlength="256" required />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="confirm" HelpText="If you are changing your password you must enter it again to confirm it matches" ResourceKey="Confirm"></Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="confirm" type="password" class="form-control" @bind="@confirm" autocomplete="new-password" maxlength="256" required />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="email" HelpText="Your email address where you wish to receive notifications" ResourceKey="Email"></Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="email" class="form-control" @bind="@email" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="displayname" HelpText="Your full name" ResourceKey="DisplayName"></Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="displayname" class="form-control" @bind="@displayname" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="@photofileid.ToString()" HelpText="A photo of yourself" ResourceKey="Photo"></Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<FileManager FileId="@photofileid" @ref="filemanager" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<button type="button" class="btn btn-success" @onclick="Save">@SharedLocalizer["Save"]</button>
|
|
||||||
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
|
||||||
</form>
|
|
||||||
}
|
|
||||||
</TabPanel>
|
|
||||||
<TabPanel Name="Profile" ResourceKey="Profile">
|
|
||||||
@if (profiles != null && settings != null)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
@foreach (Profile profile in profiles)
|
<Label Class="col-sm-3" For="username" HelpText="Your username. Note that this field can not be modified." ResourceKey="Username"></Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="username" class="form-control" @bind="@username" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="password" HelpText="If you wish to change your password you can enter it here. Please choose a sufficiently secure password." ResourceKey="Password"></Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="password" type="password" class="form-control" @bind="@password" autocomplete="new-password" maxlength="256" required />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="confirm" HelpText="If you are changing your password you must enter it again to confirm it matches" ResourceKey="Confirm"></Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="confirm" type="password" class="form-control" @bind="@confirm" autocomplete="new-password" maxlength="256" required />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="email" HelpText="Your email address where you wish to receive notifications" ResourceKey="Email"></Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="email" class="form-control" @bind="@email" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="displayname" HelpText="Your full name" ResourceKey="DisplayName"></Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="displayname" class="form-control" @bind="@displayname" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="@photofileid.ToString()" HelpText="A photo of yourself" ResourceKey="Photo"></Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<FileManager FileId="@photofileid" @ref="filemanager" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<button type="button" class="btn btn-success" @onclick="Save">@SharedLocalizer["Save"]</button>
|
||||||
|
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
||||||
|
</form>
|
||||||
|
}
|
||||||
|
</TabPanel>
|
||||||
|
<TabPanel Name="Profile" ResourceKey="Profile">
|
||||||
|
@if (profiles != null && settings != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
@foreach (Profile profile in profiles)
|
||||||
|
{
|
||||||
|
var p = profile;
|
||||||
|
if (!p.IsPrivate || UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
||||||
{
|
{
|
||||||
var p = profile;
|
if (p.Category != category)
|
||||||
if (!p.IsPrivate || UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
|
||||||
{
|
{
|
||||||
if (p.Category != category)
|
<div class="col text-center pb-2">
|
||||||
{
|
@p.Category
|
||||||
<div class="col text-center pb-2">
|
</div>
|
||||||
@p.Category
|
category = p.Category;
|
||||||
</div>
|
}
|
||||||
category = p.Category;
|
<div class="row mb-1 align-items-center">
|
||||||
}
|
<Label Class="col-sm-3" For="@p.Name" HelpText="@p.Description">@p.Title</Label>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="col-sm-9">
|
||||||
<Label Class="col-sm-3" For="@p.Name" HelpText="@p.Description">@p.Title</Label>
|
@if (!string.IsNullOrEmpty(p.Options))
|
||||||
<div class="col-sm-9">
|
{
|
||||||
@if (!string.IsNullOrEmpty(p.Options))
|
<select id="@p.Name" class="form-select" @onchange="@(e => ProfileChanged(e, p.Name))">
|
||||||
{
|
@foreach (var option in p.Options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
<select id="@p.Name" class="form-select" @onchange="@(e => ProfileChanged(e, p.Name))">
|
{
|
||||||
@foreach (var option in p.Options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
@if (GetProfileValue(p.Name, "") == option || (GetProfileValue(p.Name, "") == "" && p.DefaultValue == option))
|
||||||
{
|
{
|
||||||
@if (GetProfileValue(p.Name, "") == option || (GetProfileValue(p.Name, "") == "" && p.DefaultValue == option))
|
<option value="@option" selected>@option</option>
|
||||||
{
|
|
||||||
<option value="@option" selected>@option</option>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<option value="@option">@option</option>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</select>
|
else
|
||||||
|
{
|
||||||
|
<option value="@option">@option</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@if (p.IsRequired)
|
||||||
|
{
|
||||||
|
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" required @onchange="@(e => ProfileChanged(e, p.Name))" />
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@if (p.IsRequired)
|
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
|
||||||
{
|
|
||||||
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" required @onchange="@(e => ProfileChanged(e, p.Name))" />
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</div>
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
}
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="btn btn-success" @onclick="Save">@SharedLocalizer["Save"]</button>
|
</div>
|
||||||
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
<button type="button" class="btn btn-success" @onclick="Save">@SharedLocalizer["Save"]</button>
|
||||||
}
|
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
||||||
</TabPanel>
|
|
||||||
<TabPanel Name="Notifications" ResourceKey="Notifications">
|
|
||||||
@if (notifications != null)
|
|
||||||
{
|
|
||||||
<ActionLink Action="Add" Text="Send Notification" Security="SecurityAccessLevel.View" EditMode="false" ResourceKey="SendNotification" />
|
|
||||||
<br /><br />
|
|
||||||
@if (filter == "to")
|
|
||||||
{
|
|
||||||
<Pager Items="@notifications">
|
|
||||||
<Header>
|
|
||||||
<th style="width: 1px;"> </th>
|
|
||||||
<th style="width: 1px;"> </th>
|
|
||||||
<th>@Localizer["From"]</th>
|
|
||||||
<th>@Localizer["Subject"]</th>
|
|
||||||
<th>@Localizer["Received"]</th>
|
|
||||||
</Header>
|
|
||||||
<Row>
|
|
||||||
<td><ActionLink Action="View" Parameters="@($"id=" + context.NotificationId.ToString())" Security="SecurityAccessLevel.View" EditMode="false" ResourceKey="ViewNotification" /></td>
|
|
||||||
<td><ActionDialog Header="Delete Notification" Message="Are You Sure You Wish To Delete This Notification?" Action="Delete" Security="SecurityAccessLevel.View" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" EditMode="false" ResourceKey="DeleteNotification" /></td>
|
|
||||||
<td>@context.FromDisplayName</td>
|
|
||||||
<td>@context.Subject</td>
|
|
||||||
<td>@context.CreatedOn</td>
|
|
||||||
</Row>
|
|
||||||
<Detail>
|
|
||||||
<td colspan="2"></td>
|
|
||||||
<td colspan="3">
|
|
||||||
@{
|
|
||||||
string input = "___";
|
|
||||||
if (context.Body.Contains(input))
|
|
||||||
{
|
|
||||||
context.Body = context.Body.Split(input)[0];
|
|
||||||
context.Body = context.Body.Replace("\n", "");
|
|
||||||
context.Body = context.Body.Replace("\r", "");
|
|
||||||
} }
|
|
||||||
@(context.Body.Length > 100 ? (context.Body.Substring(0, 97) + "...") : context.Body)
|
|
||||||
</td>
|
|
||||||
</Detail>
|
|
||||||
</Pager>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<Pager Items="@notifications">
|
|
||||||
<Header>
|
|
||||||
<th> </th>
|
|
||||||
<th> </th>
|
|
||||||
<th>@Localizer["To"]</th>
|
|
||||||
<th>@Localizer["Subject"]</th>
|
|
||||||
<th>@Localizer["Sent"]</th>
|
|
||||||
</Header>
|
|
||||||
<Row>
|
|
||||||
<td><ActionLink Action="View" Parameters="@($"id=" + context.NotificationId.ToString())" Security="SecurityAccessLevel.View" EditMode="false" ResourceKey="ViewNotification" /></td>
|
|
||||||
<td><ActionDialog Header="Delete Notification" Message="Are You Sure You Wish To Delete This Notification?" Action="Delete" Security="SecurityAccessLevel.View" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" EditMode="false" ResourceKey="DeleteNotification" /></td>
|
|
||||||
<td>@context.ToDisplayName</td>
|
|
||||||
<td>@context.Subject</td>
|
|
||||||
<td>@context.CreatedOn</td>
|
|
||||||
</Row>
|
|
||||||
<Detail>
|
|
||||||
<td colspan="2"></td>
|
|
||||||
<td colspan="3">
|
|
||||||
@{
|
|
||||||
string input = "___";
|
|
||||||
if (context.Body.Contains(input))
|
|
||||||
{
|
|
||||||
context.Body = context.Body.Split(input)[0];
|
|
||||||
context.Body = context.Body.Replace("\n", "");
|
|
||||||
context.Body = context.Body.Replace("\r", "");
|
|
||||||
} }
|
|
||||||
@(context.Body.Length > 100 ? (context.Body.Substring(0, 97) + "...") : context.Body)
|
|
||||||
</td>
|
|
||||||
</Detail>
|
|
||||||
</Pager>
|
|
||||||
}
|
|
||||||
<br /><hr />
|
|
||||||
<select class="form-select" @onchange="(e => FilterChanged(e))">
|
|
||||||
<option value="to">@Localizer["Inbox"]</option>
|
|
||||||
<option value="from">@Localizer["Items.Sent"]</option>
|
|
||||||
</select>
|
|
||||||
}
|
|
||||||
</TabPanel>
|
|
||||||
</TabStrip>
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private ElementReference form;
|
|
||||||
private bool validated = false;
|
|
||||||
private string username = string.Empty;
|
|
||||||
private string password = string.Empty;
|
|
||||||
private string confirm = string.Empty;
|
|
||||||
private string email = string.Empty;
|
|
||||||
private string displayname = string.Empty;
|
|
||||||
private FileManager filemanager;
|
|
||||||
private int photofileid = -1;
|
|
||||||
private File photo = null;
|
|
||||||
private List<Profile> profiles;
|
|
||||||
private Dictionary<string, string> settings;
|
|
||||||
private string category = string.Empty;
|
|
||||||
private string filter = "to";
|
|
||||||
private List<Notification> notifications;
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
|
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (PageState.User != null)
|
|
||||||
{
|
|
||||||
username = PageState.User.Username;
|
|
||||||
email = PageState.User.Email;
|
|
||||||
displayname = PageState.User.DisplayName;
|
|
||||||
|
|
||||||
if (PageState.User.PhotoFileId != null)
|
|
||||||
{
|
|
||||||
photofileid = PageState.User.PhotoFileId.Value;
|
|
||||||
photo = await FileService.GetFileAsync(photofileid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
photofileid = -1;
|
|
||||||
photo = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
profiles = await ProfileService.GetProfilesAsync(ModuleState.SiteId);
|
|
||||||
settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
|
|
||||||
|
|
||||||
await LoadNotificationsAsync();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.User.NoLogIn"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading User Profile {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Profile.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
</TabPanel>
|
||||||
private async Task LoadNotificationsAsync()
|
<TabPanel Name="Notifications" ResourceKey="Notifications">
|
||||||
|
@if (notifications != null)
|
||||||
{
|
{
|
||||||
notifications = await NotificationService.GetNotificationsAsync(PageState.Site.SiteId, filter, PageState.User.UserId);
|
<ActionLink Action="Add" Text="Send Notification" Security="SecurityAccessLevel.View" EditMode="false" ResourceKey="SendNotification" />
|
||||||
notifications = notifications.Where(item => item.DeletedBy != PageState.User.Username).ToList();
|
<br /><br />
|
||||||
}
|
@if (filter == "to")
|
||||||
|
|
||||||
private string GetProfileValue(string SettingName, string DefaultValue)
|
|
||||||
=> SettingService.GetSetting(settings, SettingName, DefaultValue);
|
|
||||||
|
|
||||||
private async Task Save()
|
|
||||||
{
|
|
||||||
validated = true;
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
{
|
||||||
try
|
<Pager Items="@notifications">
|
||||||
{
|
<Header>
|
||||||
if (username != string.Empty && email != string.Empty && ValidateProfiles())
|
<th style="width: 1px;"> </th>
|
||||||
{
|
<th style="width: 1px;"> </th>
|
||||||
if (password == confirm)
|
<th>@Localizer["From"]</th>
|
||||||
{
|
<th>@Localizer["Subject"]</th>
|
||||||
var user = PageState.User;
|
<th>@Localizer["Received"]</th>
|
||||||
user.Username = username;
|
</Header>
|
||||||
user.Password = password;
|
<Row>
|
||||||
user.Email = email;
|
<td><ActionLink Action="View" Parameters="@($"id=" + context.NotificationId.ToString())" Security="SecurityAccessLevel.View" EditMode="false" ResourceKey="ViewNotification" /></td>
|
||||||
user.DisplayName = (displayname == string.Empty ? username : displayname);
|
<td><ActionDialog Header="Delete Notification" Message="Are You Sure You Wish To Delete This Notification?" Action="Delete" Security="SecurityAccessLevel.View" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" EditMode="false" ResourceKey="DeleteNotification" /></td>
|
||||||
user.PhotoFileId = filemanager.GetFileId();
|
<td>@context.FromDisplayName</td>
|
||||||
if (user.PhotoFileId == -1)
|
<td>@context.Subject</td>
|
||||||
{
|
<td>@context.CreatedOn</td>
|
||||||
user.PhotoFileId = null;
|
</Row>
|
||||||
}
|
<Detail>
|
||||||
|
<td colspan="2"></td>
|
||||||
await UserService.UpdateUserAsync(user);
|
<td colspan="3">
|
||||||
await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId);
|
@{
|
||||||
await logger.LogInformation("User Profile Saved");
|
string input = "___";
|
||||||
|
if (context.Body.Contains(input))
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
{
|
||||||
}
|
context.Body = context.Body.Split(input)[0];
|
||||||
else
|
context.Body = context.Body.Replace("\n", "");
|
||||||
{
|
context.Body = context.Body.Replace("\r", "");
|
||||||
AddModuleMessage(Localizer["Message.Password.Invalid"], MessageType.Warning);
|
} }
|
||||||
}
|
@(context.Body.Length > 100 ? (context.Body.Substring(0, 97) + "...") : context.Body)
|
||||||
}
|
</td>
|
||||||
else
|
</Detail>
|
||||||
{
|
</Pager>
|
||||||
AddModuleMessage(Localizer["Message.Required.ProfileInfo"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Saving User Profile {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Profile.Save"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
<Pager Items="@notifications">
|
||||||
|
<Header>
|
||||||
|
<th> </th>
|
||||||
|
<th> </th>
|
||||||
|
<th>@Localizer["To"]</th>
|
||||||
|
<th>@Localizer["Subject"]</th>
|
||||||
|
<th>@Localizer["Sent"]</th>
|
||||||
|
</Header>
|
||||||
|
<Row>
|
||||||
|
<td><ActionLink Action="View" Parameters="@($"id=" + context.NotificationId.ToString())" Security="SecurityAccessLevel.View" EditMode="false" ResourceKey="ViewNotification" /></td>
|
||||||
|
<td><ActionDialog Header="Delete Notification" Message="Are You Sure You Wish To Delete This Notification?" Action="Delete" Security="SecurityAccessLevel.View" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" EditMode="false" ResourceKey="DeleteNotification" /></td>
|
||||||
|
<td>@context.ToDisplayName</td>
|
||||||
|
<td>@context.Subject</td>
|
||||||
|
<td>@context.CreatedOn</td>
|
||||||
|
</Row>
|
||||||
|
<Detail>
|
||||||
|
<td colspan="2"></td>
|
||||||
|
<td colspan="3">
|
||||||
|
@{
|
||||||
|
string input = "___";
|
||||||
|
if (context.Body.Contains(input))
|
||||||
|
{
|
||||||
|
context.Body = context.Body.Split(input)[0];
|
||||||
|
context.Body = context.Body.Replace("\n", "");
|
||||||
|
context.Body = context.Body.Replace("\r", "");
|
||||||
|
} }
|
||||||
|
@(context.Body.Length > 100 ? (context.Body.Substring(0, 97) + "...") : context.Body)
|
||||||
|
</td>
|
||||||
|
</Detail>
|
||||||
|
</Pager>
|
||||||
}
|
}
|
||||||
|
<br /><hr />
|
||||||
|
<select class="form-select" @onchange="(e => FilterChanged(e))">
|
||||||
|
<option value="to">@Localizer["Inbox"]</option>
|
||||||
|
<option value="from">@Localizer["Items.Sent"]</option>
|
||||||
|
</select>
|
||||||
}
|
}
|
||||||
|
</TabPanel>
|
||||||
|
</TabStrip>
|
||||||
|
|
||||||
private bool ValidateProfiles()
|
@code {
|
||||||
|
private ElementReference form;
|
||||||
|
private bool validated = false;
|
||||||
|
private string username = string.Empty;
|
||||||
|
private string password = string.Empty;
|
||||||
|
private string confirm = string.Empty;
|
||||||
|
private string email = string.Empty;
|
||||||
|
private string displayname = string.Empty;
|
||||||
|
private FileManager filemanager;
|
||||||
|
private int photofileid = -1;
|
||||||
|
private File photo = null;
|
||||||
|
private List<Profile> profiles;
|
||||||
|
private Dictionary<string, string> settings;
|
||||||
|
private string category = string.Empty;
|
||||||
|
private string filter = "to";
|
||||||
|
private List<Notification> notifications;
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
bool valid = true;
|
if (PageState.User != null)
|
||||||
foreach (Profile profile in profiles)
|
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)) && !string.IsNullOrEmpty(profile.DefaultValue))
|
username = PageState.User.Username;
|
||||||
{
|
email = PageState.User.Email;
|
||||||
settings = SettingService.SetSetting(settings, profile.Name, profile.DefaultValue);
|
displayname = PageState.User.DisplayName;
|
||||||
}
|
|
||||||
if (!profile.IsPrivate || UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
|
||||||
{
|
|
||||||
if (profile.IsRequired && string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)))
|
|
||||||
{
|
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Cancel()
|
if (PageState.User.PhotoFileId != null)
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ProfileChanged(ChangeEventArgs e, string SettingName)
|
|
||||||
{
|
|
||||||
var value = (string)e.Value;
|
|
||||||
settings = SettingService.SetSetting(settings, SettingName, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Delete(Notification Notification)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!Notification.IsDeleted)
|
|
||||||
{
|
{
|
||||||
Notification.IsDeleted = true;
|
photofileid = PageState.User.PhotoFileId.Value;
|
||||||
await NotificationService.UpdateNotificationAsync(Notification);
|
photo = await FileService.GetFileAsync(photofileid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await NotificationService.DeleteNotificationAsync(Notification.NotificationId);
|
photofileid = -1;
|
||||||
|
photo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
await logger.LogInformation("Notification Deleted {Notification}", Notification);
|
profiles = await ProfileService.GetProfilesAsync(ModuleState.SiteId);
|
||||||
|
settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
|
||||||
|
|
||||||
await LoadNotificationsAsync();
|
await LoadNotificationsAsync();
|
||||||
StateHasChanged();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.User.NoLogIn"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading User Profile {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Profile.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadNotificationsAsync()
|
||||||
|
{
|
||||||
|
notifications = await NotificationService.GetNotificationsAsync(PageState.Site.SiteId, filter, PageState.User.UserId);
|
||||||
|
notifications = notifications.Where(item => item.DeletedBy != PageState.User.Username).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetProfileValue(string SettingName, string DefaultValue)
|
||||||
|
=> SettingService.GetSetting(settings, SettingName, DefaultValue);
|
||||||
|
|
||||||
|
private async Task Save()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (username != string.Empty && email != string.Empty && ValidateProfiles())
|
||||||
|
{
|
||||||
|
if (password == confirm)
|
||||||
|
{
|
||||||
|
var user = PageState.User;
|
||||||
|
user.Username = username;
|
||||||
|
user.Password = password;
|
||||||
|
user.Email = email;
|
||||||
|
user.DisplayName = (displayname == string.Empty ? username : displayname);
|
||||||
|
user.PhotoFileId = filemanager.GetFileId();
|
||||||
|
if (user.PhotoFileId == -1)
|
||||||
|
{
|
||||||
|
user.PhotoFileId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
await UserService.UpdateUserAsync(user);
|
||||||
|
await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId);
|
||||||
|
await logger.LogInformation("User Profile Saved");
|
||||||
|
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Password.Invalid"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Required.ProfileInfo"], MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Deleting Notification {Notification} {Error}", Notification, ex.Message);
|
await logger.LogError(ex, "Error Saving User Profile {Error}", ex.Message);
|
||||||
AddModuleMessage(ex.Message, MessageType.Error);
|
AddModuleMessage(Localizer["Error.Profile.Save"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private async void FilterChanged(ChangeEventArgs e)
|
|
||||||
{
|
{
|
||||||
filter = (string)e.Value;
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ValidateProfiles()
|
||||||
|
{
|
||||||
|
bool valid = true;
|
||||||
|
foreach (Profile profile in profiles)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)) && !string.IsNullOrEmpty(profile.DefaultValue))
|
||||||
|
{
|
||||||
|
settings = SettingService.SetSetting(settings, profile.Name, profile.DefaultValue);
|
||||||
|
}
|
||||||
|
if (!profile.IsPrivate || UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
||||||
|
{
|
||||||
|
if (profile.IsRequired && string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)))
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Cancel()
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProfileChanged(ChangeEventArgs e, string SettingName)
|
||||||
|
{
|
||||||
|
var value = (string)e.Value;
|
||||||
|
settings = SettingService.SetSetting(settings, SettingName, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Delete(Notification Notification)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!Notification.IsDeleted)
|
||||||
|
{
|
||||||
|
Notification.IsDeleted = true;
|
||||||
|
await NotificationService.UpdateNotificationAsync(Notification);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await NotificationService.DeleteNotificationAsync(Notification.NotificationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
await logger.LogInformation("Notification Deleted {Notification}", Notification);
|
||||||
await LoadNotificationsAsync();
|
await LoadNotificationsAsync();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Deleting Notification {Notification} {Error}", Notification, ex.Message);
|
||||||
|
AddModuleMessage(ex.Message, MessageType.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void FilterChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
filter = (string)e.Value;
|
||||||
|
|
||||||
|
await LoadNotificationsAsync();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -8,191 +8,191 @@
|
||||||
|
|
||||||
@if (PageState.User != null)
|
@if (PageState.User != null)
|
||||||
{
|
{
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<label Class="col-sm-3">@Localizer["Title"] </label>
|
<label Class="col-sm-3">@Localizer["Title"] </label>
|
||||||
@if (title == "From")
|
|
||||||
{
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<input class="form-control" @bind="@username" readonly />
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@if (title == "To")
|
|
||||||
{
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<input class="form-control" @bind="@username"/>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<label Class="col-sm-3">@Localizer["Subject"] </label>
|
|
||||||
@if (title == "From")
|
|
||||||
{
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<input class="form-control" @bind="@subject" readonly />
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@if (title == "To")
|
|
||||||
{
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<input class="form-control" @bind="@subject"/>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="container">
|
|
||||||
@if (title == "From")
|
@if (title == "From")
|
||||||
{
|
{
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="col-sm-3">
|
||||||
<label class="col-sm-3">@Localizer["Date"] </label>
|
<input class="form-control" @bind="@username" readonly />
|
||||||
<div class="col-sm-9">
|
|
||||||
<input class="form-control" @bind="@createdon" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@if (title == "From")
|
|
||||||
{
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<label class="col-sm-3">@Localizer["Message"] </label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea class="form-control" @bind="@body" rows="5" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
}
|
|
||||||
@if (title == "To")
|
@if (title == "To")
|
||||||
{
|
{
|
||||||
|
<div class="col-sm-3">
|
||||||
<div class="row mb-1 align-items-center">
|
<input class="form-control" @bind="@username" />
|
||||||
<label class="col-sm-3">@Localizer["Message"] </label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea class="form-control" @bind="@body" rows="5" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<label Class="col-sm-3">@Localizer["Subject"] </label>
|
||||||
@if (reply != string.Empty)
|
@if (title == "From")
|
||||||
{
|
|
||||||
<button type="button" class="btn btn-primary" @onclick="Send">@SharedLocalizer["Send"]</button>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (title == "From")
|
|
||||||
{
|
{
|
||||||
<button type="button" class="btn btn-primary" @onclick="Reply">@Localizer["Reply"]</button>
|
<div class="col-sm-3">
|
||||||
|
<input class="form-control" @bind="@subject" readonly />
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
}
|
@if (title == "To")
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
{
|
||||||
<br />
|
<div class="col-sm-3">
|
||||||
<br />
|
<input class="form-control" @bind="@subject" />
|
||||||
@if (title == "To")
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
@if (title == "From")
|
||||||
{
|
{
|
||||||
<div class="control-group">
|
<div class="row mb-1 align-items-center">
|
||||||
<label class="control-label">@Localizer["OriginalMessage"] </label>
|
<label class="col-sm-3">@Localizer["Date"] </label>
|
||||||
<textarea class="form-control" @bind="@reply" rows="5" readonly />
|
<div class="col-sm-9">
|
||||||
|
<input class="form-control" @bind="@createdon" readonly />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
@if (title == "From")
|
||||||
|
{
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<label class="col-sm-3">@Localizer["Message"] </label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<textarea class="form-control" @bind="@body" rows="5" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@code {
|
}
|
||||||
private int notificationid;
|
@if (title == "To")
|
||||||
private string title = string.Empty;
|
{
|
||||||
private string username = "";
|
|
||||||
private string subject = string.Empty;
|
|
||||||
private string createdon = string.Empty;
|
|
||||||
private string body = string.Empty;
|
|
||||||
private string reply = string.Empty;
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
|
<div class="row mb-1 align-items-center">
|
||||||
public override string Title => "View Notification";
|
<label class="col-sm-3">@Localizer["Message"] </label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<textarea class="form-control" @bind="@body" rows="5" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
notificationid = Int32.Parse(PageState.QueryString["id"]);
|
|
||||||
Notification notification = await NotificationService.GetNotificationAsync(notificationid);
|
|
||||||
if (notification != null)
|
|
||||||
{
|
|
||||||
int userid = -1;
|
|
||||||
if (notification.ToUserId == PageState.User.UserId)
|
|
||||||
{
|
|
||||||
title = "From";
|
|
||||||
if (notification.FromUserId != null)
|
|
||||||
{
|
|
||||||
userid = notification.FromUserId.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
title = "To";
|
|
||||||
if (notification.ToUserId != null)
|
|
||||||
{
|
|
||||||
userid = notification.ToUserId.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (userid != -1)
|
|
||||||
{
|
|
||||||
var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
username = user.Username;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (username == "")
|
|
||||||
{
|
|
||||||
username = "System";
|
|
||||||
}
|
|
||||||
subject = notification.Subject;
|
|
||||||
createdon = notification.CreatedOn.ToString();
|
|
||||||
body = notification.Body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Users {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.User.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Reply()
|
|
||||||
{
|
|
||||||
title = "To";
|
|
||||||
if (!subject.Contains("RE:"))
|
|
||||||
{
|
|
||||||
subject = "RE: " + subject;
|
|
||||||
}
|
|
||||||
reply = body;
|
|
||||||
body = "\n\n____________________________________________\nSent: " + createdon + "\nSubject: " + subject + "\n\n" + body;
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Send()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var user = await UserService.GetUserAsync(username, PageState.Site.SiteId);
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, notificationid);
|
|
||||||
notification = await NotificationService.AddNotificationAsync(notification);
|
|
||||||
await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId);
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@if (reply != string.Empty)
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-primary" @onclick="Send">@SharedLocalizer["Send"]</button>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (title == "From")
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-primary" @onclick="Reply">@Localizer["Reply"]</button>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
@if (title == "To")
|
||||||
|
{
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label">@Localizer["OriginalMessage"] </label>
|
||||||
|
<textarea class="form-control" @bind="@reply" rows="5" readonly />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private int notificationid;
|
||||||
|
private string title = string.Empty;
|
||||||
|
private string username = "";
|
||||||
|
private string subject = string.Empty;
|
||||||
|
private string createdon = string.Empty;
|
||||||
|
private string body = string.Empty;
|
||||||
|
private string reply = string.Empty;
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
|
||||||
|
public override string Title => "View Notification";
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
notificationid = Int32.Parse(PageState.QueryString["id"]);
|
||||||
|
Notification notification = await NotificationService.GetNotificationAsync(notificationid);
|
||||||
|
if (notification != null)
|
||||||
|
{
|
||||||
|
int userid = -1;
|
||||||
|
if (notification.ToUserId == PageState.User.UserId)
|
||||||
|
{
|
||||||
|
title = "From";
|
||||||
|
if (notification.FromUserId != null)
|
||||||
|
{
|
||||||
|
userid = notification.FromUserId.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
title = "To";
|
||||||
|
if (notification.ToUserId != null)
|
||||||
|
{
|
||||||
|
userid = notification.ToUserId.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (userid != -1)
|
||||||
|
{
|
||||||
|
var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
username = user.Username;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (username == "")
|
||||||
|
{
|
||||||
|
username = "System";
|
||||||
|
}
|
||||||
|
subject = notification.Subject;
|
||||||
|
createdon = notification.CreatedOn.ToString();
|
||||||
|
body = notification.Body;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Users {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.User.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Reply()
|
||||||
|
{
|
||||||
|
title = "To";
|
||||||
|
if (!subject.Contains("RE:"))
|
||||||
|
{
|
||||||
|
subject = "RE: " + subject;
|
||||||
|
}
|
||||||
|
reply = body;
|
||||||
|
body = "\n\n____________________________________________\nSent: " + createdon + "\nSubject: " + subject + "\n\n" + body;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Send()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var user = await UserService.GetUserAsync(username, PageState.Site.SiteId);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, notificationid);
|
||||||
|
notification = await NotificationService.AddNotificationAsync(notification);
|
||||||
|
await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId);
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,31 +16,31 @@
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="username" HelpText="A unique username for a user. Note that this field can not be modified once it is saved." ResourceKey="Username"></Label>
|
<Label Class="col-sm-3" For="username" HelpText="A unique username for a user. Note that this field can not be modified once it is saved." ResourceKey="Username"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="username" class="form-control" @bind="@username" maxlength="256" required/>
|
<input id="username" class="form-control" @bind="@username" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="password" HelpText="The user's password. Please choose a password which is sufficiently secure." ResourceKey="Password"></Label>
|
<Label Class="col-sm-3" For="password" HelpText="The user's password. Please choose a password which is sufficiently secure." ResourceKey="Password"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="password" type="password" class="form-control" @bind="@password" maxlength="256" required/>
|
<input id="password" type="password" class="form-control" @bind="@password" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="confirm" HelpText="Please enter the password again to confirm it matches with the value above" ResourceKey="Confirm"></Label>
|
<Label Class="col-sm-3" For="confirm" HelpText="Please enter the password again to confirm it matches with the value above" ResourceKey="Confirm"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="confirm" type="password" class="form-control" @bind="@confirm" maxlength="256" required/>
|
<input id="confirm" type="password" class="form-control" @bind="@confirm" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="email" HelpText="The email address where the user will receive notifications" ResourceKey="Email"></Label>
|
<Label Class="col-sm-3" For="email" HelpText="The email address where the user will receive notifications" ResourceKey="Email"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="email" class="form-control" @bind="@email" maxlength="256" required/>
|
<input id="email" class="form-control" @bind="@email" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="displayname" HelpText="The full name of the user" ResourceKey="DisplayName"></Label>
|
<Label Class="col-sm-3" For="displayname" HelpText="The full name of the user" ResourceKey="DisplayName"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="displayname" class="form-control" @bind="@displayname" maxlength="256" required/>
|
<input id="displayname" class="form-control" @bind="@displayname" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -88,123 +88,123 @@
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
|
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private string username = string.Empty;
|
private string username = string.Empty;
|
||||||
private string password = string.Empty;
|
private string password = string.Empty;
|
||||||
private string confirm = string.Empty;
|
private string confirm = string.Empty;
|
||||||
private string email = string.Empty;
|
private string email = string.Empty;
|
||||||
private string displayname = string.Empty;
|
private string displayname = string.Empty;
|
||||||
private List<Profile> profiles;
|
private List<Profile> profiles;
|
||||||
private Dictionary<string, string> settings;
|
private Dictionary<string, string> settings;
|
||||||
private string category = string.Empty;
|
private string category = string.Empty;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
profiles = await ProfileService.GetProfilesAsync(ModuleState.SiteId);
|
||||||
|
settings = new Dictionary<string, string>();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading User Profile {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Profile.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetProfileValue(string SettingName, string DefaultValue)
|
||||||
|
=> SettingService.GetSetting(settings, SettingName, DefaultValue);
|
||||||
|
|
||||||
|
private async Task SaveUser()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
profiles = await ProfileService.GetProfilesAsync(ModuleState.SiteId);
|
if (username != string.Empty && password != string.Empty && confirm != string.Empty && email != string.Empty && ValidateProfiles())
|
||||||
settings = new Dictionary<string, string>();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading User Profile {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Profile.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetProfileValue(string SettingName, string DefaultValue)
|
|
||||||
=> SettingService.GetSetting(settings, SettingName, DefaultValue);
|
|
||||||
|
|
||||||
private async Task SaveUser()
|
|
||||||
{
|
|
||||||
validated = true;
|
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if (username != string.Empty && password != string.Empty && confirm != string.Empty && email != string.Empty && ValidateProfiles())
|
if (password == confirm)
|
||||||
{
|
{
|
||||||
if (password == confirm)
|
var user = await UserService.GetUserAsync(username, PageState.Site.SiteId);
|
||||||
|
if (user == null)
|
||||||
{
|
{
|
||||||
var user = await UserService.GetUserAsync(username, PageState.Site.SiteId);
|
user = new User();
|
||||||
if (user == null)
|
user.SiteId = PageState.Site.SiteId;
|
||||||
|
user.Username = username;
|
||||||
|
user.Password = password;
|
||||||
|
user.Email = email;
|
||||||
|
user.DisplayName = string.IsNullOrWhiteSpace(displayname) ? username : displayname;
|
||||||
|
user.PhotoFileId = null;
|
||||||
|
|
||||||
|
user = await UserService.AddUserAsync(user);
|
||||||
|
|
||||||
|
if (user != null)
|
||||||
{
|
{
|
||||||
user = new User();
|
await SettingService.UpdateUserSettingsAsync(settings, user.UserId);
|
||||||
user.SiteId = PageState.Site.SiteId;
|
await logger.LogInformation("User Created {User}", user);
|
||||||
user.Username = username;
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
user.Password = password;
|
|
||||||
user.Email = email;
|
|
||||||
user.DisplayName = string.IsNullOrWhiteSpace(displayname) ? username : displayname;
|
|
||||||
user.PhotoFileId = null;
|
|
||||||
|
|
||||||
user = await UserService.AddUserAsync(user);
|
|
||||||
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
await SettingService.UpdateUserSettingsAsync(settings, user.UserId);
|
|
||||||
await logger.LogInformation("User Created {User}", user);
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await logger.LogError("Error Adding User {Username} {Email}", username, email);
|
|
||||||
AddModuleMessage(Localizer["Error.User.AddCheckPass"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Username.Exists"], MessageType.Warning);
|
await logger.LogError("Error Adding User {Username} {Email}", username, email);
|
||||||
|
AddModuleMessage(Localizer["Error.User.AddCheckPass"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning);
|
AddModuleMessage(Localizer["Message.Username.Exists"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.ProfileInfo"], MessageType.Warning);
|
AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", username, email, ex.Message);
|
AddModuleMessage(Localizer["Message.Required.ProfileInfo"], MessageType.Warning);
|
||||||
AddModuleMessage(Localizer["Error.User.Add"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", username, email, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.User.Add"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private bool ValidateProfiles()
|
|
||||||
{
|
{
|
||||||
bool valid = true;
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
foreach (Profile profile in profiles)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)) && !string.IsNullOrEmpty(profile.DefaultValue))
|
|
||||||
{
|
|
||||||
settings = SettingService.SetSetting(settings, profile.Name, profile.DefaultValue);
|
|
||||||
}
|
|
||||||
if (profile.IsRequired && string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)))
|
|
||||||
{
|
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return valid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProfileChanged(ChangeEventArgs e, string SettingName)
|
|
||||||
{
|
|
||||||
var value = (string)e.Value;
|
|
||||||
settings = SettingService.SetSetting(settings, SettingName, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool ValidateProfiles()
|
||||||
|
{
|
||||||
|
bool valid = true;
|
||||||
|
foreach (Profile profile in profiles)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)) && !string.IsNullOrEmpty(profile.DefaultValue))
|
||||||
|
{
|
||||||
|
settings = SettingService.SetSetting(settings, profile.Name, profile.DefaultValue);
|
||||||
|
}
|
||||||
|
if (profile.IsRequired && string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)))
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProfileChanged(ChangeEventArgs e, string SettingName)
|
||||||
|
{
|
||||||
|
var value = (string)e.Value;
|
||||||
|
settings = SettingService.SetSetting(settings, SettingName, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -31,25 +31,25 @@ else
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="password" HelpText="The user's password. Please choose a password which is sufficiently secure." ResourceKey="Password"></Label>
|
<Label Class="col-sm-3" For="password" HelpText="The user's password. Please choose a password which is sufficiently secure." ResourceKey="Password"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="password" type="password" class="form-control" @bind="@password" maxlength="256" required/>
|
<input id="password" type="password" class="form-control" @bind="@password" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="confirm" HelpText="Please enter the password again to confirm it matches with the value above" ResourceKey="Confirm"></Label>
|
<Label Class="col-sm-3" For="confirm" HelpText="Please enter the password again to confirm it matches with the value above" ResourceKey="Confirm"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="confirm" type="password" class="form-control" @bind="@confirm" maxlength="256" required/>
|
<input id="confirm" type="password" class="form-control" @bind="@confirm" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="email" HelpText="The email address where the user will receive notifications" ResourceKey="Email"></Label>
|
<Label Class="col-sm-3" For="email" HelpText="The email address where the user will receive notifications" ResourceKey="Email"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="email" class="form-control" @bind="@email" maxlength="256" required/>
|
<input id="email" class="form-control" @bind="@email" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="displayname" HelpText="The full name of the user" ResourceKey="DisplayName"></Label>
|
<Label Class="col-sm-3" For="displayname" HelpText="The full name of the user" ResourceKey="DisplayName"></Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="displayname" class="form-control" @bind="@displayname" maxlength="256" required/>
|
<input id="displayname" class="form-control" @bind="@displayname" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
|
@ -113,153 +113,153 @@ else
|
||||||
<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>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private int userid;
|
private int userid;
|
||||||
private string username = string.Empty;
|
private string username = string.Empty;
|
||||||
private string password = string.Empty;
|
private string password = string.Empty;
|
||||||
private string confirm = string.Empty;
|
private string confirm = string.Empty;
|
||||||
private string email = string.Empty;
|
private string email = string.Empty;
|
||||||
private string displayname = string.Empty;
|
private string displayname = string.Empty;
|
||||||
private FileManager filemanager;
|
private FileManager filemanager;
|
||||||
private int photofileid = -1;
|
private int photofileid = -1;
|
||||||
private File photo = null;
|
private File photo = null;
|
||||||
private List<Profile> profiles;
|
private List<Profile> profiles;
|
||||||
private Dictionary<string, string> settings;
|
private Dictionary<string, string> settings;
|
||||||
private string category = string.Empty;
|
private string category = string.Empty;
|
||||||
private string createdby;
|
private string createdby;
|
||||||
private DateTime createdon;
|
private DateTime createdon;
|
||||||
private string modifiedby;
|
private string modifiedby;
|
||||||
private DateTime modifiedon;
|
private DateTime modifiedon;
|
||||||
private string deletedby;
|
private string deletedby;
|
||||||
private DateTime? deletedon;
|
private DateTime? deletedon;
|
||||||
private string isdeleted;
|
private string isdeleted;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// OnParametersSetAsync is called when the edit modal is closed - in which case there is no id parameter
|
||||||
|
if (PageState.QueryString.ContainsKey("id"))
|
||||||
|
{
|
||||||
|
profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
|
||||||
|
userid = Int32.Parse(PageState.QueryString["id"]);
|
||||||
|
var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
username = user.Username;
|
||||||
|
email = user.Email;
|
||||||
|
displayname = user.DisplayName;
|
||||||
|
if (user.PhotoFileId != null)
|
||||||
|
{
|
||||||
|
photofileid = user.PhotoFileId.Value;
|
||||||
|
photo = await FileService.GetFileAsync(photofileid);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
photofileid = -1;
|
||||||
|
photo = null;
|
||||||
|
}
|
||||||
|
settings = await SettingService.GetUserSettingsAsync(user.UserId);
|
||||||
|
createdby = user.CreatedBy;
|
||||||
|
createdon = user.CreatedOn;
|
||||||
|
modifiedby = user.ModifiedBy;
|
||||||
|
modifiedon = user.ModifiedOn;
|
||||||
|
deletedby = user.DeletedBy;
|
||||||
|
deletedon = user.DeletedOn;
|
||||||
|
isdeleted = user.IsDeleted.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading User {UserId} {Error}", userid, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.User.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetProfileValue(string SettingName, string DefaultValue)
|
||||||
|
=> SettingService.GetSetting(settings, SettingName, DefaultValue);
|
||||||
|
|
||||||
|
private async Task SaveUser()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// OnParametersSetAsync is called when the edit modal is closed - in which case there is no id parameter
|
if (username != string.Empty && email != string.Empty && ValidateProfiles())
|
||||||
if (PageState.QueryString.ContainsKey("id"))
|
|
||||||
{
|
{
|
||||||
profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
|
if (password == confirm)
|
||||||
userid = Int32.Parse(PageState.QueryString["id"]);
|
|
||||||
var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
|
||||||
if (user != null)
|
|
||||||
{
|
{
|
||||||
username = user.Username;
|
var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
||||||
email = user.Email;
|
user.SiteId = PageState.Site.SiteId;
|
||||||
displayname = user.DisplayName;
|
user.Username = username;
|
||||||
if (user.PhotoFileId != null)
|
user.Password = password;
|
||||||
|
user.Email = email;
|
||||||
|
user.DisplayName = string.IsNullOrWhiteSpace(displayname) ? username : displayname;
|
||||||
|
user.PhotoFileId = null;
|
||||||
|
user.PhotoFileId = filemanager.GetFileId();
|
||||||
|
if (user.PhotoFileId == -1)
|
||||||
{
|
{
|
||||||
photofileid = user.PhotoFileId.Value;
|
user.PhotoFileId = null;
|
||||||
photo = await FileService.GetFileAsync(photofileid);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
user.IsDeleted = (isdeleted == null ? true : Boolean.Parse(isdeleted));
|
||||||
photofileid = -1;
|
|
||||||
photo = null;
|
user = await UserService.UpdateUserAsync(user);
|
||||||
}
|
await SettingService.UpdateUserSettingsAsync(settings, user.UserId);
|
||||||
settings = await SettingService.GetUserSettingsAsync(user.UserId);
|
await logger.LogInformation("User Saved {User}", user);
|
||||||
createdby = user.CreatedBy;
|
|
||||||
createdon = user.CreatedOn;
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
modifiedby = user.ModifiedBy;
|
|
||||||
modifiedon = user.ModifiedOn;
|
|
||||||
deletedby = user.DeletedBy;
|
|
||||||
deletedon = user.DeletedOn;
|
|
||||||
isdeleted = user.IsDeleted.ToString();
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Required.ProfileInfo"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading User {UserId} {Error}", userid, ex.Message);
|
await logger.LogError(ex, "Error Saving User {Username} {Email} {Error}", username, email, ex.Message);
|
||||||
AddModuleMessage(Localizer["Error.User.Load"], MessageType.Error);
|
AddModuleMessage(Localizer["Error.User.Save"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private string GetProfileValue(string SettingName, string DefaultValue)
|
|
||||||
=> SettingService.GetSetting(settings, SettingName, DefaultValue);
|
|
||||||
|
|
||||||
private async Task SaveUser()
|
|
||||||
{
|
{
|
||||||
validated = true;
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (username != string.Empty && email != string.Empty && ValidateProfiles())
|
|
||||||
{
|
|
||||||
if (password == confirm)
|
|
||||||
{
|
|
||||||
var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
|
||||||
user.SiteId = PageState.Site.SiteId;
|
|
||||||
user.Username = username;
|
|
||||||
user.Password = password;
|
|
||||||
user.Email = email;
|
|
||||||
user.DisplayName = string.IsNullOrWhiteSpace(displayname) ? username : displayname;
|
|
||||||
user.PhotoFileId = null;
|
|
||||||
user.PhotoFileId = filemanager.GetFileId();
|
|
||||||
if (user.PhotoFileId == -1)
|
|
||||||
{
|
|
||||||
user.PhotoFileId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
user.IsDeleted = (isdeleted == null ? true : Boolean.Parse(isdeleted));
|
|
||||||
|
|
||||||
user = await UserService.UpdateUserAsync(user);
|
|
||||||
await SettingService.UpdateUserSettingsAsync(settings, user.UserId);
|
|
||||||
await logger.LogInformation("User Saved {User}", user);
|
|
||||||
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Required.ProfileInfo"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Saving User {Username} {Email} {Error}", username, email, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.User.Save"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ValidateProfiles()
|
|
||||||
{
|
|
||||||
bool valid = true;
|
|
||||||
foreach (Profile profile in profiles)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)) && !string.IsNullOrEmpty(profile.DefaultValue))
|
|
||||||
{
|
|
||||||
settings = SettingService.SetSetting(settings, profile.Name, profile.DefaultValue);
|
|
||||||
}
|
|
||||||
if (profile.IsRequired && string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)))
|
|
||||||
{
|
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ProfileChanged(ChangeEventArgs e, string SettingName)
|
|
||||||
{
|
|
||||||
var value = (string)e.Value;
|
|
||||||
settings = SettingService.SetSetting(settings, SettingName, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool ValidateProfiles()
|
||||||
|
{
|
||||||
|
bool valid = true;
|
||||||
|
foreach (Profile profile in profiles)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)) && !string.IsNullOrEmpty(profile.DefaultValue))
|
||||||
|
{
|
||||||
|
settings = SettingService.SetSetting(settings, profile.Name, profile.DefaultValue);
|
||||||
|
}
|
||||||
|
if (profile.IsRequired && string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)))
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProfileChanged(ChangeEventArgs e, string SettingName)
|
||||||
|
{
|
||||||
|
var value = (string)e.Value;
|
||||||
|
settings = SettingService.SetSetting(settings, SettingName, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -14,110 +14,110 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<ActionLink Action="Add" Text="Add User" ResourceKey="AddUser" />
|
<ActionLink Action="Add" Text="Add User" ResourceKey="AddUser" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<input class="form-control" @bind="@_search" />
|
<input class="form-control" @bind="@_search" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<button class="btn btn-secondary" @onclick="OnSearch">@SharedLocalizer["Search"]</button>
|
<button class="btn btn-secondary" @onclick="OnSearch">@SharedLocalizer["Search"]</button>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Pager Items="@userroles">
|
</div>
|
||||||
<Header>
|
<Pager Items="@userroles">
|
||||||
<th style="width: 1px;"> </th>
|
<Header>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th>@SharedLocalizer["Name"]</th>
|
<th style="width: 1px;"> </th>
|
||||||
</Header>
|
<th>@SharedLocalizer["Name"]</th>
|
||||||
<Row>
|
</Header>
|
||||||
<td>
|
<Row>
|
||||||
<ActionLink Action="Edit" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="EditUser" />
|
<td>
|
||||||
</td>
|
<ActionLink Action="Edit" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="EditUser" />
|
||||||
<td>
|
</td>
|
||||||
<ActionDialog Header="Delete User" Message="@string.Format(Localizer["Confirm.User.Delete"], context.User.DisplayName)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteUser(context))" Disabled="@(context.Role.Name == RoleNames.Host)" ResourceKey="DeleteUser" />
|
<td>
|
||||||
</td>
|
<ActionDialog Header="Delete User" Message="@string.Format(Localizer["Confirm.User.Delete"], context.User.DisplayName)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteUser(context))" Disabled="@(context.Role.Name == RoleNames.Host)" ResourceKey="DeleteUser" />
|
||||||
<td>
|
</td>
|
||||||
<ActionLink Action="Roles" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="Roles" />
|
<td>
|
||||||
</td>
|
<ActionLink Action="Roles" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="Roles" />
|
||||||
<td>@context.User.DisplayName</td>
|
</td>
|
||||||
</Row>
|
<td>@context.User.DisplayName</td>
|
||||||
</Pager>
|
</Row>
|
||||||
|
</Pager>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<UserRole> allroles;
|
private List<UserRole> allroles;
|
||||||
private List<UserRole> userroles;
|
private List<UserRole> userroles;
|
||||||
private string _search;
|
private string _search;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
allroles = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
allroles = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
||||||
await LoadSettingsAsync();
|
await LoadSettingsAsync();
|
||||||
userroles = Search(_search);
|
userroles = Search(_search);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<UserRole> Search(string search)
|
private List<UserRole> Search(string search)
|
||||||
{
|
{
|
||||||
var results = allroles.Where(item => item.Role.Name == RoleNames.Registered || (item.Role.Name == RoleNames.Host && UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)));
|
var results = allroles.Where(item => item.Role.Name == RoleNames.Registered || (item.Role.Name == RoleNames.Host && UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(_search))
|
|
||||||
{
|
|
||||||
results = results.Where(item =>
|
|
||||||
(
|
|
||||||
item.User.Username.Contains(search, StringComparison.OrdinalIgnoreCase) ||
|
|
||||||
item.User.Email.Contains(search, StringComparison.OrdinalIgnoreCase) ||
|
|
||||||
item.User.DisplayName.Contains(search, StringComparison.OrdinalIgnoreCase)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return results.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task OnSearch()
|
|
||||||
{
|
|
||||||
userroles = Search(_search);
|
|
||||||
await UpdateSettingsAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DeleteUser(UserRole UserRole)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var user = await UserService.GetUserAsync(UserRole.UserId, PageState.Site.SiteId);
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
await UserService.DeleteUserAsync(user.UserId, PageState.Site.SiteId);
|
|
||||||
await logger.LogInformation("User Deleted {User}", UserRole.User);
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Deleting User {User} {Error}", UserRole.User, ex.Message);
|
|
||||||
AddModuleMessage(ex.Message, MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string settingSearch = "AU-search";
|
|
||||||
|
|
||||||
private async Task LoadSettingsAsync()
|
|
||||||
{
|
|
||||||
Dictionary<string, string> settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
|
|
||||||
_search = SettingService.GetSetting(settings, settingSearch, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task UpdateSettingsAsync()
|
|
||||||
{
|
|
||||||
Dictionary<string, string> settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
|
|
||||||
SettingService.SetSetting(settings, settingSearch, _search);
|
|
||||||
await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_search))
|
||||||
|
{
|
||||||
|
results = results.Where(item =>
|
||||||
|
(
|
||||||
|
item.User.Username.Contains(search, StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
item.User.Email.Contains(search, StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
item.User.DisplayName.Contains(search, StringComparison.OrdinalIgnoreCase)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
return results.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnSearch()
|
||||||
|
{
|
||||||
|
userroles = Search(_search);
|
||||||
|
await UpdateSettingsAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteUser(UserRole UserRole)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var user = await UserService.GetUserAsync(UserRole.UserId, PageState.Site.SiteId);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
await UserService.DeleteUserAsync(user.UserId, PageState.Site.SiteId);
|
||||||
|
await logger.LogInformation("User Deleted {User}", UserRole.User);
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Deleting User {User} {Error}", UserRole.User, ex.Message);
|
||||||
|
AddModuleMessage(ex.Message, MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string settingSearch = "AU-search";
|
||||||
|
|
||||||
|
private async Task LoadSettingsAsync()
|
||||||
|
{
|
||||||
|
Dictionary<string, string> settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
|
||||||
|
_search = SettingService.GetSetting(settings, settingSearch, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateSettingsAsync()
|
||||||
|
{
|
||||||
|
Dictionary<string, string> settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
|
||||||
|
SettingService.SetSetting(settings, settingSearch, _search);
|
||||||
|
await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -72,153 +72,153 @@ else
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
private int userid;
|
private int userid;
|
||||||
private string name = string.Empty;
|
private string name = string.Empty;
|
||||||
private List<Role> roles;
|
private List<Role> roles;
|
||||||
private int roleid = -1;
|
private int roleid = -1;
|
||||||
private string effectivedate = string.Empty;
|
private string effectivedate = string.Empty;
|
||||||
private string expirydate = string.Empty;
|
private string expirydate = string.Empty;
|
||||||
private List<UserRole> userroles;
|
private List<UserRole> userroles;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
userid = Int32.Parse(PageState.QueryString["id"]);
|
||||||
|
User user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
||||||
|
name = user.DisplayName;
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||||
{
|
{
|
||||||
try
|
roles = await RoleService.GetRolesAsync(PageState.Site.SiteId, true);
|
||||||
{
|
roles = roles.Where(item => item.Name != RoleNames.Everyone).ToList();
|
||||||
userid = Int32.Parse(PageState.QueryString["id"]);
|
|
||||||
User user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
|
||||||
name = user.DisplayName;
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
|
||||||
{
|
|
||||||
roles = await RoleService.GetRolesAsync(PageState.Site.SiteId, true);
|
|
||||||
roles = roles.Where(item => item.Name != RoleNames.Everyone).ToList();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
roles = await RoleService.GetRolesAsync(PageState.Site.SiteId);
|
|
||||||
}
|
|
||||||
await GetUserRoles();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Roles {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.LoadRole"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private async Task GetUserRoles()
|
|
||||||
{
|
{
|
||||||
try
|
roles = await RoleService.GetRolesAsync(PageState.Site.SiteId);
|
||||||
{
|
|
||||||
userroles = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
|
||||||
userroles = userroles.Where(item => item.UserId == userid).ToList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading User Roles {UserId} {Error}", userid, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.User.LoadRole"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
await GetUserRoles();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Roles {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.LoadRole"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task SaveUserRole()
|
private async Task GetUserRoles()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
userroles = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
||||||
|
userroles = userroles.Where(item => item.UserId == userid).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading User Roles {UserId} {Error}", userid, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.User.LoadRole"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveUserRole()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
validated = true;
|
if (roleid != -1)
|
||||||
var interop = new Interop(JSRuntime);
|
|
||||||
if (await interop.FormValid(form))
|
|
||||||
{
|
{
|
||||||
try
|
var userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault();
|
||||||
|
if (userrole != null)
|
||||||
{
|
{
|
||||||
if (roleid != -1)
|
if (string.IsNullOrEmpty(effectivedate))
|
||||||
{
|
{
|
||||||
var userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault();
|
userrole.EffectiveDate = null;
|
||||||
if (userrole != null)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(effectivedate))
|
|
||||||
{
|
|
||||||
userrole.EffectiveDate = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
userrole.EffectiveDate = DateTime.Parse(effectivedate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(expirydate))
|
|
||||||
{
|
|
||||||
userrole.ExpiryDate = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
userrole.ExpiryDate = DateTime.Parse(expirydate);
|
|
||||||
}
|
|
||||||
await UserRoleService.UpdateUserRoleAsync(userrole);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
userrole = new UserRole();
|
|
||||||
userrole.UserId = userid;
|
|
||||||
userrole.RoleId = roleid;
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(effectivedate))
|
|
||||||
{
|
|
||||||
userrole.EffectiveDate = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
userrole.EffectiveDate = DateTime.Parse(effectivedate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(expirydate))
|
|
||||||
{
|
|
||||||
userrole.ExpiryDate = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
userrole.ExpiryDate = DateTime.Parse(expirydate);
|
|
||||||
}
|
|
||||||
|
|
||||||
await UserRoleService.AddUserRoleAsync(userrole);
|
|
||||||
}
|
|
||||||
|
|
||||||
await logger.LogInformation("User Assigned To Role {UserRole}", userrole);
|
|
||||||
AddModuleMessage(Localizer["Success.User.AssignRole"], MessageType.Success);
|
|
||||||
await GetUserRoles();
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.Role"], MessageType.Warning);
|
userrole.EffectiveDate = DateTime.Parse(effectivedate);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Saving User Roles {UserId} {Error}", userid, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.User.SaveRole"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DeleteUserRole(int UserRoleId)
|
if (string.IsNullOrEmpty(expirydate))
|
||||||
{
|
{
|
||||||
try
|
userrole.ExpiryDate = null;
|
||||||
{
|
}
|
||||||
await UserRoleService.DeleteUserRoleAsync(UserRoleId);
|
else
|
||||||
await logger.LogInformation("User Removed From Role {UserRoleId}", UserRoleId);
|
{
|
||||||
AddModuleMessage(Localizer["Success.User.Remove"], MessageType.Success);
|
userrole.ExpiryDate = DateTime.Parse(expirydate);
|
||||||
|
}
|
||||||
|
await UserRoleService.UpdateUserRoleAsync(userrole);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
userrole = new UserRole();
|
||||||
|
userrole.UserId = userid;
|
||||||
|
userrole.RoleId = roleid;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(effectivedate))
|
||||||
|
{
|
||||||
|
userrole.EffectiveDate = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
userrole.EffectiveDate = DateTime.Parse(effectivedate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(expirydate))
|
||||||
|
{
|
||||||
|
userrole.ExpiryDate = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
userrole.ExpiryDate = DateTime.Parse(expirydate);
|
||||||
|
}
|
||||||
|
|
||||||
|
await UserRoleService.AddUserRoleAsync(userrole);
|
||||||
|
}
|
||||||
|
|
||||||
|
await logger.LogInformation("User Assigned To Role {UserRole}", userrole);
|
||||||
|
AddModuleMessage(Localizer["Success.User.AssignRole"], MessageType.Success);
|
||||||
await GetUserRoles();
|
await GetUserRoles();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Removing User From Role {UserRoleId} {Error}", UserRoleId, ex.Message);
|
AddModuleMessage(Localizer["Message.Required.Role"], MessageType.Warning);
|
||||||
AddModuleMessage(Localizer["Error.User.RemoveRole"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Saving User Roles {UserId} {Error}", userid, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.User.SaveRole"], MessageType.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteUserRole(int UserRoleId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await UserRoleService.DeleteUserRoleAsync(UserRoleId);
|
||||||
|
await logger.LogInformation("User Removed From Role {UserRoleId}", UserRoleId);
|
||||||
|
AddModuleMessage(Localizer["Success.User.Remove"], MessageType.Success);
|
||||||
|
await GetUserRoles();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Removing User From Role {UserRoleId} {Error}", UserRoleId, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.User.RemoveRole"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user