2009-05-20 Esteban Sanchez <estebans@artica.es>

* general/ui/agents_list.php: Fixed searching filter. Added pagination
	via AJAX.

	* godmode/alerts/configure_alert_template.php: Typo error.

	* images/application_edit.png, images/suc.png, images/err.png: Tiny
	changes.

	* images/application_not_writable.png: Added to repository.

	* include/styles/pandora.css: Make success and error messages a little
	bit narrower. Typo error.

	* include/functions.php: Style corrections in safe_input().



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1698 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2009-05-20 13:24:50 +00:00
parent ea4075e546
commit 9d0105c8d9
9 changed files with 127 additions and 123 deletions

View File

@ -1,3 +1,20 @@
2009-05-20 Esteban Sanchez <estebans@artica.es>
* general/ui/agents_list.php: Fixed searching filter. Added pagination
via AJAX.
* godmode/alerts/configure_alert_template.php: Typo error.
* images/application_edit.png, images/suc.png, images/err.png: Tiny
changes.
* images/application_not_writable.png: Added to repository.
* include/styles/pandora.css: Make success and error messages a little
bit narrower. Typo error.
* include/functions.php: Style corrections in safe_input().
2009-05-19 Evi Vanoost <vanooste@rcbi.rochester.edu> 2009-05-19 Evi Vanoost <vanooste@rcbi.rochester.edu>
* include/functions_incidents.php: Removed upgrade_inc13to21. An old * include/functions_incidents.php: Removed upgrade_inc13to21. An old
@ -8,7 +25,6 @@
* include/functions_ui.php: Added $config['ignore_callback']. Useful if * include/functions_ui.php: Added $config['ignore_callback']. Useful if
you decide to flush the buffers (eg. to offer a download) you decide to flush the buffers (eg. to offer a download)
* include/functions_db.php: Cleaned up get_db_all_rows_filter and added * include/functions_db.php: Cleaned up get_db_all_rows_filter and added
some documentation and todo's. Added get_agentmodule_data to get all some documentation and todo's. Added get_agentmodule_data to get all
datapoints of a module. Cleaned up get_agentmodule_data_average datapoints of a module. Cleaned up get_agentmodule_data_average
@ -19,6 +35,15 @@
* include/exportdata.php: Rewritten. Added filters for group. Works using * include/exportdata.php: Rewritten. Added filters for group. Works using
functions and export into HTML, CSV and Excel with the option for functions and export into HTML, CSV and Excel with the option for
expansion (specify the delimiter values) expansion (specify the delimiter values)
svn co
2009-05-19 Esteban Sanchez <estebans@artica.es>
* operation/agentes/status_monitor.php: Many fixes in the code for
pagination. Fixes #2762175
* images/networkmap/4.png, images/networkmap/firewall.png,
images/networkmap/7.png, images/networkmap/9.png,
images/networkmap/printer.png: Updated with tango icons.
2009-05-19 Esteban Sanchez <estebans@artica.es> 2009-05-19 Esteban Sanchez <estebans@artica.es>

View File

@ -22,74 +22,33 @@ require_once ('include/functions_agents.php');
if (is_ajax ()) { if (is_ajax ()) {
$search_agents = (bool) get_parameter ('search_agents'); $search_agents = (bool) get_parameter ('search_agents');
$show_filter_form = (bool) get_parameter ('show_filter_form', false);
$access = (string) get_parameter ('access', 'AR');
$filter = str_replace ("\\\"", "\"", $_POST['filter']);
$filter = json_decode ($filter, true);
$id_group = (int) get_parameter ('id_group');
if ($id_group > 1 && give_acl ($config['id_user'], $id_group, $access))
$filter['id_grupo'] = $id_group;
else
$filter['id_grupo'] = array_keys (get_user_groups (false, $access));
$fields = '';
if (isset ($_POST['fields']))
$fields = json_decode (str_replace ("\\\"", "\"", $_POST['fields']));
$table_heads = array ();
if (isset ($_POST['table_heads']))
$table_heads = json_decode (str_replace ("\\\"", "\"", $_POST['table_heads']));
$table_size = array ();
if (isset ($_POST['table_size']))
$table_size = json_decode (str_replace ("\\\"", "\"", $_POST['table_size']));
$table_size = array ();
if (isset ($_POST['table_align']))
$table_align = json_decode (str_replace ("\\\"", "\"", $_POST['table_align']));
$table_renders = str_replace ("\\\"", "\"", $_POST['table_renders']);
$table_renders = json_decode ($table_renders, true);
if ($search_agents) {
require_once ('include/functions_ui_renders.php');
$filter = str_replace ("\\\"", "\"", $_POST['filter']);
$filter = json_decode ($filter, true);
$fields = '';
if (isset ($_POST['fields']))
$fields = json_decode (str_replace ("\\\"", "\"", $_POST['fields']));
$table_renders = str_replace ("\\\"", "\"", $_POST['table_renders']);
$table_renders = json_decode ($table_renders, true);
$access = (string) get_parameter ('access', 'AR');
foreach ($_POST as $field => $value) {
$value = safe_input ($value);
switch ($field) {
case 'page':
case 'search_agents':
case 'table_renders':
case 'fields':
case 'filter':
case 'access':
continue;
case 'search':
array_push ($filter, '(nombre LIKE "%'.$value.'%" OR comentarios LIKE "%'.$value.'%")');
break;
case 'id_group':
if ($value == 1)
$filter['id_grupo'] = array_keys (get_user_groups (false, $value));
else
$filter['id_grupo'] = $value;
break;
default:
$filter[$field] = $value;
}
}
$total_agents = get_agents ($filter, array ('COUNT(*) AS total'), $access);
if ($total_agents !== false)
$total_agents = $total_agents[0]['total'];
else
$total_agents = 0;
$filter['limit'] = $config['block_size'];
$filter['offset'] = (int) get_parameter ('offset');
$agents = get_agents ($filter, $fields, $access);
$all_data = array ();
if ($agents !== false) {
foreach ($agents as $agent) {
$data = array ();
foreach ($table_renders as $name => $values) {
if (! is_numeric ($name)) {
array_push ($data, render_agent_field (&$agent, $name, $values, true));
} else {
array_push ($data, render_agent_field (&$agent, $values, false, true));
}
}
array_push ($all_data, $data);
}
}
echo json_encode ($all_data);
return;
}
return;
} }
require_once ('include/functions_ui_renders.php'); require_once ('include/functions_ui_renders.php');
@ -122,7 +81,7 @@ if ($show_filter_form) {
if ($odd) if ($odd)
$data = array (); $data = array ();
$data[] = __('Search'); $data[] = __('Search');
$data[] = print_input_text ('search', '', '', 15, 255, true); $data[] = print_input_text ('search_string', '', '', 15, 255, true);
if (! $odd) if (! $odd)
array_push ($table->data, $data); array_push ($table->data, $data);
$odd = !$odd; $odd = !$odd;
@ -140,13 +99,13 @@ if ($show_filter_form) {
require_jquery_file ('form'); require_jquery_file ('form');
} }
$table->width = '90%'; if (! isset ($filter) || ! is_array ($filter))
$table->id = 'agents_table'; $filter = array ();
$table->head = $table_heads;
$table->align = $table_align; $search_string = (string) get_parameter ('search_string');
$table->size = $table_size; if ($search_string != '') {
$table->style = array (); $filter[] = '(nombre LIKE "%'.$search_string.'%" OR comentarios LIKE "%'.$search_string.'%" OR direccion LIKE "%'.$search_string.'%")';
$table->data = array (); }
$total_agents = get_agents ($filter, array ('COUNT(*) AS total'), $access); $total_agents = get_agents ($filter, array ('COUNT(*) AS total'), $access);
if ($total_agents !== false) if ($total_agents !== false)
@ -159,15 +118,25 @@ $agents = get_agents ($filter, $fields, $access);
unset ($filter['limit']); unset ($filter['limit']);
unset ($filter['offset']); unset ($filter['offset']);
echo '<div id="agents_loading" class="loading invisible">'; if (! is_ajax ()) {
echo '<img src="images/spinner.gif" />'; echo '<div id="agents_loading" class="loading invisible">';
echo __('Loading').'&hellip;'; echo '<img src="images/spinner.gif" />';
echo '</div>'; echo __('Loading').'&hellip;';
echo '</div>';
}
echo '<div id="agents_list"'.($agents === false ? ' class="invisible"' : '').'">'; echo '<div id="agents_list"'.($agents === false ? ' class="invisible"' : '').'">';
echo '<div id="no_agents"'.($agents === false ? '' : ' class="invisible"').'>'; echo '<div id="no_agents"'.($agents === false ? '' : ' class="invisible"').'>';
print_error_message (__('No agents found')); print_error_message (__('No agents found'));
echo '</div>'; echo '</div>';
$table->width = '90%';
$table->id = 'agents_table';
$table->head = $table_heads;
$table->align = $table_align;
$table->size = $table_size;
$table->style = array ();
$table->data = array ();
if ($agents !== false) { if ($agents !== false) {
foreach ($agents as $agent) { foreach ($agents as $agent) {
$data = array (); $data = array ();
@ -181,55 +150,65 @@ if ($agents !== false) {
array_push ($table->data, $data); array_push ($table->data, $data);
} }
} }
echo '<div id="agents"'.($agents === false ? ' class="invisible"' : '').'>'; echo '<div id="agents"'.($agents === false ? ' class="invisible"' : '').'>';
pagination ($total_agents); pagination ($total_agents, '#');
print_table ($table); print_table ($table);
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';
if (is_ajax ())
return;
?> ?>
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
var table_renders = '<?php echo json_encode ($table_renders) ?>';
var fields = '<?php echo json_encode ($fields) ?>'; function send_search_form (offset) {
var filter = '<?php echo json_encode ($filter) ?>'; table_renders = '<?php echo json_encode ($table_renders) ?>';
fields = '<?php echo json_encode ($fields) ?>';
filter = '<?php echo json_encode ($filter) ?>';
table_heads = '<?php echo json_encode ($table_heads) ?>';
table_align = '<?php echo json_encode ($table_align) ?>';
table_size = '<?php echo json_encode ($table_size) ?>';
$("#agents_loading").show ();
$("#no_agents, #agents_list, table#agents_table").hide ();
$("#agents_list").remove ();
values = $("form#agent_search").formToArray ();
values.push ({name: "page", value: "general/ui/agents_list"});
values.push ({name: "table_renders", value: table_renders});
values.push ({name: "table_size", value: table_size});
values.push ({name: "table_align", value: table_align});
values.push ({name: "table_heads", value: table_heads});
values.push ({name: "filter", value: filter});
values.push ({name: "offset", value: offset});
if (fields != "")
values.push ({name: "fields", value: fields});
jQuery.post ("ajax.php",
values,
function (data, status) {
$("#agents_loading").hide ().after (data);
$("#agents_list, table#agents_table").show ();
$("a.pagination").click (function () {
offset = this.href.split ("=").pop ();
send_search_form (offset);
return false;
});
},
"html"
);
}
$(document).ready (function () { $(document).ready (function () {
<?php if ($show_filter_form): ?> <?php if ($show_filter_form): ?>
$("form#agent_search").submit (function () { $("form#agent_search").submit (function () {
$("#agents_loading").show (); send_search_form (0);
$("#no_agents, #agents_list, table#agents_table").hide (); return false;
$("table#agents_table tbody tr").remove (); });
values = $(this).formToArray ();
values.push ({name: "page", value: "general/ui/agents_list"}); $("a.pagination").click (function () {
values.push ({name: "table_renders", value: table_renders}); offset = this.href.split ("=").pop ();
values.push ({name: "filter", value: filter}); send_search_form (offset);
if (fields != "")
values.push ({name: "fields", value: fields});
jQuery.post ("ajax.php",
values,
function (data, status) {
if (! data || data.length == 0) {
$("#agents_loading").hide ();
$("#agents_list, #no_agents").show ();
return;
}
jQuery.each (data, function () {
tr = $("<tr></tr>");
len = this.length;
for (i = 0; i < len; i++) {
td = $("<td></td>").html (this[i]);
tr.append (td);
}
$("table#agents_table tbody").append (tr);
});
$("#agents_loading").hide ();
$("#agents_list, table#agents_table").show ();
},
"json"
);
return false; return false;
}); });
<?php endif; ?> <?php endif; ?>

View File

@ -512,7 +512,7 @@ var is_not = "<?php echo __('The alert would fire when the value is not <span id
var between = "<?php echo __('The alert would fire when the value is between <span id=\"min\"></span> and <span id=\"max\"></span>');?>"; var between = "<?php echo __('The alert would fire when the value is between <span id=\"min\"></span> and <span id=\"max\"></span>');?>";
var between_not = "<?php echo __('The alert would fire when the value is not between <span id=\"min\"></span> and <span id=\"max\"></span>');?>"; var between_not = "<?php echo __('The alert would fire when the value is not between <span id=\"min\"></span> and <span id=\"max\"></span>');?>";
var under = "<?php echo __('The alert would fire when the value is below <span id=\"min\"></span>');?>"; var under = "<?php echo __('The alert would fire when the value is below <span id=\"min\"></span>');?>";
var over = "<?php echo __('The alert would fire when the value is avobe <span id=\"max\"></span>');?>"; var over = "<?php echo __('The alert would fire when the value is above <span id=\"max\"></span>');?>";
var warning = "<?php echo __('The alert would fire when the module is in warning status');?>"; var warning = "<?php echo __('The alert would fire when the module is in warning status');?>";
var critical = "<?php echo __('The alert would fire when the module is in critical status');?>"; var critical = "<?php echo __('The alert would fire when the module is in critical status');?>";

Binary file not shown.

Before

Width:  |  Height:  |  Size: 660 B

After

Width:  |  Height:  |  Size: 623 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -40,10 +40,10 @@ function safe_input ($value) {
return $value; return $value;
} }
if (version_compare(PHP_VERSION, '5.2.3') === 1) { if (version_compare (PHP_VERSION, '5.2.3') === 1) {
return htmlentities (utf8_encode ($value), ENT_QUOTES, "UTF-8", false); return htmlentities (utf8_encode ($value), ENT_QUOTES, "UTF-8", false);
} else { } else {
$translation_table = get_html_translation_table (HTML_ENTITIES,ENT_QUOTES); $translation_table = get_html_translation_table (HTML_ENTITIES, ENT_QUOTES);
$translation_table[chr(38)] = '&'; $translation_table[chr(38)] = '&';
return preg_replace ("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&amp;", strtr ($value, $translation_table)); return preg_replace ("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&amp;", strtr ($value, $translation_table));
} }

View File

@ -373,7 +373,7 @@ td.datos_id {
text-align: center; text-align: center;
} }
.suc, .error, .help { .suc, .error, .help {
padding: 10px 1px 6px 35px padding: 4px 1px 6px 30px;
} }
.suc { .suc {
color: #5a8629; color: #5a8629;
@ -658,7 +658,7 @@ div#logo_text3 {
font-weight: bold; font-weight: bold;
margin-top: 0px; margin-top: 0px;
margin-left: 4px; margin-left: 4px;
padding-top: 0px: padding-top: 0px;
} }
.bb0 { .bb0 {