Added projects to user management
[osm/UI.git] / skyquake / plugins / user_management / src / dashboard / dashboard.jsx
index 0377a54..70386c7 100644 (file)
@@ -114,12 +114,12 @@ class UserManagementDashboard extends React.Component {
                     disabled: [null]
                 }
             }
-            this.Store.createUser({
-                'user-name': this.state['user-name'],
-                'user-domain': this.state['user-domain'],
-                'password': this.state['new-password']
-                // 'confirm-password': this.state['confirm-password']
-            });
+            this.Store.createUser(_.merge({
+                            'user-name': this.state['user-name'],
+                            'user-domain': this.state['user-domain'],
+                            'password': this.state['new-password']
+                            // 'confirm-password': this.state['confirm-password']
+                        }, isDisabled));
         }
     }
     updateUser = (e) => {
@@ -224,13 +224,14 @@ class UserManagementDashboard extends React.Component {
                                 state.isEdit ?
                                 (
                                     <ButtonGroup className="buttonGroup">
-                                        <Button label="Update" type="submit" onClick={this.updateUser} />
                                         <Button label="Delete" onClick={this.deleteUser} />
                                         <Button label="Cancel" onClick={this.cancelEditUser} />
+                                        <Button label="Update" type="submit" onClick={this.updateUser} />
                                     </ButtonGroup>
                                 )
                                 : (
                                     <ButtonGroup className="buttonGroup">
+                                        <Button label="Cancel" onClick={this.closePanel} />
                                         <Button label="Create" type="submit" onClick={this.createUser}  />
                                     </ButtonGroup>
                                 )
@@ -251,6 +252,9 @@ class UserManagementDashboard extends React.Component {
                                 <div>
                                     Domain
                                 </div>
+                                <div>
+                                    Status
+                                </div>
                             </div>
                             {state.users && state.users.map((u, k) => {
                                 let platformRoles = [];
@@ -269,6 +273,9 @@ class UserManagementDashboard extends React.Component {
                                         <div>
                                             {u['user-domain']}
                                         </div>
+                                        <div>
+                                            {u['disabled'] ? "DISABLED" : "ENABLED"}
+                                        </div>
 
 
                                     </div>
@@ -288,38 +295,69 @@ class UserManagementDashboard extends React.Component {
                             style={{marginBottom: 0}}
                             hasCloseButton={this.closePanel}
                             no-corners>
-                            <FormSection title="USER INFO">
-                                {
-                                    this.state.isEdit ?
-                                        null
-                                        : <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
+                            <FormSection title="USER INFO" className="userInfo">
+                            {
+                                (!state.isEditUser ||  state.isReadOnly) ?
+                                <Input className="userInfo-section" readonly={state.isReadOnly || this.state.isEdit}  label="Username" value={state['user-name']} onChange={this.updateInput.bind(null, 'user-name')} />
+                                : null
+                            }
+                            {
+                                (!state.isEditUser ||  state.isReadOnly) ?
+                                <Input className="userInfo-section" readonly={true} label="Domain" value={state['user-domain']}  onChange={this.updateInput.bind(null, 'user-domain')}></Input>
+                                : null
+                            }
+                                <Input className="userInfo-section"
                                     type="radiogroup"
                                     onChange={this.disableChange}
-                                    label="Disabled"
+                                    label="STATUS"
                                     value={this.state.disabled}
-                                    options={["TRUE","FALSE"]}
-                                    readonly={state.isReadOnly} />
+                                    options={[{label: "DISABLED", value: "TRUE"},{label: "ENABLED", value: "FALSE"}]}
+                                    readonly={state.isReadOnly}
+                                    readonlydisplay={this.state.disabled == "TRUE" ? "DISABLED" : "ENABLED"}
+                                    />
                             </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" />
                                 <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>