This repository has been archived on 2025-05-14. You can view files and clone it, but cannot push or open issues or pull requests.
Pavel Vesely cf6643aef3 Client fixes
Client is partially done.
227 warnings left out of 1500
I like Rider
2020-03-15 15:19:35 +01:00

212 lines
8.5 KiB
Plaintext

@namespace Oqtane.UI
@inject NavigationManager NavigationManager
@inject IInstallationService InstallationService
@inject ISiteService SiteService
@inject IUserService UserService
<div class="container">
<div class="row">
<div class="mx-auto text-center">
<img src="oqtane.png" />
</div>
</div>
<hr class="app-rule" />
<div class="row justify-content-center">
<div class="col text-center">
<h2>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">Database Type: </label>
</td>
<td>
<select class="custom-select" @bind="@_databaseType">
<option value="LocalDB">Local Database</option>
<option value="SQLServer">SQL Server</option>
</select>
</td>
</tr>
<tr>
<td>
<label class="control-label" style="font-weight: bold">Server: </label>
</td>
<td>
<input type="text" class="form-control" @bind="@_serverName" />
</td>
</tr>
<tr>
<td>
<label class="control-label" style="font-weight: bold">Database: </label>
</td>
<td>
<input type="text" class="form-control" @bind="@_databaseName" />
</td>
</tr>
<tr>
<td>
<label class="control-label" style="font-weight: bold">Integrated Security: </label>
</td>
<td>
<select class="custom-select" @onchange="SetIntegratedSecurity">
<option value="true" selected>True</option>
<option value="false">False</option>
</select>
</td>
</tr>
<tr style="@_integratedSecurityDisplay">
<td>
<label class="control-label" style="font-weight: bold">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">Password: </label>
</td>
<td>
<input type="password" class="form-control" @bind="@_password" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="col text-center">
<h2>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">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">Password: </label>
</td>
<td>
<input type="password" class="form-control" @bind="@_hostPassword" />
</td>
</tr>
<tr>
<td>
<label class="control-label" style="font-weight: bold">Confirm: </label>
</td>
<td>
<input type="password" class="form-control" @bind="@_confirmPassword" />
</td>
</tr>
<tr>
<td>
<label class="control-label" style="font-weight: bold">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">Install Now</button><br /><br />
@((MarkupString)_message)
</div>
<div class="app-progress-indicator" style="@_loadingDisplay"></div>
</div>
</div>
@code {
private string _databaseType = "LocalDB";
private string _serverName = "(LocalDb)\\MSSQLLocalDB";
private string _databaseName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
private string _username = "";
private string _password = "";
private string _hostUsername = Constants.HostUser;
private string _hostPassword = "";
private string _confirmPassword = "";
private string _hostEmail = "";
private string _message = "";
private string _integratedSecurityDisplay = "display: none;";
private string _loadingDisplay = "display: none;";
private void SetIntegratedSecurity(ChangeEventArgs e)
{
if (Convert.ToBoolean((string)e.Value))
{
_integratedSecurityDisplay = "display: none;";
}
else
{
_integratedSecurityDisplay = "";
}
}
private async Task Install()
{
if (_hostUsername != "" && _hostPassword.Length >= 6 && _hostPassword == _confirmPassword && _hostEmail != "")
{
_loadingDisplay = "";
StateHasChanged();
string connectionstring = "";
if (_databaseType == "LocalDB")
{
connectionstring = "Data Source=" + _serverName + ";AttachDbFilename=|DataDirectory|\\" + _databaseName + ".mdf;Initial Catalog=" + _databaseName + ";Integrated Security=SSPI;";
}
else
{
connectionstring = "Data Source=" + _serverName + ";Initial Catalog=" + _databaseName + ";";
if (_integratedSecurityDisplay == "display: none;")
{
connectionstring += "Integrated Security=SSPI;";
}
else
{
connectionstring += "User ID=" + _username + ";Password=" + _password;
}
}
GenericResponse response = await InstallationService.Install(connectionstring);
if (response.Success)
{
Site site = new Site();
site.TenantId = -1; // will be populated on server
site.Name = "Default Site";
site.LogoFileId = null;
site.DefaultThemeType = Constants.DefaultTheme;
site.DefaultLayoutType = Constants.DefaultLayout;
site.DefaultContainerType = Constants.DefaultContainer;
site = await SiteService.AddSiteAsync(site, null);
User user = new User();
user.SiteId = site.SiteId;
user.Username = _hostUsername;
user.Password = _hostPassword;
user.Email = _hostEmail;
user.DisplayName = _hostUsername;
user = await UserService.AddUserAsync(user);
NavigationManager.NavigateTo("", true);
}
else
{
_message = "<div class=\"alert alert-danger\" role=\"alert\">" + response.Message + "</div>";
_loadingDisplay = "display: none;";
}
}
else
{
_message = "<div class=\"alert alert-danger\" role=\"alert\">Please Enter All Fields And Ensure Passwords Match And Are Greater Than 5 Characters In Length</div>";
}
}
}