From 8db3b3b43bec6170a7f1db21772c48c5e270c97b Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Thu, 30 Apr 2020 20:16:13 +0200 Subject: Add services dialog --- frontend/src/views/Services.js | 142 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 frontend/src/views/Services.js (limited to 'frontend/src/views/Services.js') diff --git a/frontend/src/views/Services.js b/frontend/src/views/Services.js new file mode 100644 index 0000000..1b3789d --- /dev/null +++ b/frontend/src/views/Services.js @@ -0,0 +1,142 @@ +import React, {Component} from 'react'; +import './Services.scss'; +import {Button, ButtonGroup, Col, Container, Form, FormControl, InputGroup, Modal, Row, Table} from "react-bootstrap"; +import axios from 'axios' +import {createCurlCommand} from '../utils'; + +class Services extends Component { + + constructor(props) { + super(props); + this.state = { + services: {}, + port: "", + portValid: false + } + + this.portChanged = this.portChanged.bind(this); + } + + componentDidMount() { + axios.get("/api/services").then(res => this.setState({services: res.data})) + } + + portChanged(event) { + let value = event.target.value.replace(/[^\d]/gi, '') + let intValue = parseInt(value) + this.setState({port: value, portValid: intValue > 0 && intValue <= 65565}) + + + } + + + render() { + let curl = createCurlCommand("/services", { + "port": this.state.port, + "name": "aaaaa", + "color": "#fff", + "notes": "aaa" + }) + + let rows = Object.values(this.state.services).map(s => + + + {s.port} + {s.name} + + ) + + + + + return ( + + + + ~/services + + + + + + + + + + + + + + + + {rows} + +
nameport
+ + +
+ + port: + + + {!this.state.portValid ? "assert(1 <= port <= 65565)" : ""} + + + + + name: + + + {"assert(len(name) >= 3)"} + + + + + color: + + + + + + + + + notes: + + +
+ + + + +
+ + + + + {curl} + + + + + +
+
+ + + + +
+ ); + } +} + +export default Services; -- cgit v1.2.3-70-g09d2