improved file upload, enhanced module installation from Nuget to support upgrades, added ability to upgrade the framework from Nuget, completed isolated multitenancy and site alias management, created IPortable interface for importing data into modules, added default content to initial installation
This commit is contained in:
parent
dce53e10b0
commit
9971510b1e
|
@ -11,7 +11,7 @@
|
||||||
<label for="Name" class="control-label">Module: </label>
|
<label for="Name" class="control-label">Module: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<FileUpload Filter=".nupkg"></FileUpload>
|
<FileUpload Filter=".nupkg" @ref="fileupload"></FileUpload>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -50,18 +50,55 @@
|
||||||
|
|
||||||
bool uploaded = false;
|
bool uploaded = false;
|
||||||
List<Package> packages;
|
List<Package> packages;
|
||||||
|
FileUpload fileupload;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
List<ModuleDefinition> moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
||||||
packages = await PackageService.GetPackagesAsync("module");
|
packages = await PackageService.GetPackagesAsync("module");
|
||||||
|
foreach(Package package in packages.ToArray())
|
||||||
|
{
|
||||||
|
if (moduledefinitions.Exists(item => Utilities.GetTypeName(item.ModuleDefinitionName) == package.PackageId))
|
||||||
|
{
|
||||||
|
packages.Remove(package);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UploadFile()
|
private async Task UploadFile()
|
||||||
{
|
{
|
||||||
await FileService.UploadFilesAsync("Modules");
|
string[] files = await fileupload.GetFiles();
|
||||||
ModuleInstance.AddModuleMessage("Module Uploaded Successfully. Click Install To Complete Installation.", MessageType.Success);
|
if (files.Length > 0)
|
||||||
uploaded = true;
|
{
|
||||||
StateHasChanged();
|
if (files[0].Contains(".Module."))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (await FileService.UploadFilesAsync("Modules", files, ""))
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("Module Uploaded Successfully. Click Install To Complete Installation.", MessageType.Success);
|
||||||
|
uploaded = true;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("Module Upload Failed.", MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("Module Upload Failed. " + ex.Message, MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("Invalid Module Package", MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("You Must Select A Module To Upload", MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task InstallModules()
|
private async Task InstallModules()
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
@namespace Oqtane.Modules.Admin.ModuleDefinitions
|
@namespace Oqtane.Modules.Admin.ModuleDefinitions
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
@inject IModuleDefinitionService ModuleDefinitionService
|
@inject IModuleDefinitionService ModuleDefinitionService
|
||||||
|
@inject IPackageService PackageService
|
||||||
|
|
||||||
@if (moduledefinitions == null)
|
@if (moduledefinitions == null)
|
||||||
{
|
{
|
||||||
|
@ -16,12 +18,19 @@ else
|
||||||
<th>Version</th>
|
<th>Version</th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
|
<th> </th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
<td>@context.Version</td>
|
<td>@context.Version</td>
|
||||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ModuleDefinitionId.ToString())" /></td>
|
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ModuleDefinitionId.ToString())" /></td>
|
||||||
<td><ActionLink Action="Delete" Parameters="@($"id=" + context.ModuleDefinitionId.ToString())" Class="btn btn-danger" /></td>
|
<td><ActionLink Action="Delete" Parameters="@($"id=" + context.ModuleDefinitionId.ToString())" Class="btn btn-danger" /></td>
|
||||||
|
<td>
|
||||||
|
@if (UpgradeAvailable(context.ModuleDefinitionName, context.Version))
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-success" @onclick=@(async () => await DownloadModule(context.ModuleDefinitionName, context.Version))>Upgrade</button>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
}
|
}
|
||||||
|
@ -30,9 +39,29 @@ else
|
||||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||||
|
|
||||||
List<ModuleDefinition> moduledefinitions;
|
List<ModuleDefinition> moduledefinitions;
|
||||||
|
List<Package> packages;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
||||||
|
packages = await PackageService.GetPackagesAsync("module");
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool UpgradeAvailable(string moduledefinitionname, string version)
|
||||||
|
{
|
||||||
|
bool upgradeavailable = false;
|
||||||
|
Package package = packages.Where(item => item.PackageId == Utilities.GetTypeName(moduledefinitionname)).FirstOrDefault();
|
||||||
|
if (package != null)
|
||||||
|
{
|
||||||
|
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0);
|
||||||
|
}
|
||||||
|
return upgradeavailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DownloadModule(string moduledefinitionname, string version)
|
||||||
|
{
|
||||||
|
await PackageService.DownloadPackageAsync(moduledefinitionname, version, "Modules");
|
||||||
|
await ModuleDefinitionService.InstallModulesAsync();
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
|
||||||
}
|
}
|
||||||
}
|
}
|
32
Oqtane.Client/Modules/Admin/Modules/Export.razor
Normal file
32
Oqtane.Client/Modules/Admin/Modules/Export.razor
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
@namespace Oqtane.Modules.Admin.Modules
|
||||||
|
@inherits ModuleBase
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject IModuleService ModuleService
|
||||||
|
|
||||||
|
<table class="table table-borderless">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="Title" class="control-label">Content: </label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<textarea class="form-control" @bind="@content" rows="5" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<button type="button" class="btn btn-success" @onclick="ExportModule">Export</button>
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
|
public override string Title { get { return "Export Module"; } }
|
||||||
|
|
||||||
|
string content = "";
|
||||||
|
|
||||||
|
private async Task ExportModule()
|
||||||
|
{
|
||||||
|
content = await ModuleService.ExportModuleAsync(ModuleState.ModuleId);
|
||||||
|
}
|
||||||
|
}
|
41
Oqtane.Client/Modules/Admin/Modules/Import.razor
Normal file
41
Oqtane.Client/Modules/Admin/Modules/Import.razor
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
@namespace Oqtane.Modules.Admin.Modules
|
||||||
|
@inherits ModuleBase
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject IModuleService ModuleService
|
||||||
|
|
||||||
|
<table class="table table-borderless">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="Title" class="control-label">Content: </label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<textarea class="form-control" @bind="@content" rows="5" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<button type="button" class="btn btn-success" @onclick="ImportModule">Import</button>
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
|
public override string Title { get { return "Import Module"; } }
|
||||||
|
|
||||||
|
string content = "";
|
||||||
|
|
||||||
|
|
||||||
|
private async Task ImportModule()
|
||||||
|
{
|
||||||
|
if (content != "")
|
||||||
|
{
|
||||||
|
await ModuleService.ImportModuleAsync(ModuleState.ModuleId, content);
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(Reload.Page));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("You Must Enter Some Content To Import", MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
@namespace Oqtane.Modules.Admin.ModuleSettings
|
@namespace Oqtane.Modules.Admin.Modules
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IThemeService ThemeService
|
@inject IThemeService ThemeService
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
@inject IPageModuleService PageModuleService
|
@inject IPageModuleService PageModuleService
|
||||||
|
|
||||||
<table class="table table-borderless">
|
<table class="table table-borderless">
|
||||||
<thead>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Title" class="control-label">Title: </label>
|
<label for="Title" class="control-label">Title: </label>
|
||||||
|
@ -15,8 +15,6 @@
|
||||||
<input type="text" name="Title" class="form-control" @bind="@title" />
|
<input type="text" name="Title" class="form-control" @bind="@title" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Container" class="control-label">Container: </label>
|
<label for="Container" class="control-label">Container: </label>
|
|
@ -19,7 +19,7 @@ else
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@tenantid">
|
<select class="form-control" @bind="@tenantid">
|
||||||
<option value=""><Select Tenant></option>
|
<option value="-1"><Select Tenant></option>
|
||||||
@foreach (Tenant tenant in tenants)
|
@foreach (Tenant tenant in tenants)
|
||||||
{
|
{
|
||||||
<option value="@tenant.TenantId">@tenant.Name</option>
|
<option value="@tenant.TenantId">@tenant.Name</option>
|
||||||
|
@ -37,10 +37,10 @@ else
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Name" class="control-label">Alias: </label>
|
<label for="Name" class="control-label">Aliases: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@url" />
|
<textarea class="form-control" @bind="@urls" rows="3" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -91,9 +91,9 @@ else
|
||||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||||
|
|
||||||
List<Tenant> tenants;
|
List<Tenant> tenants;
|
||||||
string tenantid = "";
|
string tenantid = "-1";
|
||||||
string name = "";
|
string name = "";
|
||||||
string url = "";
|
string urls = "";
|
||||||
string logo = "";
|
string logo = "";
|
||||||
string themetype;
|
string themetype;
|
||||||
string layouttype;
|
string layouttype;
|
||||||
|
@ -101,7 +101,7 @@ else
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
tenants = await TenantService.GetTenantsAsync();
|
tenants = await TenantService.GetTenantsAsync();
|
||||||
url = PageState.Alias.Name;
|
urls = PageState.Alias.Name;
|
||||||
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
||||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
||||||
}
|
}
|
||||||
|
@ -115,12 +115,16 @@ else
|
||||||
site.DefaultLayoutType = (layouttype == null ? "" : layouttype);
|
site.DefaultLayoutType = (layouttype == null ? "" : layouttype);
|
||||||
site = await SiteService.AddSiteAsync(site);
|
site = await SiteService.AddSiteAsync(site);
|
||||||
|
|
||||||
Alias alias = new Alias();
|
urls = urls.Replace("\n", ",");
|
||||||
alias.Name = url;
|
foreach(string name in urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
alias.TenantId = int.Parse(tenantid);
|
{
|
||||||
alias.SiteId = site.SiteId;
|
Alias alias = new Alias();
|
||||||
await AliasService.AddAliasAsync(alias);
|
alias.Name = name;
|
||||||
|
alias.TenantId = int.Parse(tenantid);
|
||||||
|
alias.SiteId = site.SiteId;
|
||||||
|
await AliasService.AddAliasAsync(alias);
|
||||||
|
}
|
||||||
|
|
||||||
NavigationManager.NavigateTo("http://" + url, true);
|
NavigationManager.NavigateTo("http://" + urls[0], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject ISiteService SiteService
|
@inject ISiteService SiteService
|
||||||
|
@inject IAliasService AliasService
|
||||||
@inject IThemeService ThemeService
|
@inject IThemeService ThemeService
|
||||||
|
|
||||||
@if (themes == null)
|
@if (themes == null)
|
||||||
|
@ -19,6 +20,14 @@ else
|
||||||
<input class="form-control" @bind="@name" />
|
<input class="form-control" @bind="@name" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="Name" class="control-label">Aliases: </label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<textarea class="form-control" @bind="@urls" rows="3" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Name" class="control-label">Logo: </label>
|
<label for="Name" class="control-label">Logo: </label>
|
||||||
|
@ -80,7 +89,9 @@ else
|
||||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
Dictionary<string, string> themes = new Dictionary<string, string>();
|
||||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
List<Alias> aliases;
|
||||||
string name = "";
|
string name = "";
|
||||||
|
string urls = "";
|
||||||
string logo = "";
|
string logo = "";
|
||||||
string themetype;
|
string themetype;
|
||||||
string layouttype;
|
string layouttype;
|
||||||
|
@ -95,9 +106,14 @@ else
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
|
aliases = PageState.Aliases.Where(item => item.TenantId == PageState.Alias.TenantId && item.SiteId == PageState.Site.SiteId).ToList();
|
||||||
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
||||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
||||||
name = PageState.Site.Name;
|
name = PageState.Site.Name;
|
||||||
|
foreach (Alias alias in aliases)
|
||||||
|
{
|
||||||
|
urls += alias.Name + "\n";
|
||||||
|
}
|
||||||
logo = PageState.Site.Logo;
|
logo = PageState.Site.Logo;
|
||||||
themetype = PageState.Site.DefaultThemeType;
|
themetype = PageState.Site.DefaultThemeType;
|
||||||
layouttype = PageState.Site.DefaultLayoutType;
|
layouttype = PageState.Site.DefaultLayoutType;
|
||||||
|
@ -122,6 +138,27 @@ else
|
||||||
|
|
||||||
site = await SiteService.UpdateSiteAsync(site);
|
site = await SiteService.UpdateSiteAsync(site);
|
||||||
|
|
||||||
|
urls = urls.Replace("\n", ",");
|
||||||
|
string[] names = urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
foreach (Alias alias in aliases)
|
||||||
|
{
|
||||||
|
if (!names.Contains(alias.Name))
|
||||||
|
{
|
||||||
|
await AliasService.DeleteAliasAsync(alias.AliasId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (string name in names)
|
||||||
|
{
|
||||||
|
if (!aliases.Exists(item => item.Name == name))
|
||||||
|
{
|
||||||
|
Alias alias = new Alias();
|
||||||
|
alias.Name = name;
|
||||||
|
alias.TenantId = PageState.Alias.TenantId;
|
||||||
|
alias.SiteId = site.SiteId;
|
||||||
|
await AliasService.AddAliasAsync(alias);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject ITenantService TenantService
|
@inject ITenantService TenantService
|
||||||
|
@inject IInstallationService InstallationService
|
||||||
|
|
||||||
<table class="table table-borderless">
|
<table class="table table-borderless">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -41,12 +42,20 @@
|
||||||
|
|
||||||
private async Task SaveTenant()
|
private async Task SaveTenant()
|
||||||
{
|
{
|
||||||
Tenant tenant = new Tenant();
|
GenericResponse response = await InstallationService.Install(connectionstring);
|
||||||
tenant.Name = name;
|
if (response.Success)
|
||||||
tenant.DBConnectionString = connectionstring;
|
{
|
||||||
tenant.DBSchema = schema;
|
Tenant tenant = new Tenant();
|
||||||
await TenantService.AddTenantAsync(tenant);
|
tenant.Name = name;
|
||||||
|
tenant.DBConnectionString = connectionstring;
|
||||||
|
tenant.DBSchema = schema;
|
||||||
|
await TenantService.AddTenantAsync(tenant);
|
||||||
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage(response.Message, MessageType.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<label for="Name" class="control-label">Theme: </label>
|
<label for="Name" class="control-label">Theme: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<FileUpload Filter=".nupkg"></FileUpload>
|
<FileUpload Filter=".nupkg" @ref="fileupload"></FileUpload>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -49,18 +49,55 @@
|
||||||
|
|
||||||
bool uploaded = false;
|
bool uploaded = false;
|
||||||
List<Package> packages;
|
List<Package> packages;
|
||||||
|
FileUpload fileupload;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
List<Theme> themes = await ThemeService.GetThemesAsync();
|
||||||
packages = await PackageService.GetPackagesAsync("theme");
|
packages = await PackageService.GetPackagesAsync("theme");
|
||||||
|
foreach(Package package in packages.ToArray())
|
||||||
|
{
|
||||||
|
if (themes.Exists(item => Utilities.GetTypeName(item.ThemeName) == package.PackageId))
|
||||||
|
{
|
||||||
|
packages.Remove(package);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UploadTheme()
|
private async Task UploadTheme()
|
||||||
{
|
{
|
||||||
await FileService.UploadFilesAsync("Themes");
|
string[] files = await fileupload.GetFiles();
|
||||||
ModuleInstance.AddModuleMessage("Theme Uploaded Successfully. Click Install To Complete Installation.", MessageType.Success);
|
if (files.Length > 0)
|
||||||
uploaded = true;
|
{
|
||||||
StateHasChanged();
|
if (files[0].Contains(".Theme."))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (await FileService.UploadFilesAsync("Themes", files, ""))
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("Theme Uploaded Successfully. Click Install To Complete Installation.", MessageType.Success);
|
||||||
|
uploaded = true;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("Theme Upload Failed.", MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("Theme Upload Failed. " + ex.Message, MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("Invalid Theme Package", MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("You Must Select A Theme To Upload", MessageType.Warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task InstallThemes()
|
private async Task InstallThemes()
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
@namespace Oqtane.Modules.Admin.Themes
|
@namespace Oqtane.Modules.Admin.Themes
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
@inject IThemeService ThemeService
|
@inject IThemeService ThemeService
|
||||||
|
@inject IPackageService PackageService
|
||||||
|
|
||||||
@if (themes == null)
|
@if (themes == null)
|
||||||
{
|
{
|
||||||
|
@ -14,10 +16,19 @@ else
|
||||||
<Header>
|
<Header>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Version</th>
|
<th>Version</th>
|
||||||
|
<th> </th>
|
||||||
|
<th> </th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
<td>@context.Version</td>
|
<td>@context.Version</td>
|
||||||
|
<td><ActionLink Action="Delete" Parameters="@($"id=" + context.ThemeName)" Class="btn btn-danger" /></td>
|
||||||
|
<td>
|
||||||
|
@if (UpgradeAvailable(context.ThemeName, context.Version))
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-success" @onclick=@(async () => await DownloadTheme(context.ThemeName, context.Version))>Upgrade</button>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
}
|
}
|
||||||
|
@ -26,9 +37,29 @@ else
|
||||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||||
|
|
||||||
List<Theme> themes;
|
List<Theme> themes;
|
||||||
|
List<Package> packages;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
themes = await ThemeService.GetThemesAsync();
|
themes = await ThemeService.GetThemesAsync();
|
||||||
|
packages = await PackageService.GetPackagesAsync("module");
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool UpgradeAvailable(string themename, string version)
|
||||||
|
{
|
||||||
|
bool upgradeavailable = false;
|
||||||
|
Package package = packages.Where(item => item.PackageId == Utilities.GetTypeName(themename)).FirstOrDefault();
|
||||||
|
if (package != null)
|
||||||
|
{
|
||||||
|
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0);
|
||||||
|
}
|
||||||
|
return upgradeavailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DownloadTheme(string themename, string version)
|
||||||
|
{
|
||||||
|
await PackageService.DownloadPackageAsync(themename, version, "Themes");
|
||||||
|
await ThemeService.InstallThemesAsync();
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
|
||||||
}
|
}
|
||||||
}
|
}
|
104
Oqtane.Client/Modules/Admin/Upgrade/Index.razor
Normal file
104
Oqtane.Client/Modules/Admin/Upgrade/Index.razor
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
@namespace Oqtane.Modules.Admin.Upgrade
|
||||||
|
@inherits ModuleBase
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject IFileService FileService
|
||||||
|
@inject IPackageService PackageService
|
||||||
|
@inject IInstallationService InstallationService
|
||||||
|
|
||||||
|
<table class="table table-borderless">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="Name" class="control-label">Framework: </label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<FileUpload Filter=".nupkg" @ref="fileupload"></FileUpload>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
@if (uploaded)
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-success" @onclick="Upgrade">Upgrade</button>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-primary" @onclick="UploadFile">Upload</button>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (upgradeavailable)
|
||||||
|
{
|
||||||
|
<hr />
|
||||||
|
<div class="mx-auto text-center"><h2>Upgrade Available</h2></div>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-success" @onclick=@(async () => await Download(Constants.PackageId, Constants.Version))>Upgrade Framework</button>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||||
|
|
||||||
|
bool uploaded = false;
|
||||||
|
bool upgradeavailable = false;
|
||||||
|
FileUpload fileupload;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
List<Package> packages = await PackageService.GetPackagesAsync("framework");
|
||||||
|
Package package = packages.FirstOrDefault();
|
||||||
|
if (package != null)
|
||||||
|
{
|
||||||
|
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(Constants.Version)) > 0);
|
||||||
|
}
|
||||||
|
if (!upgradeavailable)
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("Framework Up To Date", MessageType.Info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UploadFile()
|
||||||
|
{
|
||||||
|
string[] files = await fileupload.GetFiles();
|
||||||
|
if (files.Length > 0)
|
||||||
|
{
|
||||||
|
if (files[0].Contains(".Framework."))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (await FileService.UploadFilesAsync("Framework", files, ""))
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("Framework Uploaded Successfully. Click Upgrade To Complete Installation.", MessageType.Success);
|
||||||
|
uploaded = true;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("Framework Upload Failed.", MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("Framework Upload Failed. " + ex.Message, MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("Invalid Framework Package", MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModuleInstance.AddModuleMessage("You Must Select A Framework Package To Upload", MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Upgrade()
|
||||||
|
{
|
||||||
|
await InstallationService.Upgrade();
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Download(string packageid, string version)
|
||||||
|
{
|
||||||
|
await PackageService.DownloadPackageAsync(packageid, version, "Framework");
|
||||||
|
await InstallationService.Upgrade();
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,13 @@
|
||||||
@namespace Oqtane.Modules.Controls
|
@namespace Oqtane.Modules.Controls
|
||||||
|
@inject IJSRuntime jsRuntime
|
||||||
|
|
||||||
@if (multiple)
|
@if (multiple)
|
||||||
{
|
{
|
||||||
<input type="file" id="@fileid" name="file" accept="@filter" multiple />
|
<input type="file" id="@fileid" name="file" accept="@filter" value="@files" multiple />
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<input type="file" id="@fileid" name="file" accept="@filter" />
|
<input type="file" id="@fileid" name="file" accept="@filter" value="@files" />
|
||||||
}
|
}
|
||||||
<span id="@progressinfoid"></span> <progress id="@progressbarid" style="visibility: hidden;"></progress>
|
<span id="@progressinfoid"></span> <progress id="@progressbarid" style="visibility: hidden;"></progress>
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ else
|
||||||
string progressinfoid = "";
|
string progressinfoid = "";
|
||||||
string progressbarid = "";
|
string progressbarid = "";
|
||||||
string filter = "*";
|
string filter = "*";
|
||||||
|
string files = "";
|
||||||
bool multiple = false;
|
bool multiple = false;
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
|
@ -42,4 +44,11 @@ else
|
||||||
multiple = bool.Parse(Multiple);
|
multiple = bool.Parse(Multiple);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<string[]> GetFiles()
|
||||||
|
{
|
||||||
|
var interop = new Interop(jsRuntime);
|
||||||
|
string[] files = await interop.GetFiles(fileid);
|
||||||
|
return files;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Oqtane.Modules.HtmlText
|
namespace Oqtane.Modules.HtmlText
|
||||||
{
|
{
|
||||||
public class Module : IModule
|
public class ModuleInfo : IModule
|
||||||
{
|
{
|
||||||
public Dictionary<string, string> Properties
|
public Dictionary<string, string> Properties
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,8 @@ namespace Oqtane.Modules.HtmlText
|
||||||
{
|
{
|
||||||
{ "Name", "HtmlText" },
|
{ "Name", "HtmlText" },
|
||||||
{ "Description", "Renders HTML or Text" },
|
{ "Description", "Renders HTML or Text" },
|
||||||
{ "Version", "1.0.0" }
|
{ "Version", "1.0.0" },
|
||||||
|
{ "ServerAssemblyName", "Oqtane.Server" }
|
||||||
};
|
};
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
|
@ -1,12 +1,10 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Oqtane.Services;
|
using Oqtane.Services;
|
||||||
using Oqtane.Modules.HtmlText.Models;
|
using Oqtane.Modules.HtmlText.Models;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
using System.Text.Json;
|
using Oqtane.Models;
|
||||||
|
|
||||||
namespace Oqtane.Modules.HtmlText.Services
|
namespace Oqtane.Modules.HtmlText.Services
|
||||||
{
|
{
|
||||||
|
@ -57,5 +55,6 @@ namespace Oqtane.Modules.HtmlText.Services
|
||||||
{
|
{
|
||||||
await http.DeleteAsync(apiurl + "/" + ModuleId.ToString() + "?entityid=" + ModuleId.ToString());
|
await http.DeleteAsync(apiurl + "/" + ModuleId.ToString() + "?entityid=" + ModuleId.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ using Microsoft.JSInterop;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Oqtane.Modules
|
namespace Oqtane.Modules
|
||||||
{
|
{
|
||||||
|
@ -20,6 +21,14 @@ namespace Oqtane.Modules
|
||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
protected ModuleInstance ModuleInstance { get; set; }
|
protected ModuleInstance ModuleInstance { get; set; }
|
||||||
|
|
||||||
|
protected ModuleDefinition ModuleDefinition
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return PageState.ModuleDefinitions.Where(item => item.ModuleDefinitionName == ModuleState.ModuleDefinitionName).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.View; } set { } } // default security
|
public virtual SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.View; } set { } } // default security
|
||||||
|
|
||||||
public virtual string Title { get { return ""; } }
|
public virtual string Title { get { return ""; } }
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using System.Threading.Tasks;
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.JSInterop;
|
using Microsoft.JSInterop;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
@ -7,12 +9,14 @@ namespace Oqtane.Services
|
||||||
{
|
{
|
||||||
public class FileService : ServiceBase, IFileService
|
public class FileService : ServiceBase, IFileService
|
||||||
{
|
{
|
||||||
|
private readonly HttpClient http;
|
||||||
private readonly SiteState sitestate;
|
private readonly SiteState sitestate;
|
||||||
private readonly NavigationManager NavigationManager;
|
private readonly NavigationManager NavigationManager;
|
||||||
private readonly IJSRuntime jsRuntime;
|
private readonly IJSRuntime jsRuntime;
|
||||||
|
|
||||||
public FileService(SiteState sitestate, NavigationManager NavigationManager, IJSRuntime jsRuntime)
|
public FileService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager, IJSRuntime jsRuntime)
|
||||||
{
|
{
|
||||||
|
this.http = http;
|
||||||
this.sitestate = sitestate;
|
this.sitestate = sitestate;
|
||||||
this.NavigationManager = NavigationManager;
|
this.NavigationManager = NavigationManager;
|
||||||
this.jsRuntime = jsRuntime;
|
this.jsRuntime = jsRuntime;
|
||||||
|
@ -23,15 +27,29 @@ namespace Oqtane.Services
|
||||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "File"); }
|
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "File"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UploadFilesAsync(string Folder)
|
public async Task<List<string>> GetFilesAsync(string Folder)
|
||||||
{
|
{
|
||||||
await UploadFilesAsync(Folder, "");
|
return await http.GetJsonAsync<List<string>>(apiurl + "?folder=" + Folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UploadFilesAsync(string Folder, string FileUploadName)
|
public async Task<bool> UploadFilesAsync(string Folder, string[] Files, string FileUploadName)
|
||||||
{
|
{
|
||||||
|
bool success = false;
|
||||||
var interop = new Interop(jsRuntime);
|
var interop = new Interop(jsRuntime);
|
||||||
await interop.UploadFiles(apiurl + "/upload", Folder, FileUploadName);
|
await interop.UploadFiles(apiurl + "/upload", Folder, FileUploadName);
|
||||||
|
List<string> files = await GetFilesAsync(Folder);
|
||||||
|
if (files.Count > 0)
|
||||||
|
{
|
||||||
|
success = true;
|
||||||
|
foreach (string file in Files)
|
||||||
|
{
|
||||||
|
if (!files.Contains(file))
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,10 @@ namespace Oqtane.Services
|
||||||
{
|
{
|
||||||
return await http.PostJsonAsync<GenericResponse>(apiurl, connectionstring);
|
return await http.PostJsonAsync<GenericResponse>(apiurl, connectionstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<GenericResponse> Upgrade()
|
||||||
|
{
|
||||||
|
return await http.GetJsonAsync<GenericResponse>(apiurl + "/upgrade");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace Oqtane.Services
|
||||||
{
|
{
|
||||||
public interface IFileService
|
public interface IFileService
|
||||||
{
|
{
|
||||||
Task UploadFilesAsync(string Folder);
|
Task<List<string>> GetFilesAsync(string Folder);
|
||||||
Task UploadFilesAsync(string Folder, string FileUploadName);
|
Task<bool> UploadFilesAsync(string Folder, string[] Files, string FileUploadName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Oqtane.Services
|
namespace Oqtane.Services
|
||||||
|
@ -8,5 +7,6 @@ namespace Oqtane.Services
|
||||||
{
|
{
|
||||||
Task<GenericResponse> IsInstalled();
|
Task<GenericResponse> IsInstalled();
|
||||||
Task<GenericResponse> Install(string connectionstring);
|
Task<GenericResponse> Install(string connectionstring);
|
||||||
|
Task<GenericResponse> Upgrade();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,5 +12,7 @@ namespace Oqtane.Services
|
||||||
Task<Module> AddModuleAsync(Module Module);
|
Task<Module> AddModuleAsync(Module Module);
|
||||||
Task<Module> UpdateModuleAsync(Module Module);
|
Task<Module> UpdateModuleAsync(Module Module);
|
||||||
Task DeleteModuleAsync(int ModuleId);
|
Task DeleteModuleAsync(int ModuleId);
|
||||||
|
Task<bool> ImportModuleAsync(int ModuleId, string Content);
|
||||||
|
Task<string> ExportModuleAsync(int ModuleId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,5 +60,15 @@ namespace Oqtane.Services
|
||||||
{
|
{
|
||||||
await http.DeleteAsync(apiurl + "/" + ModuleId.ToString());
|
await http.DeleteAsync(apiurl + "/" + ModuleId.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> ImportModuleAsync(int ModuleId, string Content)
|
||||||
|
{
|
||||||
|
return await http.PostJsonAsync<bool>(apiurl + "/import?moduleid=" + ModuleId, Content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string> ExportModuleAsync(int ModuleId)
|
||||||
|
{
|
||||||
|
return await http.GetStringAsync(apiurl + "/export?moduleid=" + ModuleId.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@
|
||||||
private string DatabaseType = "LocalDB";
|
private string DatabaseType = "LocalDB";
|
||||||
private string ServerName = "(LocalDb)\\MSSQLLocalDB";
|
private string ServerName = "(LocalDb)\\MSSQLLocalDB";
|
||||||
private string DatabaseName = "Oqtane-" + DateTime.Now.ToString("yyyyMMddHHmm");
|
private string DatabaseName = "Oqtane-" + DateTime.Now.ToString("yyyyMMddHHmm");
|
||||||
private string Username = "";
|
private string Username = "host";
|
||||||
private string Password = "";
|
private string Password = "";
|
||||||
private string HostUsername = "";
|
private string HostUsername = "";
|
||||||
private string HostPassword = "";
|
private string HostPassword = "";
|
||||||
|
@ -146,7 +146,7 @@
|
||||||
|
|
||||||
private async Task Install()
|
private async Task Install()
|
||||||
{
|
{
|
||||||
if (HostPassword.Length >= 6)
|
if (HostUsername != "" & HostPassword.Length >= 6 & HostEmail != "")
|
||||||
{
|
{
|
||||||
LoadingDisplay = "";
|
LoadingDisplay = "";
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
@ -197,7 +197,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Message = "<div class=\"alert alert-danger\" role=\"alert\">Password Must Be 6 Characters Or Greater</div>";
|
Message = "<div class=\"alert alert-danger\" role=\"alert\">Username And Email Must Be Provided And Password Must Be Greater Than 5 Characters</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,20 @@ namespace Oqtane.Shared
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ValueTask<string[]> GetFiles(string name)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return jsRuntime.InvokeAsync<string[]>(
|
||||||
|
"interop.getFiles",
|
||||||
|
name);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return new ValueTask<string[]>(Task.FromResult(new string[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Task UploadFiles(string posturl, string folder, string name)
|
public Task UploadFiles(string posturl, string folder, string name)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -21,10 +21,12 @@
|
||||||
DynamicComponent = builder =>
|
DynamicComponent = builder =>
|
||||||
{
|
{
|
||||||
string typename = ModuleState.ModuleType;
|
string typename = ModuleState.ModuleType;
|
||||||
if (PageState.Control == "Settings") // module settings are a core component
|
// check for core module actions component
|
||||||
{
|
if (Constants.DefaultModuleActions.Contains(PageState.Control))
|
||||||
typename = Constants.DefaultSettingsControl;
|
{
|
||||||
|
typename = Constants.DefaultModuleActionsTemplate.Replace("{Control}", PageState.Control);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type moduleType = null;
|
Type moduleType = null;
|
||||||
if (typename != null)
|
if (typename != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,21 +40,22 @@
|
||||||
{
|
{
|
||||||
if (PageState.ModuleId != -1 && PageState.Control != "")
|
if (PageState.ModuleId != -1 && PageState.Control != "")
|
||||||
{
|
{
|
||||||
if (Name == Constants.AdminPane)
|
if (Name.ToLower() == Constants.AdminPane.ToLower())
|
||||||
{
|
{
|
||||||
Module module = PageState.Modules.Where(item => item.ModuleId == PageState.ModuleId).FirstOrDefault();
|
Module module = PageState.Modules.Where(item => item.ModuleId == PageState.ModuleId).FirstOrDefault();
|
||||||
if (module != null)
|
if (module != null)
|
||||||
{
|
{
|
||||||
string typename = module.ModuleType;
|
string typename = module.ModuleType;
|
||||||
if (PageState.Control == "Settings")
|
// check for core module actions component
|
||||||
|
if (Constants.DefaultModuleActions.Contains(PageState.Control))
|
||||||
{
|
{
|
||||||
typename = Constants.DefaultSettingsControl;
|
typename = Constants.DefaultModuleActionsTemplate.Replace("{Control}", PageState.Control);
|
||||||
}
|
}
|
||||||
Type moduleType = Type.GetType(typename);
|
Type moduleType = Type.GetType(typename);
|
||||||
if (moduleType != null)
|
if (moduleType != null)
|
||||||
{
|
{
|
||||||
bool authorized = false;
|
bool authorized = false;
|
||||||
if (PageState.Control == "Settings")
|
if (Constants.DefaultModuleActions.Contains(PageState.Control))
|
||||||
{
|
{
|
||||||
authorized = UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions);
|
authorized = UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +83,7 @@
|
||||||
}
|
}
|
||||||
if (authorized)
|
if (authorized)
|
||||||
{
|
{
|
||||||
if (PageState.Control != "Settings" && module.ControlTitle != "")
|
if (!Constants.DefaultModuleActions.Contains(PageState.Control) && module.ControlTitle != "")
|
||||||
{
|
{
|
||||||
module.Title = module.ControlTitle;
|
module.Title = module.ControlTitle;
|
||||||
}
|
}
|
||||||
|
@ -93,8 +94,8 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// module control does not exist with name specified
|
// module control does not exist with name specified
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,10 +104,10 @@
|
||||||
if (PageState.ModuleId != -1)
|
if (PageState.ModuleId != -1)
|
||||||
{
|
{
|
||||||
Module module = PageState.Modules.Where(item => item.ModuleId == PageState.ModuleId).FirstOrDefault();
|
Module module = PageState.Modules.Where(item => item.ModuleId == PageState.ModuleId).FirstOrDefault();
|
||||||
if (module != null && module.Pane == Name)
|
if (module != null && module.Pane.ToLower() == Name.ToLower())
|
||||||
{
|
{
|
||||||
// check if user is authorized to view module
|
// check if user is authorized to view module
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, "View", module.Permissions))
|
if (UserSecurity.IsAuthorized(PageState.User, "View", module.Permissions))
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, Type.GetType(Constants.DefaultContainer));
|
builder.OpenComponent(0, Type.GetType(Constants.DefaultContainer));
|
||||||
builder.AddAttribute(1, "Module", module);
|
builder.AddAttribute(1, "Module", module);
|
||||||
|
@ -116,10 +117,10 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (Module module in PageState.Modules.Where(item => item.Pane == Name).OrderBy(x => x.Order).ToArray())
|
foreach (Module module in PageState.Modules.Where(item => item.Pane.ToLower() == Name.ToLower()).OrderBy(x => x.Order).ToArray())
|
||||||
{
|
{
|
||||||
// check if user is authorized to view module
|
// check if user is authorized to view module
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, "View", module.Permissions))
|
if (UserSecurity.IsAuthorized(PageState.User, "View", module.Permissions))
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, Type.GetType(Constants.DefaultContainer));
|
builder.OpenComponent(0, Type.GetType(Constants.DefaultContainer));
|
||||||
builder.AddAttribute(1, "Module", module);
|
builder.AddAttribute(1, "Module", module);
|
||||||
|
|
|
@ -342,9 +342,10 @@
|
||||||
|
|
||||||
// get IModuleControl properties
|
// get IModuleControl properties
|
||||||
typename = module.ModuleType;
|
typename = module.ModuleType;
|
||||||
if (control == "Settings")
|
// check for core module actions component
|
||||||
|
if (Constants.DefaultModuleActions.Contains(control))
|
||||||
{
|
{
|
||||||
typename = Constants.DefaultSettingsControl;
|
typename = Constants.DefaultModuleActionsTemplate.Replace("{Control}", control);
|
||||||
}
|
}
|
||||||
Type moduletype = Type.GetType(typename);
|
Type moduletype = Type.GetType(typename);
|
||||||
if (moduletype != null)
|
if (moduletype != null)
|
||||||
|
@ -358,7 +359,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure module's pane exists in current page and if not, assign it to the Admin pane
|
// ensure module's pane exists in current page and if not, assign it to the Admin pane
|
||||||
if (!panes.Contains(module.Pane))
|
if (!panes.ToLower().Contains(module.Pane.ToLower()))
|
||||||
{
|
{
|
||||||
module.Pane = Constants.AdminPane;
|
module.Pane = Constants.AdminPane;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,18 @@ namespace Oqtane.Shared
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetTypeName(string fullyqualifiedtypename)
|
||||||
|
{
|
||||||
|
if (fullyqualifiedtypename.Contains(","))
|
||||||
|
{
|
||||||
|
return fullyqualifiedtypename.Substring(0, fullyqualifiedtypename.IndexOf(","));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return fullyqualifiedtypename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetTypeNameClass(string typename)
|
public static string GetTypeNameClass(string typename)
|
||||||
{
|
{
|
||||||
if (typename.Contains(","))
|
if (typename.Contains(","))
|
||||||
|
|
|
@ -3,6 +3,7 @@ using Microsoft.JSInterop;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Oqtane.Themes
|
namespace Oqtane.Themes
|
||||||
{
|
{
|
||||||
|
@ -17,6 +18,14 @@ namespace Oqtane.Themes
|
||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
protected Module ModuleState { get; set; }
|
protected Module ModuleState { get; set; }
|
||||||
|
|
||||||
|
protected ModuleDefinition ModuleDefinition
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return PageState.ModuleDefinitions.Where(item => item.ModuleDefinitionName == ModuleState.ModuleDefinitionName).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual string Name { get; set; }
|
public virtual string Name { get; set; }
|
||||||
|
|
||||||
public string ThemePath()
|
public string ThemePath()
|
||||||
|
|
|
@ -48,8 +48,13 @@
|
||||||
actions.Add(new ActionViewModel { Action = pane, Name = "Move To " + pane + " Pane" });
|
actions.Add(new ActionViewModel { Action = pane, Name = "Move To " + pane + " Pane" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actions.Add(new ActionViewModel { Action = "settings", Name = "Settings" });
|
actions.Add(new ActionViewModel { Action = "settings", Name = "Manage Settings" });
|
||||||
actions.Add(new ActionViewModel { Action = "delete", Name = "Delete" });
|
if (ModuleDefinition.ServerAssemblyName != "")
|
||||||
|
{
|
||||||
|
actions.Add(new ActionViewModel { Action = "import", Name = "Import Content" });
|
||||||
|
actions.Add(new ActionViewModel { Action = "export", Name = "Export Content" });
|
||||||
|
}
|
||||||
|
actions.Add(new ActionViewModel { Action = "delete", Name = "Delete Module" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +90,12 @@
|
||||||
case "settings":
|
case "settings":
|
||||||
url = EditUrl(pagemodule.ModuleId, "Settings");
|
url = EditUrl(pagemodule.ModuleId, "Settings");
|
||||||
break;
|
break;
|
||||||
|
case "import":
|
||||||
|
url = EditUrl(pagemodule.ModuleId, "Import");
|
||||||
|
break;
|
||||||
|
case "export":
|
||||||
|
url = EditUrl(pagemodule.ModuleId, "Export");
|
||||||
|
break;
|
||||||
case "delete":
|
case "delete":
|
||||||
await PageModuleService.DeletePageModuleAsync(pagemodule.PageModuleId);
|
await PageModuleService.DeletePageModuleAsync(pagemodule.PageModuleId);
|
||||||
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
protected override Task OnParametersSetAsync()
|
protected override Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
title = ModuleState.Title;
|
title = ModuleState.Title;
|
||||||
if (PageState.Control == "Settings")
|
// check for core module actions component
|
||||||
|
if (Constants.DefaultModuleActions.Contains(PageState.Control))
|
||||||
{
|
{
|
||||||
title = PageState.Control;
|
title = PageState.Control;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,16 @@ window.interop = {
|
||||||
document.body.appendChild(form);
|
document.body.appendChild(form);
|
||||||
form.submit();
|
form.submit();
|
||||||
},
|
},
|
||||||
|
getFiles: function (name) {
|
||||||
|
var files = [];
|
||||||
|
var fileinput = document.getElementById(name);
|
||||||
|
if (fileinput !== null) {
|
||||||
|
for (var i = 0; i < fileinput.files.length; i++) {
|
||||||
|
files.push(fileinput.files[i].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
},
|
||||||
uploadFiles: function (posturl, folder, name) {
|
uploadFiles: function (posturl, folder, name) {
|
||||||
var files = document.getElementById(name + 'FileInput').files;
|
var files = document.getElementById(name + 'FileInput').files;
|
||||||
var progressinfo = document.getElementById(name + 'ProgressInfo');
|
var progressinfo = document.getElementById(name + 'ProgressInfo');
|
||||||
|
|
|
@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||||
using Oqtane.Repository;
|
using Oqtane.Repository;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -17,7 +18,25 @@ namespace Oqtane.Controllers
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET api/<controller>/current
|
// GET: api/<controller>?folder=x
|
||||||
|
[HttpGet]
|
||||||
|
public IEnumerable<string> Get(string folder)
|
||||||
|
{
|
||||||
|
List<string> files = new List<string>();
|
||||||
|
folder = folder.Replace("/", "\\");
|
||||||
|
if (folder.StartsWith("\\")) folder = folder.Substring(1);
|
||||||
|
folder = Path.Combine(environment.WebRootPath, folder);
|
||||||
|
if (Directory.Exists(folder))
|
||||||
|
{
|
||||||
|
foreach(string file in Directory.GetFiles(folder))
|
||||||
|
{
|
||||||
|
files.Add(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST api/<controller>/upload
|
||||||
[HttpPost("upload")]
|
[HttpPost("upload")]
|
||||||
public async Task UploadFile(string folder, IFormFile file)
|
public async Task UploadFile(string folder, IFormFile file)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
using DbUp;
|
using DbUp;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Oqtane.Infrastructure;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
using Oqtane.Shared;
|
||||||
using System;
|
using System;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -17,28 +20,41 @@ namespace Oqtane.Controllers
|
||||||
public class InstallationController : Controller
|
public class InstallationController : Controller
|
||||||
{
|
{
|
||||||
private readonly IConfigurationRoot Config;
|
private readonly IConfigurationRoot Config;
|
||||||
|
private readonly IInstallationManager InstallationManager;
|
||||||
|
|
||||||
public InstallationController(IConfigurationRoot Config)
|
public InstallationController(IConfigurationRoot Config, IInstallationManager InstallationManager)
|
||||||
{
|
{
|
||||||
this.Config = Config;
|
this.Config = Config;
|
||||||
|
this.InstallationManager = InstallationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public GenericResponse Post([FromBody] string connectionString)
|
public GenericResponse Post([FromBody] string connectionstring)
|
||||||
{
|
{
|
||||||
var response = new GenericResponse { Success = false, Message = "" };
|
var response = new GenericResponse { Success = false, Message = "" };
|
||||||
|
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
bool exists = IsInstalled().Success;
|
bool master = false;
|
||||||
|
string defaultconnectionstring = Config.GetConnectionString("DefaultConnection");
|
||||||
|
if (string.IsNullOrEmpty(defaultconnectionstring) || connectionstring != defaultconnectionstring)
|
||||||
|
{
|
||||||
|
master = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool exists = false;
|
||||||
|
if (master)
|
||||||
|
{
|
||||||
|
exists = IsInstalled().Success;
|
||||||
|
}
|
||||||
|
|
||||||
if (!exists)
|
if (!exists)
|
||||||
{
|
{
|
||||||
string datadirectory = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
|
string datadirectory = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
|
||||||
connectionString = connectionString.Replace("|DataDirectory|", datadirectory);
|
connectionstring = connectionstring.Replace("|DataDirectory|", datadirectory);
|
||||||
|
|
||||||
SqlConnection connection = new SqlConnection(connectionString);
|
SqlConnection connection = new SqlConnection(connectionstring);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (connection)
|
using (connection)
|
||||||
|
@ -57,7 +73,7 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
string masterConnectionString = "";
|
string masterConnectionString = "";
|
||||||
string databaseName = "";
|
string databaseName = "";
|
||||||
string[] fragments = connectionString.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
string[] fragments = connectionstring.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||||
foreach (string fragment in fragments)
|
foreach (string fragment in fragments)
|
||||||
{
|
{
|
||||||
if (fragment.ToLower().Contains("initial catalog=") || fragment.ToLower().Contains("database="))
|
if (fragment.ToLower().Contains("initial catalog=") || fragment.ToLower().Contains("database="))
|
||||||
|
@ -79,7 +95,7 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
connection.Open();
|
connection.Open();
|
||||||
SqlCommand command;
|
SqlCommand command;
|
||||||
if (connectionString.ToLower().Contains("attachdbfilename=")) // LocalDB
|
if (connectionstring.ToLower().Contains("attachdbfilename=")) // LocalDB
|
||||||
{
|
{
|
||||||
command = new SqlCommand("CREATE DATABASE [" + databaseName + "] ON ( NAME = '" + databaseName + "', FILENAME = '" + datadirectory + "\\" + databaseName + ".mdf')", connection);
|
command = new SqlCommand("CREATE DATABASE [" + databaseName + "] ON ( NAME = '" + databaseName + "', FILENAME = '" + datadirectory + "\\" + databaseName + ".mdf')", connection);
|
||||||
}
|
}
|
||||||
|
@ -104,14 +120,17 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
// get master initialization script and update connectionstring and alias in seed data
|
// get master initialization script and update connectionstring and alias in seed data
|
||||||
string initializationScript = "";
|
string initializationScript = "";
|
||||||
using (StreamReader reader = new StreamReader(Directory.GetCurrentDirectory() + "\\Scripts\\Master.sql"))
|
if (master)
|
||||||
{
|
{
|
||||||
initializationScript = reader.ReadToEnd();
|
using (StreamReader reader = new StreamReader(Directory.GetCurrentDirectory() + "\\Scripts\\Master.sql"))
|
||||||
|
{
|
||||||
|
initializationScript = reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
initializationScript = initializationScript.Replace("{ConnectionString}", connectionstring);
|
||||||
|
initializationScript = initializationScript.Replace("{Alias}", HttpContext.Request.Host.Value);
|
||||||
}
|
}
|
||||||
initializationScript = initializationScript.Replace("{ConnectionString}", connectionString);
|
|
||||||
initializationScript = initializationScript.Replace("{Alias}", HttpContext.Request.Host.Value);
|
|
||||||
|
|
||||||
var dbUpgradeConfig = DeployChanges.To.SqlDatabase(connectionString)
|
var dbUpgradeConfig = DeployChanges.To.SqlDatabase(connectionstring)
|
||||||
.WithScript(new DbUp.Engine.SqlScript("Master.sql", initializationScript))
|
.WithScript(new DbUp.Engine.SqlScript("Master.sql", initializationScript))
|
||||||
.WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly()); // tenant scripts should be added to /Scripts folder as Embedded Resources
|
.WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly()); // tenant scripts should be added to /Scripts folder as Embedded Resources
|
||||||
var dbUpgrade = dbUpgradeConfig.Build();
|
var dbUpgrade = dbUpgradeConfig.Build();
|
||||||
|
@ -125,19 +144,22 @@ namespace Oqtane.Controllers
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// update appsettings
|
// update appsettings
|
||||||
string config = "";
|
if (master)
|
||||||
using (StreamReader reader = new StreamReader(Directory.GetCurrentDirectory() + "\\appsettings.json"))
|
|
||||||
{
|
{
|
||||||
config = reader.ReadToEnd();
|
string config = "";
|
||||||
|
using (StreamReader reader = new StreamReader(Directory.GetCurrentDirectory() + "\\appsettings.json"))
|
||||||
|
{
|
||||||
|
config = reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
connectionstring = connectionstring.Replace(datadirectory, "|DataDirectory|");
|
||||||
|
connectionstring = connectionstring.Replace(@"\", @"\\");
|
||||||
|
config = config.Replace("DefaultConnection\": \"", "DefaultConnection\": \"" + connectionstring);
|
||||||
|
using (StreamWriter writer = new StreamWriter(Directory.GetCurrentDirectory() + "\\appsettings.json"))
|
||||||
|
{
|
||||||
|
writer.WriteLine(config);
|
||||||
|
}
|
||||||
|
Config.Reload();
|
||||||
}
|
}
|
||||||
connectionString = connectionString.Replace(datadirectory, "|DataDirectory|");
|
|
||||||
connectionString = connectionString.Replace(@"\", @"\\");
|
|
||||||
config = config.Replace("DefaultConnection\": \"", "DefaultConnection\": \"" + connectionString);
|
|
||||||
using (StreamWriter writer = new StreamWriter(Directory.GetCurrentDirectory() + "\\appsettings.json"))
|
|
||||||
{
|
|
||||||
writer.WriteLine(config);
|
|
||||||
}
|
|
||||||
Config.Reload();
|
|
||||||
response.Success = true;
|
response.Success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,6 +257,15 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("upgrade")]
|
||||||
|
[Authorize(Roles = Constants.HostRole)]
|
||||||
|
public GenericResponse Upgrade()
|
||||||
|
{
|
||||||
|
var response = new GenericResponse { Success = true, Message = "" };
|
||||||
|
InstallationManager.InstallPackages("Framework");
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InstallationContext : DbContext
|
public class InstallationContext : DbContext
|
||||||
|
|
|
@ -4,6 +4,12 @@ using Microsoft.AspNetCore.Authorization;
|
||||||
using Oqtane.Repository;
|
using Oqtane.Repository;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System;
|
||||||
|
using Oqtane.Modules;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
|
@ -12,24 +18,28 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
private readonly IModuleRepository Modules;
|
private readonly IModuleRepository Modules;
|
||||||
private readonly IPageModuleRepository PageModules;
|
private readonly IPageModuleRepository PageModules;
|
||||||
|
private readonly IModuleDefinitionRepository ModuleDefinitions;
|
||||||
|
private readonly IServiceProvider ServiceProvider;
|
||||||
|
|
||||||
public ModuleController(IModuleRepository Modules, IPageModuleRepository PageModules)
|
public ModuleController(IModuleRepository Modules, IPageModuleRepository PageModules, IModuleDefinitionRepository ModuleDefinitions, IServiceProvider ServiceProvider)
|
||||||
{
|
{
|
||||||
this.Modules = Modules;
|
this.Modules = Modules;
|
||||||
this.PageModules = PageModules;
|
this.PageModules = PageModules;
|
||||||
|
this.ModuleDefinitions = ModuleDefinitions;
|
||||||
|
this.ServiceProvider = ServiceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/<controller>?pageid=x
|
// GET: api/<controller>?pageid=x
|
||||||
// GET: api/<controller>?siteid=x&moduledefinitionname=x
|
// GET: api/<controller>?siteid=x&moduledefinitionname=x
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IEnumerable<Module> Get(string pageid, string siteid, string moduledefinitionname)
|
public IEnumerable<Models.Module> Get(string pageid, string siteid, string moduledefinitionname)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(pageid))
|
if (!string.IsNullOrEmpty(pageid))
|
||||||
{
|
{
|
||||||
List<Module> modulelist = new List<Module>();
|
List<Models.Module> modulelist = new List<Models.Module>();
|
||||||
foreach (PageModule pagemodule in PageModules.GetPageModules(int.Parse(pageid)))
|
foreach (PageModule pagemodule in PageModules.GetPageModules(int.Parse(pageid)))
|
||||||
{
|
{
|
||||||
Module module = pagemodule.Module;
|
Models.Module module = pagemodule.Module;
|
||||||
module.PageModuleId = pagemodule.PageModuleId;
|
module.PageModuleId = pagemodule.PageModuleId;
|
||||||
module.PageId = pagemodule.PageId;
|
module.PageId = pagemodule.PageId;
|
||||||
module.Title = pagemodule.Title;
|
module.Title = pagemodule.Title;
|
||||||
|
@ -48,7 +58,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/5
|
// GET api/<controller>/5
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public Module Get(int id)
|
public Models.Module Get(int id)
|
||||||
{
|
{
|
||||||
return Modules.GetModule(id);
|
return Modules.GetModule(id);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +66,7 @@ namespace Oqtane.Controllers
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = Constants.AdminRole)]
|
||||||
public Module Post([FromBody] Module Module)
|
public Models.Module Post([FromBody] Models.Module Module)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
|
@ -68,7 +78,7 @@ namespace Oqtane.Controllers
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = Constants.AdminRole)]
|
||||||
public Module Put(int id, [FromBody] Module Module)
|
public Models.Module Put(int id, [FromBody] Models.Module Module)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
|
@ -84,5 +94,103 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
Modules.DeleteModule(id);
|
Modules.DeleteModule(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GET api/<controller>/export?moduleid=x
|
||||||
|
[HttpGet("export")]
|
||||||
|
[Authorize(Roles = Constants.AdminRole)]
|
||||||
|
public string Export(int moduleid)
|
||||||
|
{
|
||||||
|
string content = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Models.Module module = Modules.GetModule(moduleid);
|
||||||
|
if (module != null)
|
||||||
|
{
|
||||||
|
List<ModuleDefinition> moduledefinitions = ModuleDefinitions.GetModuleDefinitions(module.SiteId).ToList();
|
||||||
|
ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == module.ModuleDefinitionName).FirstOrDefault();
|
||||||
|
if (moduledefinition != null)
|
||||||
|
{
|
||||||
|
ModuleContent modulecontent = new ModuleContent();
|
||||||
|
modulecontent.ModuleDefinitionName = moduledefinition.ModuleDefinitionName;
|
||||||
|
modulecontent.Version = moduledefinition.Version;
|
||||||
|
modulecontent.Content = "";
|
||||||
|
|
||||||
|
if (moduledefinition.ServerAssemblyName != "")
|
||||||
|
{
|
||||||
|
Assembly assembly = AppDomain.CurrentDomain.GetAssemblies()
|
||||||
|
.Where(item => item.FullName.StartsWith(moduledefinition.ServerAssemblyName)).FirstOrDefault();
|
||||||
|
if (assembly != null)
|
||||||
|
{
|
||||||
|
Type moduletype = assembly.GetTypes()
|
||||||
|
.Where(item => item.Namespace != null)
|
||||||
|
.Where(item => item.Namespace.StartsWith(moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(","))))
|
||||||
|
.Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault();
|
||||||
|
if (moduletype != null)
|
||||||
|
{
|
||||||
|
var moduleobject = ActivatorUtilities.CreateInstance(ServiceProvider, moduletype);
|
||||||
|
modulecontent.Content = ((IPortable)moduleobject).ExportModule(module);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
content = JsonSerializer.Serialize(modulecontent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// error occurred during export
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST api/<controller>/import?moduleid=x
|
||||||
|
[HttpPost("import")]
|
||||||
|
[Authorize(Roles = Constants.AdminRole)]
|
||||||
|
public bool Import(int moduleid, [FromBody] string Content)
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
if (ModelState.IsValid)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Models.Module module = Modules.GetModule(moduleid);
|
||||||
|
if (module != null)
|
||||||
|
{
|
||||||
|
List<ModuleDefinition> moduledefinitions = ModuleDefinitions.GetModuleDefinitions(module.SiteId).ToList();
|
||||||
|
ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == module.ModuleDefinitionName).FirstOrDefault();
|
||||||
|
if (moduledefinition != null)
|
||||||
|
{
|
||||||
|
ModuleContent modulecontent = JsonSerializer.Deserialize<ModuleContent>(Content);
|
||||||
|
if (modulecontent.ModuleDefinitionName == moduledefinition.ModuleDefinitionName)
|
||||||
|
{
|
||||||
|
if (moduledefinition.ServerAssemblyName != "")
|
||||||
|
{
|
||||||
|
Assembly assembly = AppDomain.CurrentDomain.GetAssemblies()
|
||||||
|
.Where(item => item.FullName.StartsWith(moduledefinition.ServerAssemblyName)).FirstOrDefault();
|
||||||
|
if (assembly != null)
|
||||||
|
{
|
||||||
|
Type moduletype = assembly.GetTypes()
|
||||||
|
.Where(item => item.Namespace != null)
|
||||||
|
.Where(item => item.Namespace.StartsWith(moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(","))))
|
||||||
|
.Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault();
|
||||||
|
if (moduletype != null)
|
||||||
|
{
|
||||||
|
var moduleobject = ActivatorUtilities.CreateInstance(ServiceProvider, moduletype);
|
||||||
|
((IPortable)moduleobject).ImportModule(module, modulecontent.Content, modulecontent.Version);
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// error occurred during import
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ using System.Threading;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
|
@ -24,6 +26,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>?tag=x
|
// GET: api/<controller>?tag=x
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
[Authorize(Roles = Constants.HostRole)]
|
||||||
public async Task<IEnumerable<Package>> Get(string tag)
|
public async Task<IEnumerable<Package>> Get(string tag)
|
||||||
{
|
{
|
||||||
List<Package> packages = new List<Package>();
|
List<Package> packages = new List<Package>();
|
||||||
|
@ -52,6 +55,7 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
[Authorize(Roles = Constants.HostRole)]
|
||||||
public async Task Post(string packageid, string version, string folder)
|
public async Task Post(string packageid, string version, string folder)
|
||||||
{
|
{
|
||||||
using (var httpClient = new HttpClient())
|
using (var httpClient = new HttpClient())
|
||||||
|
|
|
@ -45,11 +45,12 @@ namespace Oqtane.Infrastructure
|
||||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||||
{
|
{
|
||||||
string filename = Path.GetFileName(entry.FullName);
|
string filename = Path.GetFileName(entry.FullName);
|
||||||
switch (Path.GetExtension(filename))
|
switch (Path.GetExtension(filename).ToLower())
|
||||||
{
|
{
|
||||||
case ".dll":
|
case ".dll":
|
||||||
entry.ExtractToFile(Path.Combine(binfolder, filename), true);
|
entry.ExtractToFile(Path.Combine(binfolder, filename), true);
|
||||||
break;
|
break;
|
||||||
|
case ".nuspec":
|
||||||
case ".png":
|
case ".png":
|
||||||
case ".jpg":
|
case ".jpg":
|
||||||
case ".jpeg":
|
case ".jpeg":
|
||||||
|
|
46
Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs
Normal file
46
Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using Oqtane.Modules.HtmlText.Models;
|
||||||
|
using Oqtane.Modules.HtmlText.Repository;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace Oqtane.Modules.HtmlText.Manager
|
||||||
|
{
|
||||||
|
public class HtmlTextManager : IPortable
|
||||||
|
{
|
||||||
|
private IHtmlTextRepository htmltexts;
|
||||||
|
|
||||||
|
public HtmlTextManager(IHtmlTextRepository htmltexts)
|
||||||
|
{
|
||||||
|
this.htmltexts = htmltexts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ExportModule(Module Module)
|
||||||
|
{
|
||||||
|
string content = "";
|
||||||
|
HtmlTextInfo htmltext = htmltexts.GetHtmlText(Module.ModuleId);
|
||||||
|
if (htmltext != null)
|
||||||
|
{
|
||||||
|
content = WebUtility.HtmlEncode(htmltext.Content);
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ImportModule(Module Module, string Content, string Version)
|
||||||
|
{
|
||||||
|
Content = WebUtility.HtmlDecode(Content);
|
||||||
|
HtmlTextInfo htmltext = htmltexts.GetHtmlText(Module.ModuleId);
|
||||||
|
if (htmltext != null)
|
||||||
|
{
|
||||||
|
htmltext.Content = Content;
|
||||||
|
htmltexts.UpdateHtmlText(htmltext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
htmltext = new HtmlTextInfo();
|
||||||
|
htmltext.ModuleId = Module.ModuleId;
|
||||||
|
htmltext.Content = Content;
|
||||||
|
htmltexts.AddHtmlText(htmltext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
Oqtane.Server/Modules/IPortable.cs
Normal file
13
Oqtane.Server/Modules/IPortable.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
|
||||||
|
namespace Oqtane.Modules
|
||||||
|
{
|
||||||
|
public interface IPortable
|
||||||
|
{
|
||||||
|
// You Must Set The "ServerAssemblyName" In Your IModule Interface
|
||||||
|
|
||||||
|
string ExportModule(Module Module);
|
||||||
|
|
||||||
|
void ImportModule(Module Module, string Content, string Version);
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
db.Alias.Add(Alias);
|
db.Alias.Add(Alias);
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
|
_cache.Remove("aliases");
|
||||||
return Alias;
|
return Alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
db.Entry(Alias).State = EntityState.Modified;
|
db.Entry(Alias).State = EntityState.Modified;
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
|
_cache.Remove("aliases");
|
||||||
return Alias;
|
return Alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +52,7 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
Alias alias = db.Alias.Find(AliasId);
|
Alias alias = db.Alias.Find(AliasId);
|
||||||
db.Alias.Remove(alias);
|
db.Alias.Remove(alias);
|
||||||
|
_cache.Remove("aliases");
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,31 +5,32 @@ using Oqtane.Models;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System;
|
using System;
|
||||||
using Oqtane.Modules;
|
using Oqtane.Modules;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
|
||||||
namespace Oqtane.Repository
|
namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
public class ModuleDefinitionRepository : IModuleDefinitionRepository
|
public class ModuleDefinitionRepository : IModuleDefinitionRepository
|
||||||
{
|
{
|
||||||
private MasterDBContext db;
|
private MasterDBContext db;
|
||||||
|
private readonly IMemoryCache _cache;
|
||||||
private readonly IPermissionRepository Permissions;
|
private readonly IPermissionRepository Permissions;
|
||||||
|
|
||||||
public ModuleDefinitionRepository(MasterDBContext context, IPermissionRepository Permissions)
|
public ModuleDefinitionRepository(MasterDBContext context, IMemoryCache cache, IPermissionRepository Permissions)
|
||||||
{
|
{
|
||||||
db = context;
|
db = context;
|
||||||
|
_cache = cache;
|
||||||
this.Permissions = Permissions;
|
this.Permissions = Permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ModuleDefinition> LoadModuleDefinitions(int SiteId)
|
private List<ModuleDefinition> LoadModuleDefinitions(int SiteId)
|
||||||
{
|
{
|
||||||
List<ModuleDefinition> ModuleDefinitions = new List<ModuleDefinition>();
|
List<ModuleDefinition> ModuleDefinitions;
|
||||||
|
|
||||||
// iterate through Oqtane module assemblies
|
ModuleDefinitions = _cache.GetOrCreate("moduledefinitions", entry =>
|
||||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies()
|
|
||||||
.Where(item => item.FullName.StartsWith("Oqtane.") || item.FullName.Contains(".Module.")).ToArray();
|
|
||||||
foreach (Assembly assembly in assemblies)
|
|
||||||
{
|
{
|
||||||
ModuleDefinitions = LoadModuleDefinitionsFromAssembly(ModuleDefinitions, assembly);
|
entry.SlidingExpiration = TimeSpan.FromMinutes(30);
|
||||||
}
|
return LoadModuleDefinitionsFromAssemblies();
|
||||||
|
});
|
||||||
|
|
||||||
// sync module definitions with database
|
// sync module definitions with database
|
||||||
List<ModuleDefinition> moduledefs = db.ModuleDefinition.ToList();
|
List<ModuleDefinition> moduledefs = db.ModuleDefinition.ToList();
|
||||||
|
@ -65,6 +66,19 @@ namespace Oqtane.Repository
|
||||||
return ModuleDefinitions;
|
return ModuleDefinitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<ModuleDefinition> LoadModuleDefinitionsFromAssemblies()
|
||||||
|
{
|
||||||
|
List<ModuleDefinition> ModuleDefinitions = new List<ModuleDefinition>();
|
||||||
|
// iterate through Oqtane module assemblies
|
||||||
|
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies()
|
||||||
|
.Where(item => item.FullName.StartsWith("Oqtane.") || item.FullName.Contains(".Module.")).ToArray();
|
||||||
|
foreach (Assembly assembly in assemblies)
|
||||||
|
{
|
||||||
|
ModuleDefinitions = LoadModuleDefinitionsFromAssembly(ModuleDefinitions, assembly);
|
||||||
|
}
|
||||||
|
return ModuleDefinitions;
|
||||||
|
}
|
||||||
|
|
||||||
private List<ModuleDefinition> LoadModuleDefinitionsFromAssembly(List<ModuleDefinition> moduledefinitions, Assembly assembly)
|
private List<ModuleDefinition> LoadModuleDefinitionsFromAssembly(List<ModuleDefinition> moduledefinitions, Assembly assembly)
|
||||||
{
|
{
|
||||||
ModuleDefinition moduledefinition;
|
ModuleDefinition moduledefinition;
|
||||||
|
@ -105,6 +119,7 @@ namespace Oqtane.Repository
|
||||||
License = GetProperty(properties, "License"),
|
License = GetProperty(properties, "License"),
|
||||||
Dependencies = GetProperty(properties, "Dependencies"),
|
Dependencies = GetProperty(properties, "Dependencies"),
|
||||||
PermissionNames = GetProperty(properties, "PermissionNames"),
|
PermissionNames = GetProperty(properties, "PermissionNames"),
|
||||||
|
ServerAssemblyName = GetProperty(properties, "ServerAssemblyName"),
|
||||||
ControlTypeTemplate = ModuleType + ".{Control}" + ", " + typename[1],
|
ControlTypeTemplate = ModuleType + ".{Control}" + ", " + typename[1],
|
||||||
ControlTypeRoutes = "",
|
ControlTypeRoutes = "",
|
||||||
AssemblyName = assembly.FullName.Split(",")[0]
|
AssemblyName = assembly.FullName.Split(",")[0]
|
||||||
|
@ -125,6 +140,7 @@ namespace Oqtane.Repository
|
||||||
License = "",
|
License = "",
|
||||||
Dependencies = "",
|
Dependencies = "",
|
||||||
PermissionNames = "",
|
PermissionNames = "",
|
||||||
|
ServerAssemblyName = "",
|
||||||
ControlTypeTemplate = ModuleType + ".{Control}" + ", " + typename[1],
|
ControlTypeTemplate = ModuleType + ".{Control}" + ", " + typename[1],
|
||||||
ControlTypeRoutes = "",
|
ControlTypeRoutes = "",
|
||||||
AssemblyName = assembly.FullName.Split(",")[0]
|
AssemblyName = assembly.FullName.Split(",")[0]
|
||||||
|
|
|
@ -4,6 +4,9 @@ using System.Linq;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using Oqtane.Modules;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Oqtane.Repository
|
namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
|
@ -15,9 +18,11 @@ namespace Oqtane.Repository
|
||||||
private readonly IPageRepository PageRepository;
|
private readonly IPageRepository PageRepository;
|
||||||
private readonly IModuleRepository ModuleRepository;
|
private readonly IModuleRepository ModuleRepository;
|
||||||
private readonly IPageModuleRepository PageModuleRepository;
|
private readonly IPageModuleRepository PageModuleRepository;
|
||||||
|
private readonly IModuleDefinitionRepository ModuleDefinitionRepository;
|
||||||
|
private readonly IServiceProvider ServiceProvider;
|
||||||
private readonly List<PageTemplate> SiteTemplate;
|
private readonly List<PageTemplate> SiteTemplate;
|
||||||
|
|
||||||
public SiteRepository(TenantDBContext context, IRoleRepository RoleRepository, IProfileRepository ProfileRepository, IPageRepository PageRepository, IModuleRepository ModuleRepository, IPageModuleRepository PageModuleRepository)
|
public SiteRepository(TenantDBContext context, IRoleRepository RoleRepository, IProfileRepository ProfileRepository, IPageRepository PageRepository, IModuleRepository ModuleRepository, IPageModuleRepository PageModuleRepository, IModuleDefinitionRepository ModuleDefinitionRepository, IServiceProvider ServiceProvider)
|
||||||
{
|
{
|
||||||
db = context;
|
db = context;
|
||||||
this.RoleRepository = RoleRepository;
|
this.RoleRepository = RoleRepository;
|
||||||
|
@ -25,33 +30,54 @@ namespace Oqtane.Repository
|
||||||
this.PageRepository = PageRepository;
|
this.PageRepository = PageRepository;
|
||||||
this.ModuleRepository = ModuleRepository;
|
this.ModuleRepository = ModuleRepository;
|
||||||
this.PageModuleRepository = PageModuleRepository;
|
this.PageModuleRepository = PageModuleRepository;
|
||||||
|
this.ModuleDefinitionRepository = ModuleDefinitionRepository;
|
||||||
|
this.ServiceProvider = ServiceProvider;
|
||||||
|
|
||||||
// defines the default site template
|
// define the default site template
|
||||||
SiteTemplate = new List<PageTemplate>();
|
SiteTemplate = new List<PageTemplate>();
|
||||||
SiteTemplate.Add(new PageTemplate { Name = "Home", Parent = "", Path = "", Order = 1, Icon = "home", IsNavigation = true, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
SiteTemplate.Add(new PageTemplate { Name = "Home", Parent = "", Path = "", Order = 1, Icon = "home", IsNavigation = true, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||||
ModuleDefinitionName = "", ModulePermissions = "", Title = "", Pane = "", ContainerType = "" });
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Welcome To Oqtane", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client",
|
||||||
SiteTemplate.Add(new PageTemplate { Name = "Admin", Parent = "", Path = "admin", Order = 1, Icon = "", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
Content = "<p><a href=\"https://www.oqtane.org\" target=\"_new\">Oqtane</a> is an open source <b>modular application framework</b> built from the ground up using modern .NET Core technology. It leverages the revolutionary new Blazor component model to create a <b>fully dynamic</b> web development experience which can be executed on a client or server. Whether you are looking for a platform to <b>accelerate your web development</b> efforts, or simply interested in exploring the anatomy of a large-scale Blazor application, Oqtane provides a solid foundation based on proven enterprise architectural principles.</p>" +
|
||||||
ModuleDefinitionName = "Oqtane.Modules.Admin.Dashboard, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Administration", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client" });
|
"<p align=\"center\"><a href=\"https://www.oqtane.org\" target=\"_new\"><img src=\"oqtane.png\"></a><br /><br /><a class=\"btn btn-primary\" href=\"https://www.oqtane.org/Community\" target=\"_new\">Join Our Community</a> <a class=\"btn btn-primary\" href=\"https://github.com/oqtane/oqtane.framework\" target=\"_new\">Clone Our Repo</a><br /><br /></p>" +
|
||||||
SiteTemplate.Add(new PageTemplate { Name = "Site Management", Parent = "Admin", Path = "admin/sites", Order = 1, Icon = "globe", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
"<p><a href=\"https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor\" target=\"_new\">Blazor</a> is a single-page app framework that lets you build interactive web applications using C# instead of JavaScript. Client-side Blazor relies on WebAssembly, an open web standard that does not require plugins or code transpilation in order to run natively in a web browser. Server-side Blazor uses SignalR to host your application on a web server and provide a responsive and robust debugging experience. Blazor applications works in all modern web browsers, including mobile browsers.</p>" +
|
||||||
ModuleDefinitionName = "Oqtane.Modules.Admin.Sites, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Site Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client" });
|
"<p>Blazor is a feature of<a href=\"https://dotnet.microsoft.com/apps/aspnet\" target=\"_new\">ASP.NET Core 3.0</a>, the popular cross platform web development framework from Microsoft that extends the <a href=\"https://dotnet.microsoft.com/learn/dotnet/what-is-dotnet\" target=\"_new\" >.NET developer platform</a> with tools and libraries for building web apps.</p>" }
|
||||||
SiteTemplate.Add(new PageTemplate { Name = "Page Management", Parent = "Admin", Path = "admin/pages", Order = 1, Icon = "layers", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
}});
|
||||||
ModuleDefinitionName = "Oqtane.Modules.Admin.Pages, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Page Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client" });
|
SiteTemplate.Add(new PageTemplate { Name = "Admin", Parent = "", Path = "admin", Order = 1, Icon = "", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||||
SiteTemplate.Add(new PageTemplate { Name = "Module Management", Parent = "Admin", Path = "admin/modules", Order = 1, Icon = "browser", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Dashboard, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Administration", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client", Content = "" }
|
||||||
ModuleDefinitionName = "Oqtane.Modules.Admin.ModuleDefinitions, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Module Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client" });
|
}});
|
||||||
SiteTemplate.Add(new PageTemplate { Name = "Theme Management", Parent = "Admin", Path = "admin/themes", Order = 1, Icon = "brush", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
SiteTemplate.Add(new PageTemplate { Name = "Site Management", Parent = "Admin", Path = "admin/sites", Order = 1, Icon = "globe", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||||
ModuleDefinitionName = "Oqtane.Modules.Admin.Themes, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Theme Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client" });
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Sites, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Site Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client", Content = "" }
|
||||||
SiteTemplate.Add(new PageTemplate { Name = "User Management", Parent = "Admin", Path = "admin/users", Order = 1, Icon = "person", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
}});
|
||||||
ModuleDefinitionName = "Oqtane.Modules.Admin.Users, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "User Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client" });
|
SiteTemplate.Add(new PageTemplate { Name = "Page Management", Parent = "Admin", Path = "admin/pages", Order = 1, Icon = "layers", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||||
SiteTemplate.Add(new PageTemplate { Name = "Role Management", Parent = "Admin", Path = "admin/roles", Order = 1, Icon = "lock-locked", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Pages, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Page Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client", Content = "" }
|
||||||
ModuleDefinitionName = "Oqtane.Modules.Admin.Roles, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Role Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client" });
|
}});
|
||||||
SiteTemplate.Add(new PageTemplate { Name = "Tenant Management", Parent = "Admin", Path = "admin/tenants", Order = 1, Icon = "list", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
SiteTemplate.Add(new PageTemplate { Name = "Module Management", Parent = "Admin", Path = "admin/modules", Order = 1, Icon = "browser", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||||
ModuleDefinitionName = "Oqtane.Modules.Admin.Tenants, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Site Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client" });
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.ModuleDefinitions, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Module Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client", Content = "" }
|
||||||
SiteTemplate.Add(new PageTemplate { Name = "Login", Parent = "", Path = "login", Order = 1, Icon = "lock-locked", IsNavigation = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
}});
|
||||||
ModuleDefinitionName = "Oqtane.Modules.Admin.Login, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Login", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client" });
|
SiteTemplate.Add(new PageTemplate { Name = "Theme Management", Parent = "Admin", Path = "admin/themes", Order = 1, Icon = "brush", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||||
SiteTemplate.Add(new PageTemplate { Name = "Register", Parent = "", Path = "register", Order = 1, Icon = "person", IsNavigation = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Themes, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Theme Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client", Content = "" }
|
||||||
ModuleDefinitionName = "Oqtane.Modules.Admin.Register, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Register", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client" });
|
}});
|
||||||
SiteTemplate.Add(new PageTemplate { Name = "Profile", Parent = "", Path = "profile", Order = 1, Icon = "person", IsNavigation = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
SiteTemplate.Add(new PageTemplate { Name = "User Management", Parent = "Admin", Path = "admin/users", Order = 1, Icon = "person", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||||
ModuleDefinitionName = "Oqtane.Modules.Admin.Profile, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "User Profile", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client" });
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Users, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "User Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client", Content = "" }
|
||||||
|
}});
|
||||||
|
SiteTemplate.Add(new PageTemplate { Name = "Role Management", Parent = "Admin", Path = "admin/roles", Order = 1, Icon = "lock-locked", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||||
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Roles, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Role Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client", Content = "" }
|
||||||
|
}});
|
||||||
|
SiteTemplate.Add(new PageTemplate { Name = "Tenant Management", Parent = "Admin", Path = "admin/tenants", Order = 1, Icon = "list", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||||
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Tenants, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Upgrade", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client", Content = "" }
|
||||||
|
}});
|
||||||
|
SiteTemplate.Add(new PageTemplate { Name = "Upgrade", Parent = "Admin", Path = "admin/upgrade", Order = 1, Icon = "aperture", IsNavigation = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||||
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Upgrade, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Site Management", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client", Content = "" }
|
||||||
|
}});
|
||||||
|
SiteTemplate.Add(new PageTemplate { Name = "Login", Parent = "", Path = "login", Order = 1, Icon = "lock-locked", IsNavigation = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||||
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Login, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Login", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client", Content = "" }
|
||||||
|
}});
|
||||||
|
SiteTemplate.Add(new PageTemplate { Name = "Register", Parent = "", Path = "register", Order = 1, Icon = "person", IsNavigation = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||||
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Register, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "Register", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client", Content = "" }
|
||||||
|
}});
|
||||||
|
SiteTemplate.Add(new PageTemplate { Name = "Profile", Parent = "", Path = "profile", Order = 1, Icon = "person", IsNavigation = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||||
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Profile, Oqtane.Client", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Title = "User Profile", Pane = "top", ContainerType = "Oqtane.Themes.Theme2.Container2, Oqtane.Client", Content = "" }
|
||||||
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Site> GetSites()
|
public IEnumerable<Site> GetSites()
|
||||||
|
@ -110,6 +136,7 @@ namespace Oqtane.Repository
|
||||||
ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "PostalCode", Title = "Postal Code", Description = "Postal Code Or Zip Code", Category = "Address", ViewOrder = 7, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "PostalCode", Title = "Postal Code", Description = "Postal Code Or Zip Code", Category = "Address", ViewOrder = 7, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||||
ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Phone", Title = "Phone Number", Description = "Phone Number", Category = "Contact", ViewOrder = 8, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Phone", Title = "Phone Number", Description = "Phone Number", Category = "Contact", ViewOrder = 8, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||||
|
|
||||||
|
List<ModuleDefinition> moduledefinitions = ModuleDefinitionRepository.GetModuleDefinitions(site.SiteId).ToList();
|
||||||
foreach (PageTemplate pagetemplate in SiteTemplate)
|
foreach (PageTemplate pagetemplate in SiteTemplate)
|
||||||
{
|
{
|
||||||
int? parentid = null;
|
int? parentid = null;
|
||||||
|
@ -139,26 +166,52 @@ namespace Oqtane.Repository
|
||||||
page.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
page.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
||||||
page = PageRepository.AddPage(page);
|
page = PageRepository.AddPage(page);
|
||||||
|
|
||||||
if (pagetemplate.ModuleDefinitionName != "")
|
foreach(PageTemplateModule pagetemplatemodule in pagetemplate.PageTemplateModules)
|
||||||
{
|
{
|
||||||
Module module = new Module
|
if (pagetemplatemodule.ModuleDefinitionName != "")
|
||||||
{
|
{
|
||||||
SiteId = site.SiteId,
|
ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == pagetemplatemodule.ModuleDefinitionName).FirstOrDefault();
|
||||||
ModuleDefinitionName = pagetemplate.ModuleDefinitionName,
|
if (moduledefinition != null)
|
||||||
Permissions = pagetemplate.ModulePermissions,
|
{
|
||||||
};
|
Models.Module module = new Models.Module
|
||||||
module = ModuleRepository.AddModule(module);
|
{
|
||||||
|
SiteId = site.SiteId,
|
||||||
|
ModuleDefinitionName = pagetemplatemodule.ModuleDefinitionName,
|
||||||
|
Permissions = pagetemplatemodule.ModulePermissions,
|
||||||
|
};
|
||||||
|
module = ModuleRepository.AddModule(module);
|
||||||
|
|
||||||
PageModule pagemodule = new PageModule
|
if (pagetemplatemodule.Content != "" && moduledefinition.ServerAssemblyName != "")
|
||||||
{
|
{
|
||||||
PageId = page.PageId,
|
Assembly assembly = AppDomain.CurrentDomain.GetAssemblies()
|
||||||
ModuleId = module.ModuleId,
|
.Where(item => item.FullName.StartsWith(moduledefinition.ServerAssemblyName)).FirstOrDefault();
|
||||||
Title = pagetemplate.Title,
|
if (assembly != null)
|
||||||
Pane = pagetemplate.Pane,
|
{
|
||||||
Order = 1,
|
Type moduletype = assembly.GetTypes()
|
||||||
ContainerType = pagetemplate.ContainerType
|
.Where(item => item.Namespace != null)
|
||||||
};
|
.Where(item => item.Namespace.StartsWith(moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(","))))
|
||||||
PageModuleRepository.AddPageModule(pagemodule);
|
.Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault();
|
||||||
|
if (moduletype != null)
|
||||||
|
{
|
||||||
|
var moduleobject = ActivatorUtilities.CreateInstance(ServiceProvider, moduletype);
|
||||||
|
((IPortable)moduleobject).ImportModule(module, pagetemplatemodule.Content, moduledefinition.Version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PageModule pagemodule = new PageModule
|
||||||
|
{
|
||||||
|
PageId = page.PageId,
|
||||||
|
ModuleId = module.ModuleId,
|
||||||
|
Title = pagetemplatemodule.Title,
|
||||||
|
Pane = pagetemplatemodule.Pane,
|
||||||
|
Order = 1,
|
||||||
|
ContainerType = pagetemplatemodule.ContainerType
|
||||||
|
};
|
||||||
|
PageModuleRepository.AddPageModule(pagemodule);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
db.Tenant.Add(Tenant);
|
db.Tenant.Add(Tenant);
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
|
_cache.Remove("tenants");
|
||||||
return Tenant;
|
return Tenant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
db.Entry(Tenant).State = EntityState.Modified;
|
db.Entry(Tenant).State = EntityState.Modified;
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
|
_cache.Remove("tenants");
|
||||||
return Tenant;
|
return Tenant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +54,7 @@ namespace Oqtane.Repository
|
||||||
Tenant tenant = db.Tenant.Find(TenantId);
|
Tenant tenant = db.Tenant.Find(TenantId);
|
||||||
db.Tenant.Remove(tenant);
|
db.Tenant.Remove(tenant);
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
|
_cache.Remove("tenants");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,16 @@ window.interop = {
|
||||||
document.body.appendChild(form);
|
document.body.appendChild(form);
|
||||||
form.submit();
|
form.submit();
|
||||||
},
|
},
|
||||||
|
getFiles: function (name) {
|
||||||
|
var files = [];
|
||||||
|
var fileinput = document.getElementById(name);
|
||||||
|
if (fileinput !== null) {
|
||||||
|
for (var i = 0; i < fileinput.files.length; i++) {
|
||||||
|
files.push(fileinput.files[i].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
},
|
||||||
uploadFiles: function (posturl, folder, name) {
|
uploadFiles: function (posturl, folder, name) {
|
||||||
var files = document.getElementById(name + 'FileInput').files;
|
var files = document.getElementById(name + 'FileInput').files;
|
||||||
var progressinfo = document.getElementById(name + 'ProgressInfo');
|
var progressinfo = document.getElementById(name + 'ProgressInfo');
|
||||||
|
|
9
Oqtane.Shared/Models/ModuleContent.cs
Normal file
9
Oqtane.Shared/Models/ModuleContent.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace Oqtane.Models
|
||||||
|
{
|
||||||
|
public class ModuleContent
|
||||||
|
{
|
||||||
|
public string ModuleDefinitionName { get; set; }
|
||||||
|
public string Version { get; set; }
|
||||||
|
public string Content { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,6 +34,8 @@ namespace Oqtane.Models
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string PermissionNames { get; set; }
|
public string PermissionNames { get; set; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
public string ServerAssemblyName { get; set; }
|
||||||
|
[NotMapped]
|
||||||
public string ControlTypeTemplate { get; set; }
|
public string ControlTypeTemplate { get; set; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string ControlTypeRoutes { get; set; }
|
public string ControlTypeRoutes { get; set; }
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
namespace Oqtane.Models
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Oqtane.Models
|
||||||
{
|
{
|
||||||
public class PageTemplate
|
public class PageTemplate
|
||||||
{
|
{
|
||||||
|
@ -10,10 +12,16 @@
|
||||||
public bool IsNavigation { get; set; }
|
public bool IsNavigation { get; set; }
|
||||||
public bool EditMode { get; set; }
|
public bool EditMode { get; set; }
|
||||||
public string PagePermissions { get; set; }
|
public string PagePermissions { get; set; }
|
||||||
|
public List<PageTemplateModule> PageTemplateModules { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PageTemplateModule
|
||||||
|
{
|
||||||
public string ModuleDefinitionName { get; set; }
|
public string ModuleDefinitionName { get; set; }
|
||||||
public string ModulePermissions { get; set; }
|
public string ModulePermissions { get; set; }
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public string Pane { get; set; }
|
public string Pane { get; set; }
|
||||||
public string ContainerType { get; set; }
|
public string ContainerType { get; set; }
|
||||||
|
public string Content { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,14 @@
|
||||||
{
|
{
|
||||||
public class Constants
|
public class Constants
|
||||||
{
|
{
|
||||||
|
public const string PackageId = "Oqtane.Framework";
|
||||||
|
public const string Version = "0.0.1";
|
||||||
|
|
||||||
public const string DefaultPage = "Oqtane.Shared.ThemeBuilder, Oqtane.Client";
|
public const string DefaultPage = "Oqtane.Shared.ThemeBuilder, Oqtane.Client";
|
||||||
public const string DefaultContainer = "Oqtane.Shared.ContainerBuilder, Oqtane.Client";
|
public const string DefaultContainer = "Oqtane.Shared.ContainerBuilder, Oqtane.Client";
|
||||||
public const string DefaultAdminContainer = "Oqtane.Themes.AdminContainer, Oqtane.Client";
|
public const string DefaultAdminContainer = "Oqtane.Themes.AdminContainer, Oqtane.Client";
|
||||||
public const string DefaultSettingsControl = "Oqtane.Modules.Admin.ModuleSettings.Index, Oqtane.Client";
|
public static readonly string[] DefaultModuleActions = new[] { "Settings", "Import", "Export" };
|
||||||
|
public const string DefaultModuleActionsTemplate = "Oqtane.Modules.Admin.Modules.{Control}, Oqtane.Client";
|
||||||
public const string PageManagementModule = "Oqtane.Modules.Admin.Pages, Oqtane.Client";
|
public const string PageManagementModule = "Oqtane.Modules.Admin.Pages, Oqtane.Client";
|
||||||
public const string ModuleMessageControl = "Oqtane.Modules.Controls.ModuleMessage, Oqtane.Client";
|
public const string ModuleMessageControl = "Oqtane.Modules.Controls.ModuleMessage, Oqtane.Client";
|
||||||
public const string DefaultControl = "Index";
|
public const string DefaultControl = "Index";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user