From 53df976426f8845adf58e8ff9355764343a38549 Mon Sep 17 00:00:00 2001 From: aribeiro Date: Wed, 16 Jun 2021 23:21:04 +0100 Subject: Specify model at service creation Allows a user to select a model when designing a service Issue-ID: SDC-3621 Signed-off-by: aribeiro Change-Id: I386e43ddeb649a4ba0805f153e4b47e8a528cff0 --- .../workspace/tabs/general/general-view-model.ts | 20 +++++++++++++++++++- .../workspace/tabs/general/general-view.html | 17 ++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) (limited to 'catalog-ui/src/app/view-models') diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts index b456bece19..9b7a92b297 100644 --- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts +++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts @@ -33,7 +33,7 @@ import { ValidationUtils } from "app/utils"; import {EventListenerService, ProgressService} from "app/services"; -import {CacheService, ElementService, ImportVSPService, OnboardingService} from "app/services-ng2"; +import {CacheService, ElementService, ModelService, ImportVSPService, OnboardingService} from "app/services-ng2"; import {Component, IAppConfigurtaion, ICsarComponent, IMainCategory, IMetadataKey, ISubCategory, IValidate, Resource, Service} from "app/models"; import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; import {CATEGORY_SERVICE_METADATA_KEYS, PREVIOUS_CSAR_COMPONENT} from "../../../../utils/constants"; @@ -53,6 +53,10 @@ export class componentCategories {//categories field bind to this obj in order t selectedCategory:string; } +export class componentModel { + selectedModel:string; +} + export interface IEnvironmentContext { defaultValue:string; validValues:Array; @@ -73,6 +77,7 @@ export interface IGeneralScope extends IWorkspaceViewModelScope { importCsarProProgressKey:string; browseFileLabel:string; componentCategories:componentCategories; + componentModel:componentModel; instantiationTypes:Array; isHiddenCategorySelected: boolean; @@ -95,6 +100,7 @@ export interface IGeneralScope extends IWorkspaceViewModelScope { onInstantiationTypeChange():void; updateIcon():void; possibleToUpdateIcon():boolean; + initModel():void; } // tslint:disable-next-line:max-classes-per-file @@ -124,6 +130,7 @@ export class GeneralViewModel { 'ComponentFactory', 'ImportVSPService', 'ElementService', + 'ModelService', '$stateParams' ]; @@ -150,6 +157,7 @@ export class GeneralViewModel { private ComponentFactory:ComponentFactory, private importVSPService: ImportVSPService, private elementService: ElementService, + private modelService: ModelService, private $stateParams: any) { this.initScopeValidation(); @@ -270,6 +278,7 @@ export class GeneralViewModel { // Init Instantiation types this.$scope.initInstantiationTypes(); this.$scope.initBaseTypes(); + this.$scope.initModel(); } if (this.cacheService.get(PREVIOUS_CSAR_COMPONENT)) { //keep the old component in the cache until checkout, so we dont need to pass it around @@ -451,6 +460,15 @@ export class GeneralViewModel { } }; + this.$scope.initModel = ():void => { + if (this.$scope.componentType === ComponentType.SERVICE) { + this.$scope.models = new Array(); + this.modelService.getModels().subscribe((modelsFound: Model[]) => { + modelsFound.forEach(model => {this.$scope.models.push(model.name)});}) + this.$scope.models.filter(model => model.name === (this.$scope.component).model); + } + }; + this.$scope.initEnvironmentContext = ():void => { if (this.$scope.componentType === ComponentType.SERVICE) { this.$scope.environmentContextObj = this.cacheService.get('UIConfiguration').environmentContext; diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html index d598e170a4..d2529f9bb6 100644 --- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html @@ -607,7 +607,22 @@ - + + + +
+ + +
+