2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 * Created by obarda on 7/5/2016.
25 import {ComponentType} from "../../utils/constants";
26 import {ComponentMetadata} from "../component-metadata";
27 import {RequirementsGroup} from "../requirement";
28 import {CapabilitiesGroup} from "../capability";
30 export class LeftPaletteComponent {
38 componentSubType:string;
39 searchFilterTerms:string;
40 certifiedIconClass:string;
42 isRequirmentAndCapabilitiesLoaded:boolean;
46 lifecycleState:string;
51 capabilities:CapabilitiesGroup;
52 requirements:RequirementsGroup;
54 constructor(public component:ComponentMetadata) {
55 this.icon = component.icon;
56 this.version = component.version;
57 this.uniqueId = component.uniqueId;
58 this.isRequirmentAndCapabilitiesLoaded = false;
59 this.uuid = component.uuid;
60 this.name = component.name;
61 this.allVersions = component.allVersions;
62 this.componentType = component.componentType;
63 this.systemName = component.systemName;
65 if (component.categories && component.categories[0] && component.categories[0].subcategories && component.categories[0].subcategories[0]) {
66 this.mainCategory = component.categories[0].name;
67 this.subCategory = component.categories[0].subcategories[0].name;
69 this.mainCategory = 'Generic';
70 this.subCategory = 'Generic';
73 this.componentSubType = component.resourceType ? component.resourceType: 'SERVICE';
74 this.initDisplayName(component.name);
75 this.searchFilterTerms = (this.displayName + ' ' + component.description + ' ' + component.tags.join(' ')).toLowerCase() + ' ' + component.version;
76 this.initIconSprite(component.icon);
77 this.certifiedIconClass = component.lifecycleState != 'CERTIFIED' ? 'non-certified' : '';
78 if (component.icon === 'vl' || component.icon === 'cp') {
79 this.certifiedIconClass = this.certifiedIconClass + " " + 'smaller-icon';
83 public initDisplayName = (name:string):void => {
85 _.last(_.last(_.last(_.last(_.last(_.last(_.last(_.last(name.split('tosca.nodes.'))
86 .split('network.')).split('relationships.')).split('org.openecomp.')).split('resource.nfv.'))
87 .split('nodes.module.')).split('cp.')).split('vl.'));
89 this.displayName = newName;
91 this.displayName = name;
95 public initIconSprite = (icon:string):void => {
96 switch (this.componentSubType) {
97 case ComponentType.SERVICE:
98 this.iconClass = "sprite-services-icons " + icon;
101 this.iconClass = "sprite-resource-icons " + icon;
105 public getComponentSubType = ():string => {
106 return this.componentSubType;