2 * STANDARD_RIFT_IO_COPYRIGHT
4 import $ from 'jquery';
5 var Utils
= require('utils/utils.js');
6 let API_SERVER
= require('utils/rw.js').getSearchParams(window
.location
).api_server
;
8 let NODE_PORT
= require('utils/rw.js').getSearchParams(window
.location
).api_port
|| ((window
.location
.protocol
== 'https:') ? 8443 : 8000);
9 let DEV_MODE
= require('utils/rw.js').getSearchParams(window
.location
).dev_mode
|| false;
12 HOST
= window
.location
.protocol
+ '//' + window
.location
.hostname
;
16 module
.exports = function(Alt
) {
18 getResourceOrchestrator
: {
20 return new Promise(function(resolve
, reject
) {
22 url
: 'passthrough/data/api/running/resource-orchestrator' + '?api_server=' + API_SERVER
,
24 beforeSend
: Utils
.addAuthorizationStub
,
25 contentType
: "application/json",
26 success: function(data
) {
27 resolve(data
["rw-launchpad:resource-orchestrator"]);
29 error: function(error
) {
30 console
.log("There was an error updating the account: ", arguments
);
33 }).fail(function(xhr
){
34 //Authentication and the handling of fail states should be wrapped up into a connection class.
35 Utils
.checkAuthentication(xhr
.status
);
36 return reject('error');
40 interceptResponse
: interceptResponse({
41 'error': 'There was an error retrieving the resource orchestrator information.'
43 success
: Alt
.actions
.global
.getResourceOrchestratorSuccess
,
44 loading
: Alt
.actions
.global
.showScreenLoader
,
45 error
: Alt
.actions
.global
.showNotification
48 remote: function(state
, account
) {
50 return new Promise(function(resolve
, reject
) {
52 url
: 'resource-orchestrator' + '?api_server=' + API_SERVER
,
54 beforeSend
: Utils
.addAuthorizationStub
,
55 data
: JSON
.stringify(account
),
56 contentType
: "application/json",
57 success: function(data
) {
60 error: function(error
) {
61 console
.log("There was an error updating the account: ", arguments
);
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
);
67 return reject('error');
72 interceptResponse
: interceptResponse({
73 'error': 'There was an error updating the account.'
75 success
: Alt
.actions
.global
.updateResourceOrchestratorSuccess
,
76 loading
: Alt
.actions
.global
.showScreenLoader
,
77 error
: Alt
.actions
.global
.showNotification
82 function interceptResponse (responses
) {
83 return function(data
, action
, args
) {
84 if(responses
.hasOwnProperty(data
)) {