Gazebo_simulation-Frontend/node_modules/.cache/babel-loader/9c2b62382190b90f94790668bca...

1 line
21 KiB
JSON

{"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\";\nvar _jsxFileName = \"/home/riddhi/simulation/Gazebo_simulation-Frontend/src/components/TaskList.js\";\nimport React, { Component } from 'react';\nimport { Button, ButtonGroup, Container, Table } from 'reactstrap';\nimport { Link, withRouter } from 'react-router-dom';\nimport { withCookies, Cookies } from 'react-cookie';\nimport { instanceOf } from 'prop-types';\nimport Navigationbar from './Navigationbar';\n\nvar TaskList = /*#__PURE__*/function (_Component) {\n _inherits(TaskList, _Component);\n\n function TaskList(props) {\n var _this;\n\n _classCallCheck(this, TaskList);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(TaskList).call(this, props));\n _this.state = {\n isLoading: true,\n isAuthenticated: false,\n user: undefined,\n simulator: undefined\n };\n var cookies = props.cookies;\n _this.state = {\n tasks: [],\n csrfToken: cookies.get('XSRF-TOKEN'),\n isLoading: true,\n simulator: \"\",\n timeoutActionTaken: false\n };\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.simulatorWindow = null;\n return _this;\n }\n\n _createClass(TaskList, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.loadUser();\n }\n }, {\n key: \"loadUser\",\n value: function () {\n var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {\n var _this2 = this;\n\n var response, body, userId, userName;\n return _regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return fetch(\"http://\".concat(this.ip, \"/api/user\"), {\n credentials: 'include'\n });\n\n case 2:\n response = _context.sent;\n _context.next = 5;\n return response.text();\n\n case 5:\n body = _context.sent;\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(\"())))))))))))))))))))))))))\");\n console.log(this.state.isAuthenticated);\n userId = this.state.user.sub;\n userName = this.state.user.given_name;\n fetch(\"http://\".concat(this.ip, \"/competition/progress/\").concat(userId, \"/13\"), {\n credentials: 'include'\n }).then(function (response) {\n return response.json();\n }).then(function (data) {\n return _this2.setState({\n tasks: data,\n isLoading: false\n });\n }).catch(function () {\n return _this2.props.history.push('/');\n });\n\n case 12:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n\n function loadUser() {\n return _loadUser.apply(this, arguments);\n }\n\n return loadUser;\n }()\n }, {\n key: \"openAutoTimeout\",\n value: function openAutoTimeout() {\n setTimeout(function () {\n console.log('auto close start now...');\n }.bind(this), 60 * 1000);\n }\n }, {\n key: \"openTimeout\",\n value: function openTimeout() {\n setTimeout(function () {\n var win = window.open(null, '_blank');\n this.state.timeoutActionTaken = false;\n win.focus();\n\n if (win.confirm(\"Do you want to keep simulator open and in-use? \\nClick 'Ok' for Yes and 'Cancel' for No.\\nIf nothing selected, simulator will be shut down automatically.\")) {\n // Do nothing, keep simulator alive\n this.state.timeoutActionTaken = true; //alert('ok clicked');\n\n win.close();\n } else {\n // send api to backend to stop task\n this.state.timeoutActionTaken = true; //alert('cancel clicked');\n\n win.close();\n }\n }.bind(this), 60 * 60 * 1000);\n this.openAutoTimeout();\n }\n }, {\n key: \"updateTask\",\n value: function updateTask(userId, compId, taskId) {\n var _this3 = this;\n\n fetch(\"http://\".concat(this.ip, \"/competition/update/\").concat(userId, \"/\").concat(compId, \"/\").concat(taskId), {\n credentials: 'include'\n }).then(function (response) {\n return response.json();\n }).then(function (data) {\n return _this3.setState({\n tasks: data,\n isLoading: false\n });\n }).catch(function () {\n return _this3.props.history.push('/');\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this4 = this;\n\n var _this$state = this.state,\n tasks = _this$state.tasks,\n isLoading = _this$state.isLoading;\n\n if (isLoading) {\n return /*#__PURE__*/React.createElement(\"p\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 97,\n columnNumber: 14\n }\n }, \"Loading...\");\n }\n\n var taskList = tasks.map(function (task) {\n return /*#__PURE__*/React.createElement(\"tr\", {\n key: task.task_id,\n __self: _this4,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 101,\n columnNumber: 14\n }\n }, /*#__PURE__*/React.createElement(\"td\", {\n style: {\n wordWrap: 'break-word'\n },\n __self: _this4,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 102,\n columnNumber: 9\n }\n }, task.task_name), /*#__PURE__*/React.createElement(\"td\", {\n style: {\n whiteSpace: 'nowrap'\n },\n __self: _this4,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 103,\n columnNumber: 9\n }\n }, task.task_progress), /*#__PURE__*/React.createElement(\"td\", {\n __self: _this4,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 104,\n columnNumber: 9\n }\n }, /*#__PURE__*/React.createElement(ButtonGroup, {\n __self: _this4,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 105,\n columnNumber: 11\n }\n }, /*#__PURE__*/React.createElement(Button, {\n size: \"sm\",\n color: \"primary\",\n onClick: function onClick() {\n _this4.openTimeout();\n\n _this4.updateTask(_this4.state.user.sub, 13, task.task_id);\n },\n __self: _this4,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 106,\n columnNumber: 11\n }\n }, task.task_action))));\n });\n return /*#__PURE__*/React.createElement(\"div\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 116,\n columnNumber: 7\n }\n }, /*#__PURE__*/React.createElement(Navigationbar, {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 117,\n columnNumber: 9\n }\n }), /*#__PURE__*/React.createElement(Container, {\n fluid: true,\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 118,\n columnNumber: 9\n }\n }, /*#__PURE__*/React.createElement(\"h3\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 119,\n columnNumber: 11\n }\n }, \"My Competition Tasks\"), /*#__PURE__*/React.createElement(Table, {\n style: {\n tableLayout: 'fixed'\n },\n className: \"mt-3\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 120,\n columnNumber: 11\n }\n }, /*#__PURE__*/React.createElement(\"thead\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 121,\n columnNumber: 13\n }\n }, /*#__PURE__*/React.createElement(\"tr\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 122,\n columnNumber: 13\n }\n }, /*#__PURE__*/React.createElement(\"th\", {\n width: \"30%\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 123,\n columnNumber: 15\n }\n }, \"Task Name\"), /*#__PURE__*/React.createElement(\"th\", {\n width: \"20%\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 124,\n columnNumber: 15\n }\n }, \"Progress\"), /*#__PURE__*/React.createElement(\"th\", {\n width: \"30%\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 125,\n columnNumber: 15\n }\n }, \"Action\"))), /*#__PURE__*/React.createElement(\"tbody\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 128,\n columnNumber: 13\n }\n }, taskList))));\n }\n }]);\n\n return TaskList;\n}(Component);\n\nTaskList.propTypes = {\n cookies: instanceOf(Cookies).isRequired\n};\nexport default withCookies(withRouter(TaskList));","map":{"version":3,"sources":["/home/riddhi/simulation/Gazebo_simulation-Frontend/src/components/TaskList.js"],"names":["React","Component","Button","ButtonGroup","Container","Table","Link","withRouter","withCookies","Cookies","instanceOf","Navigationbar","TaskList","props","state","isLoading","isAuthenticated","user","undefined","simulator","cookies","tasks","csrfToken","get","timeoutActionTaken","local","prod","status","ip","simulatorWindow","loadUser","fetch","credentials","response","text","body","setState","JSON","parse","console","log","userId","sub","userName","given_name","then","json","data","catch","history","push","setTimeout","bind","win","window","open","focus","confirm","close","openAutoTimeout","compId","taskId","taskList","map","task","task_id","wordWrap","task_name","whiteSpace","task_progress","openTimeout","updateTask","task_action","tableLayout","propTypes","isRequired"],"mappings":";;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,MAAT,EAAiBC,WAAjB,EAA8BC,SAA9B,EAAyCC,KAAzC,QAAsD,YAAtD;AACA,SAASC,IAAT,EAAeC,UAAf,QAAiC,kBAAjC;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,cAArC;AACA,SAASC,UAAT,QAA2B,YAA3B;AACA,OAAOC,aAAP,MAA2B,iBAA3B;;IAEMC,Q;;;AAYJ,oBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,kFAAMA,KAAN;AADiB,UAPnBC,KAOmB,GAPX;AACNC,MAAAA,SAAS,EAAE,IADL;AAENC,M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EAAC,KAAV;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAFF,eAGE;AAAI,QAAA,KAAK,EAAC,KAAV;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAHF,CADA,CADF,eAQE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SACCX,QADD,CARF,CAFF,CAFF,CADF;AAoBD;;;;EA/HoB7D,S;;AAAjBW,Q,CACG8D,S,GAAY;AACjBtD,EAAAA,OAAO,EAAEV,UAAU,CAACD,OAAD,CAAV,CAAoBkE;AADZ,C;AAiIrB,eAAenE,WAAW,CAACD,UAAU,CAACK,QAAD,CAAX,CAA1B","sourcesContent":["import React, { Component } from 'react';\nimport { Button, ButtonGroup, Container, Table } from 'reactstrap';\nimport { Link, withRouter } from 'react-router-dom';\nimport { withCookies, Cookies } from 'react-cookie';\nimport { instanceOf } from 'prop-types';\nimport Navigationbar from './Navigationbar'; \n\nclass TaskList extends Component {\n static propTypes = {\n cookies: instanceOf(Cookies).isRequired\n };\n\n state = {\n isLoading: true,\n isAuthenticated: false,\n user: undefined,\n simulator: undefined\n };\n\n constructor(props) {\n super(props);\n const {cookies} = props;\n this.state = {tasks: [], csrfToken: cookies.get('XSRF-TOKEN'), isLoading: true, simulator: \"\", timeoutActionTaken: false};\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.simulatorWindow = null;\n }\n\n componentDidMount() {\n this.loadUser();\n }\n\n async loadUser() {\n const response = await fetch(`http://${this.ip}/api/user`, {credentials: 'include'});\n const body = await response.text();\n if (body === '') {\n this.setState(({isAuthenticated: false}))\n } else {\n this.setState({isAuthenticated: true, user: JSON.parse(body)})\n }\n console.log(\"())))))))))))))))))))))))))\")\n console.log(this.state.isAuthenticated);\n\n const userId = this.state.user.sub;\n const userName = this.state.user.given_name;\n \n fetch(`http://${this.ip}/competition/progress/${userId}/13`, {credentials: 'include'})\n .then(response => response.json())\n .then(data => this.setState({tasks: data, isLoading: false}))\n .catch(() => this.props.history.push('/'));\n \n }\n \n \n openAutoTimeout(){\n setTimeout(function(){\n console.log('auto close start now...');\n }.bind(this), 60*1000);\n }\n\n openTimeout(){\n setTimeout(function(){\n var win = window.open(null, '_blank');\n this.state.timeoutActionTaken = false;\n win.focus();\n\n if(win.confirm(\"Do you want to keep simulator open and in-use? \\nClick 'Ok' for Yes and 'Cancel' for No.\\nIf nothing selected, simulator will be shut down automatically.\")){\n // Do nothing, keep simulator alive\n this.state.timeoutActionTaken = true;\n //alert('ok clicked');\n win.close();\n } else {\n // send api to backend to stop task\n this.state.timeoutActionTaken = true;\n //alert('cancel clicked');\n win.close();\n }}.bind(this), 60*60*1000);\n this.openAutoTimeout();\n }\n\n \n updateTask(userId, compId, taskId){\n fetch(`http://${this.ip}/competition/update/${userId}/${compId}/${taskId}`, {credentials: 'include'})\n .then(response => response.json())\n .then(data => this.setState({tasks: data, isLoading: false}))\n .catch(() => this.props.history.push('/'));\n }\n\n render() {\n const {tasks, isLoading} = this.state;\n \n if (isLoading) {\n return <p>Loading...</p>;\n }\n \n const taskList = tasks.map(task => {\n return <tr key={task.task_id}>\n <td style={{wordWrap: 'break-word'}}>{task.task_name}</td>\n <td style={{whiteSpace: 'nowrap'}}>{task.task_progress}</td>\n <td>\n <ButtonGroup>\n <Button size=\"sm\" color=\"primary\" onClick={() => {\n this.openTimeout();\n this.updateTask(this.state.user.sub, 13, task.task_id);\n }}>{task.task_action}</Button>\n </ButtonGroup>\n </td>\n </tr>\n });\n\n return (\n <div>\n <Navigationbar />\n <Container fluid>\n <h3>My Competition Tasks</h3>\n <Table style={{tableLayout: 'fixed'}} className=\"mt-3\">\n <thead>\n <tr>\n <th width=\"30%\">Task Name</th>\n <th width=\"20%\">Progress</th>\n <th width=\"30%\">Action</th>\n </tr>\n </thead>\n <tbody>\n {taskList}\n </tbody>\n </Table>\n </Container>\n </div>\n );\n }\n}\n\nexport default withCookies(withRouter(TaskList));"]},"metadata":{},"sourceType":"module"}