X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=skyquake%2Fplugins%2Fuser_management%2Fsrc%2FplatformRoleManagement%2FplatformRoleManagementSource.js;h=724312e7fa409a520f236a56bd2f77f505ac6bc7;hb=a0fefa94b21ae1620756cda0d22d5de90b9bcaa9;hp=72fc2d3c727dc18663a69362630d699772d6deaf;hpb=de8cda680ce17b1555789bf2f4d3145c0d4d4849;p=osm%2FUI.git diff --git a/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementSource.js b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementSource.js index 72fc2d3c7..724312e7f 100644 --- a/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementSource.js +++ b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementSource.js @@ -13,9 +13,6 @@ if (DEV_MODE) { } -let Projects = mockProjects(); -let Users = mockUsers(); - module.exports = function(Alt) { return { @@ -23,62 +20,67 @@ module.exports = function(Alt) { getUsers: { remote: function() { return new Promise(function(resolve, reject) { - // setTimeout(function() { - // resolve(Users); - // }, 1000); $.ajax({ url: `/user?api_server=${API_SERVER}`, type: 'GET', beforeSend: Utils.addAuthorizationStub, success: function(data, textStatus, jqXHR) { - resolve(data.users); + resolve(data.user); } }).fail(function(xhr){ //Authentication and the handling of fail states should be wrapped up into a connection class. Utils.checkAuthentication(xhr.status); + let msg = xhr.responseText; + if(xhr.errorMessage) { + msg = xhr.errorMessage + } + reject(msg); }); }); }, interceptResponse: interceptResponse({ 'error': 'There was an error retrieving the resource orchestrator information.' }), - success: Alt.actions.global.getUsersSuccess, + success: Alt.actions.global.getPlatformRoleUsersSuccess, loading: Alt.actions.global.showScreenLoader, error: Alt.actions.global.showNotification }, - getProjects: { + getPlatform: { remote: function() { return new Promise(function(resolve, reject) { - // setTimeout(function() { - // resolve(Projects); - // }, 1000) $.ajax({ - url: `/project?api_server=${API_SERVER}`, + url: `/platform?api_server=${API_SERVER}`, type: 'GET', beforeSend: Utils.addAuthorizationStub, success: function(data, textStatus, jqXHR) { - resolve(data.project); + resolve(data.platform); } }).fail(function(xhr){ //Authentication and the handling of fail states should be wrapped up into a connection class. Utils.checkAuthentication(xhr.status); + let msg = xhr.responseText; + if(xhr.errorMessage) { + msg = xhr.errorMessage + } + reject(msg); }); }); }, interceptResponse: interceptResponse({ 'error': 'There was an error retrieving the resource orchestrator information.' }), - success: Alt.actions.global.getProjectsSuccess, + success: Alt.actions.global.getPlatformSuccess, loading: Alt.actions.global.showScreenLoader, error: Alt.actions.global.showNotification }, - updateProject: { + updatePlatform: { remote: function(state, project) { return new Promise(function(resolve, reject) { $.ajax({ - url: `/project?api_server=${API_SERVER}`, + url: `/platform?api_server=${API_SERVER}`, type: 'PUT', data: project, + dataType: 'json', beforeSend: Utils.addAuthorizationStub, success: function(data, textStatus, jqXHR) { resolve(data); @@ -86,6 +88,11 @@ module.exports = function(Alt) { }).fail(function(xhr){ //Authentication and the handling of fail states should be wrapped up into a connection class. Utils.checkAuthentication(xhr.status); + let msg = xhr.responseText; + if(xhr.errorMessage) { + msg = xhr.errorMessage + } + reject(msg); }); }); }, @@ -99,9 +106,6 @@ module.exports = function(Alt) { deleteProject: { remote: function(state, project) { return new Promise(function(resolve, reject) { - // setTimeout(function() { - // resolve(true); - // }, 1000) $.ajax({ url: `/project/${project['name']}?api_server=${API_SERVER}`, type: 'DELETE', @@ -112,6 +116,11 @@ module.exports = function(Alt) { }).fail(function(xhr){ //Authentication and the handling of fail states should be wrapped up into a connection class. Utils.checkAuthentication(xhr.status); + let msg = xhr.responseText; + if(xhr.errorMessage) { + msg = xhr.errorMessage + } + reject(msg); }); }); }, @@ -126,9 +135,6 @@ module.exports = function(Alt) { remote: function(state, project) { return new Promise(function(resolve, reject) { - // setTimeout(function() { - // resolve(true); - // }, 1000) $.ajax({ url: `/project?api_server=${API_SERVER}`, type: 'POST', @@ -140,6 +146,11 @@ module.exports = function(Alt) { }).fail(function(xhr){ //Authentication and the handling of fail states should be wrapped up into a connection class. Utils.checkAuthentication(xhr.status); + let msg = xhr.responseText; + if(xhr.errorMessage) { + msg = xhr.errorMessage + } + reject(msg); }); }); }, @@ -166,61 +177,3 @@ function interceptResponse (responses) { } } -function mockProjects() { - let data = []; - let count = 10; - for(let i = 0; i < 3; i++) { - data.push({ - name: `Test Project ${i}`, - description: 'Some description', - roles: ['Some-Role', 'Some-Other-Role'], - users: [ - { - 'user-name': 'Some-User', - 'user-domain': 'system', - role: [ - { - 'role': 'Some-Role', - 'key-set' : 'some key' - }, - { - 'role': 'Some-Other-Role', - 'key-set' : 'some key' - } - ] - }, - { - 'user-name': 'Some-User', - 'user-domain': 'system', - role: [ - { - 'role': 'Some-Role', - 'key-set' : 'some key' - } - ] - } - ] - }) - } - return data; -} -function mockUsers() { - let data = []; - let count = 10; - for(let i = 0; i < 10; i++) { - data.push({ - 'user-name': `Tester ${i}`, - 'user-domain': 'Some Domain', - platformRoles: { - super_admin: true, - platform_admin: false, - platform_oper: false - }, - disabled: false, - projectRoles: [ - 'Project:Role' - ] - }) - } - return data; -}