From 2fb8993008752063fa13f253784e9e92552e339d Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Fri, 16 Oct 2020 11:13:21 +0200 Subject: Refactor js files --- frontend/src/components/pages/ConfigurationPage.js | 43 +++++++++++----------- frontend/src/components/pages/MainPage.js | 20 +++++----- .../src/components/pages/ServiceUnavailablePage.js | 4 +- 3 files changed, 33 insertions(+), 34 deletions(-) (limited to 'frontend/src/components/pages') diff --git a/frontend/src/components/pages/ConfigurationPage.js b/frontend/src/components/pages/ConfigurationPage.js index 6ab8ae3..2bd2da7 100644 --- a/frontend/src/components/pages/ConfigurationPage.js +++ b/frontend/src/components/pages/ConfigurationPage.js @@ -15,19 +15,19 @@ * along with this program. If not, see . */ -import React, {Component} from 'react'; -import '../panels/common.scss'; -import './ConfigurationPage.scss'; -import LinkPopover from "../objects/LinkPopover"; +import React, {Component} from "react"; import {Col, Container, Row} from "react-bootstrap"; -import InputField from "../fields/InputField"; -import TextField from "../fields/TextField"; -import ButtonField from "../fields/ButtonField"; -import CheckField from "../fields/CheckField"; -import {createCurlCommand} from "../../utils"; import Table from "react-bootstrap/Table"; -import validation from "../../validation"; import backend from "../../backend"; +import {createCurlCommand} from "../../utils"; +import validation from "../../validation"; +import ButtonField from "../fields/ButtonField"; +import CheckField from "../fields/CheckField"; +import InputField from "../fields/InputField"; +import TextField from "../fields/TextField"; +import LinkPopover from "../objects/LinkPopover"; +import "../panels/common.scss"; +import "./ConfigurationPage.scss"; class ConfigurationPage extends Component { @@ -40,8 +40,7 @@ class ConfigurationPage extends Component { "flag_regex": "", "auth_required": false }, - "accounts": { - } + "accounts": {} }, newUsername: "", newPassword: "" @@ -50,9 +49,9 @@ class ConfigurationPage extends Component { saveSettings = () => { if (this.validateSettings(this.state.settings)) { - backend.post("/setup", this.state.settings).then(_ => { + backend.post("/setup", this.state.settings).then((_) => { this.props.onConfigured(); - }).catch(res => { + }).catch((res) => { this.setState({setupStatusCode: res.status, setupResponse: JSON.stringify(res.json)}); }); } @@ -102,14 +101,14 @@ class ConfigurationPage extends Component { const accounts = Object.entries(settings.accounts).map(([username, password]) => {username} - + this.updateParam((s) => delete s.accounts[username]) }/> + onClick={() => this.updateParam((s) => delete s.accounts[username])}/> ).concat( this.setState({newUsername: v})} /> + onChange={(v) => this.setState({newUsername: v})}/> this.setState({newPassword: v})} /> + onChange={(v) => this.setState({newPassword: v})}/> ); @@ -122,7 +121,7 @@ class ConfigurationPage extends Component { POST /setup + placement="left"/>
@@ -131,10 +130,10 @@ class ConfigurationPage extends Component { this.updateParam((s) => s.config.server_address = v)} /> + onChange={(v) => this.updateParam((s) => s.config.server_address = v)}/> this.updateParam((s) => s.config.flag_regex = v)} - error={this.state.flagRegexError} /> + error={this.state.flagRegexError}/>
this.updateParam((s) => s.config.auth_required = v)}/> @@ -166,7 +165,7 @@ class ConfigurationPage extends Component {
- +
diff --git a/frontend/src/components/pages/MainPage.js b/frontend/src/components/pages/MainPage.js index 0b06f55..a542e3f 100644 --- a/frontend/src/components/pages/MainPage.js +++ b/frontend/src/components/pages/MainPage.js @@ -15,20 +15,20 @@ * along with this program. If not, see . */ -import React, {Component} from 'react'; -import './MainPage.scss'; -import './common.scss'; -import Connections from "../panels/ConnectionsPane"; -import StreamsPane from "../panels/StreamsPane"; +import React, {Component} from "react"; import {BrowserRouter as Router, Route, Switch} from "react-router-dom"; -import Timeline from "../Timeline"; -import PcapsPane from "../panels/PcapsPane"; -import RulesPane from "../panels/RulesPane"; -import ServicesPane from "../panels/ServicesPane"; -import Header from "../Header"; import Filters from "../dialogs/Filters"; +import Header from "../Header"; +import Connections from "../panels/ConnectionsPane"; import MainPane from "../panels/MainPane"; +import PcapsPane from "../panels/PcapsPane"; +import RulesPane from "../panels/RulesPane"; import SearchPane from "../panels/SearchPane"; +import ServicesPane from "../panels/ServicesPane"; +import StreamsPane from "../panels/StreamsPane"; +import Timeline from "../Timeline"; +import "./common.scss"; +import "./MainPage.scss"; class MainPage extends Component { diff --git a/frontend/src/components/pages/ServiceUnavailablePage.js b/frontend/src/components/pages/ServiceUnavailablePage.js index f27d84d..deb4cf8 100644 --- a/frontend/src/components/pages/ServiceUnavailablePage.js +++ b/frontend/src/components/pages/ServiceUnavailablePage.js @@ -15,8 +15,8 @@ * along with this program. If not, see . */ -import React, {Component} from 'react'; -import './MainPage.scss'; +import React, {Component} from "react"; +import "./MainPage.scss"; class ServiceUnavailablePage extends Component { -- cgit v1.2.3-70-g09d2