Fixed some todos and added the start of the dashboard

This commit is contained in:
2020-02-22 17:03:53 +01:00
parent 9dc003c9b0
commit 6ca0a99e78
12 changed files with 11010 additions and 14565 deletions
-1
View File
@@ -6,7 +6,6 @@ import Login from '../LoginComponent/Login';
import Dashboard from '../DashboardComponent/Dashboard';
export default class App extends React.Component {
render() {
return (
<Switch>
@@ -1,7 +1,40 @@
import React from 'react';
import DashboardView from '../../Views/DashboardView'
export default class Dashboard extends React.Component<{
history: any
}, {
dto: any
}> {
state!: {
dto: {
API_Link: string | null;
API_Token: string | null;
};
};
props: any;
constructor(props: any) {
super(props);
if (props.location.state.dto !== undefined) {
// If the state exists being routed from /, fill in Dashboard State.
this.state = { dto: props.location.state.dto };
} else if (localStorage.getItem("APILink") !== null &&
localStorage.getItem("AccessToken") !== null) {
// Check if localStorage has valid items, if this is the case, we can use those.
// Resolve issue with cold navigation to /dashboard.
this.state = {
dto: {
API_Link: localStorage.getItem("APILink"),
API_Token: localStorage.getItem("AccessToken")
}
}
} else {
// Route back to / if neither is the case.
this.props.history.push('/');
}
}
export default class Dashboard extends React.Component {
render () {
return (<h1> This is the dashboard, fuck yeah </h1>)
return (<DashboardView />)
}
}
+6 -14
View File
@@ -7,15 +7,14 @@ export default class Login extends React.Component<{
}, {
dto: any
}> {
props: any;
state: any;
// eslint-disable-next-line
constructor(props: any) {
super(props);
this.persistApiLink = this.persistApiLink.bind(this);
this.persistAccessToken = this.persistAccessToken.bind(this);
this.verifyLogin = this.verifyLogin.bind(this);
this.getApiLinkFromDTO = this.getApiLinkFromDTO.bind(this);
this.getApiTokenFromDTO = this.getApiTokenFromDTO.bind(this);
}
componentDidMount() {
@@ -30,17 +29,12 @@ export default class Login extends React.Component<{
console.log("API Token: " + this.state.dto.getApiToken());
localStorage.setItem("lastLoggedIn", new Date().toUTCString());
// eslint-disable-next-line
this.props.history.push('/dashboard');
this.props.history.push({
pathname: '/dashboard',
state: { dto: this.state.dto }
});
};
getApiLinkFromDTO(): string {
return this.state.dto.getApiLink();
}
getApiTokenFromDTO(): string {
return this.state.dto.getApiToken();
}
persistApiLink(e: any): void {
this.state.dto.setApiLink(e.target.value);
}
@@ -54,8 +48,6 @@ export default class Login extends React.Component<{
persistApiLink={this.persistApiLink}
persistAccessToken={this.persistAccessToken}
verifyLogin={this.verifyLogin}
getApiLinkFromDTO={this.getApiLinkFromDTO}
getApiTokenFromDTO={this.getApiTokenFromDTO}
/>);
}
}