198 lines
8.4 KiB
Plaintext
198 lines
8.4 KiB
Plaintext
@using Oqtane.Interfaces
|
|
@using System.Reflection
|
|
@namespace Oqtane.UI
|
|
@inject NavigationManager NavigationManager
|
|
@inject IInstallationService InstallationService
|
|
@inject ISiteService SiteService
|
|
@inject IUserService UserService
|
|
@inject IJSRuntime JSRuntime
|
|
@inject IStringLocalizer<Installer> Localizer
|
|
@inject IEnumerable<IOqtaneDatabase> Databases
|
|
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="mx-auto text-center">
|
|
<img src="oqtane-black.png" />
|
|
<div style="font-weight: bold">@Localizer["Version:"] @Constants.Version</div>
|
|
</div>
|
|
</div>
|
|
<hr class="app-rule" />
|
|
<div class="row justify-content-center">
|
|
<div class="col text-center">
|
|
<h2>@Localizer["Database Configuration"]</h2><br />
|
|
<table class="form-group" cellpadding="4" cellspacing="4" style="margin: auto;">
|
|
<tbody>
|
|
<tr>
|
|
<td>
|
|
<label class="control-label" style="font-weight: bold">@Localizer["Database Type:"] </label>
|
|
</td>
|
|
<td>
|
|
<select class="custom-select" @bind="@_databaseType">
|
|
@{
|
|
foreach (var database in Databases)
|
|
{
|
|
<option value="@database.Name">@Localizer[@database.FriendlyName]</option>
|
|
}
|
|
}
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
@{
|
|
_selectedDatabase = Databases.Single(d => d.Name == _databaseType);
|
|
foreach (var field in _selectedDatabase.ConnectionStringFields)
|
|
{
|
|
if (field.Name != "IntegratedSecurity")
|
|
{
|
|
var isVisible = "";
|
|
var fieldType = (field.Name == "Pwd") ? "password" : "text";
|
|
if ((field.Name == "Uid" || field.Name == "Pwd") && _selectedDatabase.Name != "MySQL" )
|
|
{
|
|
var intSecurityField = _selectedDatabase.ConnectionStringFields.Single(f => f.Name == "IntegratedSecurity");
|
|
if (intSecurityField != null)
|
|
{
|
|
isVisible = (Convert.ToBoolean(intSecurityField.Value)) ? "display: none;" : "";
|
|
}
|
|
}
|
|
|
|
field.Value = field.Value.Replace("{{Date}}", DateTime.UtcNow.ToString("yyyyMMddHHmm"));
|
|
|
|
<tr style="@isVisible">
|
|
<td>
|
|
<label class="control-label" style="font-weight: bold">@Localizer[$"{field.FriendlyName}:"]</label>
|
|
</td>
|
|
<td>
|
|
<input type="@fieldType" class="form-control" @bind="@field.Value" />
|
|
</td>
|
|
</tr>
|
|
}
|
|
else
|
|
{
|
|
<tr>
|
|
<td>
|
|
<label class="control-label" style="font-weight: bold">@Localizer[$"{field.FriendlyName}:"]</label>
|
|
</td>
|
|
<td>
|
|
<select class="custom-select" @bind="@field.Value">
|
|
<option value="true" selected>@Localizer["True"]</option>
|
|
<option value="false">@Localizer["False"]</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
}
|
|
}
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="col text-center">
|
|
<h2>@Localizer["Application Administrator"]</h2><br />
|
|
<table class="form-group" cellpadding="4" cellspacing="4" style="margin: auto;">
|
|
<tbody>
|
|
<tr>
|
|
<td>
|
|
<label class="control-label" style="font-weight: bold">@Localizer["Username:"] </label>
|
|
</td>
|
|
<td>
|
|
<input type="text" class="form-control" @bind="@_hostUsername" readonly />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label class="control-label" style="font-weight: bold">@Localizer["Password:"] </label>
|
|
</td>
|
|
<td>
|
|
<input type="password" class="form-control" @bind="@_hostPassword" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label class="control-label" style="font-weight: bold">@Localizer["Confirm:"] </label>
|
|
</td>
|
|
<td>
|
|
<input type="password" class="form-control" @bind="@_confirmPassword" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label class="control-label" style="font-weight: bold">@Localizer["Email:"] </label>
|
|
</td>
|
|
<td>
|
|
<input type="text" class="form-control" @bind="@_hostEmail" />
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<hr class="app-rule" />
|
|
<div class="row">
|
|
<div class="mx-auto text-center">
|
|
<button type="button" class="btn btn-success" @onclick="Install">@Localizer["Install Now"]</button><br /><br />
|
|
<ModuleMessage Message="@_message" Type="MessageType.Error"></ModuleMessage>
|
|
</div>
|
|
<div class="app-progress-indicator" style="@_loadingDisplay"></div>
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
private IOqtaneDatabase _selectedDatabase;
|
|
private string _databaseType = "LocalDB";
|
|
private string _hostUsername = UserNames.Host;
|
|
private string _hostPassword = string.Empty;
|
|
private string _confirmPassword = string.Empty;
|
|
private string _hostEmail = string.Empty;
|
|
private string _message = string.Empty;
|
|
private string _loadingDisplay = "display: none;";
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
var interop = new Interop(JSRuntime);
|
|
await interop.IncludeLink("app-stylesheet", "stylesheet", "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css", "text/css", "sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T", "anonymous", "");
|
|
}
|
|
}
|
|
|
|
private async Task Install()
|
|
{
|
|
var connectionString = _selectedDatabase.BuildConnectionString();
|
|
|
|
if (connectionString != "" && _hostUsername != "" && _hostPassword.Length >= 6 && _hostPassword == _confirmPassword && _hostEmail != "")
|
|
{
|
|
_loadingDisplay = "";
|
|
StateHasChanged();
|
|
|
|
Uri uri = new Uri(NavigationManager.Uri);
|
|
|
|
var config = new InstallConfig
|
|
{
|
|
DatabaseType = _databaseType,
|
|
ConnectionString = connectionString,
|
|
Aliases = uri.Authority,
|
|
HostEmail = _hostEmail,
|
|
HostPassword = _hostPassword,
|
|
HostName = UserNames.Host,
|
|
TenantName = TenantNames.Master,
|
|
IsNewTenant = true,
|
|
SiteName = Constants.DefaultSite
|
|
};
|
|
|
|
var installation = await InstallationService.Install(config);
|
|
if (installation.Success)
|
|
{
|
|
NavigationManager.NavigateTo(uri.Scheme + "://" + uri.Authority, true);
|
|
}
|
|
else
|
|
{
|
|
_message = installation.Message;
|
|
_loadingDisplay = "display: none;";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_message = Localizer["Please Enter All Fields And Ensure Passwords Match And Are Greater Than 5 Characters In Length"];
|
|
}
|
|
}
|
|
|
|
}
|