diff --git a/src/ic/confirm-command.js b/src/ic/confirm-command.js new file mode 100644 index 0000000..43b6885 --- /dev/null +++ b/src/ic/confirm-command.js @@ -0,0 +1,48 @@ +/** + * 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 from 'react'; +import { Button, Modal} from 'react-bootstrap'; + +class ConfirmCommand extends React.Component { + onModalKeyPress = (event) => { + if (event.key === 'Enter') { + event.preventDefault(); + + this.props.onClose(false); + } + } + + render() { + return this.props.onClose(false)} onKeyPress={this.onModalKeyPress}> + + Confirm {this.props.command} + + + + Are you sure you want to {this.props.command} '{this.props.name}'? + + + + + + + ; + } +} + +export default ConfirmCommand; diff --git a/src/ic/ic-dialog.js b/src/ic/ic-dialog.js index 12f65ec..0acbcb5 100644 --- a/src/ic/ic-dialog.js +++ b/src/ic/ic-dialog.js @@ -3,6 +3,7 @@ import {FormLabel, Button} from 'react-bootstrap'; import Dialog from '../common/dialogs/dialog'; import {Collapse} from 'react-collapse'; import Icon from "../common/icon"; +import ConfirmCommand from './confirm-command'; @@ -13,6 +14,8 @@ class ICDialog extends React.Component { super(props); this.state = { + confirmCommand: false, + command: '', }; } @@ -33,6 +36,15 @@ class ICDialog extends React.Component { console.log("graph error"); } + closeConfirmModal(canceled){ + if(!canceled){ + this.props.sendControlCommand(this.state.command); + } + + this.setState({confirmCommand: false, command: ''}); + } + + render() { let objectURL='' @@ -91,7 +103,15 @@ class ICDialog extends React.Component { )} + +
Controls
+ + + + this.closeConfirmModal(c)} /> + + ); } } diff --git a/src/ic/ics.js b/src/ic/ics.js index f3ec9d3..c582503 100644 --- a/src/ic/ics.js +++ b/src/ic/ics.js @@ -365,6 +365,10 @@ class InfrastructureComponents extends Component { this.setState({ icModal: true, modalIC: ic, modalICStatus: icStatus, modalICGraph: icGraph, modalIndex: index }) } + sendControlCommand(command){ + console.log(command); + } + render() { const buttonStyle = { marginLeft: '10px' @@ -435,7 +439,7 @@ class InfrastructureComponents extends Component { this.closeNewModal(data)} /> this.closeEditModal(data)} ic={this.state.modalIC} /> this.closeImportModal(data)} /> - this.closeICModal(data)} ic={this.state.modalIC} token={this.state.sessionToken} icStatus={this.state.modalICStatus} icGraph={this.state.modalICGraph} /> + this.closeICModal(data)} ic={this.state.modalIC} token={this.state.sessionToken} icStatus={this.state.modalICStatus} icGraph={this.state.modalICGraph} sendControlCommand={(command) => this.sendControlCommand(command)}/> this.closeDeleteModal(e)} />