Ticket 10484 Fixed List Operating Systems

This commit is contained in:
Jose Gonzalez 2023-02-20 13:02:24 +01:00
parent 98bd383141
commit da58e4b9e0
26 changed files with 136 additions and 89 deletions

View File

@ -1,25 +1,25 @@
START TRANSACTION;
UPDATE tconfig_os SET `icon_name` = 'linux@svg.svg' WHERE `id_os` = 1;
UPDATE tconfig_os SET `icon_name` = 'solaris@svg.svg' WHERE `id_os` = 2;
UPDATE tconfig_os SET `icon_name` = 'aix@svg.svg' WHERE `id_os` = 3;
UPDATE tconfig_os SET `icon_name` = 'freebsd@svg.svg' WHERE `id_os` = 4;
UPDATE tconfig_os SET `icon_name` = 'HP@svg.svg' WHERE `id_os` = 5;
UPDATE tconfig_os SET `icon_name` = 'cisco@svg.svg' WHERE `id_os` = 7;
UPDATE tconfig_os SET `icon_name` = 'apple@svg.svg' WHERE `id_os` = 8;
UPDATE tconfig_os SET `icon_name` = 'windows@svg.svg' WHERE `id_os` = 9;
UPDATE tconfig_os SET `icon_name` = 'other-OS@svg.svg' WHERE `id_os` = 10;
UPDATE tconfig_os SET `icon_name` = 'network-server@svg.svg' WHERE `id_os` = 11;
UPDATE tconfig_os SET `icon_name` = 'network-server@svg.svg' WHERE `id_os` = 12;
UPDATE tconfig_os SET `icon_name` = 'network-server@svg.svg' WHERE `id_os` = 13;
UPDATE tconfig_os SET `icon_name` = 'embedded@svg.svg' WHERE `id_os` = 14;
UPDATE tconfig_os SET `icon_name` = 'android@svg.svg' WHERE `id_os` = 15;
UPDATE tconfig_os SET `icon_name` = 'vmware@svg.svg' WHERE `id_os` = 16;
UPDATE tconfig_os SET `icon_name` = 'routers@svg.svg' WHERE `id_os` = 17;
UPDATE tconfig_os SET `icon_name` = 'switch@svg.svg' WHERE `id_os` = 18;
UPDATE tconfig_os SET `icon_name` = 'satellite@svg.svg' WHERE `id_os` = 19;
UPDATE tconfig_os SET `icon_name` = 'mainframe@svg.svg' WHERE `id_os` = 20;
UPDATE tconfig_os SET `icon_name` = 'cluster@svg.svg' WHERE `id_os` = 100;
UPDATE tconfig_os SET `icon_name` = 'linux@os.svg' WHERE `id_os` = 1;
UPDATE tconfig_os SET `icon_name` = 'solaris@os.svg' WHERE `id_os` = 2;
UPDATE tconfig_os SET `icon_name` = 'aix@os.svg' WHERE `id_os` = 3;
UPDATE tconfig_os SET `icon_name` = 'freebsd@os.svg' WHERE `id_os` = 4;
UPDATE tconfig_os SET `icon_name` = 'HP@os.svg' WHERE `id_os` = 5;
UPDATE tconfig_os SET `icon_name` = 'cisco@os.svg' WHERE `id_os` = 7;
UPDATE tconfig_os SET `icon_name` = 'apple@os.svg' WHERE `id_os` = 8;
UPDATE tconfig_os SET `icon_name` = 'windows@os.svg' WHERE `id_os` = 9;
UPDATE tconfig_os SET `icon_name` = 'other-OS@os.svg' WHERE `id_os` = 10;
UPDATE tconfig_os SET `icon_name` = 'network-server@os.svg' WHERE `id_os` = 11;
UPDATE tconfig_os SET `icon_name` = 'network-server@os.svg' WHERE `id_os` = 12;
UPDATE tconfig_os SET `icon_name` = 'network-server@os.svg' WHERE `id_os` = 13;
UPDATE tconfig_os SET `icon_name` = 'embedded@os.svg' WHERE `id_os` = 14;
UPDATE tconfig_os SET `icon_name` = 'android@os.svg' WHERE `id_os` = 15;
UPDATE tconfig_os SET `icon_name` = 'vmware@os.svg' WHERE `id_os` = 16;
UPDATE tconfig_os SET `icon_name` = 'routers@os.svg' WHERE `id_os` = 17;
UPDATE tconfig_os SET `icon_name` = 'switch@os.svg' WHERE `id_os` = 18;
UPDATE tconfig_os SET `icon_name` = 'satellite@os.svg' WHERE `id_os` = 19;
UPDATE tconfig_os SET `icon_name` = 'mainframe@os.svg' WHERE `id_os` = 20;
UPDATE tconfig_os SET `icon_name` = 'cluster@os.svg' WHERE `id_os` = 100;
UPDATE tgrupo SET `icon` = 'servers@groups.svg' WHERE `id_grupo` = 2;
UPDATE tgrupo SET `icon` = 'firewall@groups.svg' WHERE `id_grupo` = 4;

View File

@ -1,17 +1,32 @@
<?php
/**
* OS Builder
*
* @category Os
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 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.
// Load global vars
// Load global vars.
global $config;
check_login();
@ -25,21 +40,48 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user
return;
}
$icons = get_list_os_icons_dir();
echo '<form id="form_setup" method="post">';
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->style[0] = 'font-weight: bolder;';
$table->style[0] = 'width: 15%';
$table->data[0][0] = __('Name:');
$table->data[0][1] = html_print_input_text('name', $name, __('Name'), 20, 30, true);
$table->data[0][1] = html_print_input_text('name', $name, __('Name'), 20, 30, true, false, false, '', 'w250px');
$table->data[1][0] = __('Description');
$table->data[1][1] = html_print_textarea('description', 5, 10, $description, '', true);
$icons = get_list_os_icons_dir();
$table->data[1][1] = html_print_textarea('description', 5, 20, $description, '', true, 'w250px');
$table->data[2][0] = __('Icon');
$table->data[2][1] = html_print_select($icons, 'icon', $icon, 'show_icon_OS();', __('None'), 0, true);
$table->data[2][1] .= ' <span id="icon_image">'.ui_print_os_icon($idOS, false, true).'</span>';
$iconData = [];
$iconData[] = html_print_select(
$icons,
'icon',
$icon,
'show_icon_OS();',
__('None'),
0,
true
);
$iconData[] = html_print_div(
[
'id' => 'icon_image',
'class' => 'inverse_filter main_menu_icon',
'style' => 'margin-left: 10px',
'content' => ui_print_os_icon($idOS, false, true),
],
true
);
$table->data[2][1] = html_print_div(
[
'style' => 'display: flex;align-items: center;',
'content' => implode('', $iconData),
],
true
);
html_print_table($table);
@ -47,9 +89,11 @@ html_print_table($table);
html_print_input_hidden('id_os', $idOS);
html_print_input_hidden('action', $actionHidden);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button($textButton, 'update_button', false, $classButton);
echo '</div>';
html_print_action_buttons(
html_print_submit_button($textButton, 'update_button', false, $classButton, true),
['type' => 'form_action']
);
echo '</form>';
@ -59,18 +103,10 @@ function get_list_os_icons_dir()
$return = [];
$items = scandir($config['homedir'].'/images/os_icons');
$items = scandir($config['homedir'].'/images/');
foreach ($items as $item) {
if (strstr($item, '_small.png') || strstr($item, '_small.gif')
|| strstr($item, '_small.jpg')
) {
continue;
}
if (strstr($item, '.png') || strstr($item, '.gif')
|| strstr($item, '.jpg')
) {
if (strstr($item, '@os.svg')) {
$return[$item] = $item;
}
}
@ -86,7 +122,7 @@ function show_icon_OS() {
var params = [];
params.push("get_image_path=1");
params.push('img_src=images/os_icons/' + $("#icon").val());
params.push('img_src=images/' + $("#icon").val());
params.push("page=include/ajax/skins.ajax");
jQuery.ajax ({
data: params.join ("&"),

View File

@ -1,6 +1,6 @@
<?php
/**
* Os.
* Os List.
*
* @category Os
* @package Pandora FMS
@ -14,7 +14,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Copyright (c) 2005-2023 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
@ -61,7 +61,8 @@ if (is_management_allowed() === false) {
$table = new stdClass();
$table->width = '100%';
// $table->width = '100%';
$table->styleTable = 'margin: 10px 10px 0';
$table->class = 'info_table';
$table->head[0] = '';
@ -102,7 +103,7 @@ if ($osList === false) {
$table->data = [];
foreach ($osList as $os) {
$data = [];
$data[] = ui_print_os_icon($os['id_os'], false, true);
$data[] = html_print_div(['class' => 'main_menu_icon', 'content' => ui_print_os_icon($os['id_os'], false, true)], true);
$data[] = $os['id_os'];
if ($is_management_allowed === true) {
if (is_metaconsole() === true) {
@ -119,11 +120,20 @@ foreach ($osList as $os) {
if ($is_management_allowed === true) {
$table->cellclass[][4] = 'table_action_buttons';
if ($os['id_os'] > 16) {
if (is_metaconsole()) {
$data[] = '<a href="index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&action=delete&tab2=list&id_os='.$os['id_os'].'">'.html_print_image('images/cross.png', true).'</a>';
if (is_metaconsole() === true) {
$hrefDelete = 'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&action=delete&tab2=list&id_os='.$os['id_os'];
} else {
$data[] = '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&action=delete&tab=list&id_os='.$os['id_os'].'">'.html_print_image('images/cross.png', true, ['class' => 'invert_filter']).'</a>';
$hrefDelete = 'index.php?sec=gsetup&sec2=godmode/setup/os&action=delete&tab=list&id_os='.$os['id_os'];
}
$data[] = html_print_anchor(
[
'href' => $hrefDelete,
'class' => 'inverse_filter main_menu_icon',
'content' => html_print_image('images/delete.svg', true),
],
true
);
} else {
// The original icons of pandora don't delete.
$data[] = '';
@ -134,7 +144,6 @@ foreach ($osList as $os) {
}
if (isset($data) === true) {
ui_pagination($count_osList, ui_get_url_refresh(['message' => false]), $offset);
html_print_table($table);
ui_pagination($count_osList, ui_get_url_refresh(['message' => false]), $offset, 0, false, 'offset', true, 'pagination-bottom');
} else {

View File

@ -71,7 +71,7 @@ if ($is_management_allowed === true) {
case 'edit':
$actionHidden = 'update';
$textButton = __('Update');
$classButton = 'class="sub upd"';
$classButton = ['icon' => 'wand'];
break;
case 'save':
@ -93,7 +93,7 @@ if ($is_management_allowed === true) {
$tab = 'builder';
$actionHidden = 'save';
$textButton = __('Create');
$classButton = 'class="sub next"';
$classButton = ['icon' => 'wand'];
} else {
$tab = 'list';
$message = 1;
@ -140,7 +140,7 @@ if ($is_management_allowed === true) {
$actionHidden = 'update';
$textButton = __('Update');
$classButton = 'class="sub upd"';
$classButton = ['icon' => 'wand'];
if (is_metaconsole() === true) {
header('Location:'.$config['homeurl'].'index.php?sec=advanced&sec2=advanced/component_management&tab=os_manage&tab2='.$tab.'&message='.$message);
} else {
@ -175,7 +175,7 @@ if ($is_management_allowed === true) {
case 'new':
$actionHidden = 'save';
$textButton = __('Create');
$classButton = 'class="sub next"';
$classButton = ['icon' => 'next'];
break;
}
}
@ -184,11 +184,11 @@ $buttons = [];
$buttons['list'] = [
'active' => false,
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=list">'.html_print_image(
'images/list.png',
'images/logs@svg.svg',
true,
[
'title' => __('List OS'),
'class' => 'invert_filter',
'class' => 'invert_filter main_menu_icon',
]
).'</a>',
];
@ -196,11 +196,11 @@ if ($is_management_allowed === true) {
$buttons['builder'] = [
'active' => false,
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&tab=builder">'.html_print_image(
'images/builder.png',
'images/edit.svg',
true,
[
'title' => __('Builder OS'),
'class' => 'invert_filter',
'class' => 'invert_filter main_menu_icon',
]
).'</a>',
];

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 985 B

After

Width:  |  Height:  |  Size: 985 B

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 594 B

After

Width:  |  Height:  |  Size: 594 B

View File

@ -168,6 +168,7 @@ a#qr_code_agent_view {
.agent_description {
height: 126px;
}
/*
.agent_custom_id {
padding-bottom: 0.7em;
padding-top: 0.5em;
@ -176,6 +177,7 @@ a#qr_code_agent_view {
border: 1px solid #ccc;
}
*/
#safe_mode_module {
margin-top: 0.6em;
}

View File

@ -272,7 +272,7 @@ $searchForm .= '</form>';
ui_toggle(
$searchForm,
__('Filter'),
'<span class="subsection_header_title">'.__('Filters').'</span>',
'filter_form'
);

View File

@ -155,26 +155,26 @@ UNLOCK TABLES;
LOCK TABLES `tconfig_os` WRITE;
INSERT INTO `tconfig_os` (`id_os`, `name`, `description`, `icon_name`, `previous_name`) VALUES
(1,'Linux','Linux: All versions','linux@svg.svg', ''),
(2,'Solaris','Sun Solaris','solaris@svg.svg', ''),
(3,'AIX','IBM AIX','aix@svg.svg', ''),
(4,'BSD','OpenBSD, FreeBSD and Others','freebsd@svg.svg', ''),
(5,'HP-UX','HP-UX Unix OS','HP@svg.svg', ''),
(7,'Cisco','CISCO IOS','cisco@svg.svg', ''),
(8,'MacOS','MAC OS','apple@svg.svg', ''),
(9,'Windows','Microsoft Windows OS','windows@svg.svg', ''),
(10,'Other','Other SO','other-OS@svg.svg', ''),
(11,'Network','Network Agent','network-server@svg.svg', ''),
(12,'Web Server','Web Server/Application','network-server@svg.svg', ''),
(13,'Sensor','Hardware Agent (Sensor)','network-server@svg.svg', ''),
(14,'Embedded','Embedded device running an agent','embedded@svg.svg', ''),
(15,'Android','Android agent','android@svg.svg', ''),
(16, 'VMware', 'VMware Architecture', 'vmware@svg.svg', ''),
(17, 'Router', 'Generic router', 'routers@svg.svg', ''),
(18, 'Switch', 'Generic switch', 'switch@svg.svg', ''),
(19, 'Satellite', 'Satellite agent', 'satellite@svg.svg', ''),
(20, 'Mainframe', 'Mainframe agent', 'mainframe@svg.svg', ''),
(100, 'Cluster', 'Cluster agent', 'cluster@svg.svg', '');
(1,'Linux','Linux: All versions','linux@os.svg', ''),
(2,'Solaris','Sun Solaris','solaris@os.svg', ''),
(3,'AIX','IBM AIX','aix@os.svg', ''),
(4,'BSD','OpenBSD, FreeBSD and Others','freebsd@os.svg', ''),
(5,'HP-UX','HP-UX Unix OS','HP@os.svg', ''),
(7,'Cisco','CISCO IOS','cisco@os.svg', ''),
(8,'MacOS','MAC OS','apple@os.svg', ''),
(9,'Windows','Microsoft Windows OS','windows@os.svg', ''),
(10,'Other','Other SO','other-OS@os.svg', ''),
(11,'Network','Network Agent','network-server@os.svg', ''),
(12,'Web Server','Web Server/Application','network-server@os.svg', ''),
(13,'Sensor','Hardware Agent (Sensor)','network-server@os.svg', ''),
(14,'Embedded','Embedded device running an agent','embedded@os.svg', ''),
(15,'Android','Android agent','android@os.svg', ''),
(16, 'VMware', 'VMware Architecture', 'vmware@os.svg', ''),
(17, 'Router', 'Generic router', 'routers@os.svg', ''),
(18, 'Switch', 'Generic switch', 'switch@os.svg', ''),
(19, 'Satellite', 'Satellite agent', 'satellite@os.svg', ''),
(20, 'Mainframe', 'Mainframe agent', 'mainframe@os.svg', ''),
(100, 'Cluster', 'Cluster agent', 'cluster@os.svg', '');
UNLOCK TABLES;