2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2021 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 import React from 'react';
22 import moment from "moment";
23 import Col from 'react-bootstrap/lib/Col';
24 import Panel from 'react-bootstrap/lib/Panel';
26 const topologyDiffCard = (props) => {
27 let showNoNodesMessage = true;
28 if(props && props.node){
29 const properties = Object.entries(props.node).map((prop, idx) => {
31 showNoNodesMessage = false;
32 let showNoRelationshipsMessage = true;
33 let showNoAttributesMessage = true;
34 let propWorkaround = prop;
36 propWorkaround = prop.data;
38 let tempProp = propWorkaround[1];
39 let attributeProperties = '';
40 let relationships = '';
41 if(tempProp.properties){
42 attributeProperties = Object.entries(tempProp.properties).map((property, idx) => {
43 let attrProp = property[1];
44 if(attrProp && attrProp.value && attrProp.value.type !== 'unchanged'){
45 showNoAttributesMessage = false;
48 <p><strong>Attribute:</strong> {attrProp.key.data} ({attrProp.value.type})</p>
51 }else if (attrProp && attrProp.type){
52 showNoAttributesMessage = false;
55 <p><strong>Attribute:</strong> {attrProp.data.key} ({attrProp.type})</p>
61 if(tempProp['related-to'] || tempProp.data['related-to']){
63 let topLevelType = null;
64 if(tempProp['related-to']){
65 rel = tempProp['related-to'];
66 }else if (tempProp.data['related-to']) {
67 rel = tempProp.data['related-to'];
68 topLevelType = tempProp.type;
70 relationships = Object.entries(rel).map((property, idx) => {
71 let relationProp = property[1];
72 if(relationProp && relationProp.type && relationProp.type.type && relationProp.type.type !== "unchanged"){
74 }else if(relationProp && relationProp.type && !relationProp.type.type && relationProp.url && relationProp.url.data){
75 showNoRelationshipsMessage = false;
78 <p><strong>Relationship</strong>: {relationProp['relationship-label'].data} {relationProp['node-type'].data} {relationProp.url.data} ({relationProp.type})</p>
81 }else if (relationProp && relationProp.type && relationProp.data){
82 showNoRelationshipsMessage = false;
85 <p><strong>Relationship</strong>: {relationProp.data['relationship-label']} {relationProp.data['node-type']} {relationProp.data.url} ({relationProp.type})</p>
88 }else if (topLevelType){
89 showNoRelationshipsMessage = false;
92 <p><strong>Relationship</strong>: {relationProp['relationship-label']} {relationProp['node-type']} {relationProp.url} ({topLevelType})</p>
100 <Panel.Heading className="custom-accordion">
101 <Panel.Title toggle><strong>Node:</strong> {prop[0]} <p className={tempProp.type ? 'show' : 'hidden'}>({tempProp.type})</p></Panel.Title>
104 <Panel.Body className='cardwrap'>
105 {attributeProperties}
106 <div className={showNoAttributesMessage ? 'show' : 'hidden'}><p><strong>No Attribute differences, current.</strong></p></div>
108 <div className={showNoRelationshipsMessage ? 'show' : 'hidden'}><p><strong>No Relationship differences, current.</strong></p></div>
115 <p><strong>Node changes in the topology states</strong></p>
121 <Col className='col-lg-12'>
122 <div className='card model-card'>
123 <div className='card-header'>
124 <h4 className='card-title'>Changes from Historic to Current State</h4>
126 <div className='card-header'></div>
127 <div className='card-content model-card-content'>
135 <Col className='col-lg-12'>
136 <div className='card model-card'>
137 <div className='card-header'>
138 <h4 className='card-title'>Unable to pull diff</h4>
140 <div className='card-header'></div>
141 <div className='card-content model-card-content'>
142 Diff unable to be calculated currently, choose a different timeframe.
150 export default topologyDiffCard;