Merge branch '2778-Mostrar-valor-numerico-en-el-tooltip-dev' into 'develop'

fixed issue with string data in visual map

See merge request artica/pandorafms!1811
This commit is contained in:
vgilc 2018-10-03 09:31:02 +02:00
commit 46830a4cbe
7 changed files with 66 additions and 28 deletions

View File

@ -0,0 +1,5 @@
START TRANSACTION;
ALTER TABLE tlayout_data ADD COLUMN `show_last_value` tinyint(1) UNSIGNED NULL default '0';
COMMIT;

View File

@ -1294,6 +1294,7 @@ ALTER TABLE tlayout_data ADD COLUMN `show_on_top` tinyint(1) NOT NULL default '0
ALTER TABLE tlayout_data ADD COLUMN `clock_animation` varchar(60) NOT NULL default "analogic_1";
ALTER TABLE tlayout_data ADD COLUMN `time_format` varchar(60) NOT NULL default "time";
ALTER TABLE tlayout_data ADD COLUMN `timezone` varchar(60) NOT NULL default "Europe/Madrid";
ALTER TABLE tlayout_data ADD COLUMN `show_last_value` tinyint(1) UNSIGNED NULL default '0';
-- ---------------------------------------------------------------------
-- Table `tagent_custom_fields`

View File

@ -870,6 +870,7 @@ function readFields() {
values['time_format'] = $("select[name=time_format]").val();
values['timezone'] = $("select[name=timezone]").val();
values['clock_animation'] = $("select[name=clock_animation]").val();
values['show_last_value'] = $("select[name=last_value]").val();
if (is_metaconsole()) {
values['metaconsole'] = 1;
@ -1380,7 +1381,6 @@ function loadFieldsFromDB(item) {
}
});
parameter = Array();
parameter.push ({name: "page",
value: "include/ajax/visual_console_builder.ajax"});
@ -1459,26 +1459,26 @@ function loadFieldsFromDB(item) {
$("select[name=type_graph]").val(val);
}
if (key == 'label_position') {
if($("#hidden-metaconsole").val() == 1){
$('#labelposup'+" img").attr('src','../../images/label_up.png');
$('#labelposdown'+" img").attr('src','../../images/label_down.png');
$('#labelposleft'+" img").attr('src','../../images/label_left.png');
$('#labelposright'+" img").attr('src','../../images/label_right.png');
$('.labelpos').attr('sel','no');
$('#labelpos'+val+" img").attr('src','../../images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png');
$('#labelpos'+val).attr('sel','yes');
}
else{
$('#labelposup'+" img").attr('src','images/label_up.png');
$('#labelposdown'+" img").attr('src','images/label_down.png');
$('#labelposleft'+" img").attr('src','images/label_left.png');
$('#labelposright'+" img").attr('src','images/label_right.png');
$('.labelpos').attr('sel','no');
$('#labelpos'+val+" img").attr('src','images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png');
$('#labelpos'+val).attr('sel','yes');
}
if (key == 'label_position') {
if($("#hidden-metaconsole").val() == 1){
$('#labelposup'+" img").attr('src','../../images/label_up.png');
$('#labelposdown'+" img").attr('src','../../images/label_down.png');
$('#labelposleft'+" img").attr('src','../../images/label_left.png');
$('#labelposright'+" img").attr('src','../../images/label_right.png');
$('.labelpos').attr('sel','no');
$('#labelpos'+val+" img").attr('src','../../images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png');
$('#labelpos'+val).attr('sel','yes');
}
else{
$('#labelposup'+" img").attr('src','images/label_up.png');
$('#labelposdown'+" img").attr('src','images/label_down.png');
$('#labelposleft'+" img").attr('src','images/label_left.png');
$('#labelposright'+" img").attr('src','images/label_right.png');
$('.labelpos').attr('sel','no');
$('#labelpos'+val+" img").attr('src','images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png');
$('#labelpos'+val).attr('sel','yes');
}
}
if (key == 'image') {
//Load image preview
@ -1590,6 +1590,10 @@ function loadFieldsFromDB(item) {
.css('background-color', val);
}
if (key == 'show_last_value') {
$("select[name=last_value]").val(val);
}
if (key == 'clock_animation')
$("select[name=clock_animation]").val(val);
if (key == 'time_format')
@ -1852,6 +1856,9 @@ function hiddenFields(item) {
$("#percentile_bar_row_2").css('display', 'none');
$("#percentile_bar_row_2." + item).css('display', '');
$("#show_last_value_row").css('display', 'none');
$("#show_last_value_row." + item).css('display', '');
$("#percentile_item_row_3").css('display', 'none');
$("#percentile_item_row_3." + item).css('display', '');

View File

@ -164,6 +164,8 @@ $clock_animation = get_parameter('clock_animation', 'analogic_1');
$time_format = get_parameter('time_format', 'time');
$timezone = get_parameter('timezone', 'Europe/Madrid');
$show_last_value = get_parameter('show_last_value', null);
switch ($action) {
case 'get_font':
$return = array();
@ -785,6 +787,9 @@ switch ($action) {
if ($height !== null) {
$values['height'] = $height;
}
if ($show_last_value !== null) {
$values['show_last_value'] = $show_last_value;
}
break;
case 'simple_value':
if ($action == 'update') {
@ -1281,6 +1286,7 @@ switch ($action) {
$values['image'] = $image;
$values['width'] = $width;
$values['height'] = $height;
$values['show_last_value'] = $show_last_value;
break;
case 'group_item':
$values['type'] = GROUP_ITEM;

View File

@ -1775,16 +1775,25 @@ function visual_map_print_item($mode = "read", $layoutData,
$value = format_for_graph($value, 2);
}
if (!empty($unit_text))
$value .= " " . $unit_text;
// Hide value on boolean modules
if (!modules_is_boolean($layoutData['id_agente_modulo'])) {
$img_style_title .=
" <br>" . __("Last value: ")
. remove_right_zeros(number_format($value, $config['graph_precision'])).$unit_text;
if ($layoutData['show_last_value'] != 2) {
if ((!modules_is_boolean($layoutData['id_agente_modulo'])) ||
(modules_is_boolean($layoutData['id_agente_modulo']) && $layoutData['show_last_value'] != 0)){
if (is_numeric($value)) {
$img_style_title .=
" <br>" . __("Last value: ")
. remove_right_zeros(number_format($value, $config['graph_precision']));
} else {
$img_style_title .=
" <br>" . __("Last value: ")
. $value;
}
}
}
if (!empty($unit_text))
$img_style_title .= " " . $unit_text;
if ($layoutData['id_metaconsole'] != 0) {
//Restore db connection
metaconsole_restore_db();
@ -1792,7 +1801,7 @@ function visual_map_print_item($mode = "read", $layoutData,
}
if(get_parameter('action') == 'edit'){
$img_style_title = '';
$img_style_title = '';
}
}

View File

@ -590,6 +590,15 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
<td align="left" style="">' .
html_print_checkbox('show_on_top', 1, '', true) . '</td>';
$show_last_value = array('0' => __('Hide last value on boolean modules'), '1' => __('Enabled'), '2' => __('Disabled'));
$form_items['show_last_value_row'] = array();
$form_items['show_last_value_row']['items'] = array('static_graph');
$form_items['show_last_value_row']['html'] =
'<td align="left" style="">' . __('Show last value') . '</td>
<td align="left">' .
html_print_select($show_last_value, 'last_value', 0, '', '', '', true) .
'</td>';
$form_items['module_graph_size_row'] = array();
$form_items['module_graph_size_row']['items'] = array('module_graph', 'datos');
$form_items['module_graph_size_row']['html'] = '<td align="left">' . __('Size') . '</td>

View File

@ -1399,6 +1399,7 @@ CREATE TABLE IF NOT EXISTS `tlayout_data` (
`clock_animation` varchar(60) NOT NULL default "analogic_1",
`time_format` varchar(60) NOT NULL default "time",
`timezone` varchar(60) NOT NULL default "Europe/Madrid",
`show_last_value` tinyint(1) UNSIGNED NULL default '0',
PRIMARY KEY(`id`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;