From fe511f33c451a4c1c85950d0619b927747757d4e Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Tue, 11 Aug 2020 10:50:55 +0200 Subject: Fix codacy errors and warnings --- frontend/src/views/App.js | 11 +++- frontend/src/views/App.scss | 2 - frontend/src/views/Filters.js | 7 ++- frontend/src/views/Filters.scss | 0 frontend/src/views/Header.js | 10 ++-- frontend/src/views/Header.scss | 3 - frontend/src/views/Rules.js | 118 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 134 insertions(+), 17 deletions(-) delete mode 100644 frontend/src/views/App.scss delete mode 100644 frontend/src/views/Filters.scss create 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 14ff7bf..6c101fa 100644 --- a/frontend/src/views/App.js +++ b/frontend/src/views/App.js @@ -1,11 +1,11 @@ import React, {Component} from 'react'; import Header from "./Header"; -import './App.scss'; import MainPane from "./MainPane"; import Footer from "./Footer"; import {BrowserRouter as Router, Route, Switch} from "react-router-dom"; import Services from "./Services"; import Filters from "./Filters"; +import Rules from "./Rules"; class App extends Component { @@ -13,7 +13,8 @@ class App extends Component { super(props); this.state = { servicesWindowOpen: false, - filterWindowOpen: false + filterWindowOpen: false, + rulesWindowOpen: false }; } @@ -25,12 +26,16 @@ class App extends Component { if (this.state.filterWindowOpen) { modal = this.setState({filterWindowOpen: false})}/>; } + if (this.state.rulesWindowOpen) { + modal = this.setState({rulesWindowOpen: false})}/>; + } return (
this.setState({servicesWindowOpen: true})} - onOpenFilters={() => this.setState({filterWindowOpen: true})}/> + onOpenFilters={() => this.setState({filterWindowOpen: true})} + onOpenRules={() => this.setState({rulesWindowOpen: true})} /> }/> }/> diff --git a/frontend/src/views/App.scss b/frontend/src/views/App.scss deleted file mode 100644 index d5813f9..0000000 --- a/frontend/src/views/App.scss +++ /dev/null @@ -1,2 +0,0 @@ -.app { -} diff --git a/frontend/src/views/Filters.js b/frontend/src/views/Filters.js index 23d3a00..78f0342 100644 --- a/frontend/src/views/Filters.js +++ b/frontend/src/views/Filters.js @@ -7,8 +7,9 @@ class Filters extends Component { constructor(props) { super(props); - this.state = {}; - filtersNames.forEach(elem => this.state[`${elem}_active`] = false); + let newState = {}; + filtersNames.forEach(elem => newState[`${elem}_active`] = false); + this.state = newState; } componentDidMount() { @@ -27,7 +28,7 @@ class Filters extends Component { generateRows(filtersNames) { return filtersNames.map(name => - + this.checkboxChangesHandler(name, event)} /> diff --git a/frontend/src/views/Filters.scss b/frontend/src/views/Filters.scss deleted file mode 100644 index e69de29..0000000 diff --git a/frontend/src/views/Header.js b/frontend/src/views/Header.js index 007be74..5d0f690 100644 --- a/frontend/src/views/Header.js +++ b/frontend/src/views/Header.js @@ -2,17 +2,15 @@ import React, {Component} from 'react'; import Typed from 'typed.js'; import './Header.scss'; import {Button} from "react-bootstrap"; -import StringConnectionsFilter from "../components/filters/StringConnectionsFilter"; -import {cleanNumber, validateIpAddress, validateMin, validatePort} from "../utils"; -import RulesConnectionsFilter from "../components/filters/RulesConnectionsFilter"; import {filtersDefinitions, filtersNames} from "../components/filters/FiltersDefinitions"; class Header extends Component { constructor(props) { super(props); - this.state = {}; - filtersNames.forEach(elem => this.state[`${elem}_active`] = false); + let newState = {}; + filtersNames.forEach(elem => newState[`${elem}_active`] = false); + this.state = newState; this.fetchStateFromLocalStorage = this.fetchStateFromLocalStorage.bind(this); } @@ -73,7 +71,7 @@ class Header extends Component {
- + diff --git a/frontend/src/views/Header.scss b/frontend/src/views/Header.scss index 806e398..e84e758 100644 --- a/frontend/src/views/Header.scss +++ b/frontend/src/views/Header.scss @@ -21,8 +21,5 @@ .filters-bar-wrapper { height: 50px; padding: 8px 0; - - .filters-bar { - } } } diff --git a/frontend/src/views/Rules.js b/frontend/src/views/Rules.js new file mode 100644 index 0000000..3424410 --- /dev/null +++ b/frontend/src/views/Rules.js @@ -0,0 +1,118 @@ +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"; + +class Rules extends Component { + + constructor(props) { + super(props); + + this.state = { + rules: [] + }; + } + + componentDidMount() { + this.loadRules(); + } + + loadRules() { + axios.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