Merge pull request #900 from hishamco/localize-sites-pages

Localize Sites Pages
This commit is contained in:
Shaun Walker 2020-11-19 15:34:25 -05:00 committed by GitHub
commit 3b62ffd4f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 54 deletions

View File

@ -1,4 +1,4 @@
@namespace Oqtane.Modules.Admin.Sites @namespace Oqtane.Modules.Admin.Sites
@inherits ModuleBase @inherits ModuleBase
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
@inject ITenantService TenantService @inject ITenantService TenantService
@ -8,17 +8,18 @@
@inject ISiteTemplateService SiteTemplateService @inject ISiteTemplateService SiteTemplateService
@inject IUserService UserService @inject IUserService UserService
@inject IInstallationService InstallationService @inject IInstallationService InstallationService
@inject IStringLocalizer<Add> Localizer
@if (_tenants == null) @if (_tenants == 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="name" HelpText="Enter the name of the site">Site Name: </Label> <Label For="name" HelpText="Enter the name of the site" ResourceKey="Name">Site Name: </Label>
</td> </td>
<td> <td>
<input id="name" class="form-control" @bind="@_name" /> <input id="name" class="form-control" @bind="@_name" />
@ -26,7 +27,7 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="alias" HelpText="Enter the alias for the server">Aliases: </Label> <Label For="alias" HelpText="Enter the alias for the server" ResourceKey="Aliases">Aliases: </Label>
</td> </td>
<td> <td>
<textarea id="alias" class="form-control" @bind="@_urls" rows="3"></textarea> <textarea id="alias" class="form-control" @bind="@_urls" rows="3"></textarea>
@ -34,11 +35,11 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="defaultTheme" HelpText="Select the default theme for the website">Default Theme: </Label> <Label For="defaultTheme" HelpText="Select the default theme for the website" ResourceKey="DefaultTheme">Default Theme: </Label>
</td> </td>
<td> <td>
<select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))"> <select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="-">&lt;Select Theme&gt;</option> <option value="-">&lt;@Localizer["Select Theme"]&gt;</option>
@foreach (var theme in _themes) @foreach (var theme in _themes)
{ {
<option value="@theme.TypeName">@theme.Name</option> <option value="@theme.TypeName">@theme.Name</option>
@ -50,11 +51,11 @@ else
{ {
<tr> <tr>
<td> <td>
<Label For="defaultLayout" HelpText="Select the default layout for the site">Default Layout: </Label> <Label For="defaultLayout" HelpText="Select the default layout for the site" ResourceKey="DefaultLayout">Default Layout: </Label>
</td> </td>
<td> <td>
<select id="defaultLayout" class="form-control" @bind="@_layouttype"> <select id="defaultLayout" class="form-control" @bind="@_layouttype">
<option value="-">&lt;Select Layout&gt;</option> <option value="-">&lt;@Localizer["Select Layout"]&gt;</option>
@foreach (var layout in _layouts) @foreach (var layout in _layouts)
{ {
<option value="@(layout.TypeName)">@(layout.Name)</option> <option value="@(layout.TypeName)">@(layout.Name)</option>
@ -65,11 +66,11 @@ else
} }
<tr> <tr>
<td> <td>
<Label For="defaultContainer" HelpText="Select the default container for the site">Default Container: </Label> <Label For="defaultContainer" HelpText="Select the default container for the site" ResourceKey="DefaultContainer">Default Container: </Label>
</td> </td>
<td> <td>
<select id="defaultContainer" class="form-control" @bind="@_containertype"> <select id="defaultContainer" class="form-control" @bind="@_containertype">
<option value="-">&lt;Select Container&gt;</option> <option value="-">&lt;@Localizer["Select Container"]&gt;</option>
@foreach (var container in _containers) @foreach (var container in _containers)
{ {
<option value="@container.TypeName">@container.Name</option> <option value="@container.TypeName">@container.Name</option>
@ -79,11 +80,11 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="siteTemplate" HelpText="Select the site template">Site Template: </Label> <Label For="siteTemplate" HelpText="Select the site template" ResourceKey="SiteTemplate">Site Template: </Label>
</td> </td>
<td> <td>
<select id="siteTemplate" class="form-control" @bind="@_sitetemplatetype"> <select id="siteTemplate" class="form-control" @bind="@_sitetemplatetype">
<option value="-">&lt;Select Site Template&gt;</option> <option value="-">&lt;@Localizer["Select Site Template"]&gt;</option>
@foreach (SiteTemplate siteTemplate in _siteTemplates) @foreach (SiteTemplate siteTemplate in _siteTemplates)
{ {
<option value="@siteTemplate.TypeName">@siteTemplate.Name</option> <option value="@siteTemplate.TypeName">@siteTemplate.Name</option>
@ -93,12 +94,12 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="tenant" HelpText="Select the tenant for the site">Tenant: </Label> <Label For="tenant" HelpText="Select the tenant for the site" ResourceKey="Tenant">Tenant: </Label>
</td> </td>
<td> <td>
<select id="tenant" class="form-control" @onchange="(e => TenantChanged(e))"> <select id="tenant" class="form-control" @onchange="(e => TenantChanged(e))">
<option value="-">&lt;Select Tenant&gt;</option> <option value="-">&lt;@Localizer["Select Tenant"]&gt;</option>
<option value="+">&lt;Create New Tenant&gt;</option> <option value="+">&lt;@Localizer["Create New Tenant"]&gt;</option>
@foreach (Tenant tenant in _tenants) @foreach (Tenant tenant in _tenants)
{ {
<option value="@tenant.TenantId">@tenant.Name</option> <option value="@tenant.TenantId">@tenant.Name</option>
@ -115,7 +116,7 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="name" HelpText="Enter the name for the tenant">Tenant Name: </Label> <Label For="name" HelpText="Enter the name for the tenant" ResourceKey="TenantName">Tenant Name: </Label>
</td> </td>
<td> <td>
<input id="name" class="form-control" @bind="@_tenantname" /> <input id="name" class="form-control" @bind="@_tenantname" />
@ -123,18 +124,18 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="databaseType" HelpText="Select the database type for the tenant">Database Type: </Label> <Label For="databaseType" HelpText="Select the database type for the tenant" ResourceKey="DatabaseType">Database Type: </Label>
</td> </td>
<td> <td>
<select id="databaseType" class="custom-select" @bind="@_databasetype"> <select id="databaseType" class="custom-select" @bind="@_databasetype">
<option value="LocalDB">Local Database</option> <option value="LocalDB">@Localizer["Local Database"]</option>
<option value="SQLServer">SQL Server</option> <option value="SQLServer">@Localizer["SQL Server"]</option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="server" HelpText="Enter the server for the tenant">Server: </Label> <Label For="server" HelpText="Enter the server for the tenant" ResourceKey="DatabaseServer">Server: </Label>
</td> </td>
<td> <td>
<input id="server" type="text" class="form-control" @bind="@_server" /> <input id="server" type="text" class="form-control" @bind="@_server" />
@ -142,7 +143,7 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="database" HelpText="Enter the database for the tenant">Database: </Label> <Label For="database" HelpText="Enter the database for the tenant" ResourceKey="Database">Database: </Label>
</td> </td>
<td> <td>
<input id="database" type="text" class="form-control" @bind="@_database" /> <input id="database" type="text" class="form-control" @bind="@_database" />
@ -150,12 +151,12 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="integratedSecurity" HelpText="Select if you want integrated security or not">Integrated Security: </Label> <Label For="integratedSecurity" HelpText="Select if you want integrated security or not" ResourceKey="IntegratedSecurity">Integrated Security: </Label>
</td> </td>
<td> <td>
<select id="integratedSecurity" class="custom-select" @onchange="SetIntegratedSecurity"> <select id="integratedSecurity" class="custom-select" @onchange="SetIntegratedSecurity">
<option value="true" selected>True</option> <option value="true" selected>@Localizer["True"]</option>
<option value="false">False</option> <option value="false">@Localizer["False"]</option>
</select> </select>
</td> </td>
</tr> </tr>
@ -163,7 +164,7 @@ else
{ {
<tr> <tr>
<td> <td>
<Label For="username" HelpText="Enter the username for the integrated security">Database Username: </Label> <Label For="username" HelpText="Enter the username for the integrated security" ResourceKey="DatabaseUsername">Database Username: </Label>
</td> </td>
<td> <td>
<input id="username" type="text" class="form-control" @bind="@_username" /> <input id="username" type="text" class="form-control" @bind="@_username" />
@ -171,7 +172,7 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="password" HelpText="Enter the password for the integrated security">Database Password: </Label> <Label For="password" HelpText="Enter the password for the integrated security" ResourceKey="DatabasePassword">Database Password: </Label>
</td> </td>
<td> <td>
<input id="password" type="password" class="form-control" @bind="@_password" /> <input id="password" type="password" class="form-control" @bind="@_password" />
@ -180,7 +181,7 @@ else
} }
<tr> <tr>
<td> <td>
<Label For="hostUsername" HelpText="Enter the username of the host for this site">Host Username:</Label> <Label For="hostUsername" HelpText="Enter the username of the host for this site" ResourceKey="HostUsername">Host Username:</Label>
</td> </td>
<td> <td>
<input id="hostUsername" class="form-control" @bind="@_hostusername" readonly /> <input id="hostUsername" class="form-control" @bind="@_hostusername" readonly />
@ -188,7 +189,7 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="hostPassword" HelpText="Enter the password for the host of this site">Host Password:</Label> <Label For="hostPassword" HelpText="Enter the password for the host of this site" ResourceKey="HostPassword">Host Password:</Label>
</td> </td>
<td> <td>
<input id="hostPassword" type="password" class="form-control" @bind="@_hostpassword" /> <input id="hostPassword" type="password" class="form-control" @bind="@_hostpassword" />
@ -196,8 +197,8 @@ else
</tr> </tr>
} }
</table> </table>
<button type="button" class="btn btn-success" @onclick="SaveSite">Save</button> <button type="button" class="btn btn-success" @onclick="SaveSite">@Localizer["Save"]</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
} }
@code { @code {

View File

@ -1,17 +1,18 @@
@namespace Oqtane.Modules.Admin.Sites @namespace Oqtane.Modules.Admin.Sites
@inherits ModuleBase @inherits ModuleBase
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
@inject ISiteService SiteService @inject ISiteService SiteService
@inject ITenantService TenantService @inject ITenantService TenantService
@inject IAliasService AliasService @inject IAliasService AliasService
@inject IThemeService ThemeService @inject IThemeService ThemeService
@inject IStringLocalizer<Edit> Localizer
@if (_initialized) @if (_initialized)
{ {
<table class="table table-borderless"> <table class="table table-borderless">
<tr> <tr>
<td> <td>
<Label For="name" HelpText="Enter the name of the site">Name: </Label> <Label For="name" HelpText="Enter the name of the site" ResourceKey="Name">Name: </Label>
</td> </td>
<td> <td>
<input id="name" class="form-control" @bind="@_name" /> <input id="name" class="form-control" @bind="@_name" />
@ -19,7 +20,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="tenant" HelpText="Enter the tenant for the site">Tenant: </Label> <Label For="tenant" HelpText="Enter the tenant for the site" ResourceKey="Tenant">Tenant: </Label>
</td> </td>
<td> <td>
<input id="tenant" class="form-control" @bind="@_tenant" readonly /> <input id="tenant" class="form-control" @bind="@_tenant" readonly />
@ -27,7 +28,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="alias" HelpText="Enter the alias for the server">Aliases: </Label> <Label For="alias" HelpText="Enter the alias for the server" ResourceKey="Aliases">Aliases: </Label>
</td> </td>
<td> <td>
<textarea id="alias" class="form-control" @bind="@_urls" rows="3" /> <textarea id="alias" class="form-control" @bind="@_urls" rows="3" />
@ -35,11 +36,11 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="defaultTheme" HelpText="Select the default theme for the website">Default Theme: </Label> <Label For="defaultTheme" HelpText="Select the default theme for the website" ResourceKey="DefaultTheme">Default Theme: </Label>
</td> </td>
<td> <td>
<select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))"> <select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="-">&lt;Select Theme&gt;</option> <option value="-">&lt;@Localizer["Select Theme"]&gt;</option>
@foreach (var theme in _themes) @foreach (var theme in _themes)
{ {
if (theme.TypeName == _themetype) if (theme.TypeName == _themetype)
@ -58,11 +59,11 @@
{ {
<tr> <tr>
<td> <td>
<Label For="defaultLayout" HelpText="Select the default layout for the site">Default Layout: </Label> <Label For="defaultLayout" HelpText="Select the default layout for the site" ResourceKey="DefaultLayout">Default Layout: </Label>
</td> </td>
<td> <td>
<select id="defaultLayout" class="form-control" @bind="@_layouttype"> <select id="defaultLayout" class="form-control" @bind="@_layouttype">
<option value="-">&lt;Select Layout&gt;</option> <option value="-">&lt;@Localizer["Select Layout"]&gt;</option>
@foreach (var layout in _layouts) @foreach (var layout in _layouts)
{ {
<option value="@(layout.TypeName)">@(layout.Name)</option> <option value="@(layout.TypeName)">@(layout.Name)</option>
@ -73,11 +74,11 @@
} }
<tr> <tr>
<td> <td>
<Label For="defaultContainer" HelpText="Select the default container for the site">Default Container: </Label> <Label For="defaultContainer" HelpText="Select the default container for the site" ResourceKey="DefaultContainer">Default Container: </Label>
</td> </td>
<td> <td>
<select id="defaultIdea" class="form-control" @bind="@_containertype"> <select id="defaultIdea" class="form-control" @bind="@_containertype">
<option value="-">&lt;Select Container&gt;</option> <option value="-">&lt;@Localizer["Select Container"]&gt;</option>
@foreach (var container in _containers) @foreach (var container in _containers)
{ {
<option value="@container.TypeName">@container.Name</option> <option value="@container.TypeName">@container.Name</option>
@ -87,19 +88,19 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="isDeleted" HelpText="Has this site been deleted?">Is Deleted? </Label> <Label For="isDeleted" HelpText="Has this site been deleted?" ResourceKey="IsDeleted">Is Deleted? </Label>
</td> </td>
<td> <td>
<select id="isDeleted" class="form-control" @bind="@_isdeleted"> <select id="isDeleted" 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>
<br /> <br />
<button type="button" class="btn btn-success" @onclick="SaveSite">Save</button> <button type="button" class="btn btn-success" @onclick="SaveSite">@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>
@ -256,7 +257,7 @@
} }
} }
await Log(_alias, LogLevel.Information,PermissionNames.Edit, null, "Site Saved {Site}", site); await Log(_alias, LogLevel.Information, PermissionNames.Edit, null, "Site Saved {Site}", site);
NavigationManager.NavigateTo(NavigateUrl()); NavigationManager.NavigateTo(NavigateUrl());
} }
@ -277,4 +278,4 @@
AddModuleMessage("Error Saving Site", MessageType.Error); AddModuleMessage("Error Saving Site", MessageType.Error);
} }
} }
} }

View File

@ -1,8 +1,9 @@
@namespace Oqtane.Modules.Admin.Sites @namespace Oqtane.Modules.Admin.Sites
@inherits ModuleBase @inherits ModuleBase
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
@inject IAliasService AliasService @inject IAliasService AliasService
@inject ISiteService SiteService @inject ISiteService SiteService
@inject IStringLocalizer<Index> Localizer
@if (_sites == null) @if (_sites == null)
{ {
@ -10,17 +11,17 @@
} }
else else
{ {
<ActionLink Action="Add" Text="Add Site" /> <ActionLink Action="Add" Text="Add Site" ResourceKey="AddSite" />
<Pager Items="@_sites"> <Pager Items="@_sites">
<Header> <Header>
<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><ActionLink Action="Edit" Parameters="@($"id=" + context.AliasId.ToString())" /></td> <td><ActionLink Action="Edit" Parameters="@($"id=" + context.AliasId.ToString())" ResourceKey="EditSite" /></td>
<td><ActionDialog Header="Delete Site" Message="@("Are You Sure You Wish To Delete The " + context.Name + " Site?")" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteSite(context))" /></td> <td><ActionDialog Header="Delete Site" Message="@("Are You Sure You Wish To Delete The " + context.Name + " Site?")" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteSite(context))" ResourceKey="DeleteSite" /></td>
<td><a href="@(_scheme + context.Name)">@context.Name</a></td> <td><a href="@(_scheme + context.Name)">@context.Name</a></td>
</Row> </Row>
</Pager> </Pager>
@ -57,13 +58,13 @@ else
SiteService.SetAlias(alias); SiteService.SetAlias(alias);
await SiteService.DeleteSiteAsync(alias.SiteId); await SiteService.DeleteSiteAsync(alias.SiteId);
await Log(alias, LogLevel.Information, "", null, "Site Deleted {SiteId}", alias.SiteId); await Log(alias, LogLevel.Information, "", null, "Site Deleted {SiteId}", alias.SiteId);
var aliases = await AliasService.GetAliasesAsync(); var aliases = await AliasService.GetAliasesAsync();
foreach (Alias a in aliases.Where(item => item.SiteId == alias.SiteId && item.TenantId == alias.TenantId)) foreach (Alias a in aliases.Where(item => item.SiteId == alias.SiteId && item.TenantId == alias.TenantId))
{ {
await AliasService.DeleteAliasAsync(a.AliasId); await AliasService.DeleteAliasAsync(a.AliasId);
} }
NavigationManager.NavigateTo(NavigateUrl()); NavigationManager.NavigateTo(NavigateUrl());
} }
else else