58 lines
2.0 KiB
Plaintext
58 lines
2.0 KiB
Plaintext
@namespace Oqtane.Modules.Admin.Modules
|
|
@inherits ModuleBase
|
|
@inject NavigationManager NavigationManager
|
|
@inject IModuleService ModuleService
|
|
@inject IStringLocalizer<Import> Localizer
|
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
|
|
|
<table class="table table-borderless">
|
|
<tbody>
|
|
<tr>
|
|
<td width="30%">
|
|
<Label For="content" HelpText="Enter the module content" ResourceKey="Content">Content: </Label>
|
|
</td>
|
|
<td>
|
|
<textarea id="content" class="form-control" @bind="@_content" rows="5"></textarea>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<button type="button" class="btn btn-success" @onclick="ImportModule">@Localizer["Import"]</button>
|
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
|
|
|
|
|
@code {
|
|
private string _content = string.Empty;
|
|
|
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
|
public override string Title => "Import Content";
|
|
|
|
private async Task ImportModule()
|
|
{
|
|
if (_content != string.Empty)
|
|
{
|
|
try
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await logger.LogError(ex, "Error Importing Module {ModuleId} {Error}", ModuleState.ModuleId, ex.Message);
|
|
AddModuleMessage(Localizer["Error.Module.Import"], MessageType.Error);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AddModuleMessage(Localizer["Message.Required.ImportContent"], MessageType.Warning);
|
|
}
|
|
}
|
|
}
|