diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index 6567347999..059443eff6 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -26,6 +26,12 @@ * ============================================================================ */ +use PandoraFMS\TacticalView\GeneralTacticalView; + +$tacticalView = new GeneralTacticalView(); +$tacticalView->render(); +return; +// Temporal return for develop. // Config functions. require_once 'include/config.php'; diff --git a/pandora_console/images/status_check@svg.svg b/pandora_console/images/status_check@svg.svg new file mode 100644 index 0000000000..78e62ea848 --- /dev/null +++ b/pandora_console/images/status_check@svg.svg @@ -0,0 +1,26 @@ + + \ No newline at end of file diff --git a/pandora_console/images/status_error@svg.svg b/pandora_console/images/status_error@svg.svg new file mode 100644 index 0000000000..e6502bff7e --- /dev/null +++ b/pandora_console/images/status_error@svg.svg @@ -0,0 +1,26 @@ + + \ No newline at end of file diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 494ec9c010..f0980836b6 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -1019,7 +1019,9 @@ function get_build_setup_charts($type, $options, $data) ) { $scales = $chart->options()->getScales(); - if ($options['scales']['x'] !== false) { + if (isset($options['scales']['x']) === true + && $options['scales']['x'] !== false + ) { // Defaults scalesFont X. $scalesXFonts = $scales->getX()->ticks()->getFonts(); $scalesXFonts->setFamily((empty($config['fontpath']) === true) ? 'lato' : $config['fontpath']); @@ -1028,7 +1030,9 @@ function get_build_setup_charts($type, $options, $data) $scalesXFonts->setSize(((int) $config['font_size'] + 2)); } - if ($options['scales']['y'] !== false) { + if (isset($options['scales']['y']) === true + && $options['scales']['y'] !== false + ) { // Defaults scalesFont Y. $scalesYFonts = $scales->getY()->ticks()->getFonts(); $scalesYFonts->setFamily((empty($config['fontpath']) === true) ? 'lato' : $config['fontpath']); @@ -1037,7 +1041,9 @@ function get_build_setup_charts($type, $options, $data) $scalesYFonts->setSize(((int) $config['font_size'] + 2)); } - if ($options['scales']['r'] !== false) { + if (isset($options['scales']['r']) === true + && $options['scales']['r'] !== false + ) { // Defaults scalesFont R. $scalesRFonts = $scales->getR()->pointLabels()->getFonts(); $scalesRFonts->setStyle('normal'); @@ -1053,6 +1059,10 @@ function get_build_setup_charts($type, $options, $data) $scales->getX()->setBounds($options['scales']['x']['bounds']); } + if (isset($options['scales']['x']['display']) === true) { + $scales->getX()->setDisplay($options['scales']['x']['display']); + } + if (isset($options['scales']['x']['grid']) === true && empty($options['scales']['x']['grid']) === false && is_array($options['scales']['x']['grid']) === true @@ -1098,6 +1108,10 @@ function get_build_setup_charts($type, $options, $data) $scales->getY()->setBounds($options['scales']['y']['bounds']); } + if (isset($options['scales']['y']['display']) === true) { + $scales->getY()->setDisplay($options['scales']['y']['display']); + } + if (isset($options['scales']['y']['grid']) === true && empty($options['scales']['y']['grid']) === false && is_array($options['scales']['y']['grid']) === true diff --git a/pandora_console/include/lib/TacticalView/Element.php b/pandora_console/include/lib/TacticalView/Element.php new file mode 100644 index 0000000000..a97502e0e1 --- /dev/null +++ b/pandora_console/include/lib/TacticalView/Element.php @@ -0,0 +1,56 @@ +interval = 0; + $this->title = __('Default element'); + } + + +} diff --git a/pandora_console/include/lib/TacticalView/GeneralTacticalView.php b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php new file mode 100644 index 0000000000..82b042cf7c --- /dev/null +++ b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php @@ -0,0 +1,115 @@ +elements = $this->instanceElements(); + } + + + /** + * Instantiate all the elements that will build the dashboard + * + * @return array + */ + public function instanceElements():array + { + global $config; + $dir = $config['homedir'].'/include/lib/TacticalView/elements/'; + + $handle = opendir($dir); + if ($handle === false) { + return []; + } + + $ignores = [ + '.', + '..', + ]; + + $elements = []; + while (false !== ($file = readdir($handle))) { + try { + if (in_array($file, $ignores) === true) { + continue; + } + + $filepath = realpath($dir.'/'.$file); + if (is_readable($filepath) === false + || is_dir($filepath) === true + || preg_match('/.*\.php$/', $filepath) === false + ) { + continue; + } + + $className = preg_replace('/.php/', '', $file); + include_once $filepath; + if (class_exists($className) === true) { + $instance = new $className(); + $elements[$className] = $instance; + } + } catch (Exception $e) { + } + } + + return $elements; + } + + + /** + * Render funcion for print the html. + * + * @return void + */ + public function render():void + { + View::render( + 'tacticalView/view', + $this->elements + ); + } + + +} diff --git a/pandora_console/include/lib/TacticalView/elements/MonitoringElements.php b/pandora_console/include/lib/TacticalView/elements/MonitoringElements.php new file mode 100644 index 0000000000..4731d54b27 --- /dev/null +++ b/pandora_console/include/lib/TacticalView/elements/MonitoringElements.php @@ -0,0 +1,41 @@ +title = __('Monitoring elements'); + } + + +} diff --git a/pandora_console/include/lib/TacticalView/elements/NewsBoard.php b/pandora_console/include/lib/TacticalView/elements/NewsBoard.php new file mode 100644 index 0000000000..4f7820b19c --- /dev/null +++ b/pandora_console/include/lib/TacticalView/elements/NewsBoard.php @@ -0,0 +1,123 @@ +title = __('News Board'); + } + + + /** + * Returns the html of the latest news. + * + * @return string + */ + public function getNews():string + { + global $config; + $options = []; + $options['id_user'] = $config['id_user']; + $options['modal'] = false; + $options['limit'] = 7; + $news = get_news($options); + + if (!empty($news)) { + $output = '
'.__('Welcome to our monitoring tool so grand,').'
+
'.__('Where data insights are at your command.').'
+
'.__('Sales, marketing, operations too,').'
+
'.__("Customer support, we've got you.").'
+
'.__('Our interface is user-friendly,').'
+
'.__("Customize your dashboard, it's easy.").'
+
'.__('Set up alerts and gain insights so keen,').'
+
'.__("Optimize your data, like you've never seen.").'
+
'.__('Unleash its power now, and join the pro league,').'
+
'.__('Unlock the potential of your data to intrigue.').'
+
'.__('Monitoring made simple, efficient and fun,').'
+
'.__('Discover a whole new way to get things done.').'
+
'.__('And take control of your IT once and for all.').'
+ + '.__('You can replace this message with a personalized one at Admin tools -> Site news.').' + '; + + $output .= '