Management UI for roles, users, tenants
This commit is contained in:
99
Oqtane.Client/Modules/Admin/Roles/Edit.razor
Normal file
99
Oqtane.Client/Modules/Admin/Roles/Edit.razor
Normal file
@ -0,0 +1,99 @@
|
||||
@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" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Description: </label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea class="form-control" @bind="@description" rows="5" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Auto Assigned: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isautoassigned">
|
||||
<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">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="SaveRole">Save</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)
|
||||
{
|
||||
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveRole()
|
||||
{
|
||||
try
|
||||
{
|
||||
Role role = await RoleService.GetRoleAsync(roleid);
|
||||
if (role != null)
|
||||
{
|
||||
role.Name = name;
|
||||
role.Description = description;
|
||||
role.IsAutoAssigned = (isautoassigned == null ? false : Boolean.Parse(isautoassigned));
|
||||
role.IsSystem = (issystem == null ? false : Boolean.Parse(issystem));
|
||||
await RoleService.UpdateRoleAsync(role);
|
||||
}
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user