aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui')
-rw-r--r--catalog-ui/src/app/models/interfaceOperation.ts3
-rw-r--r--catalog-ui/src/app/models/tosca-get-function.ts18
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html3
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.ts25
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.spec.ts4
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.ts37
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts5
7 files changed, 67 insertions, 28 deletions
diff --git a/catalog-ui/src/app/models/interfaceOperation.ts b/catalog-ui/src/app/models/interfaceOperation.ts
index 20f73af3e7..a6279a589f 100644
--- a/catalog-ui/src/app/models/interfaceOperation.ts
+++ b/catalog-ui/src/app/models/interfaceOperation.ts
@@ -23,6 +23,7 @@ import {ArtifactModel} from "./artifacts";
import {SchemaPropertyGroupModel} from "./schema-property";
import {PROPERTY_DATA, PROPERTY_TYPES} from "../utils/constants";
import {ToscaFunction} from "./tosca-function";
+import {SubPropertyToscaFunction} from "./sub-property-tosca-function";
export class InputOperationParameter {
name: string;
@@ -32,8 +33,8 @@ export class InputOperationParameter {
toscaDefaultValue?: string;
value?: any;
toscaFunction?: ToscaFunction;
+ subPropertyToscaFunctions: SubPropertyToscaFunction[];
valid:boolean= true;
- subPropertyToscaFunctions: any;
constructor(param?: any) {
if (param) {
diff --git a/catalog-ui/src/app/models/tosca-get-function.ts b/catalog-ui/src/app/models/tosca-get-function.ts
index 784c7ea407..2eb47472da 100644
--- a/catalog-ui/src/app/models/tosca-get-function.ts
+++ b/catalog-ui/src/app/models/tosca-get-function.ts
@@ -71,19 +71,19 @@ export class ToscaGetFunction implements ToscaFunction, ToscaFunctionParameter {
private buildGetInputFunctionValue(): Object {
if (this.propertyPathFromSource.length === 1) {
- if (this.toscaIndexList) {
- return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource[0], this.toscaIndexList]};
+ if (this.isToscaIndexEmpty()) {
+ return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource[0], ...this.toscaIndexList]};
}
return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource[0]]};
}
- return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource, this.toscaIndexList]};
+ return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource, ...this.toscaIndexList]};
}
private buildFunctionValueWithPropertySource(): Object {
if (this.propertySource == PropertySource.SELF) {
- if (this.toscaIndexList) {
+ if (this.isToscaIndexEmpty()) {
return {
- [this.functionType.toLowerCase()]: [PropertySource.SELF, ...this.propertyPathFromSource, this.toscaIndexList]
+ [this.functionType.toLowerCase()]: [PropertySource.SELF, ...this.propertyPathFromSource, ...this.toscaIndexList]
};
}
return {
@@ -91,9 +91,9 @@ export class ToscaGetFunction implements ToscaFunction, ToscaFunctionParameter {
};
}
if (this.propertySource == PropertySource.INSTANCE) {
- if (this.toscaIndexList) {
+ if (this.isToscaIndexEmpty()) {
return {
- [this.functionType.toLowerCase()]: [this.sourceName, ...this.propertyPathFromSource, this.toscaIndexList]
+ [this.functionType.toLowerCase()]: [this.sourceName, ...this.propertyPathFromSource, ...this.toscaIndexList]
};
}
return {
@@ -101,4 +101,8 @@ export class ToscaGetFunction implements ToscaFunction, ToscaFunctionParameter {
};
}
}
+
+ private isToscaIndexEmpty(): boolean {
+ return this.toscaIndexList && this.toscaIndexList.length > 0;
+ }
} \ No newline at end of file
diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html
index 88a4d6b437..c67563ebf1 100644
--- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html
+++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html
@@ -109,6 +109,7 @@
[isViewOnly]="isViewOnly"
[showToscaFunctionOption]="showToscaFunctionOption"
[allowDeletion]="allowDeletion"
+ [componentInstanceMap]="componentInstanceMap"
(onValueChange)="onPropertyValueChange($event)">
</app-input-list-item>
</ng-container>
@@ -137,6 +138,7 @@
[isListChild]="true"
[isViewOnly]="isViewOnly"
[allowDeletion]="allowDeletion"
+ [componentInstanceMap]="componentInstanceMap"
(onValueChange)="onPropertyValueChange($event)"
(onChildListItemDelete)="onListItemDelete($event)">
</app-input-list-item>
@@ -169,6 +171,7 @@
[nestingLevel]="nestingLevel + 1"
[isViewOnly]="isViewOnly"
[allowDeletion]="allowDeletion"
+ [componentInstanceMap]="componentInstanceMap"
(onValueChange)="onPropertyValueChange($event)"
(onDelete)="onMapKeyDelete($event)">
</app-input-list-item>
diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.ts b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.ts
index 61708ab948..21e8363eb8 100644
--- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.ts
@@ -30,6 +30,7 @@ import {ToscaFunctionValidationEvent} from "../../../../../properties-assignment
import {InstanceFeDetails} from "../../../../../../../models/instance-fe-details";
import {ToscaTypeHelper} from "app/utils/tosca-type-helper";
import {CustomToscaFunction} from "../../../../../../../models/default-custom-functions";
+import {SubPropertyToscaFunction} from "../../../../../../../models/sub-property-tosca-function";
@Component({
selector: 'app-input-list-item',
@@ -49,7 +50,7 @@ export class InputListItemComponent implements OnInit {
@Input() isMapChild: boolean = false;
@Input() showToscaFunctionOption: boolean = false;
@Input() listIndex: number;
- @Input() subPropertyToscaFunctions: SubPropertyToscaFunctions[];
+ @Input() subPropertyToscaFunctions: SubPropertyToscaFunction[];
@Input() isViewOnly: boolean;
@Input() allowDeletion: boolean = false;
@Input() toscaFunction: ToscaFunction;
@@ -86,6 +87,15 @@ export class InputListItemComponent implements OnInit {
}
}
+ ngOnChanges(): void {
+ if (this.isToscaFunction) {
+ this.property.toscaFunction = this.toscaFunction;
+ this.valueObjRef = this.toscaFunction.value;
+ } else {
+ this.property.toscaFunction = undefined;
+ }
+ }
+
private initEmptyPropertyInValueObjRef(property: PropertyBEModel) {
if (this.valueObjRef[property.name] == undefined) {
if (this.isTypeComplex(property.type) || this.isTypeMap(property.type)) {
@@ -101,18 +111,12 @@ export class InputListItemComponent implements OnInit {
getToscaFunction(key: any): any {
if (this.subPropertyToscaFunctions) {
for (let subPropertyToscaFunction of this.subPropertyToscaFunctions) {
- let found = subPropertyToscaFunction.subPropertyPath.find(value => value === key);
+ let found = subPropertyToscaFunction.subPropertyPath ? subPropertyToscaFunction.subPropertyPath.find(value => value === key) : false;
if (found) {
return subPropertyToscaFunction.toscaFunction;
}
}
}
- if ((key && this.valueObjRef[key] && this.valueObjRef[key].type)) {
- const type = this.valueObjRef[key].type;
- if (type in ToscaFunctionType) {
- return <ToscaFunction> this.valueObjRef[key];
- }
- }
return undefined;
}
@@ -347,8 +351,3 @@ export class InputListItemComponent implements OnInit {
}
}
-
-export interface SubPropertyToscaFunctions {
- subPropertyPath: string[];
- toscaFunction: ToscaFunction;
-}
diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.spec.ts b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.spec.ts
index 824592f58f..53848645d7 100644
--- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.spec.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.spec.ts
@@ -29,7 +29,7 @@ import {TranslateService} from '../../../../../shared/translator/translate.servi
import {ToscaFunction} from '../../../../../../models/tosca-function';
import {InstanceFeDetails} from "../../../../../../models/instance-fe-details";
import {CustomToscaFunction} from "../../../../../../models/default-custom-functions";
-import {SubPropertyToscaFunctions} from "./input-list-item/input-list-item.component";
+import {SubPropertyToscaFunction} from "../../../../../../models/sub-property-tosca-function";
@Component({selector: 'app-input-list-item', template: ''})
class InputListItemStubComponent {
@@ -37,7 +37,7 @@ class InputListItemStubComponent {
@Input() type: DataTypeModel;
@Input() dataTypeMap: any;
@Input() valueObjRef: any;
- @Input() subPropertyToscaFunctions: SubPropertyToscaFunctions[];
+ @Input() subPropertyToscaFunctions: SubPropertyToscaFunction[];
@Input() schema: any;
@Input() allowDeletion: any;
@Input() isViewOnly: boolean;
diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.ts b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.ts
index 208c0030f6..62c5e8a52a 100644
--- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.ts
@@ -23,9 +23,12 @@ import {Component, EventEmitter, Input, Output} from '@angular/core';
import {InputOperationParameter} from "../../../../../../models/interfaceOperation";
import {DataTypeModel} from "../../../../../../models/data-types";
import {DerivedPropertyType} from "../../../../../../models/properties-inputs/property-be-model";
+import {SubPropertyToscaFunction} from "../../../../../../models/sub-property-tosca-function";
import {PROPERTY_DATA, PROPERTY_TYPES} from "../../../../../../utils/constants";
import {InstanceFeDetails} from "../../../../../../models/instance-fe-details";
+import {ToscaFunction} from "../../../../../../models/tosca-function";
import {CustomToscaFunction} from "../../../../../../models/default-custom-functions";
+import {ToscaFunctionType} from 'app/models/tosca-function-type.enum';
@Component({
selector: 'input-list',
@@ -121,6 +124,9 @@ export class InputListComponent {
onValueChange($event: any) {
const inputOperationParameter = this._inputs.find(input => input.name == $event.name);
+ if (!inputOperationParameter.subPropertyToscaFunctions) {
+ inputOperationParameter.subPropertyToscaFunctions = [];
+ }
if (inputOperationParameter) {
inputOperationParameter.valid = true;
if ($event.isToscaFunction) {
@@ -128,15 +134,44 @@ export class InputListComponent {
if (!inputOperationParameter.toscaFunction) {
inputOperationParameter.valid = false;
}
+ } else if (this.isTypeComplex(inputOperationParameter.type)) {
+ this.setComplexType($event, inputOperationParameter);
} else {
inputOperationParameter.value = $event.value;
inputOperationParameter.toscaFunction = null;
}
+ }
this.inputsValidityChangeEvent.emit(this._inputs.every(input => input.valid === true));
this.inputValueChangeEvent.emit(new InputOperationParameter(inputOperationParameter));
- }
}
+ private setComplexType ($event, inputOperationParameter): void {
+ Object.keys($event.value).forEach(function (key) {
+ let value = $event.value[key];
+ if (!value || value.length < 1) {
+ return;
+ }
+ let subPropertyToscaFunction = inputOperationParameter.subPropertyToscaFunctions.find(existingSubPropertyToscaFunction => {
+ const prop = existingSubPropertyToscaFunction.subPropertyPath;
+ return prop && [key] && prop.length === [key].length && prop.every(function(value, index) { return value === [key][index]});
+ });
+ let valueKeys = value instanceof Object ? Object.keys(value) : undefined;
+ if (value && value.type && value.type in ToscaFunctionType) {
+ if (!subPropertyToscaFunction){
+ subPropertyToscaFunction = new SubPropertyToscaFunction();
+ inputOperationParameter.subPropertyToscaFunctions.push(subPropertyToscaFunction);
+ }
+ subPropertyToscaFunction.toscaFunction = value;
+ $event.value[key] = (value as ToscaFunction).buildValueObject();
+ let array: string[] = [];
+ array.push(key)
+ subPropertyToscaFunction.subPropertyPath = array;
+ } else if (subPropertyToscaFunction && (!valueKeys || !valueKeys.every(value => value.toUpperCase() in ToscaFunctionType))) {
+ inputOperationParameter.subPropertyToscaFunctions.splice(inputOperationParameter.subPropertyToscaFunctions.indexOf(subPropertyToscaFunction), 1)
+ }
+ });
+}
+
onDelete(inputName: string) {
this.inputDeleteEvent.emit(inputName);
}
diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts
index 812490c12a..4a68de26bc 100644
--- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts
@@ -36,7 +36,6 @@ import {DataTypeModel} from "../../../../../models/data-types";
import {InstanceFeDetails} from "../../../../../models/instance-fe-details";
import {TopologyTemplateService} from "app/ng2/services/component-services/topology-template.service";
import {CustomToscaFunction} from "../../../../../models/default-custom-functions";
-import {ToscaFunctionType} from "../../../../../models/tosca-function-type.enum";
@Component({
selector: 'operation-handler',
@@ -303,9 +302,7 @@ export class InterfaceOperationHandlerComponent {
const inputOperationParameter = this.inputs.find(value => value.name == changedInput.name);
inputOperationParameter.toscaFunction = null;
inputOperationParameter.value = changedInput.value;
- if (inputOperationParameter.subPropertyToscaFunctions) {
- inputOperationParameter.subPropertyToscaFunctions = undefined;
- }
+ inputOperationParameter.subPropertyToscaFunctions = changedInput.subPropertyToscaFunctions;
if (changedInput.isToscaFunction()) {
inputOperationParameter.toscaFunction = changedInput.toscaFunction;
inputOperationParameter.value = changedInput.toscaFunction.buildValueString();