Alerts list datatable
This commit is contained in:
parent
fb5dd4d557
commit
34333f9f88
|
@ -37,6 +37,8 @@ $get_actions_module = (bool) get_parameter('get_actions_module');
|
|||
$show_update_action_menu = (bool) get_parameter('show_update_action_menu');
|
||||
$get_agent_alerts_agent_view = (bool) get_parameter('get_agent_alerts_agent_view');
|
||||
$resize_event_week = (bool) get_parameter('resize_event_week');
|
||||
$get_agent_alerts_datatable = (bool) get_parameter('get_agent_alerts_datatable', 0);
|
||||
$alert_validate = (bool) get_parameter('alert_validate', false);
|
||||
|
||||
if ($get_agent_alerts_simple) {
|
||||
$id_agent = (int) get_parameter('id_agent');
|
||||
|
@ -620,4 +622,325 @@ if ($resize_event_week === true) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($alert_validate === true) {
|
||||
include_once 'operation/agentes/alerts_status.functions.php';
|
||||
$all_groups = get_parameter('all_groups');
|
||||
$alert_ids = get_parameter('alert_ids', '');
|
||||
|
||||
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') || check_acl_one_of_groups($config['id_user'], $all_groups, 'LM')) {
|
||||
$result = validateAlert($alert_ids);
|
||||
} else {
|
||||
$result = ui_print_error_message(__('Insufficient permissions to validate alerts'), '', true);
|
||||
}
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_agent_alerts_datatable === true) {
|
||||
// Datatables offset, limit and order.
|
||||
$filter_alert = get_parameter('filter', []);
|
||||
unset($filter_alert[0]);
|
||||
$start = (int) get_parameter('start', 0);
|
||||
$length = (int) get_parameter('length', $config['block_size']);
|
||||
$order = get_datatable_order(true);
|
||||
$url = get_parameter('url', '#');
|
||||
|
||||
$free_search_alert = $filter_alert['free_search_alert'];
|
||||
$idGroup = $filter_alert['ag_group'];
|
||||
$tag_filter = $filter_alert['tag_filter'];
|
||||
$action_filter = $filter_alert['action'];
|
||||
|
||||
try {
|
||||
ob_start();
|
||||
include_once $config['homedir'].'/include/functions_agents.php';
|
||||
include_once $config['homedir'].'/operation/agentes/alerts_status.functions.php';
|
||||
include_once $config['homedir'].'/include/functions_users.php';
|
||||
|
||||
$agent_a = check_acl($config['id_user'], 0, 'AR');
|
||||
$agent_w = check_acl($config['id_user'], 0, 'AW');
|
||||
$access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR');
|
||||
|
||||
$all_groups = get_parameter('all_groups');
|
||||
$idAgent = (int) get_parameter('id_agent');
|
||||
|
||||
$sortField = $order['field'];
|
||||
$sort = $order['direction'];
|
||||
$selected = true;
|
||||
$selectModuleUp = false;
|
||||
$selectModuleDown = false;
|
||||
$selectTemplateUp = false;
|
||||
$selectTemplateDown = false;
|
||||
$selectLastFiredUp = false;
|
||||
$selectLastFiredDown = false;
|
||||
|
||||
switch ($sortField) {
|
||||
case 'module':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectModuleasc = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'desc':
|
||||
$selectModuledesc = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'template':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectTemplateasc = $selected;
|
||||
$order = [
|
||||
'field' => 'template_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'desc':
|
||||
$selectTemplatedesc = $selected;
|
||||
$order = [
|
||||
'field' => 'template_name',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'lastFired':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectLastFiredasc = $selected;
|
||||
$order = [
|
||||
'field' => 'last_fired',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'desc':
|
||||
$selectLastFireddesc = $selected;
|
||||
$order = [
|
||||
'field' => 'last_fired',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'agent':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectLastFiredasc = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'desc':
|
||||
$selectLastFireddesc = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_name',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectLastFiredasc = $selected;
|
||||
$order = [
|
||||
'field' => 'times_fired',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'desc':
|
||||
$selectLastFireddesc = $selected;
|
||||
$order = [
|
||||
'field' => 'times_fired',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$selectDisabledasc = '';
|
||||
$selectDisableddesc = '';
|
||||
$selectModuleasc = $selected;
|
||||
$selectModuledesc = false;
|
||||
$selectTemplateasc = false;
|
||||
$selectTemplatedesc = false;
|
||||
$selectLastFiredasc = false;
|
||||
$selectLastFireddesc = false;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
if ($free_search_alert != '') {
|
||||
$whereAlertSimple = 'AND ('.'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE name LIKE "%'.$free_search_alert.'%") OR '.'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%'.$free_search_alert.'%")) OR '.'talert_template_modules.id IN (
|
||||
SELECT id_alert_template_module
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%'.$free_search_alert.'%")) OR '.'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE nombre LIKE "%'.$free_search_alert.'%") OR '.'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE alias LIKE "%'.$free_search_alert.'%")'.')';
|
||||
} else {
|
||||
$whereAlertSimple = '';
|
||||
}
|
||||
|
||||
// Add checks for user ACL.
|
||||
$groups = users_get_groups($config['id_user'], $access);
|
||||
$id_groups = array_keys($groups);
|
||||
|
||||
if (empty($id_groups)) {
|
||||
$whereAlertSimple .= ' AND (1 = 0) ';
|
||||
} else {
|
||||
$whereAlertSimple .= sprintf(
|
||||
' AND id_agent_module IN (
|
||||
SELECT tam.id_agente_modulo
|
||||
FROM tagente_modulo tam
|
||||
WHERE tam.id_agente IN (SELECT ta.id_agente
|
||||
FROM tagente ta LEFT JOIN tagent_secondary_group tasg ON
|
||||
ta.id_agente = tasg.id_agent
|
||||
WHERE (ta.id_grupo IN (%s) OR tasg.id_group IN (%s)))) ',
|
||||
implode(',', $id_groups),
|
||||
implode(',', $id_groups)
|
||||
);
|
||||
}
|
||||
|
||||
$alerts = [];
|
||||
if ($agent_view_page === true) {
|
||||
$options_simple = ['order' => $order];
|
||||
} else {
|
||||
$options_simple = [
|
||||
'order' => $order,
|
||||
'limit' => $length,
|
||||
'offset' => $start,
|
||||
];
|
||||
}
|
||||
|
||||
if ($idAgent !== 0) {
|
||||
$filter_alert['disabled'] = 'all_enabled';
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
include_once $config['homedir'].'/enterprise/meta/include/functions_alerts_meta.php';
|
||||
if ($idAgent != 0) {
|
||||
$alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
} else {
|
||||
$id_groups = array_keys(
|
||||
users_get_groups($config['id_user'], 'AR', false)
|
||||
);
|
||||
|
||||
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
}
|
||||
} else {
|
||||
if ($idAgent != 0) {
|
||||
$alerts['alerts_simple'] = agents_get_alerts_simple($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter);
|
||||
|
||||
$countAlertsSimple = agents_get_alerts_simple($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter);
|
||||
} else {
|
||||
$id_groups = array_keys(
|
||||
users_get_groups($config['id_user'], $access, false)
|
||||
);
|
||||
|
||||
$alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
}
|
||||
}
|
||||
|
||||
$data = [];
|
||||
if ($alerts['alerts_simple']) {
|
||||
foreach ($alerts['alerts_simple'] as $alert) {
|
||||
$data[] = ui_format_alert_row($alert, true, $url, 'font-size: 7pt;');
|
||||
}
|
||||
|
||||
$data = array_reduce(
|
||||
$data,
|
||||
function ($carry, $row) {
|
||||
// Transforms array of arrays $data into an array
|
||||
// of objects, making a post-process of certain fields.
|
||||
$tmp = new stdClass();
|
||||
|
||||
// Standby.
|
||||
$tmp->policy = $row[0];
|
||||
$tmp->standby = $row[1];
|
||||
$tmp->force = $row[2];
|
||||
$tmp->agent = $row[3];
|
||||
$tmp->module = $row[4];
|
||||
$tmp->template = $row[5];
|
||||
$tmp->action = $row[6];
|
||||
$tmp->lastFired = $row[7];
|
||||
$tmp->status = $row[8];
|
||||
$tmp->validate = $row[9];
|
||||
|
||||
$carry[] = $tmp;
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Datatables format: RecordsTotal && recordsfiltered.
|
||||
echo json_encode(
|
||||
[
|
||||
'data' => $data,
|
||||
'recordsTotal' => $countAlertsSimple,
|
||||
'recordsFiltered' => $countAlertsSimple,
|
||||
]
|
||||
);
|
||||
// Capture output.
|
||||
$response = ob_get_clean();
|
||||
} catch (\Exception $e) {
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// If not valid, show error with issue.
|
||||
json_decode($response);
|
||||
if (json_last_error() == JSON_ERROR_NONE) {
|
||||
// If valid dump.
|
||||
echo $response;
|
||||
} else {
|
||||
echo json_encode(
|
||||
['error' => $response]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -369,7 +369,11 @@ function agents_get_alerts_simple($id_agent=false, $filter='', $options=false, $
|
|||
}
|
||||
|
||||
// Filter by agents id.
|
||||
$id_agents_list = implode(',', $id_agent);
|
||||
if (is_array($id_agent) === true && empty($id_agent) === false) {
|
||||
$id_agents_list = implode(',', $id_agent);
|
||||
} else {
|
||||
$id_agents_list = $id_agent;
|
||||
}
|
||||
|
||||
if ($id_agents_list === '') {
|
||||
$id_agents_list = '0';
|
||||
|
|
|
@ -2109,7 +2109,7 @@ function get_group_alerts(
|
|||
|
||||
if (is_array($filter)) {
|
||||
$disabled = $filter['disabled'];
|
||||
if (isset($filter['standby'])) {
|
||||
if ((isset($filter['standby']) === true) && ($filter['standby'] !== '')) {
|
||||
$filter = $group_query.' AND talert_template_modules.standby = "'.$filter['standby'].'"';
|
||||
} else {
|
||||
$filter = $group_query;
|
||||
|
|
|
@ -1179,7 +1179,18 @@ function ui_format_alert_row(
|
|||
}
|
||||
|
||||
if (is_metaconsole() === true || !can_user_access_node()) {
|
||||
$data[$index['agent_name']] = ui_print_truncate_text($agent_name, 'agent_small', false, true, true, '[…]', '');
|
||||
$pwd = $server['auth_token'];
|
||||
// Create HASH login info.
|
||||
$user = $config['id_user'];
|
||||
|
||||
// Extract auth token from serialized field.
|
||||
$pwd_deserialiced = json_decode($pwd, true);
|
||||
$hashdata = $user.$pwd_deserialiced['auth_token'];
|
||||
|
||||
$hashdata = md5($hashdata);
|
||||
$url = $server['server_url'].'/index.php?'.'sec=estado&'.'sec2=operation/agentes/ver_agente&'.'id_agente='.$agente['id_agente'].'&'.'loginhash=auto&'."loginhash_data=$hashdata&".'loginhash_user='.str_rot13($user);
|
||||
|
||||
$data[$index['agent_name']] .= '<a href="'.$url.'">'.'<b><span class="bolder" title="'.$agente['nombre'].'">'.$agente['alias'].'</span></b></a>';
|
||||
} else {
|
||||
if ($agent_style !== false) {
|
||||
$data[$index['agent_name']] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent.'"> <span class="bolder" title ="'.$agente['nombre'].'">'.$agente['alias'].'</span></a>';
|
||||
|
@ -3392,16 +3403,18 @@ function ui_print_datatable(array $parameters)
|
|||
$filter .= '</li>';
|
||||
|
||||
$filter .= '</ul><div id="both"></div></form>';
|
||||
$filter = ui_toggle(
|
||||
$filter,
|
||||
__('Filter'),
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
'white_box white_box_opened',
|
||||
'no-border'
|
||||
);
|
||||
if (isset($parameters['form']['no_toggle']) === false && ($parameters['form']['no_toggle'] !== true)) {
|
||||
$filter = ui_toggle(
|
||||
$filter,
|
||||
__('Filter'),
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
'white_box white_box_opened',
|
||||
'no-border'
|
||||
);
|
||||
}
|
||||
} else if (isset($parameters['form_html'])) {
|
||||
$filter = ui_toggle(
|
||||
$parameters['form_html'],
|
||||
|
@ -3417,6 +3430,8 @@ function ui_print_datatable(array $parameters)
|
|||
|
||||
// Languages.
|
||||
$processing = __('Processing');
|
||||
$zeroRecords = isset($parameters['zeroRecords']) === true ? $parameters['zeroRecords'] : __('No matching records found');
|
||||
$emptyTable = isset($parameters['emptyTable']) === true ? $parameters['emptyTable'] : __('No data available in table');
|
||||
|
||||
// Extra html.
|
||||
$extra = '';
|
||||
|
@ -3441,6 +3456,7 @@ function ui_print_datatable(array $parameters)
|
|||
foreach ($names as $column) {
|
||||
if (is_array($column)) {
|
||||
$table .= '<th id="'.$column['id'].'" class="'.$column['class'].'" ';
|
||||
$table .= 'title="'.__($column['title']).'" ';
|
||||
$table .= ' style="'.$column['style'].'">'.__($column['text']);
|
||||
$table .= $column['extra'];
|
||||
$table .= '</th>';
|
||||
|
@ -3499,7 +3515,9 @@ function ui_print_datatable(array $parameters)
|
|||
responsive: true,
|
||||
dom: "plfrtiBp",
|
||||
language: {
|
||||
processing:"'.$processing.'"
|
||||
processing:"'.$processing.'",
|
||||
zeroRecords:"'.$zeroRecords.'",
|
||||
emptyYable:"'.$emptyTable.'",
|
||||
},
|
||||
buttons: '.$parameters['csv'].'== 1 ? [
|
||||
{
|
||||
|
|
|
@ -1705,6 +1705,17 @@ div#agent_wizard_subtabs {
|
|||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.databox.no-border {
|
||||
margin-bottom: 5px;
|
||||
margin-top: 0px;
|
||||
margin-left: 0px;
|
||||
border: none;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.databox_color {
|
||||
padding-top: 5px;
|
||||
background-color: #fafafa;
|
||||
|
|
|
@ -37,19 +37,21 @@ function forceExecution($id_group)
|
|||
}
|
||||
|
||||
|
||||
function validateAlert()
|
||||
function validateAlert($ids)
|
||||
{
|
||||
$ids = (array) get_parameter_post('validate', []);
|
||||
|
||||
if (!empty($ids)) {
|
||||
include_once 'include/functions_alerts.php';
|
||||
$result = alerts_validate_alert_agent_module($ids);
|
||||
|
||||
ui_print_result_message(
|
||||
return ui_print_result_message(
|
||||
$result,
|
||||
__('Alert(s) validated'),
|
||||
__('Error processing alert(s)')
|
||||
__('Error processing alert(s)'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
} else {
|
||||
return ui_print_error_message(__('No alert selected'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,11 +63,11 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
|
|||
|
||||
$table = new StdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filters';
|
||||
$table->class = 'databox filters no-border';
|
||||
$table->cellpadding = '0';
|
||||
$table->cellspacing = '0';
|
||||
if (defined('METACONSOLE')) {
|
||||
$table->class = 'databox filters';
|
||||
$table->class = 'databox filters no-border';
|
||||
$table->width = '100%';
|
||||
$table->cellpadding = '0';
|
||||
$table->cellspacing = '0';
|
||||
|
@ -97,12 +99,11 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
|
|||
$alert_status_filter['disabled'] = __('Disabled');
|
||||
|
||||
$alert_standby = [];
|
||||
$alert_standby['all'] = __('All');
|
||||
$alert_standby['standby_on'] = __('Standby on');
|
||||
$alert_standby['standby_off'] = __('Standby off');
|
||||
$alert_standby['1'] = __('Standby on');
|
||||
$alert_standby['0'] = __('Standby off');
|
||||
|
||||
$table->data[0][2] = __('Status');
|
||||
$table->data[0][3] = html_print_select($alert_status_filter, 'filter', $filter, '', '', '', true);
|
||||
$table->data[0][3] = html_print_select($alert_status_filter, 'disabled', $filter, '', '', '', true);
|
||||
|
||||
$table->data[0][4] = __('Tags').ui_print_help_tip(__('Only it is show tags in use.'), true);
|
||||
|
||||
|
@ -111,7 +112,7 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
|
|||
if (empty($tags)) {
|
||||
$table->data[0][5] .= html_print_input_text('tags', __('No tags'), '', 20, 40, true, true);
|
||||
} else {
|
||||
$table->data[0][5] .= html_print_select($tags, 'tag_filter', $tag_filter, '', __('All'), '', true, false, true, '', false, 'width: 150px;');
|
||||
$table->data[0][5] .= html_print_select($tags, 'tag', $tag_filter, '', __('All'), '', true, false, true, '', false, 'width: 150px;');
|
||||
}
|
||||
|
||||
$table->data[1][0] = __('Free text for search').ui_print_help_tip(
|
||||
|
@ -121,32 +122,14 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
|
|||
$table->data[1][1] = html_print_input_text('free_search', $free_search, '', 20, 40, true);
|
||||
|
||||
$table->data[1][2] = __('Standby');
|
||||
$table->data[1][3] = html_print_select($alert_standby, 'filter_standby', $filter_standby, '', '', '', true);
|
||||
$table->data[1][3] = html_print_select($alert_standby, 'standby', $filter_standby, '', __('All'), '', true);
|
||||
|
||||
$table->data[1][4] = __('Action');
|
||||
$alert_action = alerts_get_alert_actions_filter();
|
||||
if (empty($alert_action)) {
|
||||
$table->data[1][5] .= html_print_input_text('action', __('No actions'), '', 20, 40, true, true);
|
||||
} else {
|
||||
$table->data[1][5] = html_print_select($alert_action, 'action_filter', $action_filter, '', __('All'), '', true);
|
||||
}
|
||||
|
||||
$table->data[1][5] = html_print_select($alert_action, 'action_filter', $action_filter, '', __('All'), '', true);
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
$table->data[0][7] = html_print_submit_button(__('Filter'), 'filter_button', false, 'class="sub filter"', true);
|
||||
$table->rowspan[0][7] = 2;
|
||||
$data = '<form class="bg_ec" method="post" action="'.$url.'">';
|
||||
} else {
|
||||
$data = '<form method="post" action="'.$url.'">';
|
||||
}
|
||||
$table->data[1][5] = html_print_select($alert_action, 'action', $action_filter, '', __('All'), '', true);
|
||||
|
||||
$data .= html_print_table($table, true);
|
||||
if (!defined('METACONSOLE')) {
|
||||
$data .= "<div class='height_100p right'>".html_print_submit_button(__('Filter'), 'filter_button', false, 'class="sub filter"', true).'</div>';
|
||||
}
|
||||
|
||||
$data .= '</form>';
|
||||
|
||||
if ($return) {
|
||||
return $data;
|
||||
|
@ -156,7 +139,7 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
|
|||
}
|
||||
|
||||
|
||||
function printFormFilterAlertAgent($agent_view_page, $free_search, $id_agent)
|
||||
function printFormFilterAlertAgent($agent_view_page, $free_search, $id_agent, $return=false)
|
||||
{
|
||||
$table_filter = new stdClass();
|
||||
$table_filter->width = '100%';
|
||||
|
@ -188,41 +171,11 @@ function printFormFilterAlertAgent($agent_view_page, $free_search, $id_agent)
|
|||
true
|
||||
).'</span>';
|
||||
|
||||
$table_filter->data[0][1] = '<div class="action-buttons">';
|
||||
if ($agent_view_page === true) {
|
||||
$table_filter->data[0][1] .= html_print_button(
|
||||
__('Search'),
|
||||
'',
|
||||
false,
|
||||
'filter_agent_alerts('.$id_agent.');',
|
||||
'class="sub search"',
|
||||
true
|
||||
);
|
||||
$form = html_print_table($table_filter, true);
|
||||
|
||||
if ($return === true) {
|
||||
return $form;
|
||||
} else {
|
||||
$table_filter->data[0][1] .= html_print_submit_button(
|
||||
__('Search'),
|
||||
'',
|
||||
false,
|
||||
'class="sub search"',
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$table_filter->data[0][1] .= '</div>';
|
||||
|
||||
if ($agent_view_page === true) {
|
||||
echo html_print_table($table_filter);
|
||||
} else {
|
||||
$sortField = get_parameter('sort_field');
|
||||
$sort = get_parameter('sort', 'none');
|
||||
$order = '';
|
||||
|
||||
if ($sortField != '' && $sort != '') {
|
||||
$order = '&sort_field='.$sortField.'&sort='.$sort;
|
||||
}
|
||||
|
||||
echo '<form method="post" action="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent.'&tab=alert'.$order.'">';
|
||||
echo html_print_table($table_filter);
|
||||
echo '</form>';
|
||||
echo $form;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,9 +53,8 @@ $isFunctionPolicies = enterprise_include_once('include/functions_policies.php');
|
|||
|
||||
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||
|
||||
$filter = get_parameter('filter', 'all_enabled');
|
||||
$filter_standby = get_parameter('filter_standby', 'all');
|
||||
$offset_simple = (int) get_parameter_get('offset_simple', 0);
|
||||
$filter = get_parameter('disabled', 'all_enabled');
|
||||
$filter_standby = get_parameter('standby', 'all');
|
||||
$id_group = (int) get_parameter('ag_group', 0);
|
||||
// 0 is the All group (selects all groups)
|
||||
$free_search = get_parameter('free_search', '');
|
||||
|
@ -99,7 +98,7 @@ if ($tag_filter) {
|
|||
}
|
||||
}
|
||||
|
||||
$action_filter = get_parameter('action_filter', 0);
|
||||
$action_filter = get_parameter('action', 0);
|
||||
|
||||
$sec2 = get_parameter_get('sec2');
|
||||
$sec2 = safe_url_extraclean($sec2);
|
||||
|
@ -210,249 +209,11 @@ if ($idAgent != 0) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($alert_validate) {
|
||||
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') || check_acl_one_of_groups($config['id_user'], $all_groups, 'LM')) {
|
||||
validateAlert();
|
||||
} else {
|
||||
ui_print_error_message(__('Insufficient permissions to validate alerts'));
|
||||
}
|
||||
}
|
||||
|
||||
enterprise_hook('open_meta_frame');
|
||||
|
||||
if ($free_search != '') {
|
||||
$whereAlertSimple = 'AND ('.'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE name LIKE "%'.$free_search.'%") OR '.'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%'.$free_search.'%")) OR '.'talert_template_modules.id IN (
|
||||
SELECT id_alert_template_module
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%'.$free_search.'%")) OR '.'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE nombre LIKE "%'.$free_search.'%") OR '.'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente IN (
|
||||
SELECT id_agente
|
||||
FROM tagente
|
||||
WHERE nombre LIKE "%'.$free_search.'%")
|
||||
OR alias LIKE "%'.$free_search.'%")'.')';
|
||||
} else {
|
||||
$whereAlertSimple = '';
|
||||
}
|
||||
|
||||
$sortField = get_parameter('sort_field');
|
||||
$sort = get_parameter('sort', 'none');
|
||||
$selected = true;
|
||||
$selectAgentUp = false;
|
||||
$selectAgentDown = false;
|
||||
$selectModuleUp = false;
|
||||
$selectModuleDown = false;
|
||||
$selectTemplateUp = false;
|
||||
$selectTemplateDown = false;
|
||||
$selectLastFiredUp = false;
|
||||
$selectLastFiredDown = false;
|
||||
|
||||
switch ($sortField) {
|
||||
case 'agent':
|
||||
switch ($sort) {
|
||||
case 'up':
|
||||
$selectAgentUp = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$selectAgentDown = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_name',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'module':
|
||||
switch ($sort) {
|
||||
case 'up':
|
||||
$selectModuleUp = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$selectModuleDown = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'template':
|
||||
switch ($sort) {
|
||||
case 'up':
|
||||
$selectTemplateUp = $selected;
|
||||
$order = [
|
||||
'field' => 'template_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$selectTemplateDown = $selected;
|
||||
$order = [
|
||||
'field' => 'template_name',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'last_fired':
|
||||
switch ($sort) {
|
||||
case 'up':
|
||||
$selectLastFiredUp = $selected;
|
||||
$order = [
|
||||
'field' => 'last_fired',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$selectLastFiredDown = $selected;
|
||||
$order = [
|
||||
'field' => 'last_fired',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($print_agent) {
|
||||
$selectDisabledUp = '';
|
||||
$selectDisabledDown = '';
|
||||
$selectAgentUp = false;
|
||||
$selectAgentDown = false;
|
||||
$selectModuleUp = $selected;
|
||||
$selectModuleDown = false;
|
||||
$selectTemplateUp = false;
|
||||
$selectTemplateDown = false;
|
||||
$selectLastFiredUp = false;
|
||||
$selectLastFiredDown = false;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
} else {
|
||||
$selectDisabledUp = '';
|
||||
$selectDisabledDown = '';
|
||||
$selectAgentUp = false;
|
||||
$selectAgentDown = false;
|
||||
$selectModuleUp = $selected;
|
||||
$selectModuleDown = false;
|
||||
$selectTemplateUp = false;
|
||||
$selectTemplateDown = false;
|
||||
$selectLastFiredUp = false;
|
||||
$selectLastFiredDown = false;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Add checks for user ACL
|
||||
$groups = users_get_groups($config['id_user'], $access);
|
||||
$id_groups = array_keys($groups);
|
||||
|
||||
if (empty($id_groups)) {
|
||||
$whereAlertSimple .= ' AND (1 = 0) ';
|
||||
} else {
|
||||
$whereAlertSimple .= sprintf(
|
||||
' AND id_agent_module IN (
|
||||
SELECT tam.id_agente_modulo
|
||||
FROM tagente_modulo tam
|
||||
WHERE tam.id_agente IN (SELECT ta.id_agente
|
||||
FROM tagente ta LEFT JOIN tagent_secondary_group tasg ON
|
||||
ta.id_agente = tasg.id_agent
|
||||
WHERE (ta.id_grupo IN (%s) OR tasg.id_group IN (%s)))) ',
|
||||
implode(',', $id_groups),
|
||||
implode(',', $id_groups)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$alerts = [];
|
||||
if ($agent_view_page === true) {
|
||||
$options_simple = ['order' => $order];
|
||||
} else {
|
||||
$options_simple = [
|
||||
'offset' => $offset_simple,
|
||||
'limit' => $config['block_size'],
|
||||
'order' => $order,
|
||||
];
|
||||
}
|
||||
|
||||
$filter_alert = [];
|
||||
if ($filter_standby == 'standby_on') {
|
||||
$filter_alert['disabled'] = $filter;
|
||||
$filter_alert['standby'] = '1';
|
||||
} else if ($filter_standby == 'standby_off') {
|
||||
$filter_alert['disabled'] = $filter;
|
||||
$filter_alert['standby'] = '0';
|
||||
} else {
|
||||
$filter_alert['disabled'] = $filter;
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
include_once $config['homedir'].'/enterprise/meta/include/functions_alerts_meta.php';
|
||||
if ($idAgent != 0) {
|
||||
$alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
} else {
|
||||
$id_groups = array_keys(
|
||||
users_get_groups($config['id_user'], 'AR', false)
|
||||
);
|
||||
|
||||
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
}
|
||||
} else {
|
||||
if ($idAgent != 0) {
|
||||
$alerts['alerts_simple'] = agents_get_alerts_simple($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter);
|
||||
|
||||
$countAlertsSimple = agents_get_alerts_simple($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter);
|
||||
} else {
|
||||
$id_groups = array_keys(
|
||||
users_get_groups($config['id_user'], $access, false)
|
||||
);
|
||||
|
||||
$alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
}
|
||||
}
|
||||
|
||||
if ($tab != null) {
|
||||
$url = $url.'&tab='.$tab;
|
||||
|
@ -466,313 +227,248 @@ if ($free_search != '') {
|
|||
$url .= '&free_search='.$free_search;
|
||||
}
|
||||
|
||||
// Filter form
|
||||
if ($print_agent) {
|
||||
if (is_metaconsole()) {
|
||||
ui_toggle(
|
||||
printFormFilterAlert(
|
||||
$id_group,
|
||||
$filter,
|
||||
$free_search,
|
||||
$url,
|
||||
$filter_standby,
|
||||
$tag_filter,
|
||||
|
||||
|
||||
$columns = ['standby'];
|
||||
|
||||
$column_names = [
|
||||
[
|
||||
'title' => 'Standby',
|
||||
'text' => 'S.',
|
||||
],
|
||||
];
|
||||
|
||||
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
|
||||
array_unshift(
|
||||
$column_names,
|
||||
[
|
||||
'title' => 'Policy',
|
||||
'text' => 'P.',
|
||||
],
|
||||
);
|
||||
|
||||
$columns = array_merge(
|
||||
['policy'],
|
||||
$columns
|
||||
);
|
||||
}
|
||||
|
||||
if (is_metaconsole() === false) {
|
||||
if (check_acl($config['id_user'], $id_group, 'LW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
array_unshift(
|
||||
$column_names,
|
||||
[
|
||||
'title' => 'Validate',
|
||||
'text' => html_print_checkbox('all_validate', 0, false, true, false),
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
);
|
||||
|
||||
$columns = array_merge(
|
||||
['validate'],
|
||||
$columns,
|
||||
);
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
array_push(
|
||||
$column_names,
|
||||
[
|
||||
'title' => 'Force execution',
|
||||
'text' => 'F.',
|
||||
],
|
||||
);
|
||||
|
||||
$columns = array_merge(
|
||||
$columns,
|
||||
['force']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($print_agent === true) {
|
||||
array_push(
|
||||
$column_names,
|
||||
['text' => 'Agent'],
|
||||
);
|
||||
|
||||
$columns = array_merge(
|
||||
$columns,
|
||||
['agent'],
|
||||
);
|
||||
}
|
||||
|
||||
array_push(
|
||||
$column_names,
|
||||
['text' => 'Module'],
|
||||
['text' => 'Template'],
|
||||
['text' => 'Action'],
|
||||
['text' => 'Last fired'],
|
||||
['text' => 'Status'],
|
||||
);
|
||||
|
||||
$columns = array_merge(
|
||||
$columns,
|
||||
['module'],
|
||||
['template'],
|
||||
['action'],
|
||||
['lastFired'],
|
||||
['status'],
|
||||
);
|
||||
|
||||
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$no_sortable_columns = [
|
||||
0,
|
||||
1,
|
||||
5,
|
||||
];
|
||||
} else {
|
||||
$no_sortable_columns = [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
7,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$alert_action = empty(alerts_get_alert_actions_filter()) === false ? alerts_get_alert_actions_filter() : ['' => __('No actions')];
|
||||
|
||||
|
||||
ob_start();
|
||||
|
||||
if ($agent_view_page === true) {
|
||||
ui_print_datatable(
|
||||
[
|
||||
'id' => 'alerts_status_datatable',
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'no_sortable_columns' => $no_sortable_columns,
|
||||
'ajax_url' => 'include/ajax/alert_list.ajax',
|
||||
'ajax_data' => [
|
||||
'get_agent_alerts_datatable' => 1,
|
||||
'id_agent' => $id_agent,
|
||||
'url' => $url,
|
||||
'agent_view_page' => true,
|
||||
'all_groups' => $all_groups,
|
||||
],
|
||||
'drawCallback' => 'alerts_table_controls()',
|
||||
'order' => [
|
||||
'field' => 'module',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
'zeroRecords' => __('No alerts found'),
|
||||
'emptyTable' => __('No alerts found'),
|
||||
'search_button_class' => 'sub filter float-right',
|
||||
'form' => [
|
||||
'inputs' => [
|
||||
[
|
||||
'label' => __('Free text for search (*):').ui_print_help_tip(
|
||||
__('Filter by module name, template name or action name'),
|
||||
true
|
||||
),
|
||||
'type' => 'text',
|
||||
'name' => 'free_search_alert',
|
||||
'value' => $free_search,
|
||||
'size' => 20,
|
||||
'maxlength' => 100,
|
||||
],
|
||||
],
|
||||
'no_toggle' => true,
|
||||
],
|
||||
],
|
||||
);
|
||||
} else {
|
||||
ui_print_datatable(
|
||||
[
|
||||
'id' => 'alerts_status_datatable',
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'no_sortable_columns' => $no_sortable_columns,
|
||||
'ajax_url' => 'include/ajax/alert_list.ajax',
|
||||
'ajax_data' => [
|
||||
'get_agent_alerts_datatable' => 1,
|
||||
'id_agent' => $id_agent,
|
||||
'url' => $url,
|
||||
],
|
||||
'drawCallback' => 'alerts_table_controls()',
|
||||
'order' => [
|
||||
'field' => 'module',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
'zeroRecords' => __('No alerts found'),
|
||||
'emptyTable' => __('No alerts found'),
|
||||
'search_button_class' => 'sub filter float-right',
|
||||
'form' => [
|
||||
'html' => printFormFilterAlert(
|
||||
$id_group,
|
||||
$filter,
|
||||
$free_search,
|
||||
$url,
|
||||
$filter_standby,
|
||||
$tag_filter,
|
||||
true,
|
||||
true,
|
||||
$strict_user
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.';">';
|
||||
html_print_submit_button(__('Validate'), 'alert_validate', false, 'class="sub ok"', false);
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$html_content = ob_get_clean();
|
||||
|
||||
if ($agent_view_page === true) {
|
||||
// Create controlled toggle content.
|
||||
ui_toggle(
|
||||
$html_content,
|
||||
__('Full list of alerts'),
|
||||
'status_monitor_agent',
|
||||
!$alerts_defined,
|
||||
false,
|
||||
true,
|
||||
$strict_user
|
||||
),
|
||||
__('Show Options')
|
||||
);
|
||||
;
|
||||
} else {
|
||||
ui_toggle(
|
||||
printFormFilterAlert(
|
||||
$id_group,
|
||||
$filter,
|
||||
$free_search,
|
||||
$url,
|
||||
$filter_standby,
|
||||
$tag_filter,
|
||||
$action_filter,
|
||||
true,
|
||||
$strict_user
|
||||
),
|
||||
__('Alert control filter'),
|
||||
__('Toggle filter(s)'),
|
||||
$access
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Urls to sort the table.
|
||||
$url_up_agente = $url.'&sort_field=agent&sort=up';
|
||||
$url_down_agente = $url.'&sort_field=agent&sort=down';
|
||||
$url_up_module = $url.'&sort_field=module&sort=up';
|
||||
$url_down_module = $url.'&sort_field=module&sort=down';
|
||||
$url_up_template = $url.'&sort_field=template&sort=up';
|
||||
$url_down_template = $url.'&sort_field=template&sort=down';
|
||||
$url_up_lastfired = $url.'&sort_field=last_fired&sort=up';
|
||||
$url_down_lastfired = $url.'&sort_field=last_fired&sort=down';
|
||||
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'info_table';
|
||||
$table->cellpadding = '0';
|
||||
$table->cellspacing = '0';
|
||||
$table->size = [];
|
||||
$table->head = [];
|
||||
$table->align = [];
|
||||
|
||||
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
|
||||
if ($print_agent) {
|
||||
if (!is_metaconsole()) {
|
||||
$table->size[8] = '4%';
|
||||
if (check_acl($config['id_user'], $id_group, 'LW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$table->head[9] = html_print_checkbox('all_validate', 0, false, true, false);
|
||||
$table->align[9] = 'left';
|
||||
$table->size[9] = '5%';
|
||||
}
|
||||
'',
|
||||
'white_table_graph_content no-padding-imp',
|
||||
'white_table_graph_content'
|
||||
);
|
||||
} else {
|
||||
// Dump entire content.
|
||||
echo $html_content;
|
||||
}
|
||||
|
||||
$table->head[0] = "<span title='".__('Policy')."'>".__('P.').'</span>';
|
||||
// strict user hidden
|
||||
echo '<div id="strict_hidden" class="invisible">';
|
||||
html_print_input_text('strict_user_hidden', $strict_user);
|
||||
|
||||
$table->head[1] = "<span title='".__('Standby')."'>".__('S.').'</span>';
|
||||
html_print_input_text('is_meta_hidden', (int) is_metaconsole());
|
||||
echo '</div>';
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$table->head[2] = "<span title='".__('Force execution')."'>".__('F.').'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[3] = __('Agent');
|
||||
$table->head[4] = __('Module');
|
||||
$table->head[5] = __('Template');
|
||||
$table->head[6] = __('Action');
|
||||
$table->head[7] = __('Last fired');
|
||||
$table->head[8] = __('Status');
|
||||
|
||||
$table->align[8] = 'center';
|
||||
|
||||
// Sort buttons are only for normal console
|
||||
if (!is_metaconsole()) {
|
||||
$table->head[3] .= ui_get_sorting_arrows($url_up_agente, $url_down_agente, $selectAgentUp, $selectAgentDown);
|
||||
$table->head[4] .= ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown);
|
||||
$table->head[5] .= ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown);
|
||||
$table->head[7] .= ui_get_sorting_arrows($url_up_lastfired, $url_down_lastfired, $selectLastFiredUp, $selectLastFiredDown);
|
||||
}
|
||||
} else {
|
||||
if (!is_metaconsole()) {
|
||||
$table->size[7] = '5%';
|
||||
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'LW') || check_acl_one_of_groups($config['id_user'], $all_groups, 'LM')) {
|
||||
$table->head[8] = __('Validate');
|
||||
$table->align[8] = 'left';
|
||||
$table->size[8] = '5%';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[0] = "<span title='".__('Policy')."'>".__('P.').'</span>';
|
||||
|
||||
$table->head[1] = "<span title='".__('Standby')."'>".__('S.').'</span>';
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') || check_acl_one_of_groups($config['id_user'], $all_groups, 'LM')) {
|
||||
$table->head[2] = "<span title='".__('Force execution')."'>".__('F.').'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[3] = __('Module');
|
||||
$table->head[4] = __('Template');
|
||||
$table->head[5] = __('Action');
|
||||
$table->head[6] = __('Last fired');
|
||||
$table->head[7] = __('Status');
|
||||
enterprise_hook('close_meta_frame');
|
||||
|
||||
|
||||
$table->align[7] = 'center';
|
||||
|
||||
// Sort buttons are only for normal console
|
||||
if (!is_metaconsole()) {
|
||||
$table->head[3] .= ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown);
|
||||
$table->head[4] .= ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown);
|
||||
$table->head[6] .= ui_get_sorting_arrows($url_up_lastfired, $url_down_lastfired, $selectLastFiredUp, $selectLastFiredDown);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($print_agent) {
|
||||
if (!is_metaconsole()) {
|
||||
$table->size[7] = '5%';
|
||||
if (check_acl($config['id_user'], $id_group, 'LW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$table->head[8] = __('Validate');
|
||||
$table->align[8] = 'left';
|
||||
$table->size[8] = '5%';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[0] = "<span title='".__('Standby')."'>".__('S.').'</span>';
|
||||
if (!is_metaconsole()) {
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$table->head[1] = "<span title='".__('Force execution')."'>".__('F.').'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[2] = __('Agent');
|
||||
$table->head[3] = __('Module');
|
||||
$table->head[4] = __('Template');
|
||||
$table->head[5] = __('Action');
|
||||
$table->head[6] = __('Last fired');
|
||||
$table->head[7] = __('Status');
|
||||
|
||||
$table->align[7] = 'center';
|
||||
|
||||
// Sort buttons are only for normal console
|
||||
if (!is_metaconsole()) {
|
||||
$table->head[3] .= ui_get_sorting_arrows($url_up_agente, $url_down_agente, $selectAgentUp, $selectAgentDown);
|
||||
$table->head[4] .= ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown);
|
||||
$table->head[5] .= ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown);
|
||||
$table->head[6] .= ui_get_sorting_arrows($url_up_lastfired, $url_down_lastfired, $selectLastFiredUp, $selectLastFiredDown);
|
||||
}
|
||||
} else {
|
||||
if (!is_metaconsole()) {
|
||||
$table->size[6] = '5%';
|
||||
if (check_acl($config['id_user'], $id_group, 'LW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$table->head[7] = __('Validate');
|
||||
$table->align[7] = 'left';
|
||||
$table->size[7] = '5%';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[0] = "<span title='".__('Standby')."'>".__('S.').'</span>';
|
||||
if (!is_metaconsole()) {
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$table->head[1] = "<span title='".__('Force execution')."'>".__('F.').'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[2] = __('Module');
|
||||
$table->head[3] = __('Template');
|
||||
$table->head[4] = __('Action');
|
||||
$table->head[5] = __('Last fired');
|
||||
$table->head[6] = __('Status');
|
||||
|
||||
$table->align[6] = 'center';
|
||||
|
||||
// Sort buttons are only for normal console
|
||||
if (!is_metaconsole()) {
|
||||
$table->head[2] .= ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown);
|
||||
$table->head[3] .= ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown);
|
||||
$table->head[5] .= ui_get_sorting_arrows($url_up_lastfired, $url_down_lastfired, $selectLastFiredUp, $selectLastFiredDown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($sortField) {
|
||||
$url .= '&sort_field='.$sortField;
|
||||
$url .= '&sort='.$sort;
|
||||
}
|
||||
|
||||
$table->data = [];
|
||||
|
||||
$rowPair = true;
|
||||
$iterator = 0;
|
||||
foreach ($alerts['alerts_simple'] as $alert) {
|
||||
$row = ui_format_alert_row($alert, $print_agent, $url, 'font-size: 7pt;');
|
||||
$table->data[] = $row;
|
||||
}
|
||||
|
||||
if (!empty($table->data)) {
|
||||
$class = '';
|
||||
if ($agent_view_page === true) {
|
||||
$class = 'w100p no-padding-imp';
|
||||
printFormFilterAlertAgent($agent_view_page, $free_search, $idAgent);
|
||||
}
|
||||
|
||||
echo '<form class="'.$class.'" method="post" action="'.$url.'">';
|
||||
|
||||
if ($agent_view_page !== true) {
|
||||
ui_pagination(
|
||||
$countAlertsSimple,
|
||||
$url,
|
||||
$offset_simple,
|
||||
0,
|
||||
false,
|
||||
'offset_simple'
|
||||
);
|
||||
}
|
||||
|
||||
echo '<div id="alerts_list" class="w100p">';
|
||||
html_print_table($table);
|
||||
echo '</div>';
|
||||
|
||||
if ($agent_view_page !== true) {
|
||||
ui_pagination(
|
||||
$countAlertsSimple,
|
||||
$url,
|
||||
$offset_simple,
|
||||
0,
|
||||
false,
|
||||
'offset_simple',
|
||||
true,
|
||||
'pagination-bottom'
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
if (count($alerts['alerts_simple']) > 0) {
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.';">';
|
||||
html_print_submit_button(__('Validate'), 'alert_validate', false, 'class="sub ok"', false);
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '</form>';
|
||||
$alerts_defined = true;
|
||||
} else {
|
||||
ui_print_info_message(['no_close' => true, 'message' => __('No alerts found') ]);
|
||||
$alerts_defined = false;
|
||||
}
|
||||
|
||||
$html_content = ob_get_clean();
|
||||
|
||||
if ($agent_view_page === true) {
|
||||
// Create controlled toggle content.
|
||||
ui_toggle(
|
||||
$html_content,
|
||||
__('Full list of alerts'),
|
||||
'status_monitor_agent',
|
||||
!$alerts_defined,
|
||||
false,
|
||||
'',
|
||||
'white_table_graph_content no-padding-imp'
|
||||
);
|
||||
} else {
|
||||
if (!$print_agent) {
|
||||
printFormFilterAlertAgent($agent_view_page, $free_search, $idAgent);
|
||||
}
|
||||
|
||||
// Dump entire content.
|
||||
echo $html_content;
|
||||
}
|
||||
|
||||
|
||||
// strict user hidden
|
||||
echo '<div id="strict_hidden" class="invisible">';
|
||||
html_print_input_text('strict_user_hidden', $strict_user);
|
||||
|
||||
html_print_input_text('is_meta_hidden', (int) is_metaconsole());
|
||||
echo '</div>';
|
||||
|
||||
enterprise_hook('close_meta_frame');
|
||||
|
||||
|
||||
ui_require_css_file('cluetip', 'include/styles/js/');
|
||||
ui_require_jquery_file('cluetip');
|
||||
?>
|
||||
ui_require_css_file('cluetip', 'include/styles/js/');
|
||||
ui_require_jquery_file('cluetip');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function alerts_table_controls() {
|
||||
|
||||
$(document).ready (function () {
|
||||
$("a.template_details").cluetip ({
|
||||
arrows: true,
|
||||
attribute: 'href',
|
||||
|
@ -782,19 +478,9 @@ ui_require_jquery_file('cluetip');
|
|||
});
|
||||
|
||||
|
||||
$('[id^=checkbox-validate]').change(function(){
|
||||
if($(this).parent().parent().hasClass('checkselected')){
|
||||
$(this).parent().parent().removeClass('checkselected');
|
||||
}
|
||||
else{
|
||||
$(this).parent().parent().addClass('checkselected');
|
||||
}
|
||||
});
|
||||
|
||||
$('[id^=checkbox-all_validate]').change(function(){
|
||||
if ($("#checkbox-all_validate").prop("checked")) {
|
||||
$('[id^=checkbox-validate]').parent().parent().addClass('checkselected');
|
||||
$('[name^=validate]').prop("checked", true);
|
||||
$("input[id^=checkbox-validate]").prop('checked', true);
|
||||
}
|
||||
else{
|
||||
$('[id^=checkbox-validate]').parent().parent().removeClass('checkselected');
|
||||
|
@ -802,6 +488,13 @@ ui_require_jquery_file('cluetip');
|
|||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$(document).ready ( function () {
|
||||
alerts_table_controls();
|
||||
$('#submit-alert_validate').on('click', function () {
|
||||
validateAlerts();
|
||||
});
|
||||
});
|
||||
|
||||
$('table.alert-status-filter #ag_group').change (function () {
|
||||
|
@ -825,27 +518,42 @@ ui_require_jquery_file('cluetip');
|
|||
}
|
||||
}).change();
|
||||
|
||||
function filter_agent_alerts(){
|
||||
var free_search_alert = $("input[name='free_search_alert']").val();
|
||||
$("#alerts_list").empty();
|
||||
|
||||
jQuery.ajax ({
|
||||
data: {
|
||||
get_agent_alerts_agent_view: 1,
|
||||
id_agent: '<?php echo $idAgent; ?>',
|
||||
free_search_alert: free_search_alert,
|
||||
all_groups: '<?php echo json_encode($all_groups); ?>',
|
||||
sort_field: '<?php echo $sortField; ?>',
|
||||
sort: '<?php echo $sort; ?>',
|
||||
page: 'include/ajax/alert_list.ajax'
|
||||
},
|
||||
type: 'POST',
|
||||
url: "ajax.php",
|
||||
dataType: 'html',
|
||||
success: function (data) {
|
||||
$("#alerts_list").empty();
|
||||
$("#alerts_list").html(data);
|
||||
}
|
||||
|
||||
function validateAlerts() {
|
||||
var alert_ids = [];
|
||||
|
||||
$('[id^=checkbox-validate]:checked').each(function() {
|
||||
alert_ids.push($(this).val());
|
||||
});
|
||||
|
||||
if (alert_ids.length === 0) {
|
||||
confirmDialog({
|
||||
title: "<?php echo __('No alert selected'); ?>",
|
||||
message: "<?php echo __('You must select at least one alert.'); ?>",
|
||||
hideCancelButton: true
|
||||
});
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "ajax.php",
|
||||
data: {
|
||||
alert_ids: alert_ids,
|
||||
page: "include/ajax/alert_list.ajax",
|
||||
alert_validate: 1,
|
||||
all_groups: <?php echo json_encode($all_groups); ?>,
|
||||
},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
$("#menu_tab_frame_view").after(data);
|
||||
var table = $('#alerts_status_datatable').DataTable({
|
||||
ajax: "data.json"
|
||||
});
|
||||
|
||||
table.ajax.reload();
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue