Firewall: Diagnostics: States Dump - refactor to MVC.

o fix minor regression duplicating records (only flush on last content line)
o add link to firewall / rules page
This commit is contained in:
Ad Schellevis 2021-06-21 19:37:27 +02:00
parent 63bdff8cf3
commit 43b7f1eb7f
2 changed files with 18 additions and 4 deletions

View File

@ -124,8 +124,10 @@ def query_states(rule_label, filter_str):
elif filter_str != "" and search_line.lower().find(filter_str.lower()) == -1:
# apply filter when provided
continue
# append to response
result.append(record)
if parts[0] == "id:":
# append to response
result.append(record)
elif len(parts) >= 6:
record = {
'label': '',

View File

@ -713,7 +713,12 @@ $( document ).ready(function() {
</td>
<td class="view-info hidden-xs hidden-sm">*</td>
<td class="view-stats hidden-xs hidden-sm"><?= !empty($rule_stats) ? $rule_stats['evaluations'] : gettext('N/A') ?></td>
<td class="view-stats hidden-xs hidden-sm"><?= !empty($rule_stats) ? $rule_stats['states'] : gettext('N/A') ?></td>
<td class="view-stats hidden-xs hidden-sm">
<?php if (!empty($rule_stats) && !empty($rule->getRef())):?>
<a href="/ui/diagnostics/firewall/states#<?=html_safe($rule->getLabel());?>" data-toggle="tooltip" title="<?=html_safe("open states view");?>" ><?= $rule_stats['states'];?></a>
<?php else: ?>
<?= !empty($rule_stats) ? $rule_stats['states'] : gettext('N/A') ?></td>
<?php endif ?>
<td class="view-stats"><?= !empty($rule_stats) ? $rule_stats['packets'] : gettext('N/A') ?></td>
<td class="view-stats"><?= !empty($rule_stats) ? format_bytes($rule_stats['bytes']) : gettext('N/A') ?></td>
<td><?=$rule->getDescr();?></td>
@ -854,7 +859,14 @@ $( document ).ready(function() {
endif;?>
</td>
<td class="view-stats hidden-xs hidden-sm"><?= !empty($all_rule_stats[$rule_hash]) ? $all_rule_stats[$rule_hash]['evaluations'] : gettext('N/A') ?></td>
<td class="view-stats hidden-xs hidden-sm"><?= !empty($all_rule_stats[$rule_hash]) ? $all_rule_stats[$rule_hash]['states'] : gettext('N/A') ?></td>
<td class="view-stats hidden-xs hidden-sm">
<?php if (!empty($all_rule_stats[$rule_hash])):?>
<a href="/ui/diagnostics/firewall/states#<?=html_safe($rule_hash);?>" data-toggle="tooltip" title="<?=html_safe("open states view");?>" ><?= $all_rule_stats[$rule_hash]['states'];?></a>
<?php else: ?>
<?= gettext('N/A') ?>
<?php endif ?>
</td>
<td class="view-stats"><?= !empty($all_rule_stats[$rule_hash]) ? $all_rule_stats[$rule_hash]['packets'] : gettext('N/A') ?></td>
<td class="view-stats"><?= !empty($all_rule_stats[$rule_hash]) ? format_bytes($all_rule_stats[$rule_hash]['bytes']) : gettext('N/A') ?></td>
<td class="rule-description">