Attempting to write NUT UPS Status widget for Dashboard



  • I'm trying to write a Dashboard widget for the NUT package.  I've got it to display the data I want but the data is static and won't update the changing data using that AJAX magic.  Most of the data I want to see update (Status, Battery Charge, Runtime Remaining, Battery Voltage) is getting pulled using a popen call and parsed into an array from which I grab the individual data items.  Can I get these data items within the widget to refresh automatically?

    If someone needs me to post my code just let me know…most of it is just lightly modified code from the NUT package's status_nut.php file.  I'm assuming my problem is simply my lack of understanding of the process of how the Dashboard's AJAX data items get refreshed.  If anyone could point me to documentation of how this works I'd happily read it and figure this out myself.

    Sorry in advance for my other post in webGUI...I got no response there so I re-posted this here assuming my request belongs here in the Development thread.



  • By chance is there an update/progress on this widget?

    Thanks



  • i too am interested in this



  • Ok better late than never I guess…
    I wanted to do some changes to the system info dashboard so I had to learn how to do it. Not sure if I'm missing something though, so remember this is on my experience, not following any official documentation here.

    1- You must put the data to be updated inside a container, like a div with a unique id.
    2- In /usr/local/www/includes/functions.inc.php: Create new get_*() function and call it from function get_stats()
    3- In /usr/local/www/javascript/index/ajax.js: Create new JS function and call it from function stats()

    Just copy any existing function in those files and modify it as needed. Oh and you'll want to move the data gathering code to that new function in functions.inc.php and call it from the widget as well. This means, at first when the main dashboard page loads, it gathers the data from the widget file, and then all updates are made directly from the functions.inc.php file using ajax (not the cleanest piece of code but it works anyway).
    Hope you can get it done, or at least share the code you already have so somebody can finish it  ;)

    @tweek:

    I'm trying to write a Dashboard widget for the NUT package.  I've got it to display the data I want but the data is static and won't update the changing data using that AJAX magic.  Most of the data I want to see update (Status, Battery Charge, Runtime Remaining, Battery Voltage) is getting pulled using a popen call and parsed into an array from which I grab the individual data items.  Can I get these data items within the widget to refresh automatically?

    If someone needs me to post my code just let me know…most of it is just lightly modified code from the NUT package's status_nut.php file.  I'm assuming my problem is simply my lack of understanding of the process of how the Dashboard's AJAX data items get refreshed.  If anyone could point me to documentation of how this works I'd happily read it and figure this out myself.

    Sorry in advance for my other post in webGUI...I got no response there so I re-posted this here assuming my request belongs here in the Development thread.



  • Tweek, Can you post the code?  Be interested in adding it.



  • Is this for USB or Serial UPS ??


Locked