mirror of
https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
synced 2025-11-02 03:07:46 +00:00
Added rrtys new window button
This commit is contained in:
@@ -1,12 +1,15 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import { CButton, CCard, CCardHeader, CCardBody, CRow, CCol } from '@coreui/react';
|
import { CButton, CCard, CCardHeader, CCardBody, CRow, CCol } from '@coreui/react';
|
||||||
import ActionModal from './ActionModal';
|
import ActionModal from './ActionModal';
|
||||||
import FirmwareUpgradeModal from './FirmwareUpgradeModal';
|
import FirmwareUpgradeModal from './FirmwareUpgradeModal';
|
||||||
import TraceModal from './TraceModal';
|
import TraceModal from './TraceModal';
|
||||||
import WifiScanModal from './WifiScanModal';
|
import WifiScanModal from './WifiScanModal';
|
||||||
import BlinkModal from './BlinkModal';
|
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 [showRebootModal, setShowRebootModal] = useState(false);
|
||||||
const [showBlinkModal, setShowBlinkModal] = useState(false);
|
const [showBlinkModal, setShowBlinkModal] = useState(false);
|
||||||
const [showUpgradeModal, setShowUpgradeModal] = useState(false);
|
const [showUpgradeModal, setShowUpgradeModal] = useState(false);
|
||||||
@@ -33,6 +36,26 @@ const DeviceActions = () => {
|
|||||||
setShowScanModal(!showScanModal);
|
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 (
|
return (
|
||||||
<CCard>
|
<CCard>
|
||||||
<CCardHeader>Device Actions</CCardHeader>
|
<CCardHeader>Device Actions</CCardHeader>
|
||||||
@@ -73,6 +96,14 @@ const DeviceActions = () => {
|
|||||||
</CButton>
|
</CButton>
|
||||||
</CCol>
|
</CCol>
|
||||||
</CRow>
|
</CRow>
|
||||||
|
<CRow style={{ marginTop: '10px' }}>
|
||||||
|
<CCol>
|
||||||
|
<CButton onClick={getRttysInfo} color='primary' block>
|
||||||
|
Connect
|
||||||
|
</CButton>
|
||||||
|
</CCol>
|
||||||
|
<CCol/>
|
||||||
|
</CRow>
|
||||||
</CCardBody>
|
</CCardBody>
|
||||||
<ActionModal
|
<ActionModal
|
||||||
show={showRebootModal}
|
show={showRebootModal}
|
||||||
@@ -90,4 +121,8 @@ const DeviceActions = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DeviceActions.propTypes = {
|
||||||
|
selectedDeviceId: PropTypes.string.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
export default DeviceActions;
|
export default DeviceActions;
|
||||||
|
|||||||
Reference in New Issue
Block a user