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

View File

@ -4247,7 +4247,7 @@ function html_print_switch($attributes=[])
$attributes['style'] = ''; $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']."'> return "<label class='p-switch' style='".$attributes['style']."'>
<input type='checkbox' ".$html_expand."> <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. * Print a code into a DIV and enable a toggle to show and hide it.
* *
* @param string $code Html code. * @param string $code Html code.
* @param string $name Name of the link. * @param string $name Name of the link.
* @param string $title Title of the link. * @param string $title Title of the link.
* @param string $id Block id. * @param string $id Block id.
* @param boolean $hidden_default If the div will be hidden by default (default: true). * @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 boolean $return Whether to return an output string or echo now (default: true).
* @param string $toggle_class Toggle class. * @param string $toggle_class Toggle class.
* @param string $container_class Container class. * @param string $container_class Container class.
* @param string $main_class Main object class. * @param string $main_class Main object class.
* @param string $img_a Image (closed). * @param string $img_a Image (closed).
* @param string $img_b Image (opened). * @param string $img_b Image (opened).
* @param string $clean Do not encapsulate with class boxes, clean print. * @param string $clean Do not encapsulate with class boxes, clean print.
* @param boolean $reverseImg Reverse img. * @param boolean $reverseImg Reverse img.
* @param boolean $switch Use switch. * @param boolean $switch Use switch.
* @param string $attributes_switch Switch attributes. * @param string $attributes_switch Switch attributes.
* @param string $toggl_attr Main box extra 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. * @return string HTML.
*/ */
@ -3783,7 +3784,8 @@ function ui_toggle(
$reverseImg=false, $reverseImg=false,
$switch=false, $switch=false,
$attributes_switch='', $attributes_switch='',
$toggl_attr='' $toggl_attr='',
$switch_on=null
) { ) {
// Generate unique Id. // Generate unique Id.
$uniqid = uniqid(''); $uniqid = uniqid('');
@ -3833,7 +3835,7 @@ function ui_toggle(
'content' => html_print_checkbox_switch_extended( 'content' => html_print_checkbox_switch_extended(
'box_enable_toggle'.$uniqid, 'box_enable_toggle'.$uniqid,
1, 1,
($hidden_default === true) ? 0 : 1, ($switch_on === null) ? (($hidden_default === true) ? 0 : 1) : $switch_on,
false, false,
'', '',
$attributes_switch, $attributes_switch,
@ -3963,7 +3965,8 @@ function ui_print_toggle($data)
(isset($data['reverseImg']) === true) ? $data['reverseImg'] : false, (isset($data['reverseImg']) === true) ? $data['reverseImg'] : false,
(isset($data['switch']) === true) ? $data['switch'] : false, (isset($data['switch']) === true) ? $data['switch'] : false,
(isset($data['attributes_switch']) === true) ? $data['attributes_switch'] : '', (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
); );
} }