a0588c0daacfd3493c7d6032a5226b4ece7b7815
[sdc.git] / catalog-ui / src / app / ng2 / components / logic / service-dependencies / service-dependencies.component.ts
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  * Modification Copyright (C) 2022 Nordix Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing
15  * permissions and limitations under the License.
16  */
17
18 import {Component, ComponentRef, EventEmitter, Input, OnChanges, OnInit, Output} from '@angular/core';
19 import {ButtonModel, ComponentInstance, InputBEModel, ModalModel, PropertyBEModel, PropertyModel,} from 'app/models';
20 import {ModalComponent} from 'app/ng2/components/ui/modal/modal.component';
21 import {FilterType, ServiceDependenciesEditorComponent} from 'app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component';
22 import {ModalService} from 'app/ng2/services/modal.service';
23 import {ComponentGenericResponse} from 'app/ng2/services/responses/component-generic-response';
24 import {TranslateService} from 'app/ng2/shared/translator/translate.service';
25 import {ComponentMetadata} from '../../../../models/component-metadata';
26 import {ServiceInstanceObject} from '../../../../models/service-instance-properties-and-interfaces';
27 import {TopologyTemplateService} from '../../../services/component-services/topology-template.service';
28 import {ToscaFilterConstraintType} from "../../../../models/tosca-filter-constraint-type.enum";
29 import {CompositionService} from "../../../pages/composition/composition.service";
30 import {FilterConstraint} from "app/models/filter-constraint";
31 import {PropertyFilterConstraintUi} from "../../../../models/ui-models/property-filter-constraint-ui";
32 import {ConstraintOperatorType, FilterConstraintHelper} from "../../../../utils/filter-constraint-helper";
33 import {CustomToscaFunction} from "../../../../models/default-custom-functions";
34
35 export enum SourceType {
36     STATIC = 'static',
37     TOSCA_FUNCTION = 'tosca_function',
38     TOSCA_FUNCTION_LIST = 'tosca_function_list'
39 }
40
41 class I18nTexts {
42     static removeDirectiveModalTitle: string;
43     static removeDirectiveModalText: string;
44     static updateDirectiveModalTitle: string;
45     static updateDirectiveModalText: string;
46     static modalApprove: string;
47     static modalCancel: string;
48     static modalCreate: string;
49     static modalSave: string;
50     static modalDelete: string;
51     static addNodeFilterTxt: string;
52     static updateNodeFilterTxt: string;
53     static deleteNodeFilterTxt: string;
54     static deleteNodeFilterMsg: string;
55     static validateCapabilitiesTxt: string
56     static validateCapabilitiesMsg: string
57     static validateNodePropertiesTxt: string
58     static validateNodePropertiesMsg: string
59
60     public static translateTexts(translateService) {
61             I18nTexts.removeDirectiveModalTitle = translateService.translate('DIRECTIVES_AND_NODE_FILTER_REMOVE_TITLE');
62             I18nTexts.removeDirectiveModalText = translateService.translate('DIRECTIVES_AND_NODE_FILTER_REMOVE_TEXT');
63             I18nTexts.updateDirectiveModalTitle = translateService.translate('DIRECTIVES_AND_NODE_FILTER_UPDATE_TITLE');
64             I18nTexts.updateDirectiveModalText = translateService.translate('DIRECTIVES_AND_NODE_FILTER_UPDATE_TEXT');
65             I18nTexts.modalApprove = translateService.translate('MODAL_APPROVE');
66             I18nTexts.modalCancel = translateService.translate('MODAL_CANCEL');
67             I18nTexts.modalCreate = translateService.translate('MODAL_CREATE');
68             I18nTexts.modalSave = translateService.translate('MODAL_SAVE');
69             I18nTexts.modalDelete = translateService.translate('MODAL_DELETE');
70             I18nTexts.addNodeFilterTxt = translateService.translate('DIRECTIVES_AND_NODE_FILTER_ADD_NODE_FILTER');
71             I18nTexts.updateNodeFilterTxt = translateService.translate('DIRECTIVES_AND_NODE_FILTER_UPDATE_NODE_FILTER');
72             I18nTexts.deleteNodeFilterTxt = translateService.translate('DIRECTIVES_AND_NODE_FILTER_DELETE_NODE_FILTER');
73             I18nTexts.deleteNodeFilterMsg = translateService.translate('DIRECTIVES_AND_NODE_FILTER_DELETE_NODE_FILTER_MSG');
74             I18nTexts.validateCapabilitiesTxt = translateService.translate('VALIDATE_CAPABILITIES_TXT');
75             I18nTexts.validateCapabilitiesMsg = translateService.translate('VALIDATE_CAPABILITIES_MSG');
76             I18nTexts.validateNodePropertiesTxt = translateService.translate('VALIDATE_NODE_PROPERTIES_TXT');
77             I18nTexts.validateNodePropertiesMsg = translateService.translate('VALIDATE_NODE_PROPERTIES_MSG');
78     }
79 }
80
81 @Component({
82     selector: 'service-dependencies',
83     templateUrl: './service-dependencies.component.html',
84     styleUrls: ['service-dependencies.component.less'],
85     providers: [ModalService, TranslateService]
86 })
87
88 export class ServiceDependenciesComponent implements OnInit, OnChanges {
89     modalInstance: ComponentRef<ModalComponent>;
90     isDependent: boolean;
91     isLoading: boolean;
92     parentServiceInputs: InputBEModel[] = [];
93     parentServiceProperties: PropertyBEModel[] = [];
94     constraintProperties: FilterConstraint[] = [];
95     constraintPropertyLabels: string[] = [];
96     constraintCapabilities: PropertyFilterConstraintUi[] = [];
97     constraintCapabilityLabels: string[] = [];
98     operatorTypes: any[];
99     capabilities: string = ToscaFilterConstraintType.CAPABILITIES;
100     properties: string = ToscaFilterConstraintType.PROPERTIES;
101     private componentInstancesConstraints: FilterConstraint[] = [];
102     isEditable: boolean;
103     customToscaFunctions: Array<CustomToscaFunction>;
104
105     @Input() readonly: boolean;
106     @Input() compositeService: ComponentMetadata;
107     @Input() currentServiceInstance: ComponentInstance;
108     @Input() selectedInstanceSiblings: ServiceInstanceObject[];
109     @Input() selectedInstanceConstraints: FilterConstraint[] = [];
110     @Input() selectedInstanceProperties: PropertyBEModel[] = [];
111     @Input() componentInstanceCapabilitiesMap: Map<string, PropertyModel[]>;
112     @Output() updateRulesListEvent: EventEmitter<FilterConstraint[]> = new EventEmitter<FilterConstraint[]>();
113     @Output() updateNodeFilterProperties: EventEmitter<FilterConstraint[]> = new EventEmitter<FilterConstraint[]>();
114     @Output() updateNodeFilterCapabilities: EventEmitter<PropertyFilterConstraintUi[]> = new EventEmitter<PropertyFilterConstraintUi[]>();
115     @Output() loadRulesListEvent:EventEmitter<any> = new EventEmitter();
116     @Output() dependencyStatus = new EventEmitter<boolean>();
117
118     constructor(private topologyTemplateService: TopologyTemplateService,
119                 private modalServiceNg2: ModalService,
120                 private translateService: TranslateService,
121                 private compositionService: CompositionService) {
122     }
123
124     ngOnInit(): void {
125         this.isLoading = false;
126         this.operatorTypes = [
127             {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.GREATER_THAN), value: ConstraintOperatorType.GREATER_THAN},
128             {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.LESS_THAN), value: ConstraintOperatorType.LESS_THAN},
129             {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.EQUAL), value: ConstraintOperatorType.EQUAL},
130             {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.GREATER_OR_EQUAL), value: ConstraintOperatorType.GREATER_OR_EQUAL},
131             {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.LESS_OR_EQUAL), value: ConstraintOperatorType.LESS_OR_EQUAL},
132             {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.LENGTH), value: ConstraintOperatorType.LENGTH},
133             {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.IN_RANGE), value: ConstraintOperatorType.IN_RANGE},
134             {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.MIN_LENGTH), value: ConstraintOperatorType.MIN_LENGTH},
135             {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.MAX_LENGTH), value: ConstraintOperatorType.MAX_LENGTH},
136             {label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.PATTERN), value: ConstraintOperatorType.PATTERN}
137         ];
138         this.topologyTemplateService.getComponentInputsWithProperties(this.compositeService.componentType, this.compositeService.uniqueId)
139         .subscribe((result: ComponentGenericResponse) => {
140             this.parentServiceInputs = result.inputs;
141             this.parentServiceProperties = result.properties;
142         });
143         this.initCustomToscaFunctions();
144         this.loadNodeFilter();
145         this.translateService.languageChangedObservable.subscribe((lang) => {
146             I18nTexts.translateTexts(this.translateService);
147         });
148     }
149
150     private initCustomToscaFunctions() {
151         if (!this.customToscaFunctions) {
152             this.customToscaFunctions = [];
153             this.topologyTemplateService.getDefaultCustomFunction().toPromise().then((data) => {
154                 for (let customFunction of data) {
155                     this.customToscaFunctions.push(new CustomToscaFunction(customFunction));
156                 }
157             });
158         }
159     }
160
161     ngOnChanges(changes): void {
162         if (changes.currentServiceInstance) {
163             this.currentServiceInstance = changes.currentServiceInstance.currentValue;
164             this.isDependent = this.currentServiceInstance.isDependent();
165         }
166         if (changes.selectedInstanceConstraints && changes.selectedInstanceConstraints.currentValue !== changes.selectedInstanceConstraints.previousValue) {
167             this.selectedInstanceConstraints = changes.selectedInstanceConstraints.currentValue;
168             this.loadNodeFilter();
169         }
170     }
171
172     private getActualDirectiveValue = (): string[] => {
173         return this.currentServiceInstance.directives.length > 0 ? this.currentServiceInstance.directives : [];
174     }
175
176     public openRemoveDependencyModal = (): ComponentRef<ModalComponent> => {
177         const actionButton: ButtonModel = new ButtonModel(I18nTexts.modalApprove, 'blue', this.onUncheckDependency);
178         const cancelButton: ButtonModel = new ButtonModel(I18nTexts.modalCancel, 'grey', this.onCloseRemoveDependencyModal);
179         const modalModel: ModalModel = new ModalModel('sm', I18nTexts.removeDirectiveModalTitle,
180             I18nTexts.removeDirectiveModalText, [actionButton, cancelButton]);
181         this.loadNodeFilter();
182         return this.modalServiceNg2.createCustomModal(modalModel);
183     }
184
185     private loadNodeFilter = (): void => {
186         this.topologyTemplateService.getServiceFilterConstraints(this.compositeService.componentType, this.compositeService.uniqueId).subscribe((response) => {
187             if (response.nodeFilterforNode && response.nodeFilterforNode[this.currentServiceInstance.uniqueId]) {
188                 this.componentInstancesConstraints = response.nodeFilterforNode;
189                 this.constraintProperties = response.nodeFilterforNode[this.currentServiceInstance.uniqueId].properties;
190                 this.buildConstraintPropertyLabels();
191                 this.constraintCapabilities = response.nodeFilterforNode[this.currentServiceInstance.uniqueId].capabilities;
192                 this.buildCapabilityFilterConstraintLabels();
193             }
194         });
195     }
196
197     onUncheckDependency = (): void => {
198         this.modalServiceNg2.closeCurrentModal();
199         this.isLoading = true;
200         const isDepOrig = this.isDependent;
201         const rulesListOrig = this.componentInstancesConstraints;
202         this.currentServiceInstance.unmarkAsDependent(this.getActualDirectiveValue());
203         this.updateComponentInstance(isDepOrig, rulesListOrig);
204     }
205
206     onCloseRemoveDependencyModal = (): void => {
207         this.isDependent = true;
208         this.modalServiceNg2.closeCurrentModal();
209     }
210
211     onAddDirectives(directives: string[]): void {
212         this.isEditable = false;
213         this.setDirectiveValue(directives);
214         const rulesListOrig = this.componentInstancesConstraints;
215         this.constraintProperties = [];
216         this.constraintPropertyLabels = [];
217         this.constraintCapabilities = [];
218         this.constraintCapabilityLabels = [];
219         this.loadNodeFilter();
220         this.updateComponentInstance(this.isDependent, rulesListOrig);
221     }
222
223     private onRemoveDirective(): void {
224         this.openRemoveDependencyModal().instance.open();
225         this.constraintProperties = [];
226         this.constraintPropertyLabels = [];
227         this.constraintCapabilities = [];
228         this.constraintCapabilityLabels = [];
229     }
230
231     private onEditDirectives(): void {
232         this.isEditable = true;
233     }
234
235     private setDirectiveValue(newDirectiveValues: string[]): void {
236         this.currentServiceInstance.setDirectiveValue(newDirectiveValues);
237     }
238
239     updateComponentInstance(isDependentOrigVal: boolean, rulesListOrig: FilterConstraint[]): void {
240         this.isLoading = true;
241         this.topologyTemplateService.updateComponentInstance(this.compositeService.uniqueId,
242                                                              this.compositeService.componentType,
243                                                              this.currentServiceInstance)
244                                                              .subscribe((updatedServiceIns: ComponentInstance) => {
245             const selectedComponentInstance = this.compositionService.getComponentInstances()
246             .find(componentInstance => componentInstance.uniqueId == this.currentServiceInstance.uniqueId);
247             selectedComponentInstance.directives = updatedServiceIns.directives;
248             this.currentServiceInstance = new ComponentInstance(updatedServiceIns);
249             this.isDependent = this.currentServiceInstance.isDependent();
250             this.dependencyStatus.emit(this.isDependent);
251             if (this.isDependent) {
252                 this.loadRulesListEvent.emit();
253             }
254             this.isLoading = false;
255         }, (err) => {
256             this.isDependent = isDependentOrigVal;
257             this.componentInstancesConstraints = rulesListOrig;
258             this.isLoading = false;
259             console.error('An error has occurred.', err);
260         });
261     }
262
263     onAddNodeFilter = (): void => {
264         if (!this.selectedInstanceProperties) {
265             this.modalServiceNg2.openAlertModal(I18nTexts.validateNodePropertiesTxt, I18nTexts.validateNodePropertiesMsg);
266         } else {
267             const cancelButton: ButtonModel = new ButtonModel(I18nTexts.modalCancel, 'outline white', this.modalServiceNg2.closeCurrentModal);
268             const saveButton: ButtonModel = new ButtonModel(I18nTexts.modalCreate, 'blue', () => this.createNodeFilter(this.properties), this.getDisabled);
269             const modalModel: ModalModel = new ModalModel('l', I18nTexts.addNodeFilterTxt, '', [saveButton, cancelButton], 'standard');
270             this.modalInstance = this.modalServiceNg2.createCustomModal(modalModel);
271             this.modalServiceNg2.addDynamicContentToModalAndBindInputs(
272                 this.modalInstance,
273                 ServiceDependenciesEditorComponent,
274                 {
275                     'currentServiceName': this.currentServiceInstance.name,
276                     'operatorTypes': this.operatorTypes,
277                     'compositeServiceName': this.compositeService.name,
278                     'parentServiceInputs': this.parentServiceInputs,
279                     'parentServiceProperties': this.parentServiceProperties,
280                     'selectedInstanceProperties': this.selectedInstanceProperties,
281                     'customToscaFunctions': this.customToscaFunctions,
282                     'filterType': FilterType.PROPERTY,
283                 }
284             );
285             this.modalInstance.instance.open();
286         }
287     }
288
289     onAddNodeFilterCapabilities = (): void => {
290         if (this.componentInstanceCapabilitiesMap.size == 0) {
291             this.modalServiceNg2.openAlertModal(I18nTexts.validateCapabilitiesTxt, I18nTexts.validateCapabilitiesMsg);
292         } else {
293             const cancelButton: ButtonModel = new ButtonModel(I18nTexts.modalCancel, 'outline white', this.modalServiceNg2.closeCurrentModal);
294             const saveButton: ButtonModel = new ButtonModel(I18nTexts.modalCreate, 'blue', () => this.createNodeFilterCapabilities(this.capabilities), this.getDisabled);
295             const modalModel: ModalModel = new ModalModel('l', I18nTexts.addNodeFilterTxt, '', [saveButton, cancelButton], 'standard');
296             this.modalInstance = this.modalServiceNg2.createCustomModal(modalModel);
297             this.modalServiceNg2.addDynamicContentToModalAndBindInputs(
298                 this.modalInstance,
299                 ServiceDependenciesEditorComponent,
300                 {
301                     'currentServiceName': this.currentServiceInstance.name,
302                     'operatorTypes': this.operatorTypes,
303                     'compositeServiceName': this.compositeService.name,
304                     'parentServiceInputs': this.parentServiceInputs,
305                     'parentServiceProperties': this.parentServiceProperties,
306                     'selectedInstanceProperties': this.selectedInstanceProperties,
307                     'capabilityNameAndPropertiesMap': this.componentInstanceCapabilitiesMap,
308                     'filterType': FilterType.CAPABILITY,
309                 }
310             );
311             this.modalInstance.instance.open();
312         }
313     }
314
315     createNodeFilter = (constraintType: string): void => {
316         this.customToscaFunctions = this.modalInstance.instance.dynamicContent.instance.customToscaFunctions;
317         this.isLoading = true;
318         this.topologyTemplateService.createServiceFilterConstraints(
319             this.compositeService.uniqueId,
320             this.currentServiceInstance.uniqueId,
321             new FilterConstraint(this.modalInstance.instance.dynamicContent.instance.currentRule),
322             this.compositeService.componentType,
323             constraintType
324         ).subscribe( (response) => {
325             this.emitEventOnChanges(constraintType, response);
326             this.isLoading = false;
327         }, (err) => {
328             this.isLoading = false;
329         });
330         this.modalServiceNg2.closeCurrentModal();
331     }
332
333     createNodeFilterCapabilities = (constraintType: string): void => {
334         this.isLoading = true;
335         this.topologyTemplateService.createServiceFilterCapabilitiesConstraints(
336             this.compositeService.uniqueId,
337             this.currentServiceInstance.uniqueId,
338             new PropertyFilterConstraintUi(this.modalInstance.instance.dynamicContent.instance.currentRule),
339             this.compositeService.componentType,
340             constraintType
341         ).subscribe( (response) => {
342             this.emitEventOnChanges(constraintType, response);
343             this.isLoading = false;
344         }, (err) => {
345             this.isLoading = false;
346         });
347         this.modalServiceNg2.closeCurrentModal();
348     }
349
350     onSelectNodeFilterCapability(constraintType: string, index: number): void {
351         const cancelButton: ButtonModel = new ButtonModel(I18nTexts.modalCancel, 'outline white', this.modalServiceNg2.closeCurrentModal);
352         const saveButton: ButtonModel = new ButtonModel(I18nTexts.modalSave, 'blue', () => this.updateNodeFilterCapability(constraintType, index), this.getDisabled);
353         const modalModel: ModalModel = new ModalModel('l', I18nTexts.updateNodeFilterTxt, '', [saveButton, cancelButton], 'standard');
354         this.modalInstance = this.modalServiceNg2.createCustomModal(modalModel);
355         const selectedFilterConstraint = new PropertyFilterConstraintUi(this.constraintCapabilities[index]);
356         this.modalServiceNg2.addDynamicContentToModalAndBindInputs(
357             this.modalInstance,
358             ServiceDependenciesEditorComponent,
359             {
360                 'filterConstraint': selectedFilterConstraint,
361                 'currentServiceName': this.currentServiceInstance.name,
362                 'operatorTypes': this.operatorTypes,
363                 'compositeServiceName': this.compositeService.name,
364                 'parentServiceInputs': this.parentServiceInputs,
365                 'parentServiceProperties': this.parentServiceProperties,
366                 'selectedInstanceProperties': this.selectedInstanceProperties,
367                 'capabilityNameAndPropertiesMap': this.componentInstanceCapabilitiesMap,
368                 'filterType': FilterType.CAPABILITY,
369             }
370         );
371         this.modalInstance.instance.open();
372     }
373
374     onSelectNodeFilter(constraintType: string, index: number): void {
375         const cancelButton: ButtonModel = new ButtonModel(I18nTexts.modalCancel, 'outline white', this.modalServiceNg2.closeCurrentModal);
376         const saveButton: ButtonModel = new ButtonModel(I18nTexts.modalSave, 'blue', () => this.updateNodeFilter(constraintType, index), this.getDisabled);
377         const modalModel: ModalModel = new ModalModel('l', I18nTexts.updateNodeFilterTxt, '', [saveButton, cancelButton], 'standard');
378         this.modalInstance = this.modalServiceNg2.createCustomModal(modalModel);
379         const selectedFilterConstraint = new PropertyFilterConstraintUi(this.constraintProperties[index]);
380         this.modalServiceNg2.addDynamicContentToModalAndBindInputs(
381             this.modalInstance,
382             ServiceDependenciesEditorComponent,
383             {
384                 'filterConstraint': selectedFilterConstraint,
385                 'currentServiceName': this.currentServiceInstance.name,
386                 'operatorTypes': this.operatorTypes,
387                 'compositeServiceName': this.compositeService.name,
388                 'parentServiceInputs': this.parentServiceInputs,
389                 'parentServiceProperties': this.parentServiceProperties,
390                 'selectedInstanceProperties': this.selectedInstanceProperties,
391                 'customToscaFunctions': this.customToscaFunctions,
392                 'filterType': FilterType.PROPERTY
393             }
394         );
395
396         this.modalInstance.instance.open();
397     }
398
399     getDisabled = (): boolean =>  {
400         return !this.modalInstance.instance.dynamicContent.instance.checkFormValidForSubmit();
401     }
402
403     updateNodeFilter = (constraintType: string, index: number): void => {
404         this.isLoading = true;
405         this.topologyTemplateService.updateServiceFilterConstraints(
406             this.compositeService.uniqueId,
407             this.currentServiceInstance.uniqueId,
408             new FilterConstraint(this.modalInstance.instance.dynamicContent.instance.currentRule),
409             this.compositeService.componentType,
410             constraintType,
411             index
412         ).subscribe((response) => {
413             this.emitEventOnChanges(constraintType, response);
414             this.isLoading = false;
415         }, (err) => {
416             this.isLoading = false;
417         });
418         this.modalServiceNg2.closeCurrentModal();
419     }
420
421     updateNodeFilterCapability = (constraintType: string, index: number): void => {
422         this.isLoading = true;
423         this.topologyTemplateService.updateServiceFilterCapabilitiesConstraint(
424             this.compositeService.uniqueId,
425             this.currentServiceInstance.uniqueId,
426             new PropertyFilterConstraintUi(this.modalInstance.instance.dynamicContent.instance.currentRule),
427             this.compositeService.componentType,
428             constraintType,
429             index
430         ).subscribe((response) => {
431             this.emitEventOnChanges(constraintType, response);
432             this.isLoading = false;
433         }, (err) => {
434             this.isLoading = false;
435         });
436         this.modalServiceNg2.closeCurrentModal();
437     }
438
439     onDeleteNodeFilter = (constraintType: string, index: number): void => {
440         this.isLoading = true;
441         this.topologyTemplateService.deleteServiceFilterConstraints(
442             this.compositeService.uniqueId,
443             this.currentServiceInstance.uniqueId,
444             index,
445             this.compositeService.componentType,
446             constraintType
447         ).subscribe( (response) => {
448             this.emitEventOnChanges(constraintType, response);
449             this.isLoading = false;
450         }, (err) => {
451             this.isLoading = false;
452         });
453         this.modalServiceNg2.closeCurrentModal();
454     }
455
456     private emitEventOnChanges(constraintType: string, response) {
457         if (this.properties === constraintType) {
458             this.updateNodeFilterProperties.emit(response.properties);
459             this.constraintProperties = response.properties;
460             this.buildConstraintPropertyLabels();
461         } else {
462             this.updateNodeFilterCapabilities.emit(response.capabilities);
463             this.constraintCapabilities = response.capabilities;
464             this.buildCapabilityFilterConstraintLabels();
465         }
466     }
467
468     openDeleteModal = (constraintType: string, index: number): void => {
469         this.modalServiceNg2.createActionModal(I18nTexts.deleteNodeFilterTxt, I18nTexts.deleteNodeFilterMsg,
470             I18nTexts.modalDelete, () => this.onDeleteNodeFilter(constraintType, index), I18nTexts.modalCancel).instance.open();
471     }
472
473     private buildConstraintPropertyLabels(): void {
474         this.constraintPropertyLabels = [];
475         if (!this.constraintProperties) {
476             return;
477         }
478         this.constraintProperties.forEach(
479             constraint => this.constraintPropertyLabels.push(FilterConstraintHelper.buildFilterConstraintLabel(constraint))
480         )
481     }
482
483     private buildCapabilityFilterConstraintLabels(): void {
484         this.constraintCapabilityLabels = [];
485         if (!this.constraintCapabilities) {
486             return;
487         }
488         this.constraintCapabilities.forEach(
489             constraint => this.constraintCapabilityLabels.push(FilterConstraintHelper.buildFilterConstraintLabel(constraint))
490         )
491     }
492
493 }