Hi,
I am currently exploring the capabilities of the Generic JavaScript View. As earlier forum posts show, it is possible to load external JavaScript libraries. This is a great workflow which shows many approaches to do so: Javascript_load_3rdPart_Library_2022_05_12 – KNIME Community Hub
You can not only use the Generic JavaScript View to produce visualizations but also render HTML. This offers awesome possibilities on the KNIME Server Webportal (maybe also on the new Business Hub?).
This workflow shows a proof of concept: It loads React.js from a CDN and renders a simple component in the interactive view: Load React.js – KNIME Community Hub
With React.js there is a disadvantage: You can’t write JSX code in the Generic JavaScript View editor.
What you can do is: Write & build your app in an external code editor like VS Code and load the minified js file into th Generic JavaScript View.
What I have not yet accomplished: I want to use assets like icons/pictures/etc. in my custom view. How is this possible?
Executing the Generic JavaScript View will create a Temp folder in C:\Users\username\AppData\Local\Temp\knimeViewContainer873
Is there a way to know the bold written number which makes the folder name unique ahead of time? I want to copy my app’s assets into this folder.
My best approach so far is using window.parent.location.toString()
in my code, which gives you an output like file:///C:/Users/username/AppData/Local/Temp/knimeViewContainer875/index_[long number omitted].html
Using string manipulation I could get the path but only inside the view. From there I can’t access the filesystem (or if I had, would run into timing issues).
A possible workaround would be hard-coding the assets path in the JS code. I would not like to do this, because I want to run already existing apps inside KNIME.