Skip to content

monitor.js throws redeclaration error after AJAX reload #220

Description

@godmafiaze

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:

  1. Go to the Monitor tab.
  2. Change a Monitor filter/dropdown such as View, Size, or Refresh.
  3. Let the Monitor page reload content through AJAX.
  4. Check the browser console.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions