mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-21 13:23:04 +01:00
Added in navbar and settings route
This commit is contained in:
2
resources/js/components/Home/HomePage.js
vendored
2
resources/js/components/Home/HomePage.js
vendored
@@ -8,12 +8,14 @@ import TestsTable from '../Graphics/TestsTable';
|
|||||||
import Settings from '../Settings/Settings';
|
import Settings from '../Settings/Settings';
|
||||||
import Login from '../Login';
|
import Login from '../Login';
|
||||||
import Authentication from '../Authentication/Authentication';
|
import Authentication from '../Authentication/Authentication';
|
||||||
|
import Navbar from '../Navbar';
|
||||||
|
|
||||||
export default class HomePage extends Component {
|
export default class HomePage extends Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
<Navbar />
|
||||||
<div className="my-4">
|
<div className="my-4">
|
||||||
{(window.config.auth == true && window.authenticated == false) &&
|
{(window.config.auth == true && window.authenticated == false) &&
|
||||||
<Login />
|
<Login />
|
||||||
|
|||||||
52
resources/js/components/Navbar.js
vendored
52
resources/js/components/Navbar.js
vendored
@@ -1,19 +1,65 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import {Nav, Navbar as BootstrapNavbar, NavLink as BootstrapNavLink} from 'react-bootstrap';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
|
import { Link, NavLink } from 'react-router-dom';
|
||||||
|
|
||||||
export default class Navbar extends Component {
|
export default class Navbar extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
brand: {
|
||||||
|
name: "Speedtest Tracker",
|
||||||
|
url: window.config.base
|
||||||
|
},
|
||||||
|
pages: [
|
||||||
|
{
|
||||||
|
name: 'Home',
|
||||||
|
url: window.config.base,
|
||||||
|
authRequired: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Settings',
|
||||||
|
url: window.config.base + 'settings',
|
||||||
|
authRequired: true
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
generateLinks = () => {
|
||||||
|
return this.state.pages.map(page => {
|
||||||
|
if(
|
||||||
|
page.authRequired === false ||
|
||||||
|
(
|
||||||
|
page.authRequired === true &&
|
||||||
|
window.config.auth &&
|
||||||
|
window.authenticated
|
||||||
|
) ||
|
||||||
|
(
|
||||||
|
page.authRequired === true &&
|
||||||
|
window.config.auth === false
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return <BootstrapNavLink key={page.url} as={NavLink} to={page.url}>{page.name}</BootstrapNavLink>;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
var brand = this.state.brand;
|
||||||
|
var pages = this.generateLinks();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<BootstrapNavbar variant="dark" bg="dark">
|
||||||
</div>
|
<BootstrapNavbar.Brand as={Link} to={brand.url}>{brand.name}</BootstrapNavbar.Brand>
|
||||||
|
<BootstrapNavbar.Toggle aria-controls="basic-navbar-nav" />
|
||||||
|
<BootstrapNavbar.Collapse id="basic-navbar-nav">
|
||||||
|
<Nav className="ml-auto">
|
||||||
|
{pages}
|
||||||
|
</Nav>
|
||||||
|
</BootstrapNavbar.Collapse>
|
||||||
|
</BootstrapNavbar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
resources/js/components/Settings/SettingsIndex.js
vendored
Normal file
25
resources/js/components/Settings/SettingsIndex.js
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import ReactDOM from 'react-dom';
|
||||||
|
import Navbar from '../Navbar';
|
||||||
|
|
||||||
|
export default class SettingsIndex extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Navbar />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.getElementById('settingsIndex')) {
|
||||||
|
ReactDOM.render(<SettingsIndex />, document.getElementById('settingsIndex'));
|
||||||
|
}
|
||||||
7
resources/js/index.js
vendored
7
resources/js/index.js
vendored
@@ -8,6 +8,7 @@ import { ToastContainer } from 'react-toastify';
|
|||||||
import 'react-toastify/dist/ReactToastify.css';
|
import 'react-toastify/dist/ReactToastify.css';
|
||||||
import HomePage from './components/Home/HomePage';
|
import HomePage from './components/Home/HomePage';
|
||||||
import Cookies from 'js-cookie';
|
import Cookies from 'js-cookie';
|
||||||
|
import SettingsIndex from './components/Settings/SettingsIndex';
|
||||||
|
|
||||||
export default class Index extends Component {
|
export default class Index extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -84,6 +85,12 @@ export default class Index extends Component {
|
|||||||
<HomePage />
|
<HomePage />
|
||||||
</div>
|
</div>
|
||||||
)} />
|
)} />
|
||||||
|
<Route exact path={window.config.base + 'settings'} render={(props) => (
|
||||||
|
<div>
|
||||||
|
<SettingsIndex />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
)} />
|
||||||
<Route exact path={window.config.base + "error/:code"} render={(props) => ( <ErrorPage code={props.match.params.code} /> )} />
|
<Route exact path={window.config.base + "error/:code"} render={(props) => ( <ErrorPage code={props.match.params.code} /> )} />
|
||||||
<Route render={(props) => (<ErrorPage code="404" />)} />
|
<Route render={(props) => (<ErrorPage code="404" />)} />
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|||||||
Reference in New Issue
Block a user