104 lines
3.3 KiB
Plaintext
104 lines
3.3 KiB
Plaintext
@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)
|
|
{
|
|
AddModuleMessage("Framework Is 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, ""))
|
|
{
|
|
AddModuleMessage("Framework Uploaded Successfully. Click Upgrade To Complete Installation.", MessageType.Success);
|
|
uploaded = true;
|
|
StateHasChanged();
|
|
}
|
|
else
|
|
{
|
|
AddModuleMessage("Framework Upload Failed.", MessageType.Error);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
AddModuleMessage("Framework Upload Failed. " + ex.Message, MessageType.Error);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AddModuleMessage("Invalid Framework Package", MessageType.Error);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
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));
|
|
}
|
|
} |