fix #5616 - show all available modules/themes and indicate if they are installed
This commit is contained in:
@ -101,13 +101,20 @@
|
|||||||
<small>@SharedLocalizer["Search.By"]:</small> <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
<small>@SharedLocalizer["Search.By"]:</small> <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
||||||
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
||||||
<br />
|
<br />
|
||||||
@if (!string.IsNullOrEmpty(context.PackageUrl))
|
@if (_moduledefinitions.Exists(item => item.PackageName == context.PackageId))
|
||||||
{
|
{
|
||||||
<button type="button" class="btn btn-primary" @onclick=@(async () => await GetPackage(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
<button type="button" class="btn btn-info">@SharedLocalizer["Installed"]</button>
|
||||||
}
|
}
|
||||||
@if (context.Price != null && !string.IsNullOrEmpty(context.PaymentUrl))
|
else
|
||||||
{
|
{
|
||||||
<a class="btn btn-success ms-2" style="text-decoration: none !important" href="@context.PaymentUrl" target="_new">@SharedLocalizer["Buy"]</a>
|
@if (!string.IsNullOrEmpty(context.PackageUrl))
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-primary" @onclick=@(async () => await GetPackage(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
||||||
|
}
|
||||||
|
@if (context.Price != null && !string.IsNullOrEmpty(context.PaymentUrl))
|
||||||
|
{
|
||||||
|
<a class="btn btn-success ms-2" style="text-decoration: none !important" href="@context.PaymentUrl" target="_new">@SharedLocalizer["Buy"]</a>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
@ -171,6 +178,7 @@
|
|||||||
|
|
||||||
@code {
|
@code {
|
||||||
private bool _initialized = false;
|
private bool _initialized = false;
|
||||||
|
private List<ModuleDefinition> _moduledefinitions;
|
||||||
private int _page = 1;
|
private int _page = 1;
|
||||||
private List<Package> _packages;
|
private List<Package> _packages;
|
||||||
private string _price = "free";
|
private string _price = "free";
|
||||||
@ -187,7 +195,8 @@
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await LoadModuleDefinitions();
|
_moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
||||||
|
await LoadPackages();
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -197,24 +206,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task LoadModuleDefinitions()
|
private async Task LoadPackages()
|
||||||
{
|
{
|
||||||
ShowProgressIndicator();
|
ShowProgressIndicator();
|
||||||
|
|
||||||
var moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
|
||||||
_packages = await PackageService.GetPackagesAsync("module", _search, _price, "", _sort);
|
_packages = await PackageService.GetPackagesAsync("module", _search, _price, "", _sort);
|
||||||
|
|
||||||
if (_packages != null)
|
|
||||||
{
|
|
||||||
foreach (Package package in _packages.ToArray())
|
|
||||||
{
|
|
||||||
if (moduledefinitions.Exists(item => item.PackageName == package.PackageId))
|
|
||||||
{
|
|
||||||
_packages.Remove(package);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HideProgressIndicator();
|
HideProgressIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,25 +217,25 @@
|
|||||||
{
|
{
|
||||||
_price = price;
|
_price = price;
|
||||||
_sort = "popularity";
|
_sort = "popularity";
|
||||||
await LoadModuleDefinitions();
|
await LoadPackages();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Search()
|
private async Task Search()
|
||||||
{
|
{
|
||||||
await LoadModuleDefinitions();
|
await LoadPackages();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Reset()
|
private async Task Reset()
|
||||||
{
|
{
|
||||||
_page = 1;
|
_page = 1;
|
||||||
_search = "";
|
_search = "";
|
||||||
await LoadModuleDefinitions();
|
await LoadPackages();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Refresh()
|
private async Task Refresh()
|
||||||
{
|
{
|
||||||
await LoadModuleDefinitions();
|
await LoadPackages();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPageChange(int page)
|
private void OnPageChange(int page)
|
||||||
@ -251,7 +246,7 @@
|
|||||||
private async void SortChanged(ChangeEventArgs e)
|
private async void SortChanged(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
_sort = (string)e.Value;
|
_sort = (string)e.Value;
|
||||||
await LoadModuleDefinitions();
|
await LoadPackages();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HideModal()
|
private void HideModal()
|
||||||
|
|||||||
@ -101,13 +101,20 @@
|
|||||||
<small>@SharedLocalizer["Search.By"]:</small> <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
<small>@SharedLocalizer["Search.By"]:</small> <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
||||||
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
||||||
<br />
|
<br />
|
||||||
@if (!string.IsNullOrEmpty(context.PackageUrl))
|
@if (_themes.Exists(item => item.PackageName == context.PackageId))
|
||||||
{
|
{
|
||||||
<button type="button" class="btn btn-primary" @onclick=@(async () => await GetPackage(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
<button type="button" class="btn btn-info">@SharedLocalizer["Installed"]</button>
|
||||||
}
|
}
|
||||||
@if (context.Price != null && !string.IsNullOrEmpty(context.PaymentUrl))
|
else
|
||||||
{
|
{
|
||||||
<a class="btn btn-success ms-2" style="text-decoration: none !important" href="@context.PaymentUrl" target="_new">@SharedLocalizer["Buy"]</a>
|
@if (!string.IsNullOrEmpty(context.PackageUrl))
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-primary" @onclick=@(async () => await GetPackage(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
||||||
|
}
|
||||||
|
@if (context.Price != null && !string.IsNullOrEmpty(context.PaymentUrl))
|
||||||
|
{
|
||||||
|
<a class="btn btn-success ms-2" style="text-decoration: none !important" href="@context.PaymentUrl" target="_new">@SharedLocalizer["Buy"]</a>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
@ -171,6 +178,7 @@
|
|||||||
|
|
||||||
@code {
|
@code {
|
||||||
private bool _initialized = false;
|
private bool _initialized = false;
|
||||||
|
private List<Theme> _themes;
|
||||||
private int _page = 1;
|
private int _page = 1;
|
||||||
private List<Package> _packages;
|
private List<Package> _packages;
|
||||||
private string _price = "free";
|
private string _price = "free";
|
||||||
@ -187,7 +195,8 @@
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await LoadThemes();
|
_themes = await ThemeService.GetThemesAsync();
|
||||||
|
await LoadPackages();
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -197,24 +206,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task LoadThemes()
|
private async Task LoadPackages()
|
||||||
{
|
{
|
||||||
ShowProgressIndicator();
|
ShowProgressIndicator();
|
||||||
|
|
||||||
var themes = await ThemeService.GetThemesAsync();
|
|
||||||
_packages = await PackageService.GetPackagesAsync("theme", _search, _price, "", _sort);
|
_packages = await PackageService.GetPackagesAsync("theme", _search, _price, "", _sort);
|
||||||
|
|
||||||
if (_packages != null)
|
|
||||||
{
|
|
||||||
foreach (Package package in _packages.ToArray())
|
|
||||||
{
|
|
||||||
if (themes.Exists(item => item.PackageName == package.PackageId))
|
|
||||||
{
|
|
||||||
_packages.Remove(package);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HideProgressIndicator();
|
HideProgressIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,25 +217,25 @@
|
|||||||
{
|
{
|
||||||
_price = price;
|
_price = price;
|
||||||
_sort = "popularity";
|
_sort = "popularity";
|
||||||
await LoadThemes();
|
await LoadPackages();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Search()
|
private async Task Search()
|
||||||
{
|
{
|
||||||
await LoadThemes();
|
await LoadPackages();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Reset()
|
private async Task Reset()
|
||||||
{
|
{
|
||||||
_page = 1;
|
_page = 1;
|
||||||
_search = "";
|
_search = "";
|
||||||
await LoadThemes();
|
await LoadPackages();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Refresh()
|
private async Task Refresh()
|
||||||
{
|
{
|
||||||
await LoadThemes();
|
await LoadPackages();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPageChange(int page)
|
private void OnPageChange(int page)
|
||||||
@ -251,7 +246,7 @@
|
|||||||
private async void SortChanged(ChangeEventArgs e)
|
private async void SortChanged(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
_sort = (string)e.Value;
|
_sort = (string)e.Value;
|
||||||
await LoadThemes();
|
await LoadPackages();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HideModal()
|
private void HideModal()
|
||||||
|
|||||||
@ -477,4 +477,7 @@
|
|||||||
<data name="Path" xml:space="preserve">
|
<data name="Path" xml:space="preserve">
|
||||||
<value>Path</value>
|
<value>Path</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Installed" xml:space="preserve">
|
||||||
|
<value>Installed</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Reference in New Issue
Block a user