From 06a68d01bec5dbdcc365e3eed798d44fbed69024 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Thu, 13 Dec 2018 15:36:01 +0100 Subject: [PATCH] Error fixes and metaconsole support for the color cloud item of the VC Former-commit-id: 01b0045b76c41dc2c0f3145631fbd0beae3b16df --- .../visual_console_builder.editor.js | 19 ++++++++++--------- .../include/functions_visual_map.php | 17 +++++++++++++++-- .../include/functions_visual_map_editor.php | 7 ++++++- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index a7334f3c0c..426b0f5e49 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -653,9 +653,6 @@ function update_button_palette_callback() { var image = values['image'] + ".png"; set_image("image", idItem, image); break; - case "color_cloud": - setColorCloud(id_visual_console, idItem); - break; default: if($('input[name=width]').val() == ''){ alert('Undefined width'); @@ -2782,7 +2779,7 @@ function setColorCloud (visualConsoleId, dataId, $container) { $container = $container || $("#" + dataId + ".item.color_cloud"); if ($container.length === 0) return; - var $spinner = $container.find("#image_" + dataId); + var $spinner = $container.children("img"); var $svg = $container.children("svg"); if ($svg.length === 0) { @@ -3928,10 +3925,11 @@ function updateDB_visual(type, idElement , values, event, top, left) { case 'color_cloud': var diameter = values["diameter"]; var $container = $("#" + idElement + ".item.color_cloud"); - $container - .children("svg") - .attr("width", diameter) - .attr("height", diameter); + if ($container.children("img").length === 0) { + $container.append( + '' + ); + } setColorCloud(id_visual_console, idElement, $container); break; case 'background': @@ -5396,7 +5394,10 @@ function getColorRangeTable ($colorRangeCreationTable, values) { // Change img $colorRangeAddImg = $colorRangeAddBtn.children("img"); if ($colorRangeAddImg.length > 0) { - $colorRangeAddImg.prop("src", "images/delete.png"); + var src = $("#hidden-metaconsole").val() == 1 + ? "../../images/delete.png" + : "images/delete.png"; + $colorRangeAddImg.prop("src", src); } } diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 6b3886aebd..45ca40eb5f 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -4071,8 +4071,21 @@ function visual_map_get_color_cloud_element ($data) { !empty($dynamic_fields["color_ranges"]) && !empty($data["id_agente_modulo"]) ) { - // TODO: Metaconsole support. - $value = modules_get_last_value($data["id_agente_modulo"]); + $node_id = null; + $node_connected = false; + // Connect to node + if (is_metaconsole() && !empty($data["id_metaconsole"])) { + $node_id = (int) $data["id_metaconsole"]; + if (metaconsole_connect(null, $node_id) === NOERR) $node_connected = true; + } + + // Fetch module value + $value = (!$node_id || ($node_id && $node_connected)) + ? modules_get_last_value($data["id_agente_modulo"]) + : false; + + // Restore connection + if ($node_connected) metaconsole_restore_db(); if ($value !== false) { /* TODO: It would be ok to give support to string values in the future? diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index 3891cc2352..72b32e26e4 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -612,10 +612,14 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { ""; // Color ranges + $color_range_tip = __("TODO"); $form_items["color_cloud_color_ranges_row"] = array(); $form_items["color_cloud_color_ranges_row"]["items"] = array("color_cloud"); $form_items["color_cloud_color_ranges_row"]["html"] = - "" . __("Color ranges") . "" . + "" . + __("Ranges") . + ui_print_help_tip($color_range_tip, true) . + "" . "" . "" . "" . @@ -817,6 +821,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { var $mapLinkedSelect = $("select#map_linked"); var $linkedMapNodeIDInput = $("input#hidden-linked_map_node_id"); var visualMaps = ; + if (!(visualMaps instanceof Array)) visualMaps = []; var nodesById = ; visualMaps.forEach(function (vMap) {