Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added DatabaseService to get list of database types from server #1339

Merged
merged 1 commit into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 25 additions & 58 deletions Oqtane.Client/Installer/Installer.razor
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
@namespace Oqtane.Installer
@using Oqtane.Interfaces
@using Oqtane.Installer.Controls

@inject NavigationManager NavigationManager
@inject IInstallationService InstallationService
@inject ISiteService SiteService
@inject IUserService UserService
@inject IDatabaseService DatabaseService
@inject IJSRuntime JSRuntime
@inject IStringLocalizer<Installer> Localizer

Expand All @@ -22,25 +21,28 @@
<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" value="@_databaseName" @onchange="(e => DatabaseChanged(e))">
@foreach (var database in _databases)
{
<option value="@database.Name">@Localizer[@database.FriendlyName]</option>
}
</select>
</td>
</tr>
@{
if (_databaseConfigType != null)
{
@DatabaseConfigComponent;
<tr>
<td>
<label class="control-label" style="font-weight: bold">@Localizer["Database Type:"]</label>
</td>
<td>
<select class="custom-select" value="@_databaseName" @onchange="(e => DatabaseChanged(e))">
@if (_databases != null)
{
foreach (var database in _databases)
{
<option value="@database.Name">@Localizer[@database.FriendlyName]</option>
}
}
</select>
</td>
</tr>
@{
if (_databaseConfigType != null)
{
@DatabaseConfigComponent;
}
}
}
</tbody>
</table>
</div>
Expand Down Expand Up @@ -95,7 +97,7 @@
</div>

@code {
private IList<Database> _databases;
private List<Database> _databases;
private string _databaseName = "LocalDB";
private Type _databaseConfigType;
private object _databaseConfig;
Expand All @@ -108,44 +110,9 @@
private string _message = string.Empty;
private string _loadingDisplay = "display: none;";

protected override void OnInitialized()
protected override async Task OnInitializedAsync()
{
base.OnInitialized();

_databases = new List<Database>
{
new()
{
Name = "LocalDB",
FriendlyName = "Local Database",
Type = "Oqtane.Installer.Controls.LocalDBConfig, Oqtane.Client"
},
new()
{
Name = "SqlServer",
FriendlyName = "SQL Server",
Type = "Oqtane.Installer.Controls.SqlServerConfig, Oqtane.Client"
},
new()
{
Name = "Sqlite",
FriendlyName = "Sqlite",
Type = "Oqtane.Installer.Controls.SqliteConfig, Oqtane.Client"
},
new()
{
Name = "MySQL",
FriendlyName = "MySQL",
Type = "Oqtane.Installer.Controls.MySQLConfig, Oqtane.Client"
},
new()
{
Name = "PostgreSQL",
FriendlyName = "PostgreSQL",
Type = "Oqtane.Installer.Controls.PostgreSQLConfig, Oqtane.Client"
}
};

_databases = await DatabaseService.GetDatabasesAsync();
LoadDatabaseConfigComponent();
}

Expand Down
Loading