mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Visual console list mobile view
This commit is contained in:
parent
5b176d9370
commit
b7e64f1477
BIN
pandora_console/images/visual_console.menu.png
Normal file
BIN
pandora_console/images/visual_console.menu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
@ -26,6 +26,12 @@ body {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td.flex-center {
|
||||||
|
display: flex !important;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
/*INIT----------Tactical styles-----------------------------------------*/
|
/*INIT----------Tactical styles-----------------------------------------*/
|
||||||
/* Common */
|
/* Common */
|
||||||
|
|
||||||
|
@ -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.').'<br><br>'.__('Please remember that any attempts to access this page will be recorded on the %s System Database.', get_product_name());
|
return __('Access to this page is restricted to authorized users only, please contact your system administrator if you should need help.').'<br><br>'.__('Please remember that any attempts to access this page will be recorded on the %s System Database.', get_product_name());
|
||||||
}
|
}
|
||||||
|
@ -349,6 +349,18 @@ switch ($action) {
|
|||||||
$agent = new Agent();
|
$agent = new Agent();
|
||||||
$agent->show();
|
$agent->show();
|
||||||
break;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -59,12 +59,16 @@ class Home
|
|||||||
'menu_item' => true,
|
'menu_item' => true,
|
||||||
'icon' => 'groups',
|
'icon' => 'groups',
|
||||||
];
|
];
|
||||||
$items['console'] = [
|
|
||||||
|
if ((bool) $system->getConfig('legacy_vc', false) === false) {
|
||||||
|
// Show Visual consoles only if new system is enabled.
|
||||||
|
$items['visualmap'] = [
|
||||||
'name' => __('Visual consoles'),
|
'name' => __('Visual consoles'),
|
||||||
'filename' => 'vconsole.php',
|
'filename' => 'visualmaps.php',
|
||||||
'menu_item' => true,
|
'menu_item' => true,
|
||||||
'icon' => 'consoles',
|
'icon' => 'visual_console',
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
if (!$system->getConfig('metaconsole')) {
|
if (!$system->getConfig('metaconsole')) {
|
||||||
$items['alerts'] = [
|
$items['alerts'] = [
|
||||||
|
@ -1,56 +1,107 @@
|
|||||||
<?php
|
<?php
|
||||||
// Pandora FMS - http://pandorafms.com
|
// phpcs:disable Squiz.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
// ==================================================
|
/**
|
||||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
* List of visual consoles, for mobile view.
|
||||||
// Please see http://pandorafms.org for full contribution list
|
*
|
||||||
// This program is free software; you can redistribute it and/or
|
* @category Common Class
|
||||||
// modify it under the terms of the GNU General Public License
|
* @package Pandora FMS
|
||||||
// as published by the Free Software Foundation for version 2.
|
* @subpackage OpenSource
|
||||||
// This program is distributed in the hope that it will be useful,
|
* @version 1.0.0
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* @license See below
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
*
|
||||||
// GNU General Public License for more details.
|
* ______ ___ _______ _______ ________
|
||||||
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||||
|
* Please see http://pandorafms.org for full contribution list
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation for version 2.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Begin.
|
||||||
ob_start();
|
ob_start();
|
||||||
require_once '../include/functions_visual_map.php';
|
require_once '../include/functions_visual_map.php';
|
||||||
ob_get_clean();
|
ob_get_clean();
|
||||||
// Fixed unused javascript code.
|
// Fixed unused javascript code.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to generate a list of current visual consoles defined.
|
||||||
|
*/
|
||||||
class Visualmaps
|
class Visualmaps
|
||||||
{
|
{
|
||||||
|
|
||||||
private $correct_acl = false;
|
/**
|
||||||
|
* ACL allowed.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $allowed = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perms needed to access this feature.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
private $acl = 'VR';
|
private $acl = 'VR';
|
||||||
|
|
||||||
private $default = true;
|
/**
|
||||||
|
* Default filters.
|
||||||
private $default_filters = [];
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $defaultFilters = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Group.
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
private $group = 0;
|
private $group = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type. Something about filtering.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
private $type = 0;
|
private $type = 0;
|
||||||
|
|
||||||
private $list_types = null;
|
|
||||||
|
|
||||||
|
/**
|
||||||
function __construct()
|
* Builder.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
{
|
{
|
||||||
$system = System::getInstance();
|
$system = System::getInstance();
|
||||||
|
|
||||||
if ($system->checkACL($this->acl)) {
|
if ($system->checkACL($this->acl)) {
|
||||||
$this->correct_acl = true;
|
$this->allowed = true;
|
||||||
} else {
|
} else {
|
||||||
$this->correct_acl = false;
|
$this->allowed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare filters for current view.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private function getFilters()
|
private function getFilters()
|
||||||
{
|
{
|
||||||
$system = System::getInstance();
|
$system = System::getInstance();
|
||||||
$user = User::getInstance();
|
$user = User::getInstance();
|
||||||
|
|
||||||
$this->default_filters['group'] = true;
|
$this->defaultFilters['group'] = true;
|
||||||
$this->default_filters['type'] = true;
|
$this->defaultFilters['type'] = true;
|
||||||
|
|
||||||
$this->group = (int) $system->getRequest('group', __('Group'));
|
$this->group = (int) $system->getRequest('group', __('Group'));
|
||||||
if (!$user->isInGroup($this->acl, $this->group)) {
|
if (!$user->isInGroup($this->acl, $this->group)) {
|
||||||
@ -61,7 +112,7 @@ class Visualmaps
|
|||||||
$this->group = 0;
|
$this->group = 0;
|
||||||
} else {
|
} else {
|
||||||
$this->default = false;
|
$this->default = false;
|
||||||
$this->default_filters['group'] = false;
|
$this->defaultFilters['group'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->type = $system->getRequest('type', __('Type'));
|
$this->type = $system->getRequest('type', __('Type'));
|
||||||
@ -69,14 +120,19 @@ class Visualmaps
|
|||||||
$this->type = '0';
|
$this->type = '0';
|
||||||
} else {
|
} else {
|
||||||
$this->default = false;
|
$this->default = false;
|
||||||
$this->default_filters['type'] = false;
|
$this->defaultFilters['type'] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run view.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function show()
|
public function show()
|
||||||
{
|
{
|
||||||
if (!$this->correct_acl) {
|
if (!$this->allowed) {
|
||||||
$this->show_fail_acl();
|
$this->show_fail_acl();
|
||||||
} else {
|
} else {
|
||||||
$this->getFilters();
|
$this->getFilters();
|
||||||
@ -85,12 +141,19 @@ class Visualmaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a message about failed ACL access.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private function show_fail_acl()
|
private function show_fail_acl()
|
||||||
{
|
{
|
||||||
$error['type'] = 'onStart';
|
$error['type'] = 'onStart';
|
||||||
$error['title_text'] = __('You don\'t have access to this page');
|
$error['title_text'] = __('You don\'t have access to this page');
|
||||||
$error['content_text'] = System::getDefaultACLFailText();
|
$error['content_text'] = System::getDefaultACLFailText();
|
||||||
if (class_exists('HomeEnterprise')) {
|
|
||||||
|
// Redirect to main page.
|
||||||
|
if (class_exists('HomeEnterprise') === true) {
|
||||||
$home = new HomeEnterprise();
|
$home = new HomeEnterprise();
|
||||||
} else {
|
} else {
|
||||||
$home = new Home();
|
$home = new Home();
|
||||||
@ -100,6 +163,11 @@ class Visualmaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show visual console list header.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private function show_visualmaps()
|
private function show_visualmaps()
|
||||||
{
|
{
|
||||||
$ui = Ui::getInstance();
|
$ui = Ui::getInstance();
|
||||||
@ -124,58 +192,45 @@ class Visualmaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show list of visual consoles.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private function listVisualmapsHtml()
|
private function listVisualmapsHtml()
|
||||||
{
|
{
|
||||||
$system = System::getInstance();
|
$system = System::getInstance();
|
||||||
$ui = Ui::getInstance();
|
$ui = Ui::getInstance();
|
||||||
|
|
||||||
// Create filter
|
$visualmaps = visual_map_get_user_layouts();
|
||||||
$where = [];
|
|
||||||
// Order by type field
|
|
||||||
$where['order'] = 'type';
|
|
||||||
|
|
||||||
if ($this->group != '0') {
|
if (empty($visualmaps) === true) {
|
||||||
$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')] = '<a class="ui-link" data-ajax="false" href="index.php?page=visualmap&id='.$map['id'].'">'.io_safe_output($map['name']).'</a>';
|
|
||||||
// $row[__('Type')] = $map['type'];
|
|
||||||
$row[__('Group')] = ui_print_group_icon($map['id_group'], true, 'groups_small', '', false);
|
|
||||||
$list[] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($maps) == 0) {
|
|
||||||
$ui->contentAddHtml('<p style="color: #ff0000;">'.__('No maps defined').'</p>');
|
$ui->contentAddHtml('<p style="color: #ff0000;">'.__('No maps defined').'</p>');
|
||||||
} else {
|
} else {
|
||||||
$table = new Table();
|
$table = new Table();
|
||||||
|
// Without header jquery.mobile crashes.
|
||||||
|
$table->addHeader(['']);
|
||||||
$table->id = 'list_visualmaps';
|
$table->id = 'list_visualmaps';
|
||||||
$table->importFromHash($list);
|
foreach ($visualmaps as $map) {
|
||||||
$ui->contentAddHtml($table->getHTML());
|
$link = '<a class="ui-link" data-ajax="false" ';
|
||||||
|
$link .= ' href="index.php?page=visualmap&id=';
|
||||||
|
$link .= $map['id'].'">'.io_safe_output($map['name']).'</a>';
|
||||||
|
|
||||||
|
$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');
|
$ui->contentAddLinkListener('list_visualmaps');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user