Skip to content

Commit

Permalink
firewall/filter: Create custom formatters to show inverted source, de…
Browse files Browse the repository at this point in the history
…stination and interface. Append icon column to grid. For #8367
  • Loading branch information
Monviech committed Feb 21, 2025
1 parent 2c5150f commit f0d536c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<label>Interface / Invert</label>
<type>checkbox</type>
<help>Use all but selected interfaces</help>
<advanced>true</advanced>
<grid_view>
<ignore>true</ignore>
</grid_view>
Expand All @@ -101,6 +102,7 @@
<label>Interface</label>
<type>select_multiple</type>
<grid_view>
<formatter>interfacenot</formatter>
<sequence>9</sequence>
</grid_view>
</field>
Expand Down Expand Up @@ -139,6 +141,7 @@
<type>text</type>
<style>net_selector net_selector_multi</style>
<grid_view>
<formatter>source_not</formatter>
<sequence>5</sequence>
</grid_view>
</field>
Expand Down Expand Up @@ -167,6 +170,7 @@
<type>text</type>
<style>net_selector net_selector_multi</style>
<grid_view>
<formatter>destination_not</formatter>
<sequence>7</sequence>
</grid_view>
</field>
Expand Down
31 changes: 30 additions & 1 deletion src/opnsense/mvc/app/views/OPNsense/Firewall/filter_rule.volt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@

<script>
$(document).ready(function() {
// Add column for firewall rule icons
const $iconsColumn = $('<th data-column-id="icons" data-type="string"></th>');
$('#{{formGridFilterRule['table_id']}} thead tr th[data-column-id="sequence"]').after($iconsColumn);


const grid = $("#{{formGridFilterRule['table_id']}}").UIBootgrid({
search:'/api/firewall/filter/search_rule/',
get:'/api/firewall/filter/get_rule/',
Expand All @@ -41,8 +46,32 @@
request['category'] = $('#category_filter').val();
}
return request;
}
},
formatters:{
interfacenot: function(column, row) {
if (row.interfacenot == true) {
return "! " + row.interface;
} else {
return row.interface;
}
},
source_not: function(column, row) {
if (row.source_not == true) {
return "! " + row.source_net;
} else {
return row.source_net;
}
},
destination_not: function(column, row) {
if (row.destination_not == true) {
return "! " + row.destination_net;
} else {
return row.destination_net;
}
},
},
}

});

// Reload categories before grid load
Expand Down

0 comments on commit f0d536c

Please sign in to comment.