2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 Nordix Foundation. All rights reserved.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
20 import { Component, Input } from '@angular/core';
21 import { Store } from '@ngxs/store';
23 Component as TopologyTemplate,
24 FullComponentInstance, InputBEModel,
28 import { SUBSTITUTION_FILTER_EVENTS } from 'app/utils/constants';
29 import { ComponentMetadata } from '../../../../../../models/component-metadata';
30 import { ServiceInstanceObject } from '../../../../../../models/service-instance-properties-and-interfaces';
31 import { EventListenerService } from '../../../../../../services/event-listener-service';
32 import { ConstraintObject } from '../../../../../components/logic/service-dependencies/service-dependencies.component';
33 import { TopologyTemplateService } from '../../../../../services/component-services/topology-template.service';
34 import { ComponentGenericResponse } from '../../../../../services/responses/component-generic-response';
35 import { WorkspaceService } from '../../../../workspace/workspace.service';
36 import { SelectedComponentType } from '../../../common/store/graph.actions';
37 import { CompositionService } from '../../../composition.service';
40 selector: 'substitution-filter-tab',
41 templateUrl: 'substitution-filter-tab.component.html',
42 styleUrls: ['substitution-filter-tab.component.less']
44 export class SubstitutionFilterTabComponent {
45 isComponentInstanceSelected: boolean;
47 selectedInstanceSiblings: ServiceInstanceObject[];
48 componentInstancesConstraints: any[];
49 selectedInstanceConstraints: ConstraintObject[];
50 parentServiceProperties: PropertyBEModel[];
51 parentServiceInputs: InputBEModel[];
52 componentInstanceProperties: PropertiesGroup;
53 metaData: ComponentMetadata;
55 @Input() isViewOnly: boolean;
56 @Input() componentType: SelectedComponentType;
57 @Input() component: FullComponentInstance | TopologyTemplate;
60 constructor(private store: Store,
61 private topologyTemplateService: TopologyTemplateService,
62 private workspaceService: WorkspaceService,
63 private compositionService: CompositionService,
64 private eventListenerService: EventListenerService) {
68 this.metaData = this.workspaceService.metadata;
69 this.isComponentInstanceSelected = this.componentType === SelectedComponentType.COMPONENT_INSTANCE;
70 this.initInstancesWithProperties();
73 public loadConstraints = (): void => {
74 this.topologyTemplateService.getSubstitutionFilterConstraints(this.metaData.componentType, this.metaData.uniqueId).subscribe((response) => {
75 this.componentInstancesConstraints = response.substitutionFilters;
79 public notifyDependencyEventsObserver = (isChecked: boolean): void => {
80 this.eventListenerService.notifyObservers(SUBSTITUTION_FILTER_EVENTS.ON_SUBSTITUTION_FILTER_CHANGE, isChecked);
83 public updateSelectedInstanceConstraints = (constraintsList:Array<ConstraintObject>):void => {
84 this.componentInstancesConstraints[this.component.uniqueId].properties = constraintsList;
85 this.selectedInstanceConstraints = this.componentInstancesConstraints[this.component.uniqueId].properties;
88 private initInstancesWithProperties = (): void => {
89 this.topologyTemplateService.getComponentPropertiesAndInputsForSubstitutionFilter(this.metaData.componentType, this.metaData.uniqueId)
90 .subscribe((genericResponse: ComponentGenericResponse) => {
91 this.parentServiceProperties = genericResponse.properties;
92 this.parentServiceInputs = genericResponse.inputs;