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'
21 import rw
from 'utils/rw.js';
22 import Utils
from 'utils/utils.js';
24 let API_SERVER
= rw
.getSearchParams(window
.location
).api_server
;
25 let HOST
= API_SERVER
;
26 let NODE_PORT
= rw
.getSearchParams(window
.location
).api_port
|| ((window
.location
.protocol
== 'https:') ? 8443 : 8000);
27 let DEV_MODE
= rw
.getSearchParams(window
.location
).dev_mode
|| false;
28 let RW_REST_API_PORT
= rw
.getSearchParams(window
.location
).rw_rest_api_port
|| 8008;
31 HOST
= window
.location
.protocol
+ '//' + window
.location
.hostname
;
38 return new Promise(function(resolve
, reject
) {
42 // beforeSend: Utils.addAuthorizationStub,
43 success: function(data
) {
44 Utils
.detectInactivity();
50 success
: SkyquakeContainerActions
.getSkyquakeNavSuccess
56 remote: function(state
, recordID
) {
57 return new Promise(function(resolve
, reject
) {
59 url
: '//' + window
.location
.hostname
+ ':' + window
.location
.port
+ '/api/operational/restconf-state/streams?api_server=' + API_SERVER
,
61 beforeSend
: Utils
.addAuthorizationStub
,
62 success: function(data
) {
65 }).fail(function(xhr
) {
66 //Authentication and the handling of fail states should be wrapped up into a connection class.
67 Utils
.checkAuthentication(xhr
.status
);
71 loading
: SkyquakeContainerActions
.getEventStreamsLoading
,
72 success
: SkyquakeContainerActions
.getEventStreamsSuccess
,
73 error
: SkyquakeContainerActions
.getEventStreamsError
77 openNotificationsSocket() {
79 remote: function(state
, location
, streamSource
) {
80 return new Promise((resolve
, reject
) => {
82 url
: '//' + window
.location
.hostname
+ ':' + window
.location
.port
+ '/socket-polling',
84 beforeSend
: Utils
.addAuthorizationStub
,
89 // var url = Utils.webSocketProtocol() + '//' + window.location.hostname + ':' + data.port + data.socketPath;
90 // var ws = new WebSocket(url);
93 // streamSource: streamSource
95 const checker
= () => {
96 if (!Utils
.isMultiplexerLoaded()) {
103 streamSource
: streamSource
113 loading
: SkyquakeContainerActions
.openNotificationsSocketLoading
,
114 success
: SkyquakeContainerActions
.openNotificationsSocketSuccess
,
115 error
: SkyquakeContainerActions
.openNotificationsSocketError