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:
Shaun Walker
2019-10-08 16:11:23 -04:00
parent dce53e10b0
commit 9971510b1e
48 changed files with 961 additions and 157 deletions

View File

@ -11,7 +11,7 @@
<label for="Name" class="control-label">Theme: </label>
</td>
<td>
<FileUpload Filter=".nupkg"></FileUpload>
<FileUpload Filter=".nupkg" @ref="fileupload"></FileUpload>
</td>
</tr>
</table>
@ -49,18 +49,55 @@
bool uploaded = false;
List<Package> packages;
FileUpload fileupload;
protected override async Task OnInitializedAsync()
{
List<Theme> themes = await ThemeService.GetThemesAsync();
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()
{
await FileService.UploadFilesAsync("Themes");
ModuleInstance.AddModuleMessage("Theme Uploaded Successfully. Click Install To Complete Installation.", MessageType.Success);
uploaded = true;
StateHasChanged();
string[] files = await fileupload.GetFiles();
if (files.Length > 0)
{
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()

View File

@ -1,6 +1,8 @@
@namespace Oqtane.Modules.Admin.Themes
@inherits ModuleBase
@inject NavigationManager NavigationManager
@inject IThemeService ThemeService
@inject IPackageService PackageService
@if (themes == null)
{
@ -14,10 +16,19 @@ else
<Header>
<th>Name</th>
<th>Version</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
</Header>
<Row>
<td>@context.Name</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>
</Pager>
}
@ -26,9 +37,29 @@ else
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
List<Theme> themes;
List<Package> packages;
protected override async Task OnInitializedAsync()
{
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));
}
}