Skip to content

Feat: Added <select> to control enabling players on Monitor page#4428

Open
IgorA100 wants to merge 23 commits intoZoneMinder:masterfrom
IgorA100:patch-439137
Open

Feat: Added <select> to control enabling players on Monitor page#4428
IgorA100 wants to merge 23 commits intoZoneMinder:masterfrom
IgorA100:patch-439137

Conversation

@IgorA100
Copy link
Copy Markdown
Contributor

@IgorA100 IgorA100 commented Aug 26, 2025

The code implements support for disabling ALL players, including "ZMS MJPEG", but the UI does not currently use disabling all players. Because at the moment I am not sure that it is necessary to disable all players.
To implement enabling/disabling "ZMS MJPEG" you need to uncomment some lines of code and add a field to the DB ALTER TABLE MonitorsADD COLUMNZMSEnabledBOOLEAN NOT NULL default true AFTERDecoding``

It looks like this: #4393 (comment)

Also added the ability for <input> to use ".disabled", because if you use the "disabled" attribute for <input>, then the value of <input> will not be used in the form. And now, if you add the "disabled" class, then the value of <input> will be used in the form, but you cannot change its value manually in the UI.

If this PR is approved, then in the future you can remove the checkboxes for controlling player enablement from the UI and visually combine the options into the Go2RTC, RTSP2Web & Janus groups

I'm not sure about the feasibility of this PR, but I had some ideas and decided to publish them. Probably, choosing to enable/disable players in one place (in "multi select") is better than many checkboxes.

@IgorA100 IgorA100 marked this pull request as ready for review August 26, 2025 21:42
@IgorA100 IgorA100 marked this pull request as draft September 2, 2025 15:40
@IgorA100 IgorA100 marked this pull request as ready for review September 2, 2025 15:50
@IgorA100
Copy link
Copy Markdown
Contributor Author

IgorA100 commented Sep 9, 2025

This PR is not needed?

@IgorA100
Copy link
Copy Markdown
Contributor Author

@connortechnology
Haven't you watched this PR yet?
I'm interested in your opinion.

@connortechnology
Copy link
Copy Markdown
Member

It is not clear to me why we would want to disable ZMS playback. The .disabled stuff makes sense.

@IgorA100
Copy link
Copy Markdown
Contributor Author

IgorA100 commented Dec 10, 2025

disable ZMS playback

This PR does NOT disable ZMS playback!
The code to disable ZMS playback does exist, but it's locked!

At first, I thought about disabling all players, including ZMS, but I later realized that wasn't necessary and locked the code.

This PR changes the player selection style. I plan to remove the checkboxes (which are quite confusing if there are more than two players) and switch to multi-select. I think it will be more convenient and look better.

@IgorA100
Copy link
Copy Markdown
Contributor Author

IgorA100 commented Feb 5, 2026

@connortechnology
Should I test this PR on the current version of ZM?
Or should I close this PR?

It's been almost six months, and I can't figure out what to do with this PR...

@connortechnology
Copy link
Copy Markdown
Member

It is still not clear to me why we need it. Why would we want to disable zms?

@IgorA100
Copy link
Copy Markdown
Contributor Author

IgorA100 commented Feb 5, 2026

It is still not clear to me why we need it.

This PR will allow users to select available players using multi-select, rather than the current checkboxes. The checkboxes themselves will remain visible for now, but they are disabled for editing. In the future, the checkboxes could be completely removed by revising the page layout.

Why would we want to disable zms?

We are NOT disabling ZMS in this PR!!!

333

@IgorA100
Copy link
Copy Markdown
Contributor Author

IgorA100 commented Feb 6, 2026

@connortechnology
The main idea is to get rid of the checkboxes, of which there are already many on the page, and make the selection of available players via multi-select. ZMS is NOT disabled!!!

@IgorA100
Copy link
Copy Markdown
Contributor Author

@connortechnology
Don't you like the idea of ​​using multi-select controls instead of checkboxes?
I think it's more convenient and looks better.
ZMS is NOT disabled!!!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a multi-select dropdown (<select multiple>) to the Monitor configuration page's "viewing" tab, allowing users to enable/disable streaming players (Go2RTC, RTSP2Web, Janus) from a single control instead of individual checkboxes. It also introduces a CSS .disabled class mechanism for inputs that visually disables them while still including their values in form submissions. The ZMS MJPEG player is shown as always-selected and disabled in the dropdown. Much of the ZMS toggle functionality is commented out, pending a future database schema change.

Changes:

  • Added a multi-select player control (SelectPlayers) in the monitor viewing tab that syncs with existing player-enabled checkboxes, with supporting JavaScript functions for bidirectional state management.
  • Introduced a .disabled CSS class for checkbox/radio inputs that mimics the native disabled attribute visually but still submits form values.
  • Added ZMSEnabled field references in the monitor action handler and model (commented out in the model), as groundwork for future ZMS toggle support.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
web/skins/classic/views/monitor.php Adds SelectPlayers multi-select dropdown and related PHP logic for building player options and initial selection state
web/skins/classic/views/js/monitor.js Adds JavaScript functions to manage the multi-select ↔ checkbox synchronization and disable checkbox manual interaction
web/skins/classic/js/skin.js Adds click prevention handler for input.disabled class in the global page initialization
web/skins/classic/css/base/skin.css Extends existing :disabled CSS rules to also apply to .disabled class for checkboxes and radios
web/includes/actions/monitor.php Adds ZMSEnabled to the checkbox defaults $types array
web/includes/Monitor.php Adds commented-out ZMSEnabled field to the Monitor model defaults

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

'Enabled' => 0,
'Deleted' => 0,
'DecodingEnabled' => 0,
'ZMSEnabled' => 0,
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZMSEnabled is added here as a checkbox default type, but ZMSEnabled is commented out in Monitor.php's $defaults array (line 234). The Object::changes() method only includes fields that exist in $this->defaults (see web/includes/Object.php:316), so this field will never actually be persisted to the database. Additionally, the ZMSEnabled column doesn't exist in the database schema (it requires a manual ALTER TABLE as mentioned in the PR description). This means the form will submit ZMSEnabled=0 on every save, and the $monitor->changes() call could potentially produce unexpected behavior when it encounters a field that doesn't exist in the monitor object.

Either remove this line (keeping it consistent with the commented-out model definition), or uncomment the model definition and add the corresponding database migration.

Suggested change
'ZMSEnabled' => 0,

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave the line commented out, in case we need to disable ZMS someday.

Comment on lines +1252 to +1287
@@ -1258,6 +1277,14 @@ class="nav-link<?php echo ($tab == $name ? ' active' : '') . ' ' . (($name == 'z
<label><?php echo translate('RTSPStreamName'); echo makeHelpLink('OPTIONS_RTSPSTREAMNAME') ?></label>
<input type="text" name="newMonitor[RTSPStreamName]" value="<?php echo validHtmlStr($monitor->RTSPStreamName()) ?>"/>
</li>
<li id="SelectPlayers" class="SelectPlayers">
<label><?php echo translate('Select players'); echo makeHelpLink('OPTIONS_SELECTPLAYERS') ?> </label>
<?php echo htmlSelect('SelectPlayers', $selectPlayers, $selectedPlayers, ['class'=>'chosen chosen-full-width', 'multiple'=>'', 'data-on-change'=>'selectPlayers', 'none-exists'=>$noneExists]); ?>
</li>
<!--<li id="FunctionZMSEnabled" class='hidden-shift'>
<label><?php //echo translate('ZMS MJPEG') ?></label>
<input type="checkbox" name="newMonitor[ZMSEnabled]" value="1"<?php //echo $monitor->ZMSEnabled() ? ' checked="checked"' : '' ?> class="hidden-shift0"/>
</li>-->
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a significant amount of commented-out code throughout this PR (lines 1257, 1259-1266, 1284-1287). This makes the code harder to read and maintain. If this code represents planned future functionality (as the PR description suggests), it would be better to either:

  1. Not include the commented-out code and implement it fully in a future PR when the DB schema change is ready.
  2. At minimum, add clear TODO or FIXME comments explaining what these blocks are for and what prerequisite (DB migration) is needed.

The commented-out HTML block on lines 1284-1287 still contains PHP code inside an HTML comment (<!--...-->), which means the PHP code will execute server-side even though the output is hidden from the DOM. The // inside the <?php ?> tags prevents execution, but this pattern is fragile.

Copilot uses AI. Check for mistakes.
…s/js/monitor.js


As recommended by Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@IgorA100 IgorA100 marked this pull request as draft March 5, 2026 08:08
@IgorA100
Copy link
Copy Markdown
Contributor Author

IgorA100 commented Mar 5, 2026

I'll analyze Copilot's recommendations.

@IgorA100
Copy link
Copy Markdown
Contributor Author

IgorA100 commented Mar 9, 2026

@connortechnology
I decided to slightly modify the code and added the $enableDisableZMS variable to the "Monitor" class and handle this variable.
This allowed me to avoid the commented code.

For $enableDisableZMS = false, the DB can be left unchanged.
For $enableDisableZMS = true, you need to change the BD by running the following code:
ALTER TABLE MonitorsADD COLUMNZMSEnabledBOOLEAN NOT NULL default true AFTERDecoding``

Actually, at the moment, even with $enableDisableZMS = true and the DB change, ZMS will still work. In other words, ZMS functionality doesn't change at all. Only the UI changes.

If you have any questions, ask them, and I'll answer them.

@IgorA100 IgorA100 marked this pull request as ready for review March 9, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants