install/upgrade refactoring to consolidate all use cases and implement IInstallable interface for modules, moved tenant creation to site management UI, fixed z-order issues in Blazor theme, enhanced JS Interop methods to support integrity and crossorigin
This commit is contained in:
@ -1,156 +0,0 @@
|
||||
@namespace Oqtane.Modules.Admin.Tenants
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject ITenantService TenantService
|
||||
@inject IInstallationService InstallationService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="name" HelpText="Enter the name for the tenant">Name: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="name" class="form-control" @bind="@name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="databaseType" HelpText="Select the database type for the tenant">Database Type: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<select id="databaseType" class="custom-select" @bind="@type">
|
||||
<option value="LocalDB">Local Database</option>
|
||||
<option value="SQLServer">SQL Server</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="server" HelpText="Enter the server for the tenant">Server: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="server" type="text" class="form-control" @bind="@server" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="database" HelpText="Enter the database for the tenant">Database: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="database" type="text" class="form-control" @bind="@database" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="integratedSecurity" HelpText="Select if you want integrated security or not">Integrated Security: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<select id="integratedSecurity" class="custom-select" @onchange="SetIntegratedSecurity">
|
||||
<option value="true" selected>True</option>
|
||||
<option value="false">False</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="@integratedsecurity">
|
||||
<td>
|
||||
<Label For="username" HelpText="Enter the username for the integrated security">Username: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="username" type="text" class="form-control" @bind="@username" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="@integratedsecurity">
|
||||
<td>
|
||||
<Label For="password" HelpText="Enter the password for the integrated security">Password: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="password" type="password" class="form-control" @bind="@password" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="SaveTenant">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@code {
|
||||
private string name = string.Empty;
|
||||
private string type = "LocalDB";
|
||||
private string server = "(LocalDb)\\MSSQLLocalDB";
|
||||
private string database = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
|
||||
private string username = string.Empty;
|
||||
private string password = string.Empty;
|
||||
private string schema = string.Empty;
|
||||
private string integratedsecurity = "display: none;";
|
||||
|
||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||
|
||||
private void SetIntegratedSecurity(ChangeEventArgs e)
|
||||
{
|
||||
if (Convert.ToBoolean((string)e.Value))
|
||||
{
|
||||
integratedsecurity = "display: none;";
|
||||
}
|
||||
else
|
||||
{
|
||||
integratedsecurity = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveTenant()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
ShowProgressIndicator();
|
||||
|
||||
var connectionString = string.Empty;
|
||||
if (type == "LocalDB")
|
||||
{
|
||||
connectionString = "Data Source=" + server + ";AttachDbFilename=|DataDirectory|\\" + database + ".mdf;Initial Catalog=" + database + ";Integrated Security=SSPI;";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionString = "Data Source=" + server + ";Initial Catalog=" + database + ";";
|
||||
|
||||
if (integratedsecurity == "display: none;")
|
||||
{
|
||||
connectionString += "Integrated Security=SSPI;";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionString += "User ID=" + username + ";Password=" + password;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var config = new InstallConfig
|
||||
{
|
||||
IsMaster = false,
|
||||
ConnectionString = connectionString,
|
||||
};
|
||||
|
||||
var installation = await InstallationService.Install(config);
|
||||
if (installation.Success)
|
||||
{
|
||||
//TODO : Move to Database Manager
|
||||
var tenant = new Tenant
|
||||
{
|
||||
Name = name,
|
||||
DBConnectionString = connectionString,
|
||||
IsInitialized = false
|
||||
};
|
||||
await TenantService.AddTenantAsync(tenant);
|
||||
await logger.LogInformation("Tenant Created {Tenant}", tenant);
|
||||
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
else
|
||||
{
|
||||
await logger.LogError("Error Creating Tenant {Error}", installation.Message);
|
||||
AddModuleMessage(installation.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddModuleMessage("You Must Provide A Name For The Tenant", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="name" HelpText="Enter the nameof the tenant">Name: </Label>
|
||||
<Label For="name" HelpText="The name of the tenant">Name: </Label>
|
||||
</td>
|
||||
<td>
|
||||
@if (name == Constants.MasterTenant)
|
||||
@ -21,10 +21,10 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="connectionString" HelpText="Enter the connection string for the tenant">Connection String: </Label>
|
||||
<Label For="connectionstring" HelpText="The database connection string">Connection String: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="integratedSecurity" class="form-control" @bind="@connectionstring" />
|
||||
<textarea id="connectionstring" class="form-control" @bind="@connectionstring" rows="3" readonly></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
@namespace Oqtane.Modules.Admin.Tenants
|
||||
@inherits ModuleBase
|
||||
@inject ITenantService TenantService
|
||||
@inject IAliasService AliasService
|
||||
|
||||
@if (tenants == null)
|
||||
{
|
||||
@ -8,8 +9,6 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<ActionLink Action="Add" Text="Add Tenant" />
|
||||
|
||||
<Pager Items="@tenants">
|
||||
<Header>
|
||||
<th> </th>
|
||||
@ -39,9 +38,25 @@ else
|
||||
{
|
||||
try
|
||||
{
|
||||
await TenantService.DeleteTenantAsync(Tenant.TenantId);
|
||||
await logger.LogInformation("Tenant Deleted {Tenant}", Tenant);
|
||||
StateHasChanged();
|
||||
string message = string.Empty;
|
||||
var aliases = await AliasService.GetAliasesAsync();
|
||||
foreach (var alias in aliases)
|
||||
{
|
||||
if (alias.TenantId == Tenant.TenantId)
|
||||
{
|
||||
message += ", " + alias.Name;
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(message))
|
||||
{
|
||||
await TenantService.DeleteTenantAsync(Tenant.TenantId);
|
||||
await logger.LogInformation("Tenant Deleted {Tenant}", Tenant);
|
||||
StateHasChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
AddModuleMessage("Tenant Cannot Be Deleted Until The Following Sites Are Deleted: " + message.Substring(2), MessageType.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Reference in New Issue
Block a user