diff options
author | Emiliano Ciavatta | 2020-10-16 17:06:05 +0000 |
---|---|---|
committer | Emiliano Ciavatta | 2020-10-16 17:06:05 +0000 |
commit | 56f70a72196c777f248038bb2e2e4099e6e1367d (patch) | |
tree | 714ad5aed8698dfffbb472b3fa74909acb8cdead /frontend/src/views/Header.js | |
parent | 6204c99e69d1707a79c5e56685b47310106c60b0 (diff) | |
parent | 79b8b2fa3e8563c986da8baa3a761f2d4f0c6f47 (diff) |
Merge branch 'develop'
Diffstat (limited to 'frontend/src/views/Header.js')
-rw-r--r-- | frontend/src/views/Header.js | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/frontend/src/views/Header.js b/frontend/src/views/Header.js deleted file mode 100644 index 944f1d5..0000000 --- a/frontend/src/views/Header.js +++ /dev/null @@ -1,92 +0,0 @@ -import React, {Component} from 'react'; -import Typed from 'typed.js'; -import './Header.scss'; -import {filtersDefinitions, filtersNames} from "../components/filters/FiltersDefinitions"; -import {Link} from "react-router-dom"; -import ButtonField from "../components/fields/ButtonField"; - -class Header extends Component { - - constructor(props) { - super(props); - let newState = {}; - filtersNames.forEach(elem => newState[`${elem}_active`] = false); - this.state = newState; - this.fetchStateFromLocalStorage = this.fetchStateFromLocalStorage.bind(this); - } - - componentDidMount() { - const options = { - strings: ["caronte$ "], - typeSpeed: 50, - cursorChar: "❚" - }; - this.typed = new Typed(this.el, options); - - this.fetchStateFromLocalStorage(); - - if (typeof window !== "undefined") { - window.addEventListener("quick-filters", this.fetchStateFromLocalStorage); - } - } - - componentWillUnmount() { - this.typed.destroy(); - - if (typeof window !== "undefined") { - window.removeEventListener("quick-filters", this.fetchStateFromLocalStorage); - } - } - - fetchStateFromLocalStorage() { - let newState = {}; - filtersNames.forEach(elem => newState[`${elem}_active`] = localStorage.getItem(`filters.${elem}`) === "true"); - this.setState(newState); - } - - render() { - let quickFilters = filtersNames.filter(name => this.state[`${name}_active`]) - .map(name => <React.Fragment key={name} >{filtersDefinitions[name]}</React.Fragment>) - .slice(0, 5); - - return ( - <header className="header container-fluid"> - <div className="row"> - <div className="col-auto"> - <h1 className="header-title type-wrap"> - <span style={{whiteSpace: 'pre'}} ref={(el) => { - this.el = el; - }}/> - </h1> - </div> - - <div className="col-auto"> - <div className="filters-bar"> - {quickFilters} - </div> - </div> - - <div className="col"> - <div className="header-buttons"> - <ButtonField variant="pink" onClick={this.props.onOpenFilters} name="filters" bordered /> - <Link to="/pcaps"> - <ButtonField variant="purple" name="pcaps" bordered /> - </Link> - <Link to="/rules"> - <ButtonField variant="deep-purple" name="rules" bordered /> - </Link> - <Link to="/services"> - <ButtonField variant="indigo" name="services" bordered /> - </Link> - <Link to="/config"> - <ButtonField variant="blue" name="config" bordered /> - </Link> - </div> - </div> - </div> - </header> - ); - } -} - -export default Header; |