fetch _all_ packages and only filter the displayed ones

fetch _all_ packages and only filter the displayed ones so that old images can still grab info about their package
This commit is contained in:
Dragos 2021-06-01 14:30:04 +03:00
parent 4a100cf9d4
commit bffce99fb0
2 changed files with 11 additions and 15 deletions

View File

@ -46,23 +46,18 @@ export class CatalogService
{
return this.httpClient.get(`./assets/data/packages.json`).pipe(map(prices =>
{
let filteredPackages: CatalogPackage[] = [];
packages.forEach(pkg =>
{
pkg.price = prices[pkg.id];
for (let pkg of packages)
if (pkg.group === PackageGroupsEnum.Vm || pkg.group === PackageGroupsEnum.Infra)
{
pkg.price = prices[pkg.id];
let size = this.fileSizePipe.transform(pkg.memory * 1024 * 1024);
[pkg.memorySize, pkg.memorySizeLabel] = size.split(' ');
let size = this.fileSizePipe.transform(pkg.memory * 1024 * 1024);
[pkg.memorySize, pkg.memorySizeLabel] = size.split(' ');
size = this.fileSizePipe.transform(pkg.disk * 1024 * 1024);
[pkg.diskSize, pkg.diskSizeLabel] = size.split(' ');
});
size = this.fileSizePipe.transform(pkg.disk * 1024 * 1024);
[pkg.diskSize, pkg.diskSizeLabel] = size.split(' ');
filteredPackages.push(pkg);
}
return filteredPackages;
return packages;
}))
}));
}

View File

@ -62,7 +62,8 @@ export class PackagesComponent implements OnInit, OnDestroy, OnChanges
this.catalogService.getPackages()
.subscribe(response =>
{
this._packages = response;
this._packages = response.filter(pkg => pkg.group === PackageGroupsEnum.Vm ||
pkg.group === PackageGroupsEnum.Infra);
this.setPackagesByImageType();