summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src')
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/capabilities-filter-properties-editor/capabilities-filter-properties-editor.component.ts40
-rw-r--r--catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts328
2 files changed, 190 insertions, 178 deletions
diff --git a/catalog-ui/src/app/ng2/pages/composition/capabilities-filter-properties-editor/capabilities-filter-properties-editor.component.ts b/catalog-ui/src/app/ng2/pages/composition/capabilities-filter-properties-editor/capabilities-filter-properties-editor.component.ts
index 2cd4f4d1c7..3781a5163d 100644
--- a/catalog-ui/src/app/ng2/pages/composition/capabilities-filter-properties-editor/capabilities-filter-properties-editor.component.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/capabilities-filter-properties-editor/capabilities-filter-properties-editor.component.ts
@@ -19,24 +19,23 @@
* ============LICENSE_END=========================================================
*/
-import { Component } from '@angular/core';
+import {Component} from '@angular/core';
import {InputBEModel, PropertyBEModel, PropertyModel} from 'app/models';
-import { OPERATOR_TYPES } from 'app/ng2/components/logic/service-dependencies/service-dependencies.component';
-import { DropdownValue } from 'app/ng2/components/ui/form-components/dropdown/ui-element-dropdown.component';
-import { ServiceServiceNg2 } from 'app/ng2/services/component-services/service.service';
-import { PROPERTY_DATA } from 'app/utils';
-import { ServiceInstanceObject } from '../../../../models/service-instance-properties-and-interfaces';
+import {OPERATOR_TYPES} from 'app/ng2/components/logic/service-dependencies/service-dependencies.component';
+import {DropdownValue} from 'app/ng2/components/ui/form-components/dropdown/ui-element-dropdown.component';
+import {ServiceServiceNg2} from 'app/ng2/services/component-services/service.service';
+import {PROPERTY_DATA} from 'app/utils';
+import {ServiceInstanceObject} from '../../../../models/service-instance-properties-and-interfaces';
import {CapabilitiesConstraintObjectUI} from "../../../components/logic/capabilities-constraint/capabilities-constraint.component";
export class UIDropDownSourceTypesElement extends DropdownValue {
options: any[];
assignedLabel: string;
type: string;
+
constructor(input?: any) {
+ super(input ? input.value || '' : "", input ? input.label || '' : "");
if (input) {
- const value = input.value || '';
- const label = input.label || '';
- super(value, label);
this.options = input.options;
this.assignedLabel = input.assignedLabel;
this.type = input.type;
@@ -52,9 +51,6 @@ export class UIDropDownSourceTypesElement extends DropdownValue {
})
export class CapabilitiesFilterPropertiesEditorComponent {
- constructor() {
- }
-
input: {
serviceRuleIndex: number,
serviceRules: CapabilitiesConstraintObjectUI[],
@@ -100,7 +96,8 @@ export class CapabilitiesFilterPropertiesEditorComponent {
capabilityName: this.SOURCE_TYPES.CAPABILITY_NAME.value,
sourceName: this.SOURCE_TYPES.STATIC.value,
sourceType: this.SOURCE_TYPES.STATIC.value, value: '',
- constraintOperator: OPERATOR_TYPES.EQUAL});
+ constraintOperator: OPERATOR_TYPES.EQUAL
+ });
this.currentServiceName = this.input.currentServiceName;
this.operatorTypes = this.input.operatorTypes;
@@ -111,8 +108,13 @@ export class CapabilitiesFilterPropertiesEditorComponent {
}
initSourceTypes() {
- this.sourceTypes.push({label: this.SOURCE_TYPES.STATIC.label, value: this.SOURCE_TYPES.STATIC.value,
- options: [], assignedLabel: this.SOURCE_TYPES.STATIC.label, type: this.SOURCE_TYPES.STATIC.value});
+ this.sourceTypes.push({
+ label: this.SOURCE_TYPES.STATIC.label,
+ value: this.SOURCE_TYPES.STATIC.value,
+ options: [],
+ assignedLabel: this.SOURCE_TYPES.STATIC.label,
+ type: this.SOURCE_TYPES.STATIC.value
+ });
this.sourceTypes.push({
label: this.input.compositeServiceName,
value: this.input.compositeServiceName,
@@ -135,7 +137,7 @@ export class CapabilitiesFilterPropertiesEditorComponent {
if (!this.currentRule.sourceName && this.currentRule.sourceType === this.SOURCE_TYPES.STATIC.value) {
this.currentRule.sourceName = this.SOURCE_TYPES.STATIC.value;
}
- if (!this.input.componentInstanceCapabilitiesMap){
+ if (!this.input.componentInstanceCapabilitiesMap) {
this.selectedCapabilitiesPropertyObject = Array.from(this.input.componentInstanceCapabilitiesMap
.get(this.currentRule.capabilityName))
.find(property => property.name == this.currentRule.servicePropertyName);
@@ -158,7 +160,7 @@ export class CapabilitiesFilterPropertiesEditorComponent {
const selectedSourceType: UIDropDownSourceTypesElement = this.sourceTypes.find(
(t) => t.value === this.currentRule.sourceName && t.type === this.currentRule.sourceType
);
- if(selectedSourceType) {
+ if (selectedSourceType) {
this.listOfSourceOptions = selectedSourceType.options || [];
this.assignedValueLabel = selectedSourceType.assignedLabel || this.SOURCE_TYPES.STATIC.label;
this.filterOptionsByType();
@@ -166,7 +168,7 @@ export class CapabilitiesFilterPropertiesEditorComponent {
}
}
- onCapabilityNameChanged= (value: any): void => {
+ onCapabilityNameChanged = (value: any): void => {
this.selectedPropertiesByCapabilityName = this.input.componentInstanceCapabilitiesMap.get(value);
this.capabilityProperties = _.map(this.selectedPropertiesByCapabilityName, (prop) => new DropdownValue(prop.name, prop.name));
this.selectedCapabilityName = value;
@@ -193,7 +195,7 @@ export class CapabilitiesFilterPropertiesEditorComponent {
this.listOfValuesToAssign = [];
return;
}
- this.listOfValuesToAssign = this.listOfSourceOptions.reduce((result, op: PropertyModel) => {
+ this.listOfValuesToAssign = this.listOfSourceOptions.reduce((result, op: PropertyModel) => {
if (op.type === this.selectedCapabilitiesPropertyObject.type && (!op.schemaType || op.schemaType === this.selectedCapabilitiesPropertyObject.schemaType)) {
result.push(new DropdownValue(op.name, op.name));
}
diff --git a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts
index 003c6dc515..084ab32b5c 100644
--- a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts
+++ b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts
@@ -13,183 +13,193 @@
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
-import { Component } from '@angular/core';
-import { InputBEModel, PropertyBEModel } from 'app/models';
-import { ConstraintObjectUI, OPERATOR_TYPES } from 'app/ng2/components/logic/service-dependencies/service-dependencies.component';
-import { DropdownValue } from 'app/ng2/components/ui/form-components/dropdown/ui-element-dropdown.component';
-import { ServiceServiceNg2 } from 'app/ng2/services/component-services/service.service';
-import { PROPERTY_DATA } from 'app/utils';
-import { ServiceInstanceObject } from '../../../models/service-instance-properties-and-interfaces';
+import {Component} from '@angular/core';
+import {InputBEModel, PropertyBEModel} from 'app/models';
+import {
+ ConstraintObjectUI,
+ OPERATOR_TYPES
+} from 'app/ng2/components/logic/service-dependencies/service-dependencies.component';
+import {DropdownValue} from 'app/ng2/components/ui/form-components/dropdown/ui-element-dropdown.component';
+import {ServiceServiceNg2} from 'app/ng2/services/component-services/service.service';
+import {PROPERTY_DATA} from 'app/utils';
+import {ServiceInstanceObject} from '../../../models/service-instance-properties-and-interfaces';
export class UIDropDownSourceTypesElement extends DropdownValue {
- options: any[];
- assignedLabel: string;
- type: string;
- constructor(input?: any) {
- if (input) {
- const value = input.value || '';
- const label = input.label || '';
- // const hidden = input.hidden || '';
- // const selected = input.selected || '';
- super(value, label);
- this.options = input.options;
- this.assignedLabel = input.assignedLabel;
- this.type = input.type;
- }
+ options: any[];
+ assignedLabel: string;
+ type: string;
+
+ constructor(input?: any) {
+ super(input ? input.value || '' : "", input ? input.label || '' : "");
+ if (input) {
+ this.options = input.options;
+ this.assignedLabel = input.assignedLabel;
+ this.type = input.type;
}
+ }
}
// tslint:disable-next-line:max-classes-per-file
@Component({
- selector: 'service-dependencies-editor',
- templateUrl: './service-dependencies-editor.component.html',
- styleUrls: ['./service-dependencies-editor.component.less'],
- providers: [ServiceServiceNg2]
+ selector: 'service-dependencies-editor',
+ templateUrl: './service-dependencies-editor.component.html',
+ styleUrls: ['./service-dependencies-editor.component.less'],
+ providers: [ServiceServiceNg2]
})
export class ServiceDependenciesEditorComponent {
- input: {
- serviceRuleIndex: number,
- serviceRules: ConstraintObjectUI[],
- compositeServiceName: string,
- currentServiceName: string,
- parentServiceInputs: InputBEModel[],
- selectedInstanceProperties: PropertyBEModel[],
- operatorTypes: DropdownValue[],
- selectedInstanceSiblings: ServiceInstanceObject[]
- };
- currentServiceName: string;
- selectedServiceProperties: PropertyBEModel[];
- selectedPropertyObj: PropertyBEModel;
- ddValueSelectedServicePropertiesNames: DropdownValue[];
- operatorTypes: DropdownValue[];
- sourceTypes: UIDropDownSourceTypesElement[] = [];
- currentRule: ConstraintObjectUI;
- currentIndex: number;
- listOfValuesToAssign: DropdownValue[];
- listOfSourceOptions: PropertyBEModel[];
- assignedValueLabel: string;
- serviceRulesList: ConstraintObjectUI[];
-
- SOURCE_TYPES = {
- STATIC: {label: 'Static', value: 'static'},
- SERVICE_PROPERTY: {label: 'Service Property', value: 'property'}
- };
-
- ngOnInit() {
- this.currentIndex = this.input.serviceRuleIndex;
- this.serviceRulesList = this.input.serviceRules;
- this.currentRule = this.serviceRulesList && this.input.serviceRuleIndex >= 0 ?
- this.serviceRulesList[this.input.serviceRuleIndex] :
- new ConstraintObjectUI({sourceName: this.SOURCE_TYPES.STATIC.value, sourceType: this.SOURCE_TYPES.STATIC.value, value: '', constraintOperator: OPERATOR_TYPES.EQUAL});
- this.currentServiceName = this.input.currentServiceName;
- this.operatorTypes = this.input.operatorTypes;
- this.selectedServiceProperties = this.input.selectedInstanceProperties;
- this.ddValueSelectedServicePropertiesNames = _.map(this.input.selectedInstanceProperties, (prop) => new DropdownValue(prop.name, prop.name));
- this.initSourceTypes();
- this.syncRuleData();
- this.updateSourceTypesRelatedValues();
- }
-
- initSourceTypes() {
- this.sourceTypes.push({label: this.SOURCE_TYPES.STATIC.label, value: this.SOURCE_TYPES.STATIC.value,
- options: [], assignedLabel: this.SOURCE_TYPES.STATIC.label, type: this.SOURCE_TYPES.STATIC.value});
- this.sourceTypes.push({
- label: this.input.compositeServiceName,
- value: this.input.compositeServiceName,
- assignedLabel: this.SOURCE_TYPES.SERVICE_PROPERTY.label,
- type: this.SOURCE_TYPES.SERVICE_PROPERTY.value,
- options: this.input.parentServiceInputs
+ input: {
+ serviceRuleIndex: number,
+ serviceRules: ConstraintObjectUI[],
+ compositeServiceName: string,
+ currentServiceName: string,
+ parentServiceInputs: InputBEModel[],
+ selectedInstanceProperties: PropertyBEModel[],
+ operatorTypes: DropdownValue[],
+ selectedInstanceSiblings: ServiceInstanceObject[]
+ };
+ currentServiceName: string;
+ selectedServiceProperties: PropertyBEModel[];
+ selectedPropertyObj: PropertyBEModel;
+ ddValueSelectedServicePropertiesNames: DropdownValue[];
+ operatorTypes: DropdownValue[];
+ sourceTypes: UIDropDownSourceTypesElement[] = [];
+ currentRule: ConstraintObjectUI;
+ currentIndex: number;
+ listOfValuesToAssign: DropdownValue[];
+ listOfSourceOptions: PropertyBEModel[];
+ assignedValueLabel: string;
+ serviceRulesList: ConstraintObjectUI[];
+
+ SOURCE_TYPES = {
+ STATIC: {label: 'Static', value: 'static'},
+ SERVICE_PROPERTY: {label: 'Service Property', value: 'property'}
+ };
+
+ ngOnInit() {
+ this.currentIndex = this.input.serviceRuleIndex;
+ this.serviceRulesList = this.input.serviceRules;
+ this.currentRule = this.serviceRulesList && this.input.serviceRuleIndex >= 0 ?
+ this.serviceRulesList[this.input.serviceRuleIndex] :
+ new ConstraintObjectUI({
+ sourceName: this.SOURCE_TYPES.STATIC.value,
+ sourceType: this.SOURCE_TYPES.STATIC.value,
+ value: '',
+ constraintOperator: OPERATOR_TYPES.EQUAL
});
- _.forEach(this.input.selectedInstanceSiblings, (sib) =>
- this.sourceTypes.push({
- label: sib.name,
- value: sib.name,
- options: sib.properties || [],
- assignedLabel: this.SOURCE_TYPES.SERVICE_PROPERTY.label,
- type: this.SOURCE_TYPES.SERVICE_PROPERTY.value
- })
- );
- }
-
- syncRuleData() {
- if (!this.currentRule.sourceName && this.currentRule.sourceType === this.SOURCE_TYPES.STATIC.value) {
- this.currentRule.sourceName = this.SOURCE_TYPES.STATIC.value;
- }
- this.selectedPropertyObj = _.find(this.selectedServiceProperties, (prop) => prop.name === this.currentRule.servicePropertyName);
- this.updateOperatorTypesList();
- this.updateSourceTypesRelatedValues();
- }
-
- updateOperatorTypesList() {
- if (this.selectedPropertyObj && PROPERTY_DATA.SIMPLE_TYPES_COMPARABLE.indexOf(this.selectedPropertyObj.type) === -1) {
- this.operatorTypes = [{label: '=', value: OPERATOR_TYPES.EQUAL}];
- this.currentRule.constraintOperator = OPERATOR_TYPES.EQUAL;
- } else {
- this.operatorTypes = this.input.operatorTypes;
- }
- }
-
- updateSourceTypesRelatedValues() {
- if (this.currentRule.sourceName) {
- const selectedSourceType: UIDropDownSourceTypesElement = this.sourceTypes.find(
- (t) => t.value === this.currentRule.sourceName && t.type === this.currentRule.sourceType
- );
- if(selectedSourceType) {
- this.listOfSourceOptions = selectedSourceType.options || [];
- this.assignedValueLabel = selectedSourceType.assignedLabel || this.SOURCE_TYPES.STATIC.label;
- this.filterOptionsByType();
- }
- }
+ this.currentServiceName = this.input.currentServiceName;
+ this.operatorTypes = this.input.operatorTypes;
+ this.selectedServiceProperties = this.input.selectedInstanceProperties;
+ this.ddValueSelectedServicePropertiesNames = _.map(this.input.selectedInstanceProperties, (prop) => new DropdownValue(prop.name, prop.name));
+ this.initSourceTypes();
+ this.syncRuleData();
+ this.updateSourceTypesRelatedValues();
+ }
+
+ initSourceTypes() {
+ this.sourceTypes.push({
+ label: this.SOURCE_TYPES.STATIC.label,
+ value: this.SOURCE_TYPES.STATIC.value,
+ options: [],
+ assignedLabel: this.SOURCE_TYPES.STATIC.label,
+ type: this.SOURCE_TYPES.STATIC.value
+ });
+ this.sourceTypes.push({
+ label: this.input.compositeServiceName,
+ value: this.input.compositeServiceName,
+ assignedLabel: this.SOURCE_TYPES.SERVICE_PROPERTY.label,
+ type: this.SOURCE_TYPES.SERVICE_PROPERTY.value,
+ options: this.input.parentServiceInputs
+ });
+ _.forEach(this.input.selectedInstanceSiblings, (sib) =>
+ this.sourceTypes.push({
+ label: sib.name,
+ value: sib.name,
+ options: sib.properties || [],
+ assignedLabel: this.SOURCE_TYPES.SERVICE_PROPERTY.label,
+ type: this.SOURCE_TYPES.SERVICE_PROPERTY.value
+ })
+ );
+ }
+
+ syncRuleData() {
+ if (!this.currentRule.sourceName && this.currentRule.sourceType === this.SOURCE_TYPES.STATIC.value) {
+ this.currentRule.sourceName = this.SOURCE_TYPES.STATIC.value;
}
-
- onChangePage(newIndex) {
- if (newIndex >= 0 && newIndex < this.input.serviceRules.length) {
- this.currentIndex = newIndex;
- this.currentRule = this.serviceRulesList[newIndex];
- this.syncRuleData();
- }
+ this.selectedPropertyObj = _.find(this.selectedServiceProperties, (prop) => prop.name === this.currentRule.servicePropertyName);
+ this.updateOperatorTypesList();
+ this.updateSourceTypesRelatedValues();
+ }
+
+ updateOperatorTypesList() {
+ if (this.selectedPropertyObj && PROPERTY_DATA.SIMPLE_TYPES_COMPARABLE.indexOf(this.selectedPropertyObj.type) === -1) {
+ this.operatorTypes = [{label: '=', value: OPERATOR_TYPES.EQUAL}];
+ this.currentRule.constraintOperator = OPERATOR_TYPES.EQUAL;
+ } else {
+ this.operatorTypes = this.input.operatorTypes;
}
-
- onServicePropertyChanged() {
- this.selectedPropertyObj = _.find(this.selectedServiceProperties, (prop) => prop.name === this.currentRule.servicePropertyName);
- this.updateOperatorTypesList();
+ }
+
+ updateSourceTypesRelatedValues() {
+ if (this.currentRule.sourceName) {
+ const selectedSourceType: UIDropDownSourceTypesElement = this.sourceTypes.find(
+ (t) => t.value === this.currentRule.sourceName && t.type === this.currentRule.sourceType
+ );
+ if (selectedSourceType) {
+ this.listOfSourceOptions = selectedSourceType.options || [];
+ this.assignedValueLabel = selectedSourceType.assignedLabel || this.SOURCE_TYPES.STATIC.label;
this.filterOptionsByType();
- this.currentRule.value = '';
+ }
}
+ }
- onSelectSourceType() {
- this.currentRule.sourceType = this.currentRule.sourceName === this.SOURCE_TYPES.STATIC.value ?
- this.SOURCE_TYPES.STATIC.value :
- this.SOURCE_TYPES.SERVICE_PROPERTY.value;
- this.updateSourceTypesRelatedValues();
- this.currentRule.value = '';
+ onChangePage(newIndex) {
+ if (newIndex >= 0 && newIndex < this.input.serviceRules.length) {
+ this.currentIndex = newIndex;
+ this.currentRule = this.serviceRulesList[newIndex];
+ this.syncRuleData();
}
-
- filterOptionsByType() {
- if (!this.selectedPropertyObj) {
- this.listOfValuesToAssign = [];
- return;
- }
- this.listOfValuesToAssign = this.listOfSourceOptions.reduce((result, op: PropertyBEModel) => {
- if (op.type === this.selectedPropertyObj.type && (!op.schemaType || op.schemaType === this.selectedPropertyObj.schemaType)) {
- result.push(new DropdownValue(op.name, op.name));
- }
- return result;
- }, []);
- }
-
- onValueChange(isValidValue) {
- this.currentRule.updateValidity(isValidValue);
+ }
+
+ onServicePropertyChanged() {
+ this.selectedPropertyObj = _.find(this.selectedServiceProperties, (prop) => prop.name === this.currentRule.servicePropertyName);
+ this.updateOperatorTypesList();
+ this.filterOptionsByType();
+ this.currentRule.value = '';
+ }
+
+ onSelectSourceType() {
+ this.currentRule.sourceType = this.currentRule.sourceName === this.SOURCE_TYPES.STATIC.value ?
+ this.SOURCE_TYPES.STATIC.value :
+ this.SOURCE_TYPES.SERVICE_PROPERTY.value;
+ this.updateSourceTypesRelatedValues();
+ this.currentRule.value = '';
+ }
+
+ filterOptionsByType() {
+ if (!this.selectedPropertyObj) {
+ this.listOfValuesToAssign = [];
+ return;
}
-
- checkFormValidForSubmit() {
- if (!this.serviceRulesList) { // for create modal
- const isStatic = this.currentRule.sourceName === this.SOURCE_TYPES.STATIC.value;
- return this.currentRule.isValidRule(isStatic);
- }
- // for update all rules
- return this.serviceRulesList.every((rule) => rule.isValidRule(rule.sourceName === this.SOURCE_TYPES.STATIC.value));
+ this.listOfValuesToAssign = this.listOfSourceOptions.reduce((result, op: PropertyBEModel) => {
+ if (op.type === this.selectedPropertyObj.type && (!op.schemaType || op.schemaType === this.selectedPropertyObj.schemaType)) {
+ result.push(new DropdownValue(op.name, op.name));
+ }
+ return result;
+ }, []);
+ }
+
+ onValueChange(isValidValue) {
+ this.currentRule.updateValidity(isValidValue);
+ }
+
+ checkFormValidForSubmit() {
+ if (!this.serviceRulesList) { // for create modal
+ const isStatic = this.currentRule.sourceName === this.SOURCE_TYPES.STATIC.value;
+ return this.currentRule.isValidRule(isStatic);
}
+ // for update all rules
+ return this.serviceRulesList.every((rule) => rule.isValidRule(rule.sourceName === this.SOURCE_TYPES.STATIC.value));
+ }
}