mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-25 10:59:15 +02:00
filtering interfaces in wizard
This commit is contained in:
parent
63834c62a7
commit
9a439a96e5
@ -232,6 +232,17 @@ class AgentWizard extends HTML
|
|||||||
*/
|
*/
|
||||||
private $interfacesFound;
|
private $interfacesFound;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some useful information about interfaces:
|
||||||
|
* `name` => [
|
||||||
|
* operstatus
|
||||||
|
* adminstatus
|
||||||
|
* ]
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $interfacesData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X64 Interfaces
|
* X64 Interfaces
|
||||||
*
|
*
|
||||||
@ -2428,42 +2439,59 @@ class AgentWizard extends HTML
|
|||||||
'action' => $this->sectionUrl,
|
'action' => $this->sectionUrl,
|
||||||
'id' => 'form-filter-interfaces',
|
'id' => 'form-filter-interfaces',
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'class' => 'modal flex flex-row',
|
'class' => 'modal flex flex-row searchbox',
|
||||||
'extra' => '',
|
'extra' => '',
|
||||||
];
|
];
|
||||||
// Inputs.
|
|
||||||
$inputs = [];
|
|
||||||
|
|
||||||
$inputs[] = [
|
// Inputs.
|
||||||
'direct' => 1,
|
$inputs = [
|
||||||
'class' => 'select-interfaces',
|
[
|
||||||
'block_content' => [
|
'direct' => 1,
|
||||||
[
|
'class' => 'select-interfaces',
|
||||||
'label' => __('Select all filtered interfaces'),
|
'block_content' => [
|
||||||
'arguments' => [
|
[
|
||||||
'name' => 'select-all-interfaces',
|
'label' => __('Select all filtered interfaces'),
|
||||||
'type' => 'switch',
|
'arguments' => [
|
||||||
'class' => '',
|
'name' => 'select-all-interfaces',
|
||||||
'return' => true,
|
'type' => 'switch',
|
||||||
'value' => 1,
|
'class' => '',
|
||||||
'onclick' => 'switchBlockControlInterfaces(this);',
|
'return' => true,
|
||||||
|
'value' => 1,
|
||||||
|
'onclick' => 'switchBlockControlInterfaces(this);',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
[
|
||||||
|
'label' => __('Search'),
|
||||||
$inputs[] = [
|
'id' => 'txt-filter-search',
|
||||||
'direct' => 1,
|
'class' => 'textbox',
|
||||||
'block_content' => [
|
'arguments' => [
|
||||||
[
|
'name' => 'filter-search',
|
||||||
'label' => __('Search'),
|
'type' => 'text',
|
||||||
'id' => 'txt-filter-search',
|
'return' => true,
|
||||||
'arguments' => [
|
],
|
||||||
'name' => 'filter-search',
|
],
|
||||||
'type' => 'text',
|
[
|
||||||
'class' => '',
|
'label' => __('OperStatus UP'),
|
||||||
'return' => true,
|
'arguments' => [
|
||||||
],
|
'name' => 'search-oper',
|
||||||
|
'type' => 'switch',
|
||||||
|
'id' => 'search-oper',
|
||||||
|
'onchange' => 'filterInterfaces()',
|
||||||
|
'value' => 0,
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => __('AdminStatus UP'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'search-admin',
|
||||||
|
'type' => 'switch',
|
||||||
|
'id' => 'search-admin',
|
||||||
|
'onchange' => 'filterInterfaces()',
|
||||||
|
'value' => 0,
|
||||||
|
'return' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@ -3573,6 +3601,40 @@ class AgentWizard extends HTML
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve operstatus for given interface.
|
||||||
|
*
|
||||||
|
* @param string $interface_name Interface name.
|
||||||
|
*
|
||||||
|
* @return integer OperStatus.
|
||||||
|
*/
|
||||||
|
private function getOperStatus(string $interface_name)
|
||||||
|
{
|
||||||
|
if (is_array($this->interfacesData[$interface_name]) === true) {
|
||||||
|
return (int) $this->interfacesData[$interface_name]['operstatus'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve adminstatus for given interface.
|
||||||
|
*
|
||||||
|
* @param string $interface_name Interface name.
|
||||||
|
*
|
||||||
|
* @return integer AdminStatus.
|
||||||
|
*/
|
||||||
|
private function getAdminStatus(string $interface_name)
|
||||||
|
{
|
||||||
|
if (is_array($this->interfacesData[$interface_name]) === true) {
|
||||||
|
return (int) $this->interfacesData[$interface_name]['adminstatus'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the tables with toggle interface for show the modules availables.
|
* Create the tables with toggle interface for show the modules availables.
|
||||||
*
|
*
|
||||||
@ -3627,7 +3689,7 @@ class AgentWizard extends HTML
|
|||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
'',
|
'',
|
||||||
'form="form-create-modules" class="interfaz_select"',
|
'form="form-create-modules" class="interfaz_select" ',
|
||||||
true,
|
true,
|
||||||
$md5IdBlock
|
$md5IdBlock
|
||||||
);
|
);
|
||||||
@ -4156,6 +4218,10 @@ class AgentWizard extends HTML
|
|||||||
|
|
||||||
$open = true;
|
$open = true;
|
||||||
$buttonSwitch = false;
|
$buttonSwitch = false;
|
||||||
|
$attr = 'operstatus="'.$this->getOperStatus($idBlock).'" ';
|
||||||
|
$attr .= 'adminstatus="';
|
||||||
|
$attr .= $this->getAdminStatus($idBlock).'" ';
|
||||||
|
|
||||||
$class = 'box-shadow white_table_graph interfaces_search';
|
$class = 'box-shadow white_table_graph interfaces_search';
|
||||||
$reverseImg = true;
|
$reverseImg = true;
|
||||||
if ($isPrincipal === true) {
|
if ($isPrincipal === true) {
|
||||||
@ -4165,22 +4231,25 @@ class AgentWizard extends HTML
|
|||||||
$reverseImg = false;
|
$reverseImg = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= ui_toggle(
|
$output .= ui_print_toggle(
|
||||||
$content,
|
[
|
||||||
$blockTitle,
|
'content' => $content,
|
||||||
'',
|
'name' => $blockTitle,
|
||||||
$idBlock,
|
'title' => '',
|
||||||
$open,
|
'id' => $idBlock,
|
||||||
true,
|
'hidden_default' => $open,
|
||||||
'',
|
'return' => true,
|
||||||
'white-box-content',
|
'toggle_class' => '',
|
||||||
$class,
|
'container_class' => 'white-box-content',
|
||||||
'images/arrow_down_green.png',
|
'main_class' => $class,
|
||||||
'images/arrow_right_green.png',
|
'img_a' => 'images/arrow_down_green.png',
|
||||||
false,
|
'img_b' => 'images/arrow_right_green.png',
|
||||||
$reverseImg,
|
'clean' => false,
|
||||||
$buttonSwitch,
|
'reverseImg' => $reverseImg,
|
||||||
'form="form-create-modules"'
|
'switch' => $buttonSwitch,
|
||||||
|
'attributes_switch' => 'form="form-create-modules"',
|
||||||
|
'toggl_attr' => $attr,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4221,16 +4290,35 @@ class AgentWizard extends HTML
|
|||||||
// Definition object.
|
// Definition object.
|
||||||
$definition = [];
|
$definition = [];
|
||||||
|
|
||||||
|
// Fulfill extra info.
|
||||||
|
$this->interfacesData[$data['name']] = [];
|
||||||
|
|
||||||
// IfOperStatus.
|
// IfOperStatus.
|
||||||
$adminStatusValue = 1;
|
$adminStatusValue = 1;
|
||||||
if (empty($data) === false) {
|
if (empty($data) === false) {
|
||||||
$adminStatusValue = $this->snmpgetValue(
|
$adminStatusValue = $this->snmpgetValue(
|
||||||
'1.3.6.1.2.1.2.2.1.7.'.$value
|
'1.3.6.1.2.1.2.2.1.7.'.$value
|
||||||
);
|
);
|
||||||
|
|
||||||
preg_match('/\((\d+?)\)/', $adminStatusValue, $match);
|
preg_match('/\((\d+?)\)/', $adminStatusValue, $match);
|
||||||
$adminStatusValue = (int) $match[1];
|
$adminStatusValue = (int) $match[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IfOperStatus.
|
||||||
|
$operStatusValue = 1;
|
||||||
|
if (empty($data) === false) {
|
||||||
|
$operStatusValue = $this->snmpgetValue(
|
||||||
|
'1.3.6.1.2.1.2.2.1.8.'.$value
|
||||||
|
);
|
||||||
|
|
||||||
|
preg_match('/\((\d+?)\)/', $operStatusValue, $match);
|
||||||
|
$operStatusValue = (int) $match[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store aux data.
|
||||||
|
$this->interfacesData[$data['name']]['adminstatus'] = $adminStatusValue;
|
||||||
|
$this->interfacesData[$data['name']]['operstatus'] = $operStatusValue;
|
||||||
|
|
||||||
if ($adminStatusValue === 3) {
|
if ($adminStatusValue === 3) {
|
||||||
$min_warning = 3;
|
$min_warning = 3;
|
||||||
$max_warning = 4;
|
$max_warning = 4;
|
||||||
@ -4996,6 +5084,53 @@ class AgentWizard extends HTML
|
|||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
function filterInterfaces() {
|
||||||
|
var string = $('#text-filter-search').val().trim();
|
||||||
|
var filter_online = document.getElementById('search-admin').checked;
|
||||||
|
var filter_up = document.getElementById('search-oper').checked;
|
||||||
|
|
||||||
|
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
|
||||||
|
&& filter_online == false
|
||||||
|
) {
|
||||||
|
$(this).removeClass('hidden');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.id.match(regex)) {
|
||||||
|
$(this).removeClass('hidden');
|
||||||
|
} else {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter_online == true) {
|
||||||
|
if ($(this).attr('adminstatus') != 1) {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter_up == true) {
|
||||||
|
console.log($(this));
|
||||||
|
if ($(this).attr('operstatus') != 1) {
|
||||||
|
$(this).addClass('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Meta.
|
// Meta.
|
||||||
var meta = "<?php echo is_metaconsole(); ?>";
|
var meta = "<?php echo is_metaconsole(); ?>";
|
||||||
@ -5009,20 +5144,7 @@ class AgentWizard extends HTML
|
|||||||
|
|
||||||
// Filter search interfaces snmp.
|
// Filter search interfaces snmp.
|
||||||
$('#text-filter-search').keyup(function() {
|
$('#text-filter-search').keyup(function() {
|
||||||
var string = $('#text-filter-search').val();
|
filterInterfaces();
|
||||||
var regex = new RegExp(string);
|
|
||||||
var interfaces = $('.interfaces_search');
|
|
||||||
interfaces.each(function() {
|
|
||||||
if (string == '') {
|
|
||||||
$(this).removeClass('hidden');
|
|
||||||
} else {
|
|
||||||
if (this.id.match(regex)) {
|
|
||||||
$(this).removeClass('hidden');
|
|
||||||
} else {
|
|
||||||
$(this).addClass('hidden');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Loading.
|
// Loading.
|
||||||
|
@ -2923,7 +2923,7 @@ function ui_progress(
|
|||||||
$id = uniqid();
|
$id = uniqid();
|
||||||
|
|
||||||
ui_require_css_file('progress');
|
ui_require_css_file('progress');
|
||||||
$output .= '<span id="'.$id.'" class="progress_main" data-label="'.$text;
|
$output = '<span id="'.$id.'" class="progress_main" data-label="'.$text;
|
||||||
$output .= '" style="width: '.$width.'; height: '.$height.'em; border: 1px solid '.$color.'">';
|
$output .= '" style="width: '.$width.'; height: '.$height.'em; border: 1px solid '.$color.'">';
|
||||||
$output .= '<span id="'.$id.'_progress" class="progress" style="width: '.$progress.'%; background: '.$color.'"></span>';
|
$output .= '<span id="'.$id.'_progress" class="progress" style="width: '.$progress.'%; background: '.$color.'"></span>';
|
||||||
$output .= '</span>';
|
$output .= '</span>';
|
||||||
@ -3076,7 +3076,7 @@ function ui_progress_extend(
|
|||||||
ui_require_css_file('progress');
|
ui_require_css_file('progress');
|
||||||
|
|
||||||
// Main container.
|
// Main container.
|
||||||
$output .= '<div class="progress_main_noborder" ';
|
$output = '<div class="progress_main_noborder" ';
|
||||||
$output .= '" style="width:'.$data['width'].'%;';
|
$output .= '" style="width:'.$data['width'].'%;';
|
||||||
$output .= ' height:'.$data['height'].'em;">';
|
$output .= ' height:'.$data['height'].'em;">';
|
||||||
|
|
||||||
@ -3419,6 +3419,7 @@ function ui_print_datatable(array $parameters)
|
|||||||
$js .= $parameters['drawCallback'];
|
$js .= $parameters['drawCallback'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$columns = '';
|
||||||
for ($i = 1; $i <= (count($parameters['columns']) - 3); $i++) {
|
for ($i = 1; $i <= (count($parameters['columns']) - 3); $i++) {
|
||||||
if ($i != (count($parameters['columns']) - 3)) {
|
if ($i != (count($parameters['columns']) - 3)) {
|
||||||
$columns .= $i.',';
|
$columns .= $i.',';
|
||||||
@ -3747,18 +3748,22 @@ 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 $switch Use switch.
|
||||||
|
* @param string $attributes_switch Switch attributes.
|
||||||
|
* @param string $toggl_attr Main box extra attributes.
|
||||||
*
|
*
|
||||||
* @return string HTML.
|
* @return string HTML.
|
||||||
*/
|
*/
|
||||||
@ -3777,7 +3782,8 @@ function ui_toggle(
|
|||||||
$clean=false,
|
$clean=false,
|
||||||
$reverseImg=false,
|
$reverseImg=false,
|
||||||
$switch=false,
|
$switch=false,
|
||||||
$attributes_switch=''
|
$attributes_switch='',
|
||||||
|
$toggl_attr=''
|
||||||
) {
|
) {
|
||||||
// Generate unique Id.
|
// Generate unique Id.
|
||||||
$uniqid = uniqid('');
|
$uniqid = uniqid('');
|
||||||
@ -3817,7 +3823,7 @@ function ui_toggle(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Link to toggle.
|
// Link to toggle.
|
||||||
$output = '<div class="'.$main_class.'" id="'.$id.'">';
|
$output = '<div class="'.$main_class.'" id="'.$id.'" '.$toggl_attr.'>';
|
||||||
$output .= '<div class="'.$header_class.'" style="cursor: pointer;" id="tgl_ctrl_'.$uniqid.'">';
|
$output .= '<div class="'.$header_class.'" style="cursor: pointer;" id="tgl_ctrl_'.$uniqid.'">';
|
||||||
if ($reverseImg === false) {
|
if ($reverseImg === false) {
|
||||||
if ($switch === true) {
|
if ($switch === true) {
|
||||||
@ -3953,7 +3959,11 @@ function ui_print_toggle($data)
|
|||||||
(isset($data['main_class']) === true) ? $data['main_class'] : 'box-shadow white_table_graph',
|
(isset($data['main_class']) === true) ? $data['main_class'] : 'box-shadow white_table_graph',
|
||||||
(isset($data['img_a']) === true) ? $data['img_a'] : 'images/arrow_down_green.png',
|
(isset($data['img_a']) === true) ? $data['img_a'] : 'images/arrow_down_green.png',
|
||||||
(isset($data['img_b']) === true) ? $data['img_b'] : 'images/arrow_right_green.png',
|
(isset($data['img_b']) === true) ? $data['img_b'] : 'images/arrow_right_green.png',
|
||||||
(isset($data['clean']) === true) ? $data['clean'] : false
|
(isset($data['clean']) === true) ? $data['clean'] : false,
|
||||||
|
(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'] : ''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5661,12 +5671,6 @@ function ui_print_module_string_value(
|
|||||||
$value = io_safe_input($value);
|
$value = io_safe_input($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$is_snapshot = is_snapshot_data($module['datos']);
|
|
||||||
$is_large_image = is_text_to_black_string($module['datos']);
|
|
||||||
if (($config['command_snapshot']) && ($is_snapshot || $is_large_image)) {
|
|
||||||
$row[7] = ui_get_snapshot_image($link, $is_snapshot).' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$is_snapshot = is_snapshot_data($value);
|
$is_snapshot = is_snapshot_data($value);
|
||||||
$is_large_image = is_text_to_black_string($value);
|
$is_large_image = is_text_to_black_string($value);
|
||||||
if (($config['command_snapshot']) && ($is_snapshot || $is_large_image)) {
|
if (($config['command_snapshot']) && ($is_snapshot || $is_large_image)) {
|
||||||
@ -5733,6 +5737,7 @@ function ui_print_module_string_value(
|
|||||||
*/
|
*/
|
||||||
function ui_print_tags_view($title='', $tags=[])
|
function ui_print_tags_view($title='', $tags=[])
|
||||||
{
|
{
|
||||||
|
$tv = '';
|
||||||
if (!empty($title)) {
|
if (!empty($title)) {
|
||||||
$tv .= '<div class="tag-wrapper">';
|
$tv .= '<div class="tag-wrapper">';
|
||||||
$tv .= '<h3>'.$title.'</h3>';
|
$tv .= '<h3>'.$title.'</h3>';
|
||||||
@ -6071,6 +6076,7 @@ function ui_print_comments($comments)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$last_comment = [];
|
||||||
foreach ($comments_array as $comm) {
|
foreach ($comments_array as $comm) {
|
||||||
// Show the comments more recent first.
|
// Show the comments more recent first.
|
||||||
if (is_array($comm)) {
|
if (is_array($comm)) {
|
||||||
|
@ -148,3 +148,20 @@ ul.wizard li > textarea {
|
|||||||
.action_button_list li {
|
.action_button_list li {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.searchbox ul {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchbox ul li:not(.textbox) {
|
||||||
|
flex-direction: row-reverse !important;
|
||||||
|
justify-content: flex-end !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchbox ul li.textbox label {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
.searchbox ul li.textbox {
|
||||||
|
justify-content: space-evenly !important;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user