From e6713c2f2c6abb1735c3df133d8615a17985cf6f Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@artica.es>
Date: Tue, 25 May 2021 09:58:18 +0000
Subject: [PATCH] #6917 metaconsole config changes

---
 pandora_console/extras/mr/47.sql              | 10 +++++
 pandora_console/include/functions_config.php  | 38 +++++++++++++++----
 .../include/styles/meta_dashboards.css        |  2 +-
 .../operation/dashboard/dashboard.php         |  8 ++++
 4 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/pandora_console/extras/mr/47.sql b/pandora_console/extras/mr/47.sql
index aa07478947..9a7bf687a7 100644
--- a/pandora_console/extras/mr/47.sql
+++ b/pandora_console/extras/mr/47.sql
@@ -11,4 +11,14 @@ ALTER TABLE `talert_snmp_action` ADD COLUMN `al_field18` TEXT NOT NULL AFTER `al
 ALTER TABLE `talert_snmp_action` ADD COLUMN `al_field19` TEXT NOT NULL AFTER `al_field18`;
 ALTER TABLE `talert_snmp_action` ADD COLUMN `al_field20` TEXT NOT NULL AFTER `al_field19`;
 
+SET @st_oum755 = (SELECT IF(
+    (SELECT COUNT(*) FROM tconfig WHERE token LIKE 'meta_custom_logo' AND value like 'logo_pandora_metaconsola.png') > 0,
+    "UPDATE `tconfig` set value = 'pandoraFMS_metaconsole_full.svg' WHERE token LIKE 'meta_custom_logo'",
+	"SELECT 1"
+));
+
+PREPARE pr_oum755 FROM @st_oum755;
+EXECUTE pr_oum755;
+DEALLOCATE PREPARE pr_oum755;
+
 COMMIT;
diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index 676a6fbeb0..3920109890 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -1032,6 +1032,14 @@ function config_update_config()
                         $error_update[] = __('Custom subtitle header');
                     }
 
+                    if (!config_update_value('meta_custom_title_header', (string) get_parameter('meta_custom_title_header'))) {
+                        $error_update[] = __('Meta custom title header');
+                    }
+
+                    if (!config_update_value('meta_custom_subtitle_header', (string) get_parameter('meta_custom_subtitle_header'))) {
+                        $error_update[] = __('Meta custom subtitle header');
+                    }
+
                     if (!config_update_value('custom_title1_login', (string) get_parameter('custom_title1_login'))) {
                         $error_update[] = __('Custom title1 login');
                     }
@@ -1060,10 +1068,6 @@ function config_update_config()
                         $error_update[] = __('Copyright notice');
                     }
 
-                    if (!config_update_value('meta_custom_logo', (string) get_parameter('meta_custom_logo'))) {
-                        $error_update[] = __('Custom logo metaconsole');
-                    }
-
                     if (!config_update_value('meta_custom_logo_white_bg', (string) get_parameter('meta_custom_logo_white_bg'))) {
                         $error_update[] = __('Custom logo metaconsole (white background)');
                     }
@@ -2291,6 +2295,20 @@ function config_process_config()
         config_update_value('custom_logo_collapsed', 'pandora_logo_green_collapsed.png');
     }
 
+    if (is_metaconsole()) {
+        if (!isset($config['meta_custom_logo'])) {
+            config_update_value('meta_custom_logo', 'pandoraFMS_metaconsole_full.svg');
+        }
+
+        if (!isset($config['meta_custom_logo_collapsed'])) {
+            config_update_value('meta_custom_logo_collapsed', 'pandoraFMS_metaconsole_collapse.svg');
+        }
+
+        if (!isset($config['meta_menu_type'])) {
+            config_update_value('meta_menu_type', 'classic');
+        }
+    }
+
     if (!isset($config['custom_logo_white_bg'])) {
         config_update_value('custom_logo_white_bg', 'pandora_logo_head_white_bg.png');
     }
@@ -2327,6 +2345,14 @@ function config_process_config()
         config_update_value('custom_subtitle_header', __('the Flexible Monitoring System'));
     }
 
+    if (!isset($config['meta_custom_title_header'])) {
+        config_update_value('meta_custom_title_header', __('PandoraFMS Metaconsole'));
+    }
+
+    if (!isset($config['meta_custom_subtitle_header'])) {
+        config_update_value('meta_custom_subtitle_header', __('Centralized operation console'));
+    }
+
     if (!isset($config['custom_title1_login'])) {
         config_update_value('custom_title1_login', __('PANDORA FMS'));
     }
@@ -2359,10 +2385,6 @@ function config_process_config()
         config_update_value('meta_custom_support_url', 'https://support.pandorafms.com');
     }
 
-    if (!isset($config['meta_custom_logo'])) {
-        config_update_value('meta_custom_logo', 'logo_pandora_metaconsola.png');
-    }
-
     if (!isset($config['meta_custom_logo_white_bg'])) {
         config_update_value('pandora_logo_head_white_bg', 'pandora_logo_head_white_bg.png');
     }
diff --git a/pandora_console/include/styles/meta_dashboards.css b/pandora_console/include/styles/meta_dashboards.css
index 1b24b3bce5..a5b2736110 100644
--- a/pandora_console/include/styles/meta_dashboards.css
+++ b/pandora_console/include/styles/meta_dashboards.css
@@ -1,5 +1,5 @@
 div#page {
-  width: 90% !important;
+  width: auto;
   margin: 0 auto;
 }
 
diff --git a/pandora_console/operation/dashboard/dashboard.php b/pandora_console/operation/dashboard/dashboard.php
index 3b081cfc7a..a3379565b7 100644
--- a/pandora_console/operation/dashboard/dashboard.php
+++ b/pandora_console/operation/dashboard/dashboard.php
@@ -70,6 +70,14 @@ if (is_ajax() === true) {
         }
     }
 } else {
+    if ((bool) is_metaconsole() === true) {
+        echo '<div class="meta_container_dashboard">';
+    }
+
     // Run.
     $cs->run();
+
+    if ((bool) is_metaconsole() === true) {
+        echo '</div>';
+    }
 }