aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2022-09-08 18:55:08 +0100
committerMichael Morris <michael.morris@est.tech>2022-09-19 08:38:43 +0000
commit0d38a72c022fa93dba0bf052f893e51fb73d3552 (patch)
tree25f49242e6c6666c39e32abae66e4950fe4e18ed /catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts
parent2fe3d879319a34e9802d0bc172fa11fefe771df3 (diff)
Support TOSCA functions in Node Capability Filters
Adds support to use TOSCA functions as value in the node capability filters. Removes the current capability filter component to reuse, with a few changes, the node property filters component. Fixes problems with the edition and deletion of node capability filters. Change-Id: Ic91242d6cbc24e2ce0f60b84c63e104575bef8a9 Issue-ID: SDC-4173 Signed-off-by: André Schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts')
-rw-r--r--catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts111
1 files changed, 55 insertions, 56 deletions
diff --git a/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts b/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts
index 04c7a3a03b..50ea60e4ea 100644
--- a/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts
+++ b/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts
@@ -1,5 +1,6 @@
-/*!
+/*
* Copyright © 2016-2018 European Support Limited
+ * Modification Copyright (C) 2022 Nordix Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,25 +14,22 @@
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
+
import {Component, ComponentRef, EventEmitter, Input, OnChanges, OnInit, Output} from '@angular/core';
import {ButtonModel, ComponentInstance, InputBEModel, ModalModel, PropertyBEModel, PropertyModel,} from 'app/models';
import {ModalComponent} from 'app/ng2/components/ui/modal/modal.component';
-import {ServiceDependenciesEditorComponent} from 'app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component';
+import {FilterType, ServiceDependenciesEditorComponent} from 'app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component';
import {ModalService} from 'app/ng2/services/modal.service';
import {ComponentGenericResponse} from 'app/ng2/services/responses/component-generic-response';
import {TranslateService} from 'app/ng2/shared/translator/translate.service';
import {ComponentMetadata} from '../../../../models/component-metadata';
import {ServiceInstanceObject} from '../../../../models/service-instance-properties-and-interfaces';
import {TopologyTemplateService} from '../../../services/component-services/topology-template.service';
-import {
- CapabilitiesFilterPropertiesEditorComponent
-} from "../../../pages/composition/capabilities-filter-properties-editor/capabilities-filter-properties-editor.component";
-import {CapabilityFilterConstraintUI} from "../../../../models/capability-filter-constraint";
import {ToscaFilterConstraintType} from "../../../../models/tosca-filter-constraint-type.enum";
import {CompositionService} from "../../../pages/composition/composition.service";
import {FilterConstraint} from "app/models/filter-constraint";
-import {ConstraintObjectUI} from "../../../../models/ui-models/constraint-object-ui";
-import {FilterConstraintHelper, OPERATOR_TYPES} from "../../../../utils/filter-constraint-helper";
+import {PropertyFilterConstraintUi} from "../../../../models/ui-models/property-filter-constraint-ui";
+import {ConstraintOperatorType, FilterConstraintHelper} from "../../../../utils/filter-constraint-helper";
export enum SourceType {
STATIC = 'static',
@@ -93,7 +91,7 @@ export class ServiceDependenciesComponent implements OnInit, OnChanges {
parentServiceProperties: PropertyBEModel[] = [];
constraintProperties: FilterConstraint[] = [];
constraintPropertyLabels: string[] = [];
- constraintCapabilities: CapabilityFilterConstraintUI[] = [];
+ constraintCapabilities: PropertyFilterConstraintUi[] = [];
constraintCapabilityLabels: string[] = [];
operatorTypes: any[];
capabilities: string = ToscaFilterConstraintType.CAPABILITIES;
@@ -110,7 +108,7 @@ export class ServiceDependenciesComponent implements OnInit, OnChanges {
@Input() componentInstanceCapabilitiesMap: Map<string, PropertyModel[]>;
@Output() updateRulesListEvent: EventEmitter<FilterConstraint[]> = new EventEmitter<FilterConstraint[]>();
@Output() updateNodeFilterProperties: EventEmitter<FilterConstraint[]> = new EventEmitter<FilterConstraint[]>();
- @Output() updateNodeFilterCapabilities: EventEmitter<CapabilityFilterConstraintUI[]> = new EventEmitter<CapabilityFilterConstraintUI[]>();
+ @Output() updateNodeFilterCapabilities: EventEmitter<PropertyFilterConstraintUi[]> = new EventEmitter<PropertyFilterConstraintUi[]>();
@Output() loadRulesListEvent:EventEmitter<any> = new EventEmitter();
@Output() dependencyStatus = new EventEmitter<boolean>();
@@ -123,11 +121,11 @@ export class ServiceDependenciesComponent implements OnInit, OnChanges {
ngOnInit(): void {
this.isLoading = false;
this.operatorTypes = [
- {label: FilterConstraintHelper.convertToSymbol(OPERATOR_TYPES.GREATER_THAN), value: OPERATOR_TYPES.GREATER_THAN},
- {label: FilterConstraintHelper.convertToSymbol(OPERATOR_TYPES.LESS_THAN), value: OPERATOR_TYPES.LESS_THAN},
- {label: FilterConstraintHelper.convertToSymbol(OPERATOR_TYPES.EQUAL), value: OPERATOR_TYPES.EQUAL},
- {label: FilterConstraintHelper.convertToSymbol(OPERATOR_TYPES.GREATER_OR_EQUAL), value: OPERATOR_TYPES.GREATER_OR_EQUAL},
- {label: FilterConstraintHelper.convertToSymbol(OPERATOR_TYPES.LESS_OR_EQUAL), value: OPERATOR_TYPES.LESS_OR_EQUAL}
+ {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.GREATER_THAN), value: ConstraintOperatorType.GREATER_THAN},
+ {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.LESS_THAN), value: ConstraintOperatorType.LESS_THAN},
+ {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.EQUAL), value: ConstraintOperatorType.EQUAL},
+ {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.GREATER_OR_EQUAL), value: ConstraintOperatorType.GREATER_OR_EQUAL},
+ {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.LESS_OR_EQUAL), value: ConstraintOperatorType.LESS_OR_EQUAL}
];
this.topologyTemplateService.getComponentInputsWithProperties(this.compositeService.componentType, this.compositeService.uniqueId)
.subscribe((result: ComponentGenericResponse) => {
@@ -250,17 +248,17 @@ export class ServiceDependenciesComponent implements OnInit, OnChanges {
const saveButton: ButtonModel = new ButtonModel(I18nTexts.modalCreate, 'blue', () => this.createNodeFilter(this.properties), this.getDisabled);
const modalModel: ModalModel = new ModalModel('l', I18nTexts.addNodeFilterTxt, '', [saveButton, cancelButton], 'standard');
this.modalInstance = this.modalServiceNg2.createCustomModal(modalModel);
- this.modalServiceNg2.addDynamicContentToModal(
+ this.modalServiceNg2.addDynamicContentToModalAndBindInputs(
this.modalInstance,
ServiceDependenciesEditorComponent,
{
- currentServiceName: this.currentServiceInstance.name,
- operatorTypes: this.operatorTypes,
- compositeServiceName: this.compositeService.name,
- parentServiceInputs: this.parentServiceInputs,
- parentServiceProperties: this.parentServiceProperties,
- selectedInstanceProperties: this.selectedInstanceProperties,
- selectedInstanceSiblings: this.selectedInstanceSiblings
+ 'currentServiceName': this.currentServiceInstance.name,
+ 'operatorTypes': this.operatorTypes,
+ 'compositeServiceName': this.compositeService.name,
+ 'parentServiceInputs': this.parentServiceInputs,
+ 'parentServiceProperties': this.parentServiceProperties,
+ 'selectedInstanceProperties': this.selectedInstanceProperties,
+ 'filterType': FilterType.PROPERTY,
}
);
this.modalInstance.instance.open();
@@ -275,17 +273,18 @@ export class ServiceDependenciesComponent implements OnInit, OnChanges {
const saveButton: ButtonModel = new ButtonModel(I18nTexts.modalCreate, 'blue', () => this.createNodeFilterCapabilities(this.capabilities), this.getDisabled);
const modalModel: ModalModel = new ModalModel('l', I18nTexts.addNodeFilterTxt, '', [saveButton, cancelButton], 'standard');
this.modalInstance = this.modalServiceNg2.createCustomModal(modalModel);
- this.modalServiceNg2.addDynamicContentToModal(
+ this.modalServiceNg2.addDynamicContentToModalAndBindInputs(
this.modalInstance,
- CapabilitiesFilterPropertiesEditorComponent,
+ ServiceDependenciesEditorComponent,
{
- currentServiceName: this.currentServiceInstance.name,
- operatorTypes: this.operatorTypes,
- compositeServiceName: this.compositeService.name,
- parentServiceInputs: this.parentServiceInputs,
- selectedInstanceProperties: this.selectedInstanceProperties,
- selectedInstanceSiblings: this.selectedInstanceSiblings,
- componentInstanceCapabilitiesMap: this.componentInstanceCapabilitiesMap
+ 'currentServiceName': this.currentServiceInstance.name,
+ 'operatorTypes': this.operatorTypes,
+ 'compositeServiceName': this.compositeService.name,
+ 'parentServiceInputs': this.parentServiceInputs,
+ 'parentServiceProperties': this.parentServiceProperties,
+ 'selectedInstanceProperties': this.selectedInstanceProperties,
+ 'capabilityNameAndPropertiesMap': this.componentInstanceCapabilitiesMap,
+ 'filterType': FilterType.CAPABILITY,
}
);
this.modalInstance.instance.open();
@@ -314,7 +313,7 @@ export class ServiceDependenciesComponent implements OnInit, OnChanges {
this.topologyTemplateService.createServiceFilterCapabilitiesConstraints(
this.compositeService.uniqueId,
this.currentServiceInstance.uniqueId,
- new CapabilityFilterConstraintUI(this.modalInstance.instance.dynamicContent.instance.currentRule),
+ new PropertyFilterConstraintUi(this.modalInstance.instance.dynamicContent.instance.currentRule),
this.compositeService.componentType,
constraintType
).subscribe( (response) => {
@@ -331,20 +330,20 @@ export class ServiceDependenciesComponent implements OnInit, OnChanges {
const saveButton: ButtonModel = new ButtonModel(I18nTexts.modalSave, 'blue', () => this.updateNodeFilterCapability(constraintType, index), this.getDisabled);
const modalModel: ModalModel = new ModalModel('l', I18nTexts.updateNodeFilterTxt, '', [saveButton, cancelButton], 'standard');
this.modalInstance = this.modalServiceNg2.createCustomModal(modalModel);
-
- this.modalServiceNg2.addDynamicContentToModal(
+ const selectedFilterConstraint = new PropertyFilterConstraintUi(this.constraintCapabilities[index]);
+ this.modalServiceNg2.addDynamicContentToModalAndBindInputs(
this.modalInstance,
- CapabilitiesFilterPropertiesEditorComponent,
+ ServiceDependenciesEditorComponent,
{
- serviceRuleIndex: index,
- serviceRules: _.map(this.constraintCapabilities, (rule) => new CapabilityFilterConstraintUI(rule)),
- currentServiceName: this.currentServiceInstance.name,
- operatorTypes: this.operatorTypes,
- compositeServiceName: this.compositeService.name,
- parentServiceInputs: this.parentServiceInputs,
- selectedInstanceProperties: this.selectedInstanceProperties,
- selectedInstanceSiblings: this.selectedInstanceSiblings,
- componentInstanceCapabilitiesMap: this.componentInstanceCapabilitiesMap
+ 'filterConstraint': selectedFilterConstraint,
+ 'currentServiceName': this.currentServiceInstance.name,
+ 'operatorTypes': this.operatorTypes,
+ 'compositeServiceName': this.compositeService.name,
+ 'parentServiceInputs': this.parentServiceInputs,
+ 'parentServiceProperties': this.parentServiceProperties,
+ 'selectedInstanceProperties': this.selectedInstanceProperties,
+ 'capabilityNameAndPropertiesMap': this.componentInstanceCapabilitiesMap,
+ 'filterType': FilterType.CAPABILITY,
}
);
this.modalInstance.instance.open();
@@ -355,19 +354,19 @@ export class ServiceDependenciesComponent implements OnInit, OnChanges {
const saveButton: ButtonModel = new ButtonModel(I18nTexts.modalSave, 'blue', () => this.updateNodeFilter(constraintType, index), this.getDisabled);
const modalModel: ModalModel = new ModalModel('l', I18nTexts.updateNodeFilterTxt, '', [saveButton, cancelButton], 'standard');
this.modalInstance = this.modalServiceNg2.createCustomModal(modalModel);
- this.modalServiceNg2.addDynamicContentToModal(
+ const selectedFilterConstraint = new PropertyFilterConstraintUi(this.constraintProperties[index]);
+ this.modalServiceNg2.addDynamicContentToModalAndBindInputs(
this.modalInstance,
ServiceDependenciesEditorComponent,
{
- serviceRuleIndex: index,
- serviceRules: this.constraintProperties.map(rule => new ConstraintObjectUI(rule)),
- currentServiceName: this.currentServiceInstance.name,
- operatorTypes: this.operatorTypes,
- compositeServiceName: this.compositeService.name,
- parentServiceInputs: this.parentServiceInputs,
- parentServiceProperties: this.parentServiceProperties,
- selectedInstanceProperties: this.selectedInstanceProperties,
- selectedInstanceSiblings: this.selectedInstanceSiblings
+ 'filterConstraint': selectedFilterConstraint,
+ 'currentServiceName': this.currentServiceInstance.name,
+ 'operatorTypes': this.operatorTypes,
+ 'compositeServiceName': this.compositeService.name,
+ 'parentServiceInputs': this.parentServiceInputs,
+ 'parentServiceProperties': this.parentServiceProperties,
+ 'selectedInstanceProperties': this.selectedInstanceProperties,
+ 'filterType': FilterType.PROPERTY
}
);
this.modalInstance.instance.open();
@@ -400,7 +399,7 @@ export class ServiceDependenciesComponent implements OnInit, OnChanges {
this.topologyTemplateService.updateServiceFilterCapabilitiesConstraint(
this.compositeService.uniqueId,
this.currentServiceInstance.uniqueId,
- new CapabilityFilterConstraintUI(this.modalInstance.instance.dynamicContent.instance.currentRule),
+ new PropertyFilterConstraintUi(this.modalInstance.instance.dynamicContent.instance.currentRule),
this.compositeService.componentType,
constraintType,
index