ce0c984fe29f98d865a11661a36394b8efdcefd2
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
);
36 interceptResponse
: interceptResponse({
37 'error': 'There was an error retrieving the resource orchestrator information.'
39 success
: Alt
.actions
.global
.getUsersSuccess
,
40 loading
: Alt
.actions
.global
.showScreenLoader
,
41 error
: Alt
.actions
.global
.showNotification
45 return new Promise(function(resolve
, reject
) {
47 url
: `/project?api_server=${API_SERVER}`,
49 beforeSend
: Utils
.addAuthorizationStub
,
50 success: function(data
, textStatus
, jqXHR
) {
51 resolve(data
.project
);
53 }).fail(function(xhr
){
54 //Authentication and the handling of fail states should be wrapped up into a connection class.
55 Utils
.checkAuthentication(xhr
.status
);
59 interceptResponse
: interceptResponse({
60 'error': 'There was an error retrieving the resource orchestrator information.'
62 success
: Alt
.actions
.global
.getProjectsSuccess
,
63 loading
: Alt
.actions
.global
.showScreenLoader
,
64 error
: Alt
.actions
.global
.showNotification
67 remote: function(state
, project
) {
68 return new Promise(function(resolve
, reject
) {
70 url
: `/project?api_server=${API_SERVER}`,
73 beforeSend
: Utils
.addAuthorizationStub
,
74 success: function(data
, textStatus
, jqXHR
) {
77 }).fail(function(xhr
){
78 //Authentication and the handling of fail states should be wrapped up into a connection class.
79 Utils
.checkAuthentication(xhr
.status
);
83 interceptResponse
: interceptResponse({
84 'error': 'There was an error updating the project.'
86 success
: Alt
.actions
.global
.updateProjectSuccess
,
87 loading
: Alt
.actions
.global
.showScreenLoader
,
88 error
: Alt
.actions
.global
.showNotification
91 remote: function(state
, project
) {
92 return new Promise(function(resolve
, reject
) {
94 url
: `/project/${project['name']}?api_server=${API_SERVER}`,
96 beforeSend
: Utils
.addAuthorizationStub
,
97 success: function(data
, textStatus
, jqXHR
) {
100 }).fail(function(xhr
){
101 //Authentication and the handling of fail states should be wrapped up into a connection class.
102 Utils
.checkAuthentication(xhr
.status
);
106 interceptResponse
: interceptResponse({
107 'error': 'There was an error deleting the user.'
109 success
: Alt
.actions
.global
.deleteProjectSuccess
,
110 loading
: Alt
.actions
.global
.showScreenLoader
,
111 error
: Alt
.actions
.global
.showNotification
114 remote: function(state
, project
) {
116 return new Promise(function(resolve
, reject
) {
118 url
: `/project?api_server=${API_SERVER}`,
121 beforeSend
: Utils
.addAuthorizationStub
,
122 success: function(data
, textStatus
, jqXHR
) {
125 }).fail(function(xhr
){
126 //Authentication and the handling of fail states should be wrapped up into a connection class.
127 Utils
.checkAuthentication(xhr
.status
);
131 interceptResponse
: interceptResponse({
132 'error': 'There was an error updating the account.'
134 success
: Alt
.actions
.global
.createProjectSuccess
,
135 loading
: Alt
.actions
.global
.showScreenLoader
,
136 error
: Alt
.actions
.global
.showNotification
141 function interceptResponse (responses
) {
142 return function(data
, action
, args
) {
143 if(responses
.hasOwnProperty(data
)) {