2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 import React from 'react';
28 import NodeVisualElementConstants from './NodeVisualElementConstants.js';
29 import NodeVisualElementFactory from './NodeVisualElementFactory.js';
35 this.visualElementFactory = new NodeVisualElementFactory();
37 this.setNodeMeta = this.setNodeMeta.bind(this);
40 setNodeMeta(metaObject) {
41 this.graphMeta = metaObject;
42 this.visualElementFactory.setVisualElementMeta(metaObject);
45 buildNode(nodeType, nodeProps) {
47 let translate = `translate(
48 ${nodeProps.renderProps.x},
49 ${nodeProps.renderProps.y})`;
51 ...nodeProps.renderProps,
52 className: this.graphMeta.aaiEntityNodeDescriptors[nodeType].class,
56 let nodeVisualElementsData = this.extractVisualElementArrayFromMeta(
58 let nodeVisualElements = undefined;
59 if (nodeVisualElementsData) {
60 nodeVisualElements = [];
61 nodeVisualElementsData.map((elementData, index) => {
62 if (elementData.type === NodeVisualElementConstants.BUTTON) {
63 if (nodeProps.buttons) {
64 let isButtonSelected = true;
67 isSelected: isButtonSelected
71 nodeVisualElements.push(
72 this.visualElementFactory.buildVisualElement(nodeProps.meta,
73 elementData.type, elementData, index));
75 //Draw overlay only if the node is validated
76 if (nodeProps.meta.nodeMeta.nodeValidated) {
78 if (nodeProps.meta.nodeMeta.nodeIssue) {
79 let warningOverlayProps = {
80 name: NodeVisualElementConstants.ICON_WARNING,
82 nodeVisualElements.push(
83 this.visualElementFactory.buildVisualElement(nodeProps,
84 NodeVisualElementConstants.ICON, warningOverlayProps,
85 nodeVisualElementsData.length + 1));
87 let tickOverlayProps = {
88 name: NodeVisualElementConstants.ICON_TICK,
90 nodeVisualElements.push(
91 this.visualElementFactory.buildVisualElement(nodeProps,
92 NodeVisualElementConstants.ICON, tickOverlayProps,
93 nodeVisualElementsData.length + 1));
98 if (nodeVisualElements) {
99 return React.createElement('g', finalProps, nodeVisualElements);
102 return React.createElement('g', finalProps);
105 extractVisualElementArrayFromMeta(nodeClassName) {
106 let nodeVisualElements = undefined;
107 if (this.graphMeta.aaiEntityNodeDescriptors) {
109 this.graphMeta.aaiEntityNodeDescriptors[nodeClassName].visualElements;
111 return nodeVisualElements;
115 export default NodeFactory;