Skip to content

Commit

Permalink
fix support of remote sessions for version of ensight earlier than 20…
Browse files Browse the repository at this point in the history
…24R1 (#360)
  • Loading branch information
mariostieriansys authored Mar 15, 2024
1 parent a9972ee commit 981213e
Showing 1 changed file with 42 additions and 21 deletions.
63 changes: 42 additions & 21 deletions src/ansys/pyensight/core/renderable.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,20 @@ def __init__(self, *args, **kwargs) -> None:
self._rendertype = "remote"
self.update()

def _update_2023R2_or_less(self):
"""Update the remote rendering widget and display it for
backend EnSight of version earlier than 2024R1
"""
query_params = {
"autoconnect": "true",
"host": self._session.html_hostname,
"port": self._session.ws_port,
}
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(query_params)
self._url = url

def update(self):
"""Update the remote rendering widget and display it.
Expand All @@ -549,29 +563,36 @@ def update(self):
"""
optional_query = self._get_query_parameters_str()
version = _get_ansysnexus_version(self._session._cei_suffix)
html = f"<script src='/ansys{version}/nexus/viewer-loader.js{optional_query}'></script>\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} }}'
+ "'"
)
if int(self._session._cei_suffix) < 241:
self._update_2023R2_or_less()
else:
html = (
f"<script src='/ansys{version}/nexus/viewer-loader.js{optional_query}'></script>\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}"
)

html += f"<ansys-nexus-viewer {attributes}></ansys-nexus-viewer>\n"
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} }}'
+ "'"
)

# refresh the remote HTML
self._save_remote_html_page(html)
html += f"<ansys-nexus-viewer {attributes}></ansys-nexus-viewer>\n"

# refresh the remote HTML
self._save_remote_html_page(html)
super().update()


Expand Down

0 comments on commit 981213e

Please sign in to comment.