Merge pull request #893 from hishamco/localize-users-pages

Localize Users Pages
This commit is contained in:
Shaun Walker 2020-11-19 15:32:55 -05:00 committed by GitHub
commit e25146cd68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 105 additions and 100 deletions

View File

@ -1,26 +1,27 @@
@namespace Oqtane.Modules.Admin.Users
@namespace Oqtane.Modules.Admin.Users
@inherits ModuleBase
@inject NavigationManager NavigationManager
@inject IUserService UserService
@inject IProfileService ProfileService
@inject ISettingService SettingService
@inject IStringLocalizer<Add> Localizer
<TabStrip>
<TabPanel Name="Identity">
<TabPanel Name="Identity" ResourceKey="Identity">
@if (profiles != null)
{
<table class="table table-borderless">
<tr>
<td>
<label class="control-label">Username: </label>
</td>
<label class="control-label">@Localizer["Username:"] </label>
</td>
<td>
<input class="form-control" @bind="@username" />
</td>
</tr>
<tr>
<td>
<label class="control-label">Password: </label>
<label class="control-label">@Localizer["Password:"] </label>
</td>
<td>
<input type="password" class="form-control" @bind="@password" />
@ -28,7 +29,7 @@
</tr>
<tr>
<td>
<label class="control-label">Confirm Password: </label>
<label class="control-label">@Localizer["Confirm Password:"] </label>
</td>
<td>
<input type="password" class="form-control" @bind="@confirm" />
@ -36,7 +37,7 @@
</tr>
<tr>
<td>
<label class="control-label">Email: </label>
<label class="control-label">@Localizer["Email:"] </label>
</td>
<td>
<input class="form-control" @bind="@email" />
@ -44,7 +45,7 @@
</tr>
<tr>
<td>
<label class="control-label">Full Name: </label>
<label class="control-label">@Localizer["Full Name:"] </label>
</td>
<td>
<input class="form-control" @bind="@displayname" />
@ -53,45 +54,45 @@
</table>
}
</TabPanel>
<TabPanel Name="Profile">
<TabPanel Name="Profile" ResourceKey="Profile">
@if (profiles != null)
{
<table class="table table-borderless">
@foreach (Profile profile in profiles)
{
var p = profile;
if (p.Category != category)
<table class="table table-borderless">
@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>
<th colspan="2" style="text-align: center;">
@p.Category
</th>
<td>
<Label For="@p.Name" HelpText="@p.Description">@p.Title</Label>
</td>
<td>
@if (p.IsRequired)
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" required @onchange="@(e => ProfileChanged(e, p.Name))" />
}
else
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
}
</td>
</tr>
category = p.Category;
}
<tr>
<td>
<Label For="@p.Name" HelpText="@p.Description">@p.Title</Label>
</td>
<td>
@if (p.IsRequired)
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" required @onchange="@(e => ProfileChanged(e, p.Name))" />
}
else
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
}
</td>
</tr>
}
</table>
</table>
}
</TabPanel>
</TabStrip>
<button type="button" class="btn btn-primary" @onclick="SaveUser">Save</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
<button type="button" class="btn btn-primary" @onclick="SaveUser">@Localizer["Save"]</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
@code {
private string username = string.Empty;
@ -185,7 +186,7 @@
}
return valid;
}
private void ProfileChanged(ChangeEventArgs e, string SettingName)
{
var value = (string)e.Value;

View File

@ -1,9 +1,10 @@
@namespace Oqtane.Modules.Admin.Users
@namespace Oqtane.Modules.Admin.Users
@inherits ModuleBase
@inject NavigationManager NavigationManager
@inject IUserService UserService
@inject IProfileService ProfileService
@inject ISettingService SettingService
@inject IStringLocalizer<Edit> Localizer
@if (PageState.User != null && photofileid != -1)
{
@ -14,13 +15,13 @@ else
<br />
}
<TabStrip>
<TabPanel Name="Identity">
<TabPanel Name="Identity" ResourceKey="Identity">
@if (profiles != null)
{
<table class="table table-borderless">
<tr>
<td>
<label class="control-label">Username: </label>
<label class="control-label">@Localizer["Username:"] </label>
</td>
<td>
<input class="form-control" @bind="@username" readonly />
@ -28,7 +29,7 @@ else
</tr>
<tr>
<td>
<label class="control-label">Password: </label>
<label class="control-label">@Localizer["Password:"] </label>
</td>
<td>
<input type="password" class="form-control" @bind="@password" />
@ -36,7 +37,7 @@ else
</tr>
<tr>
<td>
<label class="control-label">Confirm Password: </label>
<label class="control-label">@Localizer["Confirm Password:"] </label>
</td>
<td>
<input type="password" class="form-control" @bind="@confirm" />
@ -44,7 +45,7 @@ else
</tr>
<tr>
<td>
<label class="control-label">Email: </label>
<label class="control-label">@Localizer["Email:"] </label>
</td>
<td>
<input class="form-control" @bind="@email" />
@ -52,7 +53,7 @@ else
</tr>
<tr>
<td>
<label class="control-label">Full Name: </label>
<label class="control-label">@Localizer["Full Name:"] </label>
</td>
<td>
<input class="form-control" @bind="@displayname" />
@ -60,7 +61,7 @@ else
</tr>
<tr>
<td>
<label class="control-label">Photo: </label>
<label class="control-label">@Localizer["Photo:"] </label>
</td>
<td>
<FileManager FileId="@photofileid" @ref="filemanager" />
@ -68,58 +69,59 @@ else
</tr>
<tr>
<td>
<label class="control-label">Is Deleted? </label>
<label class="control-label">@Localizer["Is Deleted?"] </label>
</td>
<td>
<select class="form-control" @bind="@isdeleted">
<option value="True">Yes</option>
<option value="False">No</option>
<option value="True">@Localizer["Yes"]</option>
<option value="False">@Localizer["No"]</option>
</select>
</td>
</tr>
</table>
}
</TabPanel>
<TabPanel Name="Profile">
<TabPanel Name="Profile" ResourceKey="Profile">
@if (profiles != null)
{
<table class="table table-borderless">
@foreach (Profile profile in profiles)
{
var p = profile;
if (p.Category != category)
<table class="table table-borderless">
@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>
<th colspan="2" style="text-align: center;">
@p.Category
</th>
<td>
<Label For="@p.Name" HelpText="@p.Description">@p.Title</Label>
</td>
<td>
@if (p.IsRequired)
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" required @onchange="@(e => ProfileChanged(e, p.Name))" />
}
else
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
}
</td>
</tr>
category = p.Category;
}
<tr>
<td>
<Label For="@p.Name" HelpText="@p.Description">@p.Title</Label>
</td>
<td>
@if (p.IsRequired)
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" required @onchange="@(e => ProfileChanged(e, p.Name))" />
}
else
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
}
</td>
</tr>
}
</table>
</table>
}
</TabPanel>
</TabStrip>
<button type="button" class="btn btn-primary" @onclick="SaveUser">Save</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
<br /><br />
<button type="button" class="btn btn-primary" @onclick="SaveUser">@Localizer["Save"]</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
<br />
<br />
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon" DeletedBy="@deletedby" DeletedOn="@deletedon"></AuditInfo>
@code {
@ -246,7 +248,7 @@ else
}
return valid;
}
private void ProfileChanged(ChangeEventArgs e, string SettingName)
{
var value = (string)e.Value;

View File

@ -1,21 +1,22 @@
@namespace Oqtane.Modules.Admin.Users
@namespace Oqtane.Modules.Admin.Users
@inherits ModuleBase
@inject IUserRoleService UserRoleService
@inject IUserService UserService
@inject ISettingService SettingService
@inject IStringLocalizer<Index> Localizer
@if (userroles == null)
{
<p>
<em>Loading...</em>
<em>@Localizer["Loading..."]</em>
</p>
}
else
{
<ActionLink Action="Add" Text="Add User"/>
<ActionLink Action="Add" Text="Add User" ResourceKey="AddUser" />
<div class="d-flex p-1">
<input class="form-control mr-4" @bind="@_search"/><button class="btn btn-outline-primary ml-1" @onclick="OnSearch">Search</button>
<input class="form-control mr-4" @bind="@_search" /><button class="btn btn-outline-primary ml-1" @onclick="OnSearch">@Localizer["Search"]</button>
</div>
<Pager Items="@userroles">
@ -23,17 +24,17 @@ else
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
<th>Name</th>
<th>@Localizer["Name"]</th>
</Header>
<Row>
<td>
<ActionLink Action="Edit" Parameters="@($"id=" + context.UserId.ToString())"/>
<ActionLink Action="Edit" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="EditUser" />
</td>
<td>
<ActionDialog Header="Delete User" Message="@("Are You Sure You Wish To Delete " + context.User.DisplayName + "?")" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteUser(context))"/>
<ActionDialog Header="Delete User" Message="@("Are You Sure You Wish To Delete " + context.User.DisplayName + "?")" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteUser(context))" ResourceKey="DeleteUser" />
</td>
<td>
<ActionLink Action="Roles" Parameters="@($"id=" + context.UserId.ToString())"/>
<ActionLink Action="Roles" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="Roles" />
</td>
<td>@context.User.DisplayName</td>
</Row>

View File

@ -1,19 +1,20 @@
@namespace Oqtane.Modules.Admin.Users
@namespace Oqtane.Modules.Admin.Users
@inherits ModuleBase
@inject IRoleService RoleService
@inject IUserService UserService
@inject IUserRoleService UserRoleService
@inject IStringLocalizer<Roles> Localizer
@if (userroles == null)
{
<p><em>Loading...</em></p>
<p><em>@Localizer["Loading..."]</em></p>
}
else
{
<table class="table table-borderless">
<tr>
<td>
<Label For="user" HelpText="The user you are assigning roles to">User: </Label>
<Label For="user" HelpText="The user you are assigning roles to" resource="User">User: </Label>
</td>
<td>
<input id="user" class="form-control" @bind="@name" disabled />
@ -21,7 +22,7 @@ else
</tr>
<tr>
<td>
<Label For="role" HelpText="Select a role">Role: </Label>
<Label For="role" HelpText="Select a role" ResourceKey="Role">Role: </Label>
</td>
<td>
<select id="role" class="form-control" @bind="@roleid">
@ -35,7 +36,7 @@ else
</tr>
<tr>
<td>
<Label For="effectiveDate" HelpText="The date that this role assignment is active">Effective Date: </Label>
<Label For="effectiveDate" HelpText="The date that this role assignment is active" resource="EffectiveDate">Effective Date: </Label>
</td>
<td>
<input id="effectiveDate" class="form-control" @bind="@effectivedate" />
@ -43,30 +44,30 @@ else
</tr>
<tr>
<td>
<Label For="expiryDate" HelpText="The date that this role assignment expires">Expiry Date: </Label>
<Label For="expiryDate" HelpText="The date that this role assignment expires" ResourceKey="ExpiryDate">Expiry Date: </Label>
</td>
<td>
<input id="expiryDate" class="form-control" @bind="@expirydate" />
</td>
</tr>
</table>
<button type="button" class="btn btn-success" @onclick="SaveUserRole">Save</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
<button type="button" class="btn btn-success" @onclick="SaveUserRole">@Localizer["Save"]</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
<hr class="app-rule" />
<p align="center">
<Pager Items="@userroles">
<Header>
<th>Roles</th>
<th>@Localizer["Roles"]</th>
<th>&nbsp;</th>
</Header>
<Row>
<td>@context.Role.Name</td>
<td>
@if (context.Role.Name != RoleNames.Registered)
{
<button type="button" class="btn btn-danger" @onclick=@(async () => await DeleteUserRole(context.UserRoleId))>Delete</button>
}
{
<button type="button" class="btn btn-danger" @onclick=@(async () => await DeleteUserRole(context.UserRoleId))>@Localizer["Delete"]</button>
}
</td>
</Row>
</Pager>