3 * Copyright 2016 RIFT.IO Inc
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 import TopologyActions
from './topologyActions.js';
19 import TopologySource
from './topologySource.js';
21 import Alt
from '../alt';
22 let rw
= require('utils/rw.js');
27 this.isLoading
= true;
28 this.topologyData
= {};
30 this.detailView
= null;
31 this.hasSelected
= false;
32 // bind action listeners
33 this.bindActions(TopologyActions
);
35 // bind source listeners
36 this.exportAsync(TopologySource
);
37 this.exportPublicMethods({
38 selectNode
: this.selectNode
,
39 closeSocket
: this.closeSocket
,
40 getTopologyData
: this.getTopologyData
42 this.ajax_mode
= rw
.getSearchParams(window
.location
).ajax_mode
|| false;
44 selectNode
= (node
) => {
47 'vdur' : 'getRawVDUR',
51 apiType
[node
.type
] && this.getInstance()[apiType
[node
.type
]](node
.id
, node
.parent
? node
.parent
.id
: undefined);
53 getRawSuccess
= (data
) => {
58 getRawLoading
= () => {
65 getTopologyData
= (nsr_id
) => {
67 this.getInstance().getNSRTopology(nsr_id
);
69 this.getInstance().openNSRTopologySocket(nsr_id
);
73 openNSRTopologySocketLoading
= () => {
74 console
.log('loading')
76 openNSRTopologySocketSuccess
= (connection
) => {
79 let connectionManager
= (type
, connection
) => {
80 let ws
= window
.multiplexer
.channel(connection
);
82 console
.warn('There was an issue connecting to the ' + type
+ ' socket');
93 ws
.onmessage = function(data
) {
94 var tData
= JSON
.parse(data
.data
);
99 if(!self
.hasSelected
) {
100 newState
.hasSelected
= true;
101 self
.selectNode(tData
);
103 self
.setState(newState
);
108 connectionManager('nsr', connection
);
110 openNSRTopologySocketError
= () => {
113 handleLogout
= () => {
116 closeSocket
= () => {
118 window
.multiplexer
.channel(this.channelId
).close();
124 getNSRTopologySuccess
= (data
) => {
131 getNSRTopologyLoading
= () => {}
132 getNSRTopologyError
= (errorMessage
) => {
133 console
.log('error', errorMessage
)
134 //this.errorMessage = errorMessage;
138 export default Alt
.createStore(TopologyStore
, 'TopologyStore');