1import React from 'react';
2import MeshCentralEmbed, { VIEWMODE } from '../../components/MeshCentralEmbed';
3import { apiFetch } from '../../lib/api';
7 * Embeds MeshCentral's remote desktop interface
9export default function TabRds({ agentId, agentUuid }) {
10 const [nodeId, setNodeId] = React.useState(null);
11 const [loading, setLoading] = React.useState(true);
12 const [error, setError] = React.useState(null);
14 // Load MeshCentral node ID for this agent
15 React.useEffect(() => {
16 async function loadNodeId() {
21 const response = await apiFetch(`/agent/${agentUuid || agentId}/meshcentral-url`);
24 const errorData = await response.json();
25 throw new Error(errorData.error || 'Failed to get MeshCentral connection');
28 const data = await response.json();
29 setNodeId(data.meshcentralNodeId);
32 console.error('[TabRds] Failed to load MeshCentral node ID:', err);
33 setError(err.message);
39 if (agentUuid || agentId) {
42 }, [agentUuid, agentId]);
46 <div className="tab-container">
47 <div style={{ textAlign: 'center', padding: '3rem' }}>
48 <div className="spinner" style={{ margin: '0 auto 1rem' }}></div>
49 <p>Loading remote desktop...</p>
57 <div className="tab-container">
58 <div className="card" style={{ textAlign: 'center', padding: '2rem' }}>
59 <div style={{ fontSize: '3rem', marginBottom: '1rem' }}>⚠️</div>
60 <h3>Connection Error</h3>
61 <p style={{ color: '#d32f2f', marginBottom: '1rem' }}>{error}</p>
62 <button className="btn" onClick={() => window.location.reload()}>
71 <div className="tab-container" style={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
74 viewMode={VIEWMODE.DESKTOP}
75 title="Remote Desktop"