R view library interactive javascript view

Hello there,

i have a workflow that makes use of the R library “visNetwork”. If run on knime desktop it opens a webpage showing an interactive javascript view which is physically located in a local temp folder. This works fine, but i want to create a webservice on knime server, but this doesnt work there.

It does create the webpage on the server’s temp folder, but this cant be accessed from the webportal.

I tried to use knime’s javascript network viewer instead as a workaround, but this node lacks certain functionalities the R view version has to offer.

I assume i could access this from the webportal if i could extract the webpage and its related metadata from the server’s temp folder and copy it to a location from where the webportal could access it, but i dont have a clue, where i should put it. Does anyone has an idea?

If someone had a similar problem and found a different solution, i am happy to learn about workarounds. :slight_smile:

thanks a lot in advance

Hi @Dr.Joker,

if you create the temp folder with Create Temp Dir node and use that for storing the outputs of your R script, KNIME Server should be able to access it.

If your question is less about how/where to store the outputs, but more about how to display it on the WebPortal afterwards, you might be able to use the Generic JavaScript View node.

Is this any helpful?

Best,
Marten

Hi,

thank you for the quick answer. The problem i have is not about storing the output, but rather displaying it.
The R script creates an html file, which cannot be displayed by webportal. I know where it is located and may access it directly on the server. My assumption was, that it should be possible to move the html file to a location from where knime server may display my html file, that was just created. I just dont know how.

Since i am not really familiar with javascript i would like to avoid coding it with the generic javascript view node.

Potentially you could create a new folder in apache/webapps directory and store the files in there.

Hello again,

this seems to work and this is a functioning option, thank you very much!

The only issue i got now is that the new display page is for everyone to see after the workflow has done its job.

Is there a way to integrate this display page into the webportal to make use of the restricted login access of the knime server?

for example: https://knime.[DOMAINEXAMPLE]/knime/[DISPLAY PAGE]

best regards

If you want to access that from within KNIME WebPortal, the easiest way is to use a String Widget node, inject the HTML with a flow variable and put it into a component.

Hi Marten,

thanks a lot for helping us!
As I understand, your idea would show the link only to the user who is accessing the node, but the website created is still public available, since it is stored outside of the KNIME Webportal next to the knime folder in webapps.
The above question is more towards the direction of how to integrate that HTML in the webportal based on the KNIME Webportal user credentials in the way all functionalities are working in the webportal.
The wanted behavior is: If the the HTML file is created via the executed workflow only the user who was running the workflow can access that HTML file via a link in his browser (KNIME Webportal). It would be even great if the temp folder is deleted via the server if the job is discarded. Like we are used too.

That way all other users who want to open that resulting HTML-page in the webportal are informed that they have no access rights.

Its all about web security :slight_smile:

Best,
Lars

Lets forget about providing the website as webapp on the TomEE directly, but rather consider to store the generated HTML in a string variable. The value of this variable we can use in a String Widget node. So basically you would provide your webpage within a KNIME Server WebPortal page. This way your security requirements should be covered and it is nicely integrated.

2 Likes

Hi Marten,

thanks a lot. This would indeed be a great solution So far I ignored such an option, since I am not sure regarding the required .js files. How would I provide them in this scenario?

The R package is writing out a folder which contains an ‘index.html’
and several subfolders with one .js file each.

Best,
Lars

Hi Lars,
you would probably have to read in the JS files as well and then replace the tags. For images it is more complicated. Here you’d have to transform them into base64 somehow and use them like this in the HTML:
<img src="data:image/png;base64, yourbase64string"/>

Kind regards
Alexander

Thanks a lot! But I think I am missing here something important. What node are you suggesting to use in order to show the HTML website containing the JS in the KNIME Webportal? I tried the text output node (widget with the HTML setting, but as expected even under 4.1.1 it does not show anything if it is containing more than HTML code (then JS would be missing).

Many thanks!
Lars

Hi,
you can use the Generic JavaScript View. There you can simply use something along the lines of document.getElementsByTagName("body")[0].innerHTML = $yourHTMLFlowVar$. I think this works, but if it does not run the script tags, you may have to concatenate all the JavaScript into one string and then run it using eval() at the end of the code you have in the Generic JS View.
Kind regards
Alexander

Hi,

Lars asked me to upload a sample webpage so everybody knows, what we’re talking about.

test.zip (297.5 KB)

cheers
Marcel

Many thanks!
We were looking for an easy way to achieve that, avoiding the need of bothering developers with writing a desired node or using the GenericJavaScript.

The comment from Marten sounded to me there is an easy way:

But as it looks like now there is no easy way for a non developer to just show a given website in the KNIME webportal.

I did ask my developer collegues to try the GenericJavaScript way for me.

Best,
Lars