Merge changes I708f8fc2,Ife664a90,I5ea07463 into projects
authorkashalkar <kiran.kashalkar@riftio.com>
Thu, 4 May 2017 19:23:58 +0000 (21:23 +0200)
committerGerrit Code Review <root@osm.etsi.org>
Thu, 4 May 2017 19:23:58 +0000 (21:23 +0200)
* changes:
  Logging page only for platform roles
  User Enable/Disable
  Allow for project description change

skyquake/framework/core/modules/api/projectManagementAPI.js
skyquake/framework/widgets/form_controls/input.jsx
skyquake/plugins/about/config.json
skyquake/plugins/user_management/src/dashboard/dashboard.jsx
skyquake/plugins/user_management/src/dashboard/userMgmtActions.js
skyquake/plugins/user_management/src/dashboard/userMgmtStore.js

index 25fcebe..195f457 100644 (file)
@@ -104,14 +104,21 @@ ProjectManagement.create = function(req) {
     });
 };
 ProjectManagement.update = function(req) {
+    //"rw-project:project"
     var self = this;
     var api_server = req.query['api_server'];
     var bodyData = req.body;
-    data = bodyData['project-config']
+    var data = {
+        "rw-project:project" : {
+            "name": bodyData.name,
+            "description": bodyData.description,
+            "project-config": bodyData['project-config']
+        }
+    }
     var updateTasks = [];
 
     var updateProject= rp({
-                uri: utils.confdPort(api_server) + '/api/config/project/' + bodyData.name + '/project-config',
+                uri: utils.confdPort(api_server) + '/api/config/project/',
                 method: 'PUT',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
                     'Authorization': req.session && req.session.authorization
index 1563f29..d605614 100644 (file)
@@ -97,10 +97,12 @@ function buildRadioButtons(props) {
        <div className={className}>
             {
                 props.options.map((o,i) => {
+                    let label = o.label || o;
+                    let value = o.value || o;
                     return (
                         <label key={i}>
-                            {o.label}
-                            <input type="radio" checked={props.value == o.value} value={o.value} onChange={props.onChange} />
+                            {label}
+                            <input type="radio" checked={props.value == value} value={value} onChange={props.onChange} />
                         </label>
                     )
                 })
index 1885a9c..def1f6c 100644 (file)
@@ -5,6 +5,7 @@
     "order": 99,
     "priority":2,
     "admin_link": true,
+    "allow": ["rw-rbac-platform:super-admin", "rw-rbac-platform:platform-admin", "rw-rbac-platform:platform-oper"],
      "routes" : [{
         "label": "Dashboard",
         "route": "/",
index cb6b9a0..4432881 100644 (file)
@@ -19,6 +19,7 @@ import SelectOption from 'widgets/form_controls/selectOption.jsx';
 import 'widgets/form_controls/formControls.scss';
 import imgAdd from '../../node_modules/open-iconic/svg/plus.svg'
 import imgRemove from '../../node_modules/open-iconic/svg/trash.svg';
+import {merge} from 'lodash';
 
 import ROLES from 'utils/roleConstants.js';
 const PLATFORM = ROLES.PLATFORM;
@@ -107,6 +108,12 @@ class UserManagementDashboard extends React.Component {
         if(this.state['new-password'] != this.state['confirm-password']) {
             this.props.actions.showNotification('Passwords do not match')
         } else {
+            let isDisabled = {};
+            if (this.state.disabled == "TRUE") {
+                let isDisabled = {
+                    disabled: [null]
+                }
+            }
             this.Store.createUser({
                 'user-name': this.state['user-name'],
                 'user-domain': this.state['user-domain'],
@@ -121,22 +128,35 @@ class UserManagementDashboard extends React.Component {
         e.stopPropagation();
         let validatedPasswords = validatePasswordFields(this.state);
         if(validatedPasswords) {
+            let isDisabled = {};
+            let password = {};
+            if (self.state.disabled == "TRUE") {
+                isDisabled = {
+                    disabled: [null]
+                }
+            }
+            if (this.state['new-password'] != '') {
+                password = {'password': this.state['new-password']}
+            } else {
+                password = {
+                    'password': this.state.currentPassword
+                }
+            }
             this.Store.updateUser(_.merge({
                             'user-name': this.state['user-name'],
-                            'user-domain': this.state['user-domain'],
-                            'password': this.state['new-password']
-                        }));
+                            'user-domain': this.state['user-domain']
+                        }, _.merge(isDisabled, password)));
         }
         function validatePasswordFields(state) {
             let oldOne = state['old-password'];
             let newOne = state['new-password'];
             let confirmOne = state['confirm-password'];
             if(true) {
-                if(!oldOne || !newOne) {
-                     self.props.actions.showNotification('Please fill in all fields.');
-                    return false;
-                }
-                if(oldOne == newOne) {
+                // if(!oldOne || !newOne) {
+                //      self.props.actions.showNotification('Please fill in all fields.');
+                //     return false;
+                // }
+                if((oldOne || newOne) && (oldOne == newOne)) {
                     self.props.actions.showNotification('Your new password must not match your old one');
                     return false;
                 }
@@ -172,12 +192,7 @@ class UserManagementDashboard extends React.Component {
     disableChange = (e) => {
         let value = e.target.value;
         value = value.toUpperCase();
-        if (value=="TRUE") {
-            value = true;
-        } else {
-            value = false;
-        }
-        console.log(value)
+        this.actions.handleDisabledChange(value);
     }
     render() {
         let self = this;
@@ -280,6 +295,13 @@ class UserManagementDashboard extends React.Component {
                                         : <Input  readonly={state.isReadOnly}  label="Username" value={state['user-name']} onChange={this.updateInput.bind(null, 'user-name')} />
                                 }
                                 <Input readonly={true} label="Domain" value={state['user-domain']}  onChange={this.updateInput.bind(null, 'user-domain')}></Input>
+                                <Input
+                                    type="radiogroup"
+                                    onChange={this.disableChange}
+                                    label="Disabled"
+                                    value={this.state.disabled}
+                                    options={["TRUE","FALSE"]}
+                                    readonly={state.isReadOnly} />
                             </FormSection>
                             <FormSection title="PLATFORM ROLES" style={{display:'none'}}>
                                 <Input label="Super Admin" onChange={this.platformChange.bind(null, 'super_admin')} checked={state.platformRoles.super_admin} type="checkbox" />
index a0a34d9..7277ce1 100644 (file)
@@ -20,6 +20,7 @@ module.exports = function(Alt) {
                                        'handleUpdateUser',
                                        'updateUserSuccess',
                                        'createUserSuccess',
-                                       'deleteUserSuccess'
+                                       'deleteUserSuccess',
+                                       'handleDisabledChange'
                                        );
 }
index 19952fb..ada7067 100644 (file)
@@ -12,7 +12,7 @@ export default class UserManagementStore {
         this.users = [];
         this['user-name'] = '';
         this['user-domain'] = 'system';
-        this.disabled = false;
+        this.disabled = "FALSE";
         this.platformRoles = {
             super_admin: false,
             platform_admin: false,
@@ -70,8 +70,9 @@ export default class UserManagementStore {
             'user-name': user['user-name'],
             'user-domain': user['user-domain'],
             platformRoles: user.platformRoles || this.platformRoles,
-            disabled: user.disabled || this.disabled,
-            projectRoles: user.projectRoles || this.projectRoles
+            disabled: user.hasOwnProperty('disabled').toString().toUpperCase(),
+            projectRoles: user.projectRoles || this.projectRoles,
+            currentPassword: user.password
         }
         let state = _.merge({
             activeIndex: userIndex,
@@ -168,6 +169,9 @@ export default class UserManagementStore {
     }
     handleCreateUser() {
 
+    }
+    handleDisabledChange(value) {
+        this.disabled = value;
     }
     handleUpdateUser() {