X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=skyquake%2Fplugins%2Fuser_management%2Fsrc%2Fdashboard%2FuserMgmtSource.js;h=267387a4dea0ad7dbf21a51d2e6aef326ef206bf;hb=a0fefa94b21ae1620756cda0d22d5de90b9bcaa9;hp=2f922a9953386ac05db8f9324b6791296f27e409;hpb=41f386a117ec725ad1eb49a9c571107a0c7d1c11;p=osm%2FUI.git diff --git a/skyquake/plugins/user_management/src/dashboard/userMgmtSource.js b/skyquake/plugins/user_management/src/dashboard/userMgmtSource.js index 2f922a995..267387a4d 100644 --- a/skyquake/plugins/user_management/src/dashboard/userMgmtSource.js +++ b/skyquake/plugins/user_management/src/dashboard/userMgmtSource.js @@ -13,7 +13,6 @@ if (DEV_MODE) { } -let Users = mockUsers(); module.exports = function(Alt) { @@ -21,19 +20,21 @@ 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); }); }); }, @@ -41,7 +42,7 @@ module.exports = function(Alt) { 'error': 'There was an error retrieving the resource orchestrator information.' }), success: Alt.actions.global.getUsersSuccess, - loading: Alt.actions.global.showScreenLoader, + loading: Alt.actions.global.showScreenLoader, error: Alt.actions.global.showNotification }, updateUser: { @@ -58,6 +59,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); }); }); }, @@ -71,9 +77,6 @@ module.exports = function(Alt) { deleteUser: { remote: function(state, user) { return new Promise(function(resolve, reject) { - // setTimeout(function() { - // resolve(true); - // }, 1000) $.ajax({ url: `/user/${user['user-name']}/${user['user-domain']}?api_server=${API_SERVER}`, type: 'DELETE', @@ -85,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 +107,6 @@ module.exports = function(Alt) { remote: function(state, user) { return new Promise(function(resolve, reject) { - // setTimeout(function() { - // resolve(true); - // }, 1000) $.ajax({ url: `/user?api_server=${API_SERVER}`, type: 'POST', @@ -113,6 +118,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); }); }); }, @@ -139,23 +149,3 @@ function interceptResponse (responses) { } } -function mockUsers() { - let data = []; - let count = 10; - for(let i = 0; i < 10; i++) { - data.push({ - username: `Tester ${i}`, - domain: 'Some Domain', - platformRoles: { - super_admin: true, - platform_admin: false, - platform_oper: false - }, - disabled: false, - projectRoles: [ - 'Project:Role' - ] - }) - } - return data; -}