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 Projects
= mockProjects();
17 let Users
= mockUsers();
20 module
.exports = function(Alt
) {
25 return new Promise(function(resolve
, reject
) {
26 // setTimeout(function() {
30 url
: `/user?api_server=${API_SERVER}`,
32 beforeSend
: Utils
.addAuthorizationStub
,
33 success: function(data
, textStatus
, jqXHR
) {
36 }).fail(function(xhr
){
37 //Authentication and the handling of fail states should be wrapped up into a connection class.
38 Utils
.checkAuthentication(xhr
.status
);
42 interceptResponse
: interceptResponse({
43 'error': 'There was an error retrieving the resource orchestrator information.'
45 success
: Alt
.actions
.global
.getPlatformRoleUsersSuccess
,
46 loading
: Alt
.actions
.global
.showScreenLoader
,
47 error
: Alt
.actions
.global
.showNotification
51 return new Promise(function(resolve
, reject
) {
52 // setTimeout(function() {
56 url
: `/platform?api_server=${API_SERVER}`,
58 beforeSend
: Utils
.addAuthorizationStub
,
59 success: function(data
, textStatus
, jqXHR
) {
60 resolve(data
.platform
);
62 }).fail(function(xhr
){
63 //Authentication and the handling of fail states should be wrapped up into a connection class.
64 Utils
.checkAuthentication(xhr
.status
);
68 interceptResponse
: interceptResponse({
69 'error': 'There was an error retrieving the resource orchestrator information.'
71 success
: Alt
.actions
.global
.getPlatformSuccess
,
72 loading
: Alt
.actions
.global
.showScreenLoader
,
73 error
: Alt
.actions
.global
.showNotification
76 remote: function(state
, project
) {
77 return new Promise(function(resolve
, reject
) {
79 url
: `/platform?api_server=${API_SERVER}`,
82 beforeSend
: Utils
.addAuthorizationStub
,
83 success: function(data
, textStatus
, jqXHR
) {
86 }).fail(function(xhr
){
87 //Authentication and the handling of fail states should be wrapped up into a connection class.
88 Utils
.checkAuthentication(xhr
.status
);
92 interceptResponse
: interceptResponse({
93 'error': 'There was an error updating the project.'
95 success
: Alt
.actions
.global
.updateProjectSuccess
,
96 loading
: Alt
.actions
.global
.showScreenLoader
,
97 error
: Alt
.actions
.global
.showNotification
100 remote: function(state
, project
) {
101 return new Promise(function(resolve
, reject
) {
102 // setTimeout(function() {
106 url
: `/project/${project['name']}?api_server=${API_SERVER}`,
108 beforeSend
: Utils
.addAuthorizationStub
,
109 success: function(data
, textStatus
, jqXHR
) {
112 }).fail(function(xhr
){
113 //Authentication and the handling of fail states should be wrapped up into a connection class.
114 Utils
.checkAuthentication(xhr
.status
);
118 interceptResponse
: interceptResponse({
119 'error': 'There was an error deleting the user.'
121 success
: Alt
.actions
.global
.deleteProjectSuccess
,
122 loading
: Alt
.actions
.global
.showScreenLoader
,
123 error
: Alt
.actions
.global
.showNotification
126 remote: function(state
, project
) {
128 return new Promise(function(resolve
, reject
) {
129 // setTimeout(function() {
133 url
: `/project?api_server=${API_SERVER}`,
136 beforeSend
: Utils
.addAuthorizationStub
,
137 success: function(data
, textStatus
, jqXHR
) {
140 }).fail(function(xhr
){
141 //Authentication and the handling of fail states should be wrapped up into a connection class.
142 Utils
.checkAuthentication(xhr
.status
);
146 interceptResponse
: interceptResponse({
147 'error': 'There was an error updating the account.'
149 success
: Alt
.actions
.global
.createProjectSuccess
,
150 loading
: Alt
.actions
.global
.showScreenLoader
,
151 error
: Alt
.actions
.global
.showNotification
156 function interceptResponse (responses
) {
157 return function(data
, action
, args
) {
158 if(responses
.hasOwnProperty(data
)) {
169 function mockProjects() {
172 for(let i
= 0; i
< 3; i
++) {
174 name
: `Test Project ${i}`,
175 description
: 'Some description',
176 roles
: ['Some-Role', 'Some-Other-Role'],
179 'user-name': 'Some-User',
180 'user-domain': 'system',
184 'key-set' : 'some key'
187 'role': 'Some-Other-Role',
188 'key-set' : 'some key'
193 'user-name': 'Some-User',
194 'user-domain': 'system',
198 'key-set' : 'some key'
207 function mockUsers() {
210 for(let i
= 0; i
< 10; i
++) {
212 'user-name': `Tester ${i}`,
213 'user-domain': 'Some Domain',
216 platform_admin
: false,