diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 283afc5565..70a111f59c 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -70,10 +70,6 @@ $values[SECONDS_5MINUTES] = human_time_description_raw(SECONDS_5MINUTES); $values[SECONDS_10MINUTES] = human_time_description_raw(SECONDS_10MINUTES); $values[SECONDS_30MINUTES] = human_time_description_raw(SECONDS_30MINUTES); -$table_behaviour->data[$row][0] = __('Default interval for refresh on Visual Console').ui_print_help_tip(__('This interval will affect to Visual Console pages'), true); -$table_behaviour->data[$row][1] = html_print_select($values, 'vc_refr', $config['vc_refr'], '', 'N/A', 0, true, false, false); -$row++; - $table_behaviour->data[$row][0] = __('Paginated module view'); $table_behaviour->data[$row][1] = html_print_checkbox_switch( 'paginate_module', @@ -908,6 +904,24 @@ $row++; $table_vc->size[0] = '50%'; $table_vc->data = []; + // Remove when the new view reaches rock solid stability. + $table_vc->data[$row][0] = __('Legacy Visual Console View'); + $table_vc->data[$row][0] .= ui_print_help_tip( + __('To use the old view when using the Visual Console visor'), + true + ); + $table_vc->data[$row][1] = html_print_checkbox_switch( + 'legacy_vc', + 1, + (bool) $config['legacy_vc'], + true + ); + $row++; + + $table_vc->data[$row][0] = __('Default interval for refresh on Visual Console').ui_print_help_tip(__('This interval will affect to Visual Console pages'), true); + $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').ui_print_help_tip(__('Allows you to directly display the list of favorite visual consoles'), true); @@ -918,12 +932,8 @@ $row++; $table_vc->data[$row][1] = ""; $row++; - if (empty($config['vc_line_thickness'])) { - $config['vc_line_thickness'] = 2; - } - $table_vc->data[$row][0] = __('Default line thickness for the Visual Console').ui_print_help_tip(__('This interval will affect to the lines between elements on the Visual Console'), true); - $table_vc->data[$row][1] = html_print_input_text('vc_line_thickness', $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); echo '
'; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 7b3c4b632b..0200331e5b 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -980,7 +980,11 @@ function config_update_config() $error_update[] = __('Custom support url'); } - if (!config_update_value('vc_refr', get_parameter('vc_refr'))) { + if (!config_update_value('legacy_vc', (int) get_parameter('legacy_vc'))) { + $error_update[] = __('Use the legacy Visual Console'); + } + + if (!config_update_value('vc_refr', (int) get_parameter('vc_refr'))) { $error_update[] = __('Default interval for refresh on Visual Console'); } @@ -2415,10 +2419,18 @@ function config_process_config() config_update_value('dbtype', 'mysql'); } + if (!isset($config['legacy_vc'])) { + config_update_value('legacy_vc', 0); + } + if (!isset($config['vc_refr'])) { config_update_value('vc_refr', 300); } + if (!isset($config['vc_line_thickness'])) { + config_update_value('vc_line_thickness', 2); + } + if (!isset($config['agent_size_text_small'])) { config_update_value('agent_size_text_small', 18); } diff --git a/pandora_console/include/rest-api/models/VisualConsole/Container.php b/pandora_console/include/rest-api/models/VisualConsole/Container.php index 29b6809153..18a81b32fb 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Container.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Container.php @@ -78,15 +78,16 @@ final class Container extends Model protected function decode(array $data): array { return [ - 'id' => (int) $data['id'], - 'name' => $data['name'], - 'groupId' => $this->extractGroupId($data), - 'backgroundImage' => $this->extractBackgroundImage($data), - 'backgroundColor' => $this->extractBackgroundColor($data), - 'isFavorite' => $this->extractFavorite($data), - 'width' => (int) $data['width'], - 'height' => (int) $data['height'], - 'backgroundURL' => $this->extractBackgroundUrl($data), + 'id' => (int) $data['id'], + 'name' => $data['name'], + 'groupId' => $this->extractGroupId($data), + 'backgroundImage' => $this->extractBackgroundImage($data), + 'backgroundColor' => $this->extractBackgroundColor($data), + 'isFavorite' => $this->extractFavorite($data), + 'width' => (int) $data['width'], + 'height' => (int) $data['height'], + 'backgroundURL' => $this->extractBackgroundUrl($data), + 'relationLineWidth' => (int) $data['relationLineWidth'], ]; } @@ -216,6 +217,8 @@ final class Container extends Model // Clean HTML entities. $row = \io_safe_output($row); + $row['relationLineWidth'] = (int) $config['vc_line_thickness']; + $backgroundUrl = static::extractBackgroundUrl($row); $backgroundImage = static::extractBackgroundImage($row); diff --git a/pandora_console/operation/visual_console/legacy_public_view.php b/pandora_console/operation/visual_console/legacy_public_view.php new file mode 100644 index 0000000000..bc5b3d2a20 --- /dev/null +++ b/pandora_console/operation/visual_console/legacy_public_view.php @@ -0,0 +1,259 @@ +'."\n"; +echo ''."\n"; +echo ''; + +global $vc_public_view; +$vc_public_view = true; +// This starts the page head. In the call back function, +// things from $page['head'] array will be processed into the head +ob_start('ui_process_page_head'); +// Enterprise main +enterprise_include('index.php'); + +require_once 'include/functions_visual_map.php'; + +$hash = get_parameter('hash'); +$id_layout = (int) get_parameter('id_layout'); +$graph_javascript = (bool) get_parameter('graph_javascript'); +$config['id_user'] = get_parameter('id_user'); + +$myhash = md5($config['dbpass'].$id_layout.$config['id_user']); + +// Check input hash +if ($myhash != $hash) { + exit; +} + +$refr = (int) get_parameter('refr', 0); +$layout = db_get_row('tlayout', 'id', $id_layout); + +if (! $layout) { + db_pandora_audit('ACL Violation', 'Trying to access visual console without id layout'); + include $config['homedir'].'/general/noaccess.php'; + exit; +} + +if (!isset($config['pure'])) { + $config['pure'] = 0; +} + +// ~ $xhr = (bool) get_parameter('xhr'); +if ($layout) { + $id_group = $layout['id_group']; + $layout_name = $layout['name']; + $background = $layout['background']; + $bwidth = $layout['width']; + $bheight = $layout['height']; + // ~ $width = (int) get_parameter('width'); + // ~ if ($width <= 0) $width = null; + // ~ $height = (int) get_parameter('height'); + // ~ if ($height <= 0) $height = null; + // ~ ob_start(); + // ~ // Render map + visual_map_print_visual_map( + $id_layout, + true, + true, + $width, + $height, + '../../', + true, + true, + true + ); + // ~ return; +} else { + echo '
'; +} + +// Floating menu - Start +echo '
'; + +echo ''; + +echo '
'; +// Floating menu - End +// QR code dialog +echo ''; + +ui_require_jquery_file('countdown'); +ui_require_javascript_file('wz_jsgraphics'); +ui_require_javascript_file('pandora_visual_console'); +$ignored_params['refr'] = ''; +?> + + diff --git a/pandora_console/operation/visual_console/legacy_view.php b/pandora_console/operation/visual_console/legacy_view.php new file mode 100644 index 0000000000..4799932e2c --- /dev/null +++ b/pandora_console/operation/visual_console/legacy_view.php @@ -0,0 +1,380 @@ +'.html_print_image( + 'images/visual_console.png', + true, + ['title' => __('Visual consoles list')] +).''; + +if ($vconsole_write || $vconsole_manage) { + $url_base = 'index.php?sec=network&sec2=godmode/reporting/visual_console_builder&action='; + + $hash = md5($config['dbpass'].$id_layout.$config['id_user']); + + $options['public_link']['text'] = ''.html_print_image( + 'images/camera_mc.png', + true, + ['title' => __('Show link to public Visual Console')] + ).''; + $options['public_link']['active'] = false; + + $options['data']['text'] = ''.html_print_image( + 'images/op_reporting.png', + true, + ['title' => __('Main data')] + ).''; + $options['list_elements']['text'] = ''.html_print_image( + 'images/list.png', + true, + ['title' => __('List elements')] + ).''; + + if (enterprise_installed()) { + $options['wizard_services']['text'] = ''.html_print_image( + 'images/wand_services.png', + true, + ['title' => __('Services wizard')] + ).''; + } + + $options['wizard']['text'] = ''.html_print_image( + 'images/wand.png', + true, + ['title' => __('Wizard')] + ).''; + $options['editor']['text'] = ''.html_print_image( + 'images/builder.png', + true, + ['title' => __('Builder')] + ).''; +} + +$options['view']['text'] = ''.html_print_image('images/operation.png', true, ['title' => __('View')]).''; +$options['view']['active'] = true; + +if (!is_metaconsole()) { + if (!$config['pure']) { + $options['pure']['text'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode')]).''; + ui_print_page_header($layout_name, 'images/visual_console.png', false, '', false, $options); + } + + // Set the hidden value for the javascript + html_print_input_hidden('metaconsole', 0); +} else { + // Set the hidden value for the javascript + html_print_input_hidden('metaconsole', 1); +} + +if ($config['pure']) { + // Container of the visual map (ajax loaded) + echo '
'.visual_map_print_visual_map( + $id_layout, + true, + true, + null, + null, + '', + false, + true + ).'
'; + + // Floating menu - Start + echo '
'; + + echo ''; + + echo '
'; + // Floating menu - End + ui_require_jquery_file('countdown'); + + ?> + + + + \ No newline at end of file diff --git a/pandora_console/operation/visual_console/public_console.php b/pandora_console/operation/visual_console/public_console.php index 6411fcd9df..8a6ff462fc 100755 --- a/pandora_console/operation/visual_console/public_console.php +++ b/pandora_console/operation/visual_console/public_console.php @@ -15,251 +15,9 @@ // The session is configured and started inside the config process. require_once '../../include/config.php'; -$legacy = (bool) get_parameter('legacy', false); +$legacy = (bool) get_parameter('legacy', $config['legacy_vc']); if ($legacy === false) { include_once $config['homedir'].'/operation/visual_console/public_view.php'; - return; -} - -// Set root on homedir, as defined in setup -chdir($config['homedir']); - -ob_start(); -// Enterprise support -if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { - include_once ENTERPRISE_DIR.'/load_enterprise.php'; -} - -if (file_exists(ENTERPRISE_DIR.'/include/functions_login.php')) { - include_once ENTERPRISE_DIR.'/include/functions_login.php'; -} - -echo ''."\n"; -echo ''."\n"; -echo ''; - -global $vc_public_view; -$vc_public_view = true; -// This starts the page head. In the call back function, -// things from $page['head'] array will be processed into the head -ob_start('ui_process_page_head'); -// Enterprise main -enterprise_include('index.php'); - -require_once 'include/functions_visual_map.php'; - -$hash = get_parameter('hash'); -$id_layout = (int) get_parameter('id_layout'); -$graph_javascript = (bool) get_parameter('graph_javascript'); -$config['id_user'] = get_parameter('id_user'); - -$myhash = md5($config['dbpass'].$id_layout.$config['id_user']); - -// Check input hash -if ($myhash != $hash) { - exit; -} - -$refr = (int) get_parameter('refr', 0); -$layout = db_get_row('tlayout', 'id', $id_layout); - -if (! $layout) { - db_pandora_audit('ACL Violation', 'Trying to access visual console without id layout'); - include $config['homedir'].'/general/noaccess.php'; - exit; -} - -if (!isset($config['pure'])) { - $config['pure'] = 0; -} - -// ~ $xhr = (bool) get_parameter('xhr'); -if ($layout) { - $id_group = $layout['id_group']; - $layout_name = $layout['name']; - $background = $layout['background']; - $bwidth = $layout['width']; - $bheight = $layout['height']; - // ~ $width = (int) get_parameter('width'); - // ~ if ($width <= 0) $width = null; - // ~ $height = (int) get_parameter('height'); - // ~ if ($height <= 0) $height = null; - // ~ ob_start(); - // ~ // Render map - visual_map_print_visual_map( - $id_layout, - true, - true, - $width, - $height, - '../../', - true, - true, - true - ); - // ~ return; } else { - echo '
'; + include_once $config['homedir'].'/operation/visual_console/legacy_public_view.php'; } - -// Floating menu - Start -echo '
'; - -echo ''; - -echo '
'; -// Floating menu - End -// QR code dialog -echo ''; - -ui_require_jquery_file('countdown'); -ui_require_javascript_file('wz_jsgraphics'); -ui_require_javascript_file('pandora_visual_console'); -$ignored_params['refr'] = ''; -?> - - diff --git a/pandora_console/operation/visual_console/render_view.php b/pandora_console/operation/visual_console/render_view.php index dc51cbaac1..00cdc2d113 100755 --- a/pandora_console/operation/visual_console/render_view.php +++ b/pandora_console/operation/visual_console/render_view.php @@ -13,374 +13,9 @@ // GNU General Public License for more details. global $config; -$legacy = (bool) get_parameter('legacy'); +$legacy = (bool) get_parameter('legacy', $config['legacy_vc']); if ($legacy === false) { include_once $config['homedir'].'/operation/visual_console/view.php'; - return; -} - -// Login check -require_once $config['homedir'].'/include/functions_visual_map.php'; - -check_login(); - -if (!defined('METACONSOLE')) { - $id_layout = (int) get_parameter('id'); } else { - $id_layout = (int) get_parameter('id_visualmap'); + include_once $config['homedir'].'/operation/visual_console/legacy_view.php'; } - -if ($id_layout) { - $default_action = 'edit'; -} else { - $default_action = 'new'; -} - -if (!defined('METACONSOLE')) { - $action = get_parameterBetweenListValues( - 'action', - [ - 'new', - 'save', - 'edit', - 'update', - 'delete', - ], - $default_action - ); -} else { - $action = get_parameterBetweenListValues( - 'action2', - [ - 'new', - 'save', - 'edit', - 'update', - 'delete', - ], - $default_action - ); -} - -$refr = (int) get_parameter('refr', $config['vc_refr']); -$graph_javascript = (bool) get_parameter('graph_javascript', true); -$vc_refr = false; - -if (isset($config['vc_refr']) and $config['vc_refr'] != 0) { - $view_refresh = $config['vc_refr']; -} else { - $view_refresh = '300'; -} - -// Get input parameter for layout id -if (! $id_layout) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access visual console without id layout' - ); - include 'general/noaccess.php'; - exit; -} - -$layout = db_get_row('tlayout', 'id', $id_layout); - -if (! $layout) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access visual console without id layout' - ); - include 'general/noaccess.php'; - exit; -} - -$id_group = $layout['id_group']; -$layout_name = $layout['name']; -$background = $layout['background']; -$bwidth = $layout['width']; -$bheight = $layout['height']; - -$pure_url = '&pure='.$config['pure']; - -// ACL -$vconsole_read = check_acl($config['id_user'], $id_group, 'VR'); -$vconsole_write = check_acl($config['id_user'], $id_group, 'VW'); -$vconsole_manage = check_acl($config['id_user'], $id_group, 'VM'); - -if (! $vconsole_read && !$vconsole_write && !$vconsole_manage) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access visual console without group access' - ); - include 'general/noaccess.php'; - exit; -} - -// Render map -$options = []; - -$options['consoles_list']['text'] = ''.html_print_image( - 'images/visual_console.png', - true, - ['title' => __('Visual consoles list')] -).''; - -if ($vconsole_write || $vconsole_manage) { - $url_base = 'index.php?sec=network&sec2=godmode/reporting/visual_console_builder&action='; - - $hash = md5($config['dbpass'].$id_layout.$config['id_user']); - - $options['public_link']['text'] = ''.html_print_image( - 'images/camera_mc.png', - true, - ['title' => __('Show link to public Visual Console')] - ).''; - $options['public_link']['active'] = false; - - $options['data']['text'] = ''.html_print_image( - 'images/op_reporting.png', - true, - ['title' => __('Main data')] - ).''; - $options['list_elements']['text'] = ''.html_print_image( - 'images/list.png', - true, - ['title' => __('List elements')] - ).''; - - if (enterprise_installed()) { - $options['wizard_services']['text'] = ''.html_print_image( - 'images/wand_services.png', - true, - ['title' => __('Services wizard')] - ).''; - } - - $options['wizard']['text'] = ''.html_print_image( - 'images/wand.png', - true, - ['title' => __('Wizard')] - ).''; - $options['editor']['text'] = ''.html_print_image( - 'images/builder.png', - true, - ['title' => __('Builder')] - ).''; -} - -$options['view']['text'] = ''.html_print_image('images/operation.png', true, ['title' => __('View')]).''; -$options['view']['active'] = true; - -if (!is_metaconsole()) { - if (!$config['pure']) { - $options['pure']['text'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode')]).''; - ui_print_page_header($layout_name, 'images/visual_console.png', false, '', false, $options); - } - - // Set the hidden value for the javascript - html_print_input_hidden('metaconsole', 0); -} else { - // Set the hidden value for the javascript - html_print_input_hidden('metaconsole', 1); -} - -if ($config['pure']) { - // Container of the visual map (ajax loaded) - echo '
'.visual_map_print_visual_map( - $id_layout, - true, - true, - null, - null, - '', - false, - true - ).'
'; - - // Floating menu - Start - echo '
'; - - echo ''; - - echo '
'; - // Floating menu - End - ui_require_jquery_file('countdown'); - - ?> - - - - \ No newline at end of file diff --git a/visual_console_client/src/VisualConsole.ts b/visual_console_client/src/VisualConsole.ts index a780d01cb9..a79f779058 100644 --- a/visual_console_client/src/VisualConsole.ts +++ b/visual_console_client/src/VisualConsole.ts @@ -133,6 +133,7 @@ export interface VisualConsoleProps extends Size { backgroundURL: string | null; // URL? backgroundColor: string | null; isFavorite: boolean; + relationLineWidth: number; } /** @@ -154,7 +155,8 @@ export function visualConsolePropsDecoder( groupId, backgroundURL, backgroundColor, - isFavorite + isFavorite, + relationLineWidth } = data; if (id == null || isNaN(parseInt(id))) { @@ -174,6 +176,7 @@ export function visualConsolePropsDecoder( backgroundURL: notEmptyStringOr(backgroundURL, null), backgroundColor: notEmptyStringOr(backgroundColor, null), isFavorite: parseBoolean(isFavorite), + relationLineWidth: parseIntOr(relationLineWidth, 0), ...sizePropsDecoder(data) }; } @@ -520,7 +523,8 @@ export default class VisualConsole { endX, endY, width: 0, - height: 0 + height: 0, + lineWidth: this.props.relationLineWidth }) ); // Save a reference to the line item. diff --git a/visual_console_client/src/items/Line.ts b/visual_console_client/src/items/Line.ts index 2a1ee2b646..efae84ffd0 100644 --- a/visual_console_client/src/items/Line.ts +++ b/visual_console_client/src/items/Line.ts @@ -26,6 +26,8 @@ interface LineProps extends ItemProps { * is missing from the raw object or have an invalid type. */ export function linePropsDecoder(data: UnknownObject): LineProps | never { + const lineWidth = parseIntOr(data.lineWidth, 0); + return { ...itemBasePropsDecoder({ ...data, width: 1, height: 1 }), // Object spread. It will merge the properties of the two objects. type: ItemType.LINE_ITEM, @@ -47,8 +49,8 @@ export function linePropsDecoder(data: UnknownObject): LineProps | never { x: parseIntOr(data.endX, 0), y: parseIntOr(data.endY, 0) }, - lineWidth: parseIntOr(data.borderWidth, 1), - color: notEmptyStringOr(data.borderColor, null) + lineWidth: lineWidth > 0 ? lineWidth : 1, + color: notEmptyStringOr(data.borderColor || data.color, null) }; }