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
;
17 module
.exports = function(Alt
) {
22 return new Promise(function(resolve
, reject
) {
24 url
: `/user?api_server=${API_SERVER}`,
26 beforeSend
: Utils
.addAuthorizationStub
,
27 success: function(data
, textStatus
, jqXHR
) {
30 }).fail(function(xhr
){
31 //Authentication and the handling of fail states should be wrapped up into a connection class.
32 Utils
.checkAuthentication(xhr
.status
);
33 let msg
= xhr
.responseText
;
34 if(xhr
.errorMessage
) {
35 msg
= xhr
.errorMessage
41 interceptResponse
: interceptResponse({
42 'error': 'There was an error retrieving the resource orchestrator information.'
44 success
: Alt
.actions
.global
.getPlatformRoleUsersSuccess
,
45 loading
: Alt
.actions
.global
.showScreenLoader
,
46 error
: Alt
.actions
.global
.handleServerReportedError
50 return new Promise(function(resolve
, reject
) {
52 url
: `/platform?api_server=${API_SERVER}`,
54 beforeSend
: Utils
.addAuthorizationStub
,
55 success: function(data
, textStatus
, jqXHR
) {
56 resolve(data
.platform
);
58 }).fail(function(xhr
){
59 //Authentication and the handling of fail states should be wrapped up into a connection class.
60 Utils
.checkAuthentication(xhr
.status
);
61 let msg
= xhr
.responseText
;
62 if(xhr
.errorMessage
) {
63 msg
= xhr
.errorMessage
69 interceptResponse
: interceptResponse({
70 'error': 'There was an error retrieving the resource orchestrator information.'
72 success
: Alt
.actions
.global
.getPlatformSuccess
,
73 loading
: Alt
.actions
.global
.showScreenLoader
,
74 error
: Alt
.actions
.global
.handleServerReportedError
77 remote: function(state
, project
) {
78 return new Promise(function(resolve
, reject
) {
80 url
: `/platform?api_server=${API_SERVER}`,
84 beforeSend
: Utils
.addAuthorizationStub
,
85 success: function(data
, textStatus
, jqXHR
) {
88 }).fail(function(xhr
){
89 //Authentication and the handling of fail states should be wrapped up into a connection class.
90 Utils
.checkAuthentication(xhr
.status
);
91 let msg
= xhr
.responseText
;
92 if(xhr
.errorMessage
) {
93 msg
= xhr
.errorMessage
99 interceptResponse
: interceptResponse({
100 'error': 'There was an error updating the project.'
102 success
: Alt
.actions
.global
.updatePlatformSuccess
,
103 loading
: Alt
.actions
.global
.showScreenLoader
,
104 error
: Alt
.actions
.global
.handleServerReportedError
109 function interceptResponse (responses
) {
110 return function(data
, action
, args
) {
111 if(responses
.hasOwnProperty(data
)) {