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) { switch ($status) {
case SERVICE_STATUS_NORMAL: 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; break;
case SERVICE_STATUS_CRITICAL: 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; break;
case SERVICE_STATUS_WARNING: 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; break;
case SERVICE_STATUS_UNKNOWN: case SERVICE_STATUS_UNKNOWN:
default: 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; break;
} }
$processed_items[$row['id']]['statusImageHTML'] = html_print_div(
[
'class' => 'node-service-status',
'style' => 'background-color: '.$serviceStatusLine,
],
true
);
} }
$this->tree = $processed_items; $this->tree = $processed_items;
@ -510,14 +518,11 @@ class TreeService extends Tree
$tmp['eventAgent'] = $item->module()->id_agente(); $tmp['eventAgent'] = $item->module()->id_agente();
$tmp['disabled'] = $item->module()->disabled(); $tmp['disabled'] = $item->module()->disabled();
$html = '<img src="'; $html = html_print_div(
$html .= ui_get_full_url( [ 'style' => 'width:7px;background-color: '.$item->module()->lastStatusColor() ],
'/images/status_sets/default/'.$item->module()->lastStatusImage() 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['statusImageHTML'] = $html;
$tmp = array_merge( $tmp = array_merge(
$tmp, $tmp,

View File

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

View File

@ -980,7 +980,7 @@ var TreeController = {
break; break;
case "module": case "module":
$content.addClass("module"); $content.addClass("module");
//console.log(element); $statusImage.addClass("node-status");
// Status image // Status image
if ( if (
typeof element.statusImageHTML != "undefined" && 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. * Return path to image representing last status.
* *

View File

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