From 0b3ffae0a3609f53828e17962b7788acc9eb2932 Mon Sep 17 00:00:00 2001 From: Ernst Widerberg Date: Thu, 21 Oct 2021 09:13:24 +0200 Subject: Switch semantic-ui to material-ui TODO: Login component --- src/components/App.js | 1 - src/components/Error.js | 14 +++-- src/components/List.js | 25 ++++----- src/components/SearchForm.js | 120 +++++++++++++++++++++++-------------------- src/index.html | 3 +- src/index.js | 9 +++- src/styles/main.css | 8 +-- 7 files changed, 100 insertions(+), 80 deletions(-) (limited to 'src') diff --git a/src/components/App.js b/src/components/App.js index 592a062..9ead9c5 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -6,7 +6,6 @@ import { Link, useParams } from "react-router-dom"; -import { Button } from "semantic-ui-react"; import Error from "./Error"; import Header from "./Header"; diff --git a/src/components/Error.js b/src/components/Error.js index 56cc09c..4d026bc 100644 --- a/src/components/Error.js +++ b/src/components/Error.js @@ -1,6 +1,9 @@ import React from "react"; import PropTypes from "prop-types"; -import { Button, Message } from "semantic-ui-react"; + +import Alert from "@mui/material/Alert"; +import AlertTitle from "@mui/material/AlertTitle"; +import Button from "@mui/material/Button"; class Error extends React.Component { static propTypes = { @@ -12,11 +15,12 @@ class Error extends React.Component { render() { return (
- - Internal server error + + Internal server error

{this.props.error}

-
+
); } diff --git a/src/components/List.js b/src/components/List.js index d5dcab4..69f2a50 100644 --- a/src/components/List.js +++ b/src/components/List.js @@ -1,5 +1,6 @@ import React from "react"; -import { Button, Pagination } from "semantic-ui-react"; + +import Pagination from "@mui/material/Pagination"; import ObjectComponent from "./ObjectComponent"; import SearchForm from "./SearchForm"; @@ -92,8 +93,9 @@ class List extends React.Component { ); } - setPage(e, { activePage: n }) { - this.setState({ page: n }, () => { + setPage(event, value) { + this.setState({ page: value }, () => { + console.log(this.state); this.getData(); window.scrollTo(0, 0); }); @@ -103,12 +105,7 @@ class List extends React.Component { return (
-
- - - - -
+
@@ -120,9 +117,13 @@ class List extends React.Component {
diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js index b3a09c0..1150dec 100644 --- a/src/components/SearchForm.js +++ b/src/components/SearchForm.js @@ -1,6 +1,14 @@ import React from "react"; import PropTypes from "prop-types"; -import { Button, Select, Input, Icon } from "semantic-ui-react"; + +import Button from "@mui/material/Button"; +import ClearIcon from "@mui/icons-material/Clear"; +import FormControl from "@mui/material/FormControl"; +import IconButton from "@mui/material/IconButton"; +import InputAdornment from "@mui/material/InputAdornment"; +import MenuItem from "@mui/material/MenuItem"; +import Select from "@mui/material/Select"; +import TextField from "@mui/material/TextField"; class SearchForm extends React.Component { static propTypes = { @@ -16,76 +24,74 @@ class SearchForm extends React.Component { }; this.clearSearch = this.clearSearch.bind(this); - this.handleInput = this.handleInput.bind(this); this.submitSearch = this.submitSearch.bind(this); } - handleInput(event, result) { - this.setState({ - [result.name]: result.value - }); - } - clearSearch(_) { this.setState({ value: "" }); this.props.filter(null, null); } - submitSearch(e) { - e.preventDefault(); - this.props.filter(this.state.field, this.state.value); + submitSearch() { + // e.preventDefault(); + if (this.state.value === "") this.clearSearch(); + else this.props.filter(this.state.field, this.state.value); } render() { - const searchOptions = [ - { - key: "port", - value: "port", - text: "Port" - }, - { - key: "domain", - value: "domain", - text: "Domain" - }, - { - key: "ip", - value: "ip", - text: "IP" - }, - { - key: "asn", - value: "asn", - text: "ASN" - }, - { - key: "asn_country_code", - value: "asn_country_code", - text: "ASN Country Code" - } - ]; return ( -
- + { + this.setState({ + value: event.target.value + }); + }} + onKeyDown={event => { + if (event.key === "Enter") this.submitSearch(); + if (event.key === "Escape") this.clearSearch(); + }} + placeholder="Search..." + InputProps={{ + endAdornment: ( + + + {this.state.value !== "" && } + + + ) + }} + sx={{ width: 400 }} + /> + +