Added the os icons to the os tree

This commit is contained in:
Alejandro Gallardo Escobar 2015-01-02 12:37:19 +01:00
parent 5da9fd8210
commit 13ce624339
2 changed files with 18 additions and 7 deletions

View File

@ -81,6 +81,7 @@ class Tree {
$list_os = os_get_os(); $list_os = os_get_os();
// Transform the os array to use the item id as key
if (!empty($list_os)) { if (!empty($list_os)) {
$list_os_aux = array(); $list_os_aux = array();
foreach ($list_os as $os) { foreach ($list_os as $os) {
@ -125,7 +126,7 @@ class Tree {
$this->processModule($module); $this->processModule($module);
// Module group // OS item
if ($actual_os_root['id'] === (int)$value['id_os']) { if ($actual_os_root['id'] === (int)$value['id_os']) {
// Agent // Agent
if (empty($actual_agent) || $actual_agent['id'] !== (int)$value['id_agente']) { if (empty($actual_agent) || $actual_agent['id'] !== (int)$value['id_agente']) {
@ -151,6 +152,7 @@ class Tree {
$actual_os_root['counters'][$actual_agent['status']]++; $actual_os_root['counters'][$actual_agent['status']]++;
} }
else { else {
// Add the module to the agent
$actual_agent['children'][] = $module; $actual_agent['children'][] = $module;
} }
} }
@ -163,13 +165,14 @@ class Tree {
$nodes[] = $actual_os_root; $nodes[] = $actual_os_root;
} }
// Create new module group // Create new os item
$actual_os_root = array(); $actual_os_root = array();
$actual_os_root['id'] = (int) $value['id_os']; $actual_os_root['id'] = (int) $value['id_os'];
$actual_os_root['type'] = $this->type;
if (isset($list_os[$actual_os_root['id']])) { if (isset($list_os[$actual_os_root['id']])) {
$actual_os_root['name'] = $list_os[$actual_os_root['id']]['name']; $actual_os_root['name'] = $list_os[$actual_os_root['id']]['name'];
$actual_os_root['icon'] = $list_os[$actual_os_root['id']]['icon']; $actual_os_root['icon'] = $list_os[$actual_os_root['id']]['icon_name'];
} }
else { else {
$actual_os_root['name'] = __('Other'); $actual_os_root['name'] = __('Other');
@ -204,9 +207,9 @@ class Tree {
$actual_os_root['counters'][$actual_agent['status']]++; $actual_os_root['counters'][$actual_agent['status']]++;
} }
} }
// If there is an agent and a module group open and not saved // If there is an agent and an os item opened and not saved
if ($actual_os_root['id'] !== null) { if ($actual_os_root['id'] !== null) {
// Add the last agent to the module group // Add the last agent to the os item
$actual_os_root['children'][] = $actual_agent; $actual_os_root['children'][] = $actual_agent;
// Add the last os to the branch // Add the last os to the branch
$nodes[] = $actual_os_root; $nodes[] = $actual_os_root;
@ -709,6 +712,7 @@ class Tree {
// Create new module group // Create new module group
$actual_module_group_root = array(); $actual_module_group_root = array();
$actual_module_group_root['id'] = (int) $module['id_module_group']; $actual_module_group_root['id'] = (int) $module['id_module_group'];
$actual_module_group_root['type'] = $this->type;
if (isset($module_groups[$module['id_module_group']])) { if (isset($module_groups[$module['id_module_group']])) {
$actual_module_group_root['name'] = $module_groups[$module['id_module_group']]; $actual_module_group_root['name'] = $module_groups[$module['id_module_group']];
@ -734,7 +738,7 @@ class Tree {
$actual_module_group_root['counters'][$actual_agent['status']]++; $actual_module_group_root['counters'][$actual_agent['status']]++;
} }
} }
// If there is an agent and a module group open and not saved // If there is an agent and a module group opened and not saved
if ($actual_module_group_root['id'] !== null) { if ($actual_module_group_root['id'] !== null) {
// Add the last agent to the module group // Add the last agent to the module group
$actual_module_group_root['children'][] = $actual_agent; $actual_module_group_root['children'][] = $actual_agent;

View File

@ -301,7 +301,7 @@ TreeController = {
case 'group': case 'group':
if (typeof element.icon != 'undefined' && element.icon.length > 0) { if (typeof element.icon != 'undefined' && element.icon.length > 0) {
$content.append('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '') $content.append('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/groups_small/'+element.icon+'" />') +'images/groups_small/'+element.icon+'" /> ')
} }
$content.append(element.name); $content.append(element.name);
break; break;
@ -311,6 +311,13 @@ TreeController = {
case 'module': case 'module':
$content.append(element.name); $content.append(element.name);
break; break;
case 'os':
if (typeof element.icon != 'undefined' && element.icon.length > 0) {
$content.append('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/os_icons/'+element.icon+'" /> ')
}
$content.append(element.name);
break;
default: default:
$content.append(element.name); $content.append(element.name);
break; break;