Management UI for roles, users, tenants

This commit is contained in:
Shaun Walker
2019-09-30 23:50:10 -04:00
parent 7f6f9427e9
commit 4de8572a87
23 changed files with 902 additions and 124 deletions

View File

@ -0,0 +1,77 @@
@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; } }
string name = "";
string description = "";
string isautoassigned = "False";
string issystem = "False";
private async Task SaveRole()
{
try
{
Role role = new Role();
role.SiteId = PageState.Page.SiteId;
role.Name = name;
role.Description = description;
role.IsAutoAssigned = (isautoassigned == null ? false : Boolean.Parse(isautoassigned));
role.IsSystem = (issystem == null ? false : Boolean.Parse(issystem));
await RoleService.AddRoleAsync(role);
NavigationManager.NavigateTo(NavigateUrl());
}
catch (Exception ex)
{
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
}
}
}

View File

@ -0,0 +1,91 @@
@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)
{
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
}
}
private async Task DeleteRole()
{
try
{
await RoleService.DeleteRoleAsync(roleid);
NavigationManager.NavigateTo(NavigateUrl());
}
catch (Exception ex)
{
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
}
}
}

View 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);
}
}
}

View File

@ -8,21 +8,20 @@
}
else
{
<table class="table table-borderless">
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
@foreach (var Role in Roles)
{
<tr>
<td>@Role.Name</td>
</tr>
}
</tbody>
</table>
<ActionLink Action="Add" Text="Add Role" Style="float: right; margin: 10px;" />
<Pager Items="@Roles">
<Header>
<th>Name</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
</Header>
<Row>
<td>@context.Name</td>
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.RoleId.ToString())" /></td>
<td><ActionLink Action="Delete" Parameters="@($"id=" + context.RoleId.ToString())" Class="btn btn-danger" /></td>
</Row>
</Pager>
}
@code {