Describe the bug
The Monitor page can reload content using AJAX. When monitor.js is executed more than once, top-level let and const declarations can throw a JavaScript redeclaration error.
Example browser console error:
Uncaught SyntaxError: Identifier 'refreshMSeconds' has already been declared
This can prevent Monitor dropdowns and filter controls from applying changes correctly after an AJAX reload.
To Reproduce
Steps to reproduce the behavior:
- Go to the Monitor tab.
- Change a Monitor filter/dropdown such as View, Size, or Refresh.
- Let the Monitor page reload content through AJAX.
- Check the browser console.
- The redeclaration error may appear and subsequent dropdown/filter changes may stop applying.
Expected behavior
The Monitor page JavaScript should be safe to execute after AJAX reloads, and Monitor dropdown/filter controls should continue working.
Screenshots
A browser console screenshot can be provided if needed.
Plugin (please complete the following information):
- Version: develop branch
- Source: github
- Identifier: Cacti/plugin_monitor develop branch
Desktop (please complete the following information):
- OS: Windows 11 / Rocky Linux server
- Browser: Chrome
- Version: latest available version
Smartphone (please complete the following information):
- Device: N/A
- OS: N/A
- Browser: N/A
- Version: N/A
Additional context
The issue appears to be caused by top-level let and const declarations in js/monitor.js.
Changing the top-level declarations to var avoids redeclaration errors when the script is executed again during AJAX reloads.
Describe the bug
The Monitor page can reload content using AJAX. When
monitor.jsis executed more than once, top-levelletandconstdeclarations can throw a JavaScript redeclaration error.Example browser console error:
Uncaught SyntaxError: Identifier 'refreshMSeconds' has already been declaredThis can prevent Monitor dropdowns and filter controls from applying changes correctly after an AJAX reload.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The Monitor page JavaScript should be safe to execute after AJAX reloads, and Monitor dropdown/filter controls should continue working.
Screenshots
A browser console screenshot can be provided if needed.
Plugin (please complete the following information):
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
The issue appears to be caused by top-level
letandconstdeclarations injs/monitor.js.Changing the top-level declarations to
varavoids redeclaration errors when the script is executed again during AJAX reloads.