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 @inherits ModuleBase
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
@inject IUserService UserService @inject IUserService UserService
@inject IProfileService ProfileService @inject IProfileService ProfileService
@inject ISettingService SettingService @inject ISettingService SettingService
@inject IStringLocalizer<Add> Localizer
<TabStrip> <TabStrip>
<TabPanel Name="Identity"> <TabPanel Name="Identity" ResourceKey="Identity">
@if (profiles != null) @if (profiles != null)
{ {
<table class="table table-borderless"> <table class="table table-borderless">
<tr> <tr>
<td> <td>
<label class="control-label">Username: </label> <label class="control-label">@Localizer["Username:"] </label>
</td> </td>
<td> <td>
<input class="form-control" @bind="@username" /> <input class="form-control" @bind="@username" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Password: </label> <label class="control-label">@Localizer["Password:"] </label>
</td> </td>
<td> <td>
<input type="password" class="form-control" @bind="@password" /> <input type="password" class="form-control" @bind="@password" />
@ -28,7 +29,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Confirm Password: </label> <label class="control-label">@Localizer["Confirm Password:"] </label>
</td> </td>
<td> <td>
<input type="password" class="form-control" @bind="@confirm" /> <input type="password" class="form-control" @bind="@confirm" />
@ -36,7 +37,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Email: </label> <label class="control-label">@Localizer["Email:"] </label>
</td> </td>
<td> <td>
<input class="form-control" @bind="@email" /> <input class="form-control" @bind="@email" />
@ -44,7 +45,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Full Name: </label> <label class="control-label">@Localizer["Full Name:"] </label>
</td> </td>
<td> <td>
<input class="form-control" @bind="@displayname" /> <input class="form-control" @bind="@displayname" />
@ -53,45 +54,45 @@
</table> </table>
} }
</TabPanel> </TabPanel>
<TabPanel Name="Profile"> <TabPanel Name="Profile" ResourceKey="Profile">
@if (profiles != null) @if (profiles != null)
{ {
<table class="table table-borderless"> <table class="table table-borderless">
@foreach (Profile profile in profiles) @foreach (Profile profile in profiles)
{
var p = profile;
if (p.Category != category)
{ {
var p = profile;
if (p.Category != category)
{
<tr>
<th colspan="2" style="text-align: center;">
@p.Category
</th>
</tr>
category = p.Category;
}
<tr> <tr>
<th colspan="2" style="text-align: center;"> <td>
@p.Category <Label For="@p.Name" HelpText="@p.Description">@p.Title</Label>
</th> </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> </tr>
category = p.Category;
} }
<tr> </table>
<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>
} }
</TabPanel> </TabPanel>
</TabStrip> </TabStrip>
<button type="button" class="btn btn-primary" @onclick="SaveUser">Save</button> <button type="button" class="btn btn-primary" @onclick="SaveUser">@Localizer["Save"]</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
@code { @code {
private string username = string.Empty; private string username = string.Empty;

View File

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

View File

@ -1,21 +1,22 @@
@namespace Oqtane.Modules.Admin.Users @namespace Oqtane.Modules.Admin.Users
@inherits ModuleBase @inherits ModuleBase
@inject IUserRoleService UserRoleService @inject IUserRoleService UserRoleService
@inject IUserService UserService @inject IUserService UserService
@inject ISettingService SettingService @inject ISettingService SettingService
@inject IStringLocalizer<Index> Localizer
@if (userroles == null) @if (userroles == null)
{ {
<p> <p>
<em>Loading...</em> <em>@Localizer["Loading..."]</em>
</p> </p>
} }
else else
{ {
<ActionLink Action="Add" Text="Add User"/> <ActionLink Action="Add" Text="Add User" ResourceKey="AddUser" />
<div class="d-flex p-1"> <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> </div>
<Pager Items="@userroles"> <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 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> </Header>
<Row> <Row>
<td> <td>
<ActionLink Action="Edit" Parameters="@($"id=" + context.UserId.ToString())"/> <ActionLink Action="Edit" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="EditUser" />
</td> </td>
<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>
<td> <td>
<ActionLink Action="Roles" Parameters="@($"id=" + context.UserId.ToString())"/> <ActionLink Action="Roles" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="Roles" />
</td> </td>
<td>@context.User.DisplayName</td> <td>@context.User.DisplayName</td>
</Row> </Row>

View File

@ -1,19 +1,20 @@
@namespace Oqtane.Modules.Admin.Users @namespace Oqtane.Modules.Admin.Users
@inherits ModuleBase @inherits ModuleBase
@inject IRoleService RoleService @inject IRoleService RoleService
@inject IUserService UserService @inject IUserService UserService
@inject IUserRoleService UserRoleService @inject IUserRoleService UserRoleService
@inject IStringLocalizer<Roles> Localizer
@if (userroles == null) @if (userroles == null)
{ {
<p><em>Loading...</em></p> <p><em>@Localizer["Loading..."]</em></p>
} }
else else
{ {
<table class="table table-borderless"> <table class="table table-borderless">
<tr> <tr>
<td> <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>
<td> <td>
<input id="user" class="form-control" @bind="@name" disabled /> <input id="user" class="form-control" @bind="@name" disabled />
@ -21,7 +22,7 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="role" HelpText="Select a role">Role: </Label> <Label For="role" HelpText="Select a role" ResourceKey="Role">Role: </Label>
</td> </td>
<td> <td>
<select id="role" class="form-control" @bind="@roleid"> <select id="role" class="form-control" @bind="@roleid">
@ -35,7 +36,7 @@ else
</tr> </tr>
<tr> <tr>
<td> <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>
<td> <td>
<input id="effectiveDate" class="form-control" @bind="@effectivedate" /> <input id="effectiveDate" class="form-control" @bind="@effectivedate" />
@ -43,30 +44,30 @@ else
</tr> </tr>
<tr> <tr>
<td> <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>
<td> <td>
<input id="expiryDate" class="form-control" @bind="@expirydate" /> <input id="expiryDate" class="form-control" @bind="@expirydate" />
</td> </td>
</tr> </tr>
</table> </table>
<button type="button" class="btn btn-success" @onclick="SaveUserRole">Save</button> <button type="button" class="btn btn-success" @onclick="SaveUserRole">@Localizer["Save"]</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
<hr class="app-rule" /> <hr class="app-rule" />
<p align="center"> <p align="center">
<Pager Items="@userroles"> <Pager Items="@userroles">
<Header> <Header>
<th>Roles</th> <th>@Localizer["Roles"]</th>
<th>&nbsp;</th> <th>&nbsp;</th>
</Header> </Header>
<Row> <Row>
<td>@context.Role.Name</td> <td>@context.Role.Name</td>
<td> <td>
@if (context.Role.Name != RoleNames.Registered) @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> </td>
</Row> </Row>
</Pager> </Pager>