From abf00ef39ee93f2a7ff05a4432eb3a50a88a487e Mon Sep 17 00:00:00 2001 From: Laurence Maultsby Date: Tue, 28 Mar 2017 16:12:23 -0400 Subject: [PATCH] Project UI updates and bug fixes Signed-off-by: Laurence Maultsby --- .../framework/core/modules/api/sessions.js | 7 +- .../core/modules/api/userManagementAPI.js | 28 ++++- .../core/modules/routes/userManagement.js | 7 ++ .../widgets/form_controls/selectOption.jsx | 6 +- .../skyquake_container/skyquakeApp.scss | 90 +-------------- .../skyquake_container/skyquakeContainer.jsx | 5 +- .../skyquakeContainerActions.js | 6 +- .../skyquakeContainerSource.js | 50 +++++++++ .../skyquakeContainerStore.js | 29 +++++ .../skyquakeNav.jsx | 50 ++++++++- .../widgets/skyquake_nav/skyquakeNav.scss | 104 ++++++++++++++++++ .../src/dashboard/dashboard.jsx | 16 ++- .../src/dashboard/projectMgmtSource.js | 27 ++++- .../src/dashboard/projectMgmtStore.js | 19 +--- .../src/dashboard/dashboard.jsx | 2 +- .../src/dashboard/userMgmtSource.js | 2 +- .../platformRoleManagementSource.js | 2 +- .../platformRoleManagementStore.js | 14 +-- 18 files changed, 323 insertions(+), 141 deletions(-) rename skyquake/framework/widgets/{skyquake_container => skyquake_nav}/skyquakeNav.jsx (85%) create mode 100644 skyquake/framework/widgets/skyquake_nav/skyquakeNav.scss diff --git a/skyquake/framework/core/modules/api/sessions.js b/skyquake/framework/core/modules/api/sessions.js index b60950390..0ce030089 100644 --- a/skyquake/framework/core/modules/api/sessions.js +++ b/skyquake/framework/core/modules/api/sessions.js @@ -1,5 +1,5 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -109,7 +109,10 @@ sessionsAPI.create = function(req, res) { req.session.authorization = authorization_header_string; req.session.loggedIn = true; - + req.session.userdata = { + username: username, + // project: req.session.projectId + }; var successMsg = 'User =>' + username + ' successfully logged in.'; successMsg += req.session.projectId ? 'Project =>' + req.session.projectId + ' set as default.' : ''; diff --git a/skyquake/framework/core/modules/api/userManagementAPI.js b/skyquake/framework/core/modules/api/userManagementAPI.js index e88a5dca7..19bb85447 100644 --- a/skyquake/framework/core/modules/api/userManagementAPI.js +++ b/skyquake/framework/core/modules/api/userManagementAPI.js @@ -33,7 +33,7 @@ UserManagement.get = function(req) { return new Promise(function(resolve, reject) { Promise.all([ rp({ - uri: utils.confdPort(api_server) + '/api/operational/user-config/users', + uri: utils.confdPort(api_server) + '/api/operational/user-config/user', method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { 'Authorization': req.session && req.session.authorization @@ -46,7 +46,7 @@ UserManagement.get = function(req) { var response = {}; response['data'] = {}; if (result[0].body) { - response['data']['users'] = JSON.parse(result[0].body)['rw-user:users']; + response['data']['user'] = JSON.parse(result[0].body)['rw-user:user']; } response.statusCode = constants.HTTP_RESPONSE_CODES.SUCCESS.OK @@ -62,12 +62,30 @@ UserManagement.get = function(req) { }); }); }; + +UserManagement.getProfile = function(req) { + var self = this; + var api_server = req.query['api_server']; + return new Promise(function(resolve, reject) { + var response = {}; + response['data'] = { + userId: req.session.userdata.username, + projectId: req.session.projectId + }; + // if (result[0].body) { + // response['data']['users'] = JSON.parse(result[0].body)['rw-user:users']; + // } + response.statusCode = constants.HTTP_RESPONSE_CODES.SUCCESS.OK + + resolve(response); + }); +}; UserManagement.create = function(req) { var self = this; var api_server = req.query['api_server']; var data = req.body; data = { - "users":[data] + "user":[data] } return new Promise(function(resolve, reject) { Promise.all([ @@ -107,7 +125,7 @@ UserManagement.update = function(req) { var api_server = req.query['api_server']; var bodyData = req.body; data = { - "users":[bodyData] + "user":[bodyData] } var updateTasks = []; if(bodyData.hasOwnProperty('old-password')) { @@ -174,7 +192,7 @@ UserManagement.delete = function(req) { var domain = req.params.domain; var api_server = req.query["api_server"]; var requestHeaders = {}; - var url = `${utils.confdPort(api_server)}/api/config/user-config/users/${username},${domain}` + var url = `${utils.confdPort(api_server)}/api/config/user-config/user/${username},${domain}` return new Promise(function(resolve, reject) { _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, diff --git a/skyquake/framework/core/modules/routes/userManagement.js b/skyquake/framework/core/modules/routes/userManagement.js index 11fb8b1c9..4e272d058 100644 --- a/skyquake/framework/core/modules/routes/userManagement.js +++ b/skyquake/framework/core/modules/routes/userManagement.js @@ -43,6 +43,13 @@ Router.get('/user', cors(), function(req, res) { utils.sendErrorResponse(error, res); }); }); +Router.get('/user-profile', cors(), function(req, res) { + UserManagementAPI.getProfile(req).then(function(response) { + utils.sendSuccessResponse(response, res); + }, function(error) { + utils.sendErrorResponse(error, res); + }); +}); Router.post('/user', cors(), function(req, res) { UserManagementAPI.create(req).then(function(response) { utils.sendSuccessResponse(response, res); diff --git a/skyquake/framework/widgets/form_controls/selectOption.jsx b/skyquake/framework/widgets/form_controls/selectOption.jsx index 1e02f15da..397963e3a 100644 --- a/skyquake/framework/widgets/form_controls/selectOption.jsx +++ b/skyquake/framework/widgets/form_controls/selectOption.jsx @@ -28,7 +28,7 @@ export default class SelectOption extends React.Component { render() { let html; let defaultValue = this.props.defaultValue; - let options = this.props.options.map(function(op, i) { + let options = this.props.options && this.props.options.map(function(op, i) { let value; let label; if(typeof(op) == 'object') { @@ -40,12 +40,12 @@ export default class SelectOption extends React.Component { } return - }); + }) || []; if (this.props.initial) { options.unshift(); } html = ( -