diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 10539fae91..633e928852 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1685,7 +1685,9 @@ function html_print_select_multiple_modules_filtered(array $data):string ); } - if ($data['mAgents'] !== null) { + if (empty($data['mAgents']) === false + && empty($data['mModuleGroup'] === false) + ) { $all_modules = get_modules_agents( $data['mModuleGroup'], explode(',', $data['mAgents']), diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 6e5a87b169..03b7be02a7 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -266,7 +266,7 @@ function initialiceLayout(data) { }); $("#configure-widget-" + id).click(function() { - configurationWidget(id, widgetId); + getSizeModalConfiguration(id, widgetId); }); }, error: function(error) { @@ -275,6 +275,29 @@ function initialiceLayout(data) { }); } + function getSizeModalConfiguration(cellId, widgetId) { + $.ajax({ + method: "post", + url: data.url, + data: { + page: data.page, + method: "getSizeModalConfiguration", + dashboardId: data.dashboardId, + cellId: cellId, + widgetId: widgetId + }, + dataType: "json", + success: function(size) { + configurationWidget(cellId, widgetId, size); + }, + error: function(error) { + console.log(error); + return []; + } + }); + return false; + } + function saveLayout() { var items = $(".grid-stack > .grid-stack-item:visible") .map(function(i, el) { @@ -370,7 +393,7 @@ function initialiceLayout(data) { }); } - function configurationWidget(cellId, widgetId) { + function configurationWidget(cellId, widgetId, size) { load_modal({ target: $("#modal-config-widget"), form: "form-config-widget", @@ -388,12 +411,9 @@ function initialiceLayout(data) { dashboardId: data.dashboardId, widgetId: widgetId }, - width: - widgetId == 14 || widgetId == 2 || widgetId == 23 || widgetId == 16 - ? 750 - : 450, - maxHeight: 650, - minHeight: widgetId == 16 ? 450 : 400 + width: size.width, + maxHeight: size.height, + minHeight: size.height }, onsubmit: { page: data.page, @@ -710,7 +730,7 @@ function initialiceLayout(data) { }); $("#configure-widget-" + cellId).click(function() { - configurationWidget(cellId, widgetId); + getSizeModalConfiguration(cellId, widgetId); }); saveLayout(); diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index 33cd0a3c2c..56dc0b2caf 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -180,6 +180,7 @@ class Manager implements PublicLogin 'imageIconDashboardAjax', 'formSlides', 'callWidgetMethod', + 'getSizeModalConfiguration', ]; @@ -1524,4 +1525,22 @@ class Manager implements PublicLogin } + /** + * Size configuration modal (ajax only). + * + * @return void. + */ + public function getSizeModalConfiguration():void + { + $result = []; + $widget = $this->instanceWidget(); + $result = $widget->getSizeModalConfiguration(); + + echo json_encode($result); + + return; + + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php index 320280718b..cf0aa9e74d 100644 --- a/pandora_console/include/lib/Dashboard/Widget.php +++ b/pandora_console/include/lib/Dashboard/Widget.php @@ -512,7 +512,9 @@ class Widget if (empty($values['background']) === true) { $values['background'] = '#ffffff'; - if ($config['style'] === 'pandora_black' && !is_metaconsole()) { + if ($config['style'] === 'pandora_black' + && is_metaconsole() === false + ) { $values['background'] = '#222222'; } } @@ -759,4 +761,20 @@ class Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration():array + { + $size = [ + 'width' => 400, + 'height' => 650, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php index dbc0c1dcf5..1a1d147f49 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php +++ b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php @@ -285,12 +285,12 @@ class AgentModuleWidget extends Widget 'arguments' => [ 'type' => 'select_multiple_modules_filtered', 'uniqId' => $this->cellId, - 'mGroup' => $this->values['mGroup'], - 'mRecursion' => $this->values['mRecursion'], - 'mModuleGroup' => $this->values['mModuleGroup'], - 'mAgents' => $this->values['mAgents'], - 'mShowCommonModules' => $this->values['mShowCommonModules'], - 'mModules' => $this->values['mModules'], + 'mGroup' => (isset($this->values['mGroup']) === true) ? $this->values['mGroup'] : '', + 'mRecursion' => (isset($this->values['mRecursion']) === true) ? $this->values['mRecursion'] : '', + 'mModuleGroup' => (isset($this->values['mModuleGroup']) === true) ? $this->values['mModuleGroup'] : '', + 'mAgents' => (isset($this->values['mAgents']) === true) ? $this->values['mAgents'] : '', + 'mShowCommonModules' => (isset($this->values['mShowCommonModules']) === true) ? $this->values['mShowCommonModules'] : '', + 'mModules' => (isset($this->values['mModules']) === true) ? $this->values['mModules'] : '', 'mShowSelectedOtherGroups' => true, 'mReturnAllGroup' => $return_all_group, 'mMetaFields' => ((bool) is_metaconsole()), @@ -852,4 +852,20 @@ class AgentModuleWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 800, + 'height' => 600, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/alerts_fired.php b/pandora_console/include/lib/Dashboard/Widgets/alerts_fired.php index fdb5c3648a..ad9fcb0c2a 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/alerts_fired.php +++ b/pandora_console/include/lib/Dashboard/Widgets/alerts_fired.php @@ -372,4 +372,20 @@ class AlertsFiredWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 370, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/clock.php b/pandora_console/include/lib/Dashboard/Widgets/clock.php index 5d90f0f863..d06e1c8958 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/clock.php +++ b/pandora_console/include/lib/Dashboard/Widgets/clock.php @@ -322,4 +322,20 @@ class ClockWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 300, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php index c2515d1088..cdb6075d51 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php +++ b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php @@ -533,4 +533,20 @@ class CustomGraphWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 480, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/events_list.php b/pandora_console/include/lib/Dashboard/Widgets/events_list.php index e0c1bfe3cf..1a381db8af 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/events_list.php +++ b/pandora_console/include/lib/Dashboard/Widgets/events_list.php @@ -822,4 +822,20 @@ class EventsListWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 450, + 'height' => 700, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/example.php b/pandora_console/include/lib/Dashboard/Widgets/example.php index 3a4ec40fb6..3281c4a660 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/example.php +++ b/pandora_console/include/lib/Dashboard/Widgets/example.php @@ -289,4 +289,20 @@ class WelcomeWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 250, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php b/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php index dba9035877..570f2ea8b2 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php +++ b/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php @@ -443,4 +443,20 @@ class GraphModuleHistogramWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 500, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/groups_status.php b/pandora_console/include/lib/Dashboard/Widgets/groups_status.php index af25b2c056..cfa4d99c8f 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/groups_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/groups_status.php @@ -493,4 +493,20 @@ class GroupsStatusWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 300, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php b/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php index 7c874954cb..24ce8adc7c 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php +++ b/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php @@ -530,4 +530,20 @@ class MapsMadeByUser extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 360, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/maps_status.php b/pandora_console/include/lib/Dashboard/Widgets/maps_status.php index 2f59a29f0a..3da581f2fc 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/maps_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/maps_status.php @@ -400,4 +400,20 @@ class MapsStatusWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 450, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_icon.php b/pandora_console/include/lib/Dashboard/Widgets/module_icon.php index cb3d8086e8..a4ec3a09c6 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_icon.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_icon.php @@ -552,4 +552,20 @@ class ModuleIconWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 450, + 'height' => 700, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_status.php b/pandora_console/include/lib/Dashboard/Widgets/module_status.php index 0a0fe65615..2c3c87cc24 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_status.php @@ -550,4 +550,20 @@ class ModuleStatusWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 450, + 'height' => 700, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_table_value.php b/pandora_console/include/lib/Dashboard/Widgets/module_table_value.php index 0039768a30..d77a0cb9e2 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_table_value.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_table_value.php @@ -409,4 +409,20 @@ class ModuleTableValueWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 450, + 'height' => 460, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_value.php b/pandora_console/include/lib/Dashboard/Widgets/module_value.php index b005863b24..05a74c1ef1 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_value.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_value.php @@ -378,7 +378,7 @@ class ModuleValueWidget extends Widget { global $config; - $output .= ''; + $output = ''; $id_agent = $this->values['agentId']; $id_group = agents_get_agent_group($id_agent); @@ -445,4 +445,20 @@ class ModuleValueWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 450, + 'height' => 500, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/monitor_health.php b/pandora_console/include/lib/Dashboard/Widgets/monitor_health.php index c8a62feafa..e01ae72843 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/monitor_health.php +++ b/pandora_console/include/lib/Dashboard/Widgets/monitor_health.php @@ -349,4 +349,20 @@ class MonitorHealthWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 250, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/network_map.php b/pandora_console/include/lib/Dashboard/Widgets/network_map.php index c07e09758f..61a099f902 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/network_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/network_map.php @@ -490,4 +490,20 @@ class NetworkMapWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 470, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/post.php b/pandora_console/include/lib/Dashboard/Widgets/post.php index 584c1af782..e497568093 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/post.php +++ b/pandora_console/include/lib/Dashboard/Widgets/post.php @@ -288,4 +288,20 @@ class PostWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 520, + 'height' => 520, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/reports.php b/pandora_console/include/lib/Dashboard/Widgets/reports.php index 8611665128..cf471c037a 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/reports.php +++ b/pandora_console/include/lib/Dashboard/Widgets/reports.php @@ -499,4 +499,20 @@ class ReportsWidget extends Widget } + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 360, + ]; + + return $size; + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_map.php b/pandora_console/include/lib/Dashboard/Widgets/service_map.php index a2122c6dca..b0230c89e9 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_map.php @@ -254,6 +254,9 @@ class ServiceMapWidget extends Widget $inputs = parent::getFormInputs(); $services_res = services_get_services(); + if ($services_res === false) { + $services_res = []; + } // If currently selected report is not included in fields array (it belongs to a group over which user has no permissions), then add it to fields array. // This is aimed to avoid overriding this value when a user with narrower permissions edits widget configuration. @@ -341,6 +344,8 @@ class ServiceMapWidget extends Widget $size = parent::getSize(); + $output = ''; + if (check_acl($config['id_user'], 0, 'AR') === 0) { $output .= '