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,12 +124,21 @@ $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;
|
||||||
|
|
||||||
$storageareas = array('' => 'All') + ZM\ZM_Object::Objects_Indexed_By_Id('ZM\Storage');
|
$storageareas = array('' => 'All') + ZM\ZM_Object::Objects_Indexed_By_Id('ZM\Storage');
|
||||||
|
@ -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>
|
||||||
|
|
|
@ -110,8 +110,12 @@ function resetFilter( element ) {
|
||||||
|
|
||||||
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,6 +276,15 @@ 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 ( attr == 'ExistsInFileSystem' ) {
|
||||||
|
if ( ! opVal ) {
|
||||||
|
// Default to equals so that something gets selected
|
||||||
|
opVal = 'IS';
|
||||||
|
}
|
||||||
|
for ( var key of ['IS', 'IS NOT'] ) {
|
||||||
|
opSelect.append('<option value="' + key + '"'+(key == opVal ? ' selected="selected"' : '')+'>' + opTypes[key] + '</option>');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if ( ! opVal ) {
|
if ( ! opVal ) {
|
||||||
// Default to equals so that something gets selected
|
// Default to equals so that something gets selected
|
||||||
console.log("No value for operator. Defaulting to =");
|
console.log("No value for operator. Defaulting to =");
|
||||||
|
@ -271,6 +293,7 @@ function parseRows(rows) {
|
||||||
for ( var key in opTypes ) {
|
for ( var key in opTypes ) {
|
||||||
opSelect.append('<option value="' + key + '"'+(key == opVal ? ' selected="selected"' : '')+'>' + opTypes[key] + '</option>');
|
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
|
||||||
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});
|
||||||
|
@ -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