From 3fa698bcf688309172ce21bbe4dac837d9cb88cc Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Fri, 22 Feb 2013 12:29:22 +0000 Subject: [PATCH] 2013-02-22 Miguel de Dios * godmode/alerts/alert_list.php, godmode/alerts/alert_list.list.php: rewrote the code for to show the form to add actions in the list of agents for make more pretty. Fixes: #3605462 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7702 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 + .../godmode/alerts/alert_list.list.php | 227 ++++++++++-------- pandora_console/godmode/alerts/alert_list.php | 2 +- 3 files changed, 133 insertions(+), 104 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 873e28ea99..0c1ef097af 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2013-02-22 Miguel de Dios + + * godmode/alerts/alert_list.php, + godmode/alerts/alert_list.list.php: rewrote the code for to show + the form to add actions in the list of agents for make more pretty. + + Fixes: #3605462 + 2013-02-22 Dario Rodriguez * godmode/servers/manage_recontask_form.php: Changed interval combo diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 463d3faaed..d701a770e8 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -160,7 +160,7 @@ if ($searchFlag) { //if ($agentID != -1) //$where .= " AND id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = " . $agentID . ")"; if (strlen(trim($agentName)) > 0) { - + switch ($config["dbtype"]) { case "mysql": case "postgresql": @@ -186,7 +186,7 @@ if ($searchFlag) { $total = agents_get_alerts_simple (array_keys ($agents), false, false, $where, false, false, false, true); -if(empty($total)) $total = 0; +if (empty($total)) $total = 0; $order = null; @@ -449,93 +449,127 @@ foreach ($simple_alerts as $alert) { $actions = alerts_get_alert_agent_module_actions ($alert['id']); - $data[3] = ''; + $data[3] = ""; if (empty($actions)) { // Get and show default actions for this alert - $default_action = db_get_sql ("SELECT id_alert_action FROM talert_templates WHERE id = ".$alert["id_alert_template"]); - if ($default_action != ""){ - $data[3] = __("Default"). " : ".db_get_sql ("SELECT name FROM talert_actions WHERE id = $default_action"); + $default_action = db_get_sql ("SELECT id_alert_action + FROM talert_templates + WHERE id = ".$alert["id_alert_template"]); + if ($default_action != "") { + $data[3] .= ""; + $data[3] .= ""; + $data[3] .= ""; } } - else { - $data[3] = '
    '; - foreach ($actions as $action_id => $action) { - $data[3] .= '
  • '; - if ($alert['disabled']) - $data[3] .= ''; - else - $data[3] .= ''; - $data[3] .= ui_print_truncate_text($action['name'], GENERIC_SIZE_TEXT, false); - $data[3] .= ' ('; - if ($action['fires_min'] == $action['fires_max']) { - if ($action['fires_min'] == 0) - $data[3] .= __('Always'); + foreach ($actions as $action_id => $action) { + $data[3] .= "
"; + $data[3] .= ""; // Is possible manage actions if have LW permissions in the agent group of the alert module - if(check_acl ($config['id_user'], $agent_group, "LW")) { - $data[3] .= ''; - $data[3] .= html_print_input_image ('delete', 'images/cross.png', 1, '', true, array('title' => __('Delete'))); - $data[3] .= html_print_input_hidden ('delete_action', 1, true); - $data[3] .= html_print_input_hidden ('id_alert', $alert['id'], true); - $data[3] .= html_print_input_hidden ('id_action', $action_id, true); - $data[3] .= ''; + if (check_acl ($config['id_user'], $agent_group, "LW")) { + $data[3] .= ""; } - $data[3] .= ''; - } - $data[3] .= ''; + $data[3] .= ""; } + // Is possible manage actions if have LW permissions in the agent group of the alert module - if(check_acl ($config['id_user'], $agent_group, "LW")) { - $data[3] .= ''; - $data[3] .= html_print_image ('images/add.png', true); - if ($alert['disabled']) - $data[3] .= ' '. '' .__('Add action') . ''; - else - $data[3] .= ' ' . __('Add action'); - $data[3] .= ''; - - - $data[3] .= ''; - $data[3] .= html_print_input_hidden ('add_action', 1, true); - $data[3] .= html_print_input_hidden ('id_alert_module', $alert['id'], true); + if (check_acl ($config['id_user'], $agent_group, "LW")) { $own_info = get_user_info($config['id_user']); $own_groups = users_get_groups($config['id_user'], 'LW', true); $filter_groups = ''; $filter_groups = implode(',', array_keys($own_groups)); $actions = alerts_get_alert_actions_filter(true, 'id_group IN (' . $filter_groups . ')'); - $data[3] .= html_print_select ($actions, 'action', '', '', __('None'), 0, true); - $data[3] .= '
'; - $data[3] .= ''.__('Advanced options').' » '; - $data[3] .= ''; - $data[3] .= '
'; - $data[3] .= html_print_submit_button (__('Add'), 'add_action', false, 'class="sub next"', true); - $data[3] .= '
'; + + + $data[3] .= ''; + + $data[3] .= html_print_input_hidden ('add_action', 1, true); + $data[3] .= html_print_input_hidden ('id_alert_module', $alert['id'], true); + + $data[3] .= '
'; + $data[3] .= "'; + $data[3] .= ''; + $data[3] .= ''; + + $data[3] .= ''; + $data[3] .= ''; + $data[3] .= ''; + $data[3] .= ''; + $data[3] .= ''; + + $data[3] .= ' + + '; } + + $data[3] .= '
"; + $data[3] .= __("Default"). " : ".db_get_sql ("SELECT name FROM talert_actions WHERE id = $default_action"); + $data[3] .= "
"; + $data[3] .= '
    '; + $data[3] .= '
  • '; + if ($alert['disabled']) + $data[3] .= ''; else - $data[3] .= __('On').' '.$action['fires_min']; - } - else { - if ($action['fires_min'] == 0) - $data[3] .= __('Until').' '.$action['fires_max']; - else - $data[3] .= __('From').' '.$action['fires_min']. - ' '.__('to').' '.$action['fires_max']; - } - if ($action['module_action_threshold'] != 0) - $data[3] .= ' '.__('Threshold').' '.$action['module_action_threshold']; - - $data[3] .= ')'; - $data[3] .= ''; + $data[3] .= ''; + $data[3] .= ui_print_truncate_text($action['name'], GENERIC_SIZE_TEXT, false); + $data[3] .= ' ('; + if ($action['fires_min'] == $action['fires_max']) { + if ($action['fires_min'] == 0) + $data[3] .= __('Always'); + else + $data[3] .= __('On').' '.$action['fires_min']; + } + else { + if ($action['fires_min'] == 0) + $data[3] .= __('Until').' '.$action['fires_max']; + else + $data[3] .= __('From').' '.$action['fires_min']. + ' '.__('to').' '.$action['fires_max']; + } + if ($action['module_action_threshold'] != 0) + $data[3] .= ' '.__('Threshold').' '.$action['module_action_threshold']; + + $data[3] .= ')'; + $data[3] .= ''; + $data[3] .= '
  • '; + $data[3] .= '
'; + $data[3] .= "
"; + $data[3] .= ''; + $data[3] .= "
"; + $data[3] .= html_print_select ($actions, 'action_select', '', '', __('None'), 0, true); + $data[3] .= ''; + $data[3] .= ''; + if ($alert['disabled']) { + $data[3] .= html_print_image('images/add.disabled.png', + true, array('title' => __("Add action"))); + } + else { + $data[3] .= html_print_image('images/add.png', + true, array('title' => __("Add action"))); + } + $data[3] .= ''; + $data[3] .= '
'; + $status = STATUS_ALERT_NOT_FIRED; $title = ""; @@ -655,12 +689,12 @@ if (! $id_agente) { } ?> $("a.template_details").cluetip ({ - arrows: true, - attribute: 'href', - cluetipClass: 'default' - }).click (function () { - return false; - }); + arrows: true, + attribute: 'href', + cluetipClass: 'default' + }).click (function () { + return false; + }); $("#tgl_alert_control").click (function () { $("#alert_control").toggle (); @@ -675,6 +709,7 @@ if (! $id_agente) { $(this).attr ("src", ); } ); + $("input[name=enable]").attr ("title", "") .hover (function () { $(this).attr ("src", ); @@ -683,7 +718,7 @@ if (! $id_agente) { $(this).attr ("src", ); } ); - + $("input[name=standby_on]").attr ("title", "") .hover (function () { $(this).attr ("src", ); @@ -692,7 +727,7 @@ if (! $id_agente) { $(this).attr ("src", ); } ); - + $("input[name=standby_off]").attr ("title", "") .hover (function () { $(this).attr ("src", ); @@ -701,39 +736,25 @@ if (! $id_agente) { $(this).attr ("src", ); } ); + $("form.disable_alert_form").submit (function () { return true; }); - - $("a.add_action").click (function () { - id = this.id.split ("-").pop (); - - $('#add_action_form-' + id).attr("class", ''); - $(this).attr("class", 'invisible'); - - return false; - }); - $("form.delete_link, form.delete_alert_form").submit (function () { if (! confirm ("")) return false; return true; }); - - $("a.show_advanced_actions").click (function () { - /* It can be done in two different sites, so it must use two different selectors */ - actions = $(this).parents ("form").children ("span.advanced_actions"); - if (actions.length == 0) - actions = $(this).parents ("div").children ("span.advanced_actions") - $("#text-fires_min", actions).attr ("value", 0); - $("#text-fires_max", actions).attr ("value", 0); - $(actions).show (); - $(this).remove (); - return false; - }); - - }); + +function show_advance_options_action(id_alert) { + $(".link_show_advance_options_" + id_alert).hide(); + $(".advance_options_" + id_alert).show(); +} + +function add_action_submit(id_alert) { + $("#add_action_form-" + id_alert).submit(); +} /* ]]> */ diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index 75cd5895ca..2d393d506d 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -142,7 +142,7 @@ if ($delete_alert) { } if ($add_action) { - $id_action = (int) get_parameter ('action'); + $id_action = (int) get_parameter ('action_select'); $id_alert_module = (int) get_parameter ('id_alert_module'); $fires_min = (int) get_parameter ('fires_min'); $fires_max = (int) get_parameter ('fires_max');