X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=skyquake%2Fplugins%2Fuser_management%2Fsrc%2FuserProfile%2FuserProfile.jsx;fp=skyquake%2Fplugins%2Fuser_management%2Fsrc%2FuserProfile%2FuserProfile.jsx;h=c4f657b4de7a48c5e057a7514092620980b58ea7;hb=03156e335275de1dafbc2a816e98006afdf249bf;hp=0000000000000000000000000000000000000000;hpb=f2dc2462571800e62cba969964de621dca09299c;p=osm%2FUI.git
diff --git a/skyquake/plugins/user_management/src/userProfile/userProfile.jsx b/skyquake/plugins/user_management/src/userProfile/userProfile.jsx
new file mode 100644
index 000000000..c4f657b4d
--- /dev/null
+++ b/skyquake/plugins/user_management/src/userProfile/userProfile.jsx
@@ -0,0 +1,387 @@
+/*
+ * STANDARD_RIFT_IO_COPYRIGHT
+ */
+
+import React from 'react';
+import ReactDOM from 'react-dom';
+import AppHeader from 'widgets/header/header.jsx';
+import UserProfileStore from './userProfileStore.js';
+import SkyquakeComponent from 'widgets/skyquake_container/skyquakeComponent.jsx';
+import 'style/layout.scss';
+import '../dashboard/userMgmt.scss';
+import { Panel, PanelWrapper } from 'widgets/panel/panel';
+
+
+import TextInput from 'widgets/form_controls/textInput.jsx';
+import Input from 'widgets/form_controls/input.jsx';
+import Button, { ButtonGroup } from 'widgets/button/sq-button.jsx';
+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';
+
+class UserProfileDashboard extends React.Component {
+ constructor(props) {
+ super(props);
+ this.Store = this.props.flux.stores.hasOwnProperty('UserProfileStore') ? this.props.flux.stores.UserProfileStore : this.props.flux.createStore(UserProfileStore);
+ this.state = this.Store.getState();
+ this.actions = this.state.actions;
+
+ }
+ componentDidUpdate() {
+ let self = this;
+ ReactDOM.findDOMNode(this.UserList).addEventListener('transitionend', this.onTransitionEnd, false);
+ setTimeout(function () {
+ let element = self[`user-ref-${self.state.activeIndex}`]
+ element && !isElementInView(element) && element.scrollIntoView({ block: 'end', behavior: 'smooth' });
+ })
+ }
+ componentWillMount() {
+ this.Store.listen(this.updateState);
+ }
+ componentWillUnmount() {
+ this.Store.unlisten(this.updateState);
+ }
+ updateState = (state) => {
+ this.setState(state);
+ }
+ updateInput = (key, e) => {
+ let property = key;
+ this.actions.handleUpdateInput({
+ [property]: e.target.value
+ })
+ }
+ disabledChange = (e) => {
+ this.actions.handleDisabledChange(e.target.checked);
+ }
+ platformChange = (platformRole, e) => {
+ this.actions.handlePlatformRoleUpdate(platformRole, e.currentTarget.checked);
+ }
+ addProjectRole = (e) => {
+ this.actions.handleAddProjectItem();
+ }
+ removeProjectRole = (i, e) => {
+ this.actions.handleRemoveProjectItem(i);
+ }
+ updateProjectRole = (i, e) => {
+ this.actions.handleUpdateProjectRole(i, e)
+ }
+ addUser = () => {
+ this.actions.handleAddUser();
+ }
+ viewUser = (un, index) => {
+ this.actions.viewUser(un, index);
+ }
+ editUser = () => {
+ this.actions.editUser(false);
+ }
+ cancelEditUser = () => {
+ this.actions.editUser(true)
+ }
+ osePanel = () => {
+ this.actions.handleCloseUserPanel();
+ }
+ // updateUser = (e) => {
+ // e.preventDefault();
+ // e.stopPropagation();
+
+ // this.Store.updateUser();
+ // }
+ deleteUser = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ this.Store.deleteUser({
+ 'user-name': this.state['user-name'],
+ 'user-domain': this.state['user-domain']
+ });
+ }
+ createUser = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ if (this.state['new-password'] != this.state['confirm-password']) {
+ this.props.actions.showNotification('Passwords do not match')
+ } else {
+ 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']
+ });
+ }
+ }
+ updateUser = (e) => {
+ let self = this;
+ e.preventDefault();
+ e.stopPropagation();
+ let validatedPasswords = validatePasswordFields(this.state);
+ if (validatedPasswords) {
+ this.Store.updateUser(_.merge({
+ 'user-name': this.context.userProfile.userId,
+ 'user-domain': this.state['user-domain'],
+ 'password': this.state['new-password'],
+ 'ui-state': this.context.userProfile.data['ui-state']
+ }));
+ }
+ function validatePasswordFields(state) {
+ let newOne = state['new-password'];
+ let confirmOne = state['confirm-password'];
+ if (!newOne || !confirmOne) {
+ self.props.actions.showNotification('Please fill in all fields.');
+ return false;
+ }
+ if (newOne != confirmOne) {
+ self.props.actions.showNotification('Passwords do not match');
+ return false;
+ }
+ return {
+ 'new-password': newOne,
+ 'confirm-password': confirmOne
+ }
+ }
+ }
+ evaluateSubmit = (e) => {
+ if (e.keyCode == 13) {
+ if (this.state.isEdit) {
+ this.updateUser(e);
+ } else {
+ this.createUser(e);
+ }
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ }
+ onTransitionEnd = (e) => {
+ this.actions.handleHideColumns(e);
+ console.log('transition end')
+ }
+ disableChange = (e) => {
+ let value = e.target.value;
+ value = value.toUpperCase();
+ if (value == "TRUE") {
+ value = true;
+ } else {
+ value = false;
+ }
+ console.log(value)
+ }
+ render() {
+
+ let self = this;
+ const User = this.context.userProfile || {};
+ let html;
+ let props = this.props;
+ let state = this.state;
+ let passwordSectionHTML = null;
+ let formButtonsHTML = (
+
+
+
+
+
+
+
+ {
+ User.data && User.data.projectId && User.data.projectId.map((p, i) => {
+ let project = User.data.project[p];
+ let projectConfig = project && project.data['project-config'];
+ let userRoles = [];
+ return (
+ Project
+ Role
+
+
+ )
+ })
+ }
+
+
+ {p}
+
+
+ {
+ project && Object.keys(project.role).map(function (k, i) {
+ return
+