Update: App.js & config.js
This commit is contained in:
parent
3433a467ad
commit
fc48ef7bde
@ -1,3 +1,5 @@
|
||||
var configs = {
|
||||
"aUrl": "https://localhost:8080"
|
||||
"authUrl": "https://{{base_url}}{{port_str}}",
|
||||
"back_endUrl": "https://spirisimbackend.{{base_url}}{{port_str}}",
|
||||
"front_endUrl": "https://sim.{{base_url}}{{port_str}}/"
|
||||
};
|
@ -30,10 +30,9 @@ class App extends Component{
|
||||
console.log(cookies);
|
||||
this.state.csrfToken = cookies.get('XSRF-TOKEN');
|
||||
console.log(this.state.csrfToken);
|
||||
|
||||
this.status = "local"
|
||||
this.ip = window.configs.aUrl;
|
||||
|
||||
this.backendip = window.configs.back_endUrl;
|
||||
this.frontendip = window.configs.front_endUrl;
|
||||
this.authip = window.configs.authUrl;
|
||||
this.simulatorWindow = null;
|
||||
this.shellWindow = null;
|
||||
this.routeLogin = this.routeLogin.bind(this);
|
||||
@ -42,7 +41,7 @@ class App extends Component{
|
||||
this.routeMain =this.routeMain.bind(this);
|
||||
this.submit = this.submit.bind(this);
|
||||
this.getSimulator = this.settingsSimulator.bind(this);
|
||||
this.launchSimulator = this.launchSimulator.bind(this);
|
||||
|
||||
this.handleUrl = this.handleUrl.bind(this);
|
||||
this.attach = this.attach.bind(this);
|
||||
this.heartbeat = this.heartbeat.bind(this);
|
||||
@ -51,7 +50,7 @@ class App extends Component{
|
||||
|
||||
async componentDidMount() {
|
||||
console.log(this.state.backend_url)
|
||||
const response = await fetch(`${this.ip}/api/user`, {credentials: 'include'});
|
||||
const response = await fetch(`${this.backendip}/api/user`, {credentials: 'include'});
|
||||
console.log(response.ok);
|
||||
const body = await response.text();
|
||||
if (body === '') {
|
||||
@ -70,7 +69,7 @@ class App extends Component{
|
||||
|
||||
login() {
|
||||
console.log(window.location)
|
||||
window.location.href = `${this.ip}/task/list`;
|
||||
window.location.href = `${this.backendip}/task/list`;
|
||||
}
|
||||
wait(ms){
|
||||
var start = new Date().getTime();
|
||||
@ -86,7 +85,7 @@ class App extends Component{
|
||||
}
|
||||
|
||||
async logout() {
|
||||
fetch(`http://localhost:8080/api/logout`,
|
||||
fetch(`${this.backendip}/api/logout`,
|
||||
{
|
||||
method : 'GET',
|
||||
mode: 'no-cors',
|
||||
@ -112,11 +111,11 @@ class App extends Component{
|
||||
console.log(this.state.isAuthenticated);
|
||||
})
|
||||
.then(reponse => {
|
||||
window.location.href = "https://localhost:8433/openid/end-session";
|
||||
window.location.href = this.authip;
|
||||
})
|
||||
.then(reponse => {
|
||||
this.wait(3000);
|
||||
window.location.href = "http://localhost:3006/";
|
||||
window.location.href = this.frontendip;
|
||||
});
|
||||
}
|
||||
|
||||
@ -143,7 +142,7 @@ class App extends Component{
|
||||
}
|
||||
|
||||
async heartbeat(){
|
||||
fetch(`http://${this.ip}/simulator/logheartbeat/${this.state.user.sub}`, {credentials: 'include'})
|
||||
fetch(`http://${this.backendip}/simulator/logheartbeat/${this.state.user.sub}`, {credentials: 'include'})
|
||||
.then((response) => response.json())
|
||||
.then((responseData) =>
|
||||
{
|
||||
@ -153,16 +152,8 @@ class App extends Component{
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
launchSimulator(urlAction) {
|
||||
//launchSimulator() {
|
||||
this.url = urlAction;
|
||||
//const url = "http://localhost";
|
||||
|
||||
window.location.href = "/simulator";
|
||||
//this.simulatorWindow = window.open(url + ":8888", '_blank');
|
||||
//this.shellWindow = window.open(url + ":4200", '_self');
|
||||
|
||||
}
|
||||
|
||||
|
||||
handleUrl = (urlValue) => {
|
||||
this.setState({url: urlValue});
|
||||
}
|
||||
@ -173,7 +164,7 @@ class App extends Component{
|
||||
|
||||
// TODO : detach the heartbeat
|
||||
|
||||
httpClient.get(`http://${this.ip}/simulator/stop/${this.state.user.sub}`, { withCredentials: true })
|
||||
httpClient.get(`http://${this.backendip}/simulator/stop/${this.state.user.sub}`, { withCredentials: true })
|
||||
.then(res => {
|
||||
this.setState({launch: false});
|
||||
})
|
||||
@ -185,7 +176,7 @@ class App extends Component{
|
||||
const httpClient = axios.create();
|
||||
httpClient.defaults.timeout = 600000;
|
||||
|
||||
httpClient.get(`http://${this.ip}/simulator/start/${this.state.user.sub}/${this.state.user.given_name}/spiri-friend2019@`, { withCredentials: true })
|
||||
httpClient.get(`http://${this.backendip}/simulator/start/${this.state.user.sub}/${this.state.user.given_name}/spiri-friend2019@`, { withCredentials: true })
|
||||
.then(res => {
|
||||
this.setState({simulator: res.data, isLoading: false, url: this.state.simulator.publicIp });
|
||||
this.launchSimulator(this.state.simulator.publicIp);
|
||||
|
Loading…
Reference in New Issue
Block a user