Update: App.js without backend code

This commit is contained in:
Riddhi Dave 2021-02-19 12:04:52 -05:00
parent 0748ea1b0a
commit d6150dc24b
1 changed files with 20 additions and 18 deletions

View File

@ -44,13 +44,13 @@ class App extends Component{
this.handleUrl = this.handleUrl.bind(this);
this.attach = this.attach.bind(this);
this.heartbeat = this.heartbeat.bind(this);
//this.heartbeat = this.heartbeat.bind(this);
this.wait = this.wait.bind(this);
}
async componentDidMount() {
console.log(this.state.backend_url)
const response = await fetch(`${this.backendip}/api/user`, {credentials: 'include'});
const response = await fetch(`${this.authip}`);
console.log(response.ok);
const body = await response.text();
if (body === '') {
@ -69,7 +69,8 @@ class App extends Component{
login() {
console.log(window.location)
window.location.href = `${this.backendip}/task/list`;
window.location.href = `${this.authip}/login`;
}
wait(ms){
var start = new Date().getTime();
@ -85,16 +86,17 @@ class App extends Component{
}
async logout() {
fetch(`${this.backendip}/api/logout`,
{
method : 'GET',
mode: 'no-cors',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
})
.then((response) => response)
fetch(`${this.authip}/logout`,
//{
//method : 'GET',
//mode: 'no-cors',
// credentials: 'include',
//headers: {
//'Content-Type': 'application/json'
//},
//}
)
/*.then((response) => response)
.then((json) => {
console.log('Gotcha');
console.log(json.status === 204);
@ -109,7 +111,7 @@ class App extends Component{
this.routeMain();
}
console.log(this.state.isAuthenticated);
})
})*/
.then(reponse => {
window.location.href = this.authip;
})
@ -141,7 +143,7 @@ class App extends Component{
this.timer = setInterval(()=> this.heartbeat(), 10000);
}
async heartbeat(){
/*async heartbeat(){
fetch(`http://${this.backendip}/simulator/logheartbeat/${this.state.user.sub}`, {credentials: 'include'})
.then((response) => response.json())
.then((responseData) =>
@ -151,7 +153,7 @@ class App extends Component{
.catch((error) => {
console.error(error);
});
}
}*/
handleUrl = (urlValue) => {
@ -218,8 +220,8 @@ class App extends Component{
const launch_ = this.state.launch ?
<div>
<div id="sim">
<iframe name="top_" src={'http://'+ this.state.url +':4200'} width="100%" height="375px" frameBorder="0"></iframe>
<iframe name="bottom_" src={'http://'+ this.state.url +':8888'} width="100%" height="375px" frameBorder="0"></iframe>
<iframe name="top_" src={'https://'+ '3.238.9.151' +':4200'} width="100%" height="375px" frameBorder="0"></iframe>
<iframe name="bottom_" src={'https://'+ '3.238.9.151' +':8888'} width="100%" height="375px" frameBorder="0"></iframe>
</div>
</div>:
<div class="SpiriImage">