oqtane.framework/Oqtane.Client/Modules/Admin/Themes/Add.razor
Hisham Bin Ateya 66ad089088
Refactoring (#314)
* Refactoring

* Refactoring

* Check for a valid email.

* Fixed missing character.

* Moved logic to  the Utilities class.

* Rename template .sql file

* Modified null and empty string check.

* Check for a valid email.

* Fixed missing character.

* Moved logic to  the Utilities class.

* Added Favicon support, Progressive Web App support, page title and url support, and private/public user registration options

* Refactoring

* Refactoring

* Check for a valid email.

* Moved logic to  the Utilities class.

Co-authored-by: Aubrey <aubrey.b@treskcow.tech>
Co-authored-by: MIchael Atwood <matwood@dragonmastery.com>
Co-authored-by: Shaun Walker <shaun.walker@siliqon.com>
2020-03-31 10:21:05 -04:00

75 lines
2.2 KiB
Plaintext

@namespace Oqtane.Modules.Admin.Themes
@inherits ModuleBase
@inject NavigationManager NavigationManager
@inject IFileService FileService
@inject IThemeService ThemeService
@inject IPackageService PackageService
<table class="table table-borderless">
<tr>
<td>
<label class="control-label">Theme: </label>
</td>
<td>
<FileManager Filter="nupkg" ShowFiles="false" Folder="Themes" />
</td>
</tr>
</table>
@if (packages != null)
{
<hr class="app-rule" />
<div class="mx-auto text-center"><h2>Available Themes</h2></div>
<Pager Items="@packages">
<Header>
<th>Name</th>
<th>Version</th>
<th></th>
</Header>
<Row>
<td>@context.Name</td>
<td>@context.Version</td>
<td>
<button type="button" class="btn btn-primary" @onclick=@(async () => await DownloadTheme(context.PackageId, context.Version))>Download Theme</button>
</td>
</Row>
</Pager>
}
<button type="button" class="btn btn-success" @onclick="InstallThemes">Install</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code {
private List<Package> packages;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
protected override async Task OnInitializedAsync()
{
var 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 InstallThemes()
{
await ThemeService.InstallThemesAsync();
NavigationManager.NavigateTo(NavigateUrl());
}
private async Task DownloadTheme(string packageid, string version)
{
await PackageService.DownloadPackageAsync(packageid, version, "Themes");
AddModuleMessage("Theme Downloaded Successfully. Click Install To Complete Installation.", MessageType.Success);
StateHasChanged();
}
}