diff --git a/src/app.js b/src/app.js index cd07f75..ea6bb5f 100644 --- a/src/app.js +++ b/src/app.js @@ -50,6 +50,7 @@ import Scenarios from './scenario/scenarios'; import Scenario from './scenario/scenario'; import SimulationModel from './simulationmodel/simulation-model'; import Users from './user/users'; +import User from './user/user'; import './styles/app.css'; @@ -108,11 +109,11 @@ class App extends React.Component { showSidebarMenu = () => { this.setState({ showSidebarMenu: true }); - } + }; hideSidebarMenu = () => { this.setState({ showSidebarMenu: false }); - } + }; render() { if (this.state.token == null) { @@ -149,6 +150,7 @@ class App extends React.Component { + diff --git a/src/common/menu-sidebar.js b/src/common/menu-sidebar.js index 70a633a..5f43425 100644 --- a/src/common/menu-sidebar.js +++ b/src/common/menu-sidebar.js @@ -38,6 +38,7 @@ class SidebarMenu extends React.Component { { this.props.currentRole === 'Admin' ?
  • User Management
  • : '' } +
  • Account
  • Logout
  • diff --git a/src/user/user.js b/src/user/user.js new file mode 100644 index 0000000..ca424c5 --- /dev/null +++ b/src/user/user.js @@ -0,0 +1,156 @@ +/** + * File: user.js + * Author: Sonja Happ + * Date: 18.09.2019 + * + * This file is part of VILLASweb. + * + * VILLASweb is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VILLASweb is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with VILLASweb. If not, see . + ******************************************************************************/ + +import React, { Component } from 'react'; +import { Container } from 'flux/utils'; +import {Button, Col, Row, FormGroup, FormLabel} from 'react-bootstrap'; + +import AppDispatcher from '../common/app-dispatcher'; +import UserStore from './user-store'; + +import Icon from '../common/icon'; +import EditUserDialog from './edit-user'; + +import DeleteDialog from '../common/dialogs/delete-dialog'; +import ParametersEditor from "../common/parameters-editor"; + +class User extends Component { + static getStores() { + return [ UserStore ]; + } + + static calculateState(prevState, props) { + prevState = prevState || {}; + + const sessionToken = UserStore.getState().token; + + let user = UserStore.getState().currentUser; + + if(user === null) { + AppDispatcher.dispatch({ + type: 'users/start-load', + data: UserStore.getState().userid, + token: sessionToken + }); + + user = {}; + } + + console.log("extracted user 2: " + user.username); + + return { + user, + + token: sessionToken, + editModal: prevState.editModal || false, + deleteModal: prevState.deleteModal || false, + modalData: prevState.modalData || {} + }; + } + + + closeDeleteModal(confirmDelete) { + this.setState({ deleteModal: false }); + + if (confirmDelete === false) { + return; + } + + AppDispatcher.dispatch({ + type: 'users/start-remove', + data: this.state.modalData, + token: this.state.token + }); + } + + closeEditModal(data) { + this.setState({ editModal: false }); + + if (data) { + AppDispatcher.dispatch({ + type: 'users/start-edit', + data: data, + token: this.state.token + }); + } + } + + getHumanRoleName(role_key) { + const HUMAN_ROLE_NAMES = {Admin: 'Administrator', User: 'User', Guest: 'Guest'}; + + return HUMAN_ROLE_NAMES.hasOwnProperty(role_key)? HUMAN_ROLE_NAMES[role_key] : ''; + } + + onModalKeyPress = (event) => { + if (event.key === 'Enter') { + event.preventDefault(); + + this.confirmDeleteModal(); + } + }; + + render() { + + return ( +
    +

    Your User Account

    + +
    + + Username: + {this.state.user.username} + + + + + E-mail: + {this.state.user.mail} + + + + Role: + {this.state.user.role} + + +
    + +
    + ); + } +} + +{/**/} +{/**/} + +{/* this.closeEditModal(data)} user={this.state.modalData} />*/} +{/* this.closeDeleteModal(e)} />*/} + +{/**/} +{/* */} +{/* */} +{/* */} +{/* this.getHumanRoleName(role)} />*/} +{/* */} +{/*
    */} + + +let fluxContainerConverter = require('../common/FluxContainerConverter'); +export default Container.create(fluxContainerConverter.convert(User));