From 9a47e7a2e2100f0bb7ebfab11f7644d32b68241f Mon Sep 17 00:00:00 2001 From: therealbobo Date: Sun, 13 Sep 2020 00:51:39 +0200 Subject: initial commit --- frontend/src/views/Config.js | 226 +++++++++++++++++++++++++++++++++++++++++ frontend/src/views/Config.scss | 38 +++++++ 2 files changed, 264 insertions(+) create mode 100644 frontend/src/views/Config.js create mode 100644 frontend/src/views/Config.scss diff --git a/frontend/src/views/Config.js b/frontend/src/views/Config.js new file mode 100644 index 0000000..438e2d6 --- /dev/null +++ b/frontend/src/views/Config.js @@ -0,0 +1,226 @@ +import { + validateIpAddress, +} from "../utils"; +import React, {Component, useState} from 'react'; +import './Config.scss'; +import {Button, ButtonGroup, ToggleButton, Col, Container, Form, FormControl, InputGroup, Modal, Row, Table} from "react-bootstrap"; +import axios from 'axios' +import {createCurlCommand} from '../utils'; + +class Config extends Component { + + constructor(props) { + super(props); + + this.state = { + server_address: "", + flag_regex: "", + auth_required: false, + accounts: {}, + showSignup: false, + showConfig: true, + tmpUser:"", + tmpPass:"", + tmpConf:"" + }; + + this.serverIpChanged = this.serverIpChanged.bind(this); + this.flagRegexChanged = this.flagRegexChanged.bind(this); + this.authRequiredChanged = this.authRequiredChanged.bind(this); + this.userChanged = this.userChanged.bind(this); + this.passwdChanged = this.passwdChanged.bind(this); + this.confirmChanged = this.confirmChanged.bind(this); + } + + serverIpChanged(event) { + this.setState({server_address: event.target.value}); + } + + flagRegexChanged(event) { + this.setState({flag_regex: event.target.value}); + } + + authRequiredChanged() { + this.setState({auth_required: !this.value}); + this.checked = !this.checked; + this.value = !this.value; + } + + userChanged(event) { + this.setState({tmpUser: event.target.value}); + } + + passwdChanged(event) { + this.setState({tmpPass: event.target.value}); + } + + confirmChanged(event) { + this.setState({tmpConf: event.target.value}); + } + + setup() { + const requestOptions = { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + config: { + server_address: this.state.server_address, + flag_regex: this.state.flag_regex, + auth_required: this.state.auth_required, + }, + accounts: this.state.accounts + }) + }; + + + fetch('/setup', requestOptions) + .then(function(response){ + console.log(response.status); + console.log(response); + } + ); + + } + + signup(){ + if (this.state.tmpPass === this.state.tmpConf){ + const accounts = {...this.state.accounts}; + accounts[this.state.tmpUser] = this.state.tmpPass; + this.setState({accounts}); + console.log(this.state); + this.setState({showSignup:false,showConfig:true}) + } + this.setState({tmpUser : ""}); + this.setState({tmpPass : ""}); + this.setState({tmpConf : ""}); + } + + render() { + let rows = Object.keys(this.state.accounts).map(u => + + {u} + + ); + + + + return ( + <> + + + + # passwd + + + + + +
+ + username: + + + + + password: + + + + + confirm password: + + + + +
+ +
+ +
+
+ + + + + +
+ + + + ~/.config + + + + + + + + + this.authRequiredChanged()} + > + Authentication + + + + + + + + + + + + {rows} + + +
users
+ +
+ + + + + + + +
+ + server_address: + + + + + flag_regex: + + + +
+ + + +
+ +
+
+ + + + +
+ + ); + } +} + +export default Config; diff --git a/frontend/src/views/Config.scss b/frontend/src/views/Config.scss new file mode 100644 index 0000000..9946ce9 --- /dev/null +++ b/frontend/src/views/Config.scss @@ -0,0 +1,38 @@ +@import '../colors.scss'; + +.curl-output { + width: 100%; + font-size: 13px; +} + +#passwd-form { + margin:auto; +} + +.users-list { + .btn { + width: 70px; + } + + td { + background-color: $color-primary-2; + border-top: 2px solid $color-primary-0; + vertical-align: middle; + text-align: center; + } + + th { + background-color: $color-primary-1; + text-align: center; + } +} + +.btn-color { + border: 3px solid #fff; +} + +.dialog-footer { + .btn { + width: 80px; + } +} -- cgit v1.2.3-70-g09d2