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 Alt
from './skyquakeAltInstance.js';
19 import $ from 'jquery';
20 import SkyquakeContainerActions
from './skyquakeContainerActions'
22 let Utils
= require('utils/utils.js');
23 let API_SERVER
= require('utils/rw.js').getSearchParams(window
.location
).api_server
;
24 let HOST
= API_SERVER
;
25 let NODE_PORT
= require('utils/rw.js').getSearchParams(window
.location
).api_port
|| ((window
.location
.protocol
== 'https:') ? 8443 : 8000);
26 let DEV_MODE
= require('utils/rw.js').getSearchParams(window
.location
).dev_mode
|| false;
27 let RW_REST_API_PORT
= require('utils/rw.js').getSearchParams(window
.location
).rw_rest_api_port
|| 8008;
30 HOST
= window
.location
.protocol
+ '//' + window
.location
.hostname
;
37 return new Promise(function(resolve
, reject
) {
41 // beforeSend: Utils.addAuthorizationStub,
42 success: function(data
) {
43 Utils
.detectInactivity();
49 success
: SkyquakeContainerActions
.getSkyquakeNavSuccess
55 remote: function(state
, recordID
) {
56 return new Promise(function(resolve
, reject
) {
58 url
: '//' + window
.location
.hostname
+ ':' + NODE_PORT
+ '/api/operational/restconf-state/streams?api_server=' + API_SERVER
,
60 beforeSend
: Utils
.addAuthorizationStub
,
61 success: function(data
) {
64 }).fail(function(xhr
) {
65 //Authentication and the handling of fail states should be wrapped up into a connection class.
66 Utils
.checkAuthentication(xhr
.status
);
70 loading
: SkyquakeContainerActions
.getEventStreamsLoading
,
71 success
: SkyquakeContainerActions
.getEventStreamsSuccess
,
72 error
: SkyquakeContainerActions
.getEventStreamsError
76 openNotificationsSocket() {
78 remote: function(state
, location
, streamSource
) {
79 return new Promise((resolve
, reject
) => {
81 url
: '//' + window
.location
.hostname
+ ':' + NODE_PORT
+ '/socket-polling?api_server=' + API_SERVER
,
83 beforeSend
: Utils
.addAuthorizationStub
,
88 // var url = Utils.webSocketProtocol() + '//' + window.location.hostname + ':' + data.port + data.socketPath;
89 // var ws = new WebSocket(url);
92 // streamSource: streamSource
94 const checker
= () => {
95 if (!Utils
.isMultiplexerLoaded()) {
102 streamSource
: streamSource
112 loading
: SkyquakeContainerActions
.openNotificationsSocketLoading
,
113 success
: SkyquakeContainerActions
.openNotificationsSocketSuccess
,
114 error
: SkyquakeContainerActions
.openNotificationsSocketError