Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the RenderableVNC class to use the <ansys-nexus-viewer> compon… #337

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions src/ansys/pyensight/core/renderable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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"<script src='/ansys/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} }}'
+ "'"
)

html += f"<ansys-nexus-viewer {attributes}></ansys-nexus-viewer>\n"

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


Expand Down
Loading