176 lines
8.4 KiB
Plaintext
176 lines
8.4 KiB
Plaintext
@namespace Oqtane.Modules.Admin.ModuleDefinitions
|
|
@inherits ModuleBase
|
|
@inject IModuleDefinitionService ModuleDefinitionService
|
|
@inject NavigationManager NavigationManager
|
|
@inject IStringLocalizer<Edit> Localizer
|
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
|
|
|
<TabStrip>
|
|
<TabPanel Name="Definition" ResourceKey="Definition">
|
|
<div class="container">
|
|
<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="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 Name="Permissions" ResourceKey="Permissions">
|
|
<div class="container">
|
|
<div class="row mb-1 align-items-center">
|
|
<PermissionGrid EntityName="@EntityNames.ModuleDefinition" PermissionNames="@PermissionNames.Utilize" Permissions="@_permissions" @ref="_permissionGrid" />
|
|
</div>
|
|
</div>
|
|
</TabPanel>
|
|
</TabStrip>
|
|
<button type="button" class="btn btn-success" @onclick="SaveModuleDefinition">@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 {
|
|
private int _moduleDefinitionId;
|
|
private string _name;
|
|
private string _version;
|
|
private string _categories;
|
|
private string _moduledefinitionname = "";
|
|
private string _description = "";
|
|
private string _owner = "";
|
|
private string _url = "";
|
|
private string _contact = "";
|
|
private string _license = "";
|
|
private string _runtimes = "";
|
|
private string _permissions;
|
|
private string _createdby;
|
|
private DateTime _createdon;
|
|
private string _modifiedby;
|
|
private DateTime _modifiedon;
|
|
|
|
#pragma warning disable 649
|
|
private PermissionGrid _permissionGrid;
|
|
#pragma warning restore 649
|
|
|
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
try
|
|
{
|
|
_moduleDefinitionId = Int32.Parse(PageState.QueryString["id"]);
|
|
var moduleDefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId);
|
|
if (moduleDefinition != null)
|
|
{
|
|
_name = moduleDefinition.Name;
|
|
_version = moduleDefinition.Version;
|
|
_categories = moduleDefinition.Categories;
|
|
_moduledefinitionname = moduleDefinition.ModuleDefinitionName;
|
|
_description = moduleDefinition.Description;
|
|
_owner = moduleDefinition.Owner;
|
|
_url = moduleDefinition.Url;
|
|
_contact = moduleDefinition.Contact;
|
|
_license = moduleDefinition.License;
|
|
_runtimes = moduleDefinition.Runtimes;
|
|
_permissions = moduleDefinition.Permissions;
|
|
_createdby = moduleDefinition.CreatedBy;
|
|
_createdon = moduleDefinition.CreatedOn;
|
|
_modifiedby = moduleDefinition.ModifiedBy;
|
|
_modifiedon = moduleDefinition.ModifiedOn;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await logger.LogError(ex, "Error Loading ModuleDefinition {ModuleDefinitionId} {Error}", _moduleDefinitionId, ex.Message);
|
|
AddModuleMessage(Localizer["Error.Module.Load"], MessageType.Error);
|
|
}
|
|
}
|
|
|
|
private async Task SaveModuleDefinition()
|
|
{
|
|
try
|
|
{
|
|
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());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await logger.LogError(ex, "Error Saving ModuleDefinition {ModuleDefinitionId} {Error}", _moduleDefinitionId, ex.Message);
|
|
AddModuleMessage(Localizer["Error.Module.Save"], MessageType.Error);
|
|
}
|
|
}
|
|
}
|