Spaces:
Configuration error
Configuration error
zack
commited on
Commit
·
08156fb
1
Parent(s):
4d7c2c6
🔧 Update importer component
Browse files
frontend/src/components/Modal/importer.js
CHANGED
@@ -12,10 +12,28 @@ export default function Import(props){
|
|
12 |
const [embedUrl, setEmbedUrl] = useState("");
|
13 |
const [vmid, setVmid] = useState('');
|
14 |
const [node, setNode] = useState('');
|
|
|
15 |
|
16 |
const handleProxmoxSubmit = async (e) => {
|
17 |
e.preventDefault();
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
};
|
20 |
|
21 |
return (<div>
|
@@ -115,9 +133,17 @@ export default function Import(props){
|
|
115 |
onChange={(e) => setNode(e.target.value)}
|
116 |
/>
|
117 |
<button className="btn btn-primary mt-2" type="submit">
|
118 |
-
|
119 |
</button>
|
120 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
</div>
|
122 |
}
|
123 |
|
|
|
12 |
const [embedUrl, setEmbedUrl] = useState("");
|
13 |
const [vmid, setVmid] = useState('');
|
14 |
const [node, setNode] = useState('');
|
15 |
+
const [iframeSrc, setIframeSrc] = useState("");
|
16 |
|
17 |
const handleProxmoxSubmit = async (e) => {
|
18 |
e.preventDefault();
|
19 |
+
const requestData = { vmid, node };
|
20 |
+
fetch("http://localhost:2000/api/proxmox/vnc", {
|
21 |
+
method: "POST",
|
22 |
+
headers: { 'Content-Type': 'application/json' },
|
23 |
+
body: JSON.stringify(requestData)
|
24 |
+
})
|
25 |
+
.then(response => response.json())
|
26 |
+
.then(data => {
|
27 |
+
if(data.iframe_src) {
|
28 |
+
setIframeSrc(data.iframe_src);
|
29 |
+
props.onAddEmbed({ url: data.iframe_src, type: 'embed' });
|
30 |
+
} else {
|
31 |
+
console.error("Failed to get iframe source URL");
|
32 |
+
}
|
33 |
+
})
|
34 |
+
.catch(error => {
|
35 |
+
console.error("Error fetching iframe source URL:", error);
|
36 |
+
});
|
37 |
};
|
38 |
|
39 |
return (<div>
|
|
|
133 |
onChange={(e) => setNode(e.target.value)}
|
134 |
/>
|
135 |
<button className="btn btn-primary mt-2" type="submit">
|
136 |
+
Generate Proxmox noVNC Session
|
137 |
</button>
|
138 |
</form>
|
139 |
+
{iframeSrc &&
|
140 |
+
<div className='p-5 flex flex-col items-start'>
|
141 |
+
<a href={iframeSrc} target="_blank" rel="noopener noreferrer" className="mb-2 underline text-blue-600 hover:text-blue-800 visited:text-purple-600">Access Proxmox noVNC Session</a>
|
142 |
+
<button onClick={() => navigator.clipboard.writeText(iframeSrc)} className="btn btn-primary">
|
143 |
+
Copy Session Link
|
144 |
+
</button>
|
145 |
+
</div>
|
146 |
+
}
|
147 |
</div>
|
148 |
}
|
149 |
|