Merge pull request #2839 from connortechnology/add_alarmed_zone_to_filters
Add alarmed zone to filterspull/2874/head
commit
ade95283d9
|
@ -1,6 +1,6 @@
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
#
|
#
|
||||||
# ZoneMinder Filter Module, $Date$, $Revision$
|
# ZoneMinder Filter Module
|
||||||
# Copyright (C) 2001-2008 Philip Coombes
|
# Copyright (C) 2001-2008 Philip Coombes
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
|
@ -162,7 +162,9 @@ sub Sql {
|
||||||
my $value = $term->{val};
|
my $value = $term->{val};
|
||||||
my @value_list;
|
my @value_list;
|
||||||
if ( $term->{attr} ) {
|
if ( $term->{attr} ) {
|
||||||
if ( $term->{attr} =~ /^Monitor/ ) {
|
if ( $term->{attr} eq 'AlarmedZoneId' ) {
|
||||||
|
$term->{op} = 'EXISTS';
|
||||||
|
} elsif ( $term->{attr} =~ /^Monitor/ ) {
|
||||||
my ( $temp_attr_name ) = $term->{attr} =~ /^Monitor(.+)$/;
|
my ( $temp_attr_name ) = $term->{attr} =~ /^Monitor(.+)$/;
|
||||||
$self->{Sql} .= 'M.'.$temp_attr_name;
|
$self->{Sql} .= 'M.'.$temp_attr_name;
|
||||||
} elsif ( $term->{attr} eq 'ServerId' or $term->{attr} eq 'MonitorServerId' ) {
|
} elsif ( $term->{attr} eq 'ServerId' or $term->{attr} eq 'MonitorServerId' ) {
|
||||||
|
@ -214,7 +216,10 @@ sub Sql {
|
||||||
|
|
||||||
( my $stripped_value = $value ) =~ s/^["\']+?(.+)["\']+?$/$1/;
|
( my $stripped_value = $value ) =~ s/^["\']+?(.+)["\']+?$/$1/;
|
||||||
foreach my $temp_value ( split( /["'\s]*?,["'\s]*?/, $stripped_value ) ) {
|
foreach my $temp_value ( split( /["'\s]*?,["'\s]*?/, $stripped_value ) ) {
|
||||||
if ( $term->{attr} =~ /^MonitorName/ ) {
|
|
||||||
|
if ( $term->{attr} eq 'AlarmedZoneId' ) {
|
||||||
|
$value = '(SELECT * FROM Stats WHERE EventId=E.Id AND ZoneId='.$value.')';
|
||||||
|
} elsif ( $term->{attr} =~ /^MonitorName/ ) {
|
||||||
$value = "'$temp_value'";
|
$value = "'$temp_value'";
|
||||||
} elsif ( $term->{attr} =~ /ServerId/) {
|
} elsif ( $term->{attr} =~ /ServerId/) {
|
||||||
Debug("ServerId, temp_value is ($temp_value) ($ZoneMinder::Config::Config{ZM_SERVER_ID})");
|
Debug("ServerId, temp_value is ($temp_value) ($ZoneMinder::Config::Config{ZM_SERVER_ID})");
|
||||||
|
@ -256,6 +261,8 @@ sub Sql {
|
||||||
} elsif ( $term->{attr} eq 'Date' or $term->{attr} eq 'StartDate' or $term->{attr} eq 'EndDate' ) {
|
} elsif ( $term->{attr} eq 'Date' or $term->{attr} eq 'StartDate' or $term->{attr} eq 'EndDate' ) {
|
||||||
if ( $temp_value eq 'NULL' ) {
|
if ( $temp_value eq 'NULL' ) {
|
||||||
$value = $temp_value;
|
$value = $temp_value;
|
||||||
|
} elsif ( $temp_value eq 'CURDATE()' or $temp_value eq 'NOW()' ) {
|
||||||
|
$value = 'to_days('.$temp_value.')';
|
||||||
} else {
|
} else {
|
||||||
$value = DateTimeToSQL($temp_value);
|
$value = DateTimeToSQL($temp_value);
|
||||||
if ( !$value ) {
|
if ( !$value ) {
|
||||||
|
@ -294,6 +301,8 @@ sub Sql {
|
||||||
} else {
|
} else {
|
||||||
$self->{Sql} .= " IS $value";
|
$self->{Sql} .= " IS $value";
|
||||||
}
|
}
|
||||||
|
} elsif ( $term->{op} eq 'EXISTS' ) {
|
||||||
|
$self->{Sql} .= " EXISTS $value";
|
||||||
} elsif ( $term->{op} eq 'IS NOT' ) {
|
} elsif ( $term->{op} eq 'IS NOT' ) {
|
||||||
$self->{Sql} .= " IS NOT $value";
|
$self->{Sql} .= " IS NOT $value";
|
||||||
} elsif ( $term->{op} eq '=[]' ) {
|
} elsif ( $term->{op} eq '=[]' ) {
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
namespace ZM;
|
||||||
|
require_once('database.php');
|
||||||
|
require_once('Object.php');
|
||||||
|
|
||||||
|
|
||||||
|
class Zone extends ZM_Object {
|
||||||
|
protected static $table = 'Zones';
|
||||||
|
|
||||||
|
protected $defaults = array(
|
||||||
|
'Id' => null,
|
||||||
|
'Name' => '',
|
||||||
|
'Type' => 'Active',
|
||||||
|
'Units' => 'Pixels',
|
||||||
|
'CheckMethod' => 'Blobs',
|
||||||
|
'MinPixelThreshold' => null,
|
||||||
|
'MaxPixelThreshold' => null,
|
||||||
|
'MinAlarmPixels' => null,
|
||||||
|
'MaxAlarmPixels' => null,
|
||||||
|
'FilterX' => null,
|
||||||
|
'FilterY' => null,
|
||||||
|
'MinFilterPixels' => null,
|
||||||
|
'MaxFilterPixels' => null,
|
||||||
|
'MinBlobPixels' => null,
|
||||||
|
'MaxBlobPixels' => null,
|
||||||
|
'MinBlobs' => null,
|
||||||
|
'MaxBlobs' => null,
|
||||||
|
'OverloadFrames' => 0,
|
||||||
|
'ExtendAlarmFrames' => 0,
|
||||||
|
);
|
||||||
|
|
||||||
|
public static function find( $parameters = array(), $options = array() ) {
|
||||||
|
return ZM_Object::_find(get_class(), $parameters, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function find_one( $parameters = array(), $options = array() ) {
|
||||||
|
return ZM_Object::_find_one(get_class(), $parameters, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
} # end class Zone
|
||||||
|
?>
|
|
@ -1094,6 +1094,7 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') {
|
||||||
for ( $i = 0; $i < count($terms); $i++ ) {
|
for ( $i = 0; $i < count($terms); $i++ ) {
|
||||||
|
|
||||||
$term = $terms[$i];
|
$term = $terms[$i];
|
||||||
|
ZM\Logger::Debug("Term: " . print_r($term,true));
|
||||||
|
|
||||||
if ( isset($term['cnj']) && array_key_exists($term['cnj'], $validQueryConjunctionTypes) ) {
|
if ( isset($term['cnj']) && array_key_exists($term['cnj'], $validQueryConjunctionTypes) ) {
|
||||||
$filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][cnj]").'='.urlencode($term['cnj']);
|
$filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][cnj]").'='.urlencode($term['cnj']);
|
||||||
|
@ -1109,6 +1110,9 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') {
|
||||||
$filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][attr]").'='.urlencode($term['attr']);
|
$filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][attr]").'='.urlencode($term['attr']);
|
||||||
$filter['fields'] .= "<input type=\"hidden\" name=\"filter[Query][terms][$i][attr]\" value=\"".htmlspecialchars($term['attr'])."\"/>\n";
|
$filter['fields'] .= "<input type=\"hidden\" name=\"filter[Query][terms][$i][attr]\" value=\"".htmlspecialchars($term['attr'])."\"/>\n";
|
||||||
switch ( $term['attr'] ) {
|
switch ( $term['attr'] ) {
|
||||||
|
case 'AlarmedZoneId':
|
||||||
|
$term['op'] = 'EXISTS';
|
||||||
|
break;
|
||||||
case 'MonitorName':
|
case 'MonitorName':
|
||||||
$filter['sql'] .= 'M.Name';
|
$filter['sql'] .= 'M.Name';
|
||||||
break;
|
break;
|
||||||
|
@ -1226,11 +1230,15 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') {
|
||||||
$valueList = array();
|
$valueList = array();
|
||||||
foreach ( preg_split('/["\'\s]*?,["\'\s]*?/', preg_replace('/^["\']+?(.+)["\']+?$/', '$1', $term['val'])) as $value ) {
|
foreach ( preg_split('/["\'\s]*?,["\'\s]*?/', preg_replace('/^["\']+?(.+)["\']+?$/', '$1', $term['val'])) as $value ) {
|
||||||
switch ( $term['attr'] ) {
|
switch ( $term['attr'] ) {
|
||||||
|
|
||||||
|
case 'AlarmedZoneId':
|
||||||
|
$value = '(SELECT * FROM Stats WHERE EventId=E.Id AND ZoneId='.$value.')';
|
||||||
|
break;
|
||||||
case 'MonitorName':
|
case 'MonitorName':
|
||||||
case 'Name':
|
case 'Name':
|
||||||
case 'Cause':
|
case 'Cause':
|
||||||
case 'Notes':
|
case 'Notes':
|
||||||
if($term['op'] == 'LIKE' || $term['op'] == 'NOT LIKE') {
|
if ( $term['op'] == 'LIKE' || $term['op'] == 'NOT LIKE' ) {
|
||||||
$value = '%'.$value.'%';
|
$value = '%'.$value.'%';
|
||||||
}
|
}
|
||||||
$value = dbEscape($value);
|
$value = dbEscape($value);
|
||||||
|
@ -1261,8 +1269,11 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') {
|
||||||
case 'Date':
|
case 'Date':
|
||||||
case 'StartDate':
|
case 'StartDate':
|
||||||
case 'EndDate':
|
case 'EndDate':
|
||||||
if ( $value != 'NULL' )
|
if ( $value == 'CURDATE()' or $value == 'NOW()' ) {
|
||||||
$value = 'to_days(\''.strftime(STRF_FMT_DATETIME_DB, strtotime($value)).'\')';
|
$value = 'to_days('.$value.')';
|
||||||
|
} else if ( $value != 'NULL' ) {
|
||||||
|
$value = 'to_days(\''.strftime(STRF_FMT_DATETIME_DB, strtotime($value)).'\')';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'Time':
|
case 'Time':
|
||||||
case 'StartTime':
|
case 'StartTime':
|
||||||
|
@ -1297,10 +1308,13 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') {
|
||||||
break;
|
break;
|
||||||
case '=[]' :
|
case '=[]' :
|
||||||
case 'IN' :
|
case 'IN' :
|
||||||
$filter['sql'] .= ' in ('.join(',', $valueList).')';
|
$filter['sql'] .= ' IN ('.join(',', $valueList).')';
|
||||||
break;
|
break;
|
||||||
case '![]' :
|
case '![]' :
|
||||||
$filter['sql'] .= ' not in ('.join(',', $valueList).')';
|
$filter['sql'] .= ' not in ('.join(',', $valueList).')';
|
||||||
|
break;
|
||||||
|
case 'EXISTS' :
|
||||||
|
$filter['sql'] .= ' EXISTS ' .$value;
|
||||||
break;
|
break;
|
||||||
case 'IS' :
|
case 'IS' :
|
||||||
if ( $value == 'Odd' ) {
|
if ( $value == 'Odd' ) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ if ( version_compare(phpversion(), '4.1.0', '<') ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Useful debugging lines for mobile devices
|
// Useful debugging lines for mobile devices
|
||||||
if ( false ) {
|
if ( true ) {
|
||||||
ob_start();
|
ob_start();
|
||||||
phpinfo(INFO_VARIABLES);
|
phpinfo(INFO_VARIABLES);
|
||||||
$fp = fopen('/tmp/env.html', 'w+');
|
$fp = fopen('/tmp/env.html', 'w+');
|
||||||
|
@ -71,7 +71,7 @@ define('ZM_BASE_URL', '');
|
||||||
|
|
||||||
require_once('includes/functions.php');
|
require_once('includes/functions.php');
|
||||||
if ( $_SERVER['REQUEST_METHOD'] == 'OPTIONS' ) {
|
if ( $_SERVER['REQUEST_METHOD'] == 'OPTIONS' ) {
|
||||||
ZM\Logger::Debug("OPTIONS Method, only doing CORS");
|
ZM\Logger::Debug('OPTIONS Method, only doing CORS');
|
||||||
# Add Cross domain access headers
|
# Add Cross domain access headers
|
||||||
CORSHeaders();
|
CORSHeaders();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -116,6 +116,7 @@ $SLANG = array(
|
||||||
'Area' => 'Area',
|
'Area' => 'Area',
|
||||||
'AreaUnits' => 'Area (px/%)',
|
'AreaUnits' => 'Area (px/%)',
|
||||||
'AttrAlarmFrames' => 'Alarm Frames',
|
'AttrAlarmFrames' => 'Alarm Frames',
|
||||||
|
'AttrAlarmedZone' => 'Alarmed Zone',
|
||||||
'AttrArchiveStatus' => 'Archive Status',
|
'AttrArchiveStatus' => 'Archive Status',
|
||||||
'AttrAvgScore' => 'Avg. Score',
|
'AttrAvgScore' => 'Avg. Score',
|
||||||
'AttrCause' => 'Cause',
|
'AttrCause' => 'Cause',
|
||||||
|
|
|
@ -191,21 +191,25 @@ while ( $event_row = dbFetchNext($results) ) {
|
||||||
?>
|
?>
|
||||||
<tr<?php if ($event->Archived()) echo ' class="archived"' ?>>
|
<tr<?php if ($event->Archived()) echo ' class="archived"' ?>>
|
||||||
<td class="colId"><a href="?view=event&eid=<?php echo $event->Id().$filterQuery.$sortQuery.'&page=1">'.$event->Id().($event->Archived()?'*':'') ?></a></td>
|
<td class="colId"><a href="?view=event&eid=<?php echo $event->Id().$filterQuery.$sortQuery.'&page=1">'.$event->Id().($event->Archived()?'*':'') ?></a></td>
|
||||||
<td class="colName"><a href="?view=event&eid=<?php echo $event->Id().$filterQuery.$sortQuery.'&page=1">'.validHtmlStr($event->Name()).($event->Archived()?'*':'') ?></a></td>
|
<td class="colName"><a href="?view=event&eid=<?php echo $event->Id().$filterQuery.$sortQuery.'&page=1">'.validHtmlStr($event->Name()).($event->Archived()?'*':'') ?></a><br/>
|
||||||
|
<?php
|
||||||
|
if ( $event->Emailed() )
|
||||||
|
echo 'Emailed ';
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
<td class="colMonitorName"><?php echo makePopupLink( '?view=monitor&mid='.$event->MonitorId(), 'zmMonitor'.$event->MonitorId(), 'monitor', $event->MonitorName(), canEdit( 'Monitors' ) ) ?></td>
|
<td class="colMonitorName"><?php echo makePopupLink( '?view=monitor&mid='.$event->MonitorId(), 'zmMonitor'.$event->MonitorId(), 'monitor', $event->MonitorName(), canEdit( 'Monitors' ) ) ?></td>
|
||||||
<td class="colCause"><?php echo makePopupLink( '?view=eventdetail&eid='.$event->Id(), 'zmEventDetail', 'eventdetail', validHtmlStr($event->Cause()), canEdit( 'Events' ), 'title="'.htmlspecialchars($event->Notes()).'"' ) ?>
|
<td class="colCause"><?php echo makePopupLink( '?view=eventdetail&eid='.$event->Id(), 'zmEventDetail', 'eventdetail', validHtmlStr($event->Cause()), canEdit( 'Events' ), 'title="'.htmlspecialchars($event->Notes()).'"' ) ?>
|
||||||
<?php
|
<?php
|
||||||
# display notes as small text
|
# display notes as small text
|
||||||
if ($event->Notes()) {
|
if ( $event->Notes() ) {
|
||||||
# if notes include detection objects, then link it to objdetect.jpg
|
# if notes include detection objects, then link it to objdetect.jpg
|
||||||
if (strpos($event->Notes(),'detected:')!== false){
|
if ( strpos($event->Notes(), 'detected:') !== false ) {
|
||||||
# make a link
|
# make a link
|
||||||
echo makePopupLink( '?view=image&eid='.$event->Id().'&fid=objdetect', 'zmImage',
|
echo makePopupLink( '?view=image&eid='.$event->Id().'&fid=objdetect', 'zmImage',
|
||||||
array('image', reScale($event->Width(), $scale), reScale($event->Height(), $scale)),
|
array('image', reScale($event->Width(), $scale), reScale($event->Height(), $scale)),
|
||||||
"<div class=\"small text-nowrap text-muted\"><u>".$event->Notes()."</u></div>");
|
'<div class="small text-nowrap text-muted"><u>'.$event->Notes().'</u></div>');
|
||||||
}
|
} else if ( $event->Notes() != 'Forced Web: ' ) {
|
||||||
elseif ($event->Notes() != 'Forced Web: ') {
|
echo '<br/><div class="small text-nowrap text-muted">'.$event->Notes().'</div>';
|
||||||
echo "<br/><div class=\"small text-nowrap text-muted\">".$event->Notes()."</div>";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
//
|
//
|
||||||
// ZoneMinder web filter view file, $Date$, $Revision$
|
// ZoneMinder web filter view file
|
||||||
// Copyright (C) 2001-2008 Philip Coombes
|
// Copyright (C) 2001-2008 Philip Coombes
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
|
@ -25,6 +25,8 @@ if ( !canView('Events') ) {
|
||||||
require_once('includes/Object.php');
|
require_once('includes/Object.php');
|
||||||
require_once('includes/Storage.php');
|
require_once('includes/Storage.php');
|
||||||
require_once('includes/Filter.php');
|
require_once('includes/Filter.php');
|
||||||
|
require_once('includes/Monitor.php');
|
||||||
|
require_once('includes/Zone.php');
|
||||||
parseSort();
|
parseSort();
|
||||||
|
|
||||||
$filterNames = array(''=>translate('ChooseFilter'));
|
$filterNames = array(''=>translate('ChooseFilter'));
|
||||||
|
@ -69,6 +71,7 @@ if ( count($terms) ) {
|
||||||
|
|
||||||
$attrTypes = array(
|
$attrTypes = array(
|
||||||
'AlarmFrames' => translate('AttrAlarmFrames'),
|
'AlarmFrames' => translate('AttrAlarmFrames'),
|
||||||
|
'AlarmedZoneId' => translate('AttrAlarmedZone'),
|
||||||
'Archived' => translate('AttrArchiveStatus'),
|
'Archived' => translate('AttrArchiveStatus'),
|
||||||
'AvgScore' => translate('AttrAvgScore'),
|
'AvgScore' => translate('AttrAvgScore'),
|
||||||
'Cause' => translate('AttrCause'),
|
'Cause' => translate('AttrCause'),
|
||||||
|
@ -78,17 +81,17 @@ $attrTypes = array(
|
||||||
'EndDateTime' => translate('AttrEndDateTime'),
|
'EndDateTime' => translate('AttrEndDateTime'),
|
||||||
'EndDate' => translate('AttrEndDate'),
|
'EndDate' => translate('AttrEndDate'),
|
||||||
'EndTime' => translate('AttrEndTime'),
|
'EndTime' => translate('AttrEndTime'),
|
||||||
|
'EndWeekday' => translate('AttrEndWeekday'),
|
||||||
'FilterServerId' => translate('AttrFilterServer'),
|
'FilterServerId' => translate('AttrFilterServer'),
|
||||||
'Frames' => translate('AttrFrames'),
|
'Frames' => translate('AttrFrames'),
|
||||||
'EndWeekday' => translate('AttrEndWeekday'),
|
|
||||||
'Id' => translate('AttrId'),
|
'Id' => translate('AttrId'),
|
||||||
'Length' => translate('AttrDuration'),
|
'Length' => translate('AttrDuration'),
|
||||||
'Name' => translate('AttrName'),
|
|
||||||
'Notes' => translate('AttrNotes'),
|
|
||||||
'MaxScore' => translate('AttrMaxScore'),
|
'MaxScore' => translate('AttrMaxScore'),
|
||||||
'MonitorId' => translate('AttrMonitorId'),
|
'MonitorId' => translate('AttrMonitorId'),
|
||||||
'MonitorName' => translate('AttrMonitorName'),
|
'MonitorName' => translate('AttrMonitorName'),
|
||||||
'MonitorServerId' => translate('AttrMonitorServer'),
|
'MonitorServerId' => translate('AttrMonitorServer'),
|
||||||
|
'Name' => translate('AttrName'),
|
||||||
|
'Notes' => translate('AttrNotes'),
|
||||||
'SecondaryStorageId' => translate('AttrSecondaryStorageArea'),
|
'SecondaryStorageId' => translate('AttrSecondaryStorageArea'),
|
||||||
'ServerId' => translate('AttrMonitorServer'),
|
'ServerId' => translate('AttrMonitorServer'),
|
||||||
'StartDateTime' => translate('AttrStartDateTime'),
|
'StartDateTime' => translate('AttrStartDateTime'),
|
||||||
|
@ -143,13 +146,22 @@ foreach ( dbFetchAll('SELECT `Id`, `Name` FROM `Servers` ORDER BY lower(`Name`)
|
||||||
$servers[$server['Id']] = validHtmlStr($server['Name']);
|
$servers[$server['Id']] = validHtmlStr($server['Name']);
|
||||||
}
|
}
|
||||||
$monitors = array();
|
$monitors = array();
|
||||||
|
$monitor_names = array();
|
||||||
foreach ( dbFetchAll('SELECT `Id`, `Name` FROM `Monitors` ORDER BY lower(`Name`) ASC') as $monitor ) {
|
foreach ( dbFetchAll('SELECT `Id`, `Name` FROM `Monitors` ORDER BY lower(`Name`) ASC') as $monitor ) {
|
||||||
if ( visibleMonitor($monitor['Id']) ) {
|
if ( visibleMonitor($monitor['Id']) ) {
|
||||||
$monitors[$monitor['Name']] = validHtmlStr($monitor['Name']);
|
$monitors[$monitor['Id']] = new ZM\Monitor($monitor);
|
||||||
|
$monitor_names[] = validHtmlStr($monitor['Name']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$zones = array();
|
||||||
|
foreach ( dbFetchAll('SELECT Id, Name, MonitorId FROM Zones ORDER BY lower(`Name`) ASC') as $zone ) {
|
||||||
|
if ( visibleMonitor($zone['MonitorId']) ) {
|
||||||
|
$zone['Name'] = validHtmlStr($monitors[$zone['MonitorId']]->Name().': '.$zone['Name']);
|
||||||
|
$zones[$zone['Id']] = new ZM\Zone($zone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xhtmlHeaders(__FILE__, translate('EventFilter') );
|
xhtmlHeaders(__FILE__, translate('EventFilter'));
|
||||||
?>
|
?>
|
||||||
<body>
|
<body>
|
||||||
<div id="page">
|
<div id="page">
|
||||||
|
@ -259,10 +271,15 @@ for ( $i=0; $i < count($terms); $i++ ) {
|
||||||
<td><?php echo htmlSelect("filter[Query][terms][$i][op]", $opTypes, $term['op']); ?></td>
|
<td><?php echo htmlSelect("filter[Query][terms][$i][op]", $opTypes, $term['op']); ?></td>
|
||||||
<td><?php echo htmlSelect("filter[Query][terms][$i][val]", $weekdays, $term['val']); ?></td>
|
<td><?php echo htmlSelect("filter[Query][terms][$i][val]", $weekdays, $term['val']); ?></td>
|
||||||
<?php
|
<?php
|
||||||
} elseif ( $term['attr'] == 'MonitorName' ) {
|
} elseif ( $term['attr'] == 'Monitor' ) {
|
||||||
?>
|
?>
|
||||||
<td><?php echo htmlSelect("filter[Query][terms][$i][op]", $opTypes, $term['op']); ?></td>
|
<td><?php echo htmlSelect("filter[Query][terms][$i][op]", $opTypes, $term['op']); ?></td>
|
||||||
<td><?php echo htmlSelect("filter[Query][terms][$i][val]", $monitors, $term['val']); ?></td>
|
<td><?php echo htmlSelect("filter[Query][terms][$i][val]", $monitors, $term['val']); ?></td>
|
||||||
|
<?php
|
||||||
|
} elseif ( $term['attr'] == 'MonitorName' ) {
|
||||||
|
?>
|
||||||
|
<td><?php echo htmlSelect("filter[Query][terms][$i][op]", $opTypes, $term['op']); ?></td>
|
||||||
|
<td><?php echo htmlSelect("filter[Query][terms][$i][val]", array_combine($monitor_names,$monitor_names), $term['val']); ?></td>
|
||||||
<?php
|
<?php
|
||||||
} elseif ( $term['attr'] == 'ServerId' || $term['attr'] == 'MonitorServerId' || $term['attr'] == 'StorageServerId' || $term['attr'] == 'FilterServerId' ) {
|
} elseif ( $term['attr'] == 'ServerId' || $term['attr'] == 'MonitorServerId' || $term['attr'] == 'StorageServerId' || $term['attr'] == 'FilterServerId' ) {
|
||||||
?>
|
?>
|
||||||
|
@ -273,6 +290,11 @@ for ( $i=0; $i < count($terms); $i++ ) {
|
||||||
?>
|
?>
|
||||||
<td><?php echo htmlSelect("filter[Query][terms][$i][op]", $opTypes, $term['op']); ?></td>
|
<td><?php echo htmlSelect("filter[Query][terms][$i][op]", $opTypes, $term['op']); ?></td>
|
||||||
<td><?php echo htmlSelect("filter[Query][terms][$i][val]", $storageareas, $term['val']); ?></td>
|
<td><?php echo htmlSelect("filter[Query][terms][$i][val]", $storageareas, $term['val']); ?></td>
|
||||||
|
<?php
|
||||||
|
} elseif ( $term['attr'] == 'AlarmedZoneId' ) {
|
||||||
|
?>
|
||||||
|
<td><?php echo htmlSelect("filter[Query][terms][$i][op]", $opTypes, $term['op']); ?></td>
|
||||||
|
<td><?php echo htmlSelect("filter[Query][terms][$i][val]", $zones, $term['val']); ?></td>
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
|
@ -423,7 +445,7 @@ if ( ZM_OPT_MESSAGE ) {
|
||||||
<hr/>
|
<hr/>
|
||||||
<div id="contentButtons">
|
<div id="contentButtons">
|
||||||
<button type="submit" data-on-click-this="submitToEvents"><?php echo translate('ListMatches') ?></button>
|
<button type="submit" data-on-click-this="submitToEvents"><?php echo translate('ListMatches') ?></button>
|
||||||
<!--<button type="submit" data-on-click-this="submitToMontageReview"><?php echo translate('ViewMatches') ?></button>-->
|
<button type="button" data-on-click-this="submitToMontageReview"><?php echo translate('ViewMatches') ?></button>
|
||||||
<button type="button" data-on-click-this="submitToExport"><?php echo translate('ExportMatches') ?></button>
|
<button type="button" data-on-click-this="submitToExport"><?php echo translate('ExportMatches') ?></button>
|
||||||
<button type="button" name="executeButton" id="executeButton" data-on-click-this="executeFilter"><?php echo translate('Execute') ?></button>
|
<button type="button" name="executeButton" id="executeButton" data-on-click-this="executeFilter"><?php echo translate('Execute') ?></button>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -114,10 +114,12 @@ function submitToEvents( element ) {
|
||||||
history.replaceState(null, null, '?view=filter&' + $j(form).serialize());
|
history.replaceState(null, null, '?view=filter&' + $j(form).serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitToMontageReview( element ) {
|
function submitToMontageReview(element) {
|
||||||
var form = element.form;
|
var form = element.form;
|
||||||
form.action = thisUrl + '?view=montagereview';
|
form.action = thisUrl + '?view=montagereview';
|
||||||
history.replaceState(null, null, '?view=filter&' + $j(form).serialize());
|
console.log($j(form).serialize());
|
||||||
|
window.location.assign('?view=montagereview&'+$j(form).serialize());
|
||||||
|
history.replaceState(null, null, '?view=montagereview&live=0&' + $j(form).serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitToExport(element) {
|
function submitToExport(element) {
|
||||||
|
@ -192,7 +194,8 @@ function parseRows(rows) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var attr = inputTds.eq(2).children().val();
|
var attr = inputTds.eq(2).children().val();
|
||||||
if ( attr == 'Archived' ) { // Archived types
|
|
||||||
|
if ( attr == 'Archived' ) { //Archived types
|
||||||
inputTds.eq(3).html('equal to<input type="hidden" name="filter[Query][terms][' + rowNum + '][op]" value="=">');
|
inputTds.eq(3).html('equal to<input type="hidden" name="filter[Query][terms][' + rowNum + '][op]" value="=">');
|
||||||
var archiveSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
|
var archiveSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
|
||||||
for (var i = 0; i < archiveTypes.length; i++) {
|
for (var i = 0; i < archiveTypes.length; i++) {
|
||||||
|
@ -200,6 +203,18 @@ function parseRows(rows) {
|
||||||
}
|
}
|
||||||
var archiveVal = inputTds.eq(4).children().val();
|
var archiveVal = inputTds.eq(4).children().val();
|
||||||
inputTds.eq(4).html(archiveSelect).children().val(archiveVal).chosen({width: "101%"});
|
inputTds.eq(4).html(archiveSelect).children().val(archiveVal).chosen({width: "101%"});
|
||||||
|
} else if ( attr == 'AlarmedZoneId' ) {
|
||||||
|
var zoneSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
|
||||||
|
for ( monitor_id in monitors ) {
|
||||||
|
for ( zone_id in zones ) {
|
||||||
|
var zone = zones[zone_id];
|
||||||
|
if ( monitor_id == zone.MonitorId ) {
|
||||||
|
zoneSelect.append('<option value="' + zone_id + '">' + zone.Name + '</option>');
|
||||||
|
}
|
||||||
|
} // end foreach zone
|
||||||
|
} // end foreach monitor
|
||||||
|
var zoneVal = inputTds.eq(4).children().val();
|
||||||
|
inputTds.eq(4).html(zoneSelect).children().val(zoneVal).chosen({width: "101%"});
|
||||||
} else if ( attr.indexOf('Weekday') >= 0 ) { //Weekday selection
|
} else if ( attr.indexOf('Weekday') >= 0 ) { //Weekday selection
|
||||||
var weekdaySelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
|
var weekdaySelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
|
||||||
for (var i = 0; i < weekdays.length; i++) {
|
for (var i = 0; i < weekdays.length; i++) {
|
||||||
|
@ -230,22 +245,29 @@ function parseRows(rows) {
|
||||||
inputTds.eq(4).html(storageSelect).children().val(storageVal).chosen({width: "101%"});
|
inputTds.eq(4).html(storageSelect).children().val(storageVal).chosen({width: "101%"});
|
||||||
} else if ( attr == 'MonitorName' ) { //Monitor names
|
} else if ( attr == 'MonitorName' ) { //Monitor names
|
||||||
var monitorSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
|
var monitorSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
|
||||||
for (var key in monitors) {
|
for ( var monitor_id in monitors ) {
|
||||||
monitorSelect.append('<option value="' + key + '">' + monitors[key] + '</option>');
|
monitorSelect.append('<option value="' + monitors[monitor_id].Name + '">' + monitors[monitor_id].Name + '</option>');
|
||||||
}
|
}
|
||||||
var monitorVal = inputTds.eq(4).children().val();
|
var monitorVal = inputTds.eq(4).children().val();
|
||||||
inputTds.eq(4).html(monitorSelect).children().val(monitorVal);
|
inputTds.eq(4).html(monitorSelect).children().val(monitorVal);
|
||||||
} else { //Reset to regular text field and operator for everything that isn't special
|
} else { // Reset to regular text field and operator for everything that isn't special
|
||||||
var opSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][op]').attr('id', queryPrefix + rowNum + '][op]');
|
|
||||||
for (var key in opTypes) {
|
|
||||||
opSelect.append('<option value="' + key + '">' + opTypes[key] + '</option>');
|
|
||||||
}
|
|
||||||
var opVal = inputTds.eq(3).children().val();
|
|
||||||
inputTds.eq(3).html(opSelect).children().val(opVal).chosen({width: "101%"});
|
|
||||||
var textInput = $j('<input></input>').attr('type', 'text').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
|
var textInput = $j('<input></input>').attr('type', 'text').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
|
||||||
var textVal = inputTds.eq(4).children().val();
|
var textVal = inputTds.eq(4).children().val();
|
||||||
inputTds.eq(4).html(textInput).children().val(textVal);
|
inputTds.eq(4).html(textInput).children().val(textVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate the operator
|
||||||
|
var opSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][op]').attr('id', queryPrefix + rowNum + '][op]');
|
||||||
|
var opVal = inputTds.eq(3).children().val();
|
||||||
|
if ( ! opVal ) {
|
||||||
|
// Default to equals so that something gets selected
|
||||||
|
console.log("No value for operator. Defaulting to =");
|
||||||
|
opVal = '=';
|
||||||
|
}
|
||||||
|
for ( var key in opTypes ) {
|
||||||
|
opSelect.append('<option value="' + key + '"'+(key == opVal ? ' selected="selected"' : '')+'>' + opTypes[key] + '</option>');
|
||||||
|
}
|
||||||
|
inputTds.eq(3).html(opSelect).children().val(opVal).chosen({width: "101%"});
|
||||||
if ( attr.endsWith('DateTime') ) { //Start/End DateTime
|
if ( attr.endsWith('DateTime') ) { //Start/End DateTime
|
||||||
inputTds.eq(4).children().datetimepicker({timeFormat: "HH:mm:ss", dateFormat: "yy-mm-dd", maxDate: 0, constrainInput: false});
|
inputTds.eq(4).children().datetimepicker({timeFormat: "HH:mm:ss", dateFormat: "yy-mm-dd", maxDate: 0, constrainInput: false});
|
||||||
} else if ( attr.endsWith('Date') ) { //Start/End Date
|
} else if ( attr.endsWith('Date') ) { //Start/End Date
|
||||||
|
@ -279,7 +301,7 @@ function addTerm( element ) {
|
||||||
var newRow = row.clone().insertAfter(row);
|
var newRow = row.clone().insertAfter(row);
|
||||||
row.find('select').chosen({width: '101%'});
|
row.find('select').chosen({width: '101%'});
|
||||||
newRow.find('select').each( function() { //reset new row to default
|
newRow.find('select').each( function() { //reset new row to default
|
||||||
this[0].selected = 'selected';
|
this[0].selected = 'selected';
|
||||||
}).chosen({width: '101%'});
|
}).chosen({width: '101%'});
|
||||||
newRow.find('input[type="text"]').val('');
|
newRow.find('input[type="text"]').val('');
|
||||||
newRow[0].querySelectorAll("button[data-on-click-this]").forEach(function(el) {
|
newRow[0].querySelectorAll("button[data-on-click-this]").forEach(function(el) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ var states = <?php echo isset($states) ? json_encode($states) : '' ?>;
|
||||||
var servers = <?php echo isset($servers) ? json_encode($servers) : '' ?>;
|
var servers = <?php echo isset($servers) ? json_encode($servers) : '' ?>;
|
||||||
var storageareas = <?php echo isset($storageareas) ? json_encode($storageareas) : '' ?>;
|
var storageareas = <?php echo isset($storageareas) ? json_encode($storageareas) : '' ?>;
|
||||||
var monitors = <?php echo isset($monitors) ? json_encode($monitors) : '' ?>;
|
var monitors = <?php echo isset($monitors) ? json_encode($monitors) : '' ?>;
|
||||||
|
var zones = <?php echo isset($zones) ? json_encode($zones) : '' ?>;
|
||||||
|
|
||||||
var errorBrackets = '<?php echo translate('ErrorBrackets') ?>';
|
var errorBrackets = '<?php echo translate('ErrorBrackets') ?>';
|
||||||
var errorValue = '<?php echo translate('ErrorValidValue') ?>';
|
var errorValue = '<?php echo translate('ErrorValidValue') ?>';
|
||||||
|
|
|
@ -464,6 +464,7 @@ function initPage() {
|
||||||
|
|
||||||
// Start the fps and status updates. give a random delay so that we don't assault the server
|
// Start the fps and status updates. give a random delay so that we don't assault the server
|
||||||
var delay = Math.round( (Math.random()+0.5)*statusRefreshTimeout );
|
var delay = Math.round( (Math.random()+0.5)*statusRefreshTimeout );
|
||||||
|
console.log("delay: " + delay);
|
||||||
monitors[i].start(delay);
|
monitors[i].start(delay);
|
||||||
|
|
||||||
var interval = monitors[i].refresh;
|
var interval = monitors[i].refresh;
|
||||||
|
|
|
@ -62,6 +62,17 @@ ob_end_clean();
|
||||||
$filter = array();
|
$filter = array();
|
||||||
if ( isset($_REQUEST['filter']) ) {
|
if ( isset($_REQUEST['filter']) ) {
|
||||||
$filter = $_REQUEST['filter'];
|
$filter = $_REQUEST['filter'];
|
||||||
|
|
||||||
|
# Try to guess min/max time from filter
|
||||||
|
foreach ( $filter['Query'] as $term ) {
|
||||||
|
if ( $term['attr'] == 'StartDateTime' ) {
|
||||||
|
if ( $term['op'] == '<=' or $term['op'] == '<' ) {
|
||||||
|
$maxTime = $term['val'];
|
||||||
|
} else if ( $term['op'] == '>=' or $term['op'] == '>' ) {
|
||||||
|
$minTime = $term['val'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if ( isset($_REQUEST['minTime']) && isset($_REQUEST['maxTime']) && (count($displayMonitors) != 0) ) {
|
if ( isset($_REQUEST['minTime']) && isset($_REQUEST['maxTime']) && (count($displayMonitors) != 0) ) {
|
||||||
|
|
Loading…
Reference in New Issue