diff --git a/app/.vs/app/v16/.suo b/app/.vs/app/v16/.suo index f228265..d867b7f 100644 Binary files a/app/.vs/app/v16/.suo and b/app/.vs/app/v16/.suo differ diff --git a/app/.vs/slnx.sqlite b/app/.vs/slnx.sqlite index e976b9e..efcb274 100644 Binary files a/app/.vs/slnx.sqlite and b/app/.vs/slnx.sqlite differ diff --git a/app/src/app/catalog/models/image.ts b/app/src/app/catalog/models/image.ts index 347dd23..0e669e9 100644 --- a/app/src/app/catalog/models/image.ts +++ b/app/src/app/catalog/models/image.ts @@ -16,3 +16,11 @@ export class CatalogImage image_size: number; price: number; } + +export enum CatalogImageType +{ + InfrastructureContainer = 1, + VirtualMachine = 2, + Docker = 3, + Custom = 4 +} diff --git a/app/src/app/catalog/packages/packages.component.ts b/app/src/app/catalog/packages/packages.component.ts index d06c8b0..63c3930 100644 --- a/app/src/app/catalog/packages/packages.component.ts +++ b/app/src/app/catalog/packages/packages.component.ts @@ -5,6 +5,7 @@ import { takeUntil } from 'rxjs/operators'; import { FileSizePipe } from '../../pipes/file-size.pipe'; import { CatalogService } from '../helpers/catalog.service'; import { CatalogImage } from '../../catalog/models/image'; +import { CatalogImageType } from '../models/image'; @Component({ selector: 'app-packages', @@ -120,9 +121,9 @@ export class PackagesComponent implements OnInit, OnDestroy, OnChanges // Setup the operating systems array-like object, sorted alphabetically this.packageGroups = Object.keys(this.packages) - .filter(x => + .filter(packageGroup => { - this.packages[x].forEach(p => + this.packages[packageGroup].forEach(p => { if (p.name === this.package) this._selectedPackage = p; @@ -132,27 +133,42 @@ export class PackagesComponent implements OnInit, OnDestroy, OnChanges p.visible = true; return; } + else + { + p.visible = true; + } if (this.image.requirements.brand) - p.visible = this.image.requirements.brand === p.brand; + p.visible = p.visible && this.image.requirements.brand === p.brand; if (this.image.type === 'zone-dataset') - p.visible = ['Spearhead', 'Spearhead-minimal'].includes(p.brand); + p.visible = p.visible && ['Spearhead', 'Spearhead-minimal'].includes(p.brand); if (this.image.type === 'lx-dataset') - p.visible = p.brand === 'lx'; + p.visible = p.visible && p.brand === 'lx'; if (this.image.type === 'zvol') - p.visible = ['bhyve', 'kvm'].includes(p.brand); + p.visible = p.visible && ['bhyve', 'kvm'].includes(p.brand); + + if (this.imageType === CatalogImageType.InfrastructureContainer) + p.visible = p.visible && packageGroup === 'infrastructure container'; + else if (this.imageType === CatalogImageType.VirtualMachine) + p.visible = p.visible && packageGroup === 'virtual machine'; }); switch (this.imageType | 0) { - case 1: - return this.packages[x].length && (!x || ['cpu', 'disk', 'memory optimized', 'standard', 'triton'].includes(x)); + case CatalogImageType.InfrastructureContainer: + return this.packages[packageGroup].filter(x => x.visible).length && + (!packageGroup || ['cpu', 'disk', 'memory optimized', 'standard', 'triton'].includes(packageGroup)); - case 2: - return this.packages[x].length && (!x || ['standard', 'triton', 'bhyve'].includes(x)); + case CatalogImageType.VirtualMachine: + return this.packages[packageGroup].filter(x => x.visible).length && + (!packageGroup || ['standard', 'triton', 'bhyve'].includes(packageGroup)); + + case CatalogImageType.Custom: + return this.packages[packageGroup].filter(x => x.visible).length && + packageGroup !== 'infrastructure container' && packageGroup !== 'virtual machine'; default: return false; diff --git a/app/src/app/instances/instance-wizard/instance-wizard.component.scss b/app/src/app/instances/instance-wizard/instance-wizard.component.scss index e2ab038..1d365ba 100644 --- a/app/src/app/instances/instance-wizard/instance-wizard.component.scss +++ b/app/src/app/instances/instance-wizard/instance-wizard.component.scss @@ -298,7 +298,7 @@ p { color: #00e7ff; text-transform: uppercase; - background: #0f1626; + background-color: #0f1626; border-color: #00e7ff; border-radius: 3rem; } diff --git a/app/src/app/instances/instance-wizard/instance-wizard.component.ts b/app/src/app/instances/instance-wizard/instance-wizard.component.ts index cc87dde..6b95e08 100644 --- a/app/src/app/instances/instance-wizard/instance-wizard.component.ts +++ b/app/src/app/instances/instance-wizard/instance-wizard.component.ts @@ -13,6 +13,7 @@ import { ToastrService } from 'ngx-toastr'; import { VolumesService } from '../../volumes/helpers/volumes.service'; import { AuthService } from '../../helpers/auth.service'; import { TranslateService } from '@ngx-translate/core'; +import { CatalogImageType } from '../../catalog/models/image'; @Component({ selector: 'app-instance-wizard', @@ -171,7 +172,7 @@ export class InstanceWizardComponent implements OnInit, OnDestroy const imageList = []; const operatingSystems = {}; - if (imageType === 1) + if (imageType === CatalogImageType.InfrastructureContainer) { for (const image of this.images) if (['lx-dataset', 'zone-dataset'].includes(image.type) && image.owner !== this.userId) @@ -180,7 +181,7 @@ export class InstanceWizardComponent implements OnInit, OnDestroy imageList.push(image); } } - else if (imageType === 2) + else if (imageType === CatalogImageType.VirtualMachine) { for (const image of this.images) if (['zvol'].includes(image.type) && image.owner !== this.userId) @@ -189,7 +190,7 @@ export class InstanceWizardComponent implements OnInit, OnDestroy imageList.push(image); } } - else if (imageType === 3) + else if (imageType === CatalogImageType.Custom) { for (const image of this.images) if (image.owner === this.userId) @@ -221,7 +222,7 @@ export class InstanceWizardComponent implements OnInit, OnDestroy const imageList = []; const operatingSystems = {}; - if (imageType === 1) + if (imageType === CatalogImageType.InfrastructureContainer) { for (const image of this.images) if (['lx-dataset', 'zone-dataset'].includes(image.type) && (!imageOs || imageOs === image.os) && image.owner !== this.userId) @@ -230,7 +231,7 @@ export class InstanceWizardComponent implements OnInit, OnDestroy imageList.push(image); } } - else if (imageType === 2) + else if (imageType === CatalogImageType.VirtualMachine) { for (const image of this.images) if (['zvol'].includes(image.type) && (!imageOs || imageOs === image.os) && image.owner !== this.userId) @@ -239,7 +240,7 @@ export class InstanceWizardComponent implements OnInit, OnDestroy imageList.push(image); } } - else if (imageType === 3) + else if (imageType === CatalogImageType.Custom) { for (const image of this.images) if (image.owner === this.userId) @@ -288,10 +289,10 @@ export class InstanceWizardComponent implements OnInit, OnDestroy .pipe(takeUntil(this.destroy$)) .subscribe(this.setAffinity.bind(this)); - this.editorForm.get('estimatedMinutesRan').valueChanges - .pipe(takeUntil(this.destroy$)) - .subscribe(this.computeEstimatedCost.bind(this)) - } + this.editorForm.get('estimatedMinutesRan').valueChanges + .pipe(takeUntil(this.destroy$)) + .subscribe(this.computeEstimatedCost.bind(this)); + } // ---------------------------------------------------------------------------------------------------------------- private computeEstimatedCost()