Merge pull request #1339 from sbwalker/dev
added DatabaseService to get list of database types from server
This commit is contained in:
commit
0bd6fea476
@ -1,11 +1,10 @@
|
|||||||
@namespace Oqtane.Installer
|
@namespace Oqtane.Installer
|
||||||
@using Oqtane.Interfaces
|
@using Oqtane.Interfaces
|
||||||
@using Oqtane.Installer.Controls
|
|
||||||
|
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IInstallationService InstallationService
|
@inject IInstallationService InstallationService
|
||||||
@inject ISiteService SiteService
|
@inject ISiteService SiteService
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
@inject IDatabaseService DatabaseService
|
||||||
@inject IJSRuntime JSRuntime
|
@inject IJSRuntime JSRuntime
|
||||||
@inject IStringLocalizer<Installer> Localizer
|
@inject IStringLocalizer<Installer> Localizer
|
||||||
|
|
||||||
@ -22,25 +21,28 @@
|
|||||||
<h2>@Localizer["Database Configuration"]</h2><br />
|
<h2>@Localizer["Database Configuration"]</h2><br />
|
||||||
<table class="form-group" cellpadding="4" cellspacing="4" style="margin: auto;">
|
<table class="form-group" cellpadding="4" cellspacing="4" style="margin: auto;">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label class="control-label" style="font-weight: bold">@Localizer["Database Type:"]</label>
|
<label class="control-label" style="font-weight: bold">@Localizer["Database Type:"]</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="custom-select" value="@_databaseName" @onchange="(e => DatabaseChanged(e))">
|
<select class="custom-select" value="@_databaseName" @onchange="(e => DatabaseChanged(e))">
|
||||||
@foreach (var database in _databases)
|
@if (_databases != null)
|
||||||
{
|
{
|
||||||
<option value="@database.Name">@Localizer[@database.FriendlyName]</option>
|
foreach (var database in _databases)
|
||||||
}
|
{
|
||||||
</select>
|
<option value="@database.Name">@Localizer[@database.FriendlyName]</option>
|
||||||
</td>
|
}
|
||||||
</tr>
|
}
|
||||||
@{
|
</select>
|
||||||
if (_databaseConfigType != null)
|
</td>
|
||||||
{
|
</tr>
|
||||||
@DatabaseConfigComponent;
|
@{
|
||||||
|
if (_databaseConfigType != null)
|
||||||
|
{
|
||||||
|
@DatabaseConfigComponent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -95,7 +97,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private IList<Database> _databases;
|
private List<Database> _databases;
|
||||||
private string _databaseName = "LocalDB";
|
private string _databaseName = "LocalDB";
|
||||||
private Type _databaseConfigType;
|
private Type _databaseConfigType;
|
||||||
private object _databaseConfig;
|
private object _databaseConfig;
|
||||||
@ -108,44 +110,9 @@
|
|||||||
private string _message = string.Empty;
|
private string _message = string.Empty;
|
||||||
private string _loadingDisplay = "display: none;";
|
private string _loadingDisplay = "display: none;";
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
base.OnInitialized();
|
_databases = await DatabaseService.GetDatabasesAsync();
|
||||||
|
|
||||||
_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"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
LoadDatabaseConfigComponent();
|
LoadDatabaseConfigComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
@inject ISiteTemplateService SiteTemplateService
|
@inject ISiteTemplateService SiteTemplateService
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
@inject IInstallationService InstallationService
|
@inject IInstallationService InstallationService
|
||||||
|
@inject IDatabaseService DatabaseService
|
||||||
@inject IStringLocalizer<Add> Localizer
|
@inject IStringLocalizer<Add> Localizer
|
||||||
@inject IEnumerable<IOqtaneDatabase> Databases
|
@inject IEnumerable<IOqtaneDatabase> Databases
|
||||||
|
|
||||||
@ -18,151 +19,151 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<table class="table table-borderless">
|
<table class="table table-borderless">
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<Label For="name" HelpText="Enter the name of the site" ResourceKey="Name">Site Name: </Label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input id="name" class="form-control" @bind="@_name" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<Label For="alias" HelpText="Enter the aliases for the site. An alias can be a domain name (www.site.com) or a virtual folder (ie. www.site.com/folder). If a site has multiple aliases they can be separated by commas." ResourceKey="Aliases">Aliases: </Label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<textarea id="alias" class="form-control" @bind="@_urls" rows="3"></textarea>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<Label For="defaultTheme" HelpText="Select the default theme for the website" ResourceKey="DefaultTheme">Default Theme: </Label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))">
|
|
||||||
<option value="-"><@Localizer["Select Theme"]></option>
|
|
||||||
@foreach (var theme in _themes)
|
|
||||||
{
|
|
||||||
<option value="@theme.TypeName">@theme.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<Label For="defaultContainer" HelpText="Select the default container for the site" ResourceKey="DefaultContainer">Default Container: </Label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<select id="defaultContainer" class="form-control" @bind="@_containertype">
|
|
||||||
<option value="-"><@Localizer["Select Container"]></option>
|
|
||||||
@foreach (var container in _containers)
|
|
||||||
{
|
|
||||||
<option value="@container.TypeName">@container.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<Label For="adminContainer" HelpText="Select the admin container for the site" ResourceKey="AdminContainer">Admin Container: </Label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<select id="adminContainer" class="form-control" @bind="@_admincontainertype">
|
|
||||||
<option value="-"><@Localizer["Select Container"]></option>
|
|
||||||
<option value=""><@Localizer["Default Admin Container"]></option>
|
|
||||||
@foreach (var container in _containers)
|
|
||||||
{
|
|
||||||
<option value="@container.TypeName">@container.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<Label For="siteTemplate" HelpText="Select the site template" ResourceKey="SiteTemplate">Site Template: </Label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<select id="siteTemplate" class="form-control" @bind="@_sitetemplatetype">
|
|
||||||
<option value="-"><@Localizer["Select Site Template"]></option>
|
|
||||||
@foreach (SiteTemplate siteTemplate in _siteTemplates)
|
|
||||||
{
|
|
||||||
<option value="@siteTemplate.TypeName">@siteTemplate.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<Label For="tenant" HelpText="Select the tenant for the site" ResourceKey="Tenant">Tenant: </Label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<select id="tenant" class="form-control" @onchange="(e => TenantChanged(e))">
|
|
||||||
<option value="-"><@Localizer["Select Tenant"]></option>
|
|
||||||
<option value="+"><@Localizer["Create New Tenant"]></option>
|
|
||||||
@foreach (Tenant tenant in _tenants)
|
|
||||||
{
|
|
||||||
<option value="@tenant.TenantId">@tenant.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
@if (_tenantid == "+")
|
|
||||||
{
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td>
|
||||||
<hr class="app-rule" />
|
<Label For="name" HelpText="Enter the name of the site" ResourceKey="Name">Site Name: </Label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input id="name" class="form-control" @bind="@_name" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="name" HelpText="Enter the name for the tenant" ResourceKey="TenantName">Tenant Name: </Label>
|
<Label For="alias" HelpText="Enter the aliases for the site. An alias can be a domain name (www.site.com) or a virtual folder (ie. www.site.com/folder). If a site has multiple aliases they can be separated by commas." ResourceKey="Aliases">Aliases: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="name" class="form-control" @bind="@_tenantName" />
|
<textarea id="alias" class="form-control" @bind="@_urls" rows="3"></textarea>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="databaseType" HelpText="Select the database type for the tenant" ResourceKey="DatabaseType">Database Type: </Label>
|
<Label For="defaultTheme" HelpText="Select the default theme for the website" ResourceKey="DefaultTheme">Default Theme: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select id="databaseType" class="custom-select" value="@_databaseName" @onchange="(e => DatabaseChanged(e))">
|
<select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))">
|
||||||
@foreach (var database in _databases)
|
<option value="-"><@Localizer["Select Theme"]></option>
|
||||||
|
@foreach (var theme in _themes)
|
||||||
{
|
{
|
||||||
<option value="@database.Name">@Localizer[@database.FriendlyName]</option>
|
<option value="@theme.TypeName">@theme.Name</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
if (_databaseConfigType != null)
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Label For="defaultContainer" HelpText="Select the default container for the site" ResourceKey="DefaultContainer">Default Container: </Label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select id="defaultContainer" class="form-control" @bind="@_containertype">
|
||||||
|
<option value="-"><@Localizer["Select Container"]></option>
|
||||||
|
@foreach (var container in _containers)
|
||||||
|
{
|
||||||
|
<option value="@container.TypeName">@container.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Label For="adminContainer" HelpText="Select the admin container for the site" ResourceKey="AdminContainer">Admin Container: </Label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select id="adminContainer" class="form-control" @bind="@_admincontainertype">
|
||||||
|
<option value="-"><@Localizer["Select Container"]></option>
|
||||||
|
<option value=""><@Localizer["Default Admin Container"]></option>
|
||||||
|
@foreach (var container in _containers)
|
||||||
|
{
|
||||||
|
<option value="@container.TypeName">@container.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Label For="siteTemplate" HelpText="Select the site template" ResourceKey="SiteTemplate">Site Template: </Label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select id="siteTemplate" class="form-control" @bind="@_sitetemplatetype">
|
||||||
|
<option value="-"><@Localizer["Select Site Template"]></option>
|
||||||
|
@foreach (SiteTemplate siteTemplate in _siteTemplates)
|
||||||
|
{
|
||||||
|
<option value="@siteTemplate.TypeName">@siteTemplate.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Label For="tenant" HelpText="Select the tenant for the site" ResourceKey="Tenant">Tenant: </Label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select id="tenant" class="form-control" @onchange="(e => TenantChanged(e))">
|
||||||
|
<option value="-"><@Localizer["Select Tenant"]></option>
|
||||||
|
<option value="+"><@Localizer["Create New Tenant"]></option>
|
||||||
|
@foreach (Tenant tenant in _tenants)
|
||||||
|
{
|
||||||
|
<option value="@tenant.TenantId">@tenant.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@if (_tenantid == "+")
|
||||||
{
|
{
|
||||||
@DatabaseConfigComponent;
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<hr class="app-rule" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Label For="name" HelpText="Enter the name for the tenant" ResourceKey="TenantName">Tenant Name: </Label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input id="name" class="form-control" @bind="@_tenantName" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Label For="databaseType" HelpText="Select the database type for the tenant" ResourceKey="DatabaseType">Database Type: </Label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select id="databaseType" 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 For="hostUsername" HelpText="Enter the username of the host for this site" ResourceKey="HostUsername">Host Username:</Label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input id="hostUsername" class="form-control" @bind="@_hostUserName" readonly />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Label For="hostPassword" HelpText="Enter the password for the host of this site" ResourceKey="HostPassword">Host Password:</Label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input id="hostPassword" type="password" class="form-control" @bind="@_hostpassword" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
}
|
}
|
||||||
<tr>
|
</table>
|
||||||
<td>
|
|
||||||
<Label For="hostUsername" HelpText="Enter the username of the host for this site" ResourceKey="HostUsername">Host Username:</Label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input id="hostUsername" class="form-control" @bind="@_hostUserName" readonly />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<Label For="hostPassword" HelpText="Enter the password for the host of this site" ResourceKey="HostPassword">Host Password:</Label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input id="hostPassword" type="password" class="form-control" @bind="@_hostpassword" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</table>
|
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveSite">@Localizer["Save"]</button>
|
<button type="button" class="btn btn-success" @onclick="SaveSite">@Localizer["Save"]</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private IList<Database> _databases;
|
private List<Database> _databases;
|
||||||
private string _databaseName = "LocalDB";
|
private string _databaseName = "LocalDB";
|
||||||
private Type _databaseConfigType;
|
private Type _databaseConfigType;
|
||||||
private object _databaseConfig;
|
private object _databaseConfig;
|
||||||
@ -177,7 +178,7 @@ else
|
|||||||
private string _tenantid = "-";
|
private string _tenantid = "-";
|
||||||
|
|
||||||
private string _tenantName = string.Empty;
|
private string _tenantName = string.Empty;
|
||||||
|
|
||||||
private string _hostUserName = UserNames.Host;
|
private string _hostUserName = UserNames.Host;
|
||||||
private string _hostpassword = string.Empty;
|
private string _hostpassword = string.Empty;
|
||||||
|
|
||||||
@ -197,44 +198,10 @@ else
|
|||||||
_themeList = await ThemeService.GetThemesAsync();
|
_themeList = await ThemeService.GetThemesAsync();
|
||||||
_themes = ThemeService.GetThemeControls(_themeList);
|
_themes = ThemeService.GetThemeControls(_themeList);
|
||||||
_siteTemplates = await SiteTemplateService.GetSiteTemplatesAsync();
|
_siteTemplates = await SiteTemplateService.GetSiteTemplatesAsync();
|
||||||
|
_databases = await DatabaseService.GetDatabasesAsync();
|
||||||
_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"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
LoadDatabaseConfigComponent();
|
LoadDatabaseConfigComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DatabaseChanged(ChangeEventArgs eventArgs)
|
private void DatabaseChanged(ChangeEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -365,12 +332,12 @@ else
|
|||||||
if (tenant != null)
|
if (tenant != null)
|
||||||
{
|
{
|
||||||
config.TenantName = tenant.Name;
|
config.TenantName = tenant.Name;
|
||||||
config.ConnectionString= tenant.DBConnectionString;
|
config.ConnectionString = tenant.DBConnectionString;
|
||||||
config.IsNewTenant = false;
|
config.IsNewTenant = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(config.TenantName))
|
if (!string.IsNullOrEmpty(config.TenantName))
|
||||||
{
|
{
|
||||||
config.SiteName = _name;
|
config.SiteName = _name;
|
||||||
config.Aliases = _urls;
|
config.Aliases = _urls;
|
||||||
|
28
Oqtane.Client/Services/DatabaseService.cs
Normal file
28
Oqtane.Client/Services/DatabaseService.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using Oqtane.Models;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public class DatabaseService : ServiceBase, IDatabaseService
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly SiteState _siteState;
|
||||||
|
|
||||||
|
public DatabaseService(HttpClient http, SiteState siteState) : base(http)
|
||||||
|
{
|
||||||
|
_siteState = siteState;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string Apiurl => CreateApiUrl("Database", _siteState.Alias);
|
||||||
|
|
||||||
|
public async Task<List<Database>> GetDatabasesAsync()
|
||||||
|
{
|
||||||
|
List<Database> databases = await GetJsonAsync<List<Database>>(Apiurl);
|
||||||
|
return databases.OrderBy(item => item.FriendlyName).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Oqtane.Client/Services/Interfaces/IDatabaseService.cs
Normal file
11
Oqtane.Client/Services/Interfaces/IDatabaseService.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using Oqtane.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public interface IDatabaseService
|
||||||
|
{
|
||||||
|
Task<List<Database>> GetDatabasesAsync();
|
||||||
|
}
|
||||||
|
}
|
52
Oqtane.Server/Controllers/DatabaseController.cs
Normal file
52
Oqtane.Server/Controllers/DatabaseController.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
namespace Oqtane.Controllers
|
||||||
|
{
|
||||||
|
[Route(ControllerRoutes.ApiRoute)]
|
||||||
|
public class DatabaseController : Controller
|
||||||
|
{
|
||||||
|
public DatabaseController() { }
|
||||||
|
|
||||||
|
// GET: api/<controller>
|
||||||
|
[HttpGet]
|
||||||
|
public IEnumerable<Models.Database> Get()
|
||||||
|
{
|
||||||
|
var databases = new List<Models.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"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return databases;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
@ -10,7 +9,6 @@ using Microsoft.AspNetCore.Components;
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
@ -126,6 +124,7 @@ namespace Oqtane
|
|||||||
services.AddScoped<ISystemService, SystemService>();
|
services.AddScoped<ISystemService, SystemService>();
|
||||||
services.AddScoped<ILocalizationService, LocalizationService>();
|
services.AddScoped<ILocalizationService, LocalizationService>();
|
||||||
services.AddScoped<ILanguageService, LanguageService>();
|
services.AddScoped<ILanguageService, LanguageService>();
|
||||||
|
services.AddScoped<IDatabaseService, DatabaseService>();
|
||||||
|
|
||||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user