diff --git a/pandora_console/images/visual_console.menu.png b/pandora_console/images/visual_console.menu.png
new file mode 100644
index 0000000000..818beae6f2
Binary files /dev/null and b/pandora_console/images/visual_console.menu.png differ
diff --git a/pandora_console/mobile/include/style/main.css b/pandora_console/mobile/include/style/main.css
index b3e066c893..347dce6732 100755
--- a/pandora_console/mobile/include/style/main.css
+++ b/pandora_console/mobile/include/style/main.css
@@ -26,6 +26,12 @@ body {
font-weight: bold;
}
+td.flex-center {
+ display: flex !important;
+ align-items: center;
+ justify-content: space-between;
+}
+
/*INIT----------Tactical styles-----------------------------------------*/
/* Common */
diff --git a/pandora_console/mobile/include/system.class.php b/pandora_console/mobile/include/system.class.php
index 8b79ef0139..de3b021edb 100644
--- a/pandora_console/mobile/include/system.class.php
+++ b/pandora_console/mobile/include/system.class.php
@@ -151,7 +151,7 @@ class System
}
- public function getDefaultACLFailText()
+ public static function getDefaultACLFailText()
{
return __('Access to this page is restricted to authorized users only, please contact your system administrator if you should need help.').'
'.__('Please remember that any attempts to access this page will be recorded on the %s System Database.', get_product_name());
}
diff --git a/pandora_console/mobile/index.php b/pandora_console/mobile/index.php
index 71b6db82ac..6cb2b4a56c 100644
--- a/pandora_console/mobile/index.php
+++ b/pandora_console/mobile/index.php
@@ -349,6 +349,18 @@ switch ($action) {
$agent = new Agent();
$agent->show();
break;
+
+ case 'visualmap':
+ $id = $system->getRequest('id', null);
+ if ($id !== null) {
+ $vc = new Visualmap();
+ $vc->show();
+ } else {
+ // Show a list ov VC.
+ $vc_list = new Visualmaps();
+ $vc_list->show();
+ }
+ break;
}
break;
}
diff --git a/pandora_console/mobile/operation/home.php b/pandora_console/mobile/operation/home.php
index d49f42eb0b..1fd8a79a47 100644
--- a/pandora_console/mobile/operation/home.php
+++ b/pandora_console/mobile/operation/home.php
@@ -59,12 +59,16 @@ class Home
'menu_item' => true,
'icon' => 'groups',
];
- $items['console'] = [
- 'name' => __('Visual consoles'),
- 'filename' => 'vconsole.php',
- 'menu_item' => true,
- 'icon' => 'consoles',
- ];
+
+ if ((bool) $system->getConfig('legacy_vc', false) === false) {
+ // Show Visual consoles only if new system is enabled.
+ $items['visualmap'] = [
+ 'name' => __('Visual consoles'),
+ 'filename' => 'visualmaps.php',
+ 'menu_item' => true,
+ 'icon' => 'visual_console',
+ ];
+ }
if (!$system->getConfig('metaconsole')) {
$items['alerts'] = [
diff --git a/pandora_console/mobile/operation/visualmaps.php b/pandora_console/mobile/operation/visualmaps.php
index 632f0ff1a9..1159e14409 100644
--- a/pandora_console/mobile/operation/visualmaps.php
+++ b/pandora_console/mobile/operation/visualmaps.php
@@ -1,56 +1,107 @@
checkACL($this->acl)) {
- $this->correct_acl = true;
+ $this->allowed = true;
} else {
- $this->correct_acl = false;
+ $this->allowed = false;
}
}
+ /**
+ * Prepare filters for current view.
+ *
+ * @return void
+ */
private function getFilters()
{
$system = System::getInstance();
$user = User::getInstance();
- $this->default_filters['group'] = true;
- $this->default_filters['type'] = true;
+ $this->defaultFilters['group'] = true;
+ $this->defaultFilters['type'] = true;
$this->group = (int) $system->getRequest('group', __('Group'));
if (!$user->isInGroup($this->acl, $this->group)) {
@@ -61,7 +112,7 @@ class Visualmaps
$this->group = 0;
} else {
$this->default = false;
- $this->default_filters['group'] = false;
+ $this->defaultFilters['group'] = false;
}
$this->type = $system->getRequest('type', __('Type'));
@@ -69,14 +120,19 @@ class Visualmaps
$this->type = '0';
} else {
$this->default = false;
- $this->default_filters['type'] = false;
+ $this->defaultFilters['type'] = false;
}
}
+ /**
+ * Run view.
+ *
+ * @return void
+ */
public function show()
{
- if (!$this->correct_acl) {
+ if (!$this->allowed) {
$this->show_fail_acl();
} else {
$this->getFilters();
@@ -85,12 +141,19 @@ class Visualmaps
}
+ /**
+ * Show a message about failed ACL access.
+ *
+ * @return void
+ */
private function show_fail_acl()
{
$error['type'] = 'onStart';
$error['title_text'] = __('You don\'t have access to this page');
$error['content_text'] = System::getDefaultACLFailText();
- if (class_exists('HomeEnterprise')) {
+
+ // Redirect to main page.
+ if (class_exists('HomeEnterprise') === true) {
$home = new HomeEnterprise();
} else {
$home = new Home();
@@ -100,6 +163,11 @@ class Visualmaps
}
+ /**
+ * Show visual console list header.
+ *
+ * @return void
+ */
private function show_visualmaps()
{
$ui = Ui::getInstance();
@@ -124,57 +192,44 @@ class Visualmaps
}
+ /**
+ * Show list of visual consoles.
+ *
+ * @return void
+ */
private function listVisualmapsHtml()
{
$system = System::getInstance();
$ui = Ui::getInstance();
- // Create filter
- $where = [];
- // Order by type field
- $where['order'] = 'type';
+ $visualmaps = visual_map_get_user_layouts();
- if ($this->group != '0') {
- $where['id_group'] = $this->group;
- }
-
- if ($this->type != '0') {
- $where['type'] = $this->type;
- }
-
- // Only display maps of "All" group if user is administrator
- // or has "RR" privileges, otherwise show only maps of user group
- $id_user = $system->getConfig('id_user');
- $own_info = get_user_info($id_user);
- if ($own_info['is_admin'] || $system->checkACL($this->acl)) {
- $maps = visual_map_get_user_layouts();
- } else {
- $maps = visual_map_get_user_layouts($id_user, false, false, false);
- }
-
- if (empty($maps)) {
- $maps = [];
- }
-
- $list = [];
- foreach ($maps as $map) {
- $row = [];
- $row[__('Name')] = ''.io_safe_output($map['name']).'';
- // $row[__('Type')] = $map['type'];
- $row[__('Group')] = ui_print_group_icon($map['id_group'], true, 'groups_small', '', false);
- $list[] = $row;
- }
-
- if (count($maps) == 0) {
+ if (empty($visualmaps) === true) {
$ui->contentAddHtml('
'.__('No maps defined').'
'); } else { $table = new Table(); + // Without header jquery.mobile crashes. + $table->addHeader(['']); $table->id = 'list_visualmaps'; - $table->importFromHash($list); - $ui->contentAddHtml($table->getHTML()); - } + foreach ($visualmaps as $map) { + $link = ''.io_safe_output($map['name']).''; - $ui->contentAddLinkListener('list_visualmaps'); + $row = $link; + $row .= ui_print_group_icon( + $map['id_group'], + true, + 'groups_small', + '', + false + ); + $table->addRow([ $map['id'].' flex-center' => $row]); + } + + $ui->contentAddHtml($table->getHTML()); + $ui->contentAddLinkListener('list_visualmaps'); + } }