mirror of
https://github.com/lucaspalomodevelop/opnsense-core.git
synced 2026-03-13 00:07:27 +00:00
firewall/filter: Use fetch_options from opnsense_ui.js to build interface_select selectpicker (#8493)
* firewall/filter: Use fetch_options from opnsense_ui.js to build interface_select selectpicker * Update src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/FilterController.php Co-authored-by: Franco Fichtner <franco@opnsense.org> --------- Co-authored-by: Franco Fichtner <franco@opnsense.org>
This commit is contained in:
parent
d73ec9feae
commit
92881adb40
@ -342,7 +342,8 @@ class FilterController extends FilterBaseController
|
||||
'items' => [
|
||||
[
|
||||
'value' => '',
|
||||
'label' => gettext('Any')
|
||||
'label' => gettext('Any'),
|
||||
'selected' => true,
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
@ -500,38 +500,8 @@
|
||||
});
|
||||
|
||||
// Populate interface selectpicker
|
||||
$('#interface_select').fetch_options('/api/firewall/filter/get_interface_list');
|
||||
$("#interface_select_container").show();
|
||||
ajaxCall('/api/firewall/filter/get_interface_list', {},
|
||||
function(data, status) {
|
||||
const $select = $('#interface_select');
|
||||
$select.empty();
|
||||
for (const [groupkey, group] of Object.entries(data)) {
|
||||
if (group.items.length > 0) {
|
||||
let $optgroup = $('<optgroup>', {
|
||||
"label": `${group.label}`,
|
||||
"data-icon": `${group.icon}`
|
||||
});
|
||||
group.items.forEach(function(iface) {
|
||||
let optprops = {
|
||||
value: iface.value,
|
||||
'data-subtext': group.label,
|
||||
text: iface.label
|
||||
};
|
||||
if (iface.value === '') {
|
||||
/* floating selected by default */
|
||||
optprops['selected'] = 'selected';
|
||||
}
|
||||
$optgroup.append($('<option>', optprops));
|
||||
});
|
||||
$select.append($optgroup);
|
||||
}
|
||||
}
|
||||
$select.selectpicker('refresh');
|
||||
},
|
||||
function(xhr, textStatus, errorThrown) {
|
||||
console.error("Failed to load interface list:", textStatus, errorThrown);
|
||||
}
|
||||
);
|
||||
|
||||
// move selectpickers into action bar
|
||||
$("#interface_select_container").detach().insertBefore('#{{formGridFilterRule["table_id"]}}-header > .row > .actionBar > .search');
|
||||
|
||||
@ -672,7 +672,8 @@ $.fn.fetch_options = function(url, params, data_callback, store_data) {
|
||||
$('<option>', {
|
||||
value: item.value,
|
||||
text: item.label,
|
||||
'data-subtext': group.label
|
||||
'data-subtext': group.label,
|
||||
selected: item.selected ? 'selected' : undefined
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user