Skip to content

Commit 2a69a8d

Browse files
authored
Merge pull request #135 from knoxfighter/fix-#123
fix #123
2 parents 4683e32 + c22fd4a commit 2a69a8d

File tree

3 files changed

+13
-223
lines changed

3 files changed

+13
-223
lines changed

ui/App/App.jsx

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React from 'react';
2-
import {Switch, Route} from 'react-router-dom';
2+
import {Switch, Route, withRouter} from 'react-router-dom';
33
import Header from './components/Header.jsx';
44
import Sidebar from './components/Sidebar.jsx';
55
import Footer from './components/Footer.jsx';
6-
import HiddenSidebar from './components/HiddenSidebar.jsx';
76
import Socket from '../socket.js';
87
import Index from "./components/Index";
98
import UsersContent from "./components/UsersContent";
@@ -38,14 +37,6 @@ class App extends React.Component {
3837

3938
componentDidMount() {
4039
this.checkLogin();
41-
// Wait 1 second before redirecting to login page
42-
setTimeout(() => {
43-
if (!this.state.loggedIn) {
44-
browserHistory.push("/login");
45-
}
46-
}, 1000);
47-
this.connectWebSocket();
48-
this.getFactorioVersion(); //Init serverStatus, so i know, which factorio-version is installed
4940
}
5041

5142
connectWebSocket() {
@@ -63,14 +54,23 @@ class App extends React.Component {
6354
checkLogin() {
6455
$.ajax({
6556
url: "/api/user/status",
57+
type: "GET",
6658
dataType: "json",
6759
success: (data) => {
6860
if (data.success === true) {
6961
this.setState({
7062
loggedIn: true,
7163
username: data.data.Username
7264
});
65+
66+
this.connectWebSocket();
67+
this.getFactorioVersion(); //Init serverStatus, so i know, which factorio-version is installed
68+
} else {
69+
this.props.history.push("/login");
7370
}
71+
},
72+
error: () => {
73+
this.props.history.push("/login");
7474
}
7575
})
7676
}
@@ -128,6 +128,7 @@ class App extends React.Component {
128128
url: "/api/server/facVersion",
129129
// dataType: "json",
130130
success: (data) => {
131+
console.log(data);
131132
this.setState({
132133
factorioVersion: data.data.base_mod_version
133134
});
@@ -184,13 +185,6 @@ class App extends React.Component {
184185
</Switch>
185186

186187
<Footer />
187-
188-
<HiddenSidebar
189-
serverStatus={this.state.serverStatus}
190-
username={this.state.username}
191-
loggedIn={this.state.loggedIn}
192-
checkLogin={this.checkLogin}
193-
/>
194188
</div>
195189
} else {
196190
resp = <div><p>Not Logged in</p></div>;
@@ -200,4 +194,4 @@ class App extends React.Component {
200194
}
201195
}
202196

203-
export default App
197+
export default withRouter(App);

ui/App/components/HiddenSidebar.jsx

Lines changed: 0 additions & 202 deletions
This file was deleted.

ui/App/components/LoginContent.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ class LoginContent extends React.Component {
77
this.loginUser = this.loginUser.bind(this);
88
}
99

10-
componentDidMount() {
11-
console.log(this.props);
12-
}
10+
componentDidMount() {}
1311

1412
loginUser(e) {
1513
e.preventDefault();

0 commit comments

Comments
 (0)