updated modules for input requirements
This commit is contained in:
@ -7,97 +7,110 @@
|
|||||||
@inject IStringLocalizer<Add> Localizer
|
@inject IStringLocalizer<Add> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<TabStrip>
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<TabPanel Name="Upload" Heading="Upload Files" ResourceKey="UploadFiles">
|
<TabStrip>
|
||||||
<div class="container">
|
<TabPanel Name="Upload" Heading="Upload Files" ResourceKey="UploadFiles">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<Label Class="col-sm-3" For="upload" HelpText="Upload the file you want" ResourceKey="Upload">Upload: </Label>
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<Label Class="col-sm-3" For="upload" HelpText="Upload the file you want" ResourceKey="Upload">Upload: </Label>
|
||||||
<FileManager UploadMultiple="true" ShowFiles="false" FolderId="@_folderId" />
|
<div class="col-sm-9">
|
||||||
|
<FileManager UploadMultiple="true" ShowFiles="false" FolderId="@_folderId" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
</TabPanel>
|
|
||||||
<TabPanel Name="Download" Heading="Download Files" ResourceKey="DownloadFiles">
|
|
||||||
@if (_folders != null)
|
|
||||||
{
|
|
||||||
<div class="container">
|
|
||||||
<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>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="url" class="form-control" @bind="@url" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="folder" HelpText="Select the folder to save the file in" ResourceKey="Folder">Folder: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="folder" class="form-select" @bind="@_folderId">
|
|
||||||
<option value="-1"><@Localizer["Folder.Select"]></option>
|
|
||||||
@foreach (Folder folder in _folders)
|
|
||||||
{
|
|
||||||
<option value="@(folder.FolderId)">@(new string('-', folder.Level * 2))@(folder.Name)</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button type="button" class="btn btn-success" @onclick="Download">@SharedLocalizer["Download"]</button>
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
}
|
</TabPanel>
|
||||||
</TabPanel>
|
<TabPanel Name="Download" Heading="Download Files" ResourceKey="DownloadFiles">
|
||||||
</TabStrip>
|
@if (_folders != null)
|
||||||
|
{
|
||||||
|
<div class="container">
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="url" class="form-control" @bind="@url" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="folder" HelpText="Select the folder to save the file in" ResourceKey="Folder">Folder: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="folder" class="form-select" @bind="@_folderId" required>
|
||||||
|
<option value="-1"><@Localizer["Folder.Select"]></option>
|
||||||
|
@foreach (Folder folder in _folders)
|
||||||
|
{
|
||||||
|
<option value="@(folder.FolderId)">@(new string('-', folder.Level * 2))@(folder.Name)</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn btn-success" @onclick="Download">@SharedLocalizer["Download"]</button>
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
}
|
||||||
|
</TabPanel>
|
||||||
|
</TabStrip>
|
||||||
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string url = string.Empty;
|
private ElementReference form;
|
||||||
private List<Folder> _folders;
|
private bool validated = false;
|
||||||
private int _folderId = -1;
|
private string url = string.Empty;
|
||||||
|
private List<Folder> _folders;
|
||||||
|
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"))
|
|
||||||
{
|
{
|
||||||
_folderId = int.Parse(PageState.QueryString["id"]);
|
_folders = await FolderService.GetFoldersAsync(ModuleState.SiteId);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Download()
|
if (PageState.QueryString.ContainsKey("id"))
|
||||||
{
|
{
|
||||||
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);
|
private async Task Download()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
if (url == string.Empty || _folderId == -1)
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Required.UrlFolder"], MessageType.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Constants.UploadableFiles.Split(',')
|
var filename = url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1);
|
||||||
.Contains(Path.GetExtension(filename).ToLower().Replace(".", "")))
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Download.InvalidExtension"], MessageType.Warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!filename.IsPathOrFileValid())
|
if (!Constants.UploadableFiles.Split(',')
|
||||||
{
|
.Contains(Path.GetExtension(filename).ToLower().Replace(".", "")))
|
||||||
AddModuleMessage(Localizer["Message.Required.UrlName"], MessageType.Warning);
|
{
|
||||||
return;
|
AddModuleMessage(Localizer["Message.Download.InvalidExtension"], MessageType.Warning);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
if (!filename.IsPathOrFileValid())
|
||||||
{
|
{
|
||||||
await FileService.UploadFileAsync(url, _folderId);
|
AddModuleMessage(Localizer["Message.Required.UrlName"], MessageType.Warning);
|
||||||
await logger.LogInformation("File Downloaded Successfully From Url {Url}", url);
|
return;
|
||||||
AddModuleMessage(Localizer["Success.Download.File"], MessageType.Success);
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Downloading File From Url {Url} {Error}", url, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Download.InvalidUrl"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,100 +8,114 @@
|
|||||||
|
|
||||||
@if (_folders != null)
|
@if (_folders != null)
|
||||||
{
|
{
|
||||||
<div class="container">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<Label Class="col-sm-3" For="name" HelpText="The name of the file" ResourceKey="Name">Name: </Label>
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<Label Class="col-sm-3" For="name" HelpText="The name of the file" ResourceKey="Name">Name: </Label>
|
||||||
<input id="name" class="form-control" @bind="@_name" />
|
<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="parent" HelpText="The folder where the file is located" ResourceKey="Folder">Folder: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="parent" class="form-select" @bind="@_folderId">
|
||||||
|
@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="size" HelpText="The size of the file (in bytes)" ResourceKey="Size">Size: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="size" class="form-control" @bind="@_size" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<button type="button" class="btn btn-success" @onclick="SaveFile">@SharedLocalizer["Save"]</button>
|
||||||
<div class="row mb-1 align-items-center">
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
<Label Class="col-sm-3" For="parent" HelpText="The folder where the file is located" ResourceKey="Folder">Folder: </Label>
|
<br />
|
||||||
<div class="col-sm-9">
|
<br />
|
||||||
<select id="parent" class="form-select" @bind="@_folderId">
|
<AuditInfo CreatedBy="@_createdBy" CreatedOn="@_createdOn" ModifiedBy="@_modifiedBy" ModifiedOn="@_modifiedOn"></AuditInfo>
|
||||||
@foreach (Folder folder in _folders)
|
</form>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private ElementReference form;
|
||||||
|
private bool validated = false;
|
||||||
|
private int _fileId = -1;
|
||||||
|
private string _name;
|
||||||
|
private List<Folder> _folders;
|
||||||
|
private int _folderId = -1;
|
||||||
|
private int _size;
|
||||||
|
private string _createdBy;
|
||||||
|
private DateTime _createdOn;
|
||||||
|
private string _modifiedBy;
|
||||||
|
private DateTime _modifiedOn;
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
|
public override string Title => "File Management";
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
<option value="@(folder.FolderId)">@(new string('-', folder.Level * 2))@(folder.Name)</option>
|
_folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId);
|
||||||
|
_fileId = Int32.Parse(PageState.QueryString["id"]);
|
||||||
|
File file = await FileService.GetFileAsync(_fileId);
|
||||||
|
if (file != null)
|
||||||
|
{
|
||||||
|
_name = file.Name;
|
||||||
|
_folderId = file.FolderId;
|
||||||
|
_size = file.Size;
|
||||||
|
_createdBy = file.CreatedBy;
|
||||||
|
_createdOn = file.CreatedOn;
|
||||||
|
_modifiedBy = file.ModifiedBy;
|
||||||
|
_modifiedOn = file.ModifiedOn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</select>
|
catch (Exception ex)
|
||||||
</div>
|
{
|
||||||
</div>
|
await logger.LogError(ex, "Error Loading File {FileId} {Error}", _fileId, ex.Message);
|
||||||
<div class="row mb-1 align-items-center">
|
AddModuleMessage(Localizer["Error.File.Load"], MessageType.Error);
|
||||||
<Label Class="col-sm-3" For="size" HelpText="The size of the file (in bytes)" ResourceKey="Size">Size: </Label>
|
}
|
||||||
<div class="col-sm-9">
|
}
|
||||||
<input id="size" class="form-control" @bind="@_size" readonly />
|
|
||||||
</div>
|
private async Task SaveFile()
|
||||||
</div>
|
{
|
||||||
</div>
|
validated = true;
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveFile">@SharedLocalizer["Save"]</button>
|
var interop = new Interop(JSRuntime);
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
if (await interop.FormValid(form))
|
||||||
<br />
|
{
|
||||||
<br />
|
try
|
||||||
<AuditInfo CreatedBy="@_createdBy" CreatedOn="@_createdOn" ModifiedBy="@_modifiedBy" ModifiedOn="@_modifiedOn"></AuditInfo>
|
{
|
||||||
}
|
if (_name.IsPathOrFileValid())
|
||||||
|
{
|
||||||
@code {
|
File file = await FileService.GetFileAsync(_fileId);
|
||||||
private int _fileId = -1;
|
file.Name = _name;
|
||||||
private string _name;
|
file.FolderId = _folderId;
|
||||||
private List<Folder> _folders;
|
file = await FileService.UpdateFileAsync(file);
|
||||||
private int _folderId = -1;
|
await logger.LogInformation("File Saved {File}", file);
|
||||||
private int _size;
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
private string _createdBy;
|
}
|
||||||
private DateTime _createdOn;
|
else
|
||||||
private string _modifiedBy;
|
{
|
||||||
private DateTime _modifiedOn;
|
AddModuleMessage(Localizer["Message.File.InvalidName"], MessageType.Warning);
|
||||||
|
}
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
}
|
||||||
|
catch (Exception ex)
|
||||||
public override string Title => "File Management";
|
{
|
||||||
|
await logger.LogError(ex, "Error Saving File {FileId} {Error}", _fileId, ex.Message);
|
||||||
protected override async Task OnInitializedAsync()
|
AddModuleMessage(Localizer["Error.File.Save"], MessageType.Error);
|
||||||
{
|
}
|
||||||
try
|
}
|
||||||
{
|
else
|
||||||
_folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId);
|
{
|
||||||
_fileId = Int32.Parse(PageState.QueryString["id"]);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
File file = await FileService.GetFileAsync(_fileId);
|
}
|
||||||
if (file != null)
|
}
|
||||||
{
|
}
|
||||||
_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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SaveFile()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_name.IsPathOrFileValid())
|
|
||||||
{
|
|
||||||
File file = await FileService.GetFileAsync(_fileId);
|
|
||||||
file.Name = _name;
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,52 +8,53 @@
|
|||||||
|
|
||||||
@if (_folders != null)
|
@if (_folders != null)
|
||||||
{
|
{
|
||||||
<div class="container">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<Label Class="col-sm-3" For="parent" HelpText="Select the parent folder" ResourceKey="Parent">Parent: </Label>
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<Label Class="col-sm-3" For="parent" HelpText="Select the parent folder" ResourceKey="Parent">Parent: </Label>
|
||||||
<select id="parent" class="form-select" @bind="@_parentId">
|
<div class="col-sm-9">
|
||||||
|
<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" />
|
|
||||||
</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">
|
|
||||||
<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)
|
||||||
{
|
{
|
||||||
@ -72,170 +73,182 @@
|
|||||||
{
|
{
|
||||||
<AuditInfo CreatedBy="@_createdBy" CreatedOn="@_createdOn" ModifiedBy="@_modifiedBy" ModifiedOn="@_modifiedOn"></AuditInfo>
|
<AuditInfo CreatedBy="@_createdBy" CreatedOn="@_createdOn" ModifiedBy="@_modifiedBy" ModifiedOn="@_modifiedOn"></AuditInfo>
|
||||||
}
|
}
|
||||||
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<Folder> _folders;
|
private ElementReference form;
|
||||||
private int _folderId = -1;
|
private bool validated = false;
|
||||||
private int _parentId = -1;
|
private List<Folder> _folders;
|
||||||
private string _name;
|
private int _folderId = -1;
|
||||||
private string _type = FolderTypes.Private;
|
private int _parentId = -1;
|
||||||
private bool _isSystem;
|
private string _name;
|
||||||
private string _permissions = string.Empty;
|
private string _type = FolderTypes.Private;
|
||||||
private string _createdBy;
|
private bool _isSystem;
|
||||||
private DateTime _createdOn;
|
private string _permissions = string.Empty;
|
||||||
private string _modifiedBy;
|
private string _createdBy;
|
||||||
private DateTime _modifiedOn;
|
private DateTime _createdOn;
|
||||||
|
private string _modifiedBy;
|
||||||
|
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
|
|
||||||
{
|
{
|
||||||
_folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId);
|
try
|
||||||
|
|
||||||
if (PageState.QueryString.ContainsKey("id"))
|
|
||||||
{
|
{
|
||||||
_folderId = Int32.Parse(PageState.QueryString["id"]);
|
_folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId);
|
||||||
Folder folder = await FolderService.GetFolderAsync(_folderId);
|
|
||||||
if (folder != null)
|
if (PageState.QueryString.ContainsKey("id"))
|
||||||
{
|
{
|
||||||
_parentId = folder.ParentId ?? -1;
|
_folderId = Int32.Parse(PageState.QueryString["id"]);
|
||||||
_name = folder.Name;
|
Folder folder = await FolderService.GetFolderAsync(_folderId);
|
||||||
_type = folder.Type;
|
if (folder != null)
|
||||||
_isSystem = folder.IsSystem;
|
{
|
||||||
_permissions = folder.Permissions;
|
_parentId = folder.ParentId ?? -1;
|
||||||
_createdBy = folder.CreatedBy;
|
_name = folder.Name;
|
||||||
_createdOn = folder.CreatedOn;
|
_type = folder.Type;
|
||||||
_modifiedBy = folder.ModifiedBy;
|
_isSystem = folder.IsSystem;
|
||||||
_modifiedOn = folder.ModifiedOn;
|
_permissions = folder.Permissions;
|
||||||
}
|
_createdBy = folder.CreatedBy;
|
||||||
}
|
_createdOn = folder.CreatedOn;
|
||||||
else
|
_modifiedBy = folder.ModifiedBy;
|
||||||
{
|
_modifiedOn = folder.ModifiedOn;
|
||||||
_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()
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Folder.Files.InvalidDelete"], MessageType.Warning);
|
_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(Localizer["Message.Folder.Subfolders.InvalidDelete"], MessageType.Warning);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
private async Task DeleteFolder()
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Deleting Folder {Folder} {Error}", _folderId, ex.Message);
|
try
|
||||||
AddModuleMessage(Localizer["Error.Folder.Delete"], MessageType.Error);
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -30,12 +30,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<Pager Items="@_files">
|
<Pager Items="@_files">
|
||||||
<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>@Localizer["Modified"]</th>
|
<th>@Localizer["Modified"]</th>
|
||||||
<th>@Localizer["Type"]</th>
|
<th>@Localizer["Type"]</th>
|
||||||
<th>@Localizer["Size"]</th>
|
<th>@Localizer["Size"]</th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><ActionLink Action="Details" Text="Edit" Parameters="@($"id=" + context.FileId.ToString())" ResourceKey="Details" /></td>
|
<td><ActionLink Action="Details" Text="Edit" Parameters="@($"id=" + context.FileId.ToString())" ResourceKey="Details" /></td>
|
||||||
@ -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
|
|
||||||
{
|
{
|
||||||
_folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId);
|
try
|
||||||
|
|
||||||
if (_folderId == -1 && _folders.Count > 0)
|
|
||||||
{
|
{
|
||||||
_folderId = _folders[0].FolderId;
|
_folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId);
|
||||||
await GetFiles();
|
|
||||||
|
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);
|
||||||
|
AddModuleMessage(Localizer["Error.File.Load"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Files {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.File.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task GetFiles()
|
private async Task GetFiles()
|
||||||
{
|
{
|
||||||
_files = await FileService.GetFilesAsync(_folderId);
|
_files = await FileService.GetFilesAsync(_folderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void FolderChanged(ChangeEventArgs e)
|
private async void FolderChanged(ChangeEventArgs e)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
_folderId = int.Parse((string)e.Value);
|
try
|
||||||
await GetFiles();
|
{
|
||||||
StateHasChanged();
|
_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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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)
|
private async Task DeleteFile(File file)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await FileService.DeleteFileAsync(file.FileId);
|
try
|
||||||
await logger.LogInformation("File Deleted {File}", file.Name);
|
{
|
||||||
AddModuleMessage(string.Format(Localizer["Success.File.Delete"], file.Name), MessageType.Success);
|
await FileService.DeleteFileAsync(file.FileId);
|
||||||
await GetFiles();
|
await logger.LogInformation("File Deleted {File}", file.Name);
|
||||||
StateHasChanged();
|
AddModuleMessage(string.Format(Localizer["Success.File.Delete"], file.Name), MessageType.Success);
|
||||||
}
|
await GetFiles();
|
||||||
catch (Exception ex)
|
StateHasChanged();
|
||||||
{
|
}
|
||||||
await logger.LogError(ex, "Error Deleting File {File} {Error}", file.Name, ex.Message);
|
catch (Exception ex)
|
||||||
AddModuleMessage(string.Format(Localizer["Error.File.Delete"], file.Name), MessageType.Error);
|
{
|
||||||
|
await logger.LogError(ex, "Error Deleting File {File} {Error}", file.Name, ex.Message);
|
||||||
|
AddModuleMessage(string.Format(Localizer["Error.File.Delete"], file.Name), MessageType.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -5,176 +5,183 @@
|
|||||||
@inject IStringLocalizer<Edit> Localizer
|
@inject IStringLocalizer<Edit> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<div class="container">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<Label Class="col-sm-3" For="name" HelpText="Enter the job name" ResourceKey="Name">Name: </Label>
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<Label Class="col-sm-3" For="name" HelpText="Enter the job name" ResourceKey="Name">Name: </Label>
|
||||||
<input id="name" class="form-control" @bind="@_name" />
|
<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="The fully qualified job type name" ResourceKey="Type">Type: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="type" class="form-control" @bind="@_jobType" readonly/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="enabled" HelpText="Select whether you want the job enabled or not" ResourceKey="Enabled">Enabled? </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="enabled" class="form-select" @bind="@_isEnabled" required>
|
||||||
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="runs-every" HelpText="Select how often you want the job to run" ResourceKey="RunsEvery">Runs Every: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="runs-every" class="form-control" @bind="@_interval" required />
|
||||||
|
<select id="runs-every" class="form-select" @bind="@_frequency" required>
|
||||||
|
<option value="m">@Localizer["Minute(s)"]</option>
|
||||||
|
<option value="H">@Localizer["Hour(s)"]</option>
|
||||||
|
<option value="d">@Localizer["Day(s)"]</option>
|
||||||
|
<option value="M">@Localizer["Month(s)"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="starting" HelpText="What time do you want the job to start" ResourceKey="Starting">Starting: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="starting" class="form-control" @bind="@_startDate" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="ending" HelpText="When do you want the job to end" ResourceKey="Ending">Ending: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="ending" class="form-control" @bind="@_endDate" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="retention" HelpText="Number of log entries to retain for this job" ResourceKey="RetentionLog">Retention Log (Items): </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="retention" class="form-control" @bind="@_retentionHistory" required />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="next" HelpText="Next execution for this job." ResourceKey="NextExecution">Next Execution: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="next" class="form-control" @bind="@_nextExecution" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<br />
|
||||||
<Label Class="col-sm-3" For="type" HelpText="The fully qualified job type name" ResourceKey="Type">Type: </Label>
|
<button type="button" class="btn btn-success" @onclick="SaveJob">@SharedLocalizer["Save"]</button>
|
||||||
<div class="col-sm-9">
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
<input id="type" class="form-control" @bind="@_jobType" readonly />
|
<br />
|
||||||
</div>
|
<br />
|
||||||
</div>
|
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
||||||
<div class="row mb-1 align-items-center">
|
</form>
|
||||||
<Label Class="col-sm-3" For="enabled" HelpText="Select whether you want the job enabled or not" ResourceKey="Enabled">Enabled? </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="enabled" class="form-select" @bind="@_isEnabled">
|
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="runs-every" HelpText="Select how often you want the job to run" ResourceKey="RunsEvery">Runs Every: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="runs-every" class="form-control" @bind="@_interval" />
|
|
||||||
<select id="runs-every" class="form-select" @bind="@_frequency">
|
|
||||||
<option value="m">@Localizer["Minute(s)"]</option>
|
|
||||||
<option value="H">@Localizer["Hour(s)"]</option>
|
|
||||||
<option value="d">@Localizer["Day(s)"]</option>
|
|
||||||
<option value="M">@Localizer["Month(s)"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="starting" HelpText="What time do you want the job to start" ResourceKey="Starting">Starting: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="starting" class="form-control" @bind="@_startDate" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="ending" HelpText="When do you want the job to end" ResourceKey="Ending">Ending: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="ending" class="form-control" @bind="@_endDate" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="retention" HelpText="Number of log entries to retain for this job" ResourceKey="RetentionLog">Retention Log (Items): </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="retention" class="form-control" @bind="@_retentionHistory" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="next" HelpText="Next execution for this job." ResourceKey="NextExecution">Next Execution: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="next" class="form-control" @bind="@_nextExecution" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveJob">@SharedLocalizer["Save"]</button>
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private int _jobId;
|
private ElementReference form;
|
||||||
private string _name = string.Empty;
|
private bool validated = false;
|
||||||
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;
|
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;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
{
|
|
||||||
try
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
_jobId = Int32.Parse(PageState.QueryString["id"]);
|
|
||||||
Job job = await JobService.GetJobAsync(_jobId);
|
|
||||||
if (job != null)
|
|
||||||
{
|
|
||||||
_name = job.Name;
|
|
||||||
_jobType = job.JobType;
|
|
||||||
_isEnabled = job.IsEnabled.ToString();
|
|
||||||
_interval = job.Interval.ToString();
|
|
||||||
_frequency = job.Frequency;
|
|
||||||
_startDate = (job.StartDate != null) ? job.StartDate.ToString() : string.Empty;
|
|
||||||
_endDate = (job.EndDate != null) ? job.EndDate.ToString() : string.Empty;
|
|
||||||
_retentionHistory = job.RetentionHistory.ToString();
|
|
||||||
_nextExecution = job.NextExecution.ToString();
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SaveJob()
|
|
||||||
{
|
|
||||||
if (_name != string.Empty && !string.IsNullOrEmpty(_jobType) && _frequency != string.Empty && _interval != string.Empty && _retentionHistory != string.Empty)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
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
|
try
|
||||||
{
|
{
|
||||||
job = await JobService.UpdateJobAsync(job);
|
_jobId = Int32.Parse(PageState.QueryString["id"]);
|
||||||
await logger.LogInformation("Job Updated {Job}", job);
|
Job job = await JobService.GetJobAsync(_jobId);
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
if (job != null)
|
||||||
|
{
|
||||||
|
_name = job.Name;
|
||||||
|
_jobType = job.JobType;
|
||||||
|
_isEnabled = job.IsEnabled.ToString();
|
||||||
|
_interval = job.Interval.ToString();
|
||||||
|
_frequency = job.Frequency;
|
||||||
|
_startDate = (job.StartDate != null) ? job.StartDate.ToString() : string.Empty;
|
||||||
|
_endDate = (job.EndDate != null) ? job.EndDate.ToString() : string.Empty;
|
||||||
|
_retentionHistory = job.RetentionHistory.ToString();
|
||||||
|
_nextExecution = job.NextExecution.ToString();
|
||||||
|
createdby = job.CreatedBy;
|
||||||
|
createdon = job.CreatedOn;
|
||||||
|
modifiedby = job.ModifiedBy;
|
||||||
|
modifiedon = job.ModifiedOn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Udate Job {Job} {Error}", job, ex.Message);
|
await logger.LogError(ex, "Error Loading Job {JobId} {Error}", _jobId, ex.Message);
|
||||||
AddModuleMessage(Localizer["Error.Job.Update"], MessageType.Error);
|
AddModuleMessage(Localizer["Error.Job.Load"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Required.JobInfo"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
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)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
<button type="button" class="btn btn-danger" @onclick="(async () => await StopJob(context.JobId))">@Localizer["Stop"]</button>
|
status = Localizer["Executing"];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<button type="button" class="btn btn-success" @onclick="(async () => await StartJob(context.JobId))">@Localizer["Start"]</button>
|
status = Localizer["Idle"];
|
||||||
}
|
}
|
||||||
</td>
|
}
|
||||||
</Row>
|
|
||||||
</Pager>
|
|
||||||
}
|
|
||||||
|
|
||||||
@code {
|
return status;
|
||||||
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"];
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
private string DisplayFrequency(int interval, string frequency)
|
||||||
{
|
{
|
||||||
status = Localizer["Idle"];
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,226 +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
|
|
||||||
{
|
|
||||||
<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">
|
|
||||||
@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">
|
|
||||||
<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>
|
|
||||||
}
|
|
||||||
<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)
|
|
||||||
{
|
{
|
||||||
<Pager Items="@_packages">
|
<ModuleMessage Type="MessageType.Info" Message="@_message"></ModuleMessage>
|
||||||
<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
|
||||||
{
|
{
|
||||||
<br />
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="mx-auto text-center">
|
<div class="container">
|
||||||
@Localizer["Search.NoResults"]
|
<div class="row mb-1 align-items-center">
|
||||||
</div>
|
<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>
|
||||||
}
|
}
|
||||||
<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>
|
||||||
</TabPanel>
|
<TabPanel Name="Download" ResourceKey="Download" Security="SecurityAccessLevel.Host">
|
||||||
<TabPanel Name="Upload" ResourceKey="Upload" 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="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<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">
|
||||||
<div class="col-sm-9">
|
<input id="search" class="form-control" placeholder="@SharedLocalizer["Search.Hint"]" @bind="@_search"/>
|
||||||
<FileManager Filter="nupkg" ShowFiles="false" Folder="Packages" UploadMultiple="true" />
|
</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>
|
</div>
|
||||||
</div>
|
|
||||||
<button type="button" class="btn btn-success" @onclick="InstallLanguages">@SharedLocalizer["Install"]</button>
|
@if (_packages != null)
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
{
|
||||||
</TabPanel>
|
@if (_packages.Count > 0)
|
||||||
</TabStrip>
|
{
|
||||||
|
<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>
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
</TabPanel>
|
||||||
|
</TabStrip>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _code = string.Empty;
|
private ElementReference form;
|
||||||
private string _isDefault = "False";
|
private bool validated = false;
|
||||||
private string _message;
|
|
||||||
private IEnumerable<Culture> _supportedCultures;
|
|
||||||
private IEnumerable<Culture> _availableCultures;
|
|
||||||
private List<Package> _packages;
|
|
||||||
private string _search = "";
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
private string _code = string.Empty;
|
||||||
|
private string _isDefault = "False";
|
||||||
|
private string _message;
|
||||||
|
private IEnumerable<Culture> _supportedCultures;
|
||||||
|
private IEnumerable<Culture> _availableCultures;
|
||||||
|
private List<Package> _packages;
|
||||||
|
private string _search = "";
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
{
|
|
||||||
var languages = await LanguageService.GetLanguagesAsync(PageState.Site.SiteId);
|
|
||||||
var languagesCodes = languages.Select(l => l.Code).ToList();
|
|
||||||
|
|
||||||
_supportedCultures = await LocalizationService.GetCulturesAsync();
|
protected override async Task OnParametersSetAsync()
|
||||||
_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()
|
|
||||||
{
|
|
||||||
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);
|
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"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await logger.LogInformation("Language Added {Language}", language);
|
private async Task LoadTranslations()
|
||||||
|
{
|
||||||
|
_packages = await PackageService.GetPackagesAsync("translation", _search);
|
||||||
|
}
|
||||||
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
private async Task Search()
|
||||||
}
|
{
|
||||||
catch (Exception ex)
|
try
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Adding Language {Language} {Error}", language, ex.Message);
|
await LoadTranslations();
|
||||||
AddModuleMessage(Localizer["Error.Language.Add"], MessageType.Error);
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
|
await logger.LogError(ex, "Error On Search");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task InstallLanguages()
|
private async Task Reset()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await PackageService.InstallPackagesAsync();
|
_search = "";
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Language.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
await LoadTranslations();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Installing Translations");
|
await logger.LogError(ex, "Error On Reset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DownloadLanguage(string packageid, string version)
|
private async Task SaveLanguage()
|
||||||
{
|
{
|
||||||
try
|
validated = true;
|
||||||
{
|
var interop = new Interop(JSRuntime);
|
||||||
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
if (await interop.FormValid(form))
|
||||||
await logger.LogInformation("Language Paclage {Name} {Version} Downloaded Successfully", packageid, version);
|
{
|
||||||
AddModuleMessage(Localizer["Success.Language.Download"], MessageType.Success);
|
var language = new Language
|
||||||
StateHasChanged();
|
{
|
||||||
}
|
SiteId = PageState.Page.SiteId,
|
||||||
catch (Exception ex)
|
Name = CultureInfo.GetCultureInfo(_code).DisplayName,
|
||||||
{
|
Code = _code,
|
||||||
await logger.LogError(ex, "Error Downloading Translation {Name} {Version}", packageid, version);
|
IsDefault = (_isDefault == null ? false : Boolean.Parse(_isDefault))
|
||||||
AddModuleMessage(Localizer["Error.Language.Download"], MessageType.Error);
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SetCultureAsync(string culture)
|
try
|
||||||
{
|
{
|
||||||
if (culture != CultureInfo.CurrentUICulture.Name)
|
language = await LanguageService.AddLanguageAsync(language);
|
||||||
{
|
|
||||||
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);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -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>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</Row>
|
||||||
|
</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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteLanguage(Language language)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
<button type="button" class="btn btn-success" @onclick=@(async () => await DownloadLanguage(context.Code))>@SharedLocalizer["Upgrade"]</button>
|
await LanguageService.DeleteLanguageAsync(language.LanguageId);
|
||||||
|
await logger.LogInformation("Language Deleted {Language}", language);
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
</td>
|
catch (Exception ex)
|
||||||
</Row>
|
{
|
||||||
</Pager>
|
await logger.LogError(ex, "Error Deleting Language {Language} {Error}", language, ex.Message);
|
||||||
}
|
|
||||||
|
|
||||||
@code {
|
AddModuleMessage(Localizer["Error.Language.Delete"], MessageType.Error);
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DeleteLanguage(Language language)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await LanguageService.DeleteLanguageAsync(language.LanguageId);
|
|
||||||
await logger.LogInformation("Language Deleted {Language}", language);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private bool UpgradeAvailable(string code)
|
||||||
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");
|
var upgradeavailable = false;
|
||||||
await logger.LogInformation("Translation Downloaded {Code} {Version}", code, Constants.Version);
|
if (_packages != null)
|
||||||
await PackageService.InstallPackagesAsync();
|
{
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Language.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
</AuthorizeView>
|
</AuthorizeView>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
private ElementReference form;
|
||||||
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;
|
||||||
|
@ -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
|
|
||||||
{
|
{
|
||||||
await GetLogs();
|
<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>
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
<p><em>@Localizer["NoLogs"]</em></p>
|
||||||
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void LevelChanged(ChangeEventArgs e)
|
@code {
|
||||||
{
|
private string _level = "-";
|
||||||
try
|
private string _function = "-";
|
||||||
{
|
private string _rows = "10";
|
||||||
_level = (string)e.Value;
|
private List<Log> _logs;
|
||||||
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)
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
{
|
|
||||||
try
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
_function = (string)e.Value;
|
try
|
||||||
await GetLogs();
|
{
|
||||||
StateHasChanged();
|
await GetLogs();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
||||||
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
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)
|
private async void RowsChanged(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_rows = (string)e.Value;
|
_rows = (string)e.Value;
|
||||||
await GetLogs();
|
await GetLogs();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
||||||
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task GetLogs()
|
private async Task GetLogs()
|
||||||
{
|
{
|
||||||
_logs = await LogService.GetLogsAsync(PageState.Site.SiteId, ((_level == "-") ? string.Empty : _level), ((_function == "-") ? string.Empty : _function), int.Parse(_rows));
|
_logs = await LogService.GetLogsAsync(PageState.Site.SiteId, ((_level == "-") ? string.Empty : _level), ((_function == "-") ? string.Empty : _function), int.Parse(_rows));
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetClass(string function)
|
private string GetClass(string function)
|
||||||
{
|
{
|
||||||
string classname = string.Empty;
|
string classname = string.Empty;
|
||||||
switch (function)
|
switch (function)
|
||||||
{
|
{
|
||||||
case "Create":
|
case "Create":
|
||||||
classname = "table-success";
|
classname = "table-success";
|
||||||
break;
|
break;
|
||||||
case "Read":
|
case "Read":
|
||||||
classname = "table-primary";
|
classname = "table-primary";
|
||||||
break;
|
break;
|
||||||
case "Update":
|
case "Update":
|
||||||
classname = "table-warning";
|
classname = "table-warning";
|
||||||
break;
|
break;
|
||||||
case "Delete":
|
case "Delete":
|
||||||
classname = "table-danger";
|
classname = "table-danger";
|
||||||
break;
|
break;
|
||||||
case "Security":
|
case "Security":
|
||||||
classname = "table-secondary";
|
classname = "table-secondary";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
classname = string.Empty;
|
classname = string.Empty;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
return classname;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return classname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -10,180 +10,186 @@
|
|||||||
|
|
||||||
@if (string.IsNullOrEmpty(_moduledefinitionname) && _templates != null)
|
@if (string.IsNullOrEmpty(_moduledefinitionname) && _templates != null)
|
||||||
{
|
{
|
||||||
<div class="container">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<Label Class="col-sm-3" For="owner" HelpText="Enter the name of the organization who is developing this module. It should not contain spaces or punctuation." ResourceKey="OwnerName">Owner Name: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="owner" class="form-control" @bind="@_owner" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="module" HelpText="Enter a name for this module. It should not contain spaces or punctuation." ResourceKey="ModuleName">Module Name: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="module" class="form-control" @bind="@_module" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="description" HelpText="Enter a short description for the module" ResourceKey="Description">Description: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea id="description" class="form-control" @bind="@_description" rows="3"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="template" HelpText="Select a module template. Templates are located in the wwwroot/Modules/Templates folder on the server." ResourceKey="Template">Template: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="template" class="form-select" @onchange="(e => TemplateChanged(e))">
|
|
||||||
<option value="-"><@Localizer["Template.Select"]></option>
|
|
||||||
@foreach (Template template in _templates)
|
|
||||||
{
|
|
||||||
<option value="@template.Name">@template.Title</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="reference" HelpText="Select a framework reference version" ResourceKey="FrameworkReference">Framework Reference: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="reference" class="form-select" @bind="@_reference">
|
|
||||||
@foreach (string version in _versions)
|
|
||||||
{
|
|
||||||
if (Version.Parse(version).CompareTo(Version.Parse(_minversion)) >= 0)
|
|
||||||
{
|
|
||||||
<option value="@(version)">@(version)</option>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<option value="local">@SharedLocalizer["LocalVersion"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@if (!string.IsNullOrEmpty(_location))
|
|
||||||
{
|
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="location" HelpText="Location where the module will be created" ResourceKey="Location">Location: </Label>
|
<Label Class="col-sm-3" For="owner" HelpText="Enter the name of the organization who is developing this module. It should not contain spaces or punctuation." ResourceKey="OwnerName">Owner Name: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="module" class="form-control" @bind="@_location" readonly />
|
<input id="owner" class="form-control" @bind="@_owner" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
<div class="row mb-1 align-items-center">
|
||||||
</div>
|
<Label Class="col-sm-3" For="module" HelpText="Enter a name for this module. It should not contain spaces or punctuation." ResourceKey="ModuleName">Module Name: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
<button type="button" class="btn btn-success" @onclick="CreateModule">@Localizer["Module.Create"]</button>
|
<input id="module" class="form-control" @bind="@_module" required />
|
||||||
}
|
</div>
|
||||||
else
|
</div>
|
||||||
{
|
<div class="row mb-1 align-items-center">
|
||||||
<button type="button" class="btn btn-success" @onclick="ActivateModule">@Localizer["Module.Activate"]</button>
|
<Label Class="col-sm-3" For="description" HelpText="Enter a short description for the module" ResourceKey="Description">Description: </Label>
|
||||||
}
|
<div class="col-sm-9">
|
||||||
|
<textarea id="description" class="form-control" @bind="@_description" rows="3" required></textarea>
|
||||||
@code {
|
</div>
|
||||||
private string _moduledefinitionname = string.Empty;
|
</div>
|
||||||
private string _owner = string.Empty;
|
<div class="row mb-1 align-items-center">
|
||||||
private string _module = string.Empty;
|
<Label Class="col-sm-3" For="template" HelpText="Select a module template. Templates are located in the wwwroot/Modules/Templates folder on the server." ResourceKey="Template">Template: </Label>
|
||||||
private string _description = string.Empty;
|
<div class="col-sm-9">
|
||||||
private List<Template> _templates;
|
<select id="template" class="form-select" @onchange="(e => TemplateChanged(e))" required>
|
||||||
private string _template = "-";
|
<option value="-"><@Localizer["Template.Select"]></option>
|
||||||
private string[] _versions;
|
@foreach (Template template in _templates)
|
||||||
private string _reference = Constants.Version;
|
{
|
||||||
private string _minversion = "2.0.0";
|
<option value="@template.Name">@template.Title</option>
|
||||||
private string _location = string.Empty;
|
}
|
||||||
|
</select>
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
</div>
|
||||||
|
</div>
|
||||||
protected override async Task OnParametersSetAsync()
|
<div class="row mb-1 align-items-center">
|
||||||
{
|
<Label Class="col-sm-3" For="reference" HelpText="Select a framework reference version" ResourceKey="FrameworkReference">Framework Reference: </Label>
|
||||||
try
|
<div class="col-sm-9">
|
||||||
{
|
<select id="reference" class="form-select" @bind="@_reference" required>
|
||||||
_moduledefinitionname = SettingService.GetSetting(ModuleState.Settings, "ModuleDefinitionName", "");
|
@foreach (string version in _versions)
|
||||||
_templates = await ModuleDefinitionService.GetModuleDefinitionTemplatesAsync();
|
{
|
||||||
_versions = Constants.ReleaseVersions.Split(',').Where(item => Version.Parse(item).CompareTo(Version.Parse("2.0.0")) >= 0).ToArray();
|
if (Version.Parse(version).CompareTo(Version.Parse(_minversion)) >= 0)
|
||||||
|
{
|
||||||
if (string.IsNullOrEmpty(_moduledefinitionname))
|
<option value="@(version)">@(version)</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<option value="local">@SharedLocalizer["LocalVersion"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (!string.IsNullOrEmpty(_location))
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Info.Module.Creator"], MessageType.Info);
|
<div class="row mb-1 align-items-center">
|
||||||
}
|
<Label Class="col-sm-3" For="location" HelpText="Location where the module will be created" ResourceKey="Location">Location: </Label>
|
||||||
else
|
<div class="col-sm-9">
|
||||||
{
|
<input id="module" class="form-control" @bind="@_location" readonly />
|
||||||
AddModuleMessage(Localizer["Info.Module.Activate"], MessageType.Info);
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-success" @onclick="CreateModule">@Localizer["Module.Create"]</button>
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Module Creator");
|
<button type="button" class="btn btn-success" @onclick="ActivateModule">@Localizer["Module.Activate"]</button>
|
||||||
}
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CreateModule()
|
@code {
|
||||||
{
|
private ElementReference form;
|
||||||
try
|
private bool validated = false;
|
||||||
{
|
private string _moduledefinitionname = string.Empty;
|
||||||
if (IsValid(_owner) && IsValid(_module) && _owner != _module && _template != "-")
|
private string _owner = string.Empty;
|
||||||
|
private string _module = string.Empty;
|
||||||
|
private string _description = string.Empty;
|
||||||
|
private List<Template> _templates;
|
||||||
|
private string _template = "-";
|
||||||
|
private string[] _versions;
|
||||||
|
private string _reference = Constants.Version;
|
||||||
|
private string _minversion = "2.0.0";
|
||||||
|
private string _location = string.Empty;
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference };
|
try
|
||||||
moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition);
|
{
|
||||||
|
_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();
|
||||||
|
|
||||||
var settings = ModuleState.Settings;
|
if (string.IsNullOrEmpty(_moduledefinitionname))
|
||||||
SettingService.SetSetting(settings, "ModuleDefinitionName", moduleDefinition.ModuleDefinitionName);
|
{
|
||||||
await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId);
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
GetLocation();
|
||||||
|
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
private void GetLocation()
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Require.ValidName"], MessageType.Warning);
|
_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 Creating Module");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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,151 +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>
|
|
||||||
|
|
||||||
<button type="button" class="btn btn-success" @onclick="InstallModules">@SharedLocalizer["Install"]</button>
|
@if (_packages != null)
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private List<Package> _packages;
|
|
||||||
private string _search = "";
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await LoadModuleDefinitions();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Packages {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Package.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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())
|
|
||||||
{
|
{
|
||||||
if (moduledefinitions.Exists(item => item.PackageName == package.PackageId))
|
if (_packages.Count > 0)
|
||||||
{
|
{
|
||||||
_packages.Remove(package);
|
<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>
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private List<Package> _packages;
|
||||||
|
private string _search = "";
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await LoadModuleDefinitions();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Packages {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Package.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
if (moduledefinitions.Exists(item => item.PackageName == package.PackageId))
|
||||||
|
{
|
||||||
|
_packages.Remove(package);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Search()
|
private async Task Search()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await LoadModuleDefinitions();
|
try
|
||||||
|
{
|
||||||
|
await LoadModuleDefinitions();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error On Search");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error On Search");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Reset()
|
private async Task Reset()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
_search = "";
|
try
|
||||||
await LoadModuleDefinitions();
|
{
|
||||||
|
_search = "";
|
||||||
|
await LoadModuleDefinitions();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error On Reset");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error On Reset");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task InstallModules()
|
private async Task InstallModules()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await ModuleDefinitionService.InstallModuleDefinitionsAsync();
|
try
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Module.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
{
|
||||||
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Installing Module");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DownloadModule(string packageid, string version)
|
private async Task DownloadModule(string packageid, string version)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
try
|
||||||
await logger.LogInformation("Module {ModuleDefinitionName} {Version} Downloaded Successfully", packageid, version);
|
{
|
||||||
AddModuleMessage(Localizer["Success.Module.Download"], MessageType.Success);
|
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
||||||
StateHasChanged();
|
await logger.LogInformation("Module {ModuleDefinitionName} {Version} Downloaded Successfully", packageid, version);
|
||||||
}
|
AddModuleMessage(Localizer["Success.Module.Download"], MessageType.Success);
|
||||||
catch (Exception ex)
|
StateHasChanged();
|
||||||
{
|
}
|
||||||
await logger.LogError(ex, "Error Downloading Module {ModuleDefinitionName} {Version}", packageid, version);
|
catch (Exception ex)
|
||||||
AddModuleMessage(Localizer["Error.Module.Download"], MessageType.Error);
|
{
|
||||||
|
await logger.LogError(ex, "Error Downloading Module {ModuleDefinitionName} {Version}", packageid, version);
|
||||||
|
AddModuleMessage(Localizer["Error.Module.Download"], MessageType.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -10,142 +10,155 @@
|
|||||||
|
|
||||||
@if (_templates != null)
|
@if (_templates != null)
|
||||||
{
|
{
|
||||||
<div class="container">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<Label Class="col-sm-3" For="owner" HelpText="Enter the name of the organization who is developing this module. It should not contain spaces or punctuation." ResourceKey="OwnerName">Owner Name: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="owner" class="form-control" @bind="@_owner" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="module" HelpText="Enter a name for this module. It should not contain spaces or punctuation." ResourceKey="ModuleName">Module Name: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="module" class="form-control" @bind="@_module" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="description" HelpText="Enter a short description for the module" ResourceKey="Description">Description: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea id="description" class="form-control" @bind="@_description" rows="3"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="template" HelpText="Select a module template. Templates are located in the wwwroot/Modules/Templates folder on the server." ResourceKey="Template">Template: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="template" class="form-select" @onchange="(e => TemplateChanged(e))">
|
|
||||||
<option value="-"><@Localizer["Template.Select"]></option>
|
|
||||||
@foreach (Template template in _templates)
|
|
||||||
{
|
|
||||||
<option value="@template.Name">@template.Title</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="reference" HelpText="Select a framework reference version" ResourceKey="FrameworkReference">Framework Reference: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="reference" class="form-select" @bind="@_reference">
|
|
||||||
@foreach (string version in _versions)
|
|
||||||
{
|
|
||||||
if (Version.Parse(version).CompareTo(Version.Parse(_minversion)) >= 0)
|
|
||||||
{
|
|
||||||
<option value="@(version)">@(version)</option>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<option value="local">@SharedLocalizer["LocalVersion"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@if (!string.IsNullOrEmpty(_location))
|
|
||||||
{
|
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="location" HelpText="Location where the module will be created" ResourceKey="Location">Location: </Label>
|
<Label Class="col-sm-3" For="owner" HelpText="Enter the name of the organization who is developing this module. It should not contain spaces or punctuation." ResourceKey="OwnerName">Owner Name: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="module" class="form-control" @bind="@_location" readonly />
|
<input id="owner" class="form-control" @bind="@_owner" maxlength="256" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
<div class="row mb-1 align-items-center">
|
||||||
</div>
|
<Label Class="col-sm-3" For="module" HelpText="Enter a name for this module. It should not contain spaces or punctuation." ResourceKey="ModuleName">Module Name: </Label>
|
||||||
<button type="button" class="btn btn-success" @onclick="CreateModule">@Localizer["CreateModule"]</button>
|
<div class="col-sm-9">
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<input id="module" class="form-control" @bind="@_module" maxlength="256" required />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="description" HelpText="Enter a short description for the module" ResourceKey="Description">Description: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<textarea id="description" class="form-control" @bind="@_description" rows="3" required></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="template" HelpText="Select a module template. Templates are located in the wwwroot/Modules/Templates folder on the server." ResourceKey="Template">Template: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="template" class="form-select" @onchange="(e => TemplateChanged(e))" required>
|
||||||
|
<option value="-"><@Localizer["Template.Select"]></option>
|
||||||
|
@foreach (Template template in _templates)
|
||||||
|
{
|
||||||
|
<option value="@template.Name">@template.Title</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="reference" HelpText="Select a framework reference version" ResourceKey="FrameworkReference">Framework Reference: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="reference" class="form-select" @bind="@_reference" required>
|
||||||
|
@foreach (string version in _versions)
|
||||||
|
{
|
||||||
|
if (Version.Parse(version).CompareTo(Version.Parse(_minversion)) >= 0)
|
||||||
|
{
|
||||||
|
<option value="@(version)">@(version)</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<option value="local">@SharedLocalizer["LocalVersion"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (!string.IsNullOrEmpty(_location))
|
||||||
|
{
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="location" HelpText="Location where the module will be created" ResourceKey="Location">Location: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="module" class="form-control" @bind="@_location" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn btn-success" @onclick="CreateModule">@Localizer["CreateModule"]</button>
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _owner = string.Empty;
|
private ElementReference form;
|
||||||
private string _module = string.Empty;
|
private bool validated = false;
|
||||||
private string _description = string.Empty;
|
private string _owner = string.Empty;
|
||||||
private List<Template> _templates;
|
private string _module = string.Empty;
|
||||||
private string _template = "-";
|
private string _description = string.Empty;
|
||||||
private string[] _versions;
|
private List<Template> _templates;
|
||||||
private string _reference = Constants.Version;
|
private string _template = "-";
|
||||||
private string _minversion = "2.0.0";
|
private string[] _versions;
|
||||||
private string _location = string.Empty;
|
private string _reference = Constants.Version;
|
||||||
|
private string _minversion = "2.0.0";
|
||||||
|
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()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (IsValid(_owner) && IsValid(_module) && _owner != _module && _template != "-")
|
|
||||||
{
|
{
|
||||||
var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference };
|
try
|
||||||
moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition);
|
{
|
||||||
|
_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
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
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();
|
GetLocation();
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
private void GetLocation()
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Require.ValidName"], MessageType.Warning);
|
_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 Creating 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -5,74 +5,75 @@
|
|||||||
@inject IStringLocalizer<Edit> Localizer
|
@inject IStringLocalizer<Edit> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<TabStrip>
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<TabPanel Name="Definition" ResourceKey="Definition">
|
<TabStrip>
|
||||||
<div class="container">
|
<TabPanel Name="Definition" ResourceKey="Definition">
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="name" HelpText="The name of the module" ResourceKey="Name">Name: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="name" class="form-control" @bind="@_name" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="description" HelpText="The description of the module" ResourceKey="Description">Description: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea id="description" class="form-control" @bind="@_description" rows="2"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="categories" HelpText="Comma delimited list of module categories" ResourceKey="Categories">Categories: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="categories" class="form-control" @bind="@_categories" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Section Name="Information" ResourceKey="Information">
|
|
||||||
<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="moduledefinitionname" HelpText="The internal name of the module" ResourceKey="InternalName">Internal Name: </Label>
|
<Label Class="col-sm-3" For="name" HelpText="The name of the module" ResourceKey="Name">Name: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="moduledefinitionname" class="form-control" @bind="@_moduledefinitionname" disabled />
|
<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">
|
||||||
<Label Class="col-sm-3" For="version" HelpText="The version of the module" ResourceKey="Version">Version: </Label>
|
<Label Class="col-sm-3" For="description" HelpText="The description of the module" ResourceKey="Description">Description: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="version" class="form-control" @bind="@_version" disabled />
|
<textarea id="description" class="form-control" @bind="@_description" rows="2" required></textarea>
|
||||||
</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="owner" HelpText="The owner or creator of the module" ResourceKey="Owner">Owner: </Label>
|
<Label Class="col-sm-3" For="categories" HelpText="Comma delimited list of module categories" ResourceKey="Categories">Categories: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="owner" class="form-control" @bind="@_owner" disabled />
|
<input id="categories" class="form-control" @bind="@_categories" required />
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="url" HelpText="The reference url of the module" 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 module" 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 module license terms" ResourceKey="License">License: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea id="license" class="form-control" @bind="@_license" rows="5" disabled></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="runtimes" HelpText="The Blazor runtimes which this module supports" ResourceKey="Runtimes">Runtimes: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="runtimes" class="form-control" @bind="@_runtimes" disabled />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
<Section Name="Information" ResourceKey="Information">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="moduledefinitionname" HelpText="The internal name of the module" ResourceKey="InternalName">Internal Name: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="moduledefinitionname" class="form-control" @bind="@_moduledefinitionname" disabled />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="version" HelpText="The version of the module" 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 module" 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 module" 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 module" 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 module license terms" ResourceKey="License">License: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<textarea id="license" class="form-control" @bind="@_license" rows="5" disabled></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="runtimes" HelpText="The Blazor runtimes which this module supports" ResourceKey="Runtimes">Runtimes: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="runtimes" class="form-control" @bind="@_runtimes" disabled />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Section>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel Name="Permissions" ResourceKey="Permissions">
|
<TabPanel Name="Permissions" ResourceKey="Permissions">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -87,8 +88,11 @@
|
|||||||
<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>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
private ElementReference form;
|
||||||
|
private bool validated = false;
|
||||||
private int _moduleDefinitionId;
|
private int _moduleDefinitionId;
|
||||||
private string _name;
|
private string _name;
|
||||||
private string _version;
|
private string _version;
|
||||||
@ -146,30 +150,39 @@
|
|||||||
|
|
||||||
private async Task SaveModuleDefinition()
|
private async Task SaveModuleDefinition()
|
||||||
{
|
{
|
||||||
try
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
var moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId);
|
try
|
||||||
if (moduledefinition.Name != _name)
|
|
||||||
{
|
{
|
||||||
moduledefinition.Name = _name;
|
var moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId);
|
||||||
|
if (moduledefinition.Name != _name)
|
||||||
|
{
|
||||||
|
moduledefinition.Name = _name;
|
||||||
|
}
|
||||||
|
if (moduledefinition.Description != _description)
|
||||||
|
{
|
||||||
|
moduledefinition.Description = _description;
|
||||||
|
}
|
||||||
|
if (moduledefinition.Categories != _categories)
|
||||||
|
{
|
||||||
|
moduledefinition.Categories = _categories;
|
||||||
|
}
|
||||||
|
moduledefinition.Permissions = _permissionGrid.GetPermissions();
|
||||||
|
await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition);
|
||||||
|
await logger.LogInformation("ModuleDefinition Saved {ModuleDefinition}", moduledefinition);
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
if (moduledefinition.Description != _description)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
moduledefinition.Description = _description;
|
await logger.LogError(ex, "Error Saving ModuleDefinition {ModuleDefinitionId} {Error}", _moduleDefinitionId, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Module.Save"], MessageType.Error);
|
||||||
}
|
}
|
||||||
if (moduledefinition.Categories != _categories)
|
|
||||||
{
|
|
||||||
moduledefinition.Categories = _categories;
|
|
||||||
}
|
|
||||||
moduledefinition.Permissions = _permissionGrid.GetPermissions();
|
|
||||||
await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition);
|
|
||||||
await logger.LogInformation("ModuleDefinition Saved {ModuleDefinition}", moduledefinition);
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Saving ModuleDefinition {ModuleDefinitionId} {Error}", _moduleDefinitionId, ex.Message);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
AddModuleMessage(Localizer["Error.Module.Save"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
|
||||||
private List<ModuleDefinition> _moduleDefinitions;
|
|
||||||
private List<Package> _packages;
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_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)
|
@code {
|
||||||
{
|
private List<ModuleDefinition> _moduleDefinitions;
|
||||||
var upgradeavailable = false;
|
private List<Package> _packages;
|
||||||
if (_packages != null)
|
|
||||||
{
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault();
|
|
||||||
if (package != null)
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0);
|
try
|
||||||
|
{
|
||||||
|
_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)
|
||||||
return upgradeavailable;
|
{
|
||||||
}
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task DownloadModule(string packagename, string version)
|
}
|
||||||
{
|
return upgradeavailable;
|
||||||
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)
|
private async Task DownloadModule(string packagename, string version)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await ModuleDefinitionService.DeleteModuleDefinitionAsync(moduleDefinition.ModuleDefinitionId, moduleDefinition.SiteId);
|
await PackageService.DownloadPackageAsync(packagename, version, "Packages");
|
||||||
AddModuleMessage(Localizer["Success.Module.Delete"], MessageType.Success);
|
await logger.LogInformation("Module Downloaded {ModuleDefinitionName} {Version}", packagename, version);
|
||||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Page.Path, true));
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Deleting Module {ModuleDefinition} {Error}", moduleDefinition, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Module.Delete"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -5,28 +5,39 @@
|
|||||||
@inject IStringLocalizer<Export> Localizer
|
@inject IStringLocalizer<Export> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
|
<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="content" HelpText="Enter the module content" ResourceKey="Content">Content: </Label>
|
<Label Class="col-sm-3" For="content" HelpText="Enter the module content" ResourceKey="Content">Content: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<textarea id="content" class="form-control" @bind="@_content" rows="5"></textarea>
|
<textarea id="content" class="form-control" @bind="@_content" rows="5" required></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="button" class="btn btn-success" @onclick="ExportModule">@Localizer["Export"]</button>
|
<button type="button" class="btn btn-success" @onclick="ExportModule">@Localizer["Export"]</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
private ElementReference form;
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
_content = await ModuleService.ExportModuleAsync(ModuleState.ModuleId);
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
_content = await ModuleService.ExportModuleAsync(ModuleState.ModuleId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
@inject IStringLocalizer<Import> Localizer
|
@inject IStringLocalizer<Import> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
|
<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="content" HelpText="Enter the module content" ResourceKey="Content">Content: </Label>
|
<Label Class="col-sm-3" For="content" HelpText="Enter the module content" ResourceKey="Content">Content: </Label>
|
||||||
@ -17,39 +18,50 @@
|
|||||||
|
|
||||||
<button type="button" class="btn btn-success" @onclick="ImportModule">@Localizer["Import"]</button>
|
<button type="button" class="btn btn-success" @onclick="ImportModule">@Localizer["Import"]</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _content = string.Empty;
|
private string _content = string.Empty;
|
||||||
|
private ElementReference form;
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
if (_content != string.Empty)
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
try
|
if (_content != string.Empty)
|
||||||
{
|
{
|
||||||
bool success = await ModuleService.ImportModuleAsync(ModuleState.ModuleId, _content);
|
try
|
||||||
if (success)
|
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Success.Content.Import"], MessageType.Success);
|
bool success = await ModuleService.ImportModuleAsync(ModuleState.ModuleId, _content);
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Success.Content.Import"], MessageType.Success);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Content.ImportProblem"], MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Content.ImportProblem"], MessageType.Warning);
|
await logger.LogError(ex, "Error Importing Module {ModuleId} {Error}", ModuleState.ModuleId, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Module.Import"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Importing Module {ModuleId} {Error}", ModuleState.ModuleId, ex.Message);
|
AddModuleMessage(Localizer["Message.Required.ImportContent"], MessageType.Warning);
|
||||||
AddModuleMessage(Localizer["Error.Module.Import"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.ImportContent"], MessageType.Warning);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,215 +8,228 @@
|
|||||||
@inject IStringLocalizer<Settings> Localizer
|
@inject IStringLocalizer<Settings> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<TabStrip>
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<TabPanel Name="Settings" Heading="Settings" ResourceKey="Settings">
|
<TabStrip>
|
||||||
@if (_containers != null)
|
<TabPanel Name="Settings" Heading="Settings" ResourceKey="Settings">
|
||||||
{
|
@if (_containers != null)
|
||||||
<div class="container">
|
|
||||||
<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>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="title" type="text" name="Title" class="form-control" @bind="@_title" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="container" HelpText="Select the module's container" ResourceKey="Container">Container: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="container" class="form-select" @bind="@_containerType">
|
|
||||||
@foreach (var container in _containers)
|
|
||||||
{
|
|
||||||
<option value="@container.TypeName">@container.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="allpages" HelpText="Indicate if this module should be displayed on all pages" ResourceKey="DisplayOnAllPages">Display On All Pages? </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="allpages" class="form-select" @bind="@_allPages">
|
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="page" HelpText="The page that the module is located on" ResourceKey="Page">Page: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="page" class="form-select" @bind="@_pageId">
|
|
||||||
@foreach (Page p in PageState.Pages)
|
|
||||||
{
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.Permissions))
|
|
||||||
{
|
|
||||||
<option value="@p.PageId">@(new string('-', p.Level * 2))@(p.Name)</option>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</TabPanel>
|
|
||||||
<TabPanel Name="Permissions" ResourceKey="Permissions">
|
|
||||||
@if (_permissions != null)
|
|
||||||
{
|
|
||||||
<div class="container">
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<PermissionGrid EntityName="@EntityNames.Module" PermissionNames="@_permissionNames" Permissions="@_permissions" @ref="_permissionGrid" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
}
|
|
||||||
</TabPanel>
|
|
||||||
@if (_moduleSettingsType != null)
|
|
||||||
{
|
|
||||||
<TabPanel Name="ModuleSettings" Heading="@_moduleSettingsTitle" ResourceKey="ModuleSettings">
|
|
||||||
@ModuleSettingsComponent
|
|
||||||
</TabPanel>
|
|
||||||
}
|
|
||||||
@if (_containerSettingsType != null)
|
|
||||||
{
|
|
||||||
<TabPanel Name="ContainerSettings" Heading="Container Settings" ResourceKey="ContainerSettings">
|
|
||||||
@ContainerSettingsComponent
|
|
||||||
</TabPanel>
|
|
||||||
}
|
|
||||||
</TabStrip>
|
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveModule">@SharedLocalizer["Save"]</button>
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
|
||||||
|
|
||||||
@code {
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
|
|
||||||
public override string Title => "Module Settings";
|
|
||||||
|
|
||||||
private List<Theme> _themes;
|
|
||||||
private List<ThemeControl> _containers = new List<ThemeControl>();
|
|
||||||
private string _title;
|
|
||||||
private string _containerType;
|
|
||||||
private string _allPages = "false";
|
|
||||||
private string _permissionNames = "";
|
|
||||||
private string _permissions = null;
|
|
||||||
private string _pageId;
|
|
||||||
private PermissionGrid _permissionGrid;
|
|
||||||
private Type _moduleSettingsType;
|
|
||||||
private object _moduleSettings;
|
|
||||||
private string _moduleSettingsTitle = "Module Settings";
|
|
||||||
private RenderFragment ModuleSettingsComponent { get; set; }
|
|
||||||
private Type _containerSettingsType;
|
|
||||||
private object _containerSettings;
|
|
||||||
private RenderFragment ContainerSettingsComponent { get; set; }
|
|
||||||
private string createdby;
|
|
||||||
private DateTime createdon;
|
|
||||||
private string modifiedby;
|
|
||||||
private DateTime modifiedon;
|
|
||||||
|
|
||||||
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))
|
|
||||||
{
|
|
||||||
// module settings type explicitly declared in IModule interface
|
|
||||||
_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;
|
<div class="container">
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="title" type="text" name="Title" class="form-control" @bind="@_title" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="container" HelpText="Select the module's container" ResourceKey="Container">Container: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="container" class="form-select" @bind="@_containerType" required>
|
||||||
|
@foreach (var container in _containers)
|
||||||
|
{
|
||||||
|
<option value="@container.TypeName">@container.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="allpages" HelpText="Indicate if this module should be displayed on all pages" ResourceKey="DisplayOnAllPages">Display On All Pages? </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="allpages" class="form-select" @bind="@_allPages" required>
|
||||||
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="page" HelpText="The page that the module is located on" ResourceKey="Page">Page: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="page" class="form-select" @bind="@_pageId" required>
|
||||||
|
@foreach (Page p in PageState.Pages)
|
||||||
|
{
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.Permissions))
|
||||||
|
{
|
||||||
|
<option value="@p.PageId">@(new string('-', p.Level * 2))@(p.Name)</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
|
</TabPanel>
|
||||||
ModuleSettingsComponent = builder =>
|
<TabPanel Name="Permissions" ResourceKey="Permissions">
|
||||||
|
@if (_permissions != null)
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, _moduleSettingsType);
|
<div class="container">
|
||||||
builder.AddComponentReferenceCapture(1, inst => { _moduleSettings = Convert.ChangeType(inst, _moduleSettingsType); });
|
<div class="row mb-1 align-items-center">
|
||||||
builder.CloseComponent();
|
<PermissionGrid EntityName="@EntityNames.Module" PermissionNames="@_permissionNames" Permissions="@_permissions" @ref="_permissionGrid" />
|
||||||
};
|
</div>
|
||||||
}
|
</div>
|
||||||
|
|
||||||
var theme = _themes.FirstOrDefault(item => item.Containers.Any(themecontrol => themecontrol.TypeName.Equals(_containerType)));
|
}
|
||||||
if (theme != null && !string.IsNullOrEmpty(theme.ContainerSettingsType))
|
</TabPanel>
|
||||||
|
@if (_moduleSettingsType != null)
|
||||||
{
|
{
|
||||||
_containerSettingsType = Type.GetType(theme.ContainerSettingsType);
|
<TabPanel Name="ModuleSettings" Heading="@_moduleSettingsTitle" ResourceKey="ModuleSettings">
|
||||||
if (_containerSettingsType != null)
|
@ModuleSettingsComponent
|
||||||
|
</TabPanel>
|
||||||
|
}
|
||||||
|
@if (_containerSettingsType != null)
|
||||||
|
{
|
||||||
|
<TabPanel Name="ContainerSettings" Heading="Container Settings" ResourceKey="ContainerSettings">
|
||||||
|
@ContainerSettingsComponent
|
||||||
|
</TabPanel>
|
||||||
|
}
|
||||||
|
</TabStrip>
|
||||||
|
<button type="button" class="btn btn-success" @onclick="SaveModule">@SharedLocalizer["Save"]</button>
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
|
||||||
|
public override string Title => "Module Settings";
|
||||||
|
|
||||||
|
private ElementReference form;
|
||||||
|
private bool validated = false;
|
||||||
|
private List<Theme> _themes;
|
||||||
|
private List<ThemeControl> _containers = new List<ThemeControl>();
|
||||||
|
private string _title;
|
||||||
|
private string _containerType;
|
||||||
|
private string _allPages = "false";
|
||||||
|
private string _permissionNames = "";
|
||||||
|
private string _permissions = null;
|
||||||
|
private string _pageId;
|
||||||
|
private PermissionGrid _permissionGrid;
|
||||||
|
private Type _moduleSettingsType;
|
||||||
|
private object _moduleSettings;
|
||||||
|
private string _moduleSettingsTitle = "Module Settings";
|
||||||
|
private RenderFragment ModuleSettingsComponent { get; set; }
|
||||||
|
private Type _containerSettingsType;
|
||||||
|
private object _containerSettings;
|
||||||
|
private RenderFragment ContainerSettingsComponent { get; set; }
|
||||||
|
private string createdby;
|
||||||
|
private DateTime createdon;
|
||||||
|
private string modifiedby;
|
||||||
|
private DateTime modifiedon;
|
||||||
|
|
||||||
|
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))
|
||||||
{
|
{
|
||||||
ContainerSettingsComponent = builder =>
|
// module settings type explicitly declared in IModule interface
|
||||||
|
_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))
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, _containerSettingsType);
|
_moduleSettingsTitle = moduleobject.Title;
|
||||||
builder.AddComponentReferenceCapture(1, inst => { _containerSettings = Convert.ChangeType(inst, _containerSettingsType); });
|
}
|
||||||
|
|
||||||
|
ModuleSettingsComponent = builder =>
|
||||||
|
{
|
||||||
|
builder.OpenComponent(0, _moduleSettingsType);
|
||||||
|
builder.AddComponentReferenceCapture(1, inst => { _moduleSettings = Convert.ChangeType(inst, _moduleSettingsType); });
|
||||||
builder.CloseComponent();
|
builder.CloseComponent();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SaveModule()
|
var theme = _themes.FirstOrDefault(item => item.Containers.Any(themecontrol => themecontrol.TypeName.Equals(_containerType)));
|
||||||
{
|
if (theme != null && !string.IsNullOrEmpty(theme.ContainerSettingsType))
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
pagemodule.ContainerType = string.Empty;
|
_containerSettingsType = Type.GetType(theme.ContainerSettingsType);
|
||||||
}
|
if (_containerSettingsType != null)
|
||||||
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
|
ContainerSettingsComponent = builder =>
|
||||||
await moduleSettingsControl.UpdateSettings();
|
{
|
||||||
|
builder.OpenComponent(0, _containerSettingsType);
|
||||||
|
builder.AddComponentReferenceCapture(1, inst => { _containerSettings = Convert.ChangeType(inst, _containerSettingsType); });
|
||||||
|
builder.CloseComponent();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveModule()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
// legacy support - module settings updated by convention ( ie. by calling a public method named "UpdateSettings" in settings component )
|
AddModuleMessage(Localizer["Message.Required.Title"], MessageType.Warning);
|
||||||
_moduleSettings?.GetType().GetMethod("UpdateSettings")?.Invoke(_moduleSettings, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (_containerSettingsType != null && _containerSettings is ISettingsControl containerSettingsControl)
|
|
||||||
{
|
{
|
||||||
await containerSettingsControl.UpdateSettings();
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Required.Title"], MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -6,151 +6,154 @@
|
|||||||
@inject IStringLocalizer<Add> Localizer
|
@inject IStringLocalizer<Add> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<TabStrip Refresh="@_refresh">
|
|
||||||
<TabPanel Name="Settings" ResourceKey="Settings">
|
|
||||||
@if (_themeList != null)
|
|
||||||
{
|
|
||||||
<div class="container">
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Name" HelpText="Enter the page name" ResourceKey="Name">Name: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="Name" class="form-control" @bind="@_name" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Parent" HelpText="Select the parent for the page in the site hierarchy" ResourceKey="Parent">Parent: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="Parent" class="form-select" @onchange="(e => ParentChanged(e))">
|
|
||||||
<option value="-1"><@Localizer["SiteRoot"]></option>
|
|
||||||
@foreach (Page page in _pageList)
|
|
||||||
{
|
|
||||||
<option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Insert" HelpText="Select the location where you would like the page to be inserted in relation to other pages" ResourceKey="Insert">Insert: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="Insert" class="form-select" @bind="@_insert">
|
|
||||||
<option value="<<">@Localizer["AtBeginning"]</option>
|
|
||||||
@if (_children != null && _children.Count > 0)
|
|
||||||
{
|
|
||||||
<option value="<">@Localizer["Before"]</option>
|
|
||||||
<option value=">">@Localizer["After"]</option>
|
|
||||||
}
|
|
||||||
<option value=">>">@Localizer["AtEnd"]</option>
|
|
||||||
</select>
|
|
||||||
@if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">"))
|
|
||||||
{
|
|
||||||
<select class="form-select" @bind="@_childid">
|
|
||||||
<option value="-1"><@Localizer["Page.Select"]></option>
|
|
||||||
@foreach (Page page in _children)
|
|
||||||
{
|
|
||||||
<option value="@(page.PageId)">@(page.Name)</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="navigation" HelpText="Select whether the page is part of the site navigation or hidden" ResourceKey="Navigation">Navigation? </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="navigation" class="form-select" @bind="@_isnavigation">
|
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="clickable" HelpText="Select whether the link in the site navigation is enabled or disabled" ResourceKey="Clickable">Clickable? </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="clickable" class="form-select" @bind="@_isclickable">
|
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Path" HelpText="Optionally enter a url path for this page (ie. home ). If you do not provide a url path, the page name will be used." ResourceKey="UrlPath">Url Path: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="Path" class="form-control" @bind="@_path" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Url" HelpText="Optionally enter a url which this page should redirect to when a user navigates to it" ResourceKey="Redirect">Redirect: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="Url" class="form-control" @bind="@_url" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Section Name="Appearance" ResourceKey="Appearance">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
|
<TabStrip Refresh="@_refresh">
|
||||||
|
<TabPanel Name="Settings" ResourceKey="Settings">
|
||||||
|
@if (_themeList != 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" For="Title" HelpText="Optionally enter the page title. If you do not provide a page title, the page name will be used." ResourceKey="Title">Title: </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="Title" class="form-control" @bind="@_title" />
|
<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="Theme" HelpText="Select the theme for this page" ResourceKey="Theme">Theme: </Label>
|
<Label Class="col-sm-3" For="Parent" HelpText="Select the parent for the page in the site hierarchy" ResourceKey="Parent">Parent: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<select id="Theme" class="form-select" value="@_themetype" @onchange="(e => ThemeChanged(e))">
|
<select id="Parent" class="form-select" @onchange="(e => ParentChanged(e))" required>
|
||||||
@foreach (var theme in _themes)
|
<option value="-1"><@Localizer["SiteRoot"]></option>
|
||||||
|
@foreach (Page page in _pageList)
|
||||||
{
|
{
|
||||||
<option value="@theme.TypeName">@theme.Name</option>
|
<option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</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="defaultContainer" HelpText="Select the default container for the page" ResourceKey="DefaultContainer">Default Container: </Label>
|
<Label Class="col-sm-3" For="Insert" HelpText="Select the location where you would like the page to be inserted in relation to other pages" ResourceKey="Insert">Insert: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<select id="defaultContainer" class="form-select" @bind="@_containertype">
|
<select id="Insert" class="form-select" @bind="@_insert" required>
|
||||||
<option value="-"><@Localizer["Container.Select"]></option>
|
<option value="<<">@Localizer["AtBeginning"]</option>
|
||||||
@foreach (var container in _containers)
|
@if (_children != null && _children.Count > 0)
|
||||||
{
|
{
|
||||||
<option value="@container.TypeName">@container.Name</option>
|
<option value="<">@Localizer["Before"]</option>
|
||||||
|
<option value=">">@Localizer["After"]</option>
|
||||||
}
|
}
|
||||||
|
<option value=">>">@Localizer["AtEnd"]</option>
|
||||||
</select>
|
</select>
|
||||||
|
@if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">"))
|
||||||
|
{
|
||||||
|
<select class="form-select" @bind="@_childid">
|
||||||
|
<option value="-1"><@Localizer["Page.Select"]></option>
|
||||||
|
@foreach (Page page in _children)
|
||||||
|
{
|
||||||
|
<option value="@(page.PageId)">@(page.Name)</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
}
|
||||||
</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="Icon" HelpText="Optionally provide an icon class name for this page which will be displayed in the site navigation" ResourceKey="Icon">Icon: </Label>
|
<Label Class="col-sm-3" For="navigation" HelpText="Select whether the page is part of the site navigation or hidden" ResourceKey="Navigation">Navigation? </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="Icon" class="form-control" @bind="@_icon" />
|
<select id="navigation" class="form-select" @bind="@_isnavigation" required>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Personalizable" HelpText="Select whether you would like users to be able to personalize this page with their own content" ResourceKey="Personalizable">Personalizable? </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="Personalizable" class="form-select" @bind="@_ispersonalizable">
|
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="clickable" HelpText="Select whether the link in the site navigation is enabled or disabled" ResourceKey="Clickable">Clickable? </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="clickable" class="form-select" @bind="@_isclickable" required>
|
||||||
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="Path" HelpText="Optionally enter a url path for this page (ie. home ). If you do not provide a url path, the page name will be used." ResourceKey="UrlPath">Url Path: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="Path" class="form-control" @bind="@_path" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="Url" HelpText="Optionally enter a url which this page should redirect to when a user navigates to it" ResourceKey="Redirect">Redirect: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="Url" class="form-control" @bind="@_url" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
|
||||||
}
|
<Section Name="Appearance" ResourceKey="Appearance">
|
||||||
</TabPanel>
|
<div class="container">
|
||||||
<TabPanel Name="Permissions" ResourceKey="Permissions">
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="container">
|
<Label Class="col-sm-3" For="Title" HelpText="Optionally enter the page title. If you do not provide a page title, the page name will be used." ResourceKey="Title">Title: </Label>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="col-sm-9">
|
||||||
<PermissionGrid EntityName="@EntityNames.Page" Permissions="@_permissions" @ref="_permissionGrid" />
|
<input id="Title" class="form-control" @bind="@_title" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</TabPanel>
|
<div class="row mb-1 align-items-center">
|
||||||
@if (_themeSettingsType != null)
|
<Label Class="col-sm-3" For="Theme" HelpText="Select the theme for this page" ResourceKey="Theme">Theme: </Label>
|
||||||
{
|
<div class="col-sm-9">
|
||||||
<TabPanel Name="ThemeSettings" Heading="Theme Settings" ResourceKey="ThemeSettings">
|
<select id="Theme" class="form-select" value="@_themetype" @onchange="(e => ThemeChanged(e))" required>
|
||||||
@ThemeSettingsComponent
|
@foreach (var theme in _themes)
|
||||||
|
{
|
||||||
|
<option value="@theme.TypeName">@theme.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="defaultContainer" HelpText="Select the default container for the page" ResourceKey="DefaultContainer">Default Container: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="defaultContainer" class="form-select" @bind="@_containertype" required>
|
||||||
|
<option value="-"><@Localizer["Container.Select"]></option>
|
||||||
|
@foreach (var container in _containers)
|
||||||
|
{
|
||||||
|
<option value="@container.TypeName">@container.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="Icon" HelpText="Optionally provide an icon class name for this page which will be displayed in the site navigation" ResourceKey="Icon">Icon: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="Icon" class="form-control" @bind="@_icon" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="Personalizable" HelpText="Select whether you would like users to be able to personalize this page with their own content" ResourceKey="Personalizable">Personalizable? </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="Personalizable" class="form-select" @bind="@_ispersonalizable" required>
|
||||||
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Section>
|
||||||
|
}
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
}
|
<TabPanel Name="Permissions" ResourceKey="Permissions">
|
||||||
</TabStrip>
|
<div class="container">
|
||||||
<button type="button" class="btn btn-success" @onclick="SavePage">@SharedLocalizer["Save"]</button>
|
<div class="row mb-1 align-items-center">
|
||||||
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
<PermissionGrid EntityName="@EntityNames.Page" Permissions="@_permissions" @ref="_permissionGrid" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</TabPanel>
|
||||||
|
@if (_themeSettingsType != null)
|
||||||
|
{
|
||||||
|
<TabPanel Name="ThemeSettings" Heading="Theme Settings" ResourceKey="ThemeSettings">
|
||||||
|
@ThemeSettingsComponent
|
||||||
|
</TabPanel>
|
||||||
|
}
|
||||||
|
</TabStrip>
|
||||||
|
<button type="button" class="btn btn-success" @onclick="SavePage">@SharedLocalizer["Save"]</button>
|
||||||
|
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
@ -179,6 +182,8 @@
|
|||||||
private object _themeSettings;
|
private object _themeSettings;
|
||||||
private RenderFragment ThemeSettingsComponent { get; set; }
|
private RenderFragment ThemeSettingsComponent { get; set; }
|
||||||
private bool _refresh = false;
|
private bool _refresh = false;
|
||||||
|
private ElementReference form;
|
||||||
|
private bool validated = false;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
@ -275,110 +280,119 @@
|
|||||||
|
|
||||||
private async Task SavePage()
|
private async Task SavePage()
|
||||||
{
|
{
|
||||||
Page page = null;
|
validated = true;
|
||||||
try
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(_name) && !string.IsNullOrEmpty(_themetype) && _containertype != "-")
|
Page page = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
page = new Page();
|
if (!string.IsNullOrEmpty(_name) && !string.IsNullOrEmpty(_themetype) && _containertype != "-")
|
||||||
page.SiteId = PageState.Page.SiteId;
|
|
||||||
page.Name = _name;
|
|
||||||
page.Title = _title;
|
|
||||||
if (_path == "")
|
|
||||||
{
|
{
|
||||||
_path = _name;
|
page = new Page();
|
||||||
}
|
page.SiteId = PageState.Page.SiteId;
|
||||||
|
page.Name = _name;
|
||||||
if (_path.Contains("/"))
|
page.Title = _title;
|
||||||
{
|
if (_path == "")
|
||||||
_path = _path.Substring(_path.LastIndexOf("/") + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(_parentid))
|
|
||||||
{
|
|
||||||
page.ParentId = null;
|
|
||||||
page.Path = Utilities.GetFriendlyUrl(_path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
page.ParentId = Int32.Parse(_parentid);
|
|
||||||
var parent = PageState.Pages.Where(item => item.PageId == page.ParentId).FirstOrDefault();
|
|
||||||
if (parent.Path == string.Empty)
|
|
||||||
{
|
{
|
||||||
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
|
_path = _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_path.Contains("/"))
|
||||||
|
{
|
||||||
|
_path = _path.Substring(_path.LastIndexOf("/") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_parentid))
|
||||||
|
{
|
||||||
|
page.ParentId = null;
|
||||||
|
page.Path = Utilities.GetFriendlyUrl(_path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path);
|
page.ParentId = Int32.Parse(_parentid);
|
||||||
|
var parent = PageState.Pages.Where(item => item.PageId == page.ParentId).FirstOrDefault();
|
||||||
|
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, _pageList))
|
if (!PagePathIsUnique(page.Path, page.SiteId, _pageList))
|
||||||
{
|
{
|
||||||
AddModuleMessage(string.Format(Localizer["Message.Page.Exists"], _path), MessageType.Warning);
|
AddModuleMessage(string.Format(Localizer["Message.Page.Exists"], _path), MessageType.Warning);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Page child;
|
Page child;
|
||||||
switch (_insert)
|
switch (_insert)
|
||||||
{
|
{
|
||||||
case "<<":
|
case "<<":
|
||||||
page.Order = 0;
|
page.Order = 0;
|
||||||
break;
|
break;
|
||||||
case "<":
|
case "<":
|
||||||
child = PageState.Pages.Where(item => item.PageId == _childid).FirstOrDefault();
|
child = PageState.Pages.Where(item => item.PageId == _childid).FirstOrDefault();
|
||||||
page.Order = child.Order - 1;
|
page.Order = child.Order - 1;
|
||||||
break;
|
break;
|
||||||
case ">":
|
case ">":
|
||||||
child = PageState.Pages.Where(item => item.PageId == _childid).FirstOrDefault();
|
child = PageState.Pages.Where(item => item.PageId == _childid).FirstOrDefault();
|
||||||
page.Order = child.Order + 1;
|
page.Order = child.Order + 1;
|
||||||
break;
|
break;
|
||||||
case ">>":
|
case ">>":
|
||||||
page.Order = int.MaxValue;
|
page.Order = int.MaxValue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
page.IsNavigation = (_isnavigation == null ? true : Boolean.Parse(_isnavigation));
|
page.IsNavigation = (_isnavigation == null ? true : Boolean.Parse(_isnavigation));
|
||||||
page.IsClickable = (_isclickable == null ? true : Boolean.Parse(_isclickable));
|
page.IsClickable = (_isclickable == null ? true : Boolean.Parse(_isclickable));
|
||||||
page.Url = _url;
|
page.Url = _url;
|
||||||
page.ThemeType = (_themetype != "-") ? _themetype : string.Empty;
|
page.ThemeType = (_themetype != "-") ? _themetype : string.Empty;
|
||||||
if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType)
|
if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType)
|
||||||
{
|
{
|
||||||
page.ThemeType = string.Empty;
|
page.ThemeType = string.Empty;
|
||||||
}
|
}
|
||||||
page.DefaultContainerType = (_containertype != "-") ? _containertype : string.Empty;
|
page.DefaultContainerType = (_containertype != "-") ? _containertype : string.Empty;
|
||||||
if (!string.IsNullOrEmpty(page.DefaultContainerType) && page.DefaultContainerType == PageState.Site.DefaultContainerType)
|
if (!string.IsNullOrEmpty(page.DefaultContainerType) && page.DefaultContainerType == PageState.Site.DefaultContainerType)
|
||||||
{
|
{
|
||||||
page.DefaultContainerType = string.Empty;
|
page.DefaultContainerType = string.Empty;
|
||||||
}
|
}
|
||||||
page.Icon = (_icon == null ? string.Empty : _icon);
|
page.Icon = (_icon == null ? string.Empty : _icon);
|
||||||
page.Permissions = _permissionGrid.GetPermissions();
|
page.Permissions = _permissionGrid.GetPermissions();
|
||||||
page.IsPersonalizable = (_ispersonalizable == null ? false : Boolean.Parse(_ispersonalizable));
|
page.IsPersonalizable = (_ispersonalizable == null ? false : Boolean.Parse(_ispersonalizable));
|
||||||
page.UserId = null;
|
page.UserId = null;
|
||||||
|
|
||||||
page = await PageService.AddPageAsync(page);
|
page = await PageService.AddPageAsync(page);
|
||||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, page.ParentId);
|
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, page.ParentId);
|
||||||
|
|
||||||
await logger.LogInformation("Page Added {Page}", page);
|
await logger.LogInformation("Page Added {Page}", page);
|
||||||
if (PageState.QueryString.ContainsKey("cp"))
|
if (PageState.QueryString.ContainsKey("cp"))
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path));
|
NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(page.Path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo(NavigateUrl(page.Path));
|
AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Saving Page {Page} {Error}", page, ex.Message);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,495 +7,508 @@
|
|||||||
@inject IStringLocalizer<Edit> Localizer
|
@inject IStringLocalizer<Edit> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<TabStrip Refresh="@_refresh">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<TabPanel Name="Settings" ResourceKey="Settings">
|
<TabStrip Refresh="@_refresh">
|
||||||
@if (_themeList != null)
|
<TabPanel Name="Settings" ResourceKey="Settings">
|
||||||
{
|
@if (_themeList != null)
|
||||||
<div class="container">
|
{
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Name" HelpText="Enter the page name" ResourceKey="Name">Name: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="Name" class="form-control" @bind="@_name" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Parent" HelpText="Select the parent for the page in the site hierarchy" ResourceKey="Parent">Parent: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="Parent" class="form-select" value="@_parentid" @onchange="(e => ParentChanged(e))">
|
|
||||||
<option value="-1"><@Localizer["SiteRoot"]></option>
|
|
||||||
@foreach (Page page in _pageList)
|
|
||||||
{
|
|
||||||
if (page.PageId != _pageId)
|
|
||||||
{
|
|
||||||
<option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Move" HelpText="Select the location where you would like the page to be moved in relation to other pages" ResourceKey="Move">Move: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="Move" class="form-select" @bind="@_insert">
|
|
||||||
@if (_parentid == _currentparentid)
|
|
||||||
{
|
|
||||||
<option value="="><@Localizer["ThisLocation.Keep"]></option>
|
|
||||||
}
|
|
||||||
<option value="<<">@Localizer["ToBeginning"]</option>
|
|
||||||
@if (_children != null && _children.Count > 0)
|
|
||||||
{
|
|
||||||
<option value="<">@Localizer["Before"]</option>
|
|
||||||
<option value=">">@Localizer["After"]</option>
|
|
||||||
}
|
|
||||||
<option value=">>">@Localizer["ToEnd"]</option>
|
|
||||||
</select>
|
|
||||||
@if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">"))
|
|
||||||
{
|
|
||||||
<select class="form-select" @bind="@_childid">
|
|
||||||
<option value="-1"><@Localizer["Page.Select"]></option>
|
|
||||||
@foreach (Page page in _children)
|
|
||||||
{
|
|
||||||
<option value="@(page.PageId)">@(page.Name)</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Navigation" HelpText="Select whether the page is part of the site navigation or hidden" ResourceKey="Navigation">Navigation? </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="Navigation" class="form-select" @bind="@_isnavigation">
|
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Clickablen" HelpText="Select whether the link in the site navigation is enabled or disabled" ResourceKey="Clickable">Clickable? </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="Navigation" class="form-select" @bind="@_isclickable">
|
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Path" HelpText="Optionally enter a url path for this page (ie. home ). If you do not provide a url path, the page name will be used." ResourceKey="UrlPath">Url Path: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="Path" class="form-control" @bind="@_path" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Url" HelpText="Optionally enter a url which this page should redirect to when a user navigates to it" ResourceKey="Redirect">Redirect: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="Url" class="form-control" @bind="@_url" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Section Name="Appearance" ResourceKey="Appearance">
|
|
||||||
<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="Title" HelpText="Optionally enter the page title. If you do not provide a page title, the page name will be used." ResourceKey="Title">Title: </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="Title" class="form-control" @bind="@_title" />
|
<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="Theme" HelpText="Select the theme for this page" ResourceKey="Theme">Theme: </Label>
|
<Label Class="col-sm-3" For="Parent" HelpText="Select the parent for the page in the site hierarchy" ResourceKey="Parent">Parent: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<select id="Theme" class="form-select" value="@_themetype" @onchange="(e => ThemeChanged(e))">
|
<select id="Parent" class="form-select" value="@_parentid" @onchange="(e => ParentChanged(e))" required>
|
||||||
@foreach (var theme in _themes)
|
<option value="-1"><@Localizer["SiteRoot"]></option>
|
||||||
|
@foreach (Page page in _pageList)
|
||||||
{
|
{
|
||||||
<option value="@theme.TypeName">@theme.Name</option>
|
if (page.PageId != _pageId)
|
||||||
|
{
|
||||||
|
<option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</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="defaultContainer" HelpText="Select the default container for the page" ResourceKey="DefaultContainer">Default Container: </Label>
|
<Label Class="col-sm-3" For="Move" HelpText="Select the location where you would like the page to be moved in relation to other pages" ResourceKey="Move">Move: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<select id="defaultContainer" class="form-select" @bind="@_containertype">
|
<select id="Move" class="form-select" @bind="@_insert" required>
|
||||||
<option value="-"><@Localizer["Container.Select"]></option>
|
@if (_parentid == _currentparentid)
|
||||||
@foreach (var container in _containers)
|
|
||||||
{
|
{
|
||||||
<option value="@container.TypeName">@container.Name</option>
|
<option value="="><@Localizer["ThisLocation.Keep"]></option>
|
||||||
}
|
}
|
||||||
|
<option value="<<">@Localizer["ToBeginning"]</option>
|
||||||
|
@if (_children != null && _children.Count > 0)
|
||||||
|
{
|
||||||
|
<option value="<">@Localizer["Before"]</option>
|
||||||
|
<option value=">">@Localizer["After"]</option>
|
||||||
|
}
|
||||||
|
<option value=">>">@Localizer["ToEnd"]</option>
|
||||||
</select>
|
</select>
|
||||||
|
@if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">"))
|
||||||
|
{
|
||||||
|
<select class="form-select" @bind="@_childid">
|
||||||
|
<option value="-1"><@Localizer["Page.Select"]></option>
|
||||||
|
@foreach (Page page in _children)
|
||||||
|
{
|
||||||
|
<option value="@(page.PageId)">@(page.Name)</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
}
|
||||||
</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="Icon" HelpText="Optionally provide an icon class name for this page which will be displayed in the site navigation" ResourceKey="Icon">Icon: </Label>
|
<Label Class="col-sm-3" For="Navigation" HelpText="Select whether the page is part of the site navigation or hidden" ResourceKey="Navigation">Navigation? </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="Icon" class="form-control" @bind="@_icon" />
|
<select id="Navigation" class="form-select" @bind="@_isnavigation" required>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="Personalizable" HelpText="Select whether you would like users to be able to personalize this page with their own content" ResourceKey="Personalizable">Personalizable? </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="Personalizable" class="form-select" @bind="@_ispersonalizable">
|
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="Clickablen" HelpText="Select whether the link in the site navigation is enabled or disabled" ResourceKey="Clickable">Clickable? </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="Navigation" class="form-select" @bind="@_isclickable" required>
|
||||||
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="Path" HelpText="Optionally enter a url path for this page (ie. home ). If you do not provide a url path, the page name will be used." ResourceKey="UrlPath">Url Path: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="Path" class="form-control" @bind="@_path" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="Url" HelpText="Optionally enter a url which this page should redirect to when a user navigates to it" ResourceKey="Redirect">Redirect: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="Url" class="form-control" @bind="@_url" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
<Section Name="Appearance" ResourceKey="Appearance">
|
||||||
<br /><br />
|
<div class="container">
|
||||||
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon" DeletedBy="@_deletedby" DeletedOn="@_deletedon"></AuditInfo>
|
<div class="row mb-1 align-items-center">
|
||||||
}
|
<Label Class="col-sm-3" For="Title" HelpText="Optionally enter the page title. If you do not provide a page title, the page name will be used." ResourceKey="Title">Title: </Label>
|
||||||
</TabPanel>
|
<div class="col-sm-9">
|
||||||
<TabPanel Name="Permissions" ResourceKey="Permissions">
|
<input id="Title" class="form-control" @bind="@_title" />
|
||||||
@if (_permissions != null)
|
</div>
|
||||||
{
|
</div>
|
||||||
<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="Theme" HelpText="Select the theme for this page" ResourceKey="Theme">Theme: </Label>
|
||||||
<PermissionGrid EntityName="@EntityNames.Page" Permissions="@_permissions" @ref="_permissionGrid" />
|
<div class="col-sm-9">
|
||||||
|
<select id="Theme" class="form-select" value="@_themetype" @onchange="(e => ThemeChanged(e))" required>
|
||||||
</div>
|
@foreach (var theme in _themes)
|
||||||
</div>
|
{
|
||||||
|
<option value="@theme.TypeName">@theme.Name</option>
|
||||||
}
|
}
|
||||||
</TabPanel>
|
</select>
|
||||||
@if (_themeSettingsType != null)
|
</div>
|
||||||
{
|
</div>
|
||||||
<TabPanel Name="ThemeSettings" Heading="Theme Settings" ResourceKey="ThemeSettings">
|
<div class="row mb-1 align-items-center">
|
||||||
@ThemeSettingsComponent
|
<Label Class="col-sm-3" For="defaultContainer" HelpText="Select the default container for the page" ResourceKey="DefaultContainer">Default Container: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="defaultContainer" class="form-select" @bind="@_containertype" required>
|
||||||
|
<option value="-"><@Localizer["Container.Select"]></option>
|
||||||
|
@foreach (var container in _containers)
|
||||||
|
{
|
||||||
|
<option value="@container.TypeName">@container.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="Icon" HelpText="Optionally provide an icon class name for this page which will be displayed in the site navigation" ResourceKey="Icon">Icon: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="Icon" class="form-control" @bind="@_icon" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="Personalizable" HelpText="Select whether you would like users to be able to personalize this page with their own content" ResourceKey="Personalizable">Personalizable? </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="Personalizable" class="form-select" @bind="@_ispersonalizable" required>
|
||||||
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Section>
|
||||||
|
<br /><br />
|
||||||
|
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon" DeletedBy="@_deletedby" DeletedOn="@_deletedon"></AuditInfo>
|
||||||
|
}
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
}
|
<TabPanel Name="Permissions" ResourceKey="Permissions">
|
||||||
</TabStrip>
|
@if (_permissions != null)
|
||||||
<button type="button" class="btn btn-success" @onclick="SavePage">@SharedLocalizer["Save"]</button>
|
|
||||||
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
|
||||||
|
|
||||||
@code {
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
|
||||||
|
|
||||||
private List<Theme> _themeList;
|
|
||||||
private List<ThemeControl> _themes = new List<ThemeControl>();
|
|
||||||
private List<ThemeControl> _containers = new List<ThemeControl>();
|
|
||||||
private List<Page> _pageList;
|
|
||||||
private int _pageId;
|
|
||||||
private string _name;
|
|
||||||
private string _title;
|
|
||||||
private string _path;
|
|
||||||
private string _currentparentid;
|
|
||||||
private string _parentid;
|
|
||||||
private string _insert = "=";
|
|
||||||
private List<Page> _children;
|
|
||||||
private int _childid = -1;
|
|
||||||
private string _isnavigation;
|
|
||||||
private string _isclickable;
|
|
||||||
private string _url;
|
|
||||||
private string _ispersonalizable;
|
|
||||||
private string _themetype;
|
|
||||||
private string _containertype = "-";
|
|
||||||
private string _icon;
|
|
||||||
private string _permissions = null;
|
|
||||||
private string _createdby;
|
|
||||||
private DateTime _createdon;
|
|
||||||
private string _modifiedby;
|
|
||||||
private DateTime _modifiedon;
|
|
||||||
private string _deletedby;
|
|
||||||
private DateTime? _deletedon;
|
|
||||||
private PermissionGrid _permissionGrid;
|
|
||||||
private Type _themeSettingsType;
|
|
||||||
private object _themeSettings;
|
|
||||||
private RenderFragment ThemeSettingsComponent { get; set; }
|
|
||||||
private bool _refresh = false;
|
|
||||||
|
|
||||||
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;
|
<div class="container">
|
||||||
_title = page.Title;
|
<div class="row mb-1 align-items-center">
|
||||||
_path = page.Path;
|
<PermissionGrid EntityName="@EntityNames.Page" Permissions="@_permissions" @ref="_permissionGrid" />
|
||||||
|
|
||||||
if (_path.Contains("/"))
|
</div>
|
||||||
{
|
</div>
|
||||||
_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();
|
|
||||||
}
|
}
|
||||||
}
|
</TabPanel>
|
||||||
catch (Exception ex)
|
@if (_themeSettingsType != null)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Page {PageId} {Error}", _pageId, ex.Message);
|
<TabPanel Name="ThemeSettings" Heading="Theme Settings" ResourceKey="ThemeSettings">
|
||||||
AddModuleMessage(Localizer["Error.Page.Load"], MessageType.Error);
|
@ThemeSettingsComponent
|
||||||
|
</TabPanel>
|
||||||
}
|
}
|
||||||
}
|
</TabStrip>
|
||||||
|
<button type="button" class="btn btn-success" @onclick="SavePage">@SharedLocalizer["Save"]</button>
|
||||||
|
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
private async void ParentChanged(ChangeEventArgs e)
|
@code {
|
||||||
{
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
try
|
|
||||||
|
private ElementReference form;
|
||||||
|
private bool validated = false;
|
||||||
|
private List<Theme> _themeList;
|
||||||
|
private List<ThemeControl> _themes = new List<ThemeControl>();
|
||||||
|
private List<ThemeControl> _containers = new List<ThemeControl>();
|
||||||
|
private List<Page> _pageList;
|
||||||
|
private int _pageId;
|
||||||
|
private string _name;
|
||||||
|
private string _title;
|
||||||
|
private string _path;
|
||||||
|
private string _currentparentid;
|
||||||
|
private string _parentid;
|
||||||
|
private string _insert = "=";
|
||||||
|
private List<Page> _children;
|
||||||
|
private int _childid = -1;
|
||||||
|
private string _isnavigation;
|
||||||
|
private string _isclickable;
|
||||||
|
private string _url;
|
||||||
|
private string _ispersonalizable;
|
||||||
|
private string _themetype;
|
||||||
|
private string _containertype = "-";
|
||||||
|
private string _icon;
|
||||||
|
private string _permissions = null;
|
||||||
|
private string _createdby;
|
||||||
|
private DateTime _createdon;
|
||||||
|
private string _modifiedby;
|
||||||
|
private DateTime _modifiedon;
|
||||||
|
private string _deletedby;
|
||||||
|
private DateTime? _deletedon;
|
||||||
|
private PermissionGrid _permissionGrid;
|
||||||
|
private Type _themeSettingsType;
|
||||||
|
private object _themeSettings;
|
||||||
|
private RenderFragment ThemeSettingsComponent { get; set; }
|
||||||
|
private bool _refresh = false;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
_parentid = (string)e.Value;
|
try
|
||||||
_children = new List<Page>();
|
|
||||||
if (_parentid == "-1")
|
|
||||||
{
|
{
|
||||||
foreach (Page p in PageState.Pages.Where(item => item.ParentId == null))
|
_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)
|
||||||
{
|
{
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.Permissions))
|
_name = page.Name;
|
||||||
|
_title = page.Title;
|
||||||
|
_path = page.Path;
|
||||||
|
|
||||||
|
if (_path.Contains("/"))
|
||||||
{
|
{
|
||||||
_children.Add(p);
|
_path = _path.Substring(_path.LastIndexOf("/") + 1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
if (page.ParentId == null)
|
||||||
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);
|
_parentid = string.Empty;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path);
|
_parentid = page.ParentId.ToString();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!PagePathIsUnique(page.Path, page.SiteId, page.PageId, _pageList))
|
_currentparentid = _parentid;
|
||||||
{
|
_isnavigation = page.IsNavigation.ToString();
|
||||||
AddModuleMessage(string.Format(Localizer["Mesage.Page.PathExists"], _path), MessageType.Warning);
|
_isclickable = page.IsClickable.ToString();
|
||||||
return;
|
_url = page.Url;
|
||||||
}
|
_ispersonalizable = page.IsPersonalizable.ToString();
|
||||||
|
_themetype = page.ThemeType;
|
||||||
if (_insert != "=")
|
if (string.IsNullOrEmpty(_themetype))
|
||||||
{
|
|
||||||
Page child;
|
|
||||||
switch (_insert)
|
|
||||||
{
|
{
|
||||||
case "<<":
|
_themetype = PageState.Site.DefaultThemeType;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
_containers = ThemeService.GetContainerControls(_themeList, _themetype);
|
||||||
page.IsNavigation = (_isnavigation == null || Boolean.Parse(_isnavigation));
|
_containertype = page.DefaultContainerType;
|
||||||
page.IsClickable = (_isclickable == null ? true : Boolean.Parse(_isclickable));
|
if (string.IsNullOrEmpty(_containertype))
|
||||||
page.Url = _url;
|
{
|
||||||
page.ThemeType = (_themetype != "-") ? _themetype : string.Empty;
|
_containertype = PageState.Site.DefaultContainerType;
|
||||||
if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType)
|
}
|
||||||
{
|
_icon = page.Icon;
|
||||||
page.ThemeType = string.Empty;
|
_permissions = page.Permissions;
|
||||||
}
|
_createdby = page.CreatedBy;
|
||||||
page.DefaultContainerType = (_containertype != "-") ? _containertype : string.Empty;
|
_createdon = page.CreatedOn;
|
||||||
if (!string.IsNullOrEmpty(page.DefaultContainerType) && page.DefaultContainerType == PageState.Site.DefaultContainerType)
|
_modifiedby = page.ModifiedBy;
|
||||||
{
|
_modifiedon = page.ModifiedOn;
|
||||||
page.DefaultContainerType = string.Empty;
|
_deletedby = page.DeletedBy;
|
||||||
}
|
_deletedon = page.DeletedOn;
|
||||||
page.Icon = _icon ?? string.Empty;
|
|
||||||
page.Permissions = _permissionGrid.GetPermissions();
|
|
||||||
page.IsPersonalizable = (_ispersonalizable != null && Boolean.Parse(_ispersonalizable));
|
|
||||||
page.UserId = null;
|
|
||||||
|
|
||||||
page = await PageService.UpdatePageAsync(page);
|
ThemeSettings();
|
||||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, page.ParentId);
|
}
|
||||||
if (_currentparentid == string.Empty)
|
}
|
||||||
|
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")
|
||||||
{
|
{
|
||||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, null);
|
foreach (Page p in PageState.Pages.Where(item => item.ParentId == null))
|
||||||
|
{
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.Permissions))
|
||||||
|
{
|
||||||
|
_children.Add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, int.Parse(_currentparentid));
|
foreach (Page p in PageState.Pages.Where(item => item.ParentId == int.Parse(_parentid)))
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.Permissions))
|
||||||
await PageService.UpdatePageAsync(p);
|
{
|
||||||
|
_children.Add(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_parentid == _currentparentid)
|
||||||
if (_themeSettingsType != null && _themeSettings is ISettingsControl themeSettingsControl)
|
|
||||||
{
|
{
|
||||||
await themeSettingsControl.UpdateSettings();
|
_insert = "=";
|
||||||
}
|
|
||||||
|
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo(NavigateUrl(page.Path));
|
_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
|
||||||
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Saving Page {Page} {Error}", page, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Cancel()
|
private void Cancel()
|
||||||
{
|
|
||||||
if (PageState.QueryString.ContainsKey("cp"))
|
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path));
|
if (PageState.QueryString.ContainsKey("cp"))
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool PagePathIsUnique(string pagePath, int siteId, int pageId, List<Page> existingPages)
|
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);
|
return !existingPages.Any(page => page.SiteId == siteId && page.Path == pagePath && page.PageId != pageId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -7,39 +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 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -5,180 +5,193 @@
|
|||||||
@inject IStringLocalizer<Edit> Localizer
|
@inject IStringLocalizer<Edit> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<div class="container">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<Label Class="col-sm-3" For="name" HelpText="The name of this profile item" ResourceKey="Name">Name: </Label>
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<Label Class="col-sm-3" For="name" HelpText="The name of this profile item" ResourceKey="Name">Name: </Label>
|
||||||
<input id="name" class="form-control" @bind="@_name" />
|
<div class="col-sm-9">
|
||||||
|
<input id="name" class="form-control" @bind="@_name" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="title" class="form-control" @bind="@_title" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="description" HelpText="The help text displayed to the user for this profile item" ResourceKey="Description">Description: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<textarea id="description" class="form-control" @bind="@_description" rows="5" required></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="category" class="form-control" @bind="@_category" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="order" class="form-control" @bind="@_vieworder" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="length" class="form-control" @bind="@_maxlength" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="defaultVal" class="form-control" @bind="@_defaultvalue" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="options" class="form-control" @bind="@_options" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="required" HelpText="Should a user be required to provide a value for this profile item?" ResourceKey="Required">Required? </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="required" class="form-select" @bind="@_isrequired" required>
|
||||||
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="private" HelpText="Should this profile item be visible to all users?" ResourceKey="Private">Private? </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="private" class="form-select" @bind="@_isprivate" required>
|
||||||
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<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>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="title" class="form-control" @bind="@_title" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="description" HelpText="The help text displayed to the user for this profile item" ResourceKey="Description">Description: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea id="description" class="form-control" @bind="@_description" rows="5"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<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>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="category" class="form-control" @bind="@_category" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<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>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="order" class="form-control" @bind="@_vieworder" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<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>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="length" class="form-control" @bind="@_maxlength" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<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>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="defaultVal" class="form-control" @bind="@_defaultvalue" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<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>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="options" class="form-control" @bind="@_options" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="required" HelpText="Should a user be required to provide a value for this profile item?" ResourceKey="Required">Required? </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="required" class="form-select" @bind="@_isrequired">
|
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="private" HelpText="Should this profile item be visible to all users?" ResourceKey="Private">Private? </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="private" class="form-select" @bind="@_isprivate">
|
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveProfile">@SharedLocalizer["Save"]</button>
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
@if (PageState.QueryString.ContainsKey("id"))
|
|
||||||
{
|
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<button type="button" class="btn btn-success" @onclick="SaveProfile">@SharedLocalizer["Save"]</button>
|
||||||
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
}
|
@if (PageState.QueryString.ContainsKey("id"))
|
||||||
|
|
||||||
@code {
|
|
||||||
private int _profileid = -1;
|
|
||||||
private string _name = string.Empty;
|
|
||||||
private string _title = string.Empty;
|
|
||||||
private string _description = string.Empty;
|
|
||||||
private string _category = string.Empty;
|
|
||||||
private string _vieworder = "0";
|
|
||||||
private string _maxlength = "0";
|
|
||||||
private string _defaultvalue = string.Empty;
|
|
||||||
private string _options = string.Empty;
|
|
||||||
private string _isrequired = "False";
|
|
||||||
private string _isprivate = "False";
|
|
||||||
private string createdby;
|
|
||||||
private DateTime createdon;
|
|
||||||
private string modifiedby;
|
|
||||||
private DateTime modifiedon;
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
|
||||||
|
|
||||||
public override string Actions => "Add,Edit";
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
{
|
||||||
try
|
<br />
|
||||||
|
<br />
|
||||||
|
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
||||||
|
}
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private int _profileid = -1;
|
||||||
|
private ElementReference form;
|
||||||
|
private bool validated = false;
|
||||||
|
private string _name = string.Empty;
|
||||||
|
private string _title = string.Empty;
|
||||||
|
private string _description = string.Empty;
|
||||||
|
private string _category = string.Empty;
|
||||||
|
private string _vieworder = "0";
|
||||||
|
private string _maxlength = "0";
|
||||||
|
private string _defaultvalue = string.Empty;
|
||||||
|
private string _options = string.Empty;
|
||||||
|
private string _isrequired = "False";
|
||||||
|
private string _isprivate = "False";
|
||||||
|
private string createdby;
|
||||||
|
private DateTime createdon;
|
||||||
|
private string modifiedby;
|
||||||
|
private DateTime modifiedon;
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
|
public override string Actions => "Add,Edit";
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
if (PageState.QueryString.ContainsKey("id"))
|
try
|
||||||
{
|
{
|
||||||
_profileid = Int32.Parse(PageState.QueryString["id"]);
|
if (PageState.QueryString.ContainsKey("id"))
|
||||||
var profile = await ProfileService.GetProfileAsync(_profileid);
|
|
||||||
if (profile != null)
|
|
||||||
{
|
{
|
||||||
_name = profile.Name;
|
_profileid = Int32.Parse(PageState.QueryString["id"]);
|
||||||
_title = profile.Title;
|
var profile = await ProfileService.GetProfileAsync(_profileid);
|
||||||
_description = profile.Description;
|
if (profile != null)
|
||||||
_category = profile.Category;
|
{
|
||||||
_vieworder = profile.ViewOrder.ToString();
|
_name = profile.Name;
|
||||||
_maxlength = profile.MaxLength.ToString();
|
_title = profile.Title;
|
||||||
_defaultvalue = profile.DefaultValue;
|
_description = profile.Description;
|
||||||
_options = profile.Options;
|
_category = profile.Category;
|
||||||
_isrequired = profile.IsRequired.ToString();
|
_vieworder = profile.ViewOrder.ToString();
|
||||||
_isprivate = profile.IsPrivate.ToString();
|
_maxlength = profile.MaxLength.ToString();
|
||||||
createdby = profile.CreatedBy;
|
_defaultvalue = profile.DefaultValue;
|
||||||
createdon = profile.CreatedOn;
|
_options = profile.Options;
|
||||||
modifiedby = profile.ModifiedBy;
|
_isrequired = profile.IsRequired.ToString();
|
||||||
modifiedon = profile.ModifiedOn;
|
_isprivate = profile.IsPrivate.ToString();
|
||||||
|
createdby = profile.CreatedBy;
|
||||||
|
createdon = profile.CreatedOn;
|
||||||
|
modifiedby = profile.ModifiedBy;
|
||||||
|
modifiedon = profile.ModifiedOn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
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()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Profile profile;
|
|
||||||
if (_profileid != -1)
|
|
||||||
{
|
{
|
||||||
profile = await ProfileService.GetProfileAsync(_profileid);
|
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
|
||||||
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
profile = new Profile();
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -10,54 +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 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,208 +7,182 @@
|
|||||||
@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;">
|
<br />
|
||||||
<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" />
|
<p>@Localizer["NoPage.Deleted"]</p>
|
||||||
</div>
|
}
|
||||||
|
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
|
||||||
|
{
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</TabPanel>
|
|
||||||
<TabPanel Name="Modules" ResourceKey="Modules">
|
private async Task Load()
|
||||||
@if (_modules == null)
|
|
||||||
{
|
{
|
||||||
<br />
|
_pages = await PageService.GetPagesAsync(PageState.Site.SiteId);
|
||||||
<p>@Localizer["NoModule.Deleted"]</p>
|
_pages = _pages.Where(item => item.IsDeleted).ToList();
|
||||||
|
|
||||||
|
_modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
|
||||||
|
_modules = _modules.Where(item => item.IsDeleted).ToList();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
private async Task RestorePage(Page page)
|
||||||
{
|
{
|
||||||
<Pager Items="@_modules">
|
try
|
||||||
<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;">
|
page.IsDeleted = false;
|
||||||
<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 PageService.UpdatePageAsync(page);
|
||||||
</div>
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</TabPanel>
|
|
||||||
</TabStrip>
|
|
||||||
|
|
||||||
@code {
|
private async Task DeletePage(Page page)
|
||||||
private List<Page> _pages;
|
|
||||||
private List<Module> _modules;
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await Load();
|
try
|
||||||
}
|
|
||||||
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.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)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var pagemodule = await PageModuleService.GetPageModuleAsync(module.PageModuleId);
|
|
||||||
pagemodule.IsDeleted = false;
|
|
||||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
|
||||||
await logger.LogInformation("Module Restored {Module}", module);
|
|
||||||
await Load();
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Restoring Deleted Module {Module} {Error}", module, ex.Message);
|
|
||||||
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.LogError(ex, "Error Permanently Deleting Page {Page} {Error}", page, ex.Message);
|
||||||
|
AddModuleMessage(ex.Message, MessageType.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
private async Task DeleteAllPages()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
foreach (Module module in _modules)
|
try
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var pagemodule = await PageModuleService.GetPageModuleAsync(module.PageModuleId);
|
||||||
|
pagemodule.IsDeleted = false;
|
||||||
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
|
await logger.LogInformation("Module Restored {Module}", module);
|
||||||
|
await Load();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Restoring Deleted Module {Module} {Error}", module, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Module.Restore"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteModule(Module module)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
await PageModuleService.DeletePageModuleAsync(module.PageModuleId);
|
await PageModuleService.DeletePageModuleAsync(module.PageModuleId);
|
||||||
// check if there are any remaining module instances in the site
|
// check if there are any remaining module instances in the site
|
||||||
@ -218,16 +192,42 @@
|
|||||||
{
|
{
|
||||||
await ModuleService.DeleteModuleAsync(module.ModuleId);
|
await ModuleService.DeleteModuleAsync(module.ModuleId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
await logger.LogInformation("Modules Permanently Deleted");
|
await logger.LogInformation("Module Permanently Deleted {Module}", module);
|
||||||
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()
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Permanently Deleting Modules {Error}", ex.Message);
|
try
|
||||||
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -7,117 +7,130 @@
|
|||||||
|
|
||||||
@if (PageState.Site.AllowRegistration)
|
@if (PageState.Site.AllowRegistration)
|
||||||
{
|
{
|
||||||
<AuthorizeView Roles="@RoleNames.Registered">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<Authorizing>
|
<AuthorizeView Roles="@RoleNames.Registered">
|
||||||
<text>...</text>
|
<Authorizing>
|
||||||
</Authorizing>
|
<text>...</text>
|
||||||
<Authorized>
|
</Authorizing>
|
||||||
<ModuleMessage Message="@Localizer["Info.Registration.Exists"]" Type="MessageType.Info" />
|
<Authorized>
|
||||||
</Authorized>
|
<ModuleMessage Message="@Localizer["Info.Registration.Exists"]" Type="MessageType.Info" />
|
||||||
<NotAuthorized>
|
</Authorized>
|
||||||
<ModuleMessage Message="@Localizer["Info.Registration.InvalidEmail"]" Type="MessageType.Info" />
|
<NotAuthorized>
|
||||||
<div class="container">
|
<ModuleMessage Message="@Localizer["Info.Registration.InvalidEmail"]" Type="MessageType.Info" />
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<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="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<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>
|
||||||
<input id="username" class="form-control" @bind="@_username" />
|
<div class="col-sm-9">
|
||||||
|
<input id="username" class="form-control" @bind="@_username" required/>
|
||||||
|
</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" 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" 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" required/>
|
||||||
|
</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" required/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<br />
|
||||||
<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>
|
<button type="button" class="btn btn-primary" @onclick="Register">@Localizer["Register"]</button>
|
||||||
<div class="col-sm-9">
|
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
||||||
<input id="password" type="password" class="form-control" @bind="@_password" autocomplete="new-password" />
|
</NotAuthorized>
|
||||||
</div>
|
</AuthorizeView>
|
||||||
</div>
|
</form>
|
||||||
<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>
|
else
|
||||||
<div class="col-sm-9">
|
{
|
||||||
<input id="confirm" type="password" class="form-control" @bind="@_confirm" autocomplete="new-password" />
|
|
||||||
</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>
|
|
||||||
<br />
|
|
||||||
<button type="button" class="btn btn-primary" @onclick="Register">@Localizer["Register"]</button>
|
|
||||||
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
|
||||||
</NotAuthorized>
|
|
||||||
</AuthorizeView>
|
|
||||||
}
|
|
||||||
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 string _password = string.Empty;
|
private ElementReference form;
|
||||||
private string _confirm = string.Empty;
|
private bool validated = false;
|
||||||
private string _email = string.Empty;
|
private string _password = string.Empty;
|
||||||
private string _displayname = string.Empty;
|
private string _confirm = string.Empty;
|
||||||
|
private string _email = 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()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
bool _isEmailValid = Utilities.IsValidEmail(_email);
|
|
||||||
|
|
||||||
if (_username != "" && _password != "" && _confirm != "" && _isEmailValid)
|
|
||||||
{
|
{
|
||||||
if (_password == _confirm)
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
var user = new User
|
try
|
||||||
{
|
{
|
||||||
SiteId = PageState.Site.SiteId,
|
bool _isEmailValid = Utilities.IsValidEmail(_email);
|
||||||
Username = _username,
|
|
||||||
DisplayName = (_displayname == string.Empty ? _username : _displayname),
|
|
||||||
Email = _email,
|
|
||||||
Password = _password
|
|
||||||
};
|
|
||||||
user = await UserService.AddUserAsync(user);
|
|
||||||
|
|
||||||
if (user != null)
|
if (_username != "" && _password != "" && _confirm != "" && _isEmailValid)
|
||||||
{
|
{
|
||||||
await logger.LogInformation("User Created {Username} {Email}", _username, _email);
|
if (_password == _confirm)
|
||||||
AddModuleMessage(Localizer["Info.User.AccountCreate"], MessageType.Info);
|
{
|
||||||
|
var user = new User
|
||||||
|
{
|
||||||
|
SiteId = PageState.Site.SiteId,
|
||||||
|
Username = _username,
|
||||||
|
DisplayName = (_displayname == string.Empty ? _username : _displayname),
|
||||||
|
Email = _email,
|
||||||
|
Password = _password
|
||||||
|
};
|
||||||
|
user = await UserService.AddUserAsync(user);
|
||||||
|
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
await logger.LogInformation("User Created {Username} {Email}", _username, _email);
|
||||||
|
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
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError("Error Adding User {Username} {Email}", _username, _email);
|
await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", _username, _email, ex.Message);
|
||||||
AddModuleMessage(Localizer["Error.User.AddInfo"], MessageType.Error);
|
AddModuleMessage(Localizer["Error.User.Add"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
private void Cancel()
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning);
|
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", _username, _email, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.User.Add"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Cancel()
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,88 +5,101 @@
|
|||||||
@inject IStringLocalizer<Index> Localizer
|
@inject IStringLocalizer<Index> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<div class="container">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="form-group">
|
<div class="container">
|
||||||
<label for="Username" class="control-label">@SharedLocalizer["Username"] </label>
|
<div class="form-group">
|
||||||
<input type="text" class="form-control" placeholder="Username" @bind="@_username" readonly id="Username" />
|
<label for="Username" class="control-label">@SharedLocalizer["Username"] </label>
|
||||||
|
<input type="text" class="form-control" placeholder="Username" @bind="@_username" readonly id="Username"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="Password" class="control-label">@SharedLocalizer["Password"] </label>
|
||||||
|
<input type="password" class="form-control" placeholder="Password" @bind="@_password" id="Password" maxlength="256" required />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="Confirm" class="control-label">@Localizer["Password.Confirm"] </label>
|
||||||
|
<input type="password" class="form-control" placeholder="Password" @bind="@_confirm" id="Confirm" maxlength="256" required />
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn btn-primary" @onclick="Reset">@Localizer["Password.Reset"]</button>
|
||||||
|
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
</form>
|
||||||
<label for="Password" class="control-label">@SharedLocalizer["Password"] </label>
|
|
||||||
<input type="password" class="form-control" placeholder="Password" @bind="@_password" id="Password" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="Confirm" class="control-label">@Localizer["Password.Confirm"] </label>
|
|
||||||
<input type="password" class="form-control" placeholder="Password" @bind="@_confirm" id="Confirm" />
|
|
||||||
</div>
|
|
||||||
<button type="button" class="btn btn-primary" @onclick="Reset">@Localizer["Password.Reset"]</button>
|
|
||||||
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _username = string.Empty;
|
private ElementReference form;
|
||||||
private string _password = string.Empty;
|
private bool validated = false;
|
||||||
private string _confirm = string.Empty;
|
private string _username = string.Empty;
|
||||||
|
private string _password = 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"))
|
|
||||||
{
|
{
|
||||||
_username = PageState.QueryString["name"];
|
if (PageState.QueryString.ContainsKey("name") && PageState.QueryString.ContainsKey("token"))
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Reset()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_username != string.Empty && _password != string.Empty && _confirm != string.Empty)
|
|
||||||
{
|
{
|
||||||
if (_password == _confirm)
|
_username = PageState.QueryString["name"];
|
||||||
{
|
}
|
||||||
var user = new User
|
else
|
||||||
{
|
{
|
||||||
SiteId = PageState.Site.SiteId,
|
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
||||||
Username = _username,
|
}
|
||||||
Password = _password
|
}
|
||||||
};
|
|
||||||
user = await UserService.ResetPasswordAsync(user, PageState.QueryString["token"]);
|
|
||||||
|
|
||||||
if (user != null)
|
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)
|
||||||
{
|
{
|
||||||
await logger.LogInformation("User Password Reset {Username}", _username);
|
if (_password == _confirm)
|
||||||
NavigationManager.NavigateTo(NavigateUrl("login"));
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError("Error Resetting User Password {Username}", _username);
|
AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning);
|
||||||
AddModuleMessage(Localizer["Error.Password.ResetInfo"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning);
|
await logger.LogError(ex, "Error Resetting User Password {Username} {Error}", _username, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Password.Reset"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
private void Cancel()
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Resetting User Password {Username} {Error}", _username, ex.Message);
|
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
||||||
AddModuleMessage(Localizer["Error.Password.Reset"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Cancel()
|
|
||||||
{
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="isautoassigned" HelpText="Indicates Whether Or Not New Users Are Automatically Assigned To This Role" ResourceKey="AutoAssigned">Auto Assigned?</Label>
|
<Label Class="col-sm-3" For="isautoassigned" HelpText="Indicates Whether Or Not New Users Are Automatically Assigned To This Role" ResourceKey="AutoAssigned">Auto Assigned?</Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<select id="isautoassigned" class="form-select" @bind="@_isautoassigned">
|
<select id="isautoassigned" class="form-select" @bind="@_isautoassigned" required>
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
</select>
|
</select>
|
||||||
@ -72,7 +72,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.InfoRequired"], MessageType.Warning);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="isautoassigned" HelpText="Indicates Whether Or Not New Users Are Automatically Assigned To This Role" ResourceKey="AutoAssigned">Auto Assigned?</Label>
|
<Label Class="col-sm-3" For="isautoassigned" HelpText="Indicates Whether Or Not New Users Are Automatically Assigned To This Role" ResourceKey="AutoAssigned">Auto Assigned?</Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<select id="isautoassigned" class="form-select" @bind="@_isautoassigned">
|
<select id="isautoassigned" class="form-select" @bind="@_isautoassigned" required>
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
</select>
|
</select>
|
||||||
@ -101,7 +101,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.InfoRequired"], MessageType.Warning);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,22 +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 {
|
||||||
@ -40,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,165 +12,189 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
<div class="container">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<Label Class="col-sm-3" For="role" HelpText="The role you are assigning users to" ResourceKey="Role">Role: </Label>
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<Label Class="col-sm-3" For="role" HelpText="The role you are assigning users to" ResourceKey="Role">Role: </Label>
|
||||||
<input id="role" class="form-control" @bind="@name" disabled />
|
<div class="col-sm-9">
|
||||||
|
<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">
|
|
||||||
<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" />
|
|
||||||
</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" />
|
|
||||||
</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>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private int roleid;
|
private ElementReference form;
|
||||||
private string name = string.Empty;
|
private bool validated = false;
|
||||||
private List<UserRole> users;
|
|
||||||
private int userid = -1;
|
|
||||||
private DateTime? effectivedate = null;
|
|
||||||
private DateTime? expirydate = null;
|
|
||||||
private List<UserRole> userroles;
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
private int roleid;
|
||||||
|
private string name = string.Empty;
|
||||||
|
private List<UserRole> users;
|
||||||
|
private int userid = -1;
|
||||||
|
private DateTime? effectivedate = null;
|
||||||
|
private DateTime? expirydate = null;
|
||||||
|
private List<UserRole> userroles;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
{
|
|
||||||
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()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
userroles = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
try
|
||||||
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()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (userid != -1)
|
|
||||||
{
|
{
|
||||||
var userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault();
|
roleid = Int32.Parse(PageState.QueryString["id"]);
|
||||||
if (userrole != null)
|
Role role = await RoleService.GetRoleAsync(roleid);
|
||||||
{
|
name = role.Name;
|
||||||
userrole.EffectiveDate = effectivedate;
|
users = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
||||||
userrole.ExpiryDate = expirydate;
|
users = users
|
||||||
await UserRoleService.UpdateUserRoleAsync(userrole);
|
.Where(u => u.Role.Name == RoleNames.Registered)
|
||||||
}
|
.OrderBy(u => u.User.DisplayName)
|
||||||
else
|
.ToList();
|
||||||
{
|
|
||||||
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();
|
await GetUserRoles();
|
||||||
StateHasChanged();
|
}
|
||||||
|
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
|
||||||
|
{
|
||||||
|
if (userid != -1)
|
||||||
|
{
|
||||||
|
var userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault();
|
||||||
|
if (userrole != null)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Required.UserSelect"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.UserSelect"], MessageType.Warning);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Saving User Roles {RoleId} {Error}", roleid, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.User.SaveRole"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeleteUserRole(int UserRoleId)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -19,344 +19,357 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div class="container">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<Label Class="col-sm-3" For="name" HelpText="Enter the name of the site" ResourceKey="Name">Site Name: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="name" class="form-control" @bind="@_name" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="alias" HelpText="Enter the aliases for the site. An alias can be a domain name (www.site.com) or a virtual folder (ie. www.site.com/folder). If a site has multiple aliases they can be separated by commas." ResourceKey="Aliases">Aliases: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea id="alias" class="form-control" @bind="@_urls" rows="3"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="defaultTheme" HelpText="Select the default theme for the website" ResourceKey="DefaultTheme">Default Theme: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="defaultTheme" class="form-select" @onchange="(e => ThemeChanged(e))">
|
|
||||||
<option value="-"><@Localizer["Theme.Select"]></option>
|
|
||||||
@foreach (var theme in _themes)
|
|
||||||
{
|
|
||||||
<option value="@theme.TypeName">@theme.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="defaultContainer" HelpText="Select the default container for the site" ResourceKey="DefaultContainer">Default Container: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="defaultContainer" class="form-select" @bind="@_containertype">
|
|
||||||
<option value="-"><@Localizer["Container.Select"]></option>
|
|
||||||
@foreach (var container in _containers)
|
|
||||||
{
|
|
||||||
<option value="@container.TypeName">@container.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="adminContainer" HelpText="Select the admin container for the site" ResourceKey="AdminContainer">Admin Container: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="adminContainer" class="form-select" @bind="@_admincontainertype">
|
|
||||||
<option value="-"><@Localizer["Container.Select"]></option>
|
|
||||||
<option value=""><@Localizer["DefaultContainer.Admin"]></option>
|
|
||||||
@foreach (var container in _containers)
|
|
||||||
{
|
|
||||||
<option value="@container.TypeName">@container.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="siteTemplate" HelpText="Select the site template" ResourceKey="SiteTemplate">Site Template: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="siteTemplate" class="form-select" @bind="@_sitetemplatetype">
|
|
||||||
<option value="-"><@Localizer["SiteTemplate.Select"]></option>
|
|
||||||
@foreach (SiteTemplate siteTemplate in _siteTemplates)
|
|
||||||
{
|
|
||||||
<option value="@siteTemplate.TypeName">@siteTemplate.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="tenant" HelpText="Select the tenant for the site" ResourceKey="Tenant">Tenant: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="tenant" class="form-select" @onchange="(e => TenantChanged(e))">
|
|
||||||
<option value="-"><@Localizer["Tenant.Select"]></option>
|
|
||||||
<option value="+"><@Localizer["Tenant.Add"]></option>
|
|
||||||
@foreach (Tenant tenant in _tenants)
|
|
||||||
{
|
|
||||||
<option value="@tenant.TenantId">@tenant.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@if (_tenantid == "+")
|
|
||||||
{
|
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<hr class="app-rule" />
|
<Label Class="col-sm-3" For="name" HelpText="Enter the name of the site" ResourceKey="Name">Site Name: </Label>
|
||||||
</div>
|
|
||||||
<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>
|
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="name" class="form-control" @bind="@_tenantName" />
|
<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">
|
||||||
<Label Class="col-sm-3" For="databaseType" HelpText="Select the database type for the tenant" ResourceKey="DatabaseType">Database Type: </Label>
|
<Label Class="col-sm-3" For="alias" HelpText="Enter the aliases for the site. An alias can be a domain name (www.site.com) or a virtual folder (ie. www.site.com/folder). If a site has multiple aliases they can be separated by commas." ResourceKey="Aliases">Aliases: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<select id="databaseType" class="form-select" value="@_databaseName" @onchange="(e => DatabaseChanged(e))">
|
<textarea id="alias" class="form-control" @bind="@_urls" rows="3" required></textarea>
|
||||||
@foreach (var database in _databases)
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="defaultTheme" HelpText="Select the default theme for the website" ResourceKey="DefaultTheme">Default Theme: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="defaultTheme" class="form-select" @onchange="(e => ThemeChanged(e))" required>
|
||||||
|
<option value="-"><@Localizer["Theme.Select"]></option>
|
||||||
|
@foreach (var theme in _themes)
|
||||||
{
|
{
|
||||||
if (database.IsDefault)
|
<option value="@theme.TypeName">@theme.Name</option>
|
||||||
{
|
|
||||||
<option value="@database.Name" selected>@Localizer[@database.Name]</option>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<option value="@database.Name">@Localizer[@database.Name]</option>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
if (_databaseConfigType != null)
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="defaultContainer" HelpText="Select the default container for the site" ResourceKey="DefaultContainer">Default Container: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="defaultContainer" class="form-select" @bind="@_containertype" required>
|
||||||
|
<option value="-"><@Localizer["Container.Select"]></option>
|
||||||
|
@foreach (var container in _containers)
|
||||||
|
{
|
||||||
|
<option value="@container.TypeName">@container.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="adminContainer" HelpText="Select the admin container for the site" ResourceKey="AdminContainer">Admin Container: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="adminContainer" class="form-select" @bind="@_admincontainertype" required>
|
||||||
|
<option value="-"><@Localizer["Container.Select"]></option>
|
||||||
|
<option value=""><@Localizer["DefaultContainer.Admin"]></option>
|
||||||
|
@foreach (var container in _containers)
|
||||||
|
{
|
||||||
|
<option value="@container.TypeName">@container.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="siteTemplate" HelpText="Select the site template" ResourceKey="SiteTemplate">Site Template: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="siteTemplate" class="form-select" @bind="@_sitetemplatetype" required>
|
||||||
|
<option value="-"><@Localizer["SiteTemplate.Select"]></option>
|
||||||
|
@foreach (SiteTemplate siteTemplate in _siteTemplates)
|
||||||
|
{
|
||||||
|
<option value="@siteTemplate.TypeName">@siteTemplate.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="tenant" HelpText="Select the tenant for the site" ResourceKey="Tenant">Tenant: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="tenant" class="form-select" @onchange="(e => TenantChanged(e))" required>
|
||||||
|
<option value="-"><@Localizer["Tenant.Select"]></option>
|
||||||
|
<option value="+"><@Localizer["Tenant.Add"]></option>
|
||||||
|
@foreach (Tenant tenant in _tenants)
|
||||||
|
{
|
||||||
|
<option value="@tenant.TenantId">@tenant.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (_tenantid == "+")
|
||||||
{
|
{
|
||||||
@DatabaseConfigComponent;
|
<div class="row mb-1 align-items-center">
|
||||||
|
<hr class="app-rule" />
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="name" class="form-control" @bind="@_tenantName" maxlength="256" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="databaseType" HelpText="Select the database type for the tenant" ResourceKey="DatabaseType">Database Type: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="databaseType" class="form-select" value="@_databaseName" @onchange="(e => DatabaseChanged(e))" required>
|
||||||
|
@foreach (var database in _databases)
|
||||||
|
{
|
||||||
|
if (database.IsDefault)
|
||||||
|
{
|
||||||
|
<option value="@database.Name" selected>@Localizer[@database.Name]</option>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<option value="@database.Name">@Localizer[@database.Name]</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
if (_databaseConfigType != null)
|
||||||
|
{
|
||||||
|
@DatabaseConfigComponent;
|
||||||
|
}
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="hostUsername" HelpText="Enter the username of the host for this site" ResourceKey="HostUsername">Host Username:</Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="hostUsername" class="form-control" @bind="@_hostUserName" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="hostPassword" type="password" class="form-control" @bind="@_hostpassword" maxlength="256" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
<div class="row mb-1 align-items-center">
|
</div>
|
||||||
<Label Class="col-sm-3" For="hostUsername" HelpText="Enter the username of the host for this site" ResourceKey="HostUsername">Host Username:</Label>
|
<br />
|
||||||
<div class="col-sm-9">
|
<br />
|
||||||
<input id="hostUsername" class="form-control" @bind="@_hostUserName" readonly />
|
<button type="button" class="btn btn-success" @onclick="SaveSite">@SharedLocalizer["Save"]</button>
|
||||||
</div>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
</div>
|
</form>
|
||||||
<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>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="hostPassword" type="password" class="form-control" @bind="@_hostpassword" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveSite">@SharedLocalizer["Save"]</button>
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<Database> _databases;
|
private List<Database> _databases;
|
||||||
private string _databaseName = "LocalDB";
|
private ElementReference form;
|
||||||
private Type _databaseConfigType;
|
private bool validated = false;
|
||||||
private object _databaseConfig;
|
private string _databaseName = "LocalDB";
|
||||||
private RenderFragment DatabaseConfigComponent { get; set; }
|
private Type _databaseConfigType;
|
||||||
|
private object _databaseConfig;
|
||||||
|
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 =>
|
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, _databaseConfigType);
|
_tenants = await TenantService.GetTenantsAsync();
|
||||||
builder.AddComponentReferenceCapture(1, inst => { _databaseConfig = Convert.ChangeType(inst, _databaseConfigType); });
|
_urls = PageState.Alias.Name;
|
||||||
builder.CloseComponent();
|
_themeList = await ThemeService.GetThemesAsync();
|
||||||
};
|
_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
|
|
||||||
{
|
|
||||||
_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()
|
private void DatabaseChanged(ChangeEventArgs eventArgs)
|
||||||
{
|
|
||||||
if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-" && _sitetemplatetype != "-")
|
|
||||||
{
|
|
||||||
var duplicates = new List<string>();
|
|
||||||
var aliases = await AliasService.GetAliasesAsync();
|
|
||||||
foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
{
|
||||||
if (aliases.Exists(item => item.Name == name))
|
try
|
||||||
{
|
{
|
||||||
duplicates.Add(name);
|
_databaseName = (string)eventArgs.Value;
|
||||||
|
|
||||||
|
LoadDatabaseConfigComponent();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Error.Database.LoadConfig"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (duplicates.Count == 0)
|
private void LoadDatabaseConfigComponent()
|
||||||
{
|
{
|
||||||
InstallConfig config = new InstallConfig();
|
var database = _databases.SingleOrDefault(d => d.Name == _databaseName);
|
||||||
|
if (database != null)
|
||||||
if (_tenantid == "+")
|
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(_tenantName) && _tenants.FirstOrDefault(item => item.Name == _tenantName) == null)
|
_databaseConfigType = Type.GetType(database.ControlType);
|
||||||
|
DatabaseConfigComponent = builder =>
|
||||||
{
|
{
|
||||||
// validate host credentials
|
builder.OpenComponent(0, _databaseConfigType);
|
||||||
var user = new User();
|
builder.AddComponentReferenceCapture(1, inst => { _databaseConfig = Convert.ChangeType(inst, _databaseConfigType); });
|
||||||
user.SiteId = PageState.Site.SiteId;
|
builder.CloseComponent();
|
||||||
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 != "")
|
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()
|
||||||
|
{
|
||||||
|
validated = true;
|
||||||
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
|
{
|
||||||
|
if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-" && _sitetemplatetype != "-")
|
||||||
|
{
|
||||||
|
var duplicates = new List<string>();
|
||||||
|
var aliases = await AliasService.GetAliasesAsync();
|
||||||
|
foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
if (aliases.Exists(item => item.Name == name))
|
||||||
{
|
{
|
||||||
config.TenantName = _tenantName;
|
duplicates.Add(name);
|
||||||
config.DatabaseType = database.DBType;
|
}
|
||||||
config.ConnectionString = connectionString;
|
}
|
||||||
config.HostEmail = user.Email;
|
|
||||||
config.HostPassword = _hostpassword;
|
if (duplicates.Count == 0)
|
||||||
config.HostName = user.DisplayName;
|
{
|
||||||
config.IsNewTenant = true;
|
InstallConfig config = new InstallConfig();
|
||||||
|
|
||||||
|
if (_tenantid == "+")
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(_tenantName) && _tenants.FirstOrDefault(item => item.Name == _tenantName) == null)
|
||||||
|
{
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
var connectionString = String.Empty;
|
||||||
|
if (_databaseConfig is IDatabaseConfigControl databaseConfigControl)
|
||||||
|
{
|
||||||
|
connectionString = databaseConfigControl.GetConnectionString();
|
||||||
|
}
|
||||||
|
var database = _databases.SingleOrDefault(d => d.Name == _databaseName);
|
||||||
|
|
||||||
|
if (connectionString != "")
|
||||||
|
{
|
||||||
|
config.TenantName = _tenantName;
|
||||||
|
config.DatabaseType = database.DBType;
|
||||||
|
config.ConnectionString = connectionString;
|
||||||
|
config.HostEmail = user.Email;
|
||||||
|
config.HostPassword = _hostpassword;
|
||||||
|
config.HostName = user.DisplayName;
|
||||||
|
config.IsNewTenant = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Error.Required.ServerDatabase"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Error.InvalidPassword"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Error.TenantName.Exists"], MessageType.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Error.Required.ServerDatabase"], MessageType.Error);
|
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(Localizer["Error.InvalidPassword"], MessageType.Error);
|
AddModuleMessage(string.Format(Localizer["Message.SiteName.InUse"], string.Join(", ", duplicates.ToArray())), MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Error.TenantName.Exists"], MessageType.Error);
|
AddModuleMessage(Localizer["Message.Required.Tenant"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantid));
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
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
|
|
||||||
{
|
|
||||||
AddModuleMessage(string.Format(Localizer["Message.SiteName.InUse"], string.Join(", ", duplicates.ToArray())), MessageType.Warning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
AddModuleMessage(Localizer["Message.Required.Tenant"], 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))
|
|
||||||
{
|
{
|
||||||
_sites.Add(alias);
|
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))
|
||||||
|
{
|
||||||
|
_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,159 +13,158 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<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="tenant" HelpText="Select the tenant for the SQL server" ResourceKey="Tenant">Tenant: </Label>
|
||||||
<Label Class="col-sm-3" For="tenant" HelpText="Select the tenant for the SQL server" ResourceKey="Tenant">Tenant: </Label>
|
<div class="col-sm-9">
|
||||||
<div class="col-sm-9">
|
<select id="tenant" class="form-select" value="@_tenantid" @onchange="(e => TenantChanged(e))">
|
||||||
<select id="tenant" class="form-select" value="@_tenantid" @onchange="(e => TenantChanged(e))">
|
<option value="-1"><@Localizer["Tenant.Select"]></option>
|
||||||
<option value="-1"><@Localizer["Tenant.Select"]></option>
|
@foreach (Tenant tenant in _tenants)
|
||||||
@foreach (Tenant tenant in _tenants)
|
{
|
||||||
{
|
<option value="@tenant.TenantId">@tenant.Name</option>
|
||||||
<option value="@tenant.TenantId">@tenant.Name</option>
|
}
|
||||||
}
|
</select>
|
||||||
</select>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@if (_tenantid != "-1")
|
||||||
|
{
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="database" HelpText="The database for the tenant" ResourceKey="Database">Database: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="database" class="form-control" @bind="@_database" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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="col-sm-9">
|
||||||
|
<textarea id="connectionstring" class="form-control" @bind="@_connectionstring" rows="2" readonly></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<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>
|
</div>
|
||||||
@if (_tenantid != "-1")
|
<br />
|
||||||
|
<button type="button" class="btn btn-success" @onclick="Execute">@Localizer["Execute"]</button>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
@if (!string.IsNullOrEmpty(_results))
|
||||||
{
|
{
|
||||||
<div class="row mb-1 align-items-center">
|
@((MarkupString)_results)
|
||||||
<Label Class="col-sm-3" For="database" HelpText="The database for the tenant" ResourceKey="Database">Database: </Label>
|
<br />
|
||||||
<div class="col-sm-9">
|
<br />
|
||||||
<input id="database" class="form-control" @bind="@_database" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<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="col-sm-9">
|
|
||||||
<textarea id="connectionstring" class="form-control" @bind="@_connectionstring" rows="2" readonly></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<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 />
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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)
|
|
||||||
{
|
{
|
||||||
_database = _databases.Find(item => item.DBType == tenant.DBType)?.Name;
|
try
|
||||||
_connectionstring = tenant.DBConnectionString;
|
|
||||||
}
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Tenant {TenantId} {Error}", _tenantid, ex.Message);
|
|
||||||
AddModuleMessage(ex.Message, MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Execute()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
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>";
|
_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)
|
||||||
|
{
|
||||||
|
_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Execute()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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>";
|
||||||
}
|
}
|
||||||
|
|
||||||
table += "</tr></thead><tbody>";
|
if (table != string.Empty)
|
||||||
|
{
|
||||||
|
table += "</tbody></table></div>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
table = Localizer["Return.NoResult"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -5,211 +5,224 @@
|
|||||||
@inject IStringLocalizer<Index> Localizer
|
@inject IStringLocalizer<Index> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<TabStrip>
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<TabPanel Name="Info" Heading="Info" ResourceKey="Info">
|
<TabStrip>
|
||||||
<div class="container">
|
<TabPanel Name="Info" Heading="Info" ResourceKey="Info">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<Label Class="col-sm-3" For="version" HelpText="Framework Version" ResourceKey="FrameworkVersion">Framework Version: </Label>
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<Label Class="col-sm-3" For="version" HelpText="Framework Version" ResourceKey="FrameworkVersion">Framework Version: </Label>
|
||||||
<input id="version" class="form-control" @bind="@_version" readonly />
|
<div class="col-sm-9">
|
||||||
|
<input id="version" class="form-control" @bind="@_version" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="clrversion" HelpText="Common Language Runtime Version" ResourceKey="CLRVersion">CLR Version: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="clrversion" class="form-control" @bind="@_clrversion" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="osversion" HelpText="Operating System Version" ResourceKey="OSVersion">OS Version: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="osversion" class="form-control" @bind="@_osversion" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="serverpath" HelpText="Server Path" ResourceKey="ServerPath">Server Path: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="serverpath" class="form-control" @bind="@_serverpath" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="servertime" HelpText="Server Time" ResourceKey="ServerTime">Server Time: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="servertime" class="form-control" @bind="@_servertime" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="installationid" HelpText="The Unique Identifier For Your Installation" ResourceKey="InstallationId">Installation ID: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="installationid" class="form-control" @bind="@_installationid" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<div class="col-sm-3"></div>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<br /><input type="checkbox" @onchange="(e => RegisterChecked(e))" /> @Localizer["Register"]
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<br /><br />
|
||||||
<Label Class="col-sm-3" For="clrversion" HelpText="Common Language Runtime Version" ResourceKey="CLRVersion">CLR Version: </Label>
|
<ActionDialog Header="Restart Application" Message="Are You Sure You Wish To Restart The Application?" Action="Restart Application" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await RestartApplication())" ResourceKey="RestartApplication" />
|
||||||
<div class="col-sm-9">
|
</TabPanel>
|
||||||
<input id="clrversion" class="form-control" @bind="@_clrversion" readonly />
|
<TabPanel Name="Options" Heading="Options" ResourceKey="Options">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="runtime" HelpText="Blazor Runtime (Server or WebAssembly)" ResourceKey="BlazorRuntime">Blazor Runtime: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="runtime" class="form-select" @bind="@_runtime" required>
|
||||||
|
<option value="Server">@Localizer["Server"]</option>
|
||||||
|
<option value="WebAssembly">@Localizer["WebAssembly"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="rendermode" HelpText="Blazor Server Render Mode" ResourceKey="RenderMode">Render Mode: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="rendermode" class="form-select" @bind="@_rendermode" required>
|
||||||
|
<option value="Server">@Localizer["Server"]</option>
|
||||||
|
<option value="ServerPrerendered">@Localizer["ServerPrerendered"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="detailederrors" HelpText="Specify If Detailed Errors Are Enabled For Blazor. This Option Should Not Not Be Enabled In Production." ResourceKey="DetailedErrors">Detailed Errors? </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="detailederrors" class="form-select" @bind="@_detailederrors" required>
|
||||||
|
<option value="true">@SharedLocalizer["True"]</option>
|
||||||
|
<option value="false">@SharedLocalizer["False"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="logginglevel" HelpText="The Minimum Logging Level For The Event Log. This Option Can Be Used To Control The Volume Of Items Stored In Your Event Log." ResourceKey="LoggingLevel">Logging Level: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="logginglevel" class="form-select" @bind="@_logginglevel" required>
|
||||||
|
<option value="Trace">@Localizer["Trace"]</option>
|
||||||
|
<option value="Debug">@Localizer["Debug"]</option>
|
||||||
|
<option value="Information">@Localizer["Information"]</option>
|
||||||
|
<option value="Warning">@Localizer["Warning"]</option>
|
||||||
|
<option value="Error">@Localizer["Error"]</option>
|
||||||
|
<option value="Critical">@Localizer["Critical"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="swagger" HelpText="Specify If Swagger Is Enabled For Your Server API" ResourceKey="Swagger">Swagger Enabled? </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="swagger" class="form-select" @bind="@_swagger" required>
|
||||||
|
<option value="true">@SharedLocalizer["True"]</option>
|
||||||
|
<option value="false">@SharedLocalizer["False"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="packageservice" HelpText="Specify If The Package Service Is Enabled For Installing Modules, Themes, And Translations" ResourceKey="PackageService">Enable Package Service? </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="packageservice" class="form-select" @bind="@_packageservice" required>
|
||||||
|
<option value="true">@SharedLocalizer["True"]</option>
|
||||||
|
<option value="false">@SharedLocalizer["False"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
<br /><br />
|
||||||
<Label Class="col-sm-3" For="osversion" HelpText="Operating System Version" ResourceKey="OSVersion">OS Version: </Label>
|
<button type="button" class="btn btn-success" @onclick="SaveConfig">@SharedLocalizer["Save"]</button>
|
||||||
<div class="col-sm-9">
|
<a class="btn btn-primary" href="swagger/index.html" target="_new">@Localizer["Access.ApiFramework"]</a>
|
||||||
<input id="osversion" class="form-control" @bind="@_osversion" readonly />
|
<ActionDialog Header="Restart Application" Message="Are You Sure You Wish To Restart The Application?" Action="Restart Application" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await RestartApplication())" ResourceKey="RestartApplication" />
|
||||||
</div>
|
</TabPanel>
|
||||||
</div>
|
</TabStrip>
|
||||||
<div class="row mb-1 align-items-center">
|
</form>
|
||||||
<Label Class="col-sm-3" For="serverpath" HelpText="Server Path" ResourceKey="ServerPath">Server Path: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="serverpath" class="form-control" @bind="@_serverpath" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="servertime" HelpText="Server Time" ResourceKey="ServerTime">Server Time: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="servertime" class="form-control" @bind="@_servertime" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="installationid" HelpText="The Unique Identifier For Your Installation" ResourceKey="InstallationId">Installation ID: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="installationid" class="form-control" @bind="@_installationid" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<div class="col-sm-3"></div>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<br /><input type="checkbox" @onchange="(e => RegisterChecked(e))" /> @Localizer["Register"]
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br /><br />
|
|
||||||
<ActionDialog Header="Restart Application" Message="Are You Sure You Wish To Restart The Application?" Action="Restart Application" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await RestartApplication())" ResourceKey="RestartApplication" />
|
|
||||||
</TabPanel>
|
|
||||||
<TabPanel Name="Options" Heading="Options" ResourceKey="Options">
|
|
||||||
<div class="container">
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="runtime" HelpText="Blazor Runtime (Server or WebAssembly)" ResourceKey="BlazorRuntime">Blazor Runtime: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="runtime" class="form-select" @bind="@_runtime">
|
|
||||||
<option value="Server">@Localizer["Server"]</option>
|
|
||||||
<option value="WebAssembly">@Localizer["WebAssembly"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="rendermode" HelpText="Blazor Server Render Mode" ResourceKey="RenderMode">Render Mode: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="rendermode" class="form-select" @bind="@_rendermode">
|
|
||||||
<option value="Server">@Localizer["Server"]</option>
|
|
||||||
<option value="ServerPrerendered">@Localizer["ServerPrerendered"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="detailederrors" HelpText="Specify If Detailed Errors Are Enabled For Blazor. This Option Should Not Not Be Enabled In Production." ResourceKey="DetailedErrors">Detailed Errors? </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="detailederrors" class="form-select" @bind="@_detailederrors">
|
|
||||||
<option value="true">@SharedLocalizer["True"]</option>
|
|
||||||
<option value="false">@SharedLocalizer["False"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="logginglevel" HelpText="The Minimum Logging Level For The Event Log. This Option Can Be Used To Control The Volume Of Items Stored In Your Event Log." ResourceKey="LoggingLevel">Logging Level: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="logginglevel" class="form-select" @bind="@_logginglevel">
|
|
||||||
<option value="Trace">@Localizer["Trace"]</option>
|
|
||||||
<option value="Debug">@Localizer["Debug"]</option>
|
|
||||||
<option value="Information">@Localizer["Information"]</option>
|
|
||||||
<option value="Warning">@Localizer["Warning"]</option>
|
|
||||||
<option value="Error">@Localizer["Error"]</option>
|
|
||||||
<option value="Critical">@Localizer["Critical"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="swagger" HelpText="Specify If Swagger Is Enabled For Your Server API" ResourceKey="Swagger">Swagger Enabled? </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="swagger" class="form-select" @bind="@_swagger">
|
|
||||||
<option value="true">@SharedLocalizer["True"]</option>
|
|
||||||
<option value="false">@SharedLocalizer["False"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="packageservice" HelpText="Specify If The Package Service Is Enabled For Installing Modules, Themes, And Translations" ResourceKey="PackageService">Enable Package Service? </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="packageservice" class="form-select" @bind="@_packageservice">
|
|
||||||
<option value="true">@SharedLocalizer["True"]</option>
|
|
||||||
<option value="false">@SharedLocalizer["False"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br /><br />
|
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveConfig">@SharedLocalizer["Save"]</button>
|
|
||||||
<a class="btn btn-primary" href="swagger/index.html" target="_new">@Localizer["Access.ApiFramework"]</a>
|
|
||||||
<ActionDialog Header="Restart Application" Message="Are You Sure You Wish To Restart The Application?" Action="Restart Application" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await RestartApplication())" ResourceKey="RestartApplication" />
|
|
||||||
</TabPanel>
|
|
||||||
</TabStrip>
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
private string _version = string.Empty;
|
private ElementReference form;
|
||||||
private string _clrversion = string.Empty;
|
private bool validated = false;
|
||||||
private string _osversion = string.Empty;
|
private string _version = string.Empty;
|
||||||
private string _serverpath = string.Empty;
|
private string _clrversion = string.Empty;
|
||||||
private string _servertime = string.Empty;
|
private string _osversion = string.Empty;
|
||||||
private string _installationid = string.Empty;
|
private string _serverpath = string.Empty;
|
||||||
|
private string _servertime = 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)
|
|
||||||
{
|
{
|
||||||
_clrversion = systeminfo["clrversion"];
|
_version = Constants.Version;
|
||||||
_osversion = systeminfo["osversion"];
|
|
||||||
_serverpath = systeminfo["serverpath"];
|
|
||||||
_servertime = systeminfo["servertime"];
|
|
||||||
_installationid = systeminfo["installationid"];
|
|
||||||
|
|
||||||
_runtime = systeminfo["runtime"];
|
Dictionary<string, string> systeminfo = await SystemService.GetSystemInfoAsync();
|
||||||
_rendermode = systeminfo["rendermode"];
|
if (systeminfo != null)
|
||||||
_detailederrors = systeminfo["detailederrors"];
|
|
||||||
_logginglevel = systeminfo["logginglevel"];
|
|
||||||
_swagger = systeminfo["swagger"];
|
|
||||||
_packageservice = systeminfo["packageservice"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SaveConfig()
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
_clrversion = systeminfo["clrversion"];
|
||||||
AddModuleMessage(Localizer["Success.Register"], MessageType.Success);
|
_osversion = systeminfo["osversion"];
|
||||||
|
_serverpath = systeminfo["serverpath"];
|
||||||
|
_servertime = systeminfo["servertime"];
|
||||||
|
_installationid = systeminfo["installationid"];
|
||||||
|
|
||||||
|
_runtime = systeminfo["runtime"];
|
||||||
|
_rendermode = systeminfo["rendermode"];
|
||||||
|
_detailederrors = systeminfo["detailederrors"];
|
||||||
|
_logginglevel = systeminfo["logginglevel"];
|
||||||
|
_swagger = systeminfo["swagger"];
|
||||||
|
_packageservice = systeminfo["packageservice"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
private async Task SaveConfig()
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error On Register");
|
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)
|
|
||||||
{
|
{
|
||||||
<Pager Items="@_packages">
|
if (_packages.Count > 0)
|
||||||
<Row>
|
|
||||||
<td>
|
|
||||||
<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 />
|
|
||||||
@(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 DownloadTheme(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 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>
|
|
||||||
</TabPanel>
|
|
||||||
</TabStrip>
|
|
||||||
|
|
||||||
<button type="button" class="btn btn-success" @onclick="InstallThemes">@SharedLocalizer["Install"]</button>
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private List<Package> _packages;
|
|
||||||
private string _search = "";
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await LoadThemes();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Loading Packages {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Package.Load"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task LoadThemes()
|
|
||||||
{
|
|
||||||
var themes = await ThemeService.GetThemesAsync();
|
|
||||||
_packages = await PackageService.GetPackagesAsync("theme", _search);
|
|
||||||
|
|
||||||
if (_packages != null)
|
|
||||||
{
|
|
||||||
foreach (Package package in _packages.ToArray())
|
|
||||||
{
|
|
||||||
if (themes.Exists(item => item.PackageName == package.PackageId))
|
|
||||||
{
|
{
|
||||||
_packages.Remove(package);
|
<Pager Items="@_packages">
|
||||||
|
<Row>
|
||||||
|
<td>
|
||||||
|
<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 />
|
||||||
|
@(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 DownloadTheme(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 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>
|
||||||
|
</TabPanel>
|
||||||
|
</TabStrip>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-success" @onclick="InstallThemes">@SharedLocalizer["Install"]</button>
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private List<Package> _packages;
|
||||||
|
private string _search = "";
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await LoadThemes();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading Packages {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.Package.Load"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadThemes()
|
||||||
|
{
|
||||||
|
var themes = await ThemeService.GetThemesAsync();
|
||||||
|
_packages = await PackageService.GetPackagesAsync("theme", _search);
|
||||||
|
|
||||||
|
if (_packages != null)
|
||||||
|
{
|
||||||
|
foreach (Package package in _packages.ToArray())
|
||||||
|
{
|
||||||
|
if (themes.Exists(item => item.PackageName == package.PackageId))
|
||||||
|
{
|
||||||
|
_packages.Remove(package);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Search()
|
private async Task Search()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await LoadThemes();
|
try
|
||||||
|
{
|
||||||
|
await LoadThemes();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error On Search");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error On Search");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Reset()
|
private async Task Reset()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
_search = "";
|
try
|
||||||
await LoadThemes();
|
{
|
||||||
|
_search = "";
|
||||||
|
await LoadThemes();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error On Reset");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error On Reset");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task InstallThemes()
|
private async Task InstallThemes()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await ThemeService.InstallThemesAsync();
|
try
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Theme.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
{
|
||||||
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Installing Theme");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DownloadTheme(string packageid, string version)
|
private async Task DownloadTheme(string packageid, string version)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
try
|
||||||
await logger.LogInformation("Theme {ThemeName} {Version} Downloaded Successfully", packageid, version);
|
{
|
||||||
AddModuleMessage(Localizer["Success.Theme.Download"], MessageType.Success);
|
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
||||||
StateHasChanged();
|
await logger.LogInformation("Theme {ThemeName} {Version} Downloaded Successfully", packageid, version);
|
||||||
}
|
AddModuleMessage(Localizer["Success.Theme.Download"], MessageType.Success);
|
||||||
catch (Exception ex)
|
StateHasChanged();
|
||||||
{
|
}
|
||||||
await logger.LogError(ex, "Error Downloading Module {ThemeName} {Version}", packageid, version);
|
catch (Exception ex)
|
||||||
AddModuleMessage(Localizer["Error.Theme.Download"], MessageType.Error);
|
{
|
||||||
|
await logger.LogError(ex, "Error Downloading Module {ThemeName} {Version}", packageid, version);
|
||||||
|
AddModuleMessage(Localizer["Error.Theme.Download"], MessageType.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -11,135 +11,149 @@
|
|||||||
|
|
||||||
@if (_templates != null)
|
@if (_templates != null)
|
||||||
{
|
{
|
||||||
<div class="container">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<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="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<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>
|
||||||
<input id="owner" class="form-control" @bind="@_owner" />
|
<div class="col-sm-9">
|
||||||
|
<input id="owner" class="form-control" @bind="@_owner" maxlength="256" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="module" class="form-control" @bind="@_theme" maxlength="256" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="template" HelpText="Select a theme template. Templates are located in the wwwroot/Themes/Templates folder on the server." ResourceKey="Template">Template: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="template" class="form-select" @onchange="(e => TemplateChanged(e))" required>
|
||||||
|
<option value="-"><@Localizer["Template.Select"]></option>
|
||||||
|
@foreach (Template template in _templates)
|
||||||
|
{
|
||||||
|
<option value="@template.Name">@template.Title</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="reference" HelpText="Select a framework reference version" ResourceKey="FrameworkReference">Framework Reference: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="reference" class="form-select" @bind="@_reference" required>
|
||||||
|
@foreach (string version in _versions)
|
||||||
|
{
|
||||||
|
if (Version.Parse(version).CompareTo(Version.Parse(_minversion)) >= 0)
|
||||||
|
{
|
||||||
|
<option value="@(version)">@(version)</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<option value="local">@SharedLocalizer["LocalVersion"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (!string.IsNullOrEmpty(_location))
|
||||||
|
{
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="location" HelpText="Location where the theme will be created" ResourceKey="Location">Location: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="module" class="form-control" @bind="@_location" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<br />
|
||||||
<div class="row mb-1 align-items-center">
|
<button type="button" class="btn btn-success" @onclick="CreateTheme">@Localizer["Theme.Create"]</button>
|
||||||
<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>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
<div class="col-sm-9">
|
</form>
|
||||||
<input id="module" class="form-control" @bind="@_theme" />
|
}
|
||||||
</div>
|
|
||||||
</div>
|
@code {
|
||||||
<div class="row mb-1 align-items-center">
|
private ElementReference form;
|
||||||
<Label Class="col-sm-3" For="template" HelpText="Select a theme template. Templates are located in the wwwroot/Themes/Templates folder on the server." ResourceKey="Template">Template: </Label>
|
private bool validated = false;
|
||||||
<div class="col-sm-9">
|
private string _owner = string.Empty;
|
||||||
<select id="template" class="form-select" @onchange="(e => TemplateChanged(e))">
|
private string _theme = string.Empty;
|
||||||
<option value="-"><@Localizer["Template.Select"]></option>
|
private List<Template> _templates;
|
||||||
@foreach (Template template in _templates)
|
private string _template = "-";
|
||||||
|
private string[] _versions;
|
||||||
|
private string _reference = Constants.Version;
|
||||||
|
private string _minversion = "2.0.0";
|
||||||
|
private string _location = string.Empty;
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
<option value="@template.Name">@template.Title</option>
|
_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);
|
||||||
}
|
}
|
||||||
</select>
|
catch (Exception ex)
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="reference" HelpText="Select a framework reference version" ResourceKey="FrameworkReference">Framework Reference: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="reference" class="form-select" @bind="@_reference">
|
|
||||||
@foreach (string version in _versions)
|
|
||||||
{
|
{
|
||||||
if (Version.Parse(version).CompareTo(Version.Parse(_minversion)) >= 0)
|
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
|
||||||
{
|
{
|
||||||
<option value="@(version)">@(version)</option>
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<option value="local">@SharedLocalizer["LocalVersion"]</option>
|
else
|
||||||
</select>
|
{
|
||||||
</div>
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
</div>
|
}
|
||||||
@if (!string.IsNullOrEmpty(_location)) {
|
}
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="location" HelpText="Location where the theme will be created" ResourceKey="Location">Location: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="module" class="form-control" @bind="@_location" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<button type="button" class="btn btn-success" @onclick="CreateTheme">@Localizer["Theme.Create"]</button>
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
}
|
|
||||||
|
|
||||||
@code {
|
private bool IsValid(string name)
|
||||||
private string _owner = string.Empty;
|
|
||||||
private string _theme = string.Empty;
|
|
||||||
private List<Template> _templates;
|
|
||||||
private string _template = "-";
|
|
||||||
private string[] _versions;
|
|
||||||
private string _reference = Constants.Version;
|
|
||||||
private string _minversion = "2.0.0";
|
|
||||||
private string _location = string.Empty;
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
|
||||||
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (IsValid(_owner) && IsValid(_theme) && _owner != _theme && _template != "-")
|
|
||||||
{
|
{
|
||||||
var theme = new Theme { Owner = _owner, Name = _theme, Template = _template, Version = _reference };
|
// must contain letters, underscores and digits and first character must be letter or underscore
|
||||||
theme = await ThemeService.CreateThemeAsync(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();
|
GetLocation();
|
||||||
AddModuleMessage(string.Format(Localizer["Success.Theme.Create"], NavigateUrl("admin/system")), MessageType.Success);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
private void GetLocation()
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.ValidName"], MessageType.Warning);
|
_location = string.Empty;
|
||||||
|
if (_owner != "" && _theme != "" && _template != "-")
|
||||||
|
{
|
||||||
|
var template = _templates.FirstOrDefault(item => item.Name == _template);
|
||||||
|
_location = template.Location + _owner + "." + _theme;
|
||||||
|
|
||||||
|
}
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Creating Theme");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Themes {Error}", ex.Message);
|
try
|
||||||
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>
|
||||||
<div class="row mb-1 align-items-center">
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
<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
|
|
||||||
{
|
{
|
||||||
_themeName = WebUtility.UrlDecode(PageState.QueryString["name"]);
|
try
|
||||||
var themes = await ThemeService.GetThemesAsync();
|
{
|
||||||
var theme = themes.FirstOrDefault(item => item.ThemeName == _themeName);
|
_themeName = WebUtility.UrlDecode(PageState.QueryString["name"]);
|
||||||
if (theme != null)
|
var themes = await ThemeService.GetThemesAsync();
|
||||||
{
|
var theme = themes.FirstOrDefault(item => item.ThemeName == _themeName);
|
||||||
_name = theme.Name;
|
if (theme != null)
|
||||||
_version = theme.Version;
|
{
|
||||||
_owner = theme.Owner;
|
_name = theme.Name;
|
||||||
_url = theme.Url;
|
_version = theme.Version;
|
||||||
_contact = theme.Contact;
|
_owner = theme.Owner;
|
||||||
_license = theme.License;
|
_url = theme.Url;
|
||||||
}
|
_contact = theme.Contact;
|
||||||
}
|
_license = theme.License;
|
||||||
catch (Exception ex)
|
}
|
||||||
{
|
}
|
||||||
await logger.LogError(ex, "Error Loading Theme {ThemeName} {Error}", _themeName, ex.Message);
|
catch (Exception ex)
|
||||||
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>
|
||||||
</div>
|
<button type="button" class="btn btn-success" @onclick="Upgrade">@SharedLocalizer["Upgrade"]</button>
|
||||||
<button type="button" class="btn btn-success" @onclick="Upgrade">@SharedLocalizer["Upgrade"]</button>
|
</TabPanel>
|
||||||
</TabPanel>
|
</TabStrip>
|
||||||
</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
|
|
||||||
{
|
{
|
||||||
List<Package> packages = await PackageService.GetPackagesAsync("framework");
|
try
|
||||||
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
|
||||||
{
|
{
|
||||||
_package = packages.Where(item => item.PackageId.StartsWith(Constants.PackageId)).FirstOrDefault();
|
AddModuleMessage(Localizer["Info.Upgrade.Wait"], MessageType.Info);
|
||||||
if (_package != null)
|
ShowProgressIndicator();
|
||||||
{
|
var interop = new Interop(JSRuntime);
|
||||||
_upgradeavailable = (Version.Parse(_package.Version).CompareTo(Version.Parse(Constants.Version)) > 0);
|
await interop.RedirectBrowser(NavigateUrl(), 10);
|
||||||
}
|
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
|
|
||||||
{
|
|
||||||
// can be caused by no network connection
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Upgrade()
|
private async Task Download(string packageid, string version)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Info.Upgrade.Wait"], MessageType.Info);
|
try
|
||||||
ShowProgressIndicator();
|
{
|
||||||
var interop = new Interop(JSRuntime);
|
await PackageService.DownloadPackageAsync(packageid, version, "Packages");
|
||||||
await interop.RedirectBrowser(NavigateUrl(), 10);
|
await PackageService.DownloadPackageAsync(Constants.UpdaterPackageId, version, "Packages");
|
||||||
await InstallationService.Upgrade();
|
AddModuleMessage(Localizer["Success.Framework.Download"], MessageType.Success);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Executing Upgrade {Error}", ex.Message);
|
await logger.LogError(ex, "Error Downloading Framework Package {Error}", ex.Message);
|
||||||
AddModuleMessage(Localizer["Error.Upgrade.Execute"], MessageType.Error);
|
AddModuleMessage(Localizer["Error.Framework.Download"], 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,62 +8,75 @@
|
|||||||
|
|
||||||
@if (PageState.User != null)
|
@if (PageState.User != null)
|
||||||
{
|
{
|
||||||
<div class="container">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<Label Class="col-sm-3" For="to" HelpText="Enter the username you wish to send a message to" ResourceKey="To">To: </Label>
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<Label Class="col-sm-3" For="to" HelpText="Enter the username you wish to send a message to" ResourceKey="To">To: </Label>
|
||||||
<input id="to" class="form-control" @bind="@username" />
|
<div class="col-sm-9">
|
||||||
</div> >
|
<input id="to" class="form-control" @bind="@username" maxlength="256" required/>
|
||||||
</div>
|
</div> >
|
||||||
<div class="row mb-1 align-items-center">
|
</div>
|
||||||
<Label Class="col-sm-3" For="subject" HelpText="Enter the subject of the message" ResourceKey="Subject">Subject: </Label>
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<Label Class="col-sm-3" For="subject" HelpText="Enter the subject of the message" ResourceKey="Subject">Subject: </Label>
|
||||||
<input id="subject" class="form-control" @bind="@subject" />
|
<div class="col-sm-9">
|
||||||
|
<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>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<textarea id="message" class="form-control" @bind="@body" rows="5" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br/>
|
|
||||||
<button type="button" class="btn btn-primary" @onclick="Send">@SharedLocalizer["Send"]</button>
|
<button type="button" class="btn btn-primary" @onclick="Send">@SharedLocalizer["Send"]</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string username = "";
|
private ElementReference form;
|
||||||
private string subject = "";
|
private bool validated = false;
|
||||||
private string body = "";
|
private string username = "";
|
||||||
|
private string subject = "";
|
||||||
|
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()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var user = await UserService.GetUserAsync(username, PageState.Site.SiteId);
|
validated = true;
|
||||||
if (user != null)
|
var interop = new Interop(JSRuntime);
|
||||||
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, null);
|
try
|
||||||
notification = await NotificationService.AddNotificationAsync(notification);
|
{
|
||||||
await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId);
|
var user = await UserService.GetUserAsync(username, PageState.Site.SiteId);
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
if (user != null)
|
||||||
|
{
|
||||||
|
var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, null);
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,360 +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)
|
||||||
{
|
{
|
||||||
<div class="container">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<Label Class="col-sm-3" For="username" HelpText="Your username. Note that this field can not be modified." ResourceKey="Username"></Label>
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<Label Class="col-sm-3" For="username" HelpText="Your username. Note that this field can not be modified." ResourceKey="Username"></Label>
|
||||||
<input id="username" class="form-control" @bind="@username" readonly />
|
<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>
|
</div>
|
||||||
</div>
|
<br />
|
||||||
<div class="row mb-1 align-items-center">
|
<button type="button" class="btn btn-success" @onclick="Save">@SharedLocalizer["Save"]</button>
|
||||||
<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>
|
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
|
||||||
<div class="col-sm-9">
|
</form>
|
||||||
<input id="password" type="password" class="form-control" @bind="@password" autocomplete="new-password" />
|
}
|
||||||
</div>
|
</TabPanel>
|
||||||
</div>
|
<TabPanel Name="Profile" ResourceKey="Profile">
|
||||||
<div class="row mb-1 align-items-center">
|
@if (profiles != null && settings != null)
|
||||||
<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" />
|
|
||||||
</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>
|
|
||||||
}
|
|
||||||
</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)
|
@foreach (Profile profile in profiles)
|
||||||
{
|
|
||||||
var p = profile;
|
|
||||||
if (!p.IsPrivate || UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
|
||||||
{
|
{
|
||||||
if (p.Category != category)
|
var p = profile;
|
||||||
|
if (!p.IsPrivate || UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
||||||
{
|
{
|
||||||
<div class="col text-center pb-2">
|
if (p.Category != category)
|
||||||
@p.Category
|
{
|
||||||
</div>
|
<div class="col text-center pb-2">
|
||||||
category = p.Category;
|
@p.Category
|
||||||
}
|
</div>
|
||||||
<div class="row mb-1 align-items-center">
|
category = p.Category;
|
||||||
<Label Class="col-sm-3" For="@p.Name" HelpText="@p.Description">@p.Title</Label>
|
}
|
||||||
<div class="col-sm-9">
|
<div class="row mb-1 align-items-center">
|
||||||
@if (!string.IsNullOrEmpty(p.Options))
|
<Label Class="col-sm-3" For="@p.Name" HelpText="@p.Description">@p.Title</Label>
|
||||||
{
|
<div class="col-sm-9">
|
||||||
<select id="@p.Name" class="form-select" @onchange="@(e => ProfileChanged(e, p.Name))">
|
@if (!string.IsNullOrEmpty(p.Options))
|
||||||
@foreach (var option in p.Options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
|
||||||
@if (GetProfileValue(p.Name, "") == option || (GetProfileValue(p.Name, "") == "" && p.DefaultValue == option))
|
|
||||||
{
|
|
||||||
<option value="@option" selected>@option</option>
|
|
||||||
}
|
|
||||||
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))" />
|
<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))
|
||||||
|
{
|
||||||
|
<option value="@option" selected>@option</option>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<option value="@option">@option</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
|
@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
|
||||||
|
{
|
||||||
|
<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>
|
||||||
|
<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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</div>
|
else
|
||||||
</div>
|
|
||||||
<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 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
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;
|
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
|
||||||
|
{
|
||||||
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await UserService.UpdateUserAsync(user);
|
private bool ValidateProfiles()
|
||||||
await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId);
|
{
|
||||||
await logger.LogInformation("User Profile Saved");
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
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
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Password.Invalid"], MessageType.Warning);
|
await NotificationService.DeleteNotificationAsync(Notification.NotificationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await logger.LogInformation("Notification Deleted {Notification}", Notification);
|
||||||
|
await LoadNotificationsAsync();
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.ProfileInfo"], MessageType.Warning);
|
await logger.LogError(ex, "Error Deleting Notification {Notification} {Error}", Notification, ex.Message);
|
||||||
|
AddModuleMessage(ex.Message, MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
private async void FilterChanged(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Saving User Profile {Error}", ex.Message);
|
filter = (string)e.Value;
|
||||||
AddModuleMessage(Localizer["Error.Profile.Save"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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,50 +8,50 @@
|
|||||||
|
|
||||||
@if (PageState.User != null)
|
@if (PageState.User != null)
|
||||||
{
|
{
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<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")
|
|
||||||
{
|
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<label class="col-sm-3">@Localizer["Date"] </label>
|
<label Class="col-sm-3">@Localizer["Title"] </label>
|
||||||
<div class="col-sm-9">
|
@if (title == "From")
|
||||||
<input class="form-control" @bind="@createdon" readonly />
|
{
|
||||||
</div>
|
<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>
|
||||||
}
|
<div class="row mb-1 align-items-center">
|
||||||
@if (title == "From")
|
<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")
|
||||||
|
{
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<label class="col-sm-3">@Localizer["Date"] </label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input class="form-control" @bind="@createdon" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if (title == "From")
|
||||||
|
{
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<label class="col-sm-3">@Localizer["Message"] </label>
|
<label class="col-sm-3">@Localizer["Message"] </label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
@ -59,140 +59,140 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
}
|
||||||
|
@if (title == "To")
|
||||||
|
{
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
</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")
|
@if (title == "To")
|
||||||
{
|
{
|
||||||
|
<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["Message"] </label>
|
<textarea class="form-control" @bind="@reply" rows="5" readonly />
|
||||||
<div class="col-sm-9">
|
</div>
|
||||||
<textarea class="form-control" @bind="@body" rows="5" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</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 {
|
@code {
|
||||||
private int notificationid;
|
private int notificationid;
|
||||||
private string title = string.Empty;
|
private string title = string.Empty;
|
||||||
private string username = "";
|
private string username = "";
|
||||||
private string subject = string.Empty;
|
private string subject = string.Empty;
|
||||||
private string createdon = string.Empty;
|
private string createdon = string.Empty;
|
||||||
private string body = string.Empty;
|
private string body = string.Empty;
|
||||||
private string reply = string.Empty;
|
private string reply = string.Empty;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
|
||||||
public override string Title => "View Notification";
|
public override string Title => "View Notification";
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
notificationid = Int32.Parse(PageState.QueryString["id"]);
|
|
||||||
Notification notification = await NotificationService.GetNotificationAsync(notificationid);
|
|
||||||
if (notification != null)
|
|
||||||
{
|
{
|
||||||
int userid = -1;
|
try
|
||||||
if (notification.ToUserId == PageState.User.UserId)
|
|
||||||
{
|
{
|
||||||
title = "From";
|
notificationid = Int32.Parse(PageState.QueryString["id"]);
|
||||||
if (notification.FromUserId != null)
|
Notification notification = await NotificationService.GetNotificationAsync(notificationid);
|
||||||
|
if (notification != null)
|
||||||
{
|
{
|
||||||
userid = notification.FromUserId.Value;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
title = "To";
|
await logger.LogError(ex, "Error Loading Users {Error}", ex.Message);
|
||||||
if (notification.ToUserId != null)
|
AddModuleMessage(Localizer["Error.User.Load"], MessageType.Error);
|
||||||
{
|
|
||||||
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()
|
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);
|
title = "To";
|
||||||
notification = await NotificationService.AddNotificationAsync(notification);
|
if (!subject.Contains("RE:"))
|
||||||
await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId);
|
{
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
subject = "RE: " + subject;
|
||||||
|
}
|
||||||
|
reply = body;
|
||||||
|
body = "\n\n____________________________________________\nSent: " + createdon + "\nSubject: " + subject + "\n\n" + body;
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
private async Task Send()
|
||||||
AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning);
|
{
|
||||||
}
|
try
|
||||||
}
|
{
|
||||||
catch (Exception ex)
|
var user = await UserService.GetUserAsync(username, PageState.Site.SiteId);
|
||||||
{
|
if (user != null)
|
||||||
await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message);
|
{
|
||||||
AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -7,190 +7,204 @@
|
|||||||
@inject IStringLocalizer<Add> Localizer
|
@inject IStringLocalizer<Add> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
|
||||||
<TabStrip>
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<TabPanel Name="Identity" ResourceKey="Identity">
|
<TabStrip>
|
||||||
@if (profiles != null)
|
<TabPanel Name="Identity" ResourceKey="Identity">
|
||||||
{
|
@if (profiles != null)
|
||||||
<div class="container">
|
{
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<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="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<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>
|
||||||
<input id="username" class="form-control" @bind="@username" />
|
<div class="col-sm-9">
|
||||||
|
<input id="username" class="form-control" @bind="@username" maxlength="256" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="password" type="password" class="form-control" @bind="@password" maxlength="256" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="confirm" type="password" class="form-control" @bind="@confirm" maxlength="256" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="email" class="form-control" @bind="@email" maxlength="256" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="displayname" class="form-control" @bind="@displayname" maxlength="256" required/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<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>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="password" type="password" class="form-control" @bind="@password" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<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>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="confirm" type="password" class="form-control" @bind="@confirm" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<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>
|
|
||||||
<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="The full name of the user" ResourceKey="DisplayName"></Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="displayname" class="form-control" @bind="@displayname" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel Name="Profile" ResourceKey="Profile">
|
<TabPanel Name="Profile" ResourceKey="Profile">
|
||||||
@if (profiles != null)
|
@if (profiles != 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)
|
@foreach (Profile profile in profiles)
|
||||||
{
|
|
||||||
var p = profile;
|
|
||||||
if (p.Category != category)
|
|
||||||
{
|
{
|
||||||
<div class="col text-center pb-2">
|
var p = profile;
|
||||||
<strong>@p.Category</strong>
|
if (p.Category != category)
|
||||||
|
{
|
||||||
|
<div class="col text-center pb-2">
|
||||||
|
<strong>@p.Category</strong>
|
||||||
|
</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="col-sm-9">
|
||||||
|
@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
|
||||||
|
{
|
||||||
|
<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>
|
||||||
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>
|
||||||
<div class="col-sm-9">
|
</div>
|
||||||
@if (p.IsRequired)
|
}
|
||||||
|
</TabPanel>
|
||||||
|
</TabStrip>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<button type="button" class="btn btn-success" @onclick="SaveUser">@SharedLocalizer["Save"]</button>
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@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 List<Profile> profiles;
|
||||||
|
private Dictionary<string, string> settings;
|
||||||
|
private string category = string.Empty;
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
if (username != string.Empty && password != string.Empty && confirm != string.Empty && email != string.Empty && ValidateProfiles())
|
||||||
|
{
|
||||||
|
if (password == confirm)
|
||||||
|
{
|
||||||
|
var user = await UserService.GetUserAsync(username, PageState.Site.SiteId);
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
user = new User();
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" required @onchange="@(e => ProfileChanged(e, p.Name))" />
|
await SettingService.UpdateUserSettingsAsync(settings, user.UserId);
|
||||||
|
await logger.LogInformation("User Created {User}", user);
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
|
await logger.LogError("Error Adding User {Username} {Email}", username, email);
|
||||||
|
AddModuleMessage(Localizer["Error.User.AddCheckPass"], MessageType.Error);
|
||||||
}
|
}
|
||||||
</div>
|
}
|
||||||
</div>
|
else
|
||||||
}
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Username.Exists"], MessageType.Warning);
|
||||||
</div>
|
}
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</TabPanel>
|
|
||||||
</TabStrip>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveUser">@SharedLocalizer["Save"]</button>
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
|
|
||||||
@code {
|
|
||||||
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 List<Profile> profiles;
|
|
||||||
private Dictionary<string, string> settings;
|
|
||||||
private string category = string.Empty;
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
|
||||||
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (username != string.Empty && password != string.Empty && confirm != string.Empty && email != string.Empty && ValidateProfiles())
|
|
||||||
{
|
|
||||||
if (password == confirm)
|
|
||||||
{
|
|
||||||
var user = await UserService.GetUserAsync(username, PageState.Site.SiteId);
|
|
||||||
if (user == null)
|
|
||||||
{
|
|
||||||
user = new User();
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
await SettingService.UpdateUserSettingsAsync(settings, user.UserId);
|
|
||||||
await logger.LogInformation("User Created {User}", user);
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError("Error Adding User {Username} {Email}", username, email);
|
AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning);
|
||||||
AddModuleMessage(Localizer["Error.User.AddCheckPass"], MessageType.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Username.Exists"], MessageType.Warning);
|
AddModuleMessage(Localizer["Message.Required.ProfileInfo"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning);
|
await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", username, email, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.User.Add"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.ProfileInfo"], MessageType.Warning);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
private bool ValidateProfiles()
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", username, email, ex.Message);
|
bool valid = true;
|
||||||
AddModuleMessage(Localizer["Error.User.Add"], MessageType.Error);
|
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 bool ValidateProfiles()
|
private void ProfileChanged(ChangeEventArgs e, string SettingName)
|
||||||
{
|
|
||||||
bool valid = true;
|
|
||||||
foreach (Profile profile in profiles)
|
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)) && !string.IsNullOrEmpty(profile.DefaultValue))
|
var value = (string)e.Value;
|
||||||
{
|
settings = SettingService.SetSetting(settings, SettingName, value);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -16,237 +16,250 @@ else
|
|||||||
{
|
{
|
||||||
<br />
|
<br />
|
||||||
}
|
}
|
||||||
<TabStrip>
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<TabPanel Name="Identity" ResourceKey="Identity">
|
<TabStrip>
|
||||||
@if (profiles != null)
|
<TabPanel Name="Identity" ResourceKey="Identity">
|
||||||
{
|
@if (profiles != null)
|
||||||
<div class="container">
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="username" HelpText="The unique username for a user. 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="The user's password. Please choose a password which is sufficiently secure." ResourceKey="Password"></Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="password" type="password" class="form-control" @bind="@password" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<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>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="confirm" type="password" class="form-control" @bind="@confirm" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<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>
|
|
||||||
<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="The full name of the user" 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 the user" ResourceKey="Photo"></Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<FileManager FileId="@photofileid" @ref="filemanager" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="isdeleted" HelpText="Indicate if the user is active" ResourceKey="IsDeleted"></Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<select id="isdeleted" class="form-select" @bind="@isdeleted">
|
|
||||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
|
||||||
<option value="False">@SharedLocalizer["No"]</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
}
|
|
||||||
</TabPanel>
|
|
||||||
<TabPanel Name="Profile" ResourceKey="Profile">
|
|
||||||
@if (profiles != null)
|
|
||||||
{
|
|
||||||
<div class="container">
|
|
||||||
<div class="row mb-1 align-items-center">
|
|
||||||
@foreach (Profile profile in profiles)
|
|
||||||
{
|
|
||||||
var p = profile;
|
|
||||||
if (p.Category != category)
|
|
||||||
{
|
|
||||||
<div class="col text-center pb-2">
|
|
||||||
<strong>@p.Category</strong>
|
|
||||||
</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="col-sm-9">
|
|
||||||
@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
|
|
||||||
{
|
|
||||||
<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>
|
|
||||||
}
|
|
||||||
</TabPanel>
|
|
||||||
</TabStrip>
|
|
||||||
|
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveUser">@SharedLocalizer["Save"]</button>
|
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon" DeletedBy="@deletedby" DeletedOn="@deletedon"></AuditInfo>
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private int userid;
|
|
||||||
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 createdby;
|
|
||||||
private DateTime createdon;
|
|
||||||
private string modifiedby;
|
|
||||||
private DateTime modifiedon;
|
|
||||||
private string deletedby;
|
|
||||||
private DateTime? deletedon;
|
|
||||||
private string isdeleted;
|
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
|
||||||
|
|
||||||
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);
|
<div class="container">
|
||||||
userid = Int32.Parse(PageState.QueryString["id"]);
|
<div class="row mb-1 align-items-center">
|
||||||
var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
<Label Class="col-sm-3" For="username" HelpText="The unique username for a user. Note that this field can not be modified." ResourceKey="Username"></Label>
|
||||||
if (user != null)
|
<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="The user's password. Please choose a password which is sufficiently secure." ResourceKey="Password"></Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="password" type="password" class="form-control" @bind="@password" maxlength="256" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="confirm" type="password" class="form-control" @bind="@confirm" maxlength="256" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="email" class="form-control" @bind="@email" maxlength="256" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="displayname" class="form-control" @bind="@displayname" maxlength="256" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="@photofileid.ToString()" HelpText="A photo of the user" ResourceKey="Photo"></Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<FileManager FileId="@photofileid" @ref="filemanager" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="isdeleted" HelpText="Indicate if the user is active" ResourceKey="IsDeleted"></Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="isdeleted" class="form-select" @bind="@isdeleted" required>
|
||||||
|
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||||
|
<option value="False">@SharedLocalizer["No"]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
}
|
||||||
|
</TabPanel>
|
||||||
|
<TabPanel Name="Profile" ResourceKey="Profile">
|
||||||
|
@if (profiles != null)
|
||||||
|
{
|
||||||
|
<div class="container">
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
@foreach (Profile profile in profiles)
|
||||||
|
{
|
||||||
|
var p = profile;
|
||||||
|
if (p.Category != category)
|
||||||
|
{
|
||||||
|
<div class="col text-center pb-2">
|
||||||
|
<strong>@p.Category</strong>
|
||||||
|
</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="col-sm-9">
|
||||||
|
@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
|
||||||
|
{
|
||||||
|
<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>
|
||||||
|
}
|
||||||
|
</TabPanel>
|
||||||
|
</TabStrip>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-success" @onclick="SaveUser">@SharedLocalizer["Save"]</button>
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon" DeletedBy="@deletedby" DeletedOn="@deletedon"></AuditInfo>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private ElementReference form;
|
||||||
|
private bool validated = false;
|
||||||
|
private int userid;
|
||||||
|
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 createdby;
|
||||||
|
private DateTime createdon;
|
||||||
|
private string modifiedby;
|
||||||
|
private DateTime modifiedon;
|
||||||
|
private string deletedby;
|
||||||
|
private DateTime? deletedon;
|
||||||
|
private string isdeleted;
|
||||||
|
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||||
|
|
||||||
|
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"))
|
||||||
{
|
{
|
||||||
username = user.Username;
|
profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
|
||||||
email = user.Email;
|
userid = Int32.Parse(PageState.QueryString["id"]);
|
||||||
displayname = user.DisplayName;
|
var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
||||||
if (user.PhotoFileId != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
photofileid = user.PhotoFileId.Value;
|
username = user.Username;
|
||||||
photo = await FileService.GetFileAsync(photofileid);
|
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
|
||||||
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
photofileid = -1;
|
AddModuleMessage(Localizer["Message.Required.ProfileInfo"], MessageType.Warning);
|
||||||
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)
|
||||||
}
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (username != string.Empty && email != string.Empty && ValidateProfiles())
|
|
||||||
{
|
|
||||||
if (password == confirm)
|
|
||||||
{
|
{
|
||||||
var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
await logger.LogError(ex, "Error Saving User {Username} {Email} {Error}", username, email, ex.Message);
|
||||||
user.SiteId = PageState.Site.SiteId;
|
AddModuleMessage(Localizer["Error.User.Save"], MessageType.Error);
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.ProfileInfo"], MessageType.Warning);
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
private bool ValidateProfiles()
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Saving User {Username} {Email} {Error}", username, email, ex.Message);
|
bool valid = true;
|
||||||
AddModuleMessage(Localizer["Error.User.Save"], MessageType.Error);
|
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 bool ValidateProfiles()
|
private void ProfileChanged(ChangeEventArgs e, string SettingName)
|
||||||
{
|
|
||||||
bool valid = true;
|
|
||||||
foreach (Profile profile in profiles)
|
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(SettingService.GetSetting(settings, profile.Name, string.Empty)) && !string.IsNullOrEmpty(profile.DefaultValue))
|
var value = (string)e.Value;
|
||||||
{
|
settings = SettingService.SetSetting(settings, SettingName, value);
|
||||||
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>
|
||||||
</div>
|
<Pager Items="@userroles">
|
||||||
<Pager Items="@userroles">
|
<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>
|
||||||
<td>
|
<ActionLink Action="Edit" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="EditUser" />
|
||||||
<ActionLink Action="Edit" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="EditUser" />
|
</td>
|
||||||
</td>
|
<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" />
|
||||||
<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>
|
<td>
|
||||||
<td>
|
<ActionLink Action="Roles" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="Roles" />
|
||||||
<ActionLink Action="Roles" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="Roles" />
|
</td>
|
||||||
</td>
|
<td>@context.User.DisplayName</td>
|
||||||
<td>@context.User.DisplayName</td>
|
</Row>
|
||||||
</Row>
|
</Pager>
|
||||||
</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);
|
|
||||||
await LoadSettingsAsync();
|
|
||||||
userroles = Search(_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)));
|
|
||||||
|
|
||||||
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);
|
allroles = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
||||||
await logger.LogInformation("User Deleted {User}", UserRole.User);
|
await LoadSettingsAsync();
|
||||||
StateHasChanged();
|
userroles = Search(_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)));
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -12,200 +12,213 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div class="container">
|
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="container">
|
||||||
<Label Class="col-sm-3" For="user" HelpText="The user you are assigning roles to" ResourceKey="User">User: </Label>
|
<div class="row mb-1 align-items-center">
|
||||||
<div class="col-sm-9">
|
<Label Class="col-sm-3" For="user" HelpText="The user you are assigning roles to" ResourceKey="User">User: </Label>
|
||||||
<input id="user" class="form-control" @bind="@name" disabled />
|
<div class="col-sm-9">
|
||||||
|
<input id="user" class="form-control" @bind="@name" disabled />
|
||||||
|
</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="role" HelpText="Select a role" ResourceKey="Role">Role: </Label>
|
||||||
<Label Class="col-sm-3" For="role" HelpText="Select a role" ResourceKey="Role">Role: </Label>
|
<div class="col-sm-9">
|
||||||
<div class="col-sm-9">
|
<select id="role" class="form-select" @bind="@roleid" required>
|
||||||
<select id="role" class="form-select" @bind="@roleid">
|
<option value="-1"><@Localizer["Role.Select"]></option>
|
||||||
<option value="-1"><@Localizer["Role.Select"]></option>
|
@foreach (Role role in roles)
|
||||||
@foreach (Role role in roles)
|
{
|
||||||
{
|
<option value="@(role.RoleId)">@role.Name</option>
|
||||||
<option value="@(role.RoleId)">@role.Name</option>
|
}
|
||||||
}
|
</select>
|
||||||
</select>
|
</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="effectiveDate" HelpText="The date that this role assignment is active" ResourceKey="EffectiveDate">Effective Date: </Label>
|
||||||
<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">
|
||||||
<div class="col-sm-9">
|
<input id="effectiveDate" class="form-control" @bind="@effectivedate" required />
|
||||||
<input id="effectiveDate" class="form-control" @bind="@effectivedate" />
|
</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="expiryDate" HelpText="The date that this role assignment expires" ResourceKey="ExpiryDate">Expiry Date: </Label>
|
||||||
<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">
|
||||||
<div class="col-sm-9">
|
<input id="expiryDate" class="form-control" @bind="@expirydate" required />
|
||||||
<input id="expiryDate" class="form-control" @bind="@expirydate" />
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveUserRole">@SharedLocalizer["Save"]</button>
|
<button type="button" class="btn btn-success" @onclick="SaveUserRole">@SharedLocalizer["Save"]</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
<hr class="app-rule" />
|
<hr class="app-rule" />
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<Pager Items="@userroles">
|
<Pager Items="@userroles">
|
||||||
<Header>
|
<Header>
|
||||||
<th>@Localizer["Roles"]</th>
|
<th>@Localizer["Roles"]</th>
|
||||||
<th>@Localizer["Effective"]</th>
|
<th>@Localizer["Effective"]</th>
|
||||||
<th>@Localizer["Expiry"]</th>
|
<th>@Localizer["Expiry"]</th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td>@context.Role.Name</td>
|
<td>@context.Role.Name</td>
|
||||||
<td>@context.EffectiveDate</td>
|
<td>@context.EffectiveDate</td>
|
||||||
<td>@context.ExpiryDate</td>
|
<td>@context.ExpiryDate</td>
|
||||||
<td>
|
<td>
|
||||||
<ActionDialog Header="Remove Role" Message="@string.Format(Localizer["Confirm.User.RemoveRole"], context.Role.Name)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteUserRole(context.UserRoleId))" Disabled="@(context.Role.IsAutoAssigned || (context.Role.Name == RoleNames.Host && userid == PageState.User.UserId))" ResourceKey="DeleteUserRole" />
|
<ActionDialog Header="Remove Role" Message="@string.Format(Localizer["Confirm.User.RemoveRole"], context.Role.Name)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteUserRole(context.UserRoleId))" Disabled="@(context.Role.IsAutoAssigned || (context.Role.Name == RoleNames.Host && userid == PageState.User.UserId))" ResourceKey="DeleteUserRole" />
|
||||||
</td>
|
</td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
</p>
|
</p>
|
||||||
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private int userid;
|
private ElementReference form;
|
||||||
private string name = string.Empty;
|
private bool validated = false;
|
||||||
private List<Role> roles;
|
private int userid;
|
||||||
private int roleid = -1;
|
private string name = string.Empty;
|
||||||
private string effectivedate = string.Empty;
|
private List<Role> roles;
|
||||||
private string expirydate = string.Empty;
|
private int roleid = -1;
|
||||||
private List<UserRole> userroles;
|
private string effectivedate = string.Empty;
|
||||||
|
private string expirydate = string.Empty;
|
||||||
|
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))
|
|
||||||
{
|
{
|
||||||
roles = await RoleService.GetRolesAsync(PageState.Site.SiteId, true);
|
try
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (roleid != -1)
|
|
||||||
{
|
|
||||||
var userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault();
|
|
||||||
if (userrole != null)
|
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(effectivedate))
|
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))
|
||||||
{
|
{
|
||||||
userrole.EffectiveDate = null;
|
roles = await RoleService.GetRolesAsync(PageState.Site.SiteId, true);
|
||||||
|
roles = roles.Where(item => item.Name != RoleNames.Everyone).ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
userrole.EffectiveDate = DateTime.Parse(effectivedate);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(expirydate))
|
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
|
||||||
{
|
{
|
||||||
userrole.ExpiryDate = null;
|
if (roleid != -1)
|
||||||
|
{
|
||||||
|
var userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault();
|
||||||
|
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
|
||||||
|
{
|
||||||
|
AddModuleMessage(Localizer["Message.Required.Role"], MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
userrole.ExpiryDate = DateTime.Parse(expirydate);
|
await logger.LogError(ex, "Error Saving User Roles {UserId} {Error}", userid, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Error.User.SaveRole"], MessageType.Error);
|
||||||
}
|
}
|
||||||
await UserRoleService.UpdateUserRoleAsync(userrole);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
userrole = new UserRole();
|
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||||
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
|
|
||||||
|
private async Task DeleteUserRole(int UserRoleId)
|
||||||
{
|
{
|
||||||
AddModuleMessage(Localizer["Message.Required.Role"], MessageType.Warning);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await logger.LogError(ex, "Error Saving User Roles {UserId} {Error}", userid, ex.Message);
|
|
||||||
AddModuleMessage(Localizer["Error.User.SaveRole"], MessageType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -273,10 +273,13 @@
|
|||||||
<data name="FullName" xml:space="preserve">
|
<data name="FullName" xml:space="preserve">
|
||||||
<value>Full Name:</value>
|
<value>Full Name:</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="LocalVersion" xml:space="preserve">
|
<data name="LocalVersion" xml:space="preserve">
|
||||||
<value>Local Version</value>
|
<value>Local Version</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Search.Source" xml:space="preserve">
|
<data name="Search.Source" xml:space="preserve">
|
||||||
<value>source</value>
|
<value>source</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Message.InfoRequired" xml:space="preserve">
|
||||||
|
<value>Please Provide All Required Information</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"Runtime": "Server",
|
"Runtime": "Server",
|
||||||
"RenderMode": "ServerPrerendered",
|
"RenderMode": "ServerPrerendered",
|
||||||
"Database": {
|
"Database": {
|
||||||
"DefaultDBType": ""
|
"DefaultDBType": "Oqtane.Database.SqlServer.SqlServerDatabase, Oqtane.Database.SqlServer"
|
||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DefaultConnection": ""
|
"DefaultConnection": "Data Source=(LocalDb)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\Oqtane-202107100210.mdf;Initial Catalog=Oqtane-202107100210;Integrated Security=SSPI;"
|
||||||
},
|
},
|
||||||
"Installation": {
|
"Installation": {
|
||||||
"DefaultAlias": "",
|
"DefaultAlias": "",
|
||||||
@ -44,5 +44,19 @@
|
|||||||
"ControlType": "Oqtane.Installer.Controls.PostgreSQLConfig, Oqtane.Client",
|
"ControlType": "Oqtane.Installer.Controls.PostgreSQLConfig, Oqtane.Client",
|
||||||
"DBType": "Oqtane.Database.PostgreSQL.PostgreSQLDatabase, Oqtane.Database.PostgreSQL"
|
"DBType": "Oqtane.Database.PostgreSQL.PostgreSQLDatabase, Oqtane.Database.PostgreSQL"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"Logging": {
|
||||||
|
"FileLogger": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"InstallationId": "b2c613c4-26c3-42a6-b502-f4b4f95252ac",
|
||||||
|
"DetailedErrors": "false",
|
||||||
|
"UseSwagger": "true",
|
||||||
|
"PackageService": "true"
|
||||||
}
|
}
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1,4 @@
|
|||||||
|
/* CSS overrides */
|
||||||
|
input[type="text"], textarea {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
17
Oqtane.Server/wwwroot/Themes/Oqtane.Theme.Bootswatch/Lux.css
Normal file
17
Oqtane.Server/wwwroot/Themes/Oqtane.Theme.Bootswatch/Lux.css
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/* CSS overrides */
|
||||||
|
body {
|
||||||
|
padding-top: 11rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary {
|
||||||
|
color: rgb(255, 255, 255);
|
||||||
|
background-color: rgb(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
padding: 0.75rem 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table td, .table th {
|
||||||
|
padding: 1.0rem;
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
/* CSS overrides */
|
||||||
|
.btn {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
padding-top: 8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
[contenteditable].form-control, [type=email].form-control, [type=password].form-control, [type=tel].form-control, [type=text].form-control, input.form-control, input[type=email], input[type=number], input[type=password], input[type=text], textarea, textarea.form-control {
|
||||||
|
box-shadow: inset 0 -1px 0 #ddd !important;
|
||||||
|
transition: box-shadow .2s !important;
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1,4 @@
|
|||||||
|
/* CSS overrides */
|
||||||
|
.btn {
|
||||||
|
padding: 0.9rem 0.9rem;
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
/* CSS overrides */
|
||||||
|
body{
|
||||||
|
padding-top: 9rem;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
/* CSS overrides */
|
||||||
|
.btn {
|
||||||
|
padding: 0.5rem 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table .form-control {
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table .form-select {
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
option {
|
||||||
|
background-color: #6f749c !important;
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1,8 @@
|
|||||||
|
/* CSS overrides */
|
||||||
|
.card-body {
|
||||||
|
background-color: #073642;
|
||||||
|
}
|
||||||
|
|
||||||
|
card-header {
|
||||||
|
background-color: #d8b64c;
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
108
Oqtane.Server/wwwroot/Themes/Oqtane.Theme.Bootswatch/Theme.css
Normal file
108
Oqtane.Server/wwwroot/Themes/Oqtane.Theme.Bootswatch/Theme.css
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
|
||||||
|
|
||||||
|
body {
|
||||||
|
padding-top: 7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table > :not(caption) > * > * {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table .form-control {
|
||||||
|
background-color: #ffffff !important;
|
||||||
|
border-width: 0.5px !important;
|
||||||
|
border-bottom-color: #ccc !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table .form-select {
|
||||||
|
background-color: #ffffff !important;
|
||||||
|
border-width: 0.5px !important;
|
||||||
|
border-bottom-color: #ccc !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table .btn-primary {
|
||||||
|
background-color: var(--bs-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.table .btn-secondary {
|
||||||
|
background-color: var(--bs-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-dismissible .btn-close {
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.controls {
|
||||||
|
z-index: 2000;
|
||||||
|
padding-top: 15px;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-menu .nav-item {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-menu .nav-item a {
|
||||||
|
border-radius: 4px;
|
||||||
|
height: 3rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
line-height: 3rem;
|
||||||
|
padding-left: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-menu .nav-item a.active {
|
||||||
|
background-color: rgba(255,255,255,0.25);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-menu .nav-item a:hover {
|
||||||
|
background-color: rgba(255,255,255,0.1);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-menu .nav-link .oi {
|
||||||
|
width: 1.5rem;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
vertical-align: text-top;
|
||||||
|
top: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-toggler {
|
||||||
|
background-color: rgba(255, 255, 255, 0.1);
|
||||||
|
margin: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
|
||||||
|
.app-menu {
|
||||||
|
width: 100%
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar {
|
||||||
|
position: fixed;
|
||||||
|
top: 60px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.controls {
|
||||||
|
height: 60px;
|
||||||
|
top: 15px;
|
||||||
|
position: fixed;
|
||||||
|
top: 0px;
|
||||||
|
width: 100%;
|
||||||
|
background-color: rgb(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.controls-group {
|
||||||
|
float: right;
|
||||||
|
margin-right: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
position: relative;
|
||||||
|
top: 60px;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1,16 @@
|
|||||||
|
/* CSS overrides */
|
||||||
|
.card {
|
||||||
|
background-color: #1a0a33;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table .form-control {
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table .form-select {
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
option {
|
||||||
|
background-color: #ad82fc !important;
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
@ -0,0 +1 @@
|
|||||||
|
/* CSS overrides */
|
Reference in New Issue
Block a user