{"ast":null,"code":"import _regeneratorRuntime from \"/home/riddhi/simulation/Gazebo_simulation-Frontend/node_modules/babel-preset-react-app/node_modules/@babel/runtime/regenerator\";\nimport _asyncToGenerator from \"/home/riddhi/simulation/Gazebo_simulation-Frontend/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/asyncToGenerator\";\nimport _classCallCheck from \"/home/riddhi/simulation/Gazebo_simulation-Frontend/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"/home/riddhi/simulation/Gazebo_simulation-Frontend/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/createClass\";\nimport _possibleConstructorReturn from \"/home/riddhi/simulation/Gazebo_simulation-Frontend/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn\";\nimport _getPrototypeOf from \"/home/riddhi/simulation/Gazebo_simulation-Frontend/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/getPrototypeOf\";\nimport _inherits from \"/home/riddhi/simulation/Gazebo_simulation-Frontend/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/inherits\";\nimport _assertThisInitialized from \"/home/riddhi/simulation/Gazebo_simulation-Frontend/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/assertThisInitialized\";\nvar _jsxFileName = \"/home/riddhi/simulation/Gazebo_simulation-Frontend/src/components/App.js\";\nimport React, { Component } from 'react';\nimport Navigationbar from './Navigationbar';\nimport Comp_image from './Comp_image';\nimport { Redirect, withRouter, Route, NavLink, Navbar, BrowserRouter as Router, Switch } from 'react-router-dom';\nimport './App.css';\nimport header from '../images/spiri_logo.jpg';\nimport logo from '../images/spiri.png'; // Tell Webpack this JS file uses this image\n\nimport { withCookies } from 'react-cookie';\nimport { confirmAlert } from 'react-confirm-alert'; // Import\n\nimport 'react-confirm-alert/src/react-confirm-alert.css'; // Import css\n\nimport axios from 'axios';\nimport LoadingOverlay from 'react-loading-overlay';\nimport { thisExpression } from '@babel/types'; //import { withAuth } from '@okta/okta-react';\n\nvar App = /*#__PURE__*/function (_Component) {\n _inherits(App, _Component);\n\n function App(props) {\n var _this;\n\n _classCallCheck(this, App);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(App).call(this, props));\n _this.state = {\n isLoading: false,\n isAuthenticated: false,\n user: undefined,\n launch: false,\n isNavbar: false\n };\n var cookies = props.cookies;\n console.log(cookies);\n _this.state.csrfToken = cookies.get('XSRF-TOKEN');\n console.log(_this.state.csrfToken);\n _this.local = \"localhost:8080\";\n _this.prod = \"174.138.41.124:8080\";\n _this.status = \"local\";\n\n if (_this.status === \"local\") {\n _this.ip = _this.local;\n }\n\n _this.yourOktaDomain = \"dev-125890.okta.com\";\n _this.simulatorWindow = null;\n _this.shellWindow = null;\n _this.routeLogin = _this.routeLogin.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.login = _this.login.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.logout = _this.logout.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.routeMain = _this.routeMain.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.submit = _this.submit.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.getSimulator = _this.settingsSimulator.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.launchSimulator = _this.launchSimulator.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.attach = _this.attach.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.heartbeat = _this.heartbeat.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n _this.wait = _this.wait.bind(_assertThisInitialized(_assertThisInitialized(_this)));\n return _this;\n }\n\n _createClass(App, [{\n key: \"componentDidMount\",\n value: function () {\n var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {\n var response, body;\n return _regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n console.log(\"hereeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\");\n _context.next = 3;\n return fetch(\"http://\".concat(this.ip, \"/api/user\"), {\n credentials: 'include'\n });\n\n case 3:\n response = _context.sent;\n console.log(response.ok);\n console.log(\"999999999999999999999999999999999999999\");\n _context.next = 8;\n return response.text();\n\n case 8:\n body = _context.sent;\n console.log(\"-----------------------\");\n console.log(response.ok);\n console.log(\"-----------------------\");\n\n if (body === '') {\n this.setState({\n isAuthenticated: false\n });\n } else {\n this.setState({\n isAuthenticated: true,\n user: JSON.parse(body)\n });\n }\n\n console.log(this.state.isAuthenticated);\n console.log(this.state.user);\n console.log(\"########################################\");\n console.log(this.state.isAuthenticated);\n\n case 17:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n\n function componentDidMount() {\n return _componentDidMount.apply(this, arguments);\n }\n\n return componentDidMount;\n }()\n }, {\n key: \"routeMain\",\n value: function routeMain() {\n var path = '/';\n this.props.history.push(path);\n }\n }, {\n key: \"login\",\n value: function login() {\n console.log(window.location);\n window.location.href = \"//\".concat(this.ip, \"/task/list\"); //window.location.href = `//${this.ip}/private`;\n }\n }, {\n key: \"wait\",\n value: function wait(ms) {\n var start = new Date().getTime();\n var end = start;\n\n while (end < start + ms) {\n end = new Date().getTime();\n }\n }\n }, {\n key: \"routeLogin\",\n value: function routeLogin() {\n var path = '/';\n this.props.history.push(path);\n } //http://174.138.41.124:8080/api/logout\n //https://${this.yourOktaDomain}/api/v1/users/${this.state.user.sub}/sessions\n\n }, {\n key: \"logout\",\n value: function () {\n var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {\n var _this2 = this;\n\n return _regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n //const proxyurl = `https://cors-anywhere.herokuapp.com/`;\n //const proxyurl = `https://arcane-beach-51923.herokuapp.com/`;\n //fetch(`https://${this.yourOktaDomain}/api/v1/users/${this.state.user.sub}/sessions`,\n fetch(\"https://\".concat(this.yourOktaDomain, \"/api/v1/sessions/me\"), {\n method: 'DELETE',\n //credentials: 'same-origin'\n credentials: 'include'\n }).then(function (response) {\n return response;\n }).then(function (json) {\n console.log('Gotcha');\n console.log(json.status === 204);\n console.log(json.status);\n console.log(_this2.state.isAuthenticated);\n\n if (json.status === 204) {\n _this2.state.isAuthenticated = false;\n\n _this2.routeMain();\n }\n\n if (json.status === 200) {\n _this2.state.isAuthenticated = false;\n\n _this2.routeMain();\n }\n\n console.log(_this2.state.isAuthenticated);\n }).then(function (reponse) {\n window.location.href = \"http://localhost:8080/api/logout\";\n }).then(function (reponse) {\n _this2.wait(3000);\n\n window.location.href = \"http://localhost:3000/\";\n }); //window.location.href = `http://localhost:8080/api/logout`;\n\n console.log(\"YYYYYYYYYYYYYYYYYYYYYYYYYY\");\n console.log(\"YYYYYYYYYYYYYYYYYYYYYYYYYY\");\n\n case 3:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, this);\n }));\n\n function logout() {\n return _logout.apply(this, arguments);\n }\n\n return logout;\n }()\n }, {\n key: \"submit\",\n value: function submit() {\n var _this3 = this;\n\n confirmAlert({\n title: 'Confirm to logout',\n message: 'Are you sure?',\n buttons: [{\n label: 'Yes',\n onClick: function onClick() {\n return _this3.logout();\n }\n }, {\n label: 'No',\n onClick: function onClick() {\n return _this3.routeMain();\n }\n }]\n });\n }\n }, {\n key: \"attach\",\n value: function attach() {\n var _this4 = this;\n\n this.timer = setInterval(function () {\n return _this4.heartbeat();\n }, 10000);\n }\n }, {\n key: \"heartbeat\",\n value: function () {\n var _heartbeat = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {\n return _regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n fetch(\"http://\".concat(this.ip, \"/simulator/logheartbeat/\").concat(this.state.user.sub), {\n credentials: 'include'\n }).then(function (response) {\n return response.json();\n }).then(function (responseData) {\n console.log(\"Heart Beating\");\n }).catch(function (error) {\n console.error(error);\n });\n\n case 1:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, this);\n }));\n\n function heartbeat() {\n return _heartbeat.apply(this, arguments);\n }\n\n return heartbeat;\n }()\n }, {\n key: \"launchSimulator\",\n value: function launchSimulator(urlAction) {\n //launchSimulator() {\n var url = urlAction; //const url = \"http://localhost\";\n\n window.location.href = \"http://localhost:3000/simulator\"; //this.simulatorWindow = window.open(url + \":8888\", '_blank');\n //this.shellWindow = window.open(url + \":4200\", '_self');\n }\n }, {\n key: \"settingsSimulator\",\n value: function settingsSimulator(launch) {\n var _this5 = this;\n\n if (launch) {\n var httpClient = axios.create();\n httpClient.defaults.timeout = 600000; // TODO : detach the heartbeat\n\n httpClient.get(\"http://\".concat(this.ip, \"/simulator/stop/\").concat(this.state.user.sub), {\n withCredentials: true\n }).then(function (res) {\n _this5.setState({\n launch: false\n });\n });\n } else {\n this.setState({\n isLoading: true,\n launch: true\n });\n this.attach(this.state.launch);\n\n var _httpClient = axios.create();\n\n _httpClient.defaults.timeout = 600000;\n\n _httpClient.get(\"http://\".concat(this.ip, \"/simulator/start/\").concat(this.state.user.sub, \"/\").concat(this.state.user.given_name, \"/spiri-friend2019@\"), {\n withCredentials: true\n }).then(function (res) {\n _this5.setState({\n simulator: res.data,\n isLoading: false\n });\n\n _this5.launchSimulator(_this5.state.simulator.publicIp);\n }); //this.launchSimulator();\n\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this6 = this;\n\n var options = this.state.isAuthenticated ? /*#__PURE__*/React.createElement(\"div\", {\n id: \"navbar\",\n class: \"navbar-collapse\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 220,\n columnNumber: 5\n }\n }, /*#__PURE__*/React.createElement(\"ul\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 221,\n columnNumber: 25\n }\n }, /*#__PURE__*/React.createElement(Navigationbar, {\n submit: this.submit,\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 222,\n columnNumber: 27\n }\n }))) : /*#__PURE__*/React.createElement(\"div\", {\n id: \"navbar\",\n class: \"navbar-collapse\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 230,\n columnNumber: 21\n }\n }, /*#__PURE__*/React.createElement(\"div\", {\n class: \"SpiriHeader\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 231,\n columnNumber: 21\n }\n }, /*#__PURE__*/React.createElement(\"a\", {\n class: \"Brand\",\n href: \"/\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 232,\n columnNumber: 35\n }\n }, /*#__PURE__*/React.createElement(\"img\", {\n align: \"left\",\n src: header,\n width: '70cm',\n height: '70cm',\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 233,\n columnNumber: 37\n }\n }))), /*#__PURE__*/React.createElement(\"ul\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 236,\n columnNumber: 21\n }\n }, /*#__PURE__*/React.createElement(\"li\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 237,\n columnNumber: 23\n }\n }, /*#__PURE__*/React.createElement(NavLink, {\n style: {\n textDecoration: 'none'\n },\n onClick: this.login,\n class: \"login\",\n to: \"\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 238,\n columnNumber: 27\n }\n }, \"Login\"))));\n var simulator = this.state.isAuthenticated ? /*#__PURE__*/React.createElement(\"div\", {\n class: \"SimulatorButton\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 248,\n columnNumber: 15\n }\n }, /*#__PURE__*/React.createElement(\"button\", {\n className: \"SimulatorButton\",\n onClick: function onClick() {\n _this6.settingsSimulator(_this6.state.launch);\n },\n disabled: this.state.isLoading,\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 250,\n columnNumber: 17\n }\n }, this.state.isLoading && /*#__PURE__*/React.createElement(\"i\", {\n className: \"fa fa-refresh fa-spin\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 253,\n columnNumber: 48\n }\n }), !this.state.launch && /*#__PURE__*/React.createElement(\"span\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 254,\n columnNumber: 46\n }\n }, \" Launch Simulator \"), this.state.launch && /*#__PURE__*/React.createElement(\"span\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 255,\n columnNumber: 45\n }\n }, \" Stop Simulator \"))) : null;\n var mainBody = /*#__PURE__*/React.createElement(\"div\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 261,\n columnNumber: 24\n }\n }, options, simulator, /*#__PURE__*/React.createElement(\"div\", {\n class: \"SpiriImage\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 265,\n columnNumber: 9\n }\n }, /*#__PURE__*/React.createElement(\"img\", {\n src: logo,\n width: '1000cm',\n height: '563cm',\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 266,\n columnNumber: 13\n }\n })), /*#__PURE__*/React.createElement(\"div\", {\n className: \"Text\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 268,\n columnNumber: 9\n }\n }, /*#__PURE__*/React.createElement(Comp_image, {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 269,\n columnNumber: 13\n }\n })), /*#__PURE__*/React.createElement(\"footer\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 271,\n columnNumber: 9\n }\n }));\n return /*#__PURE__*/React.createElement(\"div\", {\n className: \"App\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 278,\n columnNumber: 9\n }\n }, mainBody);\n }\n }]);\n\n return App;\n}(Component);\n\nexport default withRouter(withCookies(App));","map":{"version":3,"sources":["/home/riddhi/simulation/Gazebo_simulation-Frontend/src/components/App.js"],"names":["React","Component","Navigationbar","Comp_image","Redirect","withRouter","Route","NavLink","Navbar","BrowserRouter","Router","Switch","header","logo","withCookies","confirmAlert","axios","LoadingOverlay","thisExpression","App","props","state","isLoading","isAuthenticated","user","undefined","launch","isNavbar","cookies","console","log","csrfToken","get","local","prod","status","ip","yourOktaDomain","simulatorWindow","shellWindow","routeLogin","bind","login","logout","routeMain","submit","getSimulator","settingsSimulator","launchSimulator","attach","heartbeat","wait","fetch","credentials","response","ok","text","body","setState","JSON","parse","path","history","push","window","location","href","ms","start","Date","getTime","end","method","then","json","reponse","title","message","buttons","label","onClick","timer","setInterval","sub","responseData","catch","error","urlAction","url","httpClient","create","defaults","timeout","withCredentials","res","given_name","simulator","data","publicIp","options","textDecoration","mainBody"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,OAAOC,aAAP,MAA2B,iBAA3B;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,SAASC,QAAT,EAAmBC,UAAnB,EAA+BC,KAA/B,EAAsCC,OAAtC,EAA+CC,MAA/C,EAAuDC,aAAa,IAAIC,MAAxE,EAAgFC,MAAhF,QAAiG,kBAAjG;AACA,OAAO,WAAP;AACA,OAAOC,MAAP,MAAmB,0BAAnB;AACA,OAAOC,IAAP,MAAiB,qBAAjB,C,CAAuC;;AACvC,SAASC,WAAT,QAA4B,cAA5B;AACA,SAASC,YAAT,QAA6B,qBAA7B,C,CAAoD;;AACpD,OAAO,iDAAP,C,CAA0D;;AAC1D,OAAOC,KAAP,MAAkB,OAAlB;AACA,OAAOC,cAAP,MAA2B,uBAA3B;AACA,SAASC,cAAT,QAA+B,cAA/B,C,CACA;;IAGMC,G;;;AASJ,eAAYC,KAAZ,EAAkB;AAAA;;AAAA;;AAChB,6EAAMA,KAAN;AADgB,UARlBC,KAQkB,GARV;AACNC,MAAAA,SAAS,EAAE,KADL;AAENC,MAAAA,eAAe,EAAE,KAFX;AAGNC,MAAAA,IAAI,EAAEC,SAHA;AAINC,MAAAA,MAAM,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A;AAAA;AAAA;AAAA;AAAA;AAAA,sBACI;AAAK,QAAA,GAAG,EAAEnF,IAAV;AAAgB,QAAA,KAAK,EAAE,QAAvB;AAAiC,QAAA,MAAM,EAAE,OAAzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QADJ,CAJe,eAOf;AAAK,QAAA,SAAS,EAAC,MAAf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBACI,oBAAC,UAAD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QADJ,CAPe,eAUf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAVe,CAAjB;AAeA,0BAEE;AAAK,QAAA,SAAS,EAAC,KAAf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAGIwF,QAHJ,CAFF;AAUH;;;;EA7QepG,S;;AA+QlB,eAAeI,UAAU,CAACS,WAAW,CAACK,GAAD,CAAZ,CAAzB","sourcesContent":["import React, { Component } from 'react';\nimport Navigationbar from './Navigationbar';\nimport Comp_image from './Comp_image';\nimport { Redirect, withRouter, Route, NavLink, Navbar, BrowserRouter as Router, Switch } from 'react-router-dom'\nimport './App.css';\nimport header from '../images/spiri_logo.jpg';\nimport logo from '../images/spiri.png';// Tell Webpack this JS file uses this image\nimport { withCookies } from 'react-cookie';\nimport { confirmAlert } from 'react-confirm-alert'; // Import\nimport 'react-confirm-alert/src/react-confirm-alert.css'; // Import css\nimport axios from 'axios';\nimport LoadingOverlay from 'react-loading-overlay';\nimport { thisExpression } from '@babel/types';\n//import { withAuth } from '@okta/okta-react';\n\n\nclass App extends Component{\n state = {\n isLoading: false,\n isAuthenticated: false,\n user: undefined,\n launch: false,\n isNavbar: false\n };\n\n constructor(props){\n super(props);\n const {cookies} = props;\n console.log(cookies);\n this.state.csrfToken = cookies.get('XSRF-TOKEN');\n console.log(this.state.csrfToken);\n this.local = \"localhost:8080\";\n this.prod = \"174.138.41.124:8080\";\n this.status = \"local\"\n if (this.status === \"local\") {\n this.ip = this.local;\n }\n this.yourOktaDomain = \"dev-125890.okta.com\";\n this.simulatorWindow = null;\n this.shellWindow = null;\n this.routeLogin = this.routeLogin.bind(this);\n this.login = this.login.bind(this);\n this.logout = this.logout.bind(this);\n this.routeMain =this.routeMain.bind(this);\n this.submit = this.submit.bind(this);\n this.getSimulator = this.settingsSimulator.bind(this);\n this.launchSimulator = this.launchSimulator.bind(this);\n this.attach = this.attach.bind(this);\n this.heartbeat = this.heartbeat.bind(this);\n this.wait = this.wait.bind(this);\n }\n\n async componentDidMount() {\n console.log(\"hereeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\");\n const response = await fetch(`http://${this.ip}/api/user`, {credentials: 'include'});\n console.log(response.ok);\n console.log(\"999999999999999999999999999999999999999\");\n const body = await response.text();\n console.log(\"-----------------------\");\n console.log(response.ok)\n console.log(\"-----------------------\");\n if (body === '') {\n this.setState(({isAuthenticated: false}))\n } else {\n this.setState({isAuthenticated: true, user: JSON.parse(body)})\n }\n console.log(this.state.isAuthenticated);\n \n console.log(this.state.user);\n console.log(\"########################################\");\n console.log(this.state.isAuthenticated);\n }\n\n routeMain() {\n let path = '/';\n this.props.history.push(path);\n }\n\n login() {\n console.log(window.location)\n window.location.href = `//${this.ip}/task/list`;\n //window.location.href = `//${this.ip}/private`;\n }\n wait(ms){\n var start = new Date().getTime();\n var end = start;\n while(end < start + ms) {\n end = new Date().getTime();\n }\n }\n\n routeLogin() {\n let path = '/';\n this.props.history.push(path);\n }\n\n //http://174.138.41.124:8080/api/logout\n //https://${this.yourOktaDomain}/api/v1/users/${this.state.user.sub}/sessions\n \n async logout() { \n //const proxyurl = `https://cors-anywhere.herokuapp.com/`;\n //const proxyurl = `https://arcane-beach-51923.herokuapp.com/`;\n \n //fetch(`https://${this.yourOktaDomain}/api/v1/users/${this.state.user.sub}/sessions`,\n fetch(`https://${this.yourOktaDomain}/api/v1/sessions/me`,\n {\n method : 'DELETE',\n //credentials: 'same-origin'\n credentials: 'include',\n })\n .then((response) => response) \n .then((json) => {\n console.log('Gotcha');\n console.log(json.status === 204);\n console.log(json.status);\n console.log(this.state.isAuthenticated);\n if (json.status === 204) {\n this.state.isAuthenticated = false;\n this.routeMain();\n }\n if (json.status === 200) {\n this.state.isAuthenticated = false;\n this.routeMain();\n }\n console.log(this.state.isAuthenticated);\n })\n .then(reponse => {\n window.location.href = \"http://localhost:8080/api/logout\";\n })\n .then(reponse => {\n this.wait(3000);\n window.location.href = \"http://localhost:3000/\";\n });\n\n \n\n //window.location.href = `http://localhost:8080/api/logout`;\n \n console.log(\"YYYYYYYYYYYYYYYYYYYYYYYYYY\");\n console.log(\"YYYYYYYYYYYYYYYYYYYYYYYYYY\");\n }\n\n submit() {\n confirmAlert({\n title: 'Confirm to logout',\n message: 'Are you sure?',\n buttons: [\n {\n label: 'Yes',\n onClick: () => this.logout()\n },\n {\n label: 'No',\n onClick: () => this.routeMain()\n }\n ]\n });\n };\n\n \n attach() {\n this.timer = setInterval(()=> this.heartbeat(), 10000);\n }\n \n async heartbeat(){\n fetch(`http://${this.ip}/simulator/logheartbeat/${this.state.user.sub}`, {credentials: 'include'})\n .then((response) => response.json())\n .then((responseData) =>\n {\n \n console.log(\"Heart Beating\")\n })\n .catch((error) => {\n console.error(error);\n });\n }\n\n launchSimulator(urlAction) {\n //launchSimulator() {\n const url = urlAction;\n //const url = \"http://localhost\";\n window.location.href = \"http://localhost:3000/simulator\";\n //this.simulatorWindow = window.open(url + \":8888\", '_blank');\n //this.shellWindow = window.open(url + \":4200\", '_self');\n }\n\n settingsSimulator(launch) {\n if (launch){\n const httpClient = axios.create();\n httpClient.defaults.timeout = 600000;\n \n // TODO : detach the heartbeat\n \n httpClient.get(`http://${this.ip}/simulator/stop/${this.state.user.sub}`, { withCredentials: true })\n .then(res => {\n this.setState({launch: false});\n })\n }\n else {\n this.setState({isLoading : true, launch: true});\n this.attach(this.state.launch);\n\n const httpClient = axios.create();\n httpClient.defaults.timeout = 600000;\n\n httpClient.get(`http://${this.ip}/simulator/start/${this.state.user.sub}/${this.state.user.given_name}/spiri-friend2019@`, { withCredentials: true })\n .then(res => {\n this.setState({simulator: res.data, isLoading: false});\n this.launchSimulator(this.state.simulator.publicIp);\n })\n //this.launchSimulator();\n }\n \n }\n \n \n\n render() {\n const options = this.state.isAuthenticated ? (\n
\n \n
\n ):(\n \n \n
\n
\n \n \n \n
\n \n
\n \n )\n \n const simulator = this.state.isAuthenticated ?\n
\n {/*

Welcome, {this.state.user.name}!

*/}\n < button className=\"SimulatorButton\" onClick={() =>{\n this.settingsSimulator(this.state.launch);\n }} disabled={this.state.isLoading} >\n {this.state.isLoading && }\n {!this.state.launch && Launch Simulator }\n {this.state.launch && Stop Simulator }\n \n \n
:\n null\n \n const mainBody =
\n \n {options}\n {simulator}\n
\n \n
\n
\n \n
\n \n
\n\n \n return (\n \n
\n \n \n {mainBody}\n \n
\n )\n\n };\n}\nexport default withRouter(withCookies(App));\n"]},"metadata":{},"sourceType":"module"}