Improved the search filter and added new info icons to the modules in the tree view
This commit is contained in:
parent
2c975095d7
commit
d8aee5f0fc
|
@ -88,6 +88,12 @@ class Tree {
|
|||
$group_acl = " AND ta.id_grupo IN ($user_groups_str) ";
|
||||
}
|
||||
|
||||
// Agent name filter
|
||||
$agent_search = "";
|
||||
if (!empty($this->filter['search'])) {
|
||||
$agent_search = " AND ta.nombre LIKE '%".$this->filter['search']."%' ";
|
||||
}
|
||||
|
||||
$list_os = os_get_os();
|
||||
|
||||
// Transform the os array to use the item id as key
|
||||
|
@ -109,6 +115,7 @@ class Tree {
|
|||
WHERE ta.id_agente = tam.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND tam.disabled = 0
|
||||
$agent_search
|
||||
$group_acl
|
||||
ORDER BY ta.id_os ASC, ta.nombre ASC";
|
||||
$data = db_process_sql($sql);
|
||||
|
@ -233,9 +240,9 @@ class Tree {
|
|||
$filter = array();
|
||||
$filter['parent'] = $parent;
|
||||
|
||||
if (!empty($this->filter['search'])) {
|
||||
$filter['nombre'] = "%" . $this->filter['search'] . "%";
|
||||
}
|
||||
// if (!empty($this->filter['search'])) {
|
||||
// $filter['nombre'] = "%" . $this->filter['search'] . "%";
|
||||
// }
|
||||
// ACL groups
|
||||
if (isset($this->userGroups) && $this->userGroups === false)
|
||||
return array();
|
||||
|
@ -244,15 +251,15 @@ class Tree {
|
|||
$filter['id_grupo'] = array_keys($this->userGroups);
|
||||
|
||||
// First filter by name and father
|
||||
$groups = db_get_all_rows_filter('tgrupo', $filter, array('id_grupo', 'nombre'));
|
||||
$groups = db_get_all_rows_filter('tgrupo', $filter, array('id_grupo', 'nombre', 'icon'));
|
||||
if (empty($groups))
|
||||
$groups = array();
|
||||
|
||||
// Filter by status
|
||||
$filter_status = AGENT_STATUS_ALL;
|
||||
if (!empty($this->filter['status'])) {
|
||||
$filter_status = $this->filter['status'];
|
||||
}
|
||||
// $filter_status = AGENT_STATUS_ALL;
|
||||
// if (!empty($this->filter['status'])) {
|
||||
// $filter_status = $this->filter['status'];
|
||||
// }
|
||||
|
||||
foreach ($groups as $iterator => $group) {
|
||||
// Counters
|
||||
|
@ -269,39 +276,39 @@ class Tree {
|
|||
}
|
||||
|
||||
$groups[$iterator]['status'] = $group_stats['status'];
|
||||
$groups[$iterator]['icon'] = groups_get_icon($group['id_grupo']) . '.png';
|
||||
$groups[$iterator]['icon'] = !empty($group['icon']) ? $group['icon'] . '.png' : 'without_group.png';
|
||||
|
||||
// Filter by status
|
||||
if ($filter_status != AGENT_STATUS_ALL) {
|
||||
$remove_group = true;
|
||||
switch ($filter_status) {
|
||||
case AGENT_STATUS_NORMAL:
|
||||
if ($groups[$iterator]['status'] === "ok")
|
||||
$remove_group = false;
|
||||
break;
|
||||
case AGENT_STATUS_WARNING:
|
||||
if ($groups[$iterator]['status'] === "warning")
|
||||
$remove_group = false;
|
||||
break;
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
if ($groups[$iterator]['status'] === "critical")
|
||||
$remove_group = false;
|
||||
break;
|
||||
case AGENT_STATUS_UNKNOWN:
|
||||
if ($groups[$iterator]['status'] === "unknown")
|
||||
$remove_group = false;
|
||||
break;
|
||||
case AGENT_STATUS_NOT_INIT:
|
||||
if ($groups[$iterator]['status'] === "not_init")
|
||||
$remove_group = false;
|
||||
break;
|
||||
}
|
||||
// // Filter by status
|
||||
// if ($filter_status != AGENT_STATUS_ALL) {
|
||||
// $remove_group = true;
|
||||
// switch ($filter_status) {
|
||||
// case AGENT_STATUS_NORMAL:
|
||||
// if ($groups[$iterator]['status'] === "ok")
|
||||
// $remove_group = false;
|
||||
// break;
|
||||
// case AGENT_STATUS_WARNING:
|
||||
// if ($groups[$iterator]['status'] === "warning")
|
||||
// $remove_group = false;
|
||||
// break;
|
||||
// case AGENT_STATUS_CRITICAL:
|
||||
// if ($groups[$iterator]['status'] === "critical")
|
||||
// $remove_group = false;
|
||||
// break;
|
||||
// case AGENT_STATUS_UNKNOWN:
|
||||
// if ($groups[$iterator]['status'] === "unknown")
|
||||
// $remove_group = false;
|
||||
// break;
|
||||
// case AGENT_STATUS_NOT_INIT:
|
||||
// if ($groups[$iterator]['status'] === "not_init")
|
||||
// $remove_group = false;
|
||||
// break;
|
||||
// }
|
||||
|
||||
if ($remove_group) {
|
||||
unset($groups[$iterator]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// if ($remove_group) {
|
||||
// unset($groups[$iterator]);
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (is_null($limit)) {
|
||||
$groups[$iterator]['children'] =
|
||||
|
@ -309,9 +316,7 @@ class Tree {
|
|||
}
|
||||
else if ($limit >= 1) {
|
||||
$groups[$iterator]['children'] =
|
||||
$this->getGroupsRecursive(
|
||||
$group['id_grupo'],
|
||||
($limit - 1));
|
||||
$this->getGroupsRecursive($group['id_grupo'], ($limit - 1));
|
||||
}
|
||||
|
||||
switch ($this->countAgentStatusMethod) {
|
||||
|
@ -368,8 +373,11 @@ class Tree {
|
|||
}
|
||||
|
||||
protected function processModule (&$module) {
|
||||
global $config;
|
||||
|
||||
$module['type'] = 'module';
|
||||
$module['id'] = (int) $module['id_agente_modulo'];
|
||||
$module['agentID'] = (int) $module['id_agente'];
|
||||
$module['name'] = $module['nombre'];
|
||||
$module['id_module_type'] = (int) $module['id_tipo_modulo'];
|
||||
// $module['icon'] = modules_get_type_icon($module['id_tipo_modulo']);
|
||||
|
@ -398,6 +406,23 @@ class Tree {
|
|||
$module['status'] = "ok";
|
||||
break;
|
||||
}
|
||||
|
||||
// Link to the Module graph
|
||||
$graphType = return_graphtype($module['id']);
|
||||
$winHandle = dechex(crc32($module['id'] . $module['name']));
|
||||
|
||||
$moduleGraphURL = $config['homeurl'] .
|
||||
"/operation/agentes/stat_win.php?" .
|
||||
"type=$graphType&" .
|
||||
"period=86400&" .
|
||||
"id=" . $module['id'] . "&" .
|
||||
"label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" .
|
||||
"refresh=600";
|
||||
|
||||
$module['moduleGraph'] = array(
|
||||
'url' => $moduleGraphURL,
|
||||
'handle' => $winHandle
|
||||
);
|
||||
}
|
||||
|
||||
protected function processModules ($modules_aux, &$modules) {
|
||||
|
@ -441,12 +466,19 @@ class Tree {
|
|||
$group_acl = " AND ta.id_grupo IN ($user_groups_str) ";
|
||||
}
|
||||
|
||||
// Agent name filter
|
||||
$agent_search = "";
|
||||
if (!empty($this->filter['search'])) {
|
||||
$agent_search = " AND ta.nombre LIKE '%".$this->filter['search']."%' ";
|
||||
}
|
||||
|
||||
$sql = "SELECT tam.nombre AS module_name, tam.id_agente_modulo, tam.id_tipo_modulo,
|
||||
ta.id_agente, ta.nombre AS agent_name
|
||||
FROM tagente ta, tagente_modulo tam
|
||||
WHERE ta.id_agente = tam.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND tam.disabled = 0
|
||||
$agent_search
|
||||
$group_acl
|
||||
ORDER BY tam.nombre ASC, ta.nombre ASC";
|
||||
$data = db_process_sql($sql);
|
||||
|
@ -540,8 +572,10 @@ class Tree {
|
|||
$agent['counters']['alerts'] =
|
||||
agents_get_alerts_fired($agent['id']);
|
||||
|
||||
$agent['statusRaw'] = agents_get_status($agent['id']);
|
||||
|
||||
// Status
|
||||
switch (agents_get_status($agent['id'])) {
|
||||
switch ($agent['statusRaw']) {
|
||||
case AGENT_STATUS_NORMAL:
|
||||
$agent['status'] = "ok";
|
||||
break;
|
||||
|
@ -608,11 +642,13 @@ class Tree {
|
|||
if (!isset($this->userGroups[$parent]))
|
||||
return array();
|
||||
}
|
||||
$filter = array(
|
||||
'id_grupo' => $parent,
|
||||
'status' => $this->filter['status'],
|
||||
'nombre' => "%" . $this->filter['search'] . "%"
|
||||
);
|
||||
$filter = array();
|
||||
$filter['id_grupo'] = $parent;
|
||||
if (isset($this->filter['status']) && $this->filter['status'] != -1)
|
||||
$filter['status'] = $this->filter['status'];
|
||||
if (!empty($this->filter['search']))
|
||||
$filter['nombre'] = "%" . $this->filter['search'] . "%";
|
||||
|
||||
$agents = agents_get_agents($filter, array('id_agente', 'nombre'));
|
||||
if (empty($agents)) {
|
||||
$agents = array();
|
||||
|
@ -645,6 +681,12 @@ class Tree {
|
|||
$group_acl = " AND ta.id_grupo IN ($user_groups_str) ";
|
||||
}
|
||||
|
||||
// Agent name filter
|
||||
$agent_search = "";
|
||||
if (!empty($this->filter['search'])) {
|
||||
$agent_search = " AND ta.nombre LIKE '%".$this->filter['search']."%' ";
|
||||
}
|
||||
|
||||
$module_groups = modules_get_modulegroups();
|
||||
|
||||
if (!empty($module_groups)) {
|
||||
|
@ -655,6 +697,7 @@ class Tree {
|
|||
WHERE ta.id_agente = tam.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND tam.disabled = 0
|
||||
$agent_search
|
||||
$group_acl
|
||||
ORDER BY tam.nombre ASC, ta.nombre ASC";
|
||||
$data = db_process_sql($sql);
|
||||
|
@ -789,6 +832,12 @@ class Tree {
|
|||
$group_acl = " AND ta.id_grupo IN ($user_groups_str) ";
|
||||
}
|
||||
|
||||
// Agent name filter
|
||||
$agent_search = "";
|
||||
if (!empty($this->filter['search'])) {
|
||||
$agent_search = " AND ta.nombre LIKE '%".$this->filter['search']."%' ";
|
||||
}
|
||||
|
||||
$sql = "SELECT tam.nombre AS module_name, tam.id_agente_modulo,
|
||||
tam.id_tipo_modulo, tam.id_module_group,
|
||||
ta.id_agente, ta.nombre AS agent_name,
|
||||
|
@ -799,6 +848,7 @@ class Tree {
|
|||
AND ttm.id_tag = tt.id_tag
|
||||
AND ta.disabled = 0
|
||||
AND tam.disabled = 0
|
||||
$agent_search
|
||||
$group_acl
|
||||
ORDER BY tt.name ASC, ta.nombre ASC";
|
||||
$data = db_process_sql($sql);
|
||||
|
|
|
@ -309,7 +309,43 @@ TreeController = {
|
|||
$content.append(element.name);
|
||||
break;
|
||||
case 'module':
|
||||
$content.append(element.name);
|
||||
// Graph pop-up
|
||||
var $graphImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
|
||||
+'images/chart_curve.png" /> ');
|
||||
$graphImage
|
||||
.addClass('module-graph')
|
||||
.click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
try {
|
||||
winopeng(element.moduleGraph.url, element.moduleGraph.handle);
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
|
||||
// Data pop-up
|
||||
var $dataImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
|
||||
+'images/binary.png" /> ');
|
||||
$dataImage
|
||||
.addClass('module-data')
|
||||
.click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
try {
|
||||
if ($("#module_details_window").length > 0)
|
||||
show_module_detail_dialog(element.id, element.agentID, '', 0, 86400);
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
|
||||
$content
|
||||
.append($graphImage)
|
||||
.append($dataImage)
|
||||
.append(element.name);
|
||||
break;
|
||||
case 'os':
|
||||
if (typeof element.icon != 'undefined' && element.icon.length > 0) {
|
||||
|
|
|
@ -2931,15 +2931,26 @@ table#policy_modules td * {
|
|||
max-width: 20px;
|
||||
}
|
||||
|
||||
.tree-node-counters, .tree-node-counter {
|
||||
.tree-node>.node-content>img.module-data,
|
||||
.tree-node>.node-content>img.module-graph {
|
||||
cursor: pointer;
|
||||
padding-right: 3px;
|
||||
}
|
||||
|
||||
.tree-node>.node-content>.tree-node-counters,
|
||||
.tree-node>.node-content>.tree-node-counters>.tree-node-counter {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.tree-node-counters {
|
||||
.tree-node>.node-content>.tree-node-counters {
|
||||
|
||||
}
|
||||
|
||||
.tree-node-counter {
|
||||
.tree-node>.node-content>img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.tree-node>.node-content>.tree-node-counters>.tree-node-counter {
|
||||
font-weight: bold;
|
||||
font-size: 7pt;
|
||||
cursor: default;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -132,6 +132,8 @@ html_print_table($table);
|
|||
echo '</form>';
|
||||
|
||||
// --------------------- form filter -----------------------------------
|
||||
ui_include_time_picker();
|
||||
ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/");
|
||||
|
||||
ui_require_javascript_file("TreeController", "include/javascript/tree/");
|
||||
html_print_image('images/spinner.gif', false,
|
||||
|
@ -234,4 +236,93 @@ echo "</div>";
|
|||
});
|
||||
}
|
||||
|
||||
// Show the modal window of an module
|
||||
var moduleDetailsWindow = $("<div></div>");
|
||||
moduleDetailsWindow
|
||||
.hide()
|
||||
.prop("id", "module_details_window")
|
||||
.appendTo('body');
|
||||
|
||||
function show_module_detail_dialog(module_id, id_agent, server_name, offset, period) {
|
||||
var params = {};
|
||||
|
||||
if (period == -1) {
|
||||
period = $('#period').val();
|
||||
params.selection_mode = $('input[name=selection_mode]:checked').val();
|
||||
params.date_from = $('#text-date_from').val();
|
||||
params.time_from = $('#text-time_from').val();
|
||||
params.date_to = $('#text-date_to').val();
|
||||
params.time_to = $('#text-time_to').val();
|
||||
}
|
||||
|
||||
params.page = "include/ajax/module";
|
||||
params.get_module_detail = 1;
|
||||
params.server_name = server_name;
|
||||
params.id_agent = id_agent;
|
||||
params.id_module = module_id;
|
||||
params.offset = offset;
|
||||
params.period = period;
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
data: params,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
$("#module_details_window").hide ()
|
||||
.empty ()
|
||||
.append (data)
|
||||
.dialog ({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
width: 650,
|
||||
height: 500
|
||||
})
|
||||
.show ();
|
||||
refresh_pagination_callback(module_id, id_agent, server_name);
|
||||
datetime_picker_callback();
|
||||
forced_title_callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function datetime_picker_callback() {
|
||||
$("#text-time_from, #text-time_to").timepicker({
|
||||
showSecond: true,
|
||||
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
|
||||
timeOnlyTitle: '<?php echo __('Choose time');?>',
|
||||
timeText: '<?php echo __('Time');?>',
|
||||
hourText: '<?php echo __('Hour');?>',
|
||||
minuteText: '<?php echo __('Minute');?>',
|
||||
secondText: '<?php echo __('Second');?>',
|
||||
currentText: '<?php echo __('Now');?>',
|
||||
closeText: '<?php echo __('Close');?>'});
|
||||
|
||||
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
|
||||
$("#text-date_from, #text-date_to").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
|
||||
|
||||
}
|
||||
|
||||
function refresh_pagination_callback (module_id, id_agent, server_name) {
|
||||
|
||||
$(".binary_dialog").click( function() {
|
||||
|
||||
var classes = $(this).attr('class');
|
||||
classes = classes.split(' ');
|
||||
var offset_class = classes[2];
|
||||
offset_class = offset_class.split('_');
|
||||
var offset = offset_class[1];
|
||||
|
||||
var period = $('#period').val();
|
||||
|
||||
show_module_detail_dialog(module_id, id_agent, server_name, offset, period);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
Loading…
Reference in New Issue