Merge branch '1509-calculo-de-estado-en-consola-visual-mediante-el-peso-de-su-padre-dev' into 'develop'
Added new system of calculate status if user set a parent weight See merge request artica/pandorafms!1043
This commit is contained in:
commit
90b99c491a
|
@ -1239,6 +1239,7 @@ ALTER TABLE tlayout ADD `background_color` varchar(50) NOT NULL default '#FFF';
|
|||
ALTER TABLE tlayout_data ADD `type_graph` varchar(50) NOT NULL default 'area';
|
||||
ALTER TABLE tlayout_data ADD `label_position` varchar(50) NOT NULL default 'down';
|
||||
ALTER TABLE tlayout_data ADD COLUMN `show_statistics` tinyint(2) NOT NULL default '0';
|
||||
ALTER TABLE tlayout_data ADD COLUMN `id_layout_linked_weight` int(10) NOT NULL default '0';
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tagent_custom_fields`
|
||||
|
|
|
@ -822,6 +822,7 @@ function readFields() {
|
|||
values['bars_graph_type'] = $("select[name=bars_graph_type]").val();
|
||||
values['parent'] = $("select[name=parent]").val();
|
||||
values['map_linked'] = $("select[name=map_linked]").val();
|
||||
values['map_linked_weight'] = $("select[name=map_linked_weight]").val();
|
||||
values['width_percentile'] = $("input[name=width_percentile]").val();
|
||||
values['bars_graph_height'] = $("input[name=bars_graph_height]").val();
|
||||
values['max_percentile'] = parseInt($("input[name=max_percentile]").val());
|
||||
|
@ -1510,6 +1511,8 @@ function loadFieldsFromDB(item) {
|
|||
$("select[name=parent]").val(val);
|
||||
if (key == 'id_layout_linked')
|
||||
$("select[name=map_linked]").val(val);
|
||||
if (key == 'id_layout_linked_weight')
|
||||
$("select[name=map_linked_weight]").val(val);
|
||||
if (key == 'width_percentile')
|
||||
$("input[name=width_percentile]").val(val);
|
||||
if (key == 'bars_graph_height')
|
||||
|
@ -1800,6 +1803,9 @@ function hiddenFields(item) {
|
|||
$("#map_linked_row").css('display', 'none');
|
||||
$("#map_linked_row." + item).css('display', '');
|
||||
|
||||
$("#map_linked_weight").css('display', 'none');
|
||||
$("#map_linked_weight." + item).css('display', '');
|
||||
|
||||
$("#module_graph_size_row").css('display', 'none');
|
||||
$("#module_graph_size_row." + item).css('display', '');
|
||||
|
||||
|
@ -1879,6 +1885,7 @@ function cleanFields(item) {
|
|||
$("input[name=height]").val(0);
|
||||
$("select[name=parent]").val('');
|
||||
$("select[name=map_linked]").val('');
|
||||
$("select[name=map_linked_weight]").val('');
|
||||
$("input[name=width_module_graph]").val(300);
|
||||
$("input[name=height_module_graph]").val(180);
|
||||
$("input[name='width_box']").val(300);
|
||||
|
|
|
@ -100,6 +100,7 @@ $width = get_parameter('width', null);
|
|||
$height = get_parameter('height', null);
|
||||
$parent = get_parameter('parent', null);
|
||||
$map_linked = get_parameter('map_linked', null);
|
||||
$map_linked_weight = get_parameter('map_linked_weight', null);
|
||||
$width_percentile = get_parameter('width_percentile', null);
|
||||
$bars_graph_height = get_parameter('bars_graph_height', null);
|
||||
$max_percentile = get_parameter('max_percentile', null);
|
||||
|
@ -380,7 +381,7 @@ switch ($action) {
|
|||
|
||||
// Linked to other layout ?? - Only if not module defined
|
||||
if ($layoutData['id_layout_linked'] != 0) {
|
||||
$status = visual_map_get_layout_status ($layoutData['id_layout_linked']);
|
||||
$status = visual_map_get_layout_status ($layoutData['id_layout_linked'], $layoutData['id_layout_linked_weight']);
|
||||
|
||||
// Single object
|
||||
}
|
||||
|
@ -554,8 +555,6 @@ switch ($action) {
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (defined('METACONSOLE') && $metaconsole) {
|
||||
if ($server_name !== null) {
|
||||
$values['id_metaconsole'] = db_get_value('id',
|
||||
|
@ -570,6 +569,9 @@ switch ($action) {
|
|||
$values['id_agent'] = $id_agent;
|
||||
}
|
||||
}
|
||||
else if ($id_agent == 0) {
|
||||
$values['id_agent'] = 0;
|
||||
}
|
||||
else if (!empty($id_agent)) {
|
||||
$values['id_agent'] = $id_agent;
|
||||
}
|
||||
|
@ -586,6 +588,9 @@ switch ($action) {
|
|||
if ($map_linked !== null) {
|
||||
$values['id_layout_linked'] = $map_linked;
|
||||
}
|
||||
if ($map_linked_weight !== null) {
|
||||
$values['id_layout_linked_weight'] = $map_linked_weight;
|
||||
}
|
||||
switch ($type) {
|
||||
// -- line_item ------------------------------------
|
||||
case 'handler_start':
|
||||
|
@ -1021,6 +1026,7 @@ switch ($action) {
|
|||
}
|
||||
$values['id_agente_modulo'] = $id_module;
|
||||
$values['id_layout_linked'] = $map_linked;
|
||||
$values['id_layout_linked_weight'] = $map_linked_weight;
|
||||
$values['parent_item'] = $parent;
|
||||
$values['enable_link'] = $enable_link;
|
||||
$values['image'] = $background_color;
|
||||
|
|
|
@ -2912,7 +2912,26 @@ function visual_map_get_status_element($layoutData) {
|
|||
|
||||
//Linked to other layout ?? - Only if not module defined
|
||||
if ($layoutData['id_layout_linked'] != 0) {
|
||||
$status = visual_map_get_layout_status ($layoutData['id_layout_linked']);
|
||||
if ($layoutData['id_layout_linked_weight'] != 0) {
|
||||
$calculate_weight = true;
|
||||
}
|
||||
else {
|
||||
$calculate_weight = false;
|
||||
}
|
||||
$status = visual_map_get_layout_status ($layoutData['id_layout_linked'], 0, 0, $calculate_weight);
|
||||
|
||||
if ($layoutData['id_layout_linked_weight'] > 0) {
|
||||
$elements_to_compare = db_get_all_rows_sql("SELECT id FROM tlayout_data WHERE type = 0 AND id_layout = " . $layoutData['id_layout_linked']);
|
||||
|
||||
$aux_weight = ($status['elements_in_critical'] / count($elements_to_compare)) * 100;
|
||||
|
||||
if ($aux_weight >= $layoutData['id_layout_linked_weight']) {
|
||||
$status = $status['temp_total'];
|
||||
}
|
||||
else {
|
||||
$status = VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch ($layoutData["type"]) {
|
||||
|
@ -3356,7 +3375,7 @@ function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter
|
|||
*
|
||||
* @return bool The status of the given layout. True if it's OK, false if not.
|
||||
*/
|
||||
function visual_map_get_layout_status ($id_layout = 0, $depth = 0) {
|
||||
function visual_map_get_layout_status ($id_layout = 0, $depth = 0, $elements_in_critical = 0, $calculate_weight = false) {
|
||||
$temp_status = VISUAL_MAP_STATUS_NORMAL;
|
||||
$temp_total = VISUAL_MAP_STATUS_NORMAL;
|
||||
$depth++; // For recursion depth checking
|
||||
|
@ -3376,7 +3395,10 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) {
|
|||
'parent_item',
|
||||
'id_layout_linked',
|
||||
'id_agent',
|
||||
'type'));
|
||||
'type',
|
||||
'id_layout_linked_weight',
|
||||
'id',
|
||||
'id_layout'));
|
||||
if ($result === false)
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
|
||||
|
@ -3418,12 +3440,29 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) {
|
|||
|
||||
// Other Layout (Recursive!)
|
||||
if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) {
|
||||
$status = visual_map_get_layout_status($data["id_layout_linked"], $depth);
|
||||
if ($data['id_layout_linked_weight'] > 0) {
|
||||
$calculate_weight_c = true;
|
||||
}
|
||||
else {
|
||||
$calculate_weight_c = false;
|
||||
}
|
||||
$status = visual_map_get_layout_status($data["id_layout_linked"], $depth, 0, $calculate_weight_c);
|
||||
|
||||
$elements_in_child = db_get_all_rows_sql("SELECT id FROM tlayout_data WHERE type = 0 AND id_layout = " . $data['id_layout_linked']);
|
||||
if ($calculate_weight_c) {
|
||||
$aux_weight = ($status['elements_in_critical'] / count($elements_in_child)) * 100;
|
||||
|
||||
if ($aux_weight >= $data['id_layout_linked_weight']) {
|
||||
$status = $status['temp_total'];
|
||||
}
|
||||
else {
|
||||
$status = VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Module
|
||||
elseif ($data["id_agente_modulo"] != 0) {
|
||||
$status = modules_get_agentmodule_status($data["id_agente_modulo"]);
|
||||
|
||||
}
|
||||
// Agent
|
||||
else {
|
||||
|
@ -3437,11 +3476,23 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) {
|
|||
break;
|
||||
}
|
||||
|
||||
if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD)
|
||||
return VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
if ($calculate_weight) {
|
||||
if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD || $status == VISUAL_MAP_STATUS_WARNING) {
|
||||
$elements_in_critical++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD) {
|
||||
return VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
}
|
||||
|
||||
if ($status > $temp_total)
|
||||
}
|
||||
if ($status > $temp_total) {
|
||||
$temp_total = $status;
|
||||
}
|
||||
}
|
||||
if ($calculate_weight) {
|
||||
return array('elements_in_critical' => $elements_in_critical, 'temp_total' => $temp_total);
|
||||
}
|
||||
|
||||
return $temp_total;
|
||||
|
|
|
@ -659,11 +659,37 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
|
|||
WHERE id != ' . $visualConsole_id, 'map_linked', '', '', 'None', '0', true) .
|
||||
'</td>';
|
||||
|
||||
$form_items_advance['map_linked_weight'] = array();
|
||||
$form_items_advance['map_linked_weight']['items'] = array('static_graph');
|
||||
$form_items_advance['map_linked_weight']['html'] = '<td align="left">'.
|
||||
__('Map linked weight') . '</td>' .
|
||||
'<td align="left">' . html_print_select(array('10' => '10%',
|
||||
'20' => '20%',
|
||||
'30' => '30%',
|
||||
'40' => '40%',
|
||||
'50' => '50%',
|
||||
'60' => '60%',
|
||||
'70' => '70%',
|
||||
'80' => '80%',
|
||||
'90' => '90%',
|
||||
'100' => '100%'),
|
||||
'map_linked_weight', '', '', __('By default'), 0, true) .
|
||||
ui_print_help_tip (
|
||||
__("This percentage value specifies the number of items that must be present in the visual
|
||||
console for it to transmit its status to the icon linked here. For example, if 20% is
|
||||
specified and there are five elements in the console, it would be enough if you were in
|
||||
WARNING or CRITICAL to pass that value to the icon. If it were 40%, you would need at
|
||||
least two elements to be in CRITICAL or WARNING to go into that status. If it had one
|
||||
element in critical and another in warning, it would not forward any status to the icon
|
||||
associated with the visual console. If we had three in warning and one in critical,
|
||||
it would only convey the warning status. If there were two in warning and two in critical,
|
||||
it would show the CRITICAL because it is more serious. The same applies to unknown status."), true) .
|
||||
'</td>';
|
||||
|
||||
$form_items_advance['line_case']['items'] = array('line_item');
|
||||
$form_items_advance['line_case']['html'] = '
|
||||
<td align="left">' . __('Lines haven\'t advanced options') . '</td>';
|
||||
|
||||
|
||||
//Insert and modify before the buttons to create or update.
|
||||
if (enterprise_installed()) {
|
||||
enterprise_visual_map_editor_modify_form_items_advance_palette($form_items_advance);
|
||||
|
@ -846,4 +872,18 @@ function visual_map_editor_print_hack_translate_strings() {
|
|||
echo '<span style="display: none" id="hack_translation_incorrect_save">' .
|
||||
__('Could not be save') .'</span>';
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready (function () {
|
||||
$("#map_linked").change(function () {
|
||||
$("#text-agent").val("");
|
||||
$("input[name=id_agent]").val(0);
|
||||
$("#module").empty();
|
||||
$("#module")
|
||||
.append($("<option>")
|
||||
.attr("value", 0)
|
||||
.html("<?php echo __('Any'); ?>"));
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1360,6 +1360,7 @@ CREATE TABLE IF NOT EXISTS `tlayout_data` (
|
|||
`border_color` varchar(200) DEFAULT "",
|
||||
`fill_color` varchar(200) DEFAULT "",
|
||||
`show_statistics` tinyint(2) NOT NULL default '0',
|
||||
`id_layout_linked_weight` int(10) NOT NULL default '0',
|
||||
PRIMARY KEY(`id`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
Loading…
Reference in New Issue