diff --git a/src/app/App.js b/src/app/App.js index 6fe528b..d4e2a0f 100644 --- a/src/app/App.js +++ b/src/app/App.js @@ -6,43 +6,64 @@ import './App.css'; class App extends Component { constructor(props) { - super(props); + super(props); this.state = {frameworks: this.props.frameworkImages, - disableAllButton: false}; - this.loadingGif = "https://loading.io/spinners/double-ring/lg.double-ring-spinner.gif"; - this.click = this.click.bind(this); - this.api = window.location.protocol+"//"+window.location.href.split('/')[2] + disableAllButtons: false, + ui_url: null, + cid: null}; + this.loadingGif = "https://loading.io/spinners/double-ring/lg.double-ring-spinner.gif"; + this.select = this.select.bind(this); + this.confirm = this.confirm.bind(this); + this.api = window.location.protocol+"//"+window.location.href.split('/')[2]; } - click(f) { - var updatedFramework = this.state.frameworks - var type = typeof updatedFramework; - console.log(type); + select(f) { + var updatedFramework = this.state.frameworks; var index = updatedFramework.indexOf(f); updatedFramework[index].loading = true; - this.setState({framework:updatedFramework, disableAllButton:true}) + this.setState({framework:updatedFramework, disableAllButtons:true}); + + fetch('http://localhost:5656/create_container', { + //fetch(this.api + '/create_container', { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify(f) + }).then((resp) => resp.json()).then(data => { + var loadedFramework = this.state.frameworks; + loadedFramework[index].loaded = true; + console.log(data["cid"]); + this.setState({framework:loadedFramework, cid: data['cid'], ui_url: data['ui_url']}) + }); + } - fetch(this.api + '/create_container', { - method: 'POST', - headers: { + confirm() { + //fetch(this.api + '/confirm', { + fetch('http://localhost:5656/confirm', { + method: 'POST', + headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', - }, - body: JSON.stringify(f) - }).then((resp) => resp.json()).then(function(res){ - window.location = res['ui_url']; - }); - console.log(f) + }, + body: JSON.stringify({cid: this.state.cid}) + }).then((resp) => resp.json()).then(data => { + console.log(data); + if (data["verified"] == "confirmed") { + window.location = this.state.ui_url + } + }); + } render() { - console.log(this.state.disableAllButton); - return ( + return (