diff --git a/src/components/menu-sidebar.js b/src/components/menu-sidebar.js
index 120065d..1782304 100644
--- a/src/components/menu-sidebar.js
+++ b/src/components/menu-sidebar.js
@@ -33,6 +33,7 @@ class SidebarMenu extends Component {
Projects
Simulations
Simulators
+ User Management
Logout
diff --git a/src/containers/users.js b/src/containers/users.js
new file mode 100644
index 0000000..531f112
--- /dev/null
+++ b/src/containers/users.js
@@ -0,0 +1,136 @@
+/**
+ * File: users.js
+ * Author: Ricardo Hernandez-Montoya
+ * Date: 02.05.2017
+ *
+ * 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, Modal, Glyphicon } from 'react-bootstrap';
+
+import AppDispatcher from '../app-dispatcher';
+import UserStore from '../stores/user-store';
+
+import Table from '../components/table';
+import TableColumn from '../components/table-column';
+import NewProjectDialog from '../components/dialog/new-project';
+import EditProjectDialog from '../components/dialog/edit-project';
+
+class Projects extends Component {
+ static getStores() {
+ return [ UserStore ];
+ }
+
+ static calculateState() {
+ return {
+ users: UserStore.getState().users,
+
+ newModal: false,
+ editModal: false,
+ deleteModal: false,
+ modalData: {}
+ };
+ }
+
+ componentWillMount() {
+ AppDispatcher.dispatch({
+ type: 'users/start-load'
+ });
+ }
+
+ // closeNewModal(data) {
+ // this.setState({ newModal: false });
+
+ // if (data) {
+ // AppDispatcher.dispatch({
+ // type: 'projects/start-add',
+ // data: data
+ // });
+ // }
+ // }
+
+ // confirmDeleteModal() {
+ // this.setState({ deleteModal: false });
+
+ // AppDispatcher.dispatch({
+ // type: 'projects/start-remove',
+ // data: this.state.modalData
+ // });
+ // }
+
+ // closeEditModal(data) {
+ // this.setState({ editModal: false });
+
+ // if (data) {
+ // AppDispatcher.dispatch({
+ // type: 'projects/start-edit',
+ // data: data
+ // });
+ // }
+ // }
+
+ // getSimulationName(id) {
+ // for (var i = 0; i < this.state.simulations.length; i++) {
+ // if (this.state.simulations[i]._id === id) {
+ // return this.state.simulations[i].name;
+ // }
+ // }
+
+ // return id;
+ // }
+
+ render() {
+
+ this.state.users.map( (user) => console.log('User: %o', user));
+
+ return (
+
+
Users
+
+
+
+
+ this.setState({ editModal: true, modalData: this.state.users[index] })} onDelete={index => this.setState({ deleteModal: true, modalData: this.state.users[index] })} />
+
+
+ {/*
+
+
this.closeNewModal(data)} simulations={this.state.simulations} />
+
+ this.closeEditModal(data)} project={this.state.modalData} simulations={this.state.simulations} />
+
+
+
+ Delete Project
+
+
+
+ Are you sure you want to delete the project '{this.state.modalData.name}'?
+
+
+
+
+
+
+ */}
+
+ );
+ }
+}
+
+export default Container.create(Projects);
diff --git a/src/data-managers/users-data-manager.js b/src/data-managers/users-data-manager.js
index 711c68d..08c3138 100644
--- a/src/data-managers/users-data-manager.js
+++ b/src/data-managers/users-data-manager.js
@@ -55,6 +55,20 @@ class UsersDataManager extends RestDataManager {
});
});
}
+
+ getUsers(token) {
+ RestAPI.get(this.makeURL('/users'), token).then(response => {
+ AppDispatcher.dispatch({
+ type: 'users/users-loaded',
+ users: response.users
+ });
+ }).catch(error => {
+ AppDispatcher.dispatch({
+ type: 'users/users-load-error',
+ error: error
+ });
+ });
+ }
}
export default new UsersDataManager();
diff --git a/src/router.js b/src/router.js
index a74a7eb..85bbe78 100644
--- a/src/router.js
+++ b/src/router.js
@@ -30,6 +30,7 @@ import Simulators from './containers/simulators';
import Visualization from './containers/visualization';
import Simulations from './containers/simulations';
import Simulation from './containers/simulation';
+import Users from './containers/users';
import Login from './containers/login';
import Logout from './containers/logout';
@@ -50,6 +51,8 @@ class Root extends Component {
+
+
diff --git a/src/stores/user-store.js b/src/stores/user-store.js
index aeed56f..9acf4d2 100644
--- a/src/stores/user-store.js
+++ b/src/stores/user-store.js
@@ -80,6 +80,20 @@ class UserStore extends ReduceStore {
}
return state;
+
+ case 'users/start-load':
+ console.log('Sending request');
+ UsersDataManager.getUsers(state.token);
+
+ return state;
+
+ case 'users/users-loaded':
+
+ return Object.assign({}, state, { users: action.users });
+
+ case 'users/users-load-error':
+ // Users couldn't be loaded. Keep same state
+ return state;
default:
return state;