filter with preload - filtering improved

This commit is contained in:
fbsanchez 2021-02-05 15:10:31 +01:00
parent 9a439a96e5
commit 679ada717e
3 changed files with 51 additions and 59 deletions

View File

@ -3673,6 +3673,13 @@ class AgentWizard extends HTML
$blockComponentList .= $component['component_id'].',';
}
$is_up = false;
if ($this->getOperStatus($idBlock) === 1
&& $this->getAdminSTatus($idBlock) === 1
) {
$is_up = true;
}
$blockComponentList = chop($blockComponentList, ',');
// Title of Block.
if ($isInterface === true) {
@ -3683,15 +3690,16 @@ class AgentWizard extends HTML
);
$blockTitle .= '</b>';
} else {
$blockTitle = html_print_checkbox_switch_extended(
'interfaz_select_'.$idBlock,
1,
true,
false,
'',
'form="form-create-modules" class="interfaz_select" ',
true,
$md5IdBlock
$blockTitle = html_print_input(
[
'type' => 'switch',
'name' => 'interfaz_select_'.$idBlock,
'value' => $is_up,
'disabled' => false,
'attributes' => 'form="form-create-modules" class="interfaz_select" ',
'return' => true,
'id' => $md5IdBlock,
]
);
$blockTitle .= '<b>'.$block['name'];
$blockTitle .= '&nbsp;&nbsp;';
@ -5093,13 +5101,6 @@ class AgentWizard extends HTML
var regex = new RegExp(string, 'i');
var interfaces = $('.interfaces_search');
console.log(string);
console.log('adminstatus');
console.log(filter_online);
console.log('operstatus');
console.log(filter_up);
interfaces.each(function() {
if (string == ''
&& filter_up == false
@ -5122,7 +5123,6 @@ class AgentWizard extends HTML
}
if (filter_up == true) {
console.log($(this));
if ($(this).attr('operstatus') != 1) {
$(this).addClass('hidden');
}
@ -5323,29 +5323,18 @@ class AgentWizard extends HTML
* Controls checkboxes for modules.
*/
function switchBlockControlInterfaces(e) {
var string = $('#text-filter-search').val();
if (string == '') {
if (e.checked) {
$(".interfaz_select").prop("checked", true);
} else {
$(".interfaz_select").prop("checked", false);
}
} else {
var regex = new RegExp(string);
var interfaces = $('.interfaces_search');
interfaces.each(function() {
if (this.id.match(regex)) {
$(this).removeClass('hidden');
if (e.checked) {
$("input[name='interfaz_select_" + this.id + "']")
.prop("checked", true);
} else {
$("input[name='interfaz_select_" + this.id + "']")
.prop("checked", false);
}
}
});
// Apply filters if not done yet.
//filterInterfaces();
// Select targets.
var interfaces = document.querySelectorAll(
'.interfaces_search:not(.hidden)'
);
// Apply selection.
for (let iface of interfaces) {
iface.querySelector('input[type="checkbox"]').checked = e.checked;
}
}
/**

View File

@ -4247,7 +4247,7 @@ function html_print_switch($attributes=[])
$attributes['style'] = '';
}
$disabled_class .= (bool) ($attributes['disabled']) ? ' p-slider-disabled' : '';
$disabled_class = (bool) ($attributes['disabled']) ? ' p-slider-disabled' : '';
return "<label class='p-switch' style='".$attributes['style']."'>
<input type='checkbox' ".$html_expand.">

View File

@ -3764,6 +3764,7 @@ function ui_print_event_priority(
* @param boolean $switch Use switch.
* @param string $attributes_switch Switch attributes.
* @param string $toggl_attr Main box extra attributes.
* @param boolean|null $switch_on Switch enabled disabled or depending on hidden_Default.
*
* @return string HTML.
*/
@ -3783,7 +3784,8 @@ function ui_toggle(
$reverseImg=false,
$switch=false,
$attributes_switch='',
$toggl_attr=''
$toggl_attr='',
$switch_on=null
) {
// Generate unique Id.
$uniqid = uniqid('');
@ -3833,7 +3835,7 @@ function ui_toggle(
'content' => html_print_checkbox_switch_extended(
'box_enable_toggle'.$uniqid,
1,
($hidden_default === true) ? 0 : 1,
($switch_on === null) ? (($hidden_default === true) ? 0 : 1) : $switch_on,
false,
'',
$attributes_switch,
@ -3963,7 +3965,8 @@ function ui_print_toggle($data)
(isset($data['reverseImg']) === true) ? $data['reverseImg'] : false,
(isset($data['switch']) === true) ? $data['switch'] : false,
(isset($data['attributes_switch']) === true) ? $data['attributes_switch'] : '',
(isset($data['toggl_attr']) === true) ? $data['toggl_attr'] : ''
(isset($data['toggl_attr']) === true) ? $data['toggl_attr'] : '',
(isset($data['switch_on']) === true) ? $data['switch_on'] : null
);
}