/** * File: simulators.js * Author: Markus Grigull * Date: 02.03.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 SimulatorStore from '../stores/simulator-store'; import Table from '../components/table'; import TableColumn from '../components/table-column'; import NewSimulatorDialog from '../components/dialog/new-simulator'; import EditSimulatorDialog from '../components/dialog/edit-simulator'; class Simulators extends Component { static getStores() { return [ SimulatorStore ]; } static calculateState() { return { simulators: SimulatorStore.getState(), newModal: false, deleteModal: false, editModal: false, modalSimulator: {} }; } componentWillMount() { AppDispatcher.dispatch({ type: 'simulators/start-load' }); } closeNewModal(data) { this.setState({ newModal : false }); if (data) { AppDispatcher.dispatch({ type: 'simulators/start-add', data: data }); } } confirmDeleteModal() { this.setState({ deleteModal: false }); AppDispatcher.dispatch({ type: 'simulators/start-remove', data: this.state.modalSimulator }); } closeEditModal(data) { this.setState({ editModal : false }); if (data) { AppDispatcher.dispatch({ type: 'simulators/start-edit', data: data }); } } labelStyle(value) { if (value === true) return 'success'; else return 'warning'; } labelModifier(value) { if (value === true) return 'Running'; else return 'Not running'; } render() { return (

Simulators

this.labelStyle(value)} labelModifier={(value) => this.labelModifier(value)} /> this.setState({ editModal: true, modalSimulator: this.state.simulators[index] })} onDelete={(index) => this.setState({ deleteModal: true, modalSimulator: this.state.simulators[index] })} />
this.closeNewModal(data)} /> this.closeEditModal(data)} simulator={this.state.modalSimulator} /> Delete Simulator Are you sure you want to delete the simulator '{this.state.modalSimulator.name}'?
); } } export default Container.create(Simulators);