From 9e4c76d450bb7a69fc6958c48e88efcd68b8f26e Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Tue, 7 Dec 2021 15:06:08 +0100 Subject: [PATCH] Login with scenario duplication --- src/common/api/rest-api.js | 7 ++++--- src/styles/app.css | 1 + src/user/login-complete.js | 16 +++++++++++++--- src/user/users-data-manager.js | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/common/api/rest-api.js b/src/common/api/rest-api.js index 9de124e..a43cb9f 100644 --- a/src/common/api/rest-api.js +++ b/src/common/api/rest-api.js @@ -70,18 +70,19 @@ class RestAPI { }); } - post(url, body, token) { + post(url, body, token, timeout = 5000) { 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) { req.set('Authorization', "Bearer " + token); } req.end(function (error, res) { + console.log("req.end in post request") if (res == null || res.status !== 200) { - error.handled = isNetworkError(error); + error.handled = isNetworkError(error, url); reject(error); } else { diff --git a/src/styles/app.css b/src/styles/app.css index e4d477b..a7cfdaa 100644 --- a/src/styles/app.css +++ b/src/styles/app.css @@ -127,6 +127,7 @@ a:active { .verticalhorizontal { display: flex; + flex-direction: column; justify-content: center; align-items: center; height: 800px; diff --git a/src/user/login-complete.js b/src/user/login-complete.js index aef0c2d..3e6454b 100644 --- a/src/user/login-complete.js +++ b/src/user/login-complete.js @@ -35,7 +35,7 @@ class LoginComplete extends React.Component { loginMessage: '', token: '', currentUser: '', - secondsToWait: 99, + secondsToWait: 65, } this.timer = 0; @@ -46,7 +46,6 @@ class LoginComplete extends React.Component { componentDidMount() { this.startTimer(); - this.setState({secondsToWait: 20}); } static getStores(){ @@ -86,6 +85,16 @@ class LoginComplete extends React.Component { } 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 !== "") { this.stopTimer(); return (); @@ -98,7 +107,8 @@ class LoginComplete extends React.Component { Waiting Dog + alt="Logging in.." /> +

{waitingMsg}

; } } diff --git a/src/user/users-data-manager.js b/src/user/users-data-manager.js index 17c4cd4..05e998c 100644 --- a/src/user/users-data-manager.js +++ b/src/user/users-data-manager.js @@ -39,7 +39,7 @@ class UsersDataManager extends RestDataManager { }); }); } 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); AppDispatcher.dispatch({ type: 'users/logged-in',