233 lines
10 KiB
Plaintext
233 lines
10 KiB
Plaintext
@namespace Oqtane.UI
|
|
@inject NavigationManager NavigationManager
|
|
@inject IInstallationService InstallationService
|
|
@inject ISiteService SiteService
|
|
@inject IUserService UserService
|
|
@inject IJSRuntime JSRuntime
|
|
@inject IStringLocalizer<Installer> Localizer
|
|
|
|
<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">
|
|
<option value="LocalDB">@Localizer["Local Database"]</option>
|
|
<option value="SQLServer">@Localizer["SQL Server"]</option>
|
|
<option value="Sqlite">@Localizer["Sqlite"]</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr style="@(_databaseType == "Sqlite" ? "" : "display: none")">
|
|
<td>
|
|
<label class="control-label" style="font-weight: bold">@Localizer["File Name:"] </label>
|
|
</td>
|
|
<td>
|
|
<input type="text" class="form-control" @bind="@_fileName" />
|
|
</td>
|
|
</tr>
|
|
<tr style="@(_databaseType == "Sqlite" ? "display: none" : "")">
|
|
<td>
|
|
<label class="control-label" style="font-weight: bold">@Localizer["Server:"] </label>
|
|
</td>
|
|
<td>
|
|
<input type="text" class="form-control" @bind="@_serverName" />
|
|
</td>
|
|
</tr>
|
|
<tr style="@(_databaseType == "Sqlite" ? "display: none" : "")">
|
|
<td>
|
|
<label class="control-label" style="font-weight: bold">@Localizer["Database:"] </label>
|
|
</td>
|
|
<td>
|
|
<input type="text" class="form-control" @bind="@_databaseName" />
|
|
</td>
|
|
</tr>
|
|
<tr style="@(_databaseType == "Sqlite" ? "display: none" : "")">
|
|
<td>
|
|
<label class="control-label" style="font-weight: bold">@Localizer["Integrated Security:"] </label>
|
|
</td>
|
|
<td>
|
|
<select class="custom-select" @onchange="SetIntegratedSecurity">
|
|
<option value="true" selected>@Localizer["True"]</option>
|
|
<option value="false">@Localizer["False"]</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr style="@_integratedSecurityDisplay">
|
|
<td>
|
|
<label class="control-label" style="font-weight: bold">@Localizer["Username:"] </label>
|
|
</td>
|
|
<td>
|
|
<input type="text" class="form-control" @bind="@_username" />
|
|
</td>
|
|
</tr>
|
|
<tr style="@_integratedSecurityDisplay">
|
|
<td>
|
|
<label class="control-label" style="font-weight: bold">@Localizer["Password:"] </label>
|
|
</td>
|
|
<td>
|
|
<input type="password" class="form-control" @bind="@_password" />
|
|
</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 string _databaseType = "LocalDB";
|
|
private string _serverName = "(LocalDb)\\MSSQLLocalDB";
|
|
private string _fileName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm") + ".db";
|
|
private string _databaseName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
|
|
private string _username = string.Empty;
|
|
private string _password = string.Empty;
|
|
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 _integratedSecurityDisplay = "display: none;";
|
|
private string _fileFieldsDisplay = "display: none;";
|
|
private string _serverFieldsDisplay = "display: none;";
|
|
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 void SetIntegratedSecurity(ChangeEventArgs e)
|
|
{
|
|
_integratedSecurityDisplay = Convert.ToBoolean((string)e.Value)
|
|
? "display: none;"
|
|
: string.Empty;
|
|
}
|
|
|
|
private async Task Install()
|
|
{
|
|
if (((_serverName != "" && _databaseName != "") || _fileName !="") && _hostUsername != "" && _hostPassword.Length >= 6 && _hostPassword == _confirmPassword && _hostEmail != "")
|
|
{
|
|
_loadingDisplay = "";
|
|
StateHasChanged();
|
|
|
|
var connectionstring = "";
|
|
switch (_databaseType)
|
|
{
|
|
case "LocalDB":
|
|
connectionstring = "Data Source=" + _serverName + ";AttachDbFilename=|DataDirectory|\\" + _databaseName + ".mdf;Initial Catalog=" + _databaseName + ";Integrated Security=SSPI;";
|
|
break;
|
|
case "SQLServer":
|
|
connectionstring = "Data Source=" + _serverName + ";Initial Catalog=" + _databaseName + ";";
|
|
if (_integratedSecurityDisplay == "display: none;")
|
|
{
|
|
connectionstring += "Integrated Security=SSPI;";
|
|
}
|
|
else
|
|
{
|
|
connectionstring += "User ID=" + _username + ";Password=" + _password;
|
|
}
|
|
break;
|
|
case "Sqlite":
|
|
connectionstring = "Data Source=" + _fileName;
|
|
break;
|
|
}
|
|
|
|
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"];
|
|
}
|
|
}
|
|
|
|
}
|