4 * Copyright 2016 RIFT.IO Inc
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import React from 'react';
20 import TopologyStore from './topologyStore.js';
21 import RecordDetail from '../recordViewer/recordDetails.jsx';
22 import './topologyView.scss';
23 import DashboardCard from 'widgets/dashboard_card/dashboard_card.jsx';
24 import AppHeader from 'widgets/header/header.jsx';
25 import TopologyTree from 'widgets/topology/topologyTree.jsx';
26 import LaunchpadBreadcrumbs from '../launchpadBreadcrumbs.jsx';
27 import Button from 'widgets/button/rw.button.js';
29 export default class Topologyview extends React.Component {
32 this.state = TopologyStore.getState();
33 TopologyStore.listen(this.storeListener);
36 this.componentWillUnmount();
37 let loc = window.location.hash.split('/');
41 window.location.hash = loc.join('/');
44 this.componentWillUnmount();
45 let loc = window.location.hash.split('/');
49 window.location.hash = loc.join('/');
51 storeListener = (state) => {
55 componentWillUnmount = () => {
56 TopologyStore.closeSocket();
57 TopologyStore.unlisten(this.storeListener);
60 let nsrRegEx = new RegExp("([0-9a-zA-Z-]+)\/compute-topology");
64 nsr_id = this.props.location.query.id;
66 console.log("TopologyView.componentDidMount exception: ", e);
68 TopologyStore.getTopologyData(nsr_id);
70 selectNode = (node) => {
71 TopologyStore.selectNode(node);
74 handleReloadData = () => {
75 this.componentDidMount();
79 let location = this.props.location;
83 onClick: this.context.router.push.bind(this, {pathname:'/viewport', query: {id: location.query.id, sdnpresent: location.query.sdnpresent}})
85 name: 'COMPUTE TOPOLOGY'
89 if (location.query.sdnpresent == 'true') {
91 name: 'NETWORK TOPOLOGY',
92 onClick: this.context.router.push.bind(this, {pathname:'/network-topology', query: {id: location.query.id, sdnpresent: location.query.sdnpresent}})
95 let nav = <AppHeader nav={navItems} />
97 <div className="app-body topologyAppBody">
99 <div className="topologyView">
100 <i className="corner-accent top left"></i>
101 <i className="corner-accent top right"></i>
103 data={this.state.topologyData}
104 selectNode={this.selectNode}
105 hasSelected={this.state.hasSelected}
107 <RecordDetail data={this.state.detailView || {}} isLoading={this.state.detailsLoading} />
108 <i className="corner-accent bottom left"></i>
109 <i className="corner-accent bottom right"></i>
116 Topologyview.contextTypes = {
117 router: React.PropTypes.object