Support for Nested/Hierarchical Services
[sdc.git] / catalog-ui / src / app / models / graph / nodes / composition-graph-nodes / composition-ci-node-service-substitution.ts
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 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  *  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.
15  *
16  *  SPDX-License-Identifier: Apache-2.0
17  *  ============LICENSE_END=========================================================
18  */
19
20 import { ImagesUrl, GraphUIObjects} from "../../../../utils/constants";
21 import {ComponentInstance, CompositionCiNodeBase} from "../../../../models";
22 import {ImageCreatorService} from "app/ng2/pages/composition/graph/common/image-creator.service";
23 export class CompositionCiNodeServiceSubstitution extends CompositionCiNodeBase {
24     private isDependent: boolean;
25     private originalImg: string;
26
27     constructor(instance:ComponentInstance,
28                 imageCreator:ImageCreatorService) {
29         super(instance, imageCreator);
30         this.isDependent =instance.isDependent();
31         this.initService();
32     }
33
34     private initService():void {
35         this.imagesPath = this.imagesPath + ImagesUrl.SERVICE_PROXY_ICONS;
36         this.img = this.imagesPath + this.componentInstance.icon + '.png';
37         this.originalImg = this.img;
38         this.imgWidth = GraphUIObjects.DEFAULT_RESOURCE_WIDTH;
39         this.classes = 'service-node';
40         if(this.archived){
41             this.classes = this.classes + ' archived';
42             return;
43         }
44         if (this.isDependent) {
45             this.classes += ' dependent';
46         }
47         if (!this.certified) {
48             this.classes = this.classes + ' not-certified';
49         }
50
51     }
52     public initUncertifiedDependentImage(node:Cy.Collection, nodeMinSize:number):string {
53         return this.enhanceImage(node, nodeMinSize, this.imagesPath + 'uncertified_dependent.png');
54     }
55
56     public initDependentImage(node:Cy.Collection, nodeMinSize:number):string {
57         return this.enhanceImage(node, nodeMinSize, this.imagesPath + 'dependent.png');
58     }
59 }