fixed errors VC
This commit is contained in:
parent
4a1801bc50
commit
5900e7ba4a
|
@ -280,7 +280,14 @@ class Item extends CachedModel
|
|||
private static function extractAclGroupId(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id_group', 'aclGroupId', 'idGroup']),
|
||||
static::issetInArray(
|
||||
$data,
|
||||
[
|
||||
'element_group',
|
||||
'aclGroupId',
|
||||
'elementGroup',
|
||||
]
|
||||
),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
@ -1378,9 +1385,9 @@ class Item extends CachedModel
|
|||
$result['id_metaconsole'] = $id_metaconsole;
|
||||
}
|
||||
|
||||
$id_group = static::extractAclGroupId($data);
|
||||
if ($id_group !== null) {
|
||||
$result['id_group'] = $id_group;
|
||||
$element_group = static::extractAclGroupId($data);
|
||||
if ($element_group !== null) {
|
||||
$result['element_group'] = $element_group;
|
||||
}
|
||||
|
||||
$label_position = static::notEmptyStringOr(
|
||||
|
@ -2071,6 +2078,8 @@ class Item extends CachedModel
|
|||
*/
|
||||
public function getDefaultGeneralValues(array $values): array
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Default values.
|
||||
if (isset($values['x']) === false) {
|
||||
$values['x'] = 0;
|
||||
|
@ -2096,6 +2105,10 @@ class Item extends CachedModel
|
|||
$values['isOnTop'] = false;
|
||||
}
|
||||
|
||||
if (isset($values['cacheExpiration']) === false) {
|
||||
$values['cacheExpiration'] = $config['vc_default_cache_expiration'];
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,25 @@ final class Box extends Item
|
|||
{
|
||||
|
||||
|
||||
/**
|
||||
* Extract the "Fill transparent" switch value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return mixed If the statistics should be shown or not.
|
||||
*/
|
||||
private static function getFillTransparent(array $data)
|
||||
{
|
||||
return static::issetInArray(
|
||||
$data,
|
||||
[
|
||||
'fillTransparent',
|
||||
'show_statistics',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a valid representation of a record in database.
|
||||
*
|
||||
|
@ -40,7 +59,7 @@ final class Box extends Item
|
|||
$return['fill_color'] = $fill_color;
|
||||
}
|
||||
|
||||
$fill_transparent = static::extractFillTransparent($data);
|
||||
$fill_transparent = static::getFillTransparent($data);
|
||||
if ($fill_transparent !== null) {
|
||||
$return['show_statistics'] = static::parseBool($fill_transparent);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,41 @@ final class Group extends Item
|
|||
protected static $indexCacheByUser = true;
|
||||
|
||||
|
||||
/**
|
||||
* Get the "show statistics" switch value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return mixed If the statistics should be shown or not.
|
||||
*/
|
||||
private static function getShowStatistics(array $data)
|
||||
{
|
||||
return static::issetInArray(
|
||||
$data,
|
||||
[
|
||||
'showStatistics',
|
||||
'show_statistics',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a group Id (for ACL) value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Valid identifier of a group.
|
||||
*/
|
||||
private static function getGroupId(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id_group', 'groupId']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a valid representation of a record in database.
|
||||
*
|
||||
|
@ -47,7 +82,12 @@ final class Group extends Item
|
|||
{
|
||||
$return = parent::encode($data);
|
||||
|
||||
$show_statistics = static::extractShowStatistics($data);
|
||||
$id_group = static::getGroupId($data);
|
||||
if ($id_group !== null) {
|
||||
$return['id_group'] = $id_group;
|
||||
}
|
||||
|
||||
$show_statistics = static::getShowStatistics($data);
|
||||
if ($show_statistics !== null) {
|
||||
$return['show_statistics'] = static::parseBool($show_statistics);
|
||||
}
|
||||
|
@ -243,19 +283,26 @@ final class Group extends Item
|
|||
$numNormal = $agentsOk[0]['total'];
|
||||
|
||||
$numTotal = ($numCritical + $numWarning + $numUnknown + $numNormal);
|
||||
|
||||
$agentStats = [
|
||||
'critical' => ($numCritical / $numTotal * 100),
|
||||
'warning' => ($numWarning / $numTotal * 100),
|
||||
'normal' => ($numNormal / $numTotal * 100),
|
||||
'unknown' => ($numUnknown / $numTotal * 100),
|
||||
'critical' => 0,
|
||||
'warning' => 0,
|
||||
'normal' => 0,
|
||||
'unknown' => 0,
|
||||
];
|
||||
if ($numTotal !== 0) {
|
||||
$agentStats = [
|
||||
'critical' => ($numCritical / $numTotal * 100),
|
||||
'warning' => ($numWarning / $numTotal * 100),
|
||||
'normal' => ($numNormal / $numTotal * 100),
|
||||
'unknown' => ($numUnknown / $numTotal * 100),
|
||||
];
|
||||
}
|
||||
|
||||
$groupName = \groups_get_name($groupId, true);
|
||||
$data['html'] = static::printStatsTable(
|
||||
$groupName,
|
||||
$agentStats,
|
||||
(int) $data['width'],
|
||||
(int) $data['height']
|
||||
$agentStats
|
||||
);
|
||||
} else {
|
||||
if (\is_metaconsole()) {
|
||||
|
@ -328,100 +375,56 @@ final class Group extends Item
|
|||
/**
|
||||
* HTML representation for the agent stats of a group.
|
||||
*
|
||||
* @param string $groupName Group name.
|
||||
* @param array $agentStats Data structure with the agent statistics.
|
||||
* @param integer $width Width.
|
||||
* @param integer $height Height.
|
||||
* @param string $groupName Group name.
|
||||
* @param array $agentStats Data structure with the agent statistics.
|
||||
*
|
||||
* @return string HTML representation.
|
||||
*/
|
||||
private static function printStatsTable(
|
||||
string $groupName,
|
||||
array $agentStats,
|
||||
int $width=520,
|
||||
int $height=80
|
||||
array $agentStats
|
||||
): string {
|
||||
$width = ($width > 0) ? $width : 520;
|
||||
$height = ($height > 0) ? $height : 80;
|
||||
|
||||
$tableStyle = \join(
|
||||
[
|
||||
'width:'.$width.'px;',
|
||||
'height:'.$height.'px;',
|
||||
'text-align:center;',
|
||||
]
|
||||
);
|
||||
$headStyle = \join(
|
||||
[
|
||||
'text-align:center;',
|
||||
'background-color:#9d9ea0;',
|
||||
'color:black;',
|
||||
'font-weight:bold;',
|
||||
]
|
||||
);
|
||||
$valueStyle = \join(
|
||||
[
|
||||
'margin-left: 2%;',
|
||||
'color: #FFF;',
|
||||
'font-size: 12px;',
|
||||
'display: inline;',
|
||||
'background-color: #e63c52;',
|
||||
'position: relative;',
|
||||
'height: 80%;',
|
||||
'width: 9.4%;',
|
||||
'height: 80%;',
|
||||
'border-radius: 2px;',
|
||||
'text-align: center;',
|
||||
'padding: 5px;',
|
||||
]
|
||||
);
|
||||
$nameStyle = \join(
|
||||
[
|
||||
'background-color: white;',
|
||||
'color: black;',
|
||||
'font-size: 12px;',
|
||||
'display: inline;',
|
||||
'display: inline;',
|
||||
'position:relative;',
|
||||
'width: 9.4%;',
|
||||
'height: 80%;',
|
||||
'border-radius: 2px;',
|
||||
'text-align: center;',
|
||||
'padding: 5px;',
|
||||
]
|
||||
);
|
||||
|
||||
$html = '<table class="databox" style="'.$tableStyle.'">';
|
||||
$html .= '<tr style="height:10%;">';
|
||||
$html .= '<th style="'.$headStyle.'">'.$groupName.'</th>';
|
||||
$html .= '</tr>';
|
||||
$html .= '<tr style="background-color:whitesmoke;height:90%;">';
|
||||
$html .= '<td>';
|
||||
$critical = \number_format($agentStats['critical'], 2).'%';
|
||||
$warning = \number_format($agentStats['warning'], 2).'%';
|
||||
$normal = \number_format($agentStats['normal'], 2).'%';
|
||||
$unknown = \number_format($agentStats['unknown'], 2).'%';
|
||||
|
||||
$html = '<div class="group-container">';
|
||||
$html .= '<div class="group-item-title">';
|
||||
$html .= $groupName;
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="group-item-info">';
|
||||
// Critical.
|
||||
$html .= '<div style="'.$valueStyle.'background-color: #e63c52;">';
|
||||
$html .= \number_format($agentStats['critical'], 2).'%';
|
||||
$html .= '<div class="group-item-info-container">';
|
||||
$html .= '<div class="value-style" style="background-color: #e63c52;">';
|
||||
$html .= $critical;
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="name-style">'.__('Critical').'</div>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div style="'.$nameStyle.'">'.__('Critical').'</div>';
|
||||
// Warning.
|
||||
$html .= '<div style="'.$valueStyle.'background-color: #f8db3f;">';
|
||||
$html .= \number_format($agentStats['warning'], 2).'%';
|
||||
$html .= '<div class="group-item-info-container">';
|
||||
$html .= '<div class="value-style" style="background-color: #f8db3f;">';
|
||||
$html .= $warning;
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="name-style">'.__('Warning').'</div>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div style="'.$nameStyle.'">'.__('Warning').'</div>';
|
||||
// Normal.
|
||||
$html .= '<div style="'.$valueStyle.'background-color: #84b83c;">';
|
||||
$html .= \number_format($agentStats['normal'], 2).'%';
|
||||
$html .= '<div class="group-item-info-container">';
|
||||
$html .= '<div class="value-style" style="background-color: #84b83c;">';
|
||||
$html .= $normal;
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="name-style">'.__('Normal').'</div>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div style="'.$nameStyle.'">'.__('Normal').'</div>';
|
||||
// Unknown.
|
||||
$html .= '<div style="'.$valueStyle.'background-color: #9d9ea0;">';
|
||||
$html .= \number_format($agentStats['unknown'], 2).'%';
|
||||
$html .= '<div class="group-item-info-container">';
|
||||
$html .= '<div class="value-style" style="background-color: #9d9ea0;">';
|
||||
$html .= $unknown;
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="name-style">'.__('Unknown').'</div>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div style="'.$nameStyle.'">'.__('Unknown').'</div>';
|
||||
|
||||
$html .= '</td>';
|
||||
$html .= '</tr>';
|
||||
$html .= '</table>';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
@ -523,6 +526,19 @@ final class Group extends Item
|
|||
],
|
||||
];
|
||||
|
||||
// Group.
|
||||
$inputs[] = [
|
||||
'label' => __('Group'),
|
||||
'arguments' => [
|
||||
'type' => 'select_groups',
|
||||
'name' => 'groupId',
|
||||
'returnAllGroup' => true,
|
||||
'privilege' => $values['access'],
|
||||
'selected' => $values['groupId'],
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
// Show statistics.
|
||||
$inputs[] = [
|
||||
'label' => __('Show statistics'),
|
||||
|
|
|
@ -35,6 +35,19 @@ final class ModuleGraph extends Item
|
|||
protected static $useHtmlOutput = true;
|
||||
|
||||
|
||||
/**
|
||||
* Extract the "show Legend" switch value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return mixed If the statistics should be shown or not.
|
||||
*/
|
||||
private static function getShowLegend(array $data)
|
||||
{
|
||||
return static::issetInArray($data, ['showLegend', 'show_statistics']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a valid representation of a record in database.
|
||||
*
|
||||
|
@ -53,7 +66,7 @@ final class ModuleGraph extends Item
|
|||
$return['type_graph'] = $type_graph;
|
||||
}
|
||||
|
||||
$show_legend = static::extractShowLegend($data);
|
||||
$show_legend = static::getShowLegend($data);
|
||||
if ($show_legend !== null) {
|
||||
$return['show_statistics'] = static::parseBool($show_legend);
|
||||
}
|
||||
|
|
|
@ -402,6 +402,7 @@ class View extends \HTML
|
|||
'showStatistics',
|
||||
0
|
||||
);
|
||||
$data['groupId'] = \get_parameter('groupId');
|
||||
break;
|
||||
|
||||
case BOX_ITEM:
|
||||
|
|
|
@ -219,7 +219,7 @@
|
|||
flex-wrap: wrap;
|
||||
-webkit-box-align: start;
|
||||
-ms-flex-align: start;
|
||||
align-items: start;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.div-ranges-input-group > div {
|
||||
|
@ -268,7 +268,7 @@
|
|||
flex-wrap: wrap;
|
||||
-webkit-box-align: start;
|
||||
-ms-flex-align: start;
|
||||
align-items: start;
|
||||
align-items: flex-start;
|
||||
-webkit-box-pack: justify;
|
||||
-ms-flex-pack: justify;
|
||||
justify-content: space-between;
|
||||
|
@ -565,6 +565,122 @@ li#li-timeZone-item > select:not(:first-child) {
|
|||
background-color: #ededed;
|
||||
}
|
||||
|
||||
/*style item group show statistic*/
|
||||
.group-container {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-box-direction: normal;
|
||||
-ms-flex-direction: column;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.group-container .group-item-title {
|
||||
width: 100%;
|
||||
height: 30%;
|
||||
background-color: #9d9ea0;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-orient: horizontal;
|
||||
-webkit-box-direction: normal;
|
||||
-ms-flex-direction: row;
|
||||
flex-direction: row;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: center;
|
||||
-ms-flex-pack: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.group-container .group-item-info {
|
||||
width: 100%;
|
||||
height: 70%;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-orient: horizontal;
|
||||
-webkit-box-direction: normal;
|
||||
-ms-flex-direction: row;
|
||||
flex-direction: row;
|
||||
-ms-flex-wrap: wrap;
|
||||
flex-wrap: wrap;
|
||||
padding: 2%;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.group-container .group-item-info .group-item-info-container {
|
||||
-webkit-box-flex: 1;
|
||||
-ms-flex: 1 1 100px;
|
||||
flex: 1 1 100px;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-orient: horizontal;
|
||||
-webkit-box-direction: normal;
|
||||
-ms-flex-direction: row;
|
||||
flex-direction: row;
|
||||
border-radius: 2px;
|
||||
height: 100%;
|
||||
max-height: 50px;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.group-container .group-item-info .group-item-info-container .value-style {
|
||||
-webkit-box-flex: 1;
|
||||
-ms-flex: 1;
|
||||
flex: 1;
|
||||
color: #fff;
|
||||
font-size: 100%;
|
||||
padding: 5px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-orient: horizontal;
|
||||
-webkit-box-direction: normal;
|
||||
-ms-flex-direction: row;
|
||||
flex-direction: row;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: center;
|
||||
-ms-flex-pack: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.group-container .group-item-info .group-item-info-container .name-style {
|
||||
-webkit-box-flex: 1;
|
||||
-ms-flex: 1;
|
||||
flex: 1;
|
||||
background-color: white;
|
||||
color: black;
|
||||
font-size: 100%;
|
||||
padding: 5px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-orient: horizontal;
|
||||
-webkit-box-direction: normal;
|
||||
-ms-flex-direction: row;
|
||||
flex-direction: row;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: center;
|
||||
-ms-flex-pack: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* Styles for the solid icons */
|
||||
|
||||
.fa {
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -114,6 +114,7 @@ export default class Group extends Item<GroupProps> {
|
|||
element.style.backgroundPosition = "center";
|
||||
} else if (this.props.showStatistics && this.props.html != null) {
|
||||
// Stats table.
|
||||
element.style.backgroundImage = "none";
|
||||
element.innerHTML = this.props.html;
|
||||
}
|
||||
|
||||
|
@ -134,6 +135,7 @@ export default class Group extends Item<GroupProps> {
|
|||
element.innerHTML = "";
|
||||
} else if (this.props.showStatistics && this.props.html != null) {
|
||||
// Stats table.
|
||||
element.style.backgroundImage = "none";
|
||||
element.innerHTML = this.props.html;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
align-items: start;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.div-ranges-input-group > div {
|
||||
|
@ -193,7 +193,7 @@
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
align-items: start;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
height: 70px;
|
||||
}
|
||||
|
@ -441,3 +441,68 @@ li#li-timeZone-item > select:not(:first-child) {
|
|||
.discovery.modal li#div-textarea-label table tbody td.mceIframeContainer {
|
||||
background-color: #ededed;
|
||||
}
|
||||
|
||||
/*style item group show statistic*/
|
||||
.group-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.group-container .group-item-title {
|
||||
width: 100%;
|
||||
height: 30%;
|
||||
background-color: #9d9ea0;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.group-container .group-item-info {
|
||||
width: 100%;
|
||||
height: 70%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
padding: 2%;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.group-container .group-item-info .group-item-info-container {
|
||||
flex: 1 1 100px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
border-radius: 2px;
|
||||
height: 100%;
|
||||
max-height: 50px;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.group-container .group-item-info .group-item-info-container .value-style {
|
||||
flex: 1;
|
||||
color: #fff;
|
||||
font-size: 100%;
|
||||
padding: 5px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.group-container .group-item-info .group-item-info-container .name-style {
|
||||
flex: 1;
|
||||
background-color: white;
|
||||
color: black;
|
||||
font-size: 100%;
|
||||
padding: 5px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue