2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END============================================
19 * ===================================================================
23 import React from 'react'
24 import Select from 'react-select';
25 import Button from 'react-bootstrap/Button';
26 import Modal from 'react-bootstrap/Modal';
27 import Form from 'react-bootstrap/Form';
28 import Row from 'react-bootstrap/Row';
29 import Col from 'react-bootstrap/Col';
30 import FormCheck from 'react-bootstrap/FormCheck'
31 import styled from 'styled-components';
32 import LoopService from '../../../api/LoopService';
34 const ModalStyled = styled(Modal)`
35 background-color: transparent;
37 const CheckBoxStyled = styled(FormCheck.Input)`
41 export default class OpenLoopModal extends React.Component {
42 constructor(props, context) {
43 super(props, context);
45 this.getLoopNames = this.getLoopNames.bind(this);
46 this.handleOpen = this.handleOpen.bind(this);
47 this.handleClose = this.handleClose.bind(this);
48 this.handleDropdownListChange = this.handleDropdownListChange.bind(this);
56 componentWillMount() {
61 this.setState({ show: false });
62 this.props.history.push('/');
65 handleDropdownListChange(e) {
66 this.setState({ chosenLoopName: e.value });
70 LoopService.getLoopNames().then(loopNames => {
71 if (Object.entries(loopNames).length !== 0) {
72 const loopOptions = loopNames.filter(loopName => loopName!=='undefined').map((loopName) => { return { label: loopName, value: loopName } });
73 this.setState({ loopNames: loopOptions })
79 console.info("Loop " + this.state.chosenLoopName + " is chosen");
81 this.props.loadLoopFunction(this.state.chosenLoopName);
86 <ModalStyled size="lg" show={this.state.show} onHide={this.handleClose}>
87 <Modal.Header closeButton>
88 <Modal.Title>Open Model</Modal.Title>
91 <Form.Group as={Row} controlId="formPlaintextEmail">
92 <Form.Label column sm="2">Model Name</Form.Label>
94 <Select onChange={this.handleDropdownListChange} options={this.state.loopNames} />
97 <Form.Group controlId="formBasicChecbox">
99 <FormCheck.Label>Read Only</FormCheck.Label>
100 <CheckBoxStyled type="checkbox" />
105 <Button variant="secondary" type="null" onClick={this.handleClose}>Cancel</Button>
106 <Button variant="primary" type="submit" onClick={this.handleOpen}>Open</Button>