UNPKG

@zigbang/honeyfarm-dashboard

Version:

HoneyFarm Node에 등록 되어 있는 안드로이드 단말을 웹페이지에서 실시간으로 확인 및 사용 할수 있도록 구현된 웹

1 lines 3.22 kB
{"ast":null,"code":"import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { jsxs as _jsxs } from \"react/jsx-runtime\";\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nimport React from \"react\";\nimport Head from \"next/head\";\nimport api from \"../src/api\";\nimport { argsParser } from \"../src/utils\";\nexport const getServerSideProps = async context => {\n const endpoint = argsParser(process.argv, \"--endpoint\");\n return {\n props: {\n endpoint: endpoint\n }\n };\n};\nexport default class Dashboard extends React.Component {\n constructor(props) {\n super(props);\n\n _defineProperty(this, \"state\", {\n dashboad: []\n });\n\n _defineProperty(this, \"api\", void 0);\n }\n\n render() {\n return /*#__PURE__*/_jsxs(\"div\", {\n style: {\n height: \"100%\",\n width: \"100%\"\n },\n children: [/*#__PURE__*/_jsx(Head, {\n children: /*#__PURE__*/_jsx(\"title\", {\n children: \"dashboard\"\n })\n }), /*#__PURE__*/_jsx(\"div\", {\n style: page,\n children: this.state.dashboad\n })]\n });\n }\n\n async componentDidMount() {\n this.api = new api(this.props.endpoint);\n await this.makeChild();\n }\n\n async makeChild() {\n try {\n const result = await this.api.getDevices();\n if (!result) return null;\n const data = result.data;\n\n if (data) {\n const views = [];\n Object.entries(data).filter(([key, value]) => {\n const nodeAddress = key.split(\":\")[0];\n const status = value.showInDashboard ? \"DASHBOARD\" : value.status;\n\n if (value.platform === \"android\" && nodeAddress) {\n const view = /*#__PURE__*/_jsxs(\"div\", {\n style: page_view,\n children: [/*#__PURE__*/_jsx(\"div\", {\n style: {\n width: \"fit-content\",\n height: \"fit-content\"\n },\n children: /*#__PURE__*/_jsxs(\"div\", {\n children: [value.name, \" [\", status, \"]\"]\n })\n }), /*#__PURE__*/_jsx(\"iframe\", {\n height: \"750px\",\n width: \"500px\",\n src: `http://${nodeAddress}:8000/#!action=stream&udid=${value.udid}&player=mse&ws=ws%3A%2F%2F${nodeAddress}%3A8000%2F%3Faction%3Dproxy-adb%26remote%3Dtcp%253A8886%26udid%3D${value.udid}`,\n frameBorder: \"0\"\n })]\n }, `${value.udid}`);\n\n views.push(view);\n }\n });\n this.setState({\n dashboad: views\n });\n }\n } catch (e) {\n console.error(e);\n }\n }\n\n}\nconst page = {\n backgroundColor: \"rgb(248, 248, 248)\",\n height: \"auto\",\n width: \"auto\",\n display: \"inline\"\n};\nconst page_view = {\n height: \"fit-content\",\n width: \"500px\",\n display: \"inline-block\",\n paddingTop: \"40px\",\n alignItems: \"center\"\n};","map":null,"metadata":{},"sourceType":"module"}