From d4f6baa9bb4529e639aefc86287c9c81302ce486 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 21 Feb 2023 15:06:58 +0100 Subject: [PATCH] #8642 Added heatmap widget 2 --- .../include/lib/Dashboard/Widgets/heatmap.php | 316 ++++++++++++++++++ 1 file changed, 316 insertions(+) create mode 100644 pandora_console/include/lib/Dashboard/Widgets/heatmap.php diff --git a/pandora_console/include/lib/Dashboard/Widgets/heatmap.php b/pandora_console/include/lib/Dashboard/Widgets/heatmap.php new file mode 100644 index 0000000000..c10c7c1f27 --- /dev/null +++ b/pandora_console/include/lib/Dashboard/Widgets/heatmap.php @@ -0,0 +1,316 @@ +width = $width; + + // Height. + $this->height = $height; + + // Cell Id. + $this->cellId = $cellId; + + // Widget ID. + $this->widgetId = $widgetId; + + // Dashboard ID. + $this->dashboardId = $dashboardId; + + // Options. + $this->values = $this->decoders($this->getOptionsWidget()); + + // Page. + $this->page = basename(__FILE__); + + // ClassName. + $class = new \ReflectionClass($this); + $this->className = $class->getShortName(); + + // Title. + $this->title = __('Heatmap'); + + // Name. + if (empty($this->name) === true) { + $this->name = 'heatmap'; + } + } + + + /** + * 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); + + return $values; + } + + + /** + * Generates inputs for form (specific). + * + * @return array Of inputs. + * + * @throws Exception On error. + */ + public function getFormInputs(): array + { + // Retrieve global - common inputs. + $inputs = parent::getFormInputs(); + + return $inputs; + } + + + /** + * Get Post for widget. + * + * @return array + */ + public function getPost(): array + { + // Retrieve global - common inputs. + $values = parent::getPost(); + + return $values; + } + + + /** + * Get description. + * + * @return string. + */ + public static function getDescription() + { + return __('Heatmap'); + } + + + /** + * Get Name. + * + * @return string. + */ + public static function getName() + { + return 'heatmap'; + } + + + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 205, + ]; + + return $size; + } + + + /** + * Draw widget. + * + * @return string; + */ + public function load() + { + global $config; + + \ui_require_css_file('heatmap', 'include/styles/', true); + + $values = $this->values; + hd($values, true); + + // Control call flow. + $heatmap = new Heatmap(0, [], null, 300, 400, 200, 0, 1); + // AJAX controller. + if (is_ajax() === true) { + $method = get_parameter('method'); + + if ($method === 'drawWidget') { + // Run. + $heatmap->run(); + } else { + if (method_exists($heatmap, $method) === true) { + if ($heatmap->ajaxMethod($method) === true) { + $heatmap->{$method}(); + } else { + echo 'Unavailable method'; + } + } else { + echo 'Method not found'; + } + + // Stop any execution. + exit; + } + } else { + // Run. + $heatmap->run(); + + // Dialog. + echo ''; + } + + return ''; + } + + +}