From e2471f817d41f9a30f453e238627bfa139db54d5 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 9 Jan 2024 14:38:44 +0100 Subject: [PATCH] #12321 Added widget Gis map --- pandora_console/extras/mr/68.sql | 7 + pandora_console/images/widgets/GisMap.png | Bin 0 -> 9713 bytes .../include/lib/Dashboard/Widgets/GisMap.php | 541 ++++++++++++++++++ .../operation/gis_maps/render_view.php | 18 +- pandora_console/pandoradb_data.sql | 3 +- .../views/dashboard/listWidgets.php | 4 + 6 files changed, 555 insertions(+), 18 deletions(-) create mode 100644 pandora_console/extras/mr/68.sql create mode 100644 pandora_console/images/widgets/GisMap.png create mode 100644 pandora_console/include/lib/Dashboard/Widgets/GisMap.php diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql new file mode 100644 index 0000000000..669eceaecd --- /dev/null +++ b/pandora_console/extras/mr/68.sql @@ -0,0 +1,7 @@ +START TRANSACTION; + +SET @widget_id = NULL; +SELECT @widget_id := `id` FROM `twidget` WHERE `unique_name` = 'GisMap'; +INSERT IGNORE INTO `twidget` (`id`,`class_name`,`unique_name`,`description`,`options`,`page`) VALUES (@widget_id,'GisMap','GisMap','Gis map','','GisMap.php'); + +COMMIT; \ No newline at end of file diff --git a/pandora_console/images/widgets/GisMap.png b/pandora_console/images/widgets/GisMap.png new file mode 100644 index 0000000000000000000000000000000000000000..0cbfbf37b6e2c794aa04ac7dae32173dae9ed536 GIT binary patch literal 9713 zcmVAczO!S-4f~A|{oet>r8iym4p-@8;?ZWUKx$U7d}8t4;|Ka zUW|fV0m(mDvAatSwl6M}6X|6aIXW-gE_;{tjm4N*X0*H2D28=SGy#`f(Q-~qDF4na z>>JRAnK33vwxK$B)djL4_wIEB6>$BER1J|oJayH&VG1Y z?>+Ko#J~%d{T3%U9dePC2pCxMdnDq(*+2bcGG&G|6tsegewQXD^f@a5vt6R1iNz|( zN6I3bITLPKvkTvDPZI%vxFXwS$q80Zw+Nw?s3B`x zuy#Uo8K_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nk?!M~{~OjkYlep-;=wo{=z%uR6rR3PH;5-1@NtL!#6?}@0@&$N<3GfQ z>0PLb_LI77GxS#)R&!(o+XIR#Qn@vVzl?Yu`gHa7@cjJzh!CA2)b13*u9u}XFG=-U zO`gSJ%MT3=&AD%A*W5tkzrQ*tNqB`fNJ$FAjW=iQS|hFyuctBGWPr^`%3}2n&3)z_EZwuf`$D*W!VqpFP2ZE00000NkvXXu0mjfpGLkK literal 0 HcmV?d00001 diff --git a/pandora_console/include/lib/Dashboard/Widgets/GisMap.php b/pandora_console/include/lib/Dashboard/Widgets/GisMap.php new file mode 100644 index 0000000000..3cb967cf8c --- /dev/null +++ b/pandora_console/include/lib/Dashboard/Widgets/GisMap.php @@ -0,0 +1,541 @@ +width = $width; + + // Height. + $this->height = $height; + + // Grid Width. + $this->gridWidth = $gridWidth; + + // Cell Id. + $this->cellId = $cellId; + + // Options. + $this->values = $this->decoders($this->getOptionsWidget()); + + // Page. + $this->page = basename(__FILE__); + + // ClassName. + $class = new \ReflectionClass($this); + $this->className = $class->getShortName(); + + // Title. + $this->title = __('Gis map'); + + // Name. + if (empty($this->name) === true) { + $this->name = 'GisMap'; + } + + // This forces at least a first configuration. + $this->configurationRequired = false; + if (empty($this->values['gis_map']) === true) { + $this->configurationRequired = true; + } + } + + + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['gis_map']) === true) { + $values['gis_map'] = $decoder['gis_map']; + } + + return $values; + } + + + /** + * Generates inputs for form (specific). + * + * @return array Of inputs. + * + * @throws Exception On error. + */ + public function getFormInputs(): array + { + global $config; + + include_once $config['homedir'].'/include/functions_gis.php'; + + // Retrieve global - common inputs. + $inputs = parent::getFormInputs(); + + if ((bool) $config['activate_gis'] === true) { + $maps = gis_get_maps(); + } + + $array_map = []; + foreach ($maps as $map) { + if (check_acl($config['id_user'], $map['group_id'], 'MR') === false + && check_acl($config['id_user'], $map['group_id'], 'MW') === false + && check_acl($config['id_user'], $map['group_id'], 'MM') === false + ) { + continue; + } + + $array_map[$map['id_tgis_map']] = $map['map_name']; + } + + // Filters. + $inputs[] = [ + 'class' => 'flex flex-row', + 'label' => __('GIS maps'), + 'arguments' => [ + 'type' => 'select', + 'fields' => $array_map, + 'name' => 'gis_map', + 'return' => true, + 'selected' => ($this->values['gis_map'] === null) ? 0 : $this->values['gis_map'], + ], + ]; + + return $inputs; + } + + + /** + * Get Post for widget. + * + * @return array + */ + public function getPost(): array + { + // Retrieve global - common inputs. + $values = parent::getPost(); + + $values['gis_map'] = \get_parameter('gis_map', 0); + + return $values; + } + + + /** + * Draw widget. + * + * @return string; + */ + public function load() + { + global $config; + + include_once $config['homedir'].'/include/functions_gis.php'; + include_once $config['homedir'].'/include/functions_agents.php'; + + \ui_require_javascript_file('openlayers.pandora', 'include/javascript/', true); + \ui_require_javascript_file('OpenLayers/OpenLayers', 'include/javascript/', true); + + $map = db_get_row('tgis_map', 'id_tgis_map', $this->values['gis_map']); + + $output = ''; + if (check_acl($config['id_user'], $map['group_id'], 'MR') === false + && check_acl($config['id_user'], $map['group_id'], 'MW') === false + && check_acl($config['id_user'], $map['group_id'], 'MM') === false + ) { + $output .= '
'; + $output .= ui_print_error_message( + __('You don\'t have access'), + '', + true + ); + $output .= '
'; + return $output; + } + + $confMap = gis_get_map_conf($this->values['gis_map']); + + // Default open map (used to overwrite unlicensed google map view). + $confMapDefault = get_good_con(); + $confMapDefaultFull = json_decode($confMapDefault['conection_data'], true); + $confMapUrlDefault = $confMapDefaultFull['url']; + + $num_baselayer = 0; + // Initialy there is no Gmap base layer. + $gmap_layer = false; + if ($confMap !== false) { + foreach ($confMap as $mapC) { + $baselayers[$num_baselayer]['typeBaseLayer'] = $mapC['connection_type']; + $baselayers[$num_baselayer]['name'] = $mapC['conection_name']; + $baselayers[$num_baselayer]['num_zoom_levels'] = $mapC['num_zoom_levels']; + $decodeJSON = json_decode($mapC['conection_data'], true); + + switch ($mapC['connection_type']) { + case 'OSM': + $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; + break; + + case 'Gmap': + if (!isset($decodeJSON['gmap_key']) || empty($decodeJSON['gmap_key'])) { + // If there is not gmap_key, show the default view. + $baselayers[$num_baselayer]['url'] = $confMapUrlDefault; + $baselayers[$num_baselayer]['typeBaseLayer'] = 'OSM'; + } else { + $baselayers[$num_baselayer]['gmap_type'] = $decodeJSON['gmap_type']; + $baselayers[$num_baselayer]['gmap_key'] = $decodeJSON['gmap_key']; + $gmap_key = $decodeJSON['gmap_key']; + // Once a Gmap base layer is found we mark it to import the API. + $gmap_layer = true; + } + break; + + case 'Static_Image': + $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; + $baselayers[$num_baselayer]['bb_left'] = $decodeJSON['bb_left']; + $baselayers[$num_baselayer]['bb_right'] = $decodeJSON['bb_right']; + $baselayers[$num_baselayer]['bb_bottom'] = $decodeJSON['bb_bottom']; + $baselayers[$num_baselayer]['bb_top'] = $decodeJSON['bb_top']; + $baselayers[$num_baselayer]['image_width'] = $decodeJSON['image_width']; + $baselayers[$num_baselayer]['image_height'] = $decodeJSON['image_height']; + break; + + case 'WMS': + $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; + $baselayers[$num_baselayer]['layers'] = $decodeJSON['layers']; + break; + + default: + // Do nothing. + break; + } + + $num_baselayer++; + if ($mapC['default_map_connection'] == 1) { + $numZoomLevels = $mapC['num_zoom_levels']; + } + } + } + + if ($gmap_layer === true) { + if (https_is_running()) { + ?> + + + + values['gis_map']); + + $output .= '
'; + gis_print_map( + 'map_'.$this->cellId, + $map['zoom_level'], + $map['initial_latitude'], + $map['initial_longitude'], + $baselayers, + $controls + ); + $output .= '
'; + + if (empty($layers) === false) { + foreach ($layers as $layer) { + gis_make_layer( + $layer['layer_name'], + $layer['view_layer'], + null, + $layer['id_tmap_layer'] + ); + + // Calling agents_get_group_agents with none to obtain the names in the same case as they are in the DB. + $agentNamesByGroup = []; + if ($layer['tgrupo_id_grupo'] >= 0) { + $agentNamesByGroup = agents_get_group_agents( + $layer['tgrupo_id_grupo'], + false, + 'none', + true, + true, + false + ); + } + + $agentNamesByLayer = gis_get_agents_layer($layer['id_tmap_layer']); + + $groupsByAgentId = gis_get_groups_layer_by_agent_id($layer['id_tmap_layer']); + $agentNamesOfGroupItems = []; + foreach ($groupsByAgentId as $agentId => $groupInfo) { + $agentNamesOfGroupItems[$agentId] = $groupInfo['agent_name']; + } + + $agentNames = array_unique($agentNamesByGroup + $agentNamesByLayer + $agentNamesOfGroupItems); + + foreach ($agentNames as $key => $agentName) { + $idAgent = $key; + $coords = gis_get_data_last_position_agent($idAgent); + + if ($coords === false) { + $coords['stored_latitude'] = $map['default_latitude']; + $coords['stored_longitude'] = $map['default_longitude']; + } else { + if ($show_history == 'y') { + $lastPosition = [ + 'longitude' => $coords['stored_longitude'], + 'latitude' => $coords['stored_latitude'], + ]; + gis_add_path($layer['layer_name'], $idAgent, $lastPosition); + } + } + + $status = agents_get_status($idAgent, true); + $icon = gis_get_agent_icon_map($idAgent, true, $status); + $icon_size = getimagesize($icon); + $icon_width = $icon_size[0]; + $icon_height = $icon_size[1]; + + // Is a group item. + if (empty($groupsByAgentId[$idAgent]) === false) { + $groupId = (int) $groupsByAgentId[$idAgent]['id']; + $groupName = $groupsByAgentId[$idAgent]['name']; + + gis_add_agent_point( + $layer['layer_name'], + io_safe_output($groupName), + $coords['stored_latitude'], + $coords['stored_longitude'], + $icon, + $icon_width, + $icon_height, + $idAgent, + $status, + 'point_group_info', + $groupId + ); + } else { + $parent = db_get_value('id_parent', 'tagente', 'id_agente', $idAgent); + + gis_add_agent_point( + $layer['layer_name'], + io_safe_output($agentName), + $coords['stored_latitude'], + $coords['stored_longitude'], + $icon, + $icon_width, + $icon_height, + $idAgent, + $status, + 'point_agent_info', + $parent + ); + } + } + } + + gis_add_parent_lines(); + + $timestampLastOperation = db_get_value_sql('SELECT UNIX_TIMESTAMP()'); + + gis_activate_select_control(); + gis_activate_ajax_refresh($layers, $timestampLastOperation); + } + + return $output; + } + + + /** + * Get description. + * + * @return string. + */ + public static function getDescription() + { + return __('GIS map'); + } + + + /** + * Get Name. + * + * @return string. + */ + public static function getName() + { + return 'GisMap'; + } + + + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 500, + 'height' => 300, + ]; + + return $size; + } + + +} diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index e6cfaaee99..d826095a50 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -304,23 +304,7 @@ if ($layers != false) { gis_add_parent_lines(); - switch ($config['dbtype']) { - case 'mysql': - $timestampLastOperation = db_get_value_sql('SELECT UNIX_TIMESTAMP()'); - break; - - case 'postgresql': - $timestampLastOperation = db_get_value_sql( - "SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP))" - ); - break; - - case 'oracle': - $timestampLastOperation = db_get_value_sql( - "SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) FROM dual' - ); - break; - } + $timestampLastOperation = db_get_value_sql('SELECT UNIX_TIMESTAMP()'); gis_activate_select_control(); gis_activate_ajax_refresh($layers, $timestampLastOperation); diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index a7df8d9764..25b7cc781d 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2832,7 +2832,8 @@ INSERT INTO `twidget` (`id`,`class_name`,`unique_name`,`description`,`options`,` (44,'WuxWidget','wux_transaction','Agent WUX transaction','','wux_transaction.php'), (45,'WuxStatsWidget','wux_transaction_stats','WUX transaction stats','','wux_transaction_stats.php'), (46,'SecurityHardening','security_hardening','Security Hardening','','security_hardening.php'), - (47,'ServiceLevelWidget','service_level','Service Level','','service_level.php'); + (47,'ServiceLevelWidget','service_level','Service Level','','service_level.php'), + (48,'GisMap','GisMap','Gis map','','GisMap.php'); INSERT INTO `tmap` (`id`,`id_group`,`id_user`,`type`,`subtype`,`name`,`description`,`height`,`width`,`center_x`,`center_y`,`background`,`background_options`,`source_period`,`source`,`source_data`,`generation_method`,`generated`,`filter`,`id_group_map`,`refresh_time`) VALUES (1,'0','admin',0,0,'Sample dynamic map','This is a sample dynamic map.',900,900,0,0,'',0,60,0,'0',6,0,'{\"dont_show_subgroups\":0,\"node_radius\":40,\"x_offs\":\"0\",\"y_offs\":\"0\",\"z_dash\":\"1\",\"node_sep\":\"0.25\",\"rank_sep\":\"0.5\",\"mindist\":\"1\",\"kval\":\"0.3\"}',0,300); INSERT INTO `treport` (`id_report`,`id_user`,`name`,`description`,`private`,`id_group`,`custom_logo`,`header`,`first_page`,`footer`,`custom_font`,`id_template`,`id_group_edit`,`metaconsole`,`non_interactive`,`hidden`,`orientation`,`cover_page_render`,`index_render`) VALUES (1,'admin','Sample report #1','This is a sample report, just to show you some general report items.',0,0,NULL,NULL,'<p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><img src="http://localhost/pandora_console//images/pandora_report_logo.png" alt="" width="800" /></p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><span style="font-size: xx-large;">(_REPORT_NAME_)</span></p> <p style="text-align: center;"><span style="font-size: large;">(_DATETIME_)</span></p>',NULL,'Lato-Regular.ttf',0,0,0,0,0,'vertical',1,1); diff --git a/pandora_console/views/dashboard/listWidgets.php b/pandora_console/views/dashboard/listWidgets.php index 01767c1f9c..2c4272ddeb 100644 --- a/pandora_console/views/dashboard/listWidgets.php +++ b/pandora_console/views/dashboard/listWidgets.php @@ -71,6 +71,10 @@ foreach ($widgets as $widget) { continue; } + if ($widget['unique_name'] === 'GisMap' && (bool) $config['activate_gis'] === false) { + continue; + } + $imageWidget = '/images/widgets/'.$widget['unique_name'].'.png'; $output .= '
';