mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-05-15 01:54:31 -04:00
Add monitorFilterOnChange function for AJAX filter updates on console view
Co-authored-by: connortechnology <925519+connortechnology@users.noreply.github.com>
This commit is contained in:
@@ -19,12 +19,16 @@
|
||||
//
|
||||
|
||||
function addFilterSelect($name, $options) {
|
||||
global $view;
|
||||
// Use monitorFilterOnChange on console view for AJAX refresh, submitThisForm elsewhere
|
||||
$onChangeFunction = ($view == 'console') ? 'monitorFilterOnChange' : 'submitThisForm';
|
||||
|
||||
$html = '<span class="term '.$name.'Filter"><label>'.translate($name).'</label>';
|
||||
$html .= '<span class="term-value-wrapper">';
|
||||
$html .= htmlSelect($name.'[]', $options,
|
||||
(isset($_SESSION[$name])?$_SESSION[$name]:''),
|
||||
array(
|
||||
'data-on-change'=>'submitThisForm',
|
||||
'data-on-change'=>$onChangeFunction,
|
||||
'class'=>'chosen',
|
||||
'multiple'=>'multiple',
|
||||
'data-placeholder'=>'All',
|
||||
@@ -52,8 +56,11 @@ function addButtonResetForFilterSelect($nameSelect) {
|
||||
}
|
||||
|
||||
function buildMonitorsFilters() {
|
||||
global $user, $Servers;
|
||||
global $user, $Servers, $view;
|
||||
require_once('includes/Monitor.php');
|
||||
|
||||
// Use monitorFilterOnChange on console view for AJAX refresh, submitThisForm elsewhere
|
||||
$onChangeFunction = ($view == 'console') ? 'monitorFilterOnChange' : 'submitThisForm';
|
||||
|
||||
zm_session_start();
|
||||
foreach (array('GroupId','Capturing','Analysing','Recording','ServerId','StorageId','Status','MonitorId','MonitorName','Source') as $var) {
|
||||
@@ -151,7 +158,7 @@ function buildMonitorsFilters() {
|
||||
$html .= htmlSelect('ServerId[]', $ServersById,
|
||||
(isset($_SESSION['ServerId'])?$_SESSION['ServerId']:''),
|
||||
array(
|
||||
'data-on-change'=>'submitThisForm',
|
||||
'data-on-change'=>$onChangeFunction,
|
||||
'class'=>'chosen',
|
||||
'multiple'=>'multiple',
|
||||
'data-placeholder'=>'All',
|
||||
@@ -168,7 +175,7 @@ function buildMonitorsFilters() {
|
||||
$html .= htmlSelect('StorageId[]', $StorageById,
|
||||
(isset($_SESSION['StorageId'])?$_SESSION['StorageId']:''),
|
||||
array(
|
||||
'data-on-change'=>'submitThisForm',
|
||||
'data-on-change'=>$onChangeFunction,
|
||||
'class'=>'chosen',
|
||||
'multiple'=>'multiple',
|
||||
'data-placeholder'=>'All',
|
||||
@@ -189,7 +196,7 @@ function buildMonitorsFilters() {
|
||||
$html .= htmlSelect( 'Status[]', $status_options,
|
||||
( isset($_SESSION['Status']) ? $_SESSION['Status'] : '' ),
|
||||
array(
|
||||
'data-on-change'=>'submitThisForm',
|
||||
'data-on-change'=>$onChangeFunction,
|
||||
'class'=>'chosen',
|
||||
'multiple'=>'multiple',
|
||||
'data-placeholder'=>'All'
|
||||
@@ -296,7 +303,7 @@ function buildMonitorsFilters() {
|
||||
$html .= '<span class="term-value-wrapper">';
|
||||
$html .= htmlSelect('MonitorId[]', $monitors_dropdown, $selected_monitor_ids,
|
||||
array(
|
||||
'data-on-change'=>'submitThisForm',
|
||||
'data-on-change'=>$onChangeFunction,
|
||||
'class'=>'chosen',
|
||||
'multiple'=>'multiple',
|
||||
'data-placeholder'=>'All',
|
||||
|
||||
@@ -384,6 +384,17 @@ function manageFunctionModal(evt) {
|
||||
$j('#modalFunction').modal('show');
|
||||
} // end function manageFunctionModal
|
||||
|
||||
// Called when monitor filters change - refreshes table via AJAX instead of full page reload
|
||||
function monitorFilterOnChange() {
|
||||
// On console view with bootstrap-table, just refresh the table
|
||||
if (typeof table !== 'undefined' && table.length) {
|
||||
table.bootstrapTable('refresh');
|
||||
} else {
|
||||
// Fall back to full page reload on other views
|
||||
submitThisForm();
|
||||
}
|
||||
}
|
||||
|
||||
function initPage() {
|
||||
// Init the bootstrap-table
|
||||
table.bootstrapTable({icons: icons});
|
||||
|
||||
Reference in New Issue
Block a user