Skip to content

Commit

Permalink
Merge pull request #4093 from IgorA100/patch-157
Browse files Browse the repository at this point in the history
Feat: Show filter "Archive Status" on Events page
  • Loading branch information
connortechnology authored Jul 16, 2024
2 parents 4c9f6d3 + 119e723 commit 0e1c61d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions web/includes/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1120,15 +1120,15 @@ public function simple_widget() {

if ( $term['attr'] == 'Archived' ) {
$html .= '<span class="term-value-wrapper">';
$html .= htmlSelect("filter[Query][terms][$i][val]", $archiveTypes, $term['val'],['class'=>'chosen chosen-auto-width']).PHP_EOL;
$html .= htmlSelect("filter[Query][terms][$i][val]", $archiveTypes, $term['val'],['id'=>'filterArchived', 'class'=>'chosen chosen-auto-width']).PHP_EOL;
$html .= '</span>';
} else if ( $term['attr'] == 'Tags' ) {
$selected = explode(',', $term['val']);
// echo '<pre>selected: '; print_r($selected); echo '</pre>';
if (count($selected) == 1 and !$selected[0]) {
$selected = null;
}
$options = ['class'=>'chosen chosen-auto-width', 'multiple'=>'multiple', 'data-placeholder'=>translate('All Tags')];
$options = ['id'=>'filterTags', 'class'=>'chosen chosen-auto-width', 'multiple'=>'multiple', 'data-placeholder'=>translate('All Tags')];
if (isset($term['cookie'])) {
$options['data-cookie'] = $term['cookie'];

Expand Down Expand Up @@ -1256,7 +1256,7 @@ public function simple_widget() {
['class'=>'term-value chosen chosen-auto-width', 'multiple'=>'multiple']).PHP_EOL;
$html .= '</span>';
} else if ( $term['attr'] == 'Notes' ) {
$attrs = ['class'=>'term-value chosen chosen-auto-width', 'multiple'=>'multiple', 'data-placeholder'=>translate('Event Type')];
$attrs = ['id'=>'filterNotes', 'class'=>'term-value chosen chosen-auto-width', 'multiple'=>'multiple', 'data-placeholder'=>translate('Event Type')];
$selected = explode(',', $term['val']);
if (count($selected) == 1 and !$selected[0]) {
$selected = null;
Expand Down
7 changes: 6 additions & 1 deletion web/skins/classic/views/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@
'val' => $num_terms ? '' : (isset($_COOKIE['eventsTags']) ? $_COOKIE['eventsTags'] : ''),
'cnj' => 'and', 'cookie'=>'eventsTags'));
}
$filter->sort_terms(['Group','Monitor','StartDateTime','EndDateTime','Notes','Tags']);
if (!$filter->has_term('Archived')) {
$filter->addTerm(array('attr' => 'Archived', 'op' => '=',
'val' => $num_terms ? '' : (isset($_COOKIE['zmFilterArchived']) ? $_COOKIE['zmFilterArchived'] : ''),
'cnj' => 'and', 'cookie'=>'zmFilterArchived'));
}
$filter->sort_terms(['Group','Monitor','StartDateTime','EndDateTime','Notes','Tags','Archived']);
#$filter->addTerm(array('cnj'=>'and', 'attr'=>'AlarmFrames', 'op'=> '>', 'val'=>'10'));
#$filter->addTerm(array('cnj'=>'and', 'attr'=>'StartDateTime', 'op'=> '<=', 'val'=>''));
}
Expand Down
5 changes: 4 additions & 1 deletion web/skins/classic/views/js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,10 @@ function initPage() {
table.show();
}

function filterEvents() {
function filterEvents(clickedElement) {
if (clickedElement.target && clickedElement.target.id == 'filterArchived') {
setCookie('zmFilterArchived', clickedElement.target.value);
}
filterQuery = '';
$j('#fieldsTable input').each(function(index) {
const el = $j(this);
Expand Down

0 comments on commit 0e1c61d

Please sign in to comment.