I can't use CSS to reference images stored in the static directory and have to use raw Javascript.
I couldn't find the answer to this but ended up figuring out a weird way to discover and use the Splunk generated URL prefix local to each app e.g. "/static/@2b5b15c4ee.156/app/app_name"
using this in Javascript:
Splunk.util.make_url("/static/app/app_name/").replace(":0", "")
Is there a better way to do this?
Great, the make_url() function from util.js is just what I'll have to use. Just wanted to confirm that that was the right way to go.
@skisoccer13, are you trying to generate the dynamic path for static file based on current app?
Please refer to answer: https://answers.splunk.com/answers/552333/how-do-i-add-a-picture-to-my-dashboard-v-66.html
Here is an example to use path with $env:app$ to refer to static folder path: https://answers.splunk.com/answers/585907/how-to-shift-image-inside-an-image-in-splunk-on-th.html
If this is not what you need can you add more details of what you are trying to do?
I did see that but I need a purely Javascript only solution. This app uses Javascript libraries that need to be passed URLs of images for use. I can't use CSS or the standard HTML.
@skisoccer13, your question says without JavaScript however the comment says purely JavaScript solution. This is confusing.
You have mentioned the app
uses JavaScript Libraries. Is this Splunk App or something else? Please elaborate a bit more on use case as to what you have and what you want to do, so that community members can assist you better.
This is an app that uses the three.js Javascript library for a 3D globe rendering. It was designed for v6 of Splunk but I am on v7. I don't know if there was a change in the SDK or not.
It is working right now with my solution after I rewrote it with the Splunk.util call. I just don't know if this is the correct method to obtain the generated app prefix so the Javascript library can properly access the images stored in the appserver/static folder
Are you trying to pass on the image path to the following in three.js
: THREE.ImageUtils.loadTexture(imgDir+'world.jpg');
If you are able to access Splunk Utils using splunkjs/mv/utils.js
then you can use Splunk.util.getCurrentApp();
to get the current app name.
You can also refer to make_url()
documentation for utils.js : https://docs.splunk.com/Documentation/Splunk/latest/ModuleRef/Splunk.util#Synopsis_26
Alternatively, a longer route would be to build a Custom Visualization in Splunk
using three.js
. http://docs.splunk.com/Documentation/Splunk/latest/AdvancedDev/CustomVizTutorial