var api_server = req.query['api_server'];
return new Promise(function(resolve, reject) {
- Promise.all([
- rp({
+ var userConfig = rp({
uri: utils.confdPort(api_server) + '/api/operational/user-config/user',
method: 'GET',
headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
forever: constants.FOREVER_ON,
rejectUnauthorized: false,
resolveWithFullResponse: true
+ });
+ var userOp = rp({
+ uri: utils.confdPort(api_server) + '/api/operational/user-state/user',
+ method: 'GET',
+ headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
+ 'Authorization': req.session && req.session.authorization
+ }),
+ forever: constants.FOREVER_ON,
+ rejectUnauthorized: false,
+ resolveWithFullResponse: true
})
+ Promise.all([
+ userConfig,
+ userOp
]).then(function(result) {
var response = {};
response['data'] = {};
+ var resultData = [];
if (result[0].body) {
- response['data']['user'] = JSON.parse(result[0].body)['rw-user:user'];
+ resultData.push(JSON.parse(result[0].body)['rw-user:user'].sort());
+ }
+ if (result[1].body) {
+ resultData.push(JSON.parse(result[1].body)['rw-user:user'].sort());
}
response.statusCode = constants.HTTP_RESPONSE_CODES.SUCCESS.OK
-
+ response['data']['user'] = resultData[0].map(function(d,i) {
+ var mergedData = _.merge(d, resultData[1][i]);
+ mergedData.projects = {
+ ids: [],
+ data: {}
+ };
+ var projects = mergedData.projects;
+ mergedData.role && mergedData.role.map(function(r) {
+ if ((r.role != "rw-project:user-self" )&& (r.role != "rw-rbac-platform:user-self")) {
+ var projectId = r.keys.split(';')[0];
+ if (projectId == "") {
+ projectId = "platform"
+ }
+ if (!projects.data[projectId]) {
+ projects.ids.push(projectId);
+ projects.data[projectId] = [];
+ }
+ projects.data[projectId].push(r.role);
+ }
+ })
+ return mergedData;
+ })
resolve(response);
}).catch(function(error) {
var response = {};
<Input label="Platform Admin" onChange={this.platformChange.bind(null, 'platform_admin')} checked={state.platformRoles.platform_admin} type="checkbox" />
<Input label="Platform Oper" onChange={this.platformChange.bind(null, 'platform_oper')} checked={state.platformRoles.platform_oper} type="checkbox" />
</FormSection>
- <FormSection title="PROJECT ROLES" style={{display:'none'}}>
- <InputCollection
- inital={true}
- type='select'
- readonly={state.isReadOnly}
- options={state.projectRolesOptions}
- collection={state.projectRoles}
- onChange={this.updateProjectRole}
- AddItemFn={this.addProjectRole}
- RemoveItemFn={this.removeProjectRole}
- />
- </FormSection>
+ {
+ !state.isEditUser ?
+ <FormSection title="PROJECT ROLES">
+ <table className="userProfile-table">
+ <thead>
+ <tr>
+ <td>Project</td>
+ <td>Role</td>
+ </tr>
+ </thead>
+ <tbody>
+ {
+ this.state.projects && this.state.projects.ids && this.state.projects.ids.map((p,i)=> {
+ let project = self.state.projects.data[p];
+ let userRoles = [];
+ return (
+ <tr key={i}>
+ <td>
+ {p}
+ </td>
+ <td>
+ {
+ project.map(function(k) {
+ return <div>{k}</div>
+ })
+ }
+ </td>
+ </tr>
+ )
+ })
+ }
+ </tbody>
+ </table>
+ </FormSection>
+ : null
+ }
+
{passwordSectionHTML}
</Panel>