Fix server type icon definition

This commit is contained in:
Jose Gonzalez 2022-12-19 16:38:47 +01:00
parent 977c358fa0
commit b0997850f4
7 changed files with 81 additions and 158 deletions

View File

@ -1002,7 +1002,7 @@ foreach ($modules as $module) {
// Module type (by server type ).
$data[2] = '';
if ($module['id_modulo'] > 0) {
$data[2] = servers_show_type($module['id_modulo']);
$data[2] = ui_print_servertype_icon((int) $module['id_modulo']);
}
$module_status = db_get_row(

View File

@ -798,55 +798,7 @@ foreach ($components as $component) {
$data[0] = io_safe_output($component['name']);
}
switch ($component['id_modulo']) {
case MODULE_NETWORK:
$data[1] .= html_print_image(
'images/op_network.png',
true,
[
'title' => __('Network module'),
'class' => 'invert_filter',
]
);
break;
case MODULE_WMI:
$data[1] .= html_print_image(
'images/wmi.png',
true,
[
'title' => __('WMI module'),
'class' => 'invert_filter',
]
);
break;
case MODULE_PLUGIN:
$data[1] .= html_print_image(
'images/plugin.png',
true,
[
'title' => __('Plug-in module'),
'class' => 'invert_filter',
]
);
break;
case MODULE_WIZARD:
$data[1] .= html_print_image(
'images/wand.png',
true,
[
'title' => __('Wizard module'),
'class' => 'invert_filter',
]
);
break;
default:
// Not possible.
break;
}
$data[1] .= ui_print_servertype_icon((int) $component['id_modulo']);
$data[2] = ui_print_moduletype_icon($component['type'], true);
$data[3] = "<span class='font_8px'>".mb_strimwidth(io_safe_output($component['description']), 0, 60, '...').'</span>';

View File

@ -1102,7 +1102,7 @@ if (check_login()) {
}
}
$data[2] = servers_show_type($module['id_modulo']).'&nbsp;';
$data[2] = ui_print_servertype_icon((int) $module['id_modulo']);
if (check_acl($config['id_user'], $id_grupo, 'AW')
&& $cluster_view === false

View File

@ -670,8 +670,8 @@ class Tree
$module['statusImageHTML'] = ui_print_status_image($statusType, htmlspecialchars($statusTitle), true);
// HTML of the server type image
$module['serverTypeHTML'] = servers_show_type($module['server_type']);
// HTML of the server type image.
$module['serverTypeHTML'] = ui_print_servertype_icon((int) $module['server_type']);
// Link to the Module graph.
// ACL.

View File

@ -1152,108 +1152,6 @@ function servers_check_remote_config($server_name)
}
/**
* Return a string containing image tag for a given target id (server).
* TODO: Make this print_servertype_icon and move to functions_ui.php.
* Make XHTML compatible. Make string translatable.
*
* @param integer $id Server type id.
*
* @deprecated Use print_servertype_icon instead.
*
* @return string Fully formatted IMG HTML tag with icon.
*/
function servers_show_type($id)
{
global $config;
switch ($id) {
case 1:
$return = html_print_image(
'images/database.png',
true,
[
'title' => get_product_name().' Data server',
'class' => 'invert_filter',
]
);
break;
case 2:
$return = html_print_image(
'images/network.png',
true,
[
'title' => get_product_name().' Network server',
'class' => 'invert_filter',
]
);
break;
case 4:
$return = html_print_image(
'images/plugin.png',
true,
[
'title' => get_product_name().' Plugin server',
'class' => 'invert_filter',
]
);
break;
case 5:
$return = html_print_image(
'images/chart_bar.png',
true,
[
'title' => get_product_name().' Prediction server',
'class' => 'invert_filter',
]
);
break;
case 6:
$return = html_print_image(
'images/wmi.png',
true,
[
'title' => get_product_name().' WMI server',
'class' => 'invert_filter',
]
);
break;
case 7:
$return = html_print_image(
'images/server_web.png',
true,
[
'title' => get_product_name().' WEB server',
'class' => 'invert_filter',
]
);
break;
case 8:
$return = html_print_image(
'images/module-wux.png',
true,
[
'title' => get_product_name().' WUX server',
'class' => 'invert_filter',
]
);
break;
default:
$return = '--';
break;
}
return $return;
}
/**
* Get the numbers of servers up.
*

View File

@ -6829,3 +6829,76 @@ function ui_print_spinner(string $text='Loading', bool $return=false)
echo $output;
}
}
/**
* Return a formed server type icon.
*
* @param integer $id Id of server type.
*
* @return string.
*/
function ui_print_servertype_icon(int $id)
{
switch ($id) {
case MODULE_DATA:
$title = __('Data server');
$image = 'images/data-server@svg.svg';
break;
case MODULE_NETWORK:
$title = __('Network server');
$image = 'images/network-server@svg.svg';
break;
case MODULE_PLUGIN:
$title = __('Plugin server');
$image = 'images/plugins@svg.svg';
break;
case MODULE_PREDICTION:
$title = __('Prediction server');
$image = 'images/prediction@svg.svg';
break;
case MODULE_WMI:
$title = __('WMI server');
$image = 'images/WMI@svg.svg';
break;
case MODULE_WEB:
$title = __('WEB server');
$image = 'images/server-web@svg.svg';
break;
case MODULE_WUX:
$title = __('WUX server');
$image = 'images/wux@svg.svg';
break;
case MODULE_WIZARD:
$title = __('Wizard Module');
$image = 'images/wizard@svg.svg';
break;
default:
$title = '';
$image = '';
break;
}
if (empty($title) === true && empty($image) === true) {
$return = '--';
} else {
$return = html_print_image(
$image,
true,
[
'title' => sprintf('%s %s', get_product_name(), $title),
'class' => 'invert_filter main_menu_icon',
]
);
}
return $return;
}

View File

@ -1552,7 +1552,7 @@ if (!empty($result)) {
}
if (in_array('server_type', $show_fields) || is_metaconsole()) {
$data[4] = servers_show_type($row['id_modulo']);
$data[4] = ui_print_servertype_icon((int) $row['id_modulo']);
}
@ -1574,8 +1574,8 @@ if (!empty($result)) {
}
}
if (in_array('server_type', $show_fields) || is_metaconsole()) {
$data[4] = servers_show_type($row['id_modulo']);
if (in_array('server_type', $show_fields) === true || is_metaconsole() === true) {
$data[4] = ui_print_servertype_icon((int) $row['id_modulo']);
}