2012-07-05 Sergio Martin <sergio.martin@artica.es>

* include/functions_html.php
	include/javascript/pandora_modules.js
	include/javascript/pandora.js
	godmode/agentes/module_manager_editor_common.php
	godmode/modules/manage_network_components_form_common.php: 
	Fixed several bugs of the network/local components javascript
	code and added new fields to local components
	Add new code on advanced select for time to update it from
	javascript and a workaround to do it from code loaded through 
	ajax



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6736 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2012-07-05 09:16:57 +00:00
parent 6fc5ad1b25
commit d48d55cb04
6 changed files with 102 additions and 33 deletions

View File

@ -1,3 +1,16 @@
2012-07-05 Sergio Martin <sergio.martin@artica.es>
* include/functions_html.php
include/javascript/pandora_modules.js
include/javascript/pandora.js
godmode/agentes/module_manager_editor_common.php
godmode/modules/manage_network_components_form_common.php:
Fixed several bugs of the network/local components javascript
code and added new fields to local components
Add new code on advanced select for time to update it from
javascript and a workaround to do it from code loaded through
ajax
2012-07-04 Sergio Martin <sergio.martin@artica.es> 2012-07-04 Sergio Martin <sergio.martin@artica.es>
* include/functions_menu.php * include/functions_menu.php

View File

@ -245,7 +245,7 @@ $table_advanced->data[1][4] = html_print_input_text ('module_ff_interval', $ff_i
$table_advanced->data[2][0] = __('Interval').ui_print_help_tip (__('Module execution time interval.'), true); $table_advanced->data[2][0] = __('Interval').ui_print_help_tip (__('Module execution time interval.'), true);
$table_advanced->colspan[2][1] = 2; $table_advanced->colspan[2][1] = 2;
$table_advanced->data[2][1] = html_print_extended_select_for_time ('module_interval' , $interval, '', '', '0', false, true); $table_advanced->data[2][1] = html_print_extended_select_for_time ('module_interval' , $interval, '', '', '0', false, true, false, false);
$table_advanced->data[2][3] = __('Post process').' ' . ui_print_help_icon ('postprocess', true); $table_advanced->data[2][3] = __('Post process').' ' . ui_print_help_icon ('postprocess', true);
$table_advanced->data[2][4] = html_print_input_text ('post_process', $table_advanced->data[2][4] = html_print_input_text ('post_process',

View File

@ -65,8 +65,8 @@ $table->data[2][0] = __('Group');
$table->data[2][1] = html_print_select (network_components_get_groups (), $table->data[2][1] = html_print_select (network_components_get_groups (),
'id_group', $id_group, '', '', '', true, false, false); 'id_group', $id_group, '', '', '', true, false, false);
$table->data[2][2] = __('Interval'); $table->data[2][2] = __('Interval');
$table->data[2][3] = html_print_input_text ('module_interval', $module_interval, '', $table->data[2][3] = html_print_extended_select_for_time ('module_interval' , $module_interval, '', '', '0', false, true);
5, 15, true);
$table->data[3][0] = __('Warning status'); $table->data[3][0] = __('Warning status');
$table->data[3][1] = '<em>'.__('Min.').'</em>'; $table->data[3][1] = '<em>'.__('Min.').'</em>';

View File

@ -428,12 +428,13 @@ function html_print_select_from_sql ($sql, $name, $selected = '',
* @param variant Value when nothing is selected * @param variant Value when nothing is selected
* @param integer $size Size of the input. * @param integer $size Size of the input.
* @param bool Whether to return an output string or echo now (optional, echo by default). * @param bool Whether to return an output string or echo now (optional, echo by default).
* @param bool Wherter to assign to combo a unique name (to have more than one on same page, like dashboard)
* *
* @return string HTML code if return parameter is true. * @return string HTML code if return parameter is true.
*/ */
function html_print_extended_select_for_time ($name, $selected = '', $script = '', $nothing = '', function html_print_extended_select_for_time ($name, $selected = '', $script = '', $nothing = '',
$nothing_value = '0', $size = false, $return = false, $select_style = false) { $nothing_value = '0', $size = false, $return = false, $select_style = false, $unique_name = true) {
$fields = get_periods(); $fields = get_periods();
@ -449,7 +450,12 @@ function html_print_extended_select_for_time ($name, $selected = '', $script = '
SECONDS_1MONTH => __('months'), SECONDS_1MONTH => __('months'),
SECONDS_1YEAR => __('years')); SECONDS_1YEAR => __('years'));
$uniq_name = uniqid($name); if($unique_name === true) {
$uniq_name = uniqid($name);
}
else {
$uniq_name = $name;
}
ob_start(); ob_start();
@ -467,16 +473,19 @@ function html_print_extended_select_for_time ($name, $selected = '', $script = '
html_print_select ($units, $uniq_name . '_units', 1, "" . $script, html_print_select ($units, $uniq_name . '_units', 1, "" . $script,
$nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style); $nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style);
echo '</div>'; echo '</div>';
echo "<script type='text/javascript'>
echo "
<script type='text/javascript'>
$(document).ready (function () { $(document).ready (function () {
period_select_init('$uniq_name'); period_select_init('$uniq_name');
period_select_events('$uniq_name'); period_select_events('$uniq_name');
}); });
</script> function period_select_".$name."_update(seconds) {
"; $('#text-".$uniq_name."_text').val(seconds);
adjustTextUnits('".$uniq_name."');
calculateSeconds('".$uniq_name."');
$('#".$uniq_name."_manual').show();
$('#".$uniq_name."_default').hide();
}
</script>";
$returnString = ob_get_clean(); $returnString = ob_get_clean();
if ($return) if ($return)

View File

@ -770,6 +770,19 @@ function calculateSeconds(name) {
$('.'+name).val(calculated); $('.'+name).val(calculated);
} }
/**
*
* Update via Javascript an advance selec for time
*
*/
function period_select_update(name, seconds) {
$('#text-'+name+'_text').val(seconds);
adjustTextUnits(name);
calculateSeconds(name);
$('#'+name+'_manual').show();
$('#'+name+'_default').hide();
}
/** /**
* *
* Adjust units in the advanced select for time * Adjust units in the advanced select for time

View File

@ -69,13 +69,35 @@ function configure_modules_form () {
}, },
function (data, status) { function (data, status) {
configuration_data = js_html_entity_decode (data['data']); configuration_data = js_html_entity_decode (data['data']);
$("#text-name").attr ("value", js_html_entity_decode (data["name"])); $("#text-name").attr ("value", js_html_entity_decode (data["name"]));
$("#textarea_description").attr ("value", js_html_entity_decode (data["description"])); $("#textarea_description").attr ("value", js_html_entity_decode (data["description"]));
$("#textarea_configuration_data").attr ("value", configuration_data); $("#textarea_configuration_data").attr ("value", configuration_data);
$("#component_loading").hide (); $("#component_loading").hide ();
$("#id_module_type option[value="+data["type"]+"]").select (1); $("#id_module_type option[value="+data["type"]+"]").select (1);
$("#text-max").attr ("value", data["max"]);
$("#text-min").attr ("value", data["min"]);
// Workaround to update the advanced select control from html and ajax
if(typeof 'period_select_module_interval_update' == 'function') {
period_select_module_interval_update(data["module_interval"]);
}
else {
period_select_update('module_interval', data["module_interval"]);
} $("#id_module_group option[value="+data["id_module_group"]+"]").select (1);
if (data["history_data"])
$("#checkbox-history_data").check ();
else
$("#checkbox-history_data").uncheck ();
$("#text-min_warning").attr ("value", (data["min_warning"] == 0) ? 0 : data["min_warning"]);
$("#text-max_warning").attr ("value", (data["max_warning"] == 0) ? 0 : data["max_warning"]);
$("#text-str_warning").attr ("value", (data["str_warning"] == 0) ? 0 : data["str_warning"]);
$("#text-min_critical").attr ("value", (data["min_critical"] == 0) ? 0 : data["min_critical"]);
$("#text-max_critical").attr ("value", (data["max_critical"] == 0) ? 0 : data["max_critical"]);
$("#text-str_critical").attr ("value", (data["str_critical"] == 0) ? 0 : data["str_critical"]);
$("#text-ff_event").attr ("value", (data["min_ff_event"] == 0) ? 0 : data["min_ff_event"]);
$("#text-post_process").attr("value", (data["post_process"] == 0) ? 0 : data["post_process"])
$("#text-unit").attr("value", (data["unit"] == '') ? '' : data["unit"])
$("#component_loading").hide ();
$("#id_module_type").change ();
}, },
"json" "json"
); );
@ -131,14 +153,20 @@ function configure_modules_form () {
$("#id_module_type option[value="+data["type"]+"]").select (1); $("#id_module_type option[value="+data["type"]+"]").select (1);
$("#text-max").attr ("value", data["max"]); $("#text-max").attr ("value", data["max"]);
$("#text-min").attr ("value", data["min"]); $("#text-min").attr ("value", data["min"]);
$("#text-module_interval").attr ("value", data["module_interval"]); // Workaround to update the advanced select control from html and ajax
if(typeof 'period_select_module_interval_update' == 'function') {
period_select_module_interval_update(data["module_interval"]);
}
else {
period_select_update('module_interval', data["module_interval"]);
}
$("#text-tcp_port").attr ("value", data["tcp_port"]); $("#text-tcp_port").attr ("value", data["tcp_port"]);
$("#textarea_tcp_send").attr ("value", js_html_entity_decode (data["tcp_send"])); $("#textarea_tcp_send").attr ("value", js_html_entity_decode (data["tcp_send"]));
$("#textarea_tcp_rcv").attr ("value", js_html_entity_decode (data["tcp_rcv"])); $("#textarea_tcp_rcv").attr ("value", js_html_entity_decode (data["tcp_rcv"]));
$("#text-snmp_community").attr ("value", js_html_entity_decode (data["snmp_community"])); $("#text-snmp_community").attr ("value", js_html_entity_decode (data["snmp_community"]));
$("#text-snmp_oid").attr ("value", js_html_entity_decode (data["snmp_oid"])).show (); $("#text-snmp_oid").attr ("value", js_html_entity_decode (data["snmp_oid"])).show ();
$("#oid, img#edit_oid").hide (); $("#oid, img#edit_oid").hide ();
$("#id_module_group option["+data["id_group"]+"]").select (1); $("#id_module_group option[value="+data["id_module_group"]+"]").select (1);
$("#max_timeout").attr ("value", data["max_timeout"]); $("#max_timeout").attr ("value", data["max_timeout"]);
$("#id_plugin option[value="+data["id_plugin"]+"]").select (1); $("#id_plugin option[value="+data["id_plugin"]+"]").select (1);
$("#text-plugin_user").attr ("value", js_html_entity_decode (data["plugin_user"])); $("#text-plugin_user").attr ("value", js_html_entity_decode (data["plugin_user"]));
@ -150,9 +178,11 @@ function configure_modules_form () {
$("#checkbox-history_data").uncheck (); $("#checkbox-history_data").uncheck ();
$("#text-min_warning").attr ("value", (data["min_warning"] == 0) ? 0 : data["min_warning"]); $("#text-min_warning").attr ("value", (data["min_warning"] == 0) ? 0 : data["min_warning"]);
$("#text-max_warning").attr ("value", (data["max_warning"] == 0) ? 0 : data["max_warning"]); $("#text-max_warning").attr ("value", (data["max_warning"] == 0) ? 0 : data["max_warning"]);
$("#text-str_warning").attr ("value", (data["str_warning"] == 0) ? 0 : data["str_warning"]);
$("#text-min_critical").attr ("value", (data["min_critical"] == 0) ? 0 : data["min_critical"]); $("#text-min_critical").attr ("value", (data["min_critical"] == 0) ? 0 : data["min_critical"]);
$("#text-max_critical").attr ("value", (data["max_critical"] == 0) ? 0 : data["max_critical"]); $("#text-max_critical").attr ("value", (data["max_critical"] == 0) ? 0 : data["max_critical"]);
$("#text-ff_threshold").attr ("value", (data["min_ff_event"] == 0) ? 0 : data["min_ff_event"]); $("#text-str_critical").attr ("value", (data["str_critical"] == 0) ? 0 : data["str_critical"]);
$("#text-ff_event").attr ("value", (data["min_ff_event"] == 0) ? 0 : data["min_ff_event"]);
$("#text-post_process").attr("value", (data["post_process"] == 0) ? 0 : data["post_process"]) $("#text-post_process").attr("value", (data["post_process"] == 0) ? 0 : data["post_process"])
$("#text-unit").attr("value", (data["unit"] == '') ? '' : data["unit"]) $("#text-unit").attr("value", (data["unit"] == '') ? '' : data["unit"])
$("#component_loading").hide (); $("#component_loading").hide ();
@ -344,23 +374,27 @@ function configure_modules_form () {
return true; return true;
}); });
$("#prediction_id_group").pandoraSelectGroupAgent ({ if(typeof $("#prediction_id_group").pandoraSelectGroupAgent == 'function') {
agentSelect: "select#prediction_id_agent", $("#prediction_id_group").pandoraSelectGroupAgent ({
callbackBefore: function () { agentSelect: "select#prediction_id_agent",
$("#module_loading").show (); callbackBefore: function () {
$("#prediction_module option").remove (); $("#module_loading").show ();
return true; $("#prediction_module option").remove ();
}, return true;
callbackAfter: function (e) { },
if ($("#prediction_id_agent").children ().length == 0) { callbackAfter: function (e) {
$("#module_loading").hide (); if ($("#prediction_id_agent").children ().length == 0) {
return; $("#module_loading").hide ();
return;
}
$("#prediction_id_agent").change ();
} }
$("#prediction_id_agent").change (); });
} }
});
$("#prediction_id_agent").pandoraSelectAgentModule ({ if(typeof $("#prediction_id_agent").pandoraSelectAgentModule == 'function') {
moduleSelect: "select#prediction_module" $("#prediction_id_agent").pandoraSelectAgentModule ({
}); moduleSelect: "select#prediction_module"
});
}
} }