Services TreeView

This commit is contained in:
Jose Gonzalez 2023-03-06 13:32:21 +01:00
parent 3c1c14576e
commit e33a9bc3e4
5 changed files with 67 additions and 23 deletions

View File

@ -222,22 +222,30 @@ class TreeService extends Tree
switch ($status) {
case SERVICE_STATUS_NORMAL:
$processed_items[$row['id']]['statusImageHTML'] = '<img src="'.ui_get_full_url('images/status_sets/default/agent_ok_ball.png').'" data-title="NORMAL status." data-use_title_for_force_title="1" class="forced_title" alt="NORMAL status." />';
$serviceStatusLine = COL_NORMAL;
break;
case SERVICE_STATUS_CRITICAL:
$processed_items[$row['id']]['statusImageHTML'] = '<img src="'.ui_get_full_url('images/status_sets/default/agent_critical_ball.png').'" data-title="CRITICAL status." data-use_title_for_force_title="1" class="forced_title" alt="CRITICAL status." />';
$serviceStatusLine = COL_CRITICAL;
break;
case SERVICE_STATUS_WARNING:
$processed_items[$row['id']]['statusImageHTML'] = '<img src="'.ui_get_full_url('images/status_sets/default/agent_warning_ball.png').'" data-title="WARNING status." data-use_title_for_force_title="1" class="forced_title" alt="WARNING status." />';
$serviceStatusLine = COL_WARNING;
break;
case SERVICE_STATUS_UNKNOWN:
default:
$processed_items[$row['id']]['statusImageHTML'] = '<img src="'.ui_get_full_url('images/status_sets/default/agent_no_data_ball.png').'" data-title="UNKNOWN status." data-use_title_for_force_title="1" class="forced_title" alt="UNKNOWN status." />';
$serviceStatusLine = COL_UNKNOWN;
break;
}
$processed_items[$row['id']]['statusImageHTML'] = html_print_div(
[
'class' => 'node-service-status',
'style' => 'background-color: '.$serviceStatusLine,
],
true
);
}
$this->tree = $processed_items;
@ -510,14 +518,11 @@ class TreeService extends Tree
$tmp['eventAgent'] = $item->module()->id_agente();
$tmp['disabled'] = $item->module()->disabled();
$html = '<img src="';
$html .= ui_get_full_url(
'/images/status_sets/default/'.$item->module()->lastStatusImage()
$html = html_print_div(
[ 'style' => 'width:7px;background-color: '.$item->module()->lastStatusColor() ],
true
);
$html .= '" data-title="'.$title;
$html .= '" data-use_title_for_force_title="1" ';
$html .= 'class="forced_title" alt="';
$html .= $item->module()->lastStatusTitle().'" />';
$tmp['statusImageHTML'] = $html;
$tmp = array_merge(
$tmp,

View File

@ -702,7 +702,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
// Events graph toggle.
$eventsGraph = html_print_div(
[
'class' => 'graphic_agents',
'style' => 'height: 150px;',
'content' => graph_graphic_agentevents(
$id_agente,
'500px;',
@ -732,7 +732,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
);
if ($config['agentaccess']) {
$access_graph = '<div class="w100p height_130px center">';
$access_graph = '<div style="height: 150px;" class="w100p center">';
$access_graph .= graphic_agentaccess(
$id_agente,
SECONDS_1DAY,

View File

@ -980,7 +980,7 @@ var TreeController = {
break;
case "module":
$content.addClass("module");
//console.log(element); $statusImage.addClass("node-status");
// Status image
if (
typeof element.statusImageHTML != "undefined" &&

View File

@ -512,6 +512,37 @@ class Module extends Entity
}
/**
* Return the color to image representing last status.
*
* @return string Hexadecimal notation color.
*/
public function lastStatusColor()
{
switch ($this->lastStatus()) {
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_BAD:
return COL_CRITICAL;
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_WARNING:
return COL_WARNING;
case AGENT_MODULE_STATUS_UNKNOWN:
return COL_UNKNOWN;
case AGENT_MODULE_STATUS_NO_DATA:
case AGENT_MODULE_STATUS_NOT_INIT:
return COL_NOTINIT;
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case AGENT_MODULE_STATUS_NORMAL:
default:
return COL_NORMAL;
}
}
/**
* Return path to image representing last status.
*

View File

@ -55,11 +55,11 @@
position: absolute;
border-radius: 8px;
width: 18px;
height: 18px;
top: 6px;
height: 20px;
top: 5px;
margin: 0;
padding: 0;
left: 13px;
left: 6px;
}
.tree-node .node-name {
position: relative;
@ -236,18 +236,20 @@ div.tree-node span {
}
.node-content.module:not(.module-only-caption) .module-name {
margin-left: 3em;
margin-left: 1.5em;
font-weight: normal;
}
/*.node-content.module.module-only-caption:not(:first-of-type) {
margin-top: 8px;
}*/
.tree-node > .node-content > .status_balls,
.tree-node > .node-content > .status_small_balls {
width: 6px;
border-radius: 4px;
}
.tree-node > .node-content > .module-name-alias {
font-size: 14px;
font-weight: normal;
top: 4px;
margin-left: 3.3em;
margin-left: 1.1em;
}
.tree-node > .node-content.module-only-caption > .module-name-alias {
@ -306,7 +308,7 @@ div.tree-node span {
.tree-node > .node-content > .tree-node-counters > .tree-node-counter {
font-weight: bold;
font-size: 0.9em;
font-size: 1em;
cursor: default;
}
@ -326,6 +328,12 @@ div#tree-controller-recipient {
/*margin-left: 3px;*/
}
.tree-node .node-service div.node-service-status {
width: 6px;
height: 20px;
margin-left: 10px;
border-radius: 5px;
}
.tree-node .disabled {
filter: opacity(0.3);
}