From bffce99fb0fcbd8764ca28cc25558f4be269a4b1 Mon Sep 17 00:00:00 2001 From: Dragos Date: Tue, 1 Jun 2021 14:30:04 +0300 Subject: [PATCH] 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 --- .../app/catalog/helpers/catalog.service.ts | 23 ++++++++----------- .../catalog/packages/packages.component.ts | 3 ++- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/src/app/catalog/helpers/catalog.service.ts b/app/src/app/catalog/helpers/catalog.service.ts index 9790a1b..a35dbdd 100644 --- a/app/src/app/catalog/helpers/catalog.service.ts +++ b/app/src/app/catalog/helpers/catalog.service.ts @@ -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(' '); - - size = this.fileSizePipe.transform(pkg.disk * 1024 * 1024); - [pkg.diskSize, pkg.diskSizeLabel] = size.split(' '); + let size = this.fileSizePipe.transform(pkg.memory * 1024 * 1024); + [pkg.memorySize, pkg.memorySizeLabel] = size.split(' '); - filteredPackages.push(pkg); - } + size = this.fileSizePipe.transform(pkg.disk * 1024 * 1024); + [pkg.diskSize, pkg.diskSizeLabel] = size.split(' '); + }); - return filteredPackages; + return packages; })) })); } diff --git a/app/src/app/catalog/packages/packages.component.ts b/app/src/app/catalog/packages/packages.component.ts index 1be6a72..14a38d7 100644 --- a/app/src/app/catalog/packages/packages.component.ts +++ b/app/src/app/catalog/packages/packages.component.ts @@ -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();