From 23d8c6c34baadf2bf84db9113de6001a44996147 Mon Sep 17 00:00:00 2001 From: David Bremer <120127082+david-bremer@users.noreply.github.com> Date: Mon, 20 Nov 2023 04:00:25 -0500 Subject: [PATCH] =?UTF-8?q?Update=20the=20RenderableVNC=20class=20to=20use?= =?UTF-8?q?=20the=20=20compon=E2=80=A6=20(#337)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mario Ostieri <107915956+mariostieriansys@users.noreply.github.com> --- src/ansys/pyensight/core/renderable.py | 37 +++++++++++++++++++------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/ansys/pyensight/core/renderable.py b/src/ansys/pyensight/core/renderable.py index ce24de195e1..bc107ebadf5 100644 --- a/src/ansys/pyensight/core/renderable.py +++ b/src/ansys/pyensight/core/renderable.py @@ -525,15 +525,11 @@ def update(self): class RenderableVNC(Renderable): - """Generates a URL that can be used to connect to the EnSight VNC remote image renderer.""" + """Generates an ansys-nexus-viewer component that can be used to connect to the EnSight VNC remote image renderer.""" def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) - self._query_params = { - "autoconnect": "true", - "host": self._session.html_hostname, - "port": self._session.ws_port, - } + self._generate_url() self._rendertype = "remote" self.update() @@ -544,10 +540,31 @@ def update(self): iframe reference. """ - url = f"{self._http_protocol}://{self._session.html_hostname}:{self._session.html_port}" - url += "/ansys/nexus/novnc/vnc_envision.html" - url += self._get_query_parameters_str(self._query_params) - self._url = url + optional_query = self._get_query_parameters_str() + + html = f"\n" + rest_uri = ( + f"{self._http_protocol}://{self._session.html_hostname}:{self._session.html_port}" + ) + ws_uri = f"{self._http_protocol}://{self._session.html_hostname}:{self._session.ws_port}" + + query_args = "" + if self._using_proxy and optional_query: + query_args = f', "extra_query_args":"{optional_query[1:]}"' + + attributes = ' renderer="envnc"' + attributes += ' ui="simple"' + attributes += ' active="true"' + attributes += ( + " renderer_options='" + + f'{{ "ws":"{ws_uri}", "http":"{rest_uri}", "security_token":"{self._session.secret_key}", "connect_to_running_ens":true {query_args} }}' + + "'" + ) + + html += f"\n" + + # refresh the remote HTML + self._save_remote_html_page(html) super().update()