mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-30 00:00:13 +01:00
Login with scenario duplication
This commit is contained in:
parent
b7d089af22
commit
9e4c76d450
4 changed files with 19 additions and 7 deletions
|
@ -70,18 +70,19 @@ class RestAPI {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
post(url, body, token) {
|
post(url, body, token, timeout = 5000) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
let req = request.post(url).send(body).timeout({ response: 5000 }); // Simple response start timeout (3s)
|
let req = request.post(url).send(body).timeout({ response: timeout }); // Simple response start timeout
|
||||||
|
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
req.set('Authorization', "Bearer " + token);
|
req.set('Authorization', "Bearer " + token);
|
||||||
}
|
}
|
||||||
|
|
||||||
req.end(function (error, res) {
|
req.end(function (error, res) {
|
||||||
|
console.log("req.end in post request")
|
||||||
if (res == null || res.status !== 200) {
|
if (res == null || res.status !== 200) {
|
||||||
|
|
||||||
error.handled = isNetworkError(error);
|
error.handled = isNetworkError(error, url);
|
||||||
|
|
||||||
reject(error);
|
reject(error);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -127,6 +127,7 @@ a:active {
|
||||||
|
|
||||||
.verticalhorizontal {
|
.verticalhorizontal {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 800px;
|
height: 800px;
|
||||||
|
|
|
@ -35,7 +35,7 @@ class LoginComplete extends React.Component {
|
||||||
loginMessage: '',
|
loginMessage: '',
|
||||||
token: '',
|
token: '',
|
||||||
currentUser: '',
|
currentUser: '',
|
||||||
secondsToWait: 99,
|
secondsToWait: 65,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.timer = 0;
|
this.timer = 0;
|
||||||
|
@ -46,7 +46,6 @@ class LoginComplete extends React.Component {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.startTimer();
|
this.startTimer();
|
||||||
this.setState({secondsToWait: 20});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static getStores(){
|
static getStores(){
|
||||||
|
@ -86,6 +85,16 @@ class LoginComplete extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let waitingMsg = "Please wait"
|
||||||
|
if (this.state.secondsToWait < 20) {
|
||||||
|
waitingMsg = "Almost there .."
|
||||||
|
} else if (this.state.secondsToWait < 45) {
|
||||||
|
waitingMsg = "..."
|
||||||
|
} else if (this.state.secondsToWait < 55) {
|
||||||
|
waitingMsg = "Configuring Simulators .."
|
||||||
|
} else if (this.state.secondsToWait < 60) {
|
||||||
|
waitingMsg = "Loading Scenarios .."
|
||||||
|
}
|
||||||
if (this.state.currentUser && this.state.currentUser !== "") {
|
if (this.state.currentUser && this.state.currentUser !== "") {
|
||||||
this.stopTimer();
|
this.stopTimer();
|
||||||
return (<Redirect to="/home" />);
|
return (<Redirect to="/home" />);
|
||||||
|
@ -98,7 +107,8 @@ class LoginComplete extends React.Component {
|
||||||
<img
|
<img
|
||||||
style={{height: 80}}
|
style={{height: 80}}
|
||||||
src={require('../img/ajax-loader.gif').default}
|
src={require('../img/ajax-loader.gif').default}
|
||||||
alt="Waiting Dog" />
|
alt="Logging in.." />
|
||||||
|
<p>{waitingMsg}</p>
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class UsersDataManager extends RestDataManager {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else { // external authentication
|
} else { // external authentication
|
||||||
RestAPI.post(this.makeURL('/authenticate/external'),).then(response => {
|
RestAPI.post(this.makeURL('/authenticate/external'), null, null, 60000).then(response => {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
AppDispatcher.dispatch({
|
AppDispatcher.dispatch({
|
||||||
type: 'users/logged-in',
|
type: 'users/logged-in',
|
||||||
|
|
Loading…
Add table
Reference in a new issue