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 let Users
= mockUsers();
19 module
.exports = function(Alt
) {
23 return new Promise(function(resolve
, reject
) {
24 // setTimeout(function() {
28 url
: `/user?api_server=${API_SERVER}`,
30 beforeSend
: Utils
.addAuthorizationStub
,
31 success: function(data
, textStatus
, jqXHR
) {
34 }).fail(function(xhr
){
35 //Authentication and the handling of fail states should be wrapped up into a connection class.
36 Utils
.checkAuthentication(xhr
.status
);
40 interceptResponse
: interceptResponse({
41 'error': 'There was an error retrieving the resource orchestrator information.'
43 success
: Alt
.actions
.global
.getUsersSuccess
,
44 loading
: Alt
.actions
.global
.showScreenLoader
,
45 error
: Alt
.actions
.global
.showNotification
48 remote: function(state
, user
) {
49 return new Promise(function(resolve
, reject
) {
51 url
: `/user?api_server=${API_SERVER}`,
54 beforeSend
: Utils
.addAuthorizationStub
,
55 success: function(data
, textStatus
, jqXHR
) {
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
);
64 interceptResponse
: interceptResponse({
65 'error': 'There was an error updating the user.'
67 success
: Alt
.actions
.global
.updateUserSuccess
,
68 loading
: Alt
.actions
.global
.showScreenLoader
,
69 error
: Alt
.actions
.global
.showNotification
72 remote: function(state
, user
) {
73 return new Promise(function(resolve
, reject
) {
74 // setTimeout(function() {
78 url
: `/user/${user['user-name']}/${user['user-domain']}?api_server=${API_SERVER}`,
81 beforeSend
: Utils
.addAuthorizationStub
,
82 success: function(data
, textStatus
, jqXHR
) {
85 }).fail(function(xhr
){
86 //Authentication and the handling of fail states should be wrapped up into a connection class.
87 Utils
.checkAuthentication(xhr
.status
);
91 interceptResponse
: interceptResponse({
92 'error': 'There was an error deleting the user.'
94 success
: Alt
.actions
.global
.deleteUserSuccess
,
95 loading
: Alt
.actions
.global
.showScreenLoader
,
96 error
: Alt
.actions
.global
.showNotification
99 remote: function(state
, user
) {
101 return new Promise(function(resolve
, reject
) {
102 // setTimeout(function() {
106 url
: `/user?api_server=${API_SERVER}`,
109 beforeSend
: Utils
.addAuthorizationStub
,
110 success: function(data
, textStatus
, jqXHR
) {
113 }).fail(function(xhr
){
114 //Authentication and the handling of fail states should be wrapped up into a connection class.
115 Utils
.checkAuthentication(xhr
.status
);
119 interceptResponse
: interceptResponse({
120 'error': 'There was an error updating the account.'
122 success
: Alt
.actions
.global
.createUserSuccess
,
123 loading
: Alt
.actions
.global
.showScreenLoader
,
124 error
: Alt
.actions
.global
.showNotification
129 function interceptResponse (responses
) {
130 return function(data
, action
, args
) {
131 if(responses
.hasOwnProperty(data
)) {
142 function mockUsers() {
145 for(let i
= 0; i
< 10; i
++) {
147 username
: `Tester ${i}`,
148 domain
: 'Some Domain',
151 platform_admin
: false,