Management UI for roles, users, tenants
This commit is contained in:
parent
7f6f9427e9
commit
4de8572a87
|
@ -8,26 +8,22 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
<ActionLink Action="Add" Text="Install Module" />
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Name</th>
|
||||
<th>Version</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var moduledefinition in moduledefinitions)
|
||||
{
|
||||
<tr>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + moduledefinition.ModuleDefinitionId.ToString())" /></td>
|
||||
<td>@moduledefinition.Name</td>
|
||||
<td>@moduledefinition.Version</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<ActionLink Action="Add" Text="Install Module" Style="float: right; margin: 10px;" />
|
||||
|
||||
<Pager Items="@moduledefinitions">
|
||||
<Header>
|
||||
<th>Name</th>
|
||||
<th>Version</th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
</Header>
|
||||
<Row>
|
||||
<td>@context.Name</td>
|
||||
<td>@context.Version</td>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ModuleDefinitionId.ToString())" /></td>
|
||||
<td><ActionLink Action="Delete" Parameters="@($"id=" + context.ModuleDefinitionId.ToString())" Class="btn btn-danger" /></td>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
||||
|
||||
@code {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<Row>
|
||||
<td>@(new string('-', context.Level * 2))@(context.Name)</td>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.PageId.ToString())" /></td>
|
||||
<td><ActionLink Action="Delete" Parameters="@($"id=" +context.PageId.ToString())" Class="btn btn-danger" /></td>
|
||||
<td><ActionLink Action="Delete" Parameters="@($"id=" + context.PageId.ToString())" Class="btn btn-danger" /></td>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
||||
|
|
|
@ -24,6 +24,14 @@
|
|||
<input class="form-control" @bind="@email" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Password: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" class="form-control" @bind="@password" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@foreach (Profile profile in profiles)
|
||||
{
|
||||
|
@ -58,6 +66,7 @@
|
|||
|
||||
string displayname = "";
|
||||
string email = "";
|
||||
string password = "";
|
||||
List<Profile> profiles;
|
||||
Dictionary<string, string> settings;
|
||||
string category = "";
|
||||
|
@ -96,6 +105,7 @@
|
|||
User user = PageState.User;
|
||||
user.DisplayName = displayname;
|
||||
user.Email = email;
|
||||
user.Password = password;
|
||||
await UserService.UpdateUserAsync(user);
|
||||
await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId);
|
||||
|
||||
|
|
77
Oqtane.Client/Modules/Admin/Roles/Add.razor
Normal file
77
Oqtane.Client/Modules/Admin/Roles/Add.razor
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
91
Oqtane.Client/Modules/Admin/Roles/Delete.razor
Normal file
91
Oqtane.Client/Modules/Admin/Roles/Delete.razor
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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> </th>
|
||||
<th> </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 {
|
||||
|
|
|
@ -9,22 +9,20 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var site in sites)
|
||||
{
|
||||
<tr>
|
||||
<td>@site.Name</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<ActionLink Action="Add" Text="Add Site" />
|
||||
<ActionLink Action="Add" Text="Add Site" Style="float: right; margin: 10px;" />
|
||||
|
||||
<Pager Items="@sites">
|
||||
<Header>
|
||||
<th>Name</th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
</Header>
|
||||
<Row>
|
||||
<td>@context.Name</td>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.SiteId.ToString())" /></td>
|
||||
<td><ActionLink Action="Delete" Parameters="@($"id=" + context.SiteId.ToString())" Class="btn btn-danger" /></td>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
||||
|
||||
@code {
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject ITenantService TenantService
|
||||
@inject IAliasService AliasService
|
||||
@inject ISiteService SiteService
|
||||
@inject IPageService PageService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
|
|
70
Oqtane.Client/Modules/Admin/Tenants/Delete.razor
Normal file
70
Oqtane.Client/Modules/Admin/Tenants/Delete.razor
Normal file
|
@ -0,0 +1,70 @@
|
|||
@namespace Oqtane.Modules.Admin.Tenants
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject ITenantService TenantService
|
||||
|
||||
<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">Connection String: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@connectionstring" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Schema: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@schema" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="DeleteTenant">Delete</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
int tenantid;
|
||||
string name = "";
|
||||
string connectionstring = "";
|
||||
string schema = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
tenantid = Int32.Parse(PageState.QueryString["id"]);
|
||||
Tenant tenant = await TenantService.GetTenantAsync(tenantid);
|
||||
if (tenant != null)
|
||||
{
|
||||
name = tenant.Name;
|
||||
connectionstring = tenant.DBConnectionString;
|
||||
schema = tenant.DBSchema;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
private async Task DeleteTenant()
|
||||
{
|
||||
Tenant tenant = await TenantService.GetTenantAsync(tenantid);
|
||||
if (tenant != null)
|
||||
{
|
||||
await TenantService.DeleteTenantAsync(tenantid);
|
||||
}
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
}
|
73
Oqtane.Client/Modules/Admin/Tenants/Edit.razor
Normal file
73
Oqtane.Client/Modules/Admin/Tenants/Edit.razor
Normal file
|
@ -0,0 +1,73 @@
|
|||
@namespace Oqtane.Modules.Admin.Tenants
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject ITenantService TenantService
|
||||
|
||||
<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">Connection String: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@connectionstring" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Schema: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@schema" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="SaveTenant">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
int tenantid;
|
||||
string name = "";
|
||||
string connectionstring = "";
|
||||
string schema = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
tenantid = Int32.Parse(PageState.QueryString["id"]);
|
||||
Tenant tenant = await TenantService.GetTenantAsync(tenantid);
|
||||
if (tenant != null)
|
||||
{
|
||||
name = tenant.Name;
|
||||
connectionstring = tenant.DBConnectionString;
|
||||
schema = tenant.DBSchema;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
private async Task SaveTenant()
|
||||
{
|
||||
Tenant tenant = await TenantService.GetTenantAsync(tenantid);
|
||||
if (tenant != null)
|
||||
{
|
||||
tenant.Name = name;
|
||||
tenant.DBConnectionString = connectionstring;
|
||||
tenant.DBSchema = schema;
|
||||
await TenantService.UpdateTenantAsync(tenant);
|
||||
}
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
}
|
|
@ -2,37 +2,36 @@
|
|||
@inherits ModuleBase
|
||||
@inject ITenantService TenantService
|
||||
|
||||
@if (Tenants == null)
|
||||
@if (tenants == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ActionLink Action="Add" Text="Add Tenant" />
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var Tenant in Tenants)
|
||||
{
|
||||
<tr>
|
||||
<td>@Tenant.Name</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<ActionLink Action="Add" Text="Add Tenant" Style="float: right; margin: 10px;" />
|
||||
|
||||
<Pager Items="@tenants">
|
||||
<Header>
|
||||
<th>Name</th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
</Header>
|
||||
<Row>
|
||||
<td>@context.Name</td>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.TenantId.ToString())" /></td>
|
||||
<td><ActionLink Action="Delete" Parameters="@($"id=" + context.TenantId.ToString())" Class="btn btn-danger" /></td>
|
||||
</Row>
|
||||
</Pager>
|
||||
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
List<Tenant> Tenants;
|
||||
List<Tenant> tenants;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Tenants = await TenantService.GetTenantsAsync();
|
||||
tenants = await TenantService.GetTenantsAsync();
|
||||
}
|
||||
}
|
|
@ -2,37 +2,33 @@
|
|||
@inherits ModuleBase
|
||||
@inject IThemeService ThemeService
|
||||
|
||||
@if (Themes == null)
|
||||
@if (themes == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ActionLink Action="Add" Text="Install Theme" />
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var theme in Themes)
|
||||
{
|
||||
<tr>
|
||||
<td>@theme.Name</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<ActionLink Action="Add" Text="Install Theme" Style="float: right; margin: 10px;" />
|
||||
|
||||
<Pager Items="@themes">
|
||||
<Header>
|
||||
<th>Name</th>
|
||||
<th>Version</th>
|
||||
</Header>
|
||||
<Row>
|
||||
<td>@context.Name</td>
|
||||
<td>@context.Version</td>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
List<Theme> Themes;
|
||||
List<Theme> themes;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Themes = await ThemeService.GetThemesAsync();
|
||||
themes = await ThemeService.GetThemesAsync();
|
||||
}
|
||||
}
|
110
Oqtane.Client/Modules/Admin/Users/Add.razor
Normal file
110
Oqtane.Client/Modules/Admin/Users/Add.razor
Normal file
|
@ -0,0 +1,110 @@
|
|||
@namespace Oqtane.Modules.Admin.Users
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IUserService UserService
|
||||
@inject IProfileService ProfileService
|
||||
@inject ISettingService SettingService
|
||||
|
||||
@if (profiles != null)
|
||||
{
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@displayname" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Email: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@email" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Password: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" class="form-control" @bind="@password" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@foreach (Profile profile in profiles)
|
||||
{
|
||||
var p = profile;
|
||||
if (p.Category != category)
|
||||
{
|
||||
<tr>
|
||||
<th colspan="2" style="text-align: center;">
|
||||
@p.Category
|
||||
</th>
|
||||
</tr>
|
||||
category = p.Category;
|
||||
}
|
||||
<tr>
|
||||
<td>
|
||||
<label for="@p.Name" class="control-label">@p.Title: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" maxlength="@p.MaxLength" placeholder="@p.Description" @onchange="(e => ProfileChanged(e, p.Name))" />
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
<button type="button" class="btn btn-primary" @onclick="SaveUser">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
string displayname = "";
|
||||
string email = "";
|
||||
string password = "";
|
||||
List<Profile> profiles;
|
||||
Dictionary<string, string> settings;
|
||||
string category = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
profiles = await ProfileService.GetProfilesAsync(ModuleState.SiteId);
|
||||
settings = new Dictionary<string, string>();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
User user = new User();
|
||||
user.DisplayName = displayname;
|
||||
user.Email = email;
|
||||
user.Password = password;
|
||||
user = await UserService.AddUserAsync(user);
|
||||
await SettingService.UpdateUserSettingsAsync(settings, user.UserId);
|
||||
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProfileChanged(ChangeEventArgs e, string SettingName)
|
||||
{
|
||||
string value = (string)e.Value;
|
||||
settings = SettingService.SetSetting(settings, SettingName, value);
|
||||
}
|
||||
|
||||
}
|
108
Oqtane.Client/Modules/Admin/Users/Delete.razor
Normal file
108
Oqtane.Client/Modules/Admin/Users/Delete.razor
Normal file
|
@ -0,0 +1,108 @@
|
|||
@namespace Oqtane.Modules.Admin.Users
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IUserService UserService
|
||||
@inject IProfileService ProfileService
|
||||
@inject ISettingService SettingService
|
||||
|
||||
@if (profiles != null)
|
||||
{
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@displayname" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Email: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@email" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@foreach (Profile profile in profiles)
|
||||
{
|
||||
var p = profile;
|
||||
if (p.Category != category)
|
||||
{
|
||||
<tr>
|
||||
<th colspan="2" style="text-align: center;">
|
||||
@p.Category
|
||||
</th>
|
||||
</tr>
|
||||
category = p.Category;
|
||||
}
|
||||
<tr>
|
||||
<td>
|
||||
<label for="@p.Name" class="control-label">@p.Title: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
<button type="button" class="btn btn-primary" @onclick="DeleteUser">Delete</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
int userid;
|
||||
string displayname = "";
|
||||
string email = "";
|
||||
List<Profile> profiles;
|
||||
Dictionary<string, string> settings;
|
||||
string category = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
|
||||
|
||||
userid = Int32.Parse(PageState.QueryString["id"]);
|
||||
User user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
||||
if (user != null)
|
||||
{
|
||||
displayname = user.DisplayName;
|
||||
email = user.Email;
|
||||
settings = await SettingService.GetUserSettingsAsync(user.UserId);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetProfileValue(string SettingName, string DefaultValue)
|
||||
{
|
||||
return SettingService.GetSetting(settings, SettingName, DefaultValue);
|
||||
}
|
||||
|
||||
private async Task DeleteUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
User user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
||||
if (user != null)
|
||||
{
|
||||
await UserService.DeleteUserAsync(userid);
|
||||
}
|
||||
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
124
Oqtane.Client/Modules/Admin/Users/Edit.razor
Normal file
124
Oqtane.Client/Modules/Admin/Users/Edit.razor
Normal file
|
@ -0,0 +1,124 @@
|
|||
@namespace Oqtane.Modules.Admin.Users
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IUserService UserService
|
||||
@inject IProfileService ProfileService
|
||||
@inject ISettingService SettingService
|
||||
|
||||
@if (profiles != null)
|
||||
{
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@displayname" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Email: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@email" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Password: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" class="form-control" @bind="@password" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@foreach (Profile profile in profiles)
|
||||
{
|
||||
var p = profile;
|
||||
if (p.Category != category)
|
||||
{
|
||||
<tr>
|
||||
<th colspan="2" style="text-align: center;">
|
||||
@p.Category
|
||||
</th>
|
||||
</tr>
|
||||
category = p.Category;
|
||||
}
|
||||
<tr>
|
||||
<td>
|
||||
<label for="@p.Name" class="control-label">@p.Title: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" placeholder="@p.Description" @onchange="(e => ProfileChanged(e, p.Name))" />
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
<button type="button" class="btn btn-primary" @onclick="SaveUser">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
int userid;
|
||||
string displayname = "";
|
||||
string email = "";
|
||||
string password = "";
|
||||
List<Profile> profiles;
|
||||
Dictionary<string, string> settings;
|
||||
string category = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
|
||||
|
||||
userid = Int32.Parse(PageState.QueryString["id"]);
|
||||
User user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
||||
if (user != null)
|
||||
{
|
||||
displayname = user.DisplayName;
|
||||
email = user.Email;
|
||||
settings = await SettingService.GetUserSettingsAsync(user.UserId);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetProfileValue(string SettingName, string DefaultValue)
|
||||
{
|
||||
return SettingService.GetSetting(settings, SettingName, DefaultValue);
|
||||
}
|
||||
|
||||
private async Task SaveUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
User user = new User();
|
||||
user.DisplayName = displayname;
|
||||
user.Email = email;
|
||||
user.Password = password;
|
||||
user = await UserService.UpdateUserAsync(user);
|
||||
await SettingService.UpdateUserSettingsAsync(settings, user.UserId);
|
||||
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProfileChanged(ChangeEventArgs e, string SettingName)
|
||||
{
|
||||
string value = (string)e.Value;
|
||||
settings = SettingService.SetSetting(settings, SettingName, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -8,21 +8,20 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (UserRole userrole in userroles)
|
||||
{
|
||||
<tr>
|
||||
<td>@userrole.User.Username</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<ActionLink Action="Add" Text="Add User" Style="float: right; margin: 10px;" />
|
||||
|
||||
<Pager Items="@userroles">
|
||||
<Header>
|
||||
<th>Name</th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
</Header>
|
||||
<Row>
|
||||
<td>@context.User.DisplayName</td>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.UserId.ToString())" /></td>
|
||||
<td><ActionLink Action="Delete" Parameters="@($"id=" + context.UserId.ToString())" Class="btn btn-danger" /></td>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
||||
|
||||
@code {
|
||||
|
|
|
@ -82,6 +82,11 @@
|
|||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
authorized = true; // occurs when an action does not have a corresponding module control
|
||||
classname = "btn btn-warning"; // alert developer of missing module comtrol
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,28 +14,31 @@
|
|||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="pagination">
|
||||
<div>
|
||||
@if (Page > MaxPages)
|
||||
{
|
||||
<button class="btn btn-secondary" @onclick=@(async () => SetPagerSize("back"))><span class="oi oi-media-skip-backward" title="back" aria-hidden="true"></span></button>
|
||||
}
|
||||
<button class="btn btn-secondary" @onclick=@(async () => NavigateToPage("previous"))><span class="oi oi-chevron-left" title="previous" aria-hidden="true"></span></button>
|
||||
|
||||
@for (int i = StartPage; i <= EndPage; i++)
|
||||
@if (EndPage > 1)
|
||||
{
|
||||
var pager = i;
|
||||
<button class="btn @((pager == Page) ? "btn-primary" : "btn-link")" @onclick=@(async () => UpdateList(pager))>
|
||||
@pager
|
||||
</button>
|
||||
<button class="btn btn-secondary" @onclick=@(async () => NavigateToPage("previous"))><span class="oi oi-chevron-left" title="previous" aria-hidden="true"></span></button>
|
||||
@for (int i = StartPage; i <= EndPage; i++)
|
||||
{
|
||||
var pager = i;
|
||||
<button class="btn @((pager == Page) ? "btn-primary" : "btn-link")" @onclick=@(async () => UpdateList(pager))>
|
||||
@pager
|
||||
</button>
|
||||
}
|
||||
<button class="btn btn-secondary" @onclick=@(async () => NavigateToPage("next"))><span class="oi oi-chevron-right" title="next" aria-hidden="true"></span></button>
|
||||
}
|
||||
|
||||
<button class="btn btn-secondary" @onclick=@(async () => NavigateToPage("next"))><span class="oi oi-chevron-right" title="next" aria-hidden="true"></span></button>
|
||||
@if (EndPage < Pages)
|
||||
{
|
||||
<button class="btn btn-secondary" @onclick=@(async () => SetPagerSize("forward"))><span class="oi oi-media-skip-forward" title="forward" aria-hidden="true"></span></button>
|
||||
}
|
||||
|
||||
<span class="btn btn-link disabled">Page @Page of @Pages</span>
|
||||
@if (EndPage > 1)
|
||||
{
|
||||
<span class="btn btn-link disabled">Page @Page of @Pages</span>
|
||||
}
|
||||
</div>
|
||||
</p>
|
||||
|
||||
|
|
|
@ -8,8 +8,12 @@ namespace Oqtane.Services
|
|||
{
|
||||
Task<List<Tenant>> GetTenantsAsync();
|
||||
|
||||
Task<Tenant> GetTenantAsync();
|
||||
Task<Tenant> GetTenantAsync(int TenantId);
|
||||
|
||||
Task<Tenant> AddTenantAsync(Tenant Tenant);
|
||||
|
||||
Task<Tenant> UpdateTenantAsync(Tenant Tenant);
|
||||
|
||||
Task DeleteTenantAsync(int TenantId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ namespace Oqtane.Services
|
|||
{
|
||||
return await http.PutJsonAsync<Site>(apiurl + "/" + Site.SiteId.ToString(), Site);
|
||||
}
|
||||
|
||||
public async Task DeleteSiteAsync(int SiteId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + SiteId.ToString());
|
||||
|
|
|
@ -32,14 +32,24 @@ namespace Oqtane.Services
|
|||
return tenants.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Tenant> GetTenantAsync()
|
||||
public async Task<Tenant> GetTenantAsync(int TenantId)
|
||||
{
|
||||
return await http.GetJsonAsync<Tenant>(apiurl);
|
||||
return await http.GetJsonAsync<Tenant>(apiurl + "/" + TenantId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Tenant> AddTenantAsync(Tenant Tenant)
|
||||
{
|
||||
return await http.PostJsonAsync<Tenant>(apiurl, Tenant);
|
||||
}
|
||||
|
||||
public async Task<Tenant> UpdateTenantAsync(Tenant Tenant)
|
||||
{
|
||||
return await http.PutJsonAsync<Tenant>(apiurl + "/" + Tenant.TenantId.ToString(), Tenant);
|
||||
}
|
||||
|
||||
public async Task DeleteTenantAsync(int TenantId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + TenantId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,10 +136,19 @@ namespace Oqtane.Controllers
|
|||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize]
|
||||
public User Put(int id, [FromBody] User User)
|
||||
public async Task<User> Put(int id, [FromBody] User User)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (User.Password != "")
|
||||
{
|
||||
IdentityUser identityuser = await IdentityUserManager.FindByNameAsync(User.Username);
|
||||
if (identityuser != null)
|
||||
{
|
||||
identityuser.PasswordHash = IdentityUserManager.PasswordHasher.HashPassword(identityuser, User.Password);
|
||||
await IdentityUserManager.UpdateAsync(identityuser);
|
||||
}
|
||||
}
|
||||
User = Users.UpdateUser(User);
|
||||
}
|
||||
return User;
|
||||
|
|
Loading…
Reference in New Issue
Block a user