From d994a21a0dfae9ee026e8aa3ccdee6c213c523aa Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Tue, 29 Sep 2020 18:56:00 +0200 Subject: Complete rules page --- frontend/src/views/App.js | 6 -- frontend/src/views/Config.js | 2 - frontend/src/views/Connections.js | 4 +- frontend/src/views/Header.js | 1 - frontend/src/views/MainPane.js | 2 +- frontend/src/views/Rules.js | 118 -------------------------------------- 6 files changed, 3 insertions(+), 130 deletions(-) delete mode 100644 frontend/src/views/Rules.js (limited to 'frontend/src/views') diff --git a/frontend/src/views/App.js b/frontend/src/views/App.js index ccfdb3a..8bd5e46 100644 --- a/frontend/src/views/App.js +++ b/frontend/src/views/App.js @@ -5,7 +5,6 @@ import Footer from "./Footer"; import {BrowserRouter as Router} from "react-router-dom"; import Services from "./Services"; import Filters from "./Filters"; -import Rules from "./Rules"; import Config from "./Config"; class App extends Component { @@ -15,7 +14,6 @@ class App extends Component { this.state = { servicesWindowOpen: false, filterWindowOpen: false, - rulesWindowOpen: false, configWindowOpen: false, configDone: false }; @@ -40,9 +38,6 @@ class App extends Component { if (this.state.filterWindowOpen) { modal = this.setState({filterWindowOpen: false})}/>; } - if (this.state.rulesWindowOpen) { - modal = this.setState({rulesWindowOpen: false})}/>; - } if (this.state.configWindowOpen) { modal = this.setState({configWindowOpen: false})} onDone={() => this.setState({configDone: true})}/>; @@ -53,7 +48,6 @@ class App extends Component {
this.setState({servicesWindowOpen: true})} onOpenFilters={() => this.setState({filterWindowOpen: true})} - onOpenRules={() => this.setState({rulesWindowOpen: true})} onOpenConfig={() => this.setState({configWindowOpen: true})} onOpenUpload={() => this.setState({uploadWindowOpen: true})} onConfigDone={this.state.configDone} diff --git a/frontend/src/views/Config.js b/frontend/src/views/Config.js index a770378..b11f827 100644 --- a/frontend/src/views/Config.js +++ b/frontend/src/views/Config.js @@ -68,8 +68,6 @@ class Config extends Component { }) }; - let msg = ""; - fetch('/setup', requestOptions) .then(response => { if (response.status === 202 ){ diff --git a/frontend/src/views/Connections.js b/frontend/src/views/Connections.js index f3fec64..64068c5 100644 --- a/frontend/src/views/Connections.js +++ b/frontend/src/views/Connections.js @@ -75,7 +75,7 @@ class Connections extends Component { } this.setState({loading: true, prevParams: params}); - let res = await backend.getJson(`${url}?${urlParams}`); + let res = (await backend.getJson(`${url}?${urlParams}`)).json; let connections = this.state.connections; let firstConnection = this.state.firstConnection; @@ -115,7 +115,7 @@ class Connections extends Component { let flagRule = this.state.flagRule; let rules = this.state.rules; if (flagRule === null) { - rules = await backend.getJson("/api/rules"); + rules = (await backend.getJson("/api/rules")).json; flagRule = rules.filter(rule => { return rule.name === "flag"; })[0]; diff --git a/frontend/src/views/Header.js b/frontend/src/views/Header.js index 0b82011..06cb20e 100644 --- a/frontend/src/views/Header.js +++ b/frontend/src/views/Header.js @@ -1,7 +1,6 @@ import React, {Component} from 'react'; import Typed from 'typed.js'; import './Header.scss'; -import {Button} from "react-bootstrap"; import {filtersDefinitions, filtersNames} from "../components/filters/FiltersDefinitions"; import {Link} from "react-router-dom"; import ButtonField from "../components/fields/ButtonField"; diff --git a/frontend/src/views/MainPane.js b/frontend/src/views/MainPane.js index 9d3f7b7..6f4e3cd 100644 --- a/frontend/src/views/MainPane.js +++ b/frontend/src/views/MainPane.js @@ -22,7 +22,7 @@ class MainPane extends Component { if (match != null) { this.setState({loading: true}); backend.getJson(`/api/connections/${match[1]}`) - .then(connection => this.setState({selectedConnection: connection, loading: false})) + .then(res => this.setState({selectedConnection: res.json, loading: false})) .catch(error => console.log(error)); } } diff --git a/frontend/src/views/Rules.js b/frontend/src/views/Rules.js deleted file mode 100644 index bbc3bb6..0000000 --- a/frontend/src/views/Rules.js +++ /dev/null @@ -1,118 +0,0 @@ -import React, {Component} from 'react'; -import './Services.scss'; -import {Button, ButtonGroup, Col, Container, Form, FormControl, InputGroup, Modal, Row, Table} from "react-bootstrap"; -import backend from "../backend"; - -class Rules extends Component { - - constructor(props) { - super(props); - - this.state = { - rules: [] - }; - } - - componentDidMount() { - this.loadRules(); - } - - loadRules() { - backend.get("/api/rules").then(res => this.setState({rules: res.data})); - } - - render() { - let rulesRows = this.state.rules.map(rule => - - - {rule.name} - - ); - - - return ( - - - - ~/rules - - - - - - - - - - - - - - - {rulesRows} - - -
name
- - -
- - port: - - - - - name: - - - - - color: - - - - - - - - - - notes: - - -
- - - - -
- - - - - - - - - - - -
-
- - - -
- ); - } -} - -export default Rules; -- cgit v1.2.3-70-g09d2