Merge branch 'ent-8888-consolas-visuales-vista-movil-carrefour' into 'develop'

Not orientation CV view mobile pandora_enterprise#8888

See merge request artica/pandorafms!4886
This commit is contained in:
Daniel Rodriguez 2022-06-23 10:07:24 +00:00
commit 4dd65c20a8
15 changed files with 221 additions and 78 deletions

View File

@ -288,7 +288,7 @@ foreach ($sessions as $session) {
array_push($table->data, $data);
}
$activity .= html_print_table($table, true);
$activity = html_print_table($table, true);
unset($table);
ui_toggle(

View File

@ -11,7 +11,7 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
// Load global vars.
global $config;
check_login();
@ -181,7 +181,8 @@ $backgrounds_list = array_merge($backgrounds_list_jpg, $backgrounds_list_png);
$backgrounds_list = array_merge($backgrounds_list, $backgrounds_list_gif);
asort($backgrounds_list);
if (!enterprise_installed()) {
$open = false;
if (enterprise_installed() === false) {
$open = true;
}
@ -953,7 +954,7 @@ $options_full_escale[2] = __('On Boolean graphs');
$table_chars->data[$row][1] = html_print_select(
$options_full_escale,
'full_scale_option',
$config['full_scale_option'],
(isset($config['full_scale_option']) === true) ? $config['full_scale_option'] : 0,
'',
'',
0,
@ -973,7 +974,7 @@ $options_soft_graphs[1] = __('Show MAX/AVG/MIN by default');
$table_chars->data[$row][1] = html_print_select(
$options_soft_graphs,
'type_mode_graph',
$config['type_mode_graph'],
(isset($config['type_mode_graph']) === true) ? $config['type_mode_graph'] : 0,
'',
'',
0,
@ -1053,13 +1054,31 @@ $table_vc->data[$row][1] = html_print_extended_select_for_time(
$row++;
$table_vc->data[$row][0] = __('Default interval for refresh on Visual Console');
$table_vc->data[$row][1] = html_print_select($values, 'vc_refr', (int) $config['vc_refr'], '', 'N/A', 0, true, false, false);
$table_vc->data[$row][1] = html_print_select(
$values,
'vc_refr',
(int) $config['vc_refr'],
'',
'N/A',
0,
true,
false,
false
);
$row++;
$vc_favourite_view_array[0] = __('Classic view');
$vc_favourite_view_array[1] = __('View of favorites');
$table_vc->data[$row][0] = __('Type of view of visual consoles');
$table_vc->data[$row][1] = html_print_select($vc_favourite_view_array, 'vc_favourite_view', $config['vc_favourite_view'], '', '', 0, true);
$table_vc->data[$row][1] = html_print_select(
$vc_favourite_view_array,
'vc_favourite_view',
$config['vc_favourite_view'],
'',
'',
0,
true
);
$row++;
$table_vc->data[$row][0] = __('Number of favorite visual consoles to show in the menu');
@ -1067,7 +1086,23 @@ $table_vc->data[$row][1] = "<input type ='number' value=".$config['vc_menu_items
$row++;
$table_vc->data[$row][0] = __('Default line thickness for the Visual Console');
$table_vc->data[$row][1] = html_print_input_text('vc_line_thickness', (int) $config['vc_line_thickness'], '', 5, 5, true);
$table_vc->data[$row][1] = html_print_input_text(
'vc_line_thickness',
(int) $config['vc_line_thickness'],
'',
5,
5,
true
);
$table_vc->data[$row][0] = __('Mobile view not allow visual console orientation');
$table_vc->data[$row][1] = html_print_checkbox_switch(
'mobile_view_orientation_vc',
1,
(bool) $config['mobile_view_orientation_vc'],
true
);
$row++;
// ----------------------------------------------------------------------
@ -1133,7 +1168,17 @@ $interval_description = [
'tiny' => 'Short',
];
$table_report->data[$row][0] = __('Interval description');
$table_report->data[$row][1] = html_print_select($interval_description, 'interval_description', $config['interval_description'], '', '', '', true, false, false);
$table_report->data[$row][1] = html_print_select(
$interval_description,
'interval_description',
(isset($config['interval_description']) === true) ? $config['interval_description'] : 'large',
'',
'',
'',
true,
false,
false
);
$row++;

View File

@ -851,6 +851,8 @@ class HTML
foreach ($inputs as $input) {
if (is_array(($input['arguments'] ?? null)) === true
&& isset($input['arguments']) === true
&& isset($input['arguments']['type']) === true
&& $input['arguments']['type'] === 'submit'
) {
$output_submit .= self::printBlock($input, true);

View File

@ -309,7 +309,7 @@ class WelcomeWindow extends Wizard
{
global $config;
return $config['welcome_id_agent'];
return (isset($config['welcome_id_agent']) === true) ? $config['welcome_id_agent'] : '';
}

View File

@ -1187,6 +1187,10 @@ function config_update_config()
$error_update[] = __('Default line thickness for the Visual Console');
}
if (config_update_value('mobile_view_orientation_vc', (int) get_parameter('mobile_view_orientation_vc'), true) === false) {
$error_update[] = __('Mobile view not allow visual console orientation');
}
if (config_update_value('ser_menu_items', (int) get_parameter('ser_menu_items', 10), true) === false) {
$error_update[] = __('Default line menu items for the Services');
}
@ -3073,6 +3077,10 @@ function config_process_config()
config_update_value('vc_line_thickness', 2);
}
if (isset($config['mobile_view_orientation_vc']) === false) {
config_update_value('mobile_view_orientation_vc', 0);
}
if (!isset($config['agent_size_text_small'])) {
config_update_value('agent_size_text_small', 18);
}

View File

@ -4924,7 +4924,7 @@ function html_print_input($data, $wrapper='div', $input_only=false)
case 'image':
$output .= html_print_input_image(
$data['name'],
((isset($data['name']) === true) ? $data['name'] : ''),
$data['src'],
$data['value'],
((isset($data['style']) === true) ? $data['style'] : ''),

View File

@ -34,15 +34,22 @@
*
* @param boolean $id_user
* @param boolean $user_strict
* @param [type] $acltags
* @param array $acltags
* @param boolean $returnAllGroup
* @param string $mode
* @param array $agent_filter
* @param array $module_filter
* @return void
*/
function tactical_get_data($id_user=false, $user_strict=false, $acltags, $returnAllGroup=false, $mode='group', $agent_filter=[], $module_filter=[])
{
function tactical_get_data(
$id_user=false,
$user_strict=false,
$acltags=[],
$returnAllGroup=false,
$mode='group',
$agent_filter=[],
$module_filter=[]
) {
global $config;
if ($id_user == false) {
$id_user = $config['id_user'];
@ -504,10 +511,12 @@ function tactical_status_modules_agents($id_user=false, $user_strict=false, $acc
function tactical_monitor_alerts($strict_user=false)
{
global $config;
$groups = users_get_groups($config['id_user'], 'AR', false);
$id_groups = array_keys($groups);
if (empty($id_groups)) {
$where_clause = '';
if (empty($id_groups) === true) {
$where_clause .= ' AND (1 = 0) ';
} else {
$where_clause .= sprintf(

View File

@ -82,7 +82,7 @@ function visual_map_print_user_line_handles($layoutData)
function visual_map_print_item(
$mode='read',
$layoutData,
$layoutData=[],
$proportion=null,
$show_links=true,
$isExternalLink=false,
@ -2554,13 +2554,13 @@ function visual_map_process_wizard_add(
$range,
$width=0,
$height=0,
$period,
$process_value,
$percentileitem_width,
$max_value,
$type_percentile,
$value_show,
$type
$period='',
$process_value='',
$percentileitem_width='',
$max_value=0,
$type_percentile='',
$value_show='',
$type=''
) {
if (empty($id_agents)) {
print_error_message(__('No agents selected'));
@ -3956,7 +3956,15 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
sort_by_column($valid_layout_items, 'id_metaconsole');
}
$num_elements_by_status = [];
$num_elements_by_status = [
VISUAL_MAP_STATUS_CRITICAL_BAD => 0,
VISUAL_MAP_STATUS_CRITICAL_ALERT => 0,
VISUAL_MAP_STATUS_NORMAL => 0,
VISUAL_MAP_STATUS_WARNING => 0,
VISUAL_MAP_STATUS_UNKNOWN => 0,
VISUAL_MAP_STATUS_WARNING_ALERT => 0,
];
$meta_connected_to = null;
foreach ($valid_layout_items as $layout_item_data) {
@ -3993,7 +4001,7 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
$ent_element_status = enterprise_hook(
'enterprise_visual_map_get_status_element',
[$layoutData]
[$layout_item_data]
);
if ($ent_element_status === ENTERPRISE_NOT_HOOK) {
$ent_element_status = false;
@ -4558,7 +4566,7 @@ function css_label_styles_visual_console($uniq, $ratio=1)
$output .= '.c-'.$uniq.' a {color: #3f3f3f } ';
$output .= '.c-'.$uniq.' .label p strong span {display: inline-block !important; line-height: normal !important} ';
$output .= '.c-'.$uniq.' *:not(.parent_graph p table tr td span) { font-size: '.(8 * $ratio).'pt; line-height:'.(8 * ($ratio)).'pt; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td { padding: 0; margin: 0; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td { padding: 0; margin: 0; white-space: pre-wrap; }';
$output .= '.c-'.$uniq.' .visual_font_size_4pt, .c-'.$uniq.' .visual_font_size_4pt * { font-size: '.(4 * $ratio).'pt !important; line-height:'.(4 * ($ratio)).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_6pt, .c-'.$uniq.' .visual_font_size_6pt * { font-size: '.(6 * $ratio).'pt !important; line-height:'.(6 * ($ratio)).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_8pt, .c-'.$uniq.' .visual_font_size_8pt * { font-size: '.(8 * $ratio).'pt !important; line-height:'.(8 * ($ratio)).'pt !important; }';

View File

@ -1223,6 +1223,8 @@ function dashboardLoadVC(settings) {
var ratio_visualconsole = props.height / props.width;
var ratio_w = size.width / props.width;
var ratio_h = size.height / props.height;
var acum_height = props.height;
var acum_width = props.width;
props.width = size.width;
props.height = size.width * ratio_visualconsole;
@ -1235,6 +1237,11 @@ function dashboardLoadVC(settings) {
props.height = size.height;
props.width = size.height / ratio_visualconsole;
}
} else {
ratio = ratio_w;
var height = (acum_height * size.width) / acum_width;
props.height = height;
props.width = height / ratio_visualconsole;
}
} else {
if (props.height > size.height) {
@ -1290,22 +1297,30 @@ function dashboardLoadVC(settings) {
var regex_hash = /(hash=)[^&]+(&?)/gi;
var replacement_hash = "$1" + props.hash + "$2";
/*
var regex_width = /(width=)[^&]+(&?)/gi;
var replacement_width = "$1" + size.width + "$2";
var regex_height = /(height=)[^&]+(&?)/gi;
var replacement_height =
"$1" + (size.height + headerMobileFix) + "$2";
*/
// Change the URL (if the browser has support).
if ("history" in window) {
var href = window.location.href.replace(regex, replacement);
href = href.replace(regex_hash, replacement_hash);
href = href.replace(regex_width, replacement_width);
href = href.replace(regex_height, replacement_height);
//href = href.replace(regex_width, replacement_width);
//href = href.replace(regex_height, replacement_height);
window.history.replaceState({}, document.title, href);
}
if (props.height > props.width) {
$(".container-center").css("overflow", "auto");
} else {
$(".container-center").css("overflow", "inherit");
}
container.classList.remove("cv-overflow");
// View title.
@ -1351,40 +1366,42 @@ function dashboardLoadVC(settings) {
: "dashboard"
);
$(window).on("orientationchange", function() {
$(container).width($(window).height());
$(container).height($(window).width() - headerMobileFix);
//Remove spinner change VC.
container.classList.remove("is-updating");
container.classList.remove("cv-overflow");
if (settings.mobile_view_orientation_vc === true) {
$(window).on("orientationchange", function() {
$(container).width($(window).height());
$(container).height($(window).width() - headerMobileFix);
//Remove spinner change VC.
container.classList.remove("is-updating");
container.classList.remove("cv-overflow");
var div = container.querySelector(".div-visual-console-spinner");
var div = container.querySelector(".div-visual-console-spinner");
if (div !== null) {
var parent = div.parentElement;
if (parent !== null) {
parent.removeChild(div);
if (div !== null) {
var parent = div.parentElement;
if (parent !== null) {
parent.removeChild(div);
}
}
}
container.classList.add("is-updating");
container.classList.add("cv-overflow");
const divParent = document.createElement("div");
divParent.className = "div-visual-console-spinner";
container.classList.add("is-updating");
container.classList.add("cv-overflow");
const divParent = document.createElement("div");
divParent.className = "div-visual-console-spinner";
const divSpinner = document.createElement("div");
divSpinner.className = "visual-console-spinner";
const divSpinner = document.createElement("div");
divSpinner.className = "visual-console-spinner";
divParent.appendChild(divSpinner);
container.appendChild(divParent);
divParent.appendChild(divSpinner);
container.appendChild(divParent);
var dimensions = {
width: $(window).height(),
height: $(window).width() - 40
};
var dimensions = {
width: $(window).height(),
height: $(window).width() - 40
};
visualConsoleManager.changeDimensionsVc(dimensions, interval);
});
visualConsoleManager.changeDimensionsVc(dimensions, interval);
});
}
}
// eslint-disable-next-line no-unused-vars

View File

@ -438,16 +438,22 @@ class MapsMadeByUser extends Widget
$settings = \json_encode(
[
'props' => $visualConsoleData,
'items' => $visualConsoleItems,
'baseUrl' => ui_get_full_url('/', false, false, false),
'ratio' => $ratio,
'size' => $size,
'cellId' => $this->cellId,
'hash' => User::generatePublicHash(),
'id_user' => $config['id_user'],
'page' => 'include/ajax/visual_console.ajax',
'uniq' => $uniq,
'props' => $visualConsoleData,
'items' => $visualConsoleItems,
'baseUrl' => ui_get_full_url(
'/',
false,
false,
false
),
'ratio' => $ratio,
'size' => $size,
'cellId' => $this->cellId,
'hash' => User::generatePublicHash(),
'id_user' => $config['id_user'],
'page' => 'include/ajax/visual_console.ajax',
'uniq' => $uniq,
'mobile_view_orientation_vc' => false,
]
);
@ -507,7 +513,6 @@ class MapsMadeByUser extends Widget
},
dataType: 'JSON',
success: function(data) {
console.log(data);
$('#vcId').empty();
Object.entries(data).forEach(e => {
key = e[0];

View File

@ -223,17 +223,33 @@ abstract class Model
*/
public function adjustToViewport($size, $mode='')
{
global $config;
$ratio_visualconsole = $this->getRatio();
$ratio_w = ($size['width'] / $this->data['width']);
$ratio_h = ($size['height'] / $this->data['height']);
$acum_height = $this->data['height'];
$acum_width = $this->data['width'];
$this->data['width'] = $size['width'];
$this->data['height'] = ($size['width'] * $ratio_visualconsole);
$ratio = $ratio_w;
if ($mode === 'mobile') {
if ($this->data['height'] < $this->data['width']) {
if ($this->data['height'] > $size['height']) {
if ((bool) $config['mobile_view_orientation_vc'] === true) {
if ($this->data['height'] < $this->data['width']) {
if ($this->data['height'] > $size['height']) {
$ratio = $ratio_h;
$this->data['height'] = $size['height'];
$this->data['width'] = ($size['height'] / $ratio_visualconsole);
}
} else {
$ratio = $ratio_w;
$height = (($acum_height * ($size['width'])) / $acum_width);
$this->data['height'] = $height;
$this->data['width'] = ($height / $ratio_visualconsole);
}
} else {
if ($this->data['height'] > $this->data['width']) {
$ratio = $ratio_h;
$this->data['height'] = $size['height'];
$this->data['width'] = ($size['height'] / $ratio_visualconsole);

View File

@ -174,6 +174,14 @@ final class StaticGraph extends Item
throw new \InvalidArgumentException('missing module Id');
}
if (isset($data['agentDisabled']) === false) {
$data['agentDisabled'] = false;
}
if (isset($data['moduleDisabled']) === false) {
$data['moduleDisabled'] = false;
}
if ((bool) $data['agentDisabled'] === false
&& (bool) $data['moduleDisabled'] === false
) {

View File

@ -1396,7 +1396,7 @@ div.ui-mobile-viewport {
overflow: visible;
overflow-x: hidden;
padding: 1em;
min-height: calc(100vh - 60px);
/*min-height: calc(100vh - 60px);*/
}
.ui-corner-all > .ui-toolbar-header:first-child,
.ui-corner-all > .ui-content:first-child,

View File

@ -1003,6 +1003,22 @@ class Ui
$(document).ready(function () {
dashboardLoadVC(settings);
if(settings.mobile_view_orientation_vc === false) {
$("#main_page > .ui-content").css("display", "block");
$(".container-center").css("padding", "50% 0");
$(".container-center").css("height", "100vh");
$(".visual-console-container-dashboard").css("display", "block");
$(".visual-console-container-dashboard").css("transform-origin", "left top");
$(".visual-console-container-dashboard").css("transform", "rotate(-90deg) translate(-100%)");
$(".visual-console-container-dashboard").css("margin-top", "-50%");
$(".visual-console-container-dashboard").css("white-space", "nowrap");
if(settings.props.height > settings.props.width) {
$(".container-center").css("overflow", "auto");
}
}
});
</script>'
);

View File

@ -216,6 +216,7 @@ class Visualmap
*/
private function show_visualmap()
{
global $config;
$ui = Ui::getInstance();
$system = System::getInstance();
@ -279,6 +280,13 @@ class Visualmap
'height' => $this->height,
];
if ((bool) $config['mobile_view_orientation_vc'] === true) {
$size = [
'width' => $this->height,
'height' => $this->width,
];
}
$ratio_t = $visualConsole->adjustToViewport($size, 'mobile');
$visualConsoleData = $visualConsole->toArray();
@ -340,16 +348,17 @@ class Visualmap
$settings = \json_encode(
[
'props' => $visualConsoleData,
'items' => $visualConsoleItems,
'baseUrl' => ui_get_full_url('/', false, false, false),
'page' => 'include/ajax/visual_console.ajax',
'ratio' => $ratio_t,
'size' => $size,
'cellId' => $uniq,
'uniq' => $uniq,
'mobile' => true,
'vcId' => $visualConsoleId,
'props' => $visualConsoleData,
'items' => $visualConsoleItems,
'baseUrl' => ui_get_full_url('/', false, false, false),
'page' => 'include/ajax/visual_console.ajax',
'ratio' => $ratio_t,
'size' => $size,
'cellId' => $uniq,
'uniq' => $uniq,
'mobile' => true,
'vcId' => $visualConsoleId,
'mobile_view_orientation_vc' => (bool) !$config['mobile_view_orientation_vc'],
]
);