From 3849231a17930b1bb2ba09af15673bfd07538b9d Mon Sep 17 00:00:00 2001 From: KrupaNagabhushan Date: Thu, 19 Nov 2020 14:28:00 +0000 Subject: Create inputs independent of properties Issue-ID: SDC-3431 Signed-off-by: KrupaNagabhushan Change-Id: I4f29d0e490a14292fd1aa9f96ca6621b37f325d8 --- .../logic/inputs-table/inputs-table.component.html | 6 ++-- .../logic/inputs-table/inputs-table.component.less | 3 +- .../logic/inputs-table/inputs-table.component.ts | 12 ++++---- .../properties-assignment.page.component.html | 5 +++- .../properties-assignment.page.component.ts | 35 ++++++++++++++++++++++ .../properties-assignment/services/inputs.utils.ts | 11 +++++-- .../topology-template.service.ts | 10 +++++++ 7 files changed, 69 insertions(+), 13 deletions(-) (limited to 'catalog-ui/src/app') diff --git a/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html b/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html index ee090245f0..e1638fb00f 100644 --- a/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html +++ b/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html @@ -49,6 +49,9 @@ +
+ +
@@ -124,9 +127,6 @@ [testId]="'input-' + input.name" [constraints] = "getConstraints(input)"> -
- -
diff --git a/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.less b/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.less index 74520b6314..ae6d58e72e 100644 --- a/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.less +++ b/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.less @@ -182,7 +182,8 @@ // Column: Property Name &.col1 { flex: 1 0 130px; - max-width: 250px; + max-width: 300px; + display: flex; justify-content: space-between; diff --git a/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.ts b/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.ts index 3fa7ab4a80..5ca119c075 100644 --- a/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.ts +++ b/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.ts @@ -43,14 +43,14 @@ export class InputsTableComponent { @Input() readonly: boolean; @Input() isLoading: boolean; @Input() componentType: string; - + @Input() showDelete:boolean; @Output() inputChanged: EventEmitter = new EventEmitter(); @Output() deleteInput: EventEmitter = new EventEmitter(); @Input() fePropertiesMap: InstanceFePropertiesMap; @ViewChildren('metadataViewChildren') public metadataViewChildren: QueryList; - + sortBy: String; reverse: boolean; selectedInputToDelete: InputFEModel; @@ -107,15 +107,15 @@ export class InputsTableComponent { var mapKeyError = input.metadataMapKeyError; if(input.metadataMapKeyError){ dynamicElementComponent.cmpRef.instance.control.setErrors({mapKeyError}); - } + } }; onMetadataValueChanged = (input: InputFEModel, event, metadataEntry: MetadataEntry) => { input.updateMetadataValue(metadataEntry, event.value); this.inputChanged.emit(input); }; - - + + createNewMetadataEntry = (input: InputFEModel): void => { let metadataEntry = new MetadataEntry("", ""); input.addMetadataEntry(metadataEntry); @@ -126,7 +126,7 @@ export class InputsTableComponent { input.deleteMetadataEntry(metadataEntry); this.inputChanged.emit(input); } - + onDeleteInput = () => { this.deleteInput.emit(this.selectedInputToDelete); this.modalService.closeCurrentModal(); diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html index 6856ae8358..6b3e92adfd 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html @@ -44,6 +44,7 @@
-
Add Property
+
Add Input
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 e4a8749386..74e2680b80 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 @@ -1052,6 +1052,41 @@ export class PropertiesAssignmentComponent { modal.instance.open(); } + /*** addInput ***/ + addInput = () => { + let modalTitle = 'Add Input'; + let modal = this.ModalService.createCustomModal(new ModalModel( + 'sm', + modalTitle, + null, + [ + new ButtonModel('Save', 'blue', () => { + modal.instance.dynamicContent.instance.isLoading = true; + const newInput: InputBEModel = modal.instance.dynamicContent.instance.propertyModel; + this.topologyTemplateService.createServiceInput(this.component.uniqueId, newInput) + .subscribe((response) => { + modal.instance.dynamicContent.instance.isLoading = false; + const newInputProp: InputFEModel = this.inputsUtils.convertInputBEToInputFE(response); + this.inputs.push(newInputProp); + modal.instance.close(); + }, (error) => { + modal.instance.dynamicContent.instance.isLoading = false; + this.Notification.error({ + message: 'Failed to add input:' + error, + title: 'Failure' + }); + }); + }, () => !modal.instance.dynamicContent.instance.checkFormValidForSubmit()), + new ButtonModel('Cancel', 'outline grey', () => { + modal.instance.close(); + }), + ], + null + )); + this.ModalService.addDynamicContentToModal(modal, PropertyCreatorComponent, {}); + modal.instance.open(); + } + /*** SEARCH RELATED FUNCTIONS ***/ searchPropertiesInstances = (filterData:FilterPropertiesAssignmentData) => { let instanceBePropertiesMap:InstanceBePropertiesMap; diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/services/inputs.utils.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/services/inputs.utils.ts index 408a00e7b4..948c9032bf 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/services/inputs.utils.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/services/inputs.utils.ts @@ -19,12 +19,13 @@ */ import { Injectable } from '@angular/core'; -import { InputFEModel} from "app/models"; +import { InputBEModel, InputFEModel } from "app/models"; +import { DataTypeService } from "app/ng2/services/data-type.service"; @Injectable() export class InputsUtils { - constructor() {} + constructor(private dataTypeService:DataTypeService) {} public initDefaultValueObject = (input: InputFEModel): void => { input.resetDefaultValueObjValidation(); @@ -37,4 +38,10 @@ export class InputsUtils { this.initDefaultValueObject(input); } + public convertInputBEToInputFE = (input: InputBEModel): InputFEModel => { + const newFEInput: InputFEModel = new InputFEModel(input); //Convert input to FE + this.initDefaultValueObject(newFEInput); + return newFEInput; + } + } diff --git a/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts b/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts index 14bf84599c..492acdc1d6 100644 --- a/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts +++ b/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts @@ -227,6 +227,16 @@ export class TopologyTemplateService { }); } + createServiceInput(componentId: string, inputModel: InputBEModel): Observable { + const serverObject = {}; + serverObject[inputModel.name] = inputModel; + return this.http.post(this.baseUrl + 'services/' + componentId + '/create/input', serverObject) + .map((res) => { + const input: InputBEModel = new InputBEModel(res); + return input; + }); + } + getDependencies(componentType: string, componentId: string): Observable { return this.http.get(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/dependencies'); } -- cgit 1.2.3-korg