|
2 | 2 | <meta charset="utf-8"> |
3 | 3 | <title>guacamole-lite test</title> |
4 | 4 |
|
5 | | -<style> |
6 | | - html, body { height: 100%; margin: 0; display: flex; flex-direction: column; } |
7 | | - #display { flex-grow: 1; width: 100%; cursor: default; } |
8 | | - .guac-hide-cursor { cursor: url('dot.gif'), default; } |
9 | | - #connection-form { padding: 10px; border-bottom: 1px solid #ccc; display: flex; gap: 15px; align-items: center; } |
10 | | - #remote-host-details { display: none; gap: 10px; } |
11 | | - #remote-host-details.visible { display: flex; } |
12 | | - label { margin-right: 5px; } |
13 | | - input, select, button { padding: 5px; } |
14 | | -</style> |
15 | | - |
16 | | -<!-- Connection Form --> |
17 | | -<div id="connection-form"> |
18 | | - <label for="connect-target">Connect to:</label> |
19 | | - <select id="connect-target"> |
20 | | - <option value="test-host" selected>Test Host (Linux Desktop)</option> |
21 | | - <option value="remote-host">Remote Host</option> |
22 | | - </select> |
23 | | - |
24 | | - <label for="protocol">Protocol:</label> |
25 | | - <select id="protocol"> |
26 | | - <option value="rdp" selected>RDP</option> |
27 | | - <option value="vnc">VNC</option> |
28 | | - </select> |
29 | | - |
30 | | - <div id="remote-host-details"> |
31 | | - <label for="remote-hostname">Host:</label> |
32 | | - <input type="text" id="remote-hostname" placeholder="hostname or IP"> |
33 | | - <label for="remote-username">Username:</label> |
34 | | - <input type="text" id="remote-username"> |
35 | | - <label for="remote-password">Password:</label> |
36 | | - <input type="password" id="remote-password"> |
| 5 | +<link rel="stylesheet" href="css/style.css"> |
| 6 | + |
| 7 | +<div id="app-container"> |
| 8 | + <!-- Connection Screen --> |
| 9 | + <div id="connection-screen"> |
| 10 | + <div id="connection-form"> |
| 11 | + <h2 class="form-header">Guacamole Remote Connection</h2> |
| 12 | + |
| 13 | + <div class="form-row"> |
| 14 | + <label>Connect to:</label> |
| 15 | + <div id="connect-target" class="radio-group"> |
| 16 | + <div class="radio-option"> |
| 17 | + <input type="radio" id="connect-target-test" name="connect-target" value="test-host" checked> |
| 18 | + <label for="connect-target-test">Test Host</label> |
| 19 | + </div> |
| 20 | + <div class="radio-option"> |
| 21 | + <input type="radio" id="connect-target-remote" name="connect-target" value="remote-host"> |
| 22 | + <label for="connect-target-remote">Remote Host</label> |
| 23 | + </div> |
| 24 | + </div> |
| 25 | + </div> |
| 26 | + |
| 27 | + <div class="form-row"> |
| 28 | + <label>Protocol:</label> |
| 29 | + <div id="protocol" class="radio-group"> |
| 30 | + <div class="radio-option"> |
| 31 | + <input type="radio" id="protocol-rdp" name="protocol" value="rdp" checked> |
| 32 | + <label for="protocol-rdp">RDP</label> |
| 33 | + </div> |
| 34 | + <div class="radio-option"> |
| 35 | + <input type="radio" id="protocol-vnc" name="protocol" value="vnc"> |
| 36 | + <label for="protocol-vnc">VNC</label> |
| 37 | + </div> |
| 38 | + </div> |
| 39 | + </div> |
| 40 | + |
| 41 | + <div id="remote-host-details"> |
| 42 | + <div class="form-row"> |
| 43 | + <label for="remote-hostname">Host:</label> |
| 44 | + <input type="text" id="remote-hostname" placeholder="hostname or IP"> |
| 45 | + </div> |
| 46 | + <div class="form-row"> |
| 47 | + <label for="remote-username">Username:</label> |
| 48 | + <input type="text" id="remote-username"> |
| 49 | + </div> |
| 50 | + <div class="form-row"> |
| 51 | + <label for="remote-password">Password:</label> |
| 52 | + <input type="password" id="remote-password"> |
| 53 | + </div> |
| 54 | + </div> |
| 55 | + |
| 56 | + <div class="form-row" style="margin-top: 20px;"> |
| 57 | + <button id="connect-button">Connect</button> |
| 58 | + </div> |
| 59 | + </div> |
37 | 60 | </div> |
38 | 61 |
|
39 | | - <button id="connect-button">Connect</button> |
| 62 | + <!-- Display Screen --> |
| 63 | + <div id="display-screen"> |
| 64 | + <div id="display-header"> |
| 65 | + <div id="display-title">Remote Connection</div> |
| 66 | + <button id="close-button">Disconnect</button> |
| 67 | + </div> |
| 68 | + <!-- The remote-desktop surface --> |
| 69 | + <div id="display"></div> |
| 70 | + </div> |
40 | 71 | </div> |
41 | 72 |
|
42 | | -<!-- official guacamole-common-js bundle copied by the Dockerfile --> |
43 | | -<script src="js/all.min.js"></script> |
44 | | - |
45 | | -<!-- The remote-desktop surface --> |
46 | | -<div id="display"></div> |
47 | | - |
48 | 73 | <!-- Hidden textarea for clipboard integration --> |
49 | 74 | <textarea id="clipboard-textarea" style="position: absolute; left: -9999px;"></textarea> |
50 | 75 |
|
| 76 | +<!-- official guacamole-common-js bundle copied by the Dockerfile --> |
| 77 | +<script src="js/all.min.js"></script> |
51 | 78 | <script src="js/token-generator.js"></script> |
52 | | -<script src="js/guacamole-init.js"></script> |
53 | | - |
54 | | -<script> |
55 | | - const connectTargetSelect = document.getElementById('connect-target'); |
56 | | - const remoteHostDetailsDiv = document.getElementById('remote-host-details'); |
57 | | - const connectButton = document.getElementById('connect-button'); |
58 | | - const protocolSelect = document.getElementById('protocol'); |
59 | | - const remoteHostnameInput = document.getElementById('remote-hostname'); |
60 | | - const remoteUsernameInput = document.getElementById('remote-username'); |
61 | | - const remotePasswordInput = document.getElementById('remote-password'); |
62 | | - |
63 | | - connectTargetSelect.addEventListener('change', () => { |
64 | | - if (connectTargetSelect.value === 'remote-host') { |
65 | | - remoteHostDetailsDiv.classList.add('visible'); |
66 | | - } else { |
67 | | - remoteHostDetailsDiv.classList.remove('visible'); |
68 | | - } |
69 | | - }); |
70 | | - |
71 | | - connectButton.addEventListener('click', async () => { |
72 | | - const target = connectTargetSelect.value; |
73 | | - const protocol = protocolSelect.value; |
74 | | - let connectionSettings; |
75 | | - |
76 | | - if (target === 'test-host') { |
77 | | - connectionSettings = { |
78 | | - hostname: "desktop-linux", // Service name in docker-compose |
79 | | - username: "testuser", |
80 | | - password: "Passw0rd!", |
81 | | - security: "any", |
82 | | - "ignore-cert": true, |
83 | | - "enable-drive": protocol === 'rdp', // Drive redirection only for RDP |
84 | | - "drive-path": protocol === 'rdp' ? "/tmp/guac-drive" : undefined, |
85 | | - "create-drive-path": protocol === 'rdp', |
86 | | - "enable-printing": protocol === 'rdp', // Printing only for RDP |
87 | | - "audio": protocol === 'rdp' ? ["audio/L16;rate=44100"] : undefined // Audio only for RDP |
88 | | - }; |
89 | | - // Adjust port based on protocol for test-host |
90 | | - if (protocol === 'vnc') { |
91 | | - connectionSettings.port = 5900; // Default VNC port |
92 | | - } |
93 | | - // RDP port is handled by default (3389) unless specified |
94 | | - } else { // remote-host |
95 | | - connectionSettings = { |
96 | | - hostname: remoteHostnameInput.value, |
97 | | - username: remoteUsernameInput.value, |
98 | | - password: remotePasswordInput.value, |
99 | | - // Add common settings or let Guacamole use defaults |
100 | | - "ignore-cert": protocol === 'rdp' ? true : undefined, // Common for RDP self-signed certs |
101 | | - }; |
102 | | - // Add port setting if needed, Guacamole uses defaults (3389 for RDP, 5900 for VNC) |
103 | | - } |
104 | | - |
105 | | - const tokenObj = { |
106 | | - connection: { |
107 | | - type: protocol, |
108 | | - settings: connectionSettings |
109 | | - } |
110 | | - }; |
111 | | - |
112 | | - try { |
113 | | - // Clear previous display if any |
114 | | - const displayDiv = document.getElementById('display'); |
115 | | - while (displayDiv.firstChild) { |
116 | | - displayDiv.removeChild(displayDiv.firstChild); |
117 | | - } |
118 | | - |
119 | | - console.log("Generating token for:", tokenObj); |
120 | | - const token = await generateGuacamoleToken(tokenObj); |
121 | | - console.log("Token generated, initializing Guacamole..."); |
122 | | - await initGuacamole(token, protocol); // Pass protocol to initGuacamole |
123 | | - console.log("Guacamole initialization called."); |
124 | | - } catch (error) { |
125 | | - console.error("Failed to connect:", error); |
126 | | - alert("Connection failed: " + error.message); |
127 | | - } |
128 | | - }); |
129 | | -</script> |
| 79 | +<script src="js/main.js"></script> |
0 commit comments