APC UPS new plugin

Started by Droid999, February 13, 2021, 05:04:01 AM

Previous topic - Next topic
Great work on creating a new widget! I followed the instructions but I get "Failed to load widget" showing in the widget frame. I tried refreshing, removing and re-adding, logging out and in, and rebooting, none of which fixed the issue.

Interestingly, during the reboot process, the dashboard was initially showing (before the APC UPS Daemon had started) "Unable to connect", so at that point the widget was working. Then, after reboot was complete and all the services had started, the widget is back to "Failed to load widget".
OPNsense 24.7.7-amd64 on APU2E4 using ZFS

Droid999, thank you for this, I've really missed this widget since update!

Quote from: beneix on August 07, 2024, 04:25:26 PM
I followed the instructions but I get "Failed to load widget" showing in the widget frame.

The culprit was this line in my case:

rows.push([this.translations['t_int_temp'], this.data['status']['ITEMP']['value']]);

Apcupsd status page does not report the ITEMP metric, which leads to js error.
I've simply commented the line out and now the widget works perfectly fine!

You can try to determine the culprit in your case by opening dev console, which might have an error similar to the one I had:

Failed to load content for widget: Apcupsd, Error:
TypeError: undefined is not an object (evaluating 'this.data['status']['ITEMP']['value']')

In this case, open the Apcupsd.js, find the line mentioned in the error message and remove / comment it out.

We have a bit of a luxurious situation at the moment with 2 concurrent pull requests for a dashboard widget for the apcupsd plugin. I'm sure we can bring one in for 24.7.2 but for 24.7.1 please don't be disappointed the decision is still in the future and the release build needs to be wrapped up now.

And of course thanks to both contributors!


Cheers,
Franco

Quote from: mickgotwings on August 07, 2024, 05:39:10 PM
The culprit was this line in my case:

rows.push([this.translations['t_int_temp'], this.data['status']['ITEMP']['value']]);

Apcupsd status page does not report the ITEMP metric, which leads to js error.
I've simply commented the line out and now the widget works perfectly fine!
Thanks! I had two values that were not in my apcupsd list, so I removed the corresponding lines. Since I also wanted to add the remaining battery percentage, I added a line both to the Apcupsd.js and Apcupsd.xml with that, now it all works!

Quote
You can try to determine the culprit in your case by opening dev console
Basic question: can I look at the dev console via SSH, or do I need to use the serial console?

I just went to the Services > Apcupsd > Status page and looked there at what values were available and determined that way which the culprits were.
OPNsense 24.7.7-amd64 on APU2E4 using ZFS

Quote from: beneix on August 07, 2024, 06:22:51 PM
Quote
You can try to determine the culprit in your case by opening dev console
Basic question: can I look at the dev console via SSH, or do I need to use the serial console?

If I am not entirely mistaken they are referring to the browser dev console.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

The maintainer's submission was merged for 24.7.1. Details in https://github.com/opnsense/plugins/pull/4150


Cheers,
Franco

for me it works like a charm. thanks

I just updated to 24.7.1. Now I have a blank widget where my APC widget used to be. I can then use GUI to add the APCUPSd widget, which shows successfully next to the blank widget, but when I click "Save" the button just shows a spinning wheel and upon refresh I'm back to the single blank widget. The blank widget can be resized and moved but it does not show the normal delete button so I can't get rid of it.

Any suggestions?
OPNsense 24.7.7-amd64 on APU2E4 using ZFS

Remove both widgets from dashboard and save. Remove manual files created from disk. Add widget. Done.


Cheers,
Franco

Quote from: franco on August 09, 2024, 10:46:26 AM
Remove both widgets from dashboard and save. Remove manual files created from disk. Add widget. Done.


Cheers,
Franco

Thanks, but
QuoteThe blank widget can be resized and moved but it does not show the normal delete button so I can't get rid of it.
...so how can I remove it? I tried deleting the relevant files from /usr/local/opnsense/www/js/widgets and /usr/local/opnsense/www/js/widgets/Metadata, but that does not get rid of the blank widget and also means that the Apcupsd widget is not an option in the drop-down list for "Add Widget".
OPNsense 24.7.7-amd64 on APU2E4 using ZFS

For the blank widget to vanish you have to press "Restore default layout", since the name of the widget has been saved inside the config.xml of the firewall.
Hardware:
DEC740

Quote from: Monviech on August 09, 2024, 12:13:22 PM
For the blank widget to vanish you have to press "Restore default layout", since the name of the widget has been saved inside the config.xml of the firewall.
That worked, thanks. All good now.
OPNsense 24.7.7-amd64 on APU2E4 using ZFS

Hmm, it would be beneficial of "bad" widgets show a working close button to get rid of them? At least that's what I thought it would do. :)


Cheers,
Franco

Quote from: franco on August 09, 2024, 12:42:48 PM
Hmm, it would be beneficial of "bad" widgets show a working close button to get rid of them? At least that's what I thought it would do. :)


Cheers,
Franco
Yes...inspecting in Firefox, it seems the section
<div class="grid-stack-item size-to-content ui-resizable-autohide" gs-x="2" gs-y="532" gs-w="2" gs-h="307" gs-id="Apcupsd">
<div class="grid-stack-item-content">


was missing something like this, which was present in the other widgets' code:
<div id="close-handle-interfacestatistics" class="close-handle">
                        <i class="fa fa-times fa-xs"></i>
                    </div>


...but I would not know why.
OPNsense 24.7.7-amd64 on APU2E4 using ZFS

Probably ordering issue in the dashboard code. We'll sort this out.


Cheers,
Franco