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
) {
50 setTimeout(function() {
55 interceptResponse
: interceptResponse({
56 'error': 'There was an error updating the user.'
58 success
: Alt
.actions
.global
.updateUserSuccess
,
59 loading
: Alt
.actions
.global
.showScreenLoader
,
60 error
: Alt
.actions
.global
.showNotification
63 remote: function(state
, user
) {
64 return new Promise(function(resolve
, reject
) {
65 // setTimeout(function() {
69 url
: `/user/${user['user-name']}/${user['user-domain']}?api_server=${API_SERVER}`,
72 beforeSend
: Utils
.addAuthorizationStub
,
73 success: function(data
, textStatus
, jqXHR
) {
76 }).fail(function(xhr
){
77 //Authentication and the handling of fail states should be wrapped up into a connection class.
78 Utils
.checkAuthentication(xhr
.status
);
82 interceptResponse
: interceptResponse({
83 'error': 'There was an error deleting the user.'
85 success
: Alt
.actions
.global
.deleteUserSuccess
,
86 loading
: Alt
.actions
.global
.showScreenLoader
,
87 error
: Alt
.actions
.global
.showNotification
90 remote: function(state
, user
) {
92 return new Promise(function(resolve
, reject
) {
93 // setTimeout(function() {
97 url
: `/user?api_server=${API_SERVER}`,
100 beforeSend
: Utils
.addAuthorizationStub
,
101 success: function(data
, textStatus
, jqXHR
) {
104 }).fail(function(xhr
){
105 //Authentication and the handling of fail states should be wrapped up into a connection class.
106 Utils
.checkAuthentication(xhr
.status
);
110 interceptResponse
: interceptResponse({
111 'error': 'There was an error updating the account.'
113 success
: Alt
.actions
.global
.createUserSuccess
,
114 loading
: Alt
.actions
.global
.showScreenLoader
,
115 error
: Alt
.actions
.global
.showNotification
120 function interceptResponse (responses
) {
121 return function(data
, action
, args
) {
122 if(responses
.hasOwnProperty(data
)) {
133 function mockUsers() {
136 for(let i
= 0; i
< 10; i
++) {
138 username
: `Tester ${i}`,
139 domain
: 'Some Domain',
142 platform_admin
: false,