diff options
author | MichaelMorris <michael.morris@est.tech> | 2021-07-30 13:06:11 +0100 |
---|---|---|
committer | Andr� Schmid <andre.schmid@est.tech> | 2021-08-12 09:47:01 +0000 |
commit | df1e300dad94d65a88d2012df9096961619d8272 (patch) | |
tree | d610a352cf85237c0ef969035a58db17a297cd86 /catalog-ui/src | |
parent | 55c256b321652c5d94658a62f3ec3744cae18ff4 (diff) |
Update base types based on model
Also made some changes where model was not being considered
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-3666
Change-Id: I450c5261239cf4104c494abe6711cb61368a2b4a
Diffstat (limited to 'catalog-ui/src')
8 files changed, 31 insertions, 13 deletions
diff --git a/catalog-ui/src/app/models/components/component.ts b/catalog-ui/src/app/models/components/component.ts index a2d28ebeac..6d176df216 100644 --- a/catalog-ui/src/app/models/components/component.ts +++ b/catalog-ui/src/app/models/components/component.ts @@ -147,7 +147,7 @@ export abstract class Component implements IComponent { public categorySpecificMetadata: Metadata = new Metadata(); public derivedFromGenericType: string; public derivedFromGenericVersion: string; - public model: Model; + public model: string; constructor(componentService:IComponentService, protected $q:ng.IQService, component?:Component) { if (component) { diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts index fbbc4d8b0e..8e483ea5ef 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts @@ -1146,7 +1146,7 @@ export class PropertiesAssignmentComponent { } /*** addProperty ***/ - addProperty = (model: Model) => { + addProperty = (model: string) => { this.loadDataTypesByComponentModel(model) let modalTitle = 'Add Property'; let modal = this.ModalService.createCustomModal(new ModalModel( @@ -1251,9 +1251,8 @@ export class PropertiesAssignmentComponent { return instanceType === ResourceType.VF || instanceType === ResourceType.PNF || instanceType === ResourceType.CVFC || instanceType === ResourceType.CR; } - loadDataTypesByComponentModel(model:Model) { - let modelName = new Model(model).name; - this.propertyCreatorComponent.filterDataTypesByModel(modelName); + loadDataTypesByComponentModel(model:string) { + this.propertyCreatorComponent.filterDataTypesByModel(model); } } diff --git a/catalog-ui/src/app/ng2/services/element.service.ts b/catalog-ui/src/app/ng2/services/element.service.ts index 97efbccfef..b3cf8c38f4 100644 --- a/catalog-ui/src/app/ng2/services/element.service.ts +++ b/catalog-ui/src/app/ng2/services/element.service.ts @@ -33,8 +33,9 @@ export class ElementService { this.baseUrl = sdcConfig.api.root; } - getCategoryBasetypes(categoryName:string):Observable<BaseTypeResponse[]> { - return this.http.get<ListBaseTypesResponse>(this.baseUrl + "/v1/category/services/" + categoryName + "/baseTypes") + getCategoryBasetypes(categoryName:string, modelName:string):Observable<BaseTypeResponse[]> { + let modelQueryParam: string = modelName ? '?model=' + modelName : ''; + return this.http.get<ListBaseTypesResponse>(this.baseUrl + "/v1/category/services/" + categoryName + "/baseTypes" + modelQueryParam) .pipe(map(response => response.baseTypes)); } diff --git a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts index fa3de88c7b..aaf105463d 100644 --- a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts +++ b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts @@ -62,7 +62,7 @@ export class ComponentGenericResponse implements Serializable<ComponentGenericR public substitutionFilters: any; public derivedFromGenericType; public derivedFromGenericVersion; - public model:Model; + public model:string; deserialize (response): ComponentGenericResponse { diff --git a/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts index 5e48dc8115..fe578b6865 100644 --- a/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts +++ b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts @@ -135,7 +135,7 @@ export abstract class PropertyFormBaseView { this.$scope.property = new PropertyModel(this.originalProperty); //we create a new Object so if user press cance we won't update the property this.$scope.types = PROPERTY_DATA.TYPES; //All types - simple type + map + list this.$scope.simpleTypes = PROPERTY_DATA.SIMPLE_TYPES; //All simple types - this.$scope.dataTypes = this.DataTypesService.getAllDataTypesFromModel(this.component.model.name); //Get all data types in service + this.$scope.dataTypes = this.DataTypesService.getAllDataTypesFromModel(this.component.model); //Get all data types in service this.$scope.modalPropertyFormBase = this.$uibModalInstance; this.$scope.isNew = !angular.isDefined(this.$scope.property.name); diff --git a/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts index 9be3b642b4..2e8788f1fa 100644 --- a/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts +++ b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts @@ -63,7 +63,7 @@ export class SelectDataTypeViewModel extends PropertyFormBaseView { this.$templateCache.put("select-datatype-modal-view.html", require('app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html')); this.$scope.innerViewSrcUrl = "select-datatype-modal-view.html"; - this.$scope.modelNameFilter = this.component.model.name; + this.$scope.modelNameFilter = this.component.model; this.initChildScope(); } 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 20eaec6aad..c78852de4c 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 @@ -451,7 +451,8 @@ export class GeneralViewModel { this.$scope.initBaseTypes = ():void => { if (this.$scope.componentType === ComponentType.SERVICE && this.$scope.component && this.$scope.component.categories) { - this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name).subscribe((data: BaseTypeResponse[]) => { + let modelName = this.$scope.component.model ? this.$scope.component.model : null; + this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name, modelName).subscribe((data: BaseTypeResponse[]) => { this.$scope.baseTypes = [] this.$scope.baseTypeVersions = [] data.forEach(baseType => { @@ -682,7 +683,8 @@ export class GeneralViewModel { } } if (this.$scope.componentType === ComponentType.SERVICE && this.$scope.component.categories[0]) { - this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name).subscribe((data: BaseTypeResponse[]) => { + let modelName : string = this.$scope.component.model ? this.$scope.component.model : null; + this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name, modelName).subscribe((data: BaseTypeResponse[]) => { if(this.$scope.isCreateMode()){ this.$scope.baseTypes = [] @@ -709,7 +711,8 @@ export class GeneralViewModel { }; this.$scope.onBaseTypeChange = (): void => { - this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name).subscribe((data: BaseTypeResponse[]) => { + let modelName : string = this.$scope.component.model ? this.$scope.component.model : null; + this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name, modelName).subscribe((data: BaseTypeResponse[]) => { this.$scope.baseTypeVersions = [] data.forEach(baseType => { if(baseType.toscaResourceName === this.$scope.component.derivedFromGenericType) { @@ -720,6 +723,20 @@ export class GeneralViewModel { }) }; + this.$scope.onModelChange = (): void => { + if (this.$scope.componentType === ComponentType.SERVICE && this.$scope.component && this.$scope.component.categories) { + let modelName = this.$scope.component.model ? this.$scope.component.model : null; + this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name, modelName).subscribe((data: BaseTypeResponse[]) => { + this.$scope.baseTypes = [] + this.$scope.baseTypeVersions = [] + data.forEach(baseType => this.$scope.baseTypes.push(baseType.toscaResourceName)); + data[0].versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version)); + this.$scope.component.derivedFromGenericType = data[0].toscaResourceName; + this.$scope.component.derivedFromGenericVersion = data[0].versions[0]; + }) + } + }; + this.$scope.onVendorNameChange = (oldVendorName: string): void => { if (this.$scope.component.icon === oldVendorName) { this.$scope.component.icon = DEFAULT_ICON; 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 d84f4c87e0..fa4af6d6f5 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 @@ -617,6 +617,7 @@ data-ng-class="{'view-mode': isViewMode()}" data-ng-disabled="component.isCsarComponent() || !isCreateMode()" data-ng-model="component.model" + data-ng-change="onModelChange()" data-tests-id="modelName"> <option value="">SDC AID</option> <option ng-repeat="model in models | orderBy:[name]">{{model}}</option> |