Developing dashboard plugins

I am currently developing a few small dashboard plugins for our OOD instance. The main idea is to natively show the user some information on their account quota and system metrics on the dashboard.

I have read through the information that I could find on this topic (e.g. Passenger App inside dashboard? - #2 by jeff.ohrstrom ) and have found the good25 examples referenced there to help a lot.

While currently undocumented it seems to work to put plugins at /etc/ood/config/plugins in production to deploy plugins. However I am struggling to do something similar for dashboard development. Here I need to scatter my plugin files to the different folders to the dashboard app to find them. Is this the expected behavior or am I missing something?

Hi and welcome!

You may be looking for Custom Dashboard Layouts, specifically the section at the bottom where it talks about developing custom widgets to include on the landing page. These custom widgets are rails partials that you can place in /etc/ood/config/apps/dashboard/views/widgets/. If your plugins depend on ruby code, you can load this into the environment from a custom initializer in /etc/ood/config/apps/dashboard/initializers/. That way you can keep your plugin code together and separate from OnDemand source code.

Let me know if this works or if you have any questions, and if you want to provide more details about the plugin code you are using I could give suggestions on what those files might look like.

You also can check out the quota widget added in add a file quota widget by johrstrom · Pull Request #4206 · OSC/ondemand · GitHub and the System Status Dashboard Widget by jmeddick · Pull Request #4532 · OSC/ondemand · GitHub to see how closely they meet your needs. Both will be included in the upcoming 4.1 release, which should be out around the end of the month.

Thanks Braeden for the quick response. I was aware of the Custom Layouts in the Dashboard documentation but this requires splitting my codebase and putting stuff in different locations. Jeff mentions the ability to colocate these files in a plugin directory at /etc/ood/config/plugins which indeed seems to work (although I think is still undocumented).

While I can use /etc/ood/config/plugins well for production deployments this doesn’t work during development. I like the idea of developing the dashboard and it’s widgets through OnDemand through the production instance in a sandbox as described in Developing the OOD dashboard, but this requires me to split the code again into a million different paths. Is there a way to make a plugins directory work there as well?

I think I see what you mean. Since you can’t edit the production plugins as a developer, you can pass a new plugins path using the OOD_PLUGINS_DIRECTORY environment variable (in a .env.local file), or by setting plugins_directory: /path/to/plugins in your dashboard config YAMLs. You would have to copy over your existing (production) plugins to your new plugins directory, but be able to keep everything in one place.

This seems like the right place to ask - can separate css or javscript assets be included in plugins? It would be nice if they could be bundled in the same place but when I tested they don’t seem to be reachable from the /widgets route. Or would they need to be in the www/public directory and listed in the dashboard config?

Custom css files are located in /var/www/ood/public and should apply to every page, so as long as you use different classes to avoid redefining default dashboard styles (unless you want to of course), that should be the easiest way. The docs entry for css files is Customizations — Open OnDemand 4.1.0 documentation .

Similarly for javascript files, you can add custom files that are included with every page, so you will just need a unique tag on your plugins’ html so that it only runs on the pages you intend. This is a configuration described in ondemand.d/*.yml files — Open OnDemand 4.1.0 documentation.

Yep, thanks. I know about the public location and may end up going that route but I wondered if there was an option to keep plugin stuff all bundled together. I was getting an invalid MIME type error on trying to reach them from within the widget.

Also loading them from the html erb seems to be an option for organizing the files, by may not play nicely with the cache.

<style>
  <%= File.read("#{\__dir_\_}/accounts/assets/accounts.css").html_safe %>
</style>
...