Skip to content

Commit

Permalink
Add support for resizing the lab window
Browse files Browse the repository at this point in the history
Add an observer to the JavaScript code to detect lab size changes
on the LMS page and send the new dimensions to the guacamole client.

For RDP connections, implement the `resize-method` display setting
with both available options. (https://guacamole.apache.org/doc/1.5.5/gug/configuring-guacamole.html#rdp-display-settings)
  • Loading branch information
Maari Tamm committed Feb 7, 2025
1 parent 5b36637 commit a2da2d3
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Unreleased
-------------------------
* [Enhancement] Add the possibility to dynamically resize the lab on the
LMS page. For RDP connections, implement the options provided by
Apache Guacamole, to `display-update` or `reconnect` (the default),
when the client display size changes. The given options are explained
in more detail in the README.

Version 8.2.0 (2025-01-03)
-------------------------
* [Enhancement] Add support for Apache Guacamole 1.5.5;
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@ This is a brief explanation of each:
* `enable_fullscreen`: An option to allow learners to launch a lab in fullsceen mode,
in a separate browser window. (Default: `false`)

* `lab_resize_method`: A [display setting](https://guacamole.apache.org/doc/1.5.5/gug/configuring-guacamole.html#rdp-display-settings) for RDP connections to update the RDP server
when the width and height of the client display changes. Possible values are:

* `display-update` *Only supported with Windows RDP 8.1 or xrdp 0.10.1 (and higher)*.
Uses the "Display Update" channel to request the server to change the display size.

* `reconnect` (the default) Automatically disconnects the RDP session when the client
display size has changed, and reconnects with the new size.

* `lab_usage_limit`: Allocate limited time per user for labs across the platform,
in seconds. (Default is `None`, meaning there is no time limit).

Expand Down
3 changes: 2 additions & 1 deletion hastexo/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
"providers": {},
"guacamole_js_version": '1.5.5',
"lab_usage_limit": None,
"lab_usage_limit_breach_policy": None
"lab_usage_limit_breach_policy": None,
"lab_resize_method": "reconnect"
}

SUPPORTED_LANGUAGES = [
Expand Down
4 changes: 4 additions & 0 deletions hastexo/public/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ function HastexoGuacamoleClient(configuration) {

onidle(pause) {
return pause;
},

sendSize(height, width) {
guac_client.sendSize(height, width);
}
}

Expand Down
9 changes: 9 additions & 0 deletions hastexo/public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ function HastexoXBlock(runtime, element, configuration) {
/* Show the terminal. */
$("#terminal").append(terminal_element);

// Observe the lab size in the browser and adjust when necessary
var lab = $('#terminal')[0];
const resizeObserver = new ResizeObserver(entries => {
for (const entry of entries) {
terminal_client.sendSize(entry.contentRect.width, entry.contentRect.height);
}
});
resizeObserver.observe(lab);

/* Disconnect on tab close. */
window.onunload = function() {
terminal_client.disconnect();
Expand Down
1 change: 1 addition & 0 deletions hastexo_guacamole_client/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ async def connect(self):
protocol=stack.protocol,
width=params.get('width', [1024])[0],
height=params.get('height', [768])[0],
resize_method=settings.get("lab_resize_method"),
hostname=stack.ip,
port=params.get('port', [default_port])[0],
username=stack.user,
Expand Down

0 comments on commit a2da2d3

Please sign in to comment.