diff --git a/src/pages/DevicePage/DeviceActions.js b/src/pages/DevicePage/DeviceActions.js index 608cfe0..f687dfb 100644 --- a/src/pages/DevicePage/DeviceActions.js +++ b/src/pages/DevicePage/DeviceActions.js @@ -1,12 +1,15 @@ import React, { useState } from 'react'; +import PropTypes from 'prop-types'; import { CButton, CCard, CCardHeader, CCardBody, CRow, CCol } from '@coreui/react'; import ActionModal from './ActionModal'; import FirmwareUpgradeModal from './FirmwareUpgradeModal'; import TraceModal from './TraceModal'; import WifiScanModal from './WifiScanModal'; import BlinkModal from './BlinkModal'; +import axiosInstance from '../../utils/axiosInstance'; +import { getToken } from '../../utils/authHelper'; -const DeviceActions = () => { +const DeviceActions = ({selectedDeviceId}) => { const [showRebootModal, setShowRebootModal] = useState(false); const [showBlinkModal, setShowBlinkModal] = useState(false); const [showUpgradeModal, setShowUpgradeModal] = useState(false); @@ -33,6 +36,26 @@ const DeviceActions = () => { setShowScanModal(!showScanModal); }; + const getRttysInfo = () => { + const options = { + headers: { + Accept: 'application/json', + Authorization: `Bearer ${getToken()}`, + }, + }; + + axiosInstance + .get(`/device/${selectedDeviceId}/rtty`, options) + .then((response) => { + const url = `http://${response.data.server}:${response.data.viewport}/connect/${response.data.connectionId}`; + const newWindow = window.open(url, '_blank', 'noopener,noreferrer'); + if (newWindow) newWindow.opener = null; + }) + .catch(() => {}); + }; + + + return ( Device Actions @@ -73,6 +96,14 @@ const DeviceActions = () => { + + + + Connect + + + + { ); }; +DeviceActions.propTypes = { + selectedDeviceId: PropTypes.string.isRequired, +}; + export default DeviceActions;