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

@ -3748,22 +3748,23 @@ function ui_print_event_priority(
/**
* Print a code into a DIV and enable a toggle to show and hide it.
*
* @param string $code Html code.
* @param string $name Name of the link.
* @param string $title Title of the link.
* @param string $id Block id.
* @param boolean $hidden_default If the div will be hidden by default (default: true).
* @param boolean $return Whether to return an output string or echo now (default: true).
* @param string $toggle_class Toggle class.
* @param string $container_class Container class.
* @param string $main_class Main object class.
* @param string $img_a Image (closed).
* @param string $img_b Image (opened).
* @param string $clean Do not encapsulate with class boxes, clean print.
* @param boolean $reverseImg Reverse img.
* @param boolean $switch Use switch.
* @param string $attributes_switch Switch attributes.
* @param string $toggl_attr Main box extra attributes.
* @param string $code Html code.
* @param string $name Name of the link.
* @param string $title Title of the link.
* @param string $id Block id.
* @param boolean $hidden_default If the div will be hidden by default (default: true).
* @param boolean $return Whether to return an output string or echo now (default: true).
* @param string $toggle_class Toggle class.
* @param string $container_class Container class.
* @param string $main_class Main object class.
* @param string $img_a Image (closed).
* @param string $img_b Image (opened).
* @param string $clean Do not encapsulate with class boxes, clean print.
* @param boolean $reverseImg Reverse img.
* @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
);
}