95 lines
2.8 KiB
Plaintext
95 lines
2.8 KiB
Plaintext
@namespace Oqtane.Modules.Admin.Roles
|
|
@inherits ModuleBase
|
|
@inject NavigationManager NavigationManager
|
|
@inject IRoleService RoleService
|
|
|
|
<table class="table table-borderless">
|
|
<tr>
|
|
<td>
|
|
<label for="Name" class="control-label">Name: </label>
|
|
</td>
|
|
<td>
|
|
<input class="form-control" @bind="@name" readonly />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label for="Name" class="control-label">Description: </label>
|
|
</td>
|
|
<td>
|
|
<textarea class="form-control" @bind="@description" rows="5" readonly />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label for="Name" class="control-label">Auto Assigned? </label>
|
|
</td>
|
|
<td>
|
|
<select class="form-control" @bind="@isautoassigned" readonly>
|
|
<option value="True">Yes</option>
|
|
<option value="False">No</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label for="Name" class="control-label">System Role? </label>
|
|
</td>
|
|
<td>
|
|
<select class="form-control" @bind="@issystem" readonly>
|
|
<option value="True">Yes</option>
|
|
<option value="False">No</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<button type="button" class="btn btn-success" @onclick="DeleteRole">Delete</button>
|
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
|
|
|
@code {
|
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
|
|
|
int roleid;
|
|
string name = "";
|
|
string description = "";
|
|
string isautoassigned = "False";
|
|
string issystem = "False";
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
try
|
|
{
|
|
roleid = Int32.Parse(PageState.QueryString["id"]);
|
|
Role role = await RoleService.GetRoleAsync(roleid);
|
|
if (role != null)
|
|
{
|
|
name = role.Name;
|
|
description = role.Description;
|
|
isautoassigned = role.IsAutoAssigned.ToString();
|
|
issystem = role.IsSystem.ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await logger.LogError(ex, "Error Loading Role {RoleId} {Error}", roleid, ex.Message);
|
|
AddModuleMessage("Error Loading Role", MessageType.Error);
|
|
}
|
|
}
|
|
|
|
private async Task DeleteRole()
|
|
{
|
|
try
|
|
{
|
|
await RoleService.DeleteRoleAsync(roleid);
|
|
await logger.LogInformation("Role Deleted {RoleId}", roleid);
|
|
NavigationManager.NavigateTo(NavigateUrl());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await logger.LogError(ex, "Error Deleting Role {RoleId} {Error}", roleid, ex.Message);
|
|
AddModuleMessage("Error Deleting Role", MessageType.Error);
|
|
}
|
|
}
|
|
|
|
}
|