return new Promise(function(resolve, reject) {
//If socket connection already exists, eat the request.
if(state.socket) {
+ console.log('connection already exists')
return resolve(false);
}
$.ajax({
- url: '//' + window.location.hostname + ':' + NODE_PORT + '/socket-polling?api_server=' + API_SERVER ,
+ url: '/socket-polling?api_server=' + API_SERVER,
type: 'POST',
beforeSend: Utils.addAuthorizationStub,
data: {
- url:window.location.protocol + '//' + window.location.host + '/accounts/all?api_server=' + API_SERVER
+ url: 'accounts/all?api_server=' + API_SERVER
},
success: function(data, textStatus, jqXHR) {
Utils.checkAndResolveSocketRequest(data, resolve, reject);
}).fail(function(xhr){
//Authentication and the handling of fail states should be wrapped up into a connection class.
Utils.checkAuthentication(xhr.status);
+ reject(xhr.responseText || 'An error occurred. Check your logs for more information');
});;
});
},
}).fail(function(xhr){
//Authentication and the handling of fail states should be wrapped up into a connection class.
Utils.checkAuthentication(xhr.status);
- reject();
+ reject(xhr.responseText || 'An error occurred. Check your logs for more information');
});
});
}).fail(function(xhr){
//Authentication and the handling of fail states should be wrapped up into a connection class.
Utils.checkAuthentication(xhr.status);
- reject('error');
+ reject(xhr.responseText || 'An error occurred. Check your logs for more information');
});
});
}).fail(function(xhr){
//Authentication and the handling of fail states should be wrapped up into a connection class.
Utils.checkAuthentication(xhr.status);
- reject('error');
+ reject(xhr.responseText || 'An error occurred. Check your logs for more information');
});
})
},
beforeSend: Utils.addAuthorizationStub,
contentType: "application/json",
success: function(data) {
- resolve(data["rw-launchpad:resource-orchestrator"]);
+ let returnedData;
+ if (data.hasOwnProperty("rw-launchpad:resource-orchestrator")) {
+ returnedData = data;
+ } else {
+ returnedData = {};
+ }
+ resolve(returnedData);
},
error: function(error) {
console.log("There was an error updating the account: ", arguments);
'error': 'There was an error retrieving the resource orchestrator information.'
}),
success: Alt.actions.global.getResourceOrchestratorSuccess,
- loading: Alt.actions.global.showScreenLoader,
+ loading: Alt.actions.global.showScreenLoader,
error: Alt.actions.global.showNotification
},
}