raspap-webgui icon indicating copy to clipboard operation
raspap-webgui copied to clipboard

[Feature request] - Add auto-close to Bootstrap alerts

Open ruralmeltdown opened this issue 5 months ago • 5 comments

At present, when Bootstrap alerts are shown in RaspAP Web UI, they persist until the user manually closes each one, or the user navigates away from the page they are on. From some searches, it seems there is an ability to add some Javascript that would auto-close them after a period of time; working example with code (not saying to use this one, just sharing one I found): https://codepen.io/CSWApps/pen/XJoLmN

Note: some users may want them to persist, so maybe having a user setting for the timeout length?

ruralmeltdown avatar Jul 23 '25 01:07 ruralmeltdown

@billz I tested the code I linked above in my 3.3.6 instance, and it worked as expected (in custom.js). I can push that up in a PR if you are fine without having a user definable setting? I tried adding some code in my instance for that, and was able to get a field to show up (chose the System > Advanced page for simplicity), but couldn't figure out setting the value, and persisting it to the Javascript.

ruralmeltdown avatar Jul 24 '25 00:07 ruralmeltdown

@ruralmeltdown this is a really nice enhancement. I'd say go ahead and push it to a new PR. A user-definable setting can be added to System > Advanced post-merge.

One thing to note is that custom.js was split into two .js files in #1905 :

/app/js
   /ajax/main.js
   /ui/main.js

This was merged to the master branch but is not released yet. So your PR should merge master, or simply checkout master, do a git pull, check out your feature branch, then add your changes to /app/js/ui/main.js. Hope this makes sense. Ping me on Discord if you encounter any strangeness :)

billz avatar Jul 24 '25 13:07 billz

PR: https://github.com/RaspAP/raspap-webgui/pull/1916

ruralmeltdown avatar Jul 24 '25 14:07 ruralmeltdown

@ruralmeltdown you are on 🔥

billz avatar Jul 24 '25 17:07 billz

It's worth noting that this implementation applies to all Bootstrap alerts, which I just noticed includes the ones on the data usage page; which I've noticed can sometimes take longer than the artificially picked 5 seconds - not sure if there's a way to have those excluded from the timeout, or to just lengthen the timeout a little bit?

ruralmeltdown avatar Jul 24 '25 23:07 ruralmeltdown