Help with developing Widget

Started by Droid999, August 03, 2024, 01:56:53 AM

Previous topic - Next topic
August 03, 2024, 01:56:53 AM Last Edit: August 03, 2024, 04:51:54 AM by Droid999
Hi

Is there a tutorial / hello world  / sample  on how to develop a widget for 24.7?

Thanks

Edit 1:

Where can I find debug / error messages that I might be generating while trying to get this new widget working?

Nothing is showing up in System > Log files ( Debug ) > Backend / General.


August 03, 2024, 05:42:05 AM #1 Last Edit: August 03, 2024, 05:53:16 AM by Monviech
Here is a widget I made recently:

https://github.com/opnsense/plugins/commit/dd68ab68d88c5afd355a1662cfc4bcb44117a4ed

Esentially you check out what kind of information an API has, and then show it in a widget.

Here are some of the methods explained:

https://github.com/opnsense/docs/blob/7d69a107ab87146bd91373485ecfa5c49c8be26d/source/development/frontend/dashboard.rst


An even easier example widget where the api doesnt serve an array with uuids, but only one option:

https://github.com/opnsense/plugins/blob/master/security/etpro-telemetry/src/opnsense/www/js/widgets/ETProTelemetry.js


When widgets fail to load the console log in the browser is your friend.
Hardware:
DEC740

I got a custom widget working by placing my .js file in
/usr/local/opnsense/www/js/widgets/
And adding an entry to /usr/local/opnsense/www/js/widgets/Metadata/Core.xml

However a minor OPNsense update reverted my Core.xml changes. Is there a method that persists through updates?

Yes certainly, check out the first link above.
Hardware:
DEC740

Ah, so creating my own xml in /usr/local/opnsense/www/js/widgets/Metadata/ is the way.

Thanks!

Quote from: Monviech on August 03, 2024, 05:42:05 AM
When widgets fail to load the console log in the browser is your friend.

Yes indeed - my new BEST friend.

Thanks for the pointers - got the plugin written and working.

Cheers

Good job, but now there is already another one for UPS in a pull request too.

Which one will make it in? Yours or the other? Tune in next time for battle of the widgets.  ;D

https://github.com/opnsense/plugins/pull/4150
Hardware:
DEC740