1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
/*
* ============LICENSE_START===================================================
* SPARKY (AAI UI service)
* ============================================================================
* Copyright © 2017 AT&T Intellectual Property.
* Copyright © 2017 Amdocs
* All rights reserved.
* ============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=====================================================
*
* ECOMP and OpenECOMP are trademarks
* and service marks of AT&T Intellectual Property.
*/
import React, {Component} from 'react';
import {connect} from 'react-redux';
import SplitPane from 'react-split-pane';
import ForceDirectedGraph from 'generic-components/graph/ForceDirectedGraph.jsx';
import SelectedNodeDetails from 'app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx';
import i18n from 'utils/i18n/i18n';
import {
onNodeDetailsChange,
onNodeMenuChange,
splitPaneResize,
querySelectedNodeElement,
setNotificationText,
clearVIData
} from 'app/tierSupport/TierSupportActions.js';
import {
TSUI_TITLE,
TSUI_NODE_DETAILS_INITIAL_WIDTH,
TSUI_NODE_DETAILS_MIN_WIDTH,
TSUI_GRAPH_MENU_NODE_DETAILS
} from './TierSupportConstants.js';
let mapStateToProps = (
{
tierSupport:
{
tierSupportReducer,
globalAutoCompleteSearchBar
}
}) => {
let {
forceDirectedGraphRawData = {
graphCounter: -1,
nodeDataArray: [],
linkDataArray: [],
graphMeta: {}
}, windowWidth = 500,
windowHeight = 500,
graphNodeSelectedMenu = TSUI_GRAPH_MENU_NODE_DETAILS,
feedbackMsgText = '',
feedbackMsgSeverity = ''
} = tierSupportReducer;
let {
performPrepareVisualization = false,
selectedSuggestion = {}
} = globalAutoCompleteSearchBar;
return {
forceDirectedGraphRawData,
windowWidth,
windowHeight,
graphNodeSelectedMenu,
performPrepareVisualization,
selectedSuggestion,
feedbackMsgText,
feedbackMsgSeverity
};
};
let mapActionToProps = (dispatch) => {
return {
onNodeSelected: (requestObject) => {
dispatch(onNodeDetailsChange(requestObject));
},
onNodeMenuSelect: (selectedMenu) => {
dispatch(onNodeMenuChange(selectedMenu.buttonId));
},
onSplitPaneResize: (initialLoad) => {
dispatch(splitPaneResize(initialLoad));
},
onNewVIParam: (param) => {
dispatch(querySelectedNodeElement(param));
},
onMessageStateChange: (msgText, msgSeverity) => {
dispatch(setNotificationText(msgText, msgSeverity));
},
onRequestClearData: () => {
dispatch(clearVIData());
}
};
};
class TierSupport extends Component {
static propTypes = {
forceDirectedGraphRawData: React.PropTypes.object,
windowWidth: React.PropTypes.number,
windowHeight: React.PropTypes.number,
graphNodeSelectedMenu: React.PropTypes.string,
feedbackMsgText: React.PropTypes.string,
feedbackMsgSeverity: React.PropTypes.string
};
componentWillReceiveProps(nextProps) {
if (nextProps.match.params.viParam &&
nextProps.match.params.viParam !==
this.props.match.params.viParam) {
this.props.onNewVIParam(nextProps.match.params.viParam);
}
if (nextProps.feedbackMsgText !== this.props.feedbackMsgText) {
this.props.onMessageStateChange(nextProps.feedbackMsgText,
nextProps.feedbackMsgSeverity);
}
}
componentWillMount() {
if (this.props.match.params.viParam) {
this.props.onNewVIParam(this.props.match.params.viParam);
} else {
this.props.onRequestClearData();
}
}
componentDidMount() {
this.props.onSplitPaneResize(true);
}
componentWillUnmount() {
// resetting to default (empty screen)
this.props.onRequestClearData();
}
render() {
const {
forceDirectedGraphRawData,
onNodeSelected,
windowWidth,
windowHeight,
onSplitPaneResize,
onNodeMenuSelect
} = this.props;
let currentSelectedMenu = this.getCurrentSelectedMenu();
//Temp code for a demo, will be removed as Vis library is updated
let currentNodeButton = 'NODE_DETAILS';
// End temp code
return (
<div className='tier-support-ui'>
<div className='secondary-header'>
<span className='secondary-title'>{i18n(TSUI_TITLE)}</span>
</div>
<SplitPane
split='vertical'
enableResizing='true'
onDragFinished={ () => {
onSplitPaneResize(false);
} }
defaultSize={TSUI_NODE_DETAILS_INITIAL_WIDTH}
minSize={TSUI_NODE_DETAILS_MIN_WIDTH}
maxSize={-200}
primary='second'>
<div>
<ForceDirectedGraph
viewWidth={windowWidth}
viewHeight={windowHeight}
graphData={forceDirectedGraphRawData}
nodeSelectedCallback={(nodeData) => {
onNodeSelected(nodeData);
}}
nodeButtonSelectedCallback={(selectedMenuId) => {
onNodeMenuSelect(selectedMenuId);
}}
currentlySelectedNodeView={currentNodeButton}/>
</div>
<div>
{currentSelectedMenu}
</div>
</SplitPane>
</div>
);
}
getCurrentSelectedMenu() {
switch (this.props.graphNodeSelectedMenu) {
case TSUI_GRAPH_MENU_NODE_DETAILS:
if (!this.nodeDetails) {
this.nodeDetails = <SelectedNodeDetails/>;
}
return this.nodeDetails;
}
}
}
export default connect(mapStateToProps, mapActionToProps)(TierSupport);
|