Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Attempting to write NUT UPS Status widget for Dashboard

    Scheduled Pinned Locked Moved Development
    6 Posts 6 Posters 4.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tweek
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • S
        Seth
        last edited by

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

        Thanks

        1 Reply Last reply Reply Quote 0
        • E
          ericab
          last edited by

          i too am interested in this

          1 Reply Last reply Reply Quote 0
          • F
            feadin
            last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • L
              LostInIgnorance
              last edited by

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

              1 Reply Last reply Reply Quote 0
              • _Adrian__
                _Adrian_
                last edited by

                Is this for USB or Serial UPS ??

                If it ain't broken, fix it till it is :P

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.