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 let alt
= require('../alt');
20 import VnfrActions
from './vnfrActions.js';
21 let Utils
= require('utils/utils.js');
22 let API_SERVER
= require('utils/rw.js').getSearchParams(window
.location
).api_server
;
23 let NODE_PORT
= require('utils/rw.js').getSearchParams(window
.location
).api_port
|| ((window
.location
.protocol
== 'https:') ? 8443 : 8000);
24 let isSocketOff
= true;
25 import $ from 'jquery';
28 openVnfrSocket: function() {
30 remote: function(state
) {
31 let nsrRegEx
= new RegExp("([0-9a-zA-Z-]+)\/vnfr$");
34 console
.log('NSR ID in url is', window
.location
.hash
.match(nsrRegEx
)[1]);
35 nsr_id
= window
.location
.hash
.match(nsrRegEx
)[1];
39 return new Promise(function(resolve
, reject
) {
45 url
: '//' + window
.location
.hostname
+ ':' + NODE_PORT
+ '/socket-polling?api_server=' + API_SERVER
,
47 beforeSend
: Utils
.addAuthorizationStub
,
49 url
: API_SERVER
+ ':' + NODE_PORT
+ '/launchpad/nsr/' + nsr_id
+ '/vnfr?api_server=' + API_SERVER
,
51 success: function(data
) {
52 Utils
.checkAndResolveSocketRequest(data
, resolve
, reject
);
57 loading
: VnfrActions
.openVnfrSocketLoading
,
58 success
: VnfrActions
.openVnfrSocketSuccess
,
59 error
: VnfrActions
.openVnfrSocketError
,