From e9f4934bf0e1418c5b6d918124417af8d1abac2c Mon Sep 17 00:00:00 2001 From: Dragos Date: Thu, 6 May 2021 19:53:34 +0300 Subject: [PATCH] show package list when selecting a custom image in the instance wizard --- app/.vs/app/v16/.suo | Bin 73728 -> 57856 bytes app/.vs/slnx.sqlite | Bin 135168 -> 135168 bytes app/src/app/catalog/models/image.ts | 8 ++++ .../catalog/packages/packages.component.ts | 36 +++++++++++++----- .../instance-wizard.component.scss | 2 +- .../instance-wizard.component.ts | 21 +++++----- 6 files changed, 46 insertions(+), 21 deletions(-) diff --git a/app/.vs/app/v16/.suo b/app/.vs/app/v16/.suo index f228265f20249c1fe74606e2b9505433a8320eb4..d867b7ff9ec3a5131624ae5b8d98c0c1045860ad 100644 GIT binary patch delta 6142 zcmcgweN>az9e(di2q8qqw^%4&28@=_@D-w{1O%bAT2XYAvCcq(MZ92#l0oVvc1NFcIKm%avtxbtBLudw6fCZpK=^8fHYg*wFtCkNw!yu+Uf?j1ghI|pz1!MwxYc)NG%bZpR*UpJSjxHd!3>IOh{8;+^M z7)*eMfZC-@l_o?&P60?0T`9}vLZ?y_&L4%ZOXsaZj{&Fz`1>XcU01H);qZY=We@)` z*8Dx~RP7QU7U)aWIvLMZ8f?&r+XQ-e&R%&Z+A@K6KF?4@u)cofY08N#UrXVYsKZ%2I+^?uO)&ru&l?L^&! zr_14vXTbhC)LU`9^r62O%*fs7ECTUyc5f&agvD5J5zdi!(cTH#eGc`Br4x!C!Ex~d z+Lu65t*FnJ!OtR038$V66NIbCm?!Xp8#OqJu+G40L0ExtH;xbfA{bOEw=00dF|Y=n zu_{sS$gg@b`kieLd8_Zc@W${zN=5={VFc%&hE<@=_pJ;Qq!4zQz2vnU`z)+)t=L~= zWDYy70d~PAH2wMd2dO1B_clK8NnUyLHCz3T;kXT{@ApR343(?aMZ@klmG{ChkE8t` z?Ddy0P9lz!HE8cf4TlJ&$esl-=0&jJ0kprsC19%Ynk`zpX|vX1ZnejD+-ew#8Pf5L zuzIX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BR4K~TNr@_1 zNwQol(iMrNqPo;Y7#2-8WyYU|Ifez<<6EI9Q5j4$Y7i z(QbIl)jnystKN{>)1?#HcsZWsqxZGE$b4k- z?98mBY_&QwD@$zTxlPV4P}<~ne3<6bGvQ0oLu1lRHnZ@dd1SEbLGL0+GsSF7#z)|` zox$uA+-n;9+;mbkg;6g)=05L9m-Zf-`oJUU@kvMDzBu#h6CXbI_=Y8=s-D2^*B(B$ zyR$L%F)}ZWwtYg%Zg|OK^{YWfw5E5bfn|8a%z*{Z4^DKJsB(m zE~)l|zJQZhGdnziyLP|Z)x7h`jR=l~zvUBFUE)qLuFH&J~Sbv-2Zd#2{0F&#m zmxUHH$W}&OUVB6;I8(mb3nN<~x7G zaLqA`NRgTAz_HraH~sU582u=B7siaQcu3h4gQg}y$+E1e!D{rj_=j6J8EQOWco MgE4^q{NaWF0)9}aM*si- diff --git a/app/.vs/slnx.sqlite b/app/.vs/slnx.sqlite index e976b9ef2ea991ed2d7845776193cceb81c7948a..efcb2741abd1e8fc728d18949194356c17ab033e 100644 GIT binary patch delta 56 zcmV-80LTA;pa_7V2#^~ALXjLp0Yb50R;dN94Jz;pv%9Ia0|l>Z@gQ@Pb*(T45Uvd- OTuFngt+%VK0aapDa~1pm delta 56 zcmV-80LTA;pa_7V2#^~AH<27e0XMN=R;dLLk2%M(v%9Ia0|gR6LC#>4b*(T451O?P OH0pz^t+%VK0aapB@)mFa 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()