Dynamic user profile per tenant
This commit is contained in:
@ -12,7 +12,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
|
@ -11,7 +11,8 @@
|
||||
@inject IModuleService ModuleService
|
||||
@inject IPageModuleService PageModuleService
|
||||
|
||||
<table class="form-group">
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Title" class="control-label">Title: </label>
|
||||
@ -20,6 +21,8 @@
|
||||
<input type="text" name="Title" class="form-control" @bind="@title" />
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Container" class="control-label">Container: </label>
|
||||
@ -55,7 +58,8 @@
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@DynamicComponent
|
||||
|
||||
|
@ -11,7 +11,8 @@
|
||||
@inject IThemeService ThemeService
|
||||
|
||||
<ModuleMessage Message="@message" />
|
||||
<table class="form-group">
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
<ModuleMessage Message="@message" />
|
||||
|
||||
<table class="form-group">
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
<ModuleMessage Message="@message" />
|
||||
|
||||
<table class="form-group">
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
|
@ -12,7 +12,7 @@
|
||||
else
|
||||
{
|
||||
<ActionLink Action="Add" Text="Add Page" Style="float: right; margin: 10px;" />
|
||||
<table class="table">
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
|
116
Oqtane.Client/Modules/Admin/Profile/Index.razor
Normal file
116
Oqtane.Client/Modules/Admin/Profile/Index.razor
Normal file
@ -0,0 +1,116 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Services
|
||||
@inherits ModuleBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject IUserService UserService
|
||||
@inject IProfileService ProfileService
|
||||
@inject ISettingService SettingService
|
||||
|
||||
<ModuleMessage Message="@message" />
|
||||
|
||||
@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>
|
||||
|
||||
@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)" @onchange="@(e => ProfileChanged(e, p.Name))" />
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
<button type="button" class="btn btn-primary" @onclick="@SaveUser">Save</button>
|
||||
<button type="button" class="btn btn-secondary" @onclick="@Cancel">Cancel</button>
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.View; } }
|
||||
|
||||
string message = "";
|
||||
string displayname = "";
|
||||
string email = "";
|
||||
List<Profile> profiles;
|
||||
List<Setting> settings;
|
||||
string category = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
displayname = PageState.User.DisplayName;
|
||||
email = PageState.User.Email;
|
||||
profiles = await ProfileService.GetProfilesAsync(ModuleState.SiteId);
|
||||
settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetProfileValue(string SettingName, string DefaultValue)
|
||||
{
|
||||
return SettingService.GetSetting(settings, SettingName, DefaultValue);
|
||||
}
|
||||
|
||||
private async Task SaveUser()
|
||||
{
|
||||
User user = PageState.User;
|
||||
user.DisplayName = displayname;
|
||||
user.Email = email;
|
||||
await UserService.UpdateUserAsync(user);
|
||||
|
||||
foreach (Profile profile in profiles)
|
||||
{
|
||||
string value = SettingService.GetSetting(settings, profile.Name, "");
|
||||
await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId, profile.Name, value);
|
||||
}
|
||||
|
||||
UriHelper.NavigateTo("");
|
||||
}
|
||||
|
||||
private void Cancel()
|
||||
{
|
||||
UriHelper.NavigateTo(NavigateUrl("")); // navigate to home
|
||||
}
|
||||
|
||||
private void ProfileChanged(UIChangeEventArgs e, string SettingName)
|
||||
{
|
||||
string value = (string)e.Value;
|
||||
settings = SettingService.SetSetting(settings, "User", PageState.User.UserId, SettingName, value);
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
|
@ -17,7 +17,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="form-group">
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Tenant: </label>
|
||||
|
@ -12,7 +12,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
|
@ -11,7 +11,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
|
@ -10,73 +10,71 @@
|
||||
@if (roles != null)
|
||||
{
|
||||
<br />
|
||||
<div class="container">
|
||||
<div class="form-group">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Role</th>
|
||||
@foreach (PermissionString permission in permissions)
|
||||
{
|
||||
<th style="text-align: center;">@permission.PermissionName @EntityName</th>
|
||||
}
|
||||
</tr>
|
||||
@foreach (Role role in roles)
|
||||
{
|
||||
<tr>
|
||||
<td>@role.Name</td>
|
||||
@foreach (PermissionString permission in permissions)
|
||||
{
|
||||
var p = permission;
|
||||
<td style="text-align: center;">
|
||||
<TriStateCheckBox Value=@GetPermissionValue(p.Permissions, role.Name) Disabled=@GetPermissionDisabled(role.Name) OnChange="@(e => PermissionChanged(e, p.PermissionName, role.Name))" />
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
@if (@users.Count != 0)
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
@foreach (PermissionString permission in permissions)
|
||||
{
|
||||
<th style="text-align: center;">@permission.PermissionName @EntityName</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (User user in users)
|
||||
{
|
||||
string userid = "[" + user.UserId.ToString() + "]";
|
||||
<tr>
|
||||
<th>Role</th>
|
||||
<td>@user.DisplayName</td>
|
||||
@foreach (PermissionString permission in permissions)
|
||||
{
|
||||
<th>@permission.PermissionName @EntityName</th>
|
||||
var p = permission;
|
||||
<td style="text-align: center;">
|
||||
<TriStateCheckBox Value=@GetPermissionValue(p.Permissions, userid) Disabled=@GetPermissionDisabled(userid) OnChange="@(e => PermissionChanged(e, p.PermissionName, userid))" />
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
@foreach (Role role in roles)
|
||||
{
|
||||
<tr>
|
||||
<td>@role.Name</td>
|
||||
@foreach (PermissionString permission in permissions)
|
||||
{
|
||||
var p = permission;
|
||||
<td align="center">
|
||||
<TriStateCheckBox Value=@GetPermissionValue(p.Permissions, role.Name) Disabled=@GetPermissionDisabled(role.Name) OnChange="@(e => PermissionChanged(e, p.PermissionName, role.Name))" />
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@if (@users.Count != 0)
|
||||
{
|
||||
<div class="form-group">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
@foreach (PermissionString permission in permissions)
|
||||
{
|
||||
<th>@permission.PermissionName @EntityName</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (User user in users)
|
||||
{
|
||||
string userid = "[" + user.UserId.ToString() + "]";
|
||||
<tr>
|
||||
<td>@user.DisplayName</td>
|
||||
@foreach (PermissionString permission in permissions)
|
||||
{
|
||||
var p = permission;
|
||||
<td align="center">
|
||||
<TriStateCheckBox Value=@GetPermissionValue(p.Permissions, userid) Disabled=@GetPermissionDisabled(userid) OnChange="@(e => PermissionChanged(e, p.PermissionName, userid))" />
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
<div style="white-space:nowrap;">
|
||||
<label for="Username" class="control-label" style="display:inline-block;">User: </label>
|
||||
<input type="text" name="Username" class="form-control" style="display:inline-block; width: auto !important;" placeholder="Enter Username" @bind="@username" />
|
||||
<button type="button" class="btn btn-primary" style="display:inline-block;" @onclick="@AddUser">Add</button>
|
||||
</div>
|
||||
<br />
|
||||
<ModuleMessage Type="MessageType.Error" Message="@message" />
|
||||
</div>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><label for="Username" class="control-label">User: </label></td>
|
||||
<td><input type="text" name="Username" class="form-control" placeholder="Enter Username" @bind="@username" /></td>
|
||||
<td><button type="button" class="btn btn-primary" @onclick="@AddUser">Add</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br />
|
||||
<ModuleMessage Type="MessageType.Error" Message="@message" />
|
||||
}
|
||||
|
||||
@code {
|
||||
|
Reference in New Issue
Block a user