Add ExistsInFileSystem support in Filters. This also includes limiting operators to IS/IS NOT
This commit is contained in:
parent
303154c690
commit
77f9f4bffb
|
@ -25,6 +25,7 @@ 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/FilterTerm.php');
|
||||||
require_once('includes/Monitor.php');
|
require_once('includes/Monitor.php');
|
||||||
require_once('includes/Zone.php');
|
require_once('includes/Zone.php');
|
||||||
require_once('includes/User.php');
|
require_once('includes/User.php');
|
||||||
|
@ -53,7 +54,7 @@ if ( isset($_REQUEST['filter']) ) {
|
||||||
#$filter->set($_REQUEST['filter']);
|
#$filter->set($_REQUEST['filter']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$conjunctionTypes = getFilterQueryConjunctionTypes();
|
$conjunctionTypes = ZM\getFilterQueryConjunctionTypes();
|
||||||
$obracketTypes = array();
|
$obracketTypes = array();
|
||||||
$cbracketTypes = array();
|
$cbracketTypes = array();
|
||||||
|
|
||||||
|
@ -83,6 +84,7 @@ $attrTypes = array(
|
||||||
'EndDate' => translate('AttrEndDate'),
|
'EndDate' => translate('AttrEndDate'),
|
||||||
'EndTime' => translate('AttrEndTime'),
|
'EndTime' => translate('AttrEndTime'),
|
||||||
'EndWeekday' => translate('AttrEndWeekday'),
|
'EndWeekday' => translate('AttrEndWeekday'),
|
||||||
|
'ExistsInFileSystem' => translate('ExistsInFileSystem'),
|
||||||
'FilterServerId' => translate('AttrFilterServer'),
|
'FilterServerId' => translate('AttrFilterServer'),
|
||||||
'Frames' => translate('AttrFrames'),
|
'Frames' => translate('AttrFrames'),
|
||||||
'Id' => translate('AttrId'),
|
'Id' => translate('AttrId'),
|
||||||
|
@ -122,11 +124,20 @@ $opTypes = array(
|
||||||
'LIKE' => translate('OpLike'),
|
'LIKE' => translate('OpLike'),
|
||||||
'NOT LIKE' => translate('OpNotLike'),
|
'NOT LIKE' => translate('OpNotLike'),
|
||||||
);
|
);
|
||||||
|
$is_isnot_opTypes = array(
|
||||||
|
'IS' => translate('OpIs'),
|
||||||
|
'IS NOT' => translate('OpIsNot'),
|
||||||
|
);
|
||||||
|
|
||||||
$archiveTypes = array(
|
$archiveTypes = array(
|
||||||
'0' => translate('ArchUnarchived'),
|
'0' => translate('ArchUnarchived'),
|
||||||
'1' => translate('ArchArchived')
|
'1' => translate('ArchArchived')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$booleanValues = array(
|
||||||
|
'false' => translate('False'),
|
||||||
|
'true' => translate('True')
|
||||||
|
);
|
||||||
|
|
||||||
$focusWindow = true;
|
$focusWindow = true;
|
||||||
|
|
||||||
|
@ -275,6 +286,11 @@ for ( $i=0; $i < count($terms); $i++ ) {
|
||||||
<input type="text" name="filter[Query][terms][<?php echo $i ?>][val]" id="filter[Query][terms][<?php echo $i ?>][val]" value="<?php echo isset($term['val'])?validHtmlStr(str_replace('T', ' ', $term['val'])):'' ?>"/>
|
<input type="text" name="filter[Query][terms][<?php echo $i ?>][val]" id="filter[Query][terms][<?php echo $i ?>][val]" value="<?php echo isset($term['val'])?validHtmlStr(str_replace('T', ' ', $term['val'])):'' ?>"/>
|
||||||
<script nonce="<?php echo $cspNonce;?>">$j("[name$='\\[<?php echo $i ?>\\]\\[val\\]']").timepicker({timeFormat: "HH:mm:ss", constrainInput: false}); </script>
|
<script nonce="<?php echo $cspNonce;?>">$j("[name$='\\[<?php echo $i ?>\\]\\[val\\]']").timepicker({timeFormat: "HH:mm:ss", constrainInput: false}); </script>
|
||||||
</td>
|
</td>
|
||||||
|
<?php
|
||||||
|
} elseif ( $term['attr'] == 'ExistsInFileSystem' ) {
|
||||||
|
?>
|
||||||
|
<td><?php echo htmlSelect("filter[Query][terms][$i][op]", $is_isnot_opTypes, $term['op']); ?></td>
|
||||||
|
<td><?php echo htmlSelect("filter[Query][terms][$i][val]", $booleanValues, $term['val']); ?></td>
|
||||||
<?php
|
<?php
|
||||||
} elseif ( $term['attr'] == 'StateId' ) {
|
} elseif ( $term['attr'] == 'StateId' ) {
|
||||||
?>
|
?>
|
||||||
|
@ -459,7 +475,7 @@ if ( ZM_OPT_MESSAGE ) {
|
||||||
</div>
|
</div>
|
||||||
<hr/>
|
<hr/>
|
||||||
<div id="contentButtons">
|
<div id="contentButtons">
|
||||||
<button type="submit" data-on-click-this="submitToEvents"><?php echo translate('ListMatches') ?></button>
|
<button type="button" data-on-click-this="submitToEvents"><?php echo translate('ListMatches') ?></button>
|
||||||
<button type="button" 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>
|
||||||
|
|
|
@ -2,12 +2,12 @@ function selectFilter(element) {
|
||||||
element.form.submit();
|
element.form.submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateForm( form ) {
|
function validateForm(form) {
|
||||||
var rows = $j(form).find('tbody').eq(0).find('tr');
|
var rows = $j(form).find('tbody').eq(0).find('tr');
|
||||||
var obrCount = 0;
|
var obrCount = 0;
|
||||||
var cbrCount = 0;
|
var cbrCount = 0;
|
||||||
for ( var i = 0; i < rows.length; i++ ) {
|
for ( var i = 0; i < rows.length; i++ ) {
|
||||||
if (rows.length > 2) {
|
if ( rows.length > 2 ) {
|
||||||
obrCount += parseInt(form.elements['filter[Query][terms][' + i + '][obr]'].value);
|
obrCount += parseInt(form.elements['filter[Query][terms][' + i + '][obr]'].value);
|
||||||
cbrCount += parseInt(form.elements['filter[Query][terms][' + i + '][cbr]'].value);
|
cbrCount += parseInt(form.elements['filter[Query][terms][' + i + '][cbr]'].value);
|
||||||
}
|
}
|
||||||
|
@ -108,10 +108,14 @@ function resetFilter( element ) {
|
||||||
$j('#contentForm')[0].reset();
|
$j('#contentForm')[0].reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitToEvents( element ) {
|
function submitToEvents(element) {
|
||||||
var form = element.form;
|
var form = element.form;
|
||||||
form.action = thisUrl + '?view=events';
|
//form.action = '?view=events';
|
||||||
history.replaceState(null, null, '?view=filter&' + $j(form).serialize());
|
//form.submit();
|
||||||
|
//console.log(form);
|
||||||
|
//console.log($j(form).serialize());
|
||||||
|
//history.replaceState(null, null, '?view=filter&' + $j(form).serialize());
|
||||||
|
window.location.assign('?view=events&'+$j(form).serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitToMontageReview(element) {
|
function submitToMontageReview(element) {
|
||||||
|
@ -254,6 +258,15 @@ function parseRows(rows) {
|
||||||
}
|
}
|
||||||
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 if ( attr == 'ExistsInFileSystem' ) {
|
||||||
|
var select = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
|
||||||
|
for ( var booleanVal in booleanValues ) {
|
||||||
|
select.append('<option value="' + booleanVal + '">' + escapeHTML(booleanValues[booleanVal]) + '</option>');
|
||||||
|
}
|
||||||
|
var val = inputTds.eq(4).children().val();
|
||||||
|
if ( ! val ) val = 'false'; // default to the first option false
|
||||||
|
inputTds.eq(4).html(select).children().val(val);
|
||||||
|
|
||||||
} 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 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();
|
||||||
|
@ -263,13 +276,23 @@ function parseRows(rows) {
|
||||||
// Validate the operator
|
// Validate the operator
|
||||||
var opSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][op]').attr('id', queryPrefix + rowNum + '][op]');
|
var opSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][op]').attr('id', queryPrefix + rowNum + '][op]');
|
||||||
var opVal = inputTds.eq(3).children().val();
|
var opVal = inputTds.eq(3).children().val();
|
||||||
if ( ! opVal ) {
|
if ( attr == 'ExistsInFileSystem' ) {
|
||||||
// Default to equals so that something gets selected
|
if ( ! opVal ) {
|
||||||
console.log("No value for operator. Defaulting to =");
|
// Default to equals so that something gets selected
|
||||||
opVal = '=';
|
opVal = 'IS';
|
||||||
}
|
}
|
||||||
for ( var key in opTypes ) {
|
for ( var key of ['IS', 'IS NOT'] ) {
|
||||||
opSelect.append('<option value="' + key + '"'+(key == opVal ? ' selected="selected"' : '')+'>' + opTypes[key] + '</option>');
|
opSelect.append('<option value="' + key + '"'+(key == opVal ? ' selected="selected"' : '')+'>' + opTypes[key] + '</option>');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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%"});
|
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
|
||||||
|
@ -289,7 +312,7 @@ function parseRows(rows) {
|
||||||
inputTds.eq(2).children().eq(0).attr('id', 'filter'+stringFilter(term));
|
inputTds.eq(2).children().eq(0).attr('id', 'filter'+stringFilter(term));
|
||||||
} //End for each term/row
|
} //End for each term/row
|
||||||
history.replaceState(null, null, '?view=filter&' + $j('#contentForm').serialize());
|
history.replaceState(null, null, '?view=filter&' + $j('#contentForm').serialize());
|
||||||
}
|
} // parseRows
|
||||||
|
|
||||||
function stringFilter(term) {
|
function stringFilter(term) {
|
||||||
var termString = '';
|
var termString = '';
|
||||||
|
|
Loading…
Reference in New Issue