2011-02-15 Miguel de Dios <miguel.dedios@artica.es>

* include/javascript/pandora.js, operation/agentes/ver_agente.php,
	godmode/reporting/visual_console_builder.wizard.php,
	godmode/reporting/visual_console_builder.php: fixed when the agent haven't
	any module and fixed when to try to create items without modules selected.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3865 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2011-02-15 19:07:23 +00:00
parent 29ad21a436
commit 9c3cdfa3aa
5 changed files with 69 additions and 20 deletions

View File

@ -1,3 +1,10 @@
2011-02-15 Miguel de Dios <miguel.dedios@artica.es>
* include/javascript/pandora.js, operation/agentes/ver_agente.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php: fixed when the agent haven't
any module and fixed when to try to create items without modules selected.
2011-02-15 Miguel de Dios <miguel.dedios@artica.es>
* operation/visual_console/render_view.php: fixed the link to edit

View File

@ -165,26 +165,32 @@ switch ($activeTab) {
}
$message = '';
if ($name_modules[0] == '0')
$message .= process_wizard_add ($id_agents, $image, $idVisualConsole, $range, $width, $height);
else{
$id_modules = array();
$cont_dest = 1;
$cont_mod = 1;
foreach($name_modules as $mod){
$cont_ag = 1;
foreach($id_agents as $ag){
$sql = "SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 0 AND id_agente = ".$ag." AND nombre = '".$mod."'";
$result = get_db_row_sql ($sql);
$id_modules[$cont_dest] = $result['id_agente_modulo'];
$cont_ag = $cont_ag + 1;
$cont_dest = $cont_dest + 1;
}
$cont_mod = $cont_mod + 1;
}
$message .= process_wizard_add_modules ($id_modules, $image, $idVisualConsole, $range, $width, $height);
if (empty($name_modules)) {
$statusProcessInDB = array('flag' => true, 'message' => print_error_message (__('No modules selected'), '', true));
}
else {
if ($name_modules[0] == '0')
$message .= process_wizard_add ($id_agents, $image, $idVisualConsole, $range, $width, $height);
else{
$id_modules = array();
$cont_dest = 1;
$cont_mod = 1;
foreach($name_modules as $mod){
$cont_ag = 1;
foreach($id_agents as $ag){
$sql = "SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 0 AND id_agente = ".$ag." AND nombre = '".$mod."'";
$result = get_db_row_sql ($sql);
$id_modules[$cont_dest] = $result['id_agente_modulo'];
$cont_ag = $cont_ag + 1;
$cont_dest = $cont_dest + 1;
}
$cont_mod = $cont_mod + 1;
}
$message .= process_wizard_add_modules ($id_modules, $image, $idVisualConsole, $range, $width, $height);
}
$statusProcessInDB = array('flag' => true, 'message' => $message);
}
$statusProcessInDB = array('flag' => true, 'message' => $message);
$action = 'edit';
break;
}

View File

@ -78,11 +78,11 @@ echo '</form>';
//Trick for it have a traduct text for javascript.
echo '<span id="any_text" style="display: none;">' . __('Any') . '</span>';
echo '<span id="none_text" style="display: none;">' . __('None') . '</span>';
?>
<script language="javascript" type="text/javascript">
var show_only_enabled_modules = true;
$(document).ready (function () {
//$("#id_agents").change (agent_changed);
$("#id_agents").change (agent_changed_by_multiple_agents);
});
</script>

View File

@ -108,6 +108,22 @@ function agent_changed (event, id_agent, selected) {
);
}
/**
* Util for check is empty object
*
* @param obj the object to check
* @returns {Boolean} True it is empty
*/
function isEmptyObject(obj) {
for(var prop in obj) {
if(obj.hasOwnProperty(prop))
return false;
}
return true;
}
/**
* Fill up select box with id "module" with modules after agent has been selected, but this not empty the select box.s
*
@ -144,6 +160,18 @@ function agent_changed_by_multiple_agents (event, id_agent, selected) {
function (data) {
$('#module').empty ();
if (isEmptyObject(data)) {
var noneText = $("#none_text").html(); //Trick for catch the translate text.
if (anyText == null) {
anyText = 'None';
}
$('#module').append ($('<option></option>').html (anyText).attr ("None", "").attr('selected', true));
return;
}
if (typeof($(document).data('text_for_module')) != 'undefined') {
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true));
}

View File

@ -95,6 +95,10 @@ if (is_ajax ()) {
$nameModules = get_db_all_rows_sql('SELECT DISTINCT(nombre) FROM tagente_modulo t1, talert_template_modules t2 WHERE t2.id_agent_module = t1.id_agente_modulo AND delete_pending = 0 AND id_agente IN (' . implode(',', $idAgents) . ') AND (SELECT count(nombre) FROM tagente_modulo t3, talert_template_modules t4 WHERE t4.id_agent_module = t3.id_agente_modulo AND delete_pending = 0 AND t1.nombre = t3.nombre AND id_agente IN (' . implode(',', $idAgents) . ')) = (' . count($idAgents) . ')');
if ($nameModules == false) {
$nameModules = array();
}
$result = array();
foreach($nameModules as $nameModule) {
$result[] = $nameModule['nombre'];
@ -121,6 +125,10 @@ if (is_ajax ()) {
FROM tagente_modulo t1
WHERE ' . $enabled . ' AND delete_pending = 0 AND id_agente IN (' . implode(',', $idAgents) . ') AND (SELECT count(nombre) FROM tagente_modulo t2 WHERE delete_pending = 0 AND t1.nombre = t2.nombre AND id_agente IN (' . implode(',', $idAgents) . ')) = (' . count($idAgents) . ')');
if ($nameModules == false) {
$nameModules = array();
}
$result = array();
foreach($nameModules as $nameModule) {
$result[] = safe_output($nameModule['nombre']);