aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/views
diff options
context:
space:
mode:
authorEmiliano Ciavatta2020-08-11 08:50:55 +0000
committerEmiliano Ciavatta2020-08-11 08:56:52 +0000
commitfe511f33c451a4c1c85950d0619b927747757d4e (patch)
tree675909b5e6d92bc62ee535eac1867513fcd276ee /frontend/src/views
parent9dae0115592424929ffe4045069740365bc91d52 (diff)
Fix codacy errors and warnings
Diffstat (limited to 'frontend/src/views')
-rw-r--r--frontend/src/views/App.js11
-rw-r--r--frontend/src/views/App.scss2
-rw-r--r--frontend/src/views/Filters.js7
-rw-r--r--frontend/src/views/Filters.scss0
-rw-r--r--frontend/src/views/Header.js10
-rw-r--r--frontend/src/views/Header.scss3
-rw-r--r--frontend/src/views/Rules.js118
7 files changed, 134 insertions, 17 deletions
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 = <Filters onHide={() => this.setState({filterWindowOpen: false})}/>;
}
+ if (this.state.rulesWindowOpen) {
+ modal = <Rules onHide={() => this.setState({rulesWindowOpen: false})}/>;
+ }
return (
<div className="app">
<Router>
<Header onOpenServices={() => this.setState({servicesWindowOpen: true})}
- onOpenFilters={() => this.setState({filterWindowOpen: true})}/>
+ onOpenFilters={() => this.setState({filterWindowOpen: true})}
+ onOpenRules={() => this.setState({rulesWindowOpen: true})} />
<Switch>
<Route path="/connections/:id" children={<MainPane/>}/>
<Route path="/" children={<MainPane/>}/>
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 =>
- <tr>
+ <tr key={name}>
<td><input type="checkbox"
checked={this.state[`${name}_active`]}
onChange={event => this.checkboxChangesHandler(name, event)} /></td>
diff --git a/frontend/src/views/Filters.scss b/frontend/src/views/Filters.scss
deleted file mode 100644
index e69de29..0000000
--- a/frontend/src/views/Filters.scss
+++ /dev/null
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 {
<div className="header-buttons">
<Button onClick={this.props.onOpenFilters}>filters</Button>
<Button variant="yellow" size="sm">pcaps</Button>
- <Button variant="blue">rules</Button>
+ <Button variant="blue" onClick={this.props.onOpenRules}>rules</Button>
<Button variant="red" onClick={this.props.onOpenServices}>
services
</Button>
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 =>
+ <tr key={rule.id}>
+ <td><Button variant="btn-edit" size="sm"
+ style={{"backgroundColor": rule.color}}>edit</Button></td>
+ <td>{rule.name}</td>
+ </tr>
+ );
+
+
+ return (
+ <Modal
+ {...this.props}
+ show="true"
+ size="lg"
+ aria-labelledby="rules-dialog"
+ centered
+ >
+ <Modal.Header>
+ <Modal.Title id="rules-dialog">
+ ~/rules
+ </Modal.Title>
+ </Modal.Header>
+ <Modal.Body>
+ <Container>
+ <Row>
+ <Col md={7}>
+ <Table borderless size="sm" className="rules-list">
+ <thead>
+ <tr>
+ <th><Button size="sm" >new</Button></th>
+ <th>name</th>
+ </tr>
+ </thead>
+ <tbody>
+ {rulesRows}
+
+ </tbody>
+ </Table>
+ </Col>
+ <Col md={5}>
+ <Form>
+ <Form.Group controlId="servicePort">
+ <Form.Label>port:</Form.Label>
+ <Form.Control type="text" />
+ </Form.Group>
+
+ <Form.Group controlId="serviceName">
+ <Form.Label>name:</Form.Label>
+ <Form.Control type="text" />
+ </Form.Group>
+
+ <Form.Group controlId="serviceColor">
+ <Form.Label>color:</Form.Label>
+ <ButtonGroup aria-label="Basic example">
+
+ </ButtonGroup>
+ <ButtonGroup aria-label="Basic example">
+
+ </ButtonGroup>
+ </Form.Group>
+
+ <Form.Group controlId="serviceNotes">
+ <Form.Label>notes:</Form.Label>
+ <Form.Control as="textarea" rows={3} />
+ </Form.Group>
+ </Form>
+
+
+ </Col>
+
+ </Row>
+
+ <Row>
+ <Col md={12}>
+ <InputGroup>
+ <FormControl as="textarea" rows={4} className="curl-output" readOnly={true}
+ />
+ </InputGroup>
+
+ </Col>
+ </Row>
+
+
+ </Container>
+ </Modal.Body>
+ <Modal.Footer className="dialog-footer">
+ <Button variant="red" onClick={this.props.onHide}>close</Button>
+ </Modal.Footer>
+ </Modal>
+ );
+ }
+}
+
+export default Rules;