mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Fixed errors VC
This commit is contained in:
parent
121ac2e80e
commit
c3ae3f08a7
@ -3896,7 +3896,7 @@ function graph_graphic_agentevents($id_agent, $width, $height, $period=0, $homeu
|
|||||||
* @param string homeurl
|
* @param string homeurl
|
||||||
* @param bool return or echo the result
|
* @param bool return or echo the result
|
||||||
*/
|
*/
|
||||||
function graph_graphic_moduleevents($id_agent, $id_module, $width, $height, $period=0, $homeurl, $return=false)
|
function graph_graphic_moduleevents($id_agent, $id_module, $width, $height, $period=0, $homeurl, $return=false, $ttl=1)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
global $graphic_type;
|
global $graphic_type;
|
||||||
@ -3972,7 +3972,7 @@ function graph_graphic_moduleevents($id_agent, $id_module, $width, $height, $per
|
|||||||
$out = flot_slicesbar_graph(
|
$out = flot_slicesbar_graph(
|
||||||
$data,
|
$data,
|
||||||
$period,
|
$period,
|
||||||
100,
|
$width,
|
||||||
$height,
|
$height,
|
||||||
$full_legend,
|
$full_legend,
|
||||||
$colors,
|
$colors,
|
||||||
@ -3985,7 +3985,8 @@ function graph_graphic_moduleevents($id_agent, $id_module, $width, $height, $per
|
|||||||
$id_agent,
|
$id_agent,
|
||||||
[],
|
[],
|
||||||
true,
|
true,
|
||||||
1
|
$ttl,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($return) {
|
if ($return) {
|
||||||
|
@ -802,9 +802,9 @@ function pandoraFlotSlicebar(
|
|||||||
full_legend = full_legend.split(separator);
|
full_legend = full_legend.split(separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
var font_size = parseInt(font_size);
|
font_size = parseInt(font_size);
|
||||||
if (font != undefined)
|
if (font != undefined)
|
||||||
var font = font
|
font = font
|
||||||
.split("/")
|
.split("/")
|
||||||
.pop()
|
.pop()
|
||||||
.split(".")
|
.split(".")
|
||||||
@ -884,7 +884,7 @@ function pandoraFlotSlicebar(
|
|||||||
|
|
||||||
$.plot($("#" + graph_id), datas, options);
|
$.plot($("#" + graph_id), datas, options);
|
||||||
|
|
||||||
if (match == null) {
|
if (match == null && not_interactive == 0) {
|
||||||
// Events
|
// Events
|
||||||
$("#" + graph_id).bind("plothover", function(event, pos, item) {
|
$("#" + graph_id).bind("plothover", function(event, pos, item) {
|
||||||
if (item) {
|
if (item) {
|
||||||
|
@ -143,7 +143,7 @@ function flot_area_graph(
|
|||||||
// Parent layer.
|
// Parent layer.
|
||||||
$return = "<div class='parent_graph' style='width: ".($params['width']).';'.$background_style.$padding_vconsole."'>";
|
$return = "<div class='parent_graph' style='width: ".($params['width']).';'.$background_style.$padding_vconsole."'>";
|
||||||
|
|
||||||
if (empty($params['title']) === false) {
|
if ($params['title'] === true && empty($params['title']) === false) {
|
||||||
$return .= '<p style="text-align:center;">'.$params['title'].'</p>';
|
$return .= '<p style="text-align:center;">'.$params['title'].'</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -777,15 +777,17 @@ function flot_slicesbar_graph(
|
|||||||
// Get a unique identifier to graph
|
// Get a unique identifier to graph
|
||||||
$graph_id = uniqid('graph_');
|
$graph_id = uniqid('graph_');
|
||||||
|
|
||||||
$height = ((int) $height + 15);
|
|
||||||
|
|
||||||
// Set some containers to legend, graph, timestamp tooltip, etc.
|
// Set some containers to legend, graph, timestamp tooltip, etc.
|
||||||
if ($stat_win) {
|
if ($stat_win) {
|
||||||
|
$height = ((int) $height + 15);
|
||||||
$return = "<div id='$graph_id' class='noresizevc graph $adapt_key' style='width: ".$width.'%; height: '.$height."px; display: inline-block;'></div>";
|
$return = "<div id='$graph_id' class='noresizevc graph $adapt_key' style='width: ".$width.'%; height: '.$height."px; display: inline-block;'></div>";
|
||||||
} else {
|
} else {
|
||||||
if ($widgets) {
|
if ($widgets) {
|
||||||
|
$width = ((int) $width - 10);
|
||||||
|
$height = ((int) $height - 10);
|
||||||
$return = "<div id='$graph_id' class='noresizevc graph $adapt_key' style='width: ".$width.'px; height: '.$height."px;'></div>";
|
$return = "<div id='$graph_id' class='noresizevc graph $adapt_key' style='width: ".$width.'px; height: '.$height."px;'></div>";
|
||||||
} else {
|
} else {
|
||||||
|
$height = ((int) $height + 15);
|
||||||
$return = "<div id='$graph_id' class='noresizevc graph $adapt_key' style='width: ".$width.'%; height: '.$height."px;'></div>";
|
$return = "<div id='$graph_id' class='noresizevc graph $adapt_key' style='width: ".$width.'%; height: '.$height."px;'></div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,10 +355,7 @@ class Item extends CachedModel
|
|||||||
*/
|
*/
|
||||||
private static function extractLabel(array $data)
|
private static function extractLabel(array $data)
|
||||||
{
|
{
|
||||||
return static::notEmptyStringOr(
|
return static::issetInArray($data, ['label']);
|
||||||
static::issetInArray($data, ['label']),
|
|
||||||
null
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -413,29 +410,6 @@ class Item extends CachedModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract a custom id graph value.
|
|
||||||
*
|
|
||||||
* @param array $data Unknown input data structure.
|
|
||||||
*
|
|
||||||
* @return integer Valid identifier of an agent.
|
|
||||||
*/
|
|
||||||
private static function extractIdCustomGraph(array $data)
|
|
||||||
{
|
|
||||||
return static::parseIntOr(
|
|
||||||
static::issetInArray(
|
|
||||||
$data,
|
|
||||||
[
|
|
||||||
'id_custom_graph',
|
|
||||||
'idCustomGraph',
|
|
||||||
'customGraphId',
|
|
||||||
]
|
|
||||||
),
|
|
||||||
null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract the cache expiration value.
|
* Extract the cache expiration value.
|
||||||
*
|
*
|
||||||
@ -1294,12 +1268,12 @@ class Item extends CachedModel
|
|||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
$id = static::getId($data);
|
$id = static::getId($data);
|
||||||
if ($id) {
|
if (isset($id) === true) {
|
||||||
$result['id'] = $id;
|
$result['id'] = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id_layout = static::getIdLayout($data);
|
$id_layout = static::getIdLayout($data);
|
||||||
if ($id_layout) {
|
if (isset($id_layout) === true) {
|
||||||
$result['id_layout'] = $id_layout;
|
$result['id_layout'] = $id_layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1334,6 +1308,7 @@ class Item extends CachedModel
|
|||||||
$result['label'] = $label;
|
$result['label'] = $label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO change.
|
||||||
$image = static::getImageSrc($data);
|
$image = static::getImageSrc($data);
|
||||||
if ($image !== null) {
|
if ($image !== null) {
|
||||||
$result['image'] = $image;
|
$result['image'] = $image;
|
||||||
@ -1347,6 +1322,7 @@ class Item extends CachedModel
|
|||||||
$result['type'] = $type;
|
$result['type'] = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO change.
|
||||||
$period = static::parseIntOr(
|
$period = static::parseIntOr(
|
||||||
static::issetInArray($data, ['period', 'maxTime']),
|
static::issetInArray($data, ['period', 'maxTime']),
|
||||||
null
|
null
|
||||||
@ -1407,21 +1383,12 @@ class Item extends CachedModel
|
|||||||
$result['id_group'] = $id_group;
|
$result['id_group'] = $id_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id_custom_graph = static::extractIdCustomGraph($data);
|
// TODO change.
|
||||||
if ($id_custom_graph !== null) {
|
|
||||||
$result['id_custom_graph'] = $id_custom_graph;
|
|
||||||
}
|
|
||||||
|
|
||||||
$border_width = static::getBorderWidth($data);
|
$border_width = static::getBorderWidth($data);
|
||||||
if ($border_width !== null) {
|
if ($border_width !== null) {
|
||||||
$result['border_width'] = $border_width;
|
$result['border_width'] = $border_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
$type_graph = static::getTypeGraph($data);
|
|
||||||
if ($type_graph !== null) {
|
|
||||||
$result['type_graph'] = $type_graph;
|
|
||||||
}
|
|
||||||
|
|
||||||
$label_position = static::notEmptyStringOr(
|
$label_position = static::notEmptyStringOr(
|
||||||
static::issetInArray($data, ['labelPosition', 'label_position']),
|
static::issetInArray($data, ['labelPosition', 'label_position']),
|
||||||
null
|
null
|
||||||
@ -1430,27 +1397,18 @@ class Item extends CachedModel
|
|||||||
$result['label_position'] = $label_position;
|
$result['label_position'] = $label_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO change.
|
||||||
$border_color = static::getBorderColor($data);
|
$border_color = static::getBorderColor($data);
|
||||||
if ($border_color !== null) {
|
if ($border_color !== null) {
|
||||||
$result['border_color'] = $border_color;
|
$result['border_color'] = $border_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO change.
|
||||||
$fill_color = static::getFillColor($data);
|
$fill_color = static::getFillColor($data);
|
||||||
if ($fill_color !== null) {
|
if ($fill_color !== null) {
|
||||||
$result['fill_color'] = $fill_color;
|
$result['fill_color'] = $fill_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
$show_statistics = static::issetInArray(
|
|
||||||
$data,
|
|
||||||
[
|
|
||||||
'showStatistics',
|
|
||||||
'show_statistics',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
if ($show_statistics !== null) {
|
|
||||||
$result['show_statistics'] = static::parseBool($show_statistics);
|
|
||||||
}
|
|
||||||
|
|
||||||
$linked_layout_node_id = static::parseIntOr(
|
$linked_layout_node_id = static::parseIntOr(
|
||||||
static::issetInArray(
|
static::issetInArray(
|
||||||
$data,
|
$data,
|
||||||
@ -1541,6 +1499,7 @@ class Item extends CachedModel
|
|||||||
$result['show_on_top'] = static::parseBool($show_on_top);
|
$result['show_on_top'] = static::parseBool($show_on_top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO change.
|
||||||
$show_last_value = static::notEmptyStringOr(
|
$show_last_value = static::notEmptyStringOr(
|
||||||
static::issetInArray($data, ['showLastValueTooltip']),
|
static::issetInArray($data, ['showLastValueTooltip']),
|
||||||
null
|
null
|
||||||
@ -1685,29 +1644,6 @@ class Item extends CachedModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract a type graph value.
|
|
||||||
*
|
|
||||||
* @param array $data Unknown input data structure.
|
|
||||||
*
|
|
||||||
* @return string One of 'vertical' or 'horizontal'. 'vertical' by default.
|
|
||||||
*/
|
|
||||||
private static function getTypeGraph(array $data)
|
|
||||||
{
|
|
||||||
return static::notEmptyStringOr(
|
|
||||||
static::issetInArray(
|
|
||||||
$data,
|
|
||||||
[
|
|
||||||
'typeGraph',
|
|
||||||
'type_graph',
|
|
||||||
'graphType',
|
|
||||||
]
|
|
||||||
),
|
|
||||||
null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract a border color value.
|
* Extract a border color value.
|
||||||
*
|
*
|
||||||
@ -2125,6 +2061,44 @@ class Item extends CachedModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default values.
|
||||||
|
*
|
||||||
|
* @param array $values Array values.
|
||||||
|
*
|
||||||
|
* @return array Array with default values.
|
||||||
|
*/
|
||||||
|
public function getDefaultGeneralValues(array $values): array
|
||||||
|
{
|
||||||
|
// Default values.
|
||||||
|
if (isset($values['x']) === false) {
|
||||||
|
$values['x'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['y']) === false) {
|
||||||
|
$values['y'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['parentId']) === false) {
|
||||||
|
$values['parentId'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['aclGroupId']) === false) {
|
||||||
|
$values['aclGroupId'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['isLinkEnabled']) === false) {
|
||||||
|
$values['isLinkEnabled'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['isOnTop']) === false) {
|
||||||
|
$values['isOnTop'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List images for Vc Icons.
|
* List images for Vc Icons.
|
||||||
*
|
*
|
||||||
|
@ -27,6 +27,55 @@ final class BarsGraph extends Item
|
|||||||
protected static $useHtmlOutput = true;
|
protected static $useHtmlOutput = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a valid representation of a record in database.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing a record in database.
|
||||||
|
*
|
||||||
|
* @overrides Item->encode.
|
||||||
|
*/
|
||||||
|
protected function encode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::encode($data);
|
||||||
|
|
||||||
|
$id_custom_graph = static::extractIdCustomGraph($data);
|
||||||
|
if ($id_custom_graph !== null) {
|
||||||
|
$return['id_custom_graph'] = $id_custom_graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
$type_graph = static::getTypeGraph($data);
|
||||||
|
if ($type_graph !== null) {
|
||||||
|
$return['type_graph'] = $type_graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a graph type value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string 'line' or 'area'. 'line' by default.
|
||||||
|
*/
|
||||||
|
private static function extractGraphType(array $data): string
|
||||||
|
{
|
||||||
|
$value = static::issetInArray($data, ['graphType', 'type_graph']);
|
||||||
|
|
||||||
|
switch ($value) {
|
||||||
|
case 'line':
|
||||||
|
case 'area':
|
||||||
|
return $value;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'line';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a valid representation of the model.
|
* Returns a valid representation of the model.
|
||||||
*
|
*
|
||||||
@ -349,6 +398,9 @@ final class BarsGraph extends Item
|
|||||||
*/
|
*/
|
||||||
public static function getFormInputs(array $values): array
|
public static function getFormInputs(array $values): array
|
||||||
{
|
{
|
||||||
|
// Default values.
|
||||||
|
$values = static::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
// Retrieve global - common inputs.
|
// Retrieve global - common inputs.
|
||||||
$inputs = Item::getFormInputs($values);
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
@ -444,4 +496,31 @@ final class BarsGraph extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default values.
|
||||||
|
*
|
||||||
|
* @param array $values Array values.
|
||||||
|
*
|
||||||
|
* @return array Array with default values.
|
||||||
|
*
|
||||||
|
* @overrides Item->getDefaultGeneralValues.
|
||||||
|
*/
|
||||||
|
public function getDefaultGeneralValues(array $values): array
|
||||||
|
{
|
||||||
|
// Retrieve global - common inputs.
|
||||||
|
$values = parent::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
|
// Default values.
|
||||||
|
if (isset($values['width']) === false) {
|
||||||
|
$values['width'] = 250;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['height']) === false) {
|
||||||
|
$values['height'] = 250;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -93,13 +93,101 @@ final class Box extends Item
|
|||||||
*/
|
*/
|
||||||
public static function getFormInputs(array $values): array
|
public static function getFormInputs(array $values): array
|
||||||
{
|
{
|
||||||
// Retrieve global - common inputs.
|
// Default values.
|
||||||
$inputs = Item::getFormInputs($values);
|
$values = static::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
if (is_array($inputs) !== true) {
|
if ($values['tabSelected'] === 'general') {
|
||||||
throw new Exception(
|
$inputs[] = [
|
||||||
'[Box]::getFormInputs parent class return is not an array'
|
'arguments' => [
|
||||||
);
|
'type' => 'hidden',
|
||||||
|
'name' => 'tabGeneral',
|
||||||
|
'value' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Size.
|
||||||
|
$inputs[] = [
|
||||||
|
'block_id' => 'size-item',
|
||||||
|
'class' => 'flex-row flex-start w100p',
|
||||||
|
'direct' => 1,
|
||||||
|
'block_content' => [
|
||||||
|
[
|
||||||
|
'label' => __('Size'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => __('width'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'width',
|
||||||
|
'type' => 'number',
|
||||||
|
'value' => $values['width'],
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => __('height'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'height',
|
||||||
|
'type' => 'number',
|
||||||
|
'value' => $values['height'],
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Position.
|
||||||
|
$inputs[] = [
|
||||||
|
'block_id' => 'position-item',
|
||||||
|
'class' => 'flex-row flex-start w100p',
|
||||||
|
'direct' => 1,
|
||||||
|
'block_content' => [
|
||||||
|
[
|
||||||
|
'label' => __('Position'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => __('X'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'x',
|
||||||
|
'type' => 'number',
|
||||||
|
'value' => $values['x'],
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => __('Y'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'y',
|
||||||
|
'type' => 'number',
|
||||||
|
'value' => $values['y'],
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Show on top.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Show on top'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'isOnTop',
|
||||||
|
'id' => 'isOnTop',
|
||||||
|
'type' => 'switch',
|
||||||
|
'value' => $values['isOnTop'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default specific values.
|
||||||
|
if (isset($values['borderColor']) === false) {
|
||||||
|
$values['borderColor'] = '#000000';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['borderWidth']) === false) {
|
||||||
|
$values['borderWidth'] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['fillColor']) === false) {
|
||||||
|
$values['fillColor'] = '#ffffff';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($values['tabSelected'] === 'specific') {
|
if ($values['tabSelected'] === 'specific') {
|
||||||
@ -143,4 +231,31 @@ final class Box extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default values.
|
||||||
|
*
|
||||||
|
* @param array $values Array values.
|
||||||
|
*
|
||||||
|
* @return array Array with default values.
|
||||||
|
*
|
||||||
|
* @overrides Item->getDefaultGeneralValues.
|
||||||
|
*/
|
||||||
|
public function getDefaultGeneralValues(array $values): array
|
||||||
|
{
|
||||||
|
// Retrieve global - common inputs.
|
||||||
|
$values = parent::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
|
// Default values.
|
||||||
|
if (isset($values['width']) === false) {
|
||||||
|
$values['width'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['height']) === false) {
|
||||||
|
$values['height'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -252,6 +252,9 @@ final class Clock extends Item
|
|||||||
*/
|
*/
|
||||||
public static function getFormInputs(array $values): array
|
public static function getFormInputs(array $values): array
|
||||||
{
|
{
|
||||||
|
// Default values.
|
||||||
|
$values = static::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
// Retrieve global - common inputs.
|
// Retrieve global - common inputs.
|
||||||
$inputs = Item::getFormInputs($values);
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
@ -384,4 +387,31 @@ final class Clock extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default values.
|
||||||
|
*
|
||||||
|
* @param array $values Array values.
|
||||||
|
*
|
||||||
|
* @return array Array with default values.
|
||||||
|
*
|
||||||
|
* @overrides Item->getDefaultGeneralValues.
|
||||||
|
*/
|
||||||
|
public function getDefaultGeneralValues(array $values): array
|
||||||
|
{
|
||||||
|
// Retrieve global - common inputs.
|
||||||
|
$values = parent::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
|
// Default values.
|
||||||
|
if (isset($values['width']) === false) {
|
||||||
|
$values['width'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['height']) === false) {
|
||||||
|
$values['height'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -154,22 +154,12 @@ final class DonutGraph extends Item
|
|||||||
\metaconsole_restore_db();
|
\metaconsole_restore_db();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$width = (int) $data['width'];
|
||||||
|
$height = (int) $data['height'];
|
||||||
|
|
||||||
if ($isString === true) {
|
if ($isString === true) {
|
||||||
$graphData = \get_donut_module_data($moduleId);
|
$graphData = \get_donut_module_data($moduleId);
|
||||||
|
|
||||||
$width = (int) $data['width'];
|
|
||||||
$height = (int) $data['height'];
|
|
||||||
|
|
||||||
// Default width.
|
|
||||||
if ($width <= 0) {
|
|
||||||
$width = 300;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default height.
|
|
||||||
if ($height <= 0) {
|
|
||||||
$height = 300;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data['html'] = \d3_donut_graph(
|
$data['html'] = \d3_donut_graph(
|
||||||
(int) $data['id'],
|
(int) $data['id'],
|
||||||
$width,
|
$width,
|
||||||
@ -183,7 +173,8 @@ final class DonutGraph extends Item
|
|||||||
$src = '../../'.$src;
|
$src = '../../'.$src;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['html'] = '<img src="'.$src.'">';
|
$style = 'width:'.$width.'px; height:'.$height.'px;';
|
||||||
|
$data['html'] = '<img src="'.$src.'" style="'.$style.'">';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
@ -201,6 +192,9 @@ final class DonutGraph extends Item
|
|||||||
*/
|
*/
|
||||||
public static function getFormInputs(array $values): array
|
public static function getFormInputs(array $values): array
|
||||||
{
|
{
|
||||||
|
// Default values.
|
||||||
|
$values = static::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
// Retrieve global - common inputs.
|
// Retrieve global - common inputs.
|
||||||
$inputs = Item::getFormInputs($values);
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
@ -268,4 +262,31 @@ final class DonutGraph extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default values.
|
||||||
|
*
|
||||||
|
* @param array $values Array values.
|
||||||
|
*
|
||||||
|
* @return array Array with default values.
|
||||||
|
*
|
||||||
|
* @overrides Item->getDefaultGeneralValues.
|
||||||
|
*/
|
||||||
|
public function getDefaultGeneralValues(array $values): array
|
||||||
|
{
|
||||||
|
// Retrieve global - common inputs.
|
||||||
|
$values = parent::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
|
// Default values.
|
||||||
|
if (isset($values['width']) === false) {
|
||||||
|
$values['width'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['height']) === false) {
|
||||||
|
$values['height'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -102,12 +102,6 @@ final class EventsHistory extends Item
|
|||||||
throw new \InvalidArgumentException('missing agent Id');
|
throw new \InvalidArgumentException('missing agent Id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default size.
|
|
||||||
if ($data['width'] == 0 || $data['height'] == 0) {
|
|
||||||
$data['width'] = 500;
|
|
||||||
$data['height'] = 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use the same HTML output as the old VC.
|
// Use the same HTML output as the old VC.
|
||||||
$html = \graph_graphic_moduleevents(
|
$html = \graph_graphic_moduleevents(
|
||||||
$agentId,
|
$agentId,
|
||||||
@ -116,7 +110,8 @@ final class EventsHistory extends Item
|
|||||||
(int) $data['height'],
|
(int) $data['height'],
|
||||||
static::extractMaxTime($data),
|
static::extractMaxTime($data),
|
||||||
'',
|
'',
|
||||||
true
|
true,
|
||||||
|
2
|
||||||
);
|
);
|
||||||
|
|
||||||
$data['html'] = $html;
|
$data['html'] = $html;
|
||||||
@ -167,6 +162,9 @@ final class EventsHistory extends Item
|
|||||||
*/
|
*/
|
||||||
public static function getFormInputs(array $values): array
|
public static function getFormInputs(array $values): array
|
||||||
{
|
{
|
||||||
|
// Default values.
|
||||||
|
$values = static::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
// Retrieve global - common inputs.
|
// Retrieve global - common inputs.
|
||||||
$inputs = Item::getFormInputs($values);
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
@ -243,4 +241,31 @@ final class EventsHistory extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default values.
|
||||||
|
*
|
||||||
|
* @param array $values Array values.
|
||||||
|
*
|
||||||
|
* @return array Array with default values.
|
||||||
|
*
|
||||||
|
* @overrides Item->getDefaultGeneralValues.
|
||||||
|
*/
|
||||||
|
public function getDefaultGeneralValues(array $values): array
|
||||||
|
{
|
||||||
|
// Retrieve global - common inputs.
|
||||||
|
$values = parent::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
|
// Default values.
|
||||||
|
if (isset($values['width']) === false) {
|
||||||
|
$values['width'] = 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['height']) === false) {
|
||||||
|
$values['height'] = 70;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,28 @@ final class Group extends Item
|
|||||||
protected static $indexCacheByUser = true;
|
protected static $indexCacheByUser = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a valid representation of a record in database.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing a record in database.
|
||||||
|
*
|
||||||
|
* @overrides Item->encode.
|
||||||
|
*/
|
||||||
|
protected function encode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::encode($data);
|
||||||
|
|
||||||
|
$show_statistics = static::extractShowStatistics($data);
|
||||||
|
if ($show_statistics !== null) {
|
||||||
|
$return['show_statistics'] = static::parseBool($show_statistics);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a valid representation of the model.
|
* Returns a valid representation of the model.
|
||||||
*
|
*
|
||||||
@ -458,6 +480,9 @@ final class Group extends Item
|
|||||||
*/
|
*/
|
||||||
public static function getFormInputs(array $values): array
|
public static function getFormInputs(array $values): array
|
||||||
{
|
{
|
||||||
|
// Default values.
|
||||||
|
$values = static::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
// Retrieve global - common inputs.
|
// Retrieve global - common inputs.
|
||||||
$inputs = Item::getFormInputs($values);
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
|
@ -140,6 +140,9 @@ final class Icon extends Item
|
|||||||
*/
|
*/
|
||||||
public static function getFormInputs(array $values): array
|
public static function getFormInputs(array $values): array
|
||||||
{
|
{
|
||||||
|
// Default values.
|
||||||
|
$values = static::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
// Retrieve global - common inputs.
|
// Retrieve global - common inputs.
|
||||||
$inputs = Item::getFormInputs($values);
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
|
@ -61,4 +61,58 @@ final class Label extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates inputs for form (specific).
|
||||||
|
*
|
||||||
|
* @param array $values Default values.
|
||||||
|
*
|
||||||
|
* @return array Of inputs.
|
||||||
|
*
|
||||||
|
* @throws Exception On error.
|
||||||
|
*/
|
||||||
|
public static function getFormInputs(array $values): array
|
||||||
|
{
|
||||||
|
// Default values.
|
||||||
|
$values = static::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
|
// Retrieve global - common inputs.
|
||||||
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
|
if (is_array($inputs) !== true) {
|
||||||
|
throw new Exception(
|
||||||
|
'[Label]::getFormInputs parent class return is not an array'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $inputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default values.
|
||||||
|
*
|
||||||
|
* @param array $values Array values.
|
||||||
|
*
|
||||||
|
* @return array Array with default values.
|
||||||
|
*
|
||||||
|
* @overrides Item->getDefaultGeneralValues.
|
||||||
|
*/
|
||||||
|
public function getDefaultGeneralValues(array $values): array
|
||||||
|
{
|
||||||
|
// Retrieve global - common inputs.
|
||||||
|
$values = parent::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
|
// Default values.
|
||||||
|
if (isset($values['width']) === false) {
|
||||||
|
$values['width'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['height']) === false) {
|
||||||
|
$values['height'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,80 @@ final class ModuleGraph extends Item
|
|||||||
protected static $useHtmlOutput = true;
|
protected static $useHtmlOutput = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a valid representation of a record in database.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing a record in database.
|
||||||
|
*
|
||||||
|
* @overrides Item->encode.
|
||||||
|
*/
|
||||||
|
protected function encode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::encode($data);
|
||||||
|
|
||||||
|
$type_graph = static::getTypeGraph($data);
|
||||||
|
if ($type_graph !== null) {
|
||||||
|
$return['type_graph'] = $type_graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
$show_legend = static::extractShowLegend($data);
|
||||||
|
|
||||||
|
if ($show_legend !== null) {
|
||||||
|
$return['show_statistics'] = static::parseBool($show_legend);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a custom id graph value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return integer Valid identifier of an agent.
|
||||||
|
*/
|
||||||
|
private static function extractIdCustomGraph(array $data)
|
||||||
|
{
|
||||||
|
return static::parseIntOr(
|
||||||
|
static::issetInArray(
|
||||||
|
$data,
|
||||||
|
[
|
||||||
|
'id_custom_graph',
|
||||||
|
'idCustomGraph',
|
||||||
|
'customGraphId',
|
||||||
|
]
|
||||||
|
),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a type graph value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return string One of 'vertical' or 'horizontal'. 'vertical' by default.
|
||||||
|
*/
|
||||||
|
private static function getTypeGraph(array $data)
|
||||||
|
{
|
||||||
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray(
|
||||||
|
$data,
|
||||||
|
[
|
||||||
|
'typeGraph',
|
||||||
|
'type_graph',
|
||||||
|
'graphType',
|
||||||
|
]
|
||||||
|
),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a valid representation of the model.
|
* Returns a valid representation of the model.
|
||||||
*
|
*
|
||||||
@ -50,6 +124,7 @@ final class ModuleGraph extends Item
|
|||||||
$return['type'] = MODULE_GRAPH;
|
$return['type'] = MODULE_GRAPH;
|
||||||
$return['backgroundType'] = static::extractBackgroundType($data);
|
$return['backgroundType'] = static::extractBackgroundType($data);
|
||||||
$return['period'] = static::extractPeriod($data);
|
$return['period'] = static::extractPeriod($data);
|
||||||
|
$return['showLegend'] = static::extractShowLegend($data);
|
||||||
|
|
||||||
$customGraphId = static::extractCustomGraphId($data);
|
$customGraphId = static::extractCustomGraphId($data);
|
||||||
|
|
||||||
@ -68,7 +143,8 @@ final class ModuleGraph extends Item
|
|||||||
*
|
*
|
||||||
* @param array $data Unknown input data structure.
|
* @param array $data Unknown input data structure.
|
||||||
*
|
*
|
||||||
* @return string 'transparent', 'white' or 'black'. 'transparent' by default.
|
* @return string 'transparent', 'white' or 'black'.
|
||||||
|
* 'transparent' by default.
|
||||||
*/
|
*/
|
||||||
private static function extractBackgroundType(array $data): string
|
private static function extractBackgroundType(array $data): string
|
||||||
{
|
{
|
||||||
@ -102,6 +178,21 @@ final class ModuleGraph extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the "show Legend" switch value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return boolean If the statistics should be shown or not.
|
||||||
|
*/
|
||||||
|
private static function extractShowLegend(array $data): bool
|
||||||
|
{
|
||||||
|
return static::parseBool(
|
||||||
|
static::issetInArray($data, ['showLegend', 'show_statistics'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract a custom graph Id value.
|
* Extract a custom graph Id value.
|
||||||
*
|
*
|
||||||
@ -172,6 +263,7 @@ final class ModuleGraph extends Item
|
|||||||
|
|
||||||
$backgroundType = static::extractBackgroundType($data);
|
$backgroundType = static::extractBackgroundType($data);
|
||||||
$period = static::extractPeriod($data);
|
$period = static::extractPeriod($data);
|
||||||
|
$showLegend = static::extractShowLegend($data);
|
||||||
$customGraphId = static::extractCustomGraphId($data);
|
$customGraphId = static::extractCustomGraphId($data);
|
||||||
$graphType = static::extractGraphType($data);
|
$graphType = static::extractGraphType($data);
|
||||||
$linkedModule = static::extractLinkedModule($data);
|
$linkedModule = static::extractLinkedModule($data);
|
||||||
@ -208,14 +300,6 @@ final class ModuleGraph extends Item
|
|||||||
$width = (int) $data['width'];
|
$width = (int) $data['width'];
|
||||||
$height = (int) $data['height'];
|
$height = (int) $data['height'];
|
||||||
|
|
||||||
if ($width === 0) {
|
|
||||||
$width = 440;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($height === 0) {
|
|
||||||
$height = 220;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom graph.
|
// Custom graph.
|
||||||
if (empty($customGraphId) === false) {
|
if (empty($customGraphId) === false) {
|
||||||
$customGraph = \db_get_row('tgraph', 'id_graph', $customGraphId);
|
$customGraph = \db_get_row('tgraph', 'id_graph', $customGraphId);
|
||||||
@ -231,6 +315,8 @@ final class ModuleGraph extends Item
|
|||||||
'vconsole' => true,
|
'vconsole' => true,
|
||||||
'backgroundColor' => $backgroundType,
|
'backgroundColor' => $backgroundType,
|
||||||
'return_img_base_64' => true,
|
'return_img_base_64' => true,
|
||||||
|
'show_legend' => $showLegend,
|
||||||
|
'show_title' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
$paramsCombined = [
|
$paramsCombined = [
|
||||||
@ -269,6 +355,8 @@ final class ModuleGraph extends Item
|
|||||||
'type_graph' => $graphType,
|
'type_graph' => $graphType,
|
||||||
'vconsole' => true,
|
'vconsole' => true,
|
||||||
'return_img_base_64' => true,
|
'return_img_base_64' => true,
|
||||||
|
'show_legend' => $showLegend,
|
||||||
|
'show_title' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
$imgbase64 = 'data:image/jpg;base64,';
|
$imgbase64 = 'data:image/jpg;base64,';
|
||||||
@ -323,6 +411,9 @@ final class ModuleGraph extends Item
|
|||||||
*/
|
*/
|
||||||
public static function getFormInputs(array $values): array
|
public static function getFormInputs(array $values): array
|
||||||
{
|
{
|
||||||
|
// Default values.
|
||||||
|
$values = static::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
// Retrieve global - common inputs.
|
// Retrieve global - common inputs.
|
||||||
$inputs = Item::getFormInputs($values);
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
@ -466,6 +557,17 @@ final class ModuleGraph extends Item
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Show legend.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Show legend'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'showLegend',
|
||||||
|
'id' => 'showLegend',
|
||||||
|
'type' => 'switch',
|
||||||
|
'value' => $values['showLegend'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
// Inputs LinkedVisualConsole.
|
// Inputs LinkedVisualConsole.
|
||||||
$inputsLinkedVisualConsole = self::inputsLinkedVisualConsole(
|
$inputsLinkedVisualConsole = self::inputsLinkedVisualConsole(
|
||||||
$values
|
$values
|
||||||
@ -479,4 +581,31 @@ final class ModuleGraph extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default values.
|
||||||
|
*
|
||||||
|
* @param array $values Array values.
|
||||||
|
*
|
||||||
|
* @return array Array with default values.
|
||||||
|
*
|
||||||
|
* @overrides Item->getDefaultGeneralValues.
|
||||||
|
*/
|
||||||
|
public function getDefaultGeneralValues(array $values): array
|
||||||
|
{
|
||||||
|
// Retrieve global - common inputs.
|
||||||
|
$values = parent::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
|
// Default values.
|
||||||
|
if (isset($values['width']) === false) {
|
||||||
|
$values['width'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['height']) === false) {
|
||||||
|
$values['height'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -190,12 +190,12 @@ final class Percentile extends Item
|
|||||||
|
|
||||||
$color = static::encodeColor($data);
|
$color = static::encodeColor($data);
|
||||||
if ($border_color !== null) {
|
if ($border_color !== null) {
|
||||||
$result['border_color'] = $color;
|
$return['border_color'] = $color;
|
||||||
}
|
}
|
||||||
|
|
||||||
$labelColor = static::encodeLabelColor($data);
|
$labelColor = static::encodeLabelColor($data);
|
||||||
if ($labelColor !== null) {
|
if ($labelColor !== null) {
|
||||||
$result['fill_color'] = $labelColor;
|
$return['fill_color'] = $labelColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
@ -435,6 +435,9 @@ final class Percentile extends Item
|
|||||||
*/
|
*/
|
||||||
public static function getFormInputs(array $values): array
|
public static function getFormInputs(array $values): array
|
||||||
{
|
{
|
||||||
|
// Default values.
|
||||||
|
$values = static::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
// Retrieve global - common inputs.
|
// Retrieve global - common inputs.
|
||||||
$inputs = Item::getFormInputs($values);
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
@ -444,6 +447,19 @@ final class Percentile extends Item
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default specific values.
|
||||||
|
if (isset($values['color']) === false) {
|
||||||
|
$values['color'] = '#000000';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['labelColor']) === false) {
|
||||||
|
$values['labelColor'] = '#bcbcbc';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['percentileType']) === false) {
|
||||||
|
$values['percentileType'] = 'circular-progress-bar';
|
||||||
|
}
|
||||||
|
|
||||||
if ($values['tabSelected'] === 'specific') {
|
if ($values['tabSelected'] === 'specific') {
|
||||||
// Type percentile.
|
// Type percentile.
|
||||||
$fields = [
|
$fields = [
|
||||||
@ -467,19 +483,6 @@ final class Percentile extends Item
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
// TODO: QUIT WIDTH FORM GENERAL PAGE.
|
|
||||||
// Diameter.
|
|
||||||
$diameter = (isset($values['width']) === true) ? $values['width'] : 200;
|
|
||||||
$inputs[] = [
|
|
||||||
'label' => __('Diameter'),
|
|
||||||
'arguments' => [
|
|
||||||
'name' => 'width',
|
|
||||||
'type' => 'number',
|
|
||||||
'value' => $diameter,
|
|
||||||
'return' => true,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
// TODO: ADD bbdd.
|
// TODO: ADD bbdd.
|
||||||
// Min Value.
|
// Min Value.
|
||||||
$inputs[] = [
|
$inputs[] = [
|
||||||
@ -591,4 +594,31 @@ final class Percentile extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default values.
|
||||||
|
*
|
||||||
|
* @param array $values Array values.
|
||||||
|
*
|
||||||
|
* @return array Array with default values.
|
||||||
|
*
|
||||||
|
* @overrides Item->getDefaultGeneralValues.
|
||||||
|
*/
|
||||||
|
public function getDefaultGeneralValues(array $values): array
|
||||||
|
{
|
||||||
|
// Retrieve global - common inputs.
|
||||||
|
$values = parent::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
|
// Default values.
|
||||||
|
if (isset($values['width']) === false) {
|
||||||
|
$values['width'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['height']) === false) {
|
||||||
|
$values['height'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -309,6 +309,9 @@ final class SimpleValue extends Item
|
|||||||
*/
|
*/
|
||||||
public static function getFormInputs(array $values): array
|
public static function getFormInputs(array $values): array
|
||||||
{
|
{
|
||||||
|
// Default values.
|
||||||
|
$values = static::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
// Retrieve global - common inputs.
|
// Retrieve global - common inputs.
|
||||||
$inputs = Item::getFormInputs($values);
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
@ -384,4 +387,31 @@ final class SimpleValue extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default values.
|
||||||
|
*
|
||||||
|
* @param array $values Array values.
|
||||||
|
*
|
||||||
|
* @return array Array with default values.
|
||||||
|
*
|
||||||
|
* @overrides Item->getDefaultGeneralValues.
|
||||||
|
*/
|
||||||
|
public function getDefaultGeneralValues(array $values): array
|
||||||
|
{
|
||||||
|
// Retrieve global - common inputs.
|
||||||
|
$values = parent::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
|
// Default values.
|
||||||
|
if (isset($values['width']) === false) {
|
||||||
|
$values['width'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($values['height']) === false) {
|
||||||
|
$values['height'] = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -252,6 +252,9 @@ final class StaticGraph extends Item
|
|||||||
*/
|
*/
|
||||||
public static function getFormInputs(array $values): array
|
public static function getFormInputs(array $values): array
|
||||||
{
|
{
|
||||||
|
// Default values.
|
||||||
|
$values = static::getDefaultGeneralValues($values);
|
||||||
|
|
||||||
// Retrieve global - common inputs.
|
// Retrieve global - common inputs.
|
||||||
$inputs = Item::getFormInputs($values);
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
@ -261,6 +264,11 @@ final class StaticGraph extends Item
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default values.
|
||||||
|
if (isset($values['imageSrc']) === false) {
|
||||||
|
$values['imageSrc'] = 'network';
|
||||||
|
}
|
||||||
|
|
||||||
if ($values['tabSelected'] === 'specific') {
|
if ($values['tabSelected'] === 'specific') {
|
||||||
// List images VC.
|
// List images VC.
|
||||||
if (isset($values['imageSrc']) === false) {
|
if (isset($values['imageSrc']) === false) {
|
||||||
|
@ -78,7 +78,9 @@ class View extends \HTML
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$activetabs = 2;
|
||||||
if ($type === LABEL) {
|
if ($type === LABEL) {
|
||||||
|
$activetabs = 0;
|
||||||
$tabs = [
|
$tabs = [
|
||||||
[
|
[
|
||||||
'name' => __('Label settings'),
|
'name' => __('Label settings'),
|
||||||
@ -92,7 +94,8 @@ class View extends \HTML
|
|||||||
'img' => 'pencil.png',
|
'img' => 'pencil.png',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
} else if ($type === LINE_ITEM || $type === BOX_ITEM) {
|
} else if ($type === LINE_ITEM) {
|
||||||
|
$activetabs = 0;
|
||||||
$tabs = [
|
$tabs = [
|
||||||
[
|
[
|
||||||
'name' => __('Specific settings'),
|
'name' => __('Specific settings'),
|
||||||
@ -101,6 +104,21 @@ class View extends \HTML
|
|||||||
'img' => 'event_responses_col.png',
|
'img' => 'event_responses_col.png',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
} else if ($type === BOX_ITEM) {
|
||||||
|
$activetabs = 1;
|
||||||
|
$tabs = [
|
||||||
|
[
|
||||||
|
'name' => __('General settings'),
|
||||||
|
'id' => 'tab-general',
|
||||||
|
'href' => $url.'&tabSelected=general',
|
||||||
|
'img' => 'pencil.png',
|
||||||
|
],[
|
||||||
|
'name' => __('Specific settings'),
|
||||||
|
'id' => 'tab-specific',
|
||||||
|
'href' => $url.'&tabSelected=specific',
|
||||||
|
'img' => 'event_responses_col.png',
|
||||||
|
],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = html_print_tabs($tabs);
|
$result = html_print_tabs($tabs);
|
||||||
@ -161,11 +179,16 @@ class View extends \HTML
|
|||||||
theme_advanced_buttons2: "",
|
theme_advanced_buttons2: "",
|
||||||
theme_advanced_buttons3: "",
|
theme_advanced_buttons3: "",
|
||||||
theme_advanced_statusbar_location: "none",
|
theme_advanced_statusbar_location: "none",
|
||||||
body_class: "tinyMCEBody"
|
body_class: "tinyMCEBody",
|
||||||
|
forced_root_block : false,
|
||||||
|
force_p_newlines : false,
|
||||||
|
force_br_newlines : true,
|
||||||
|
convert_newlines_to_brs : false,
|
||||||
|
remove_linebreaks : true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
active: 2
|
active: '.$activetabs.'
|
||||||
});';
|
});';
|
||||||
$js .= '});';
|
$js .= '});';
|
||||||
$js .= '</script>';
|
$js .= '</script>';
|
||||||
@ -214,8 +237,6 @@ class View extends \HTML
|
|||||||
$values = $item->toArray();
|
$values = $item->toArray();
|
||||||
} else {
|
} else {
|
||||||
$values['type'] = $type;
|
$values['type'] = $type;
|
||||||
$values['isLinkEnabled'] = true;
|
|
||||||
$values['isOnTop'] = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$values['tabSelected'] = $tabSelected;
|
$values['tabSelected'] = $tabSelected;
|
||||||
@ -250,8 +271,8 @@ class View extends \HTML
|
|||||||
global $config;
|
global $config;
|
||||||
// Inserted data in new item.
|
// Inserted data in new item.
|
||||||
$vCId = \get_parameter('vCId', 0);
|
$vCId = \get_parameter('vCId', 0);
|
||||||
$type = get_parameter('type', null);
|
$type = \get_parameter('type', null);
|
||||||
$itemId = (int) get_parameter('itemId', 0);
|
$itemId = (int) \get_parameter('itemId', 0);
|
||||||
|
|
||||||
// Type.
|
// Type.
|
||||||
$data['type'] = $type;
|
$data['type'] = $type;
|
||||||
@ -262,32 +283,46 @@ class View extends \HTML
|
|||||||
|
|
||||||
// Page general for each item.
|
// Page general for each item.
|
||||||
$tabGeneral = (bool) \get_parameter('tabGeneral', false);
|
$tabGeneral = (bool) \get_parameter('tabGeneral', false);
|
||||||
$data['width'] = \get_parameter('width');
|
|
||||||
$data['height'] = \get_parameter('height');
|
|
||||||
$data['x'] = \get_parameter('x');
|
|
||||||
$data['y'] = \get_parameter('y');
|
|
||||||
|
|
||||||
if ($tabGeneral === true) {
|
if ($tabGeneral === true) {
|
||||||
|
// Size.
|
||||||
|
$data['width'] = \get_parameter('width');
|
||||||
|
$data['height'] = \get_parameter('height');
|
||||||
|
|
||||||
|
// Position.
|
||||||
|
$data['x'] = \get_parameter('x');
|
||||||
|
$data['y'] = \get_parameter('y');
|
||||||
|
|
||||||
|
// Enable link.
|
||||||
$data['isLinkEnabled'] = \get_parameter_switch('isLinkEnabled');
|
$data['isLinkEnabled'] = \get_parameter_switch('isLinkEnabled');
|
||||||
|
|
||||||
|
// Show on top.
|
||||||
$data['isOnTop'] = \get_parameter_switch('isOnTop');
|
$data['isOnTop'] = \get_parameter_switch('isOnTop');
|
||||||
|
|
||||||
|
// Parent.
|
||||||
|
$data['parentId'] = \get_parameter('parentId');
|
||||||
|
|
||||||
|
// ACL.
|
||||||
|
$data['aclGroupId'] = \get_parameter('aclGroupId');
|
||||||
|
|
||||||
|
// Cache.
|
||||||
|
$data['cacheExpiration_select'] = \get_parameter(
|
||||||
|
'cacheExpiration_select'
|
||||||
|
);
|
||||||
|
$data['cacheExpiration_text'] = \get_parameter(
|
||||||
|
'cacheExpiration_text'
|
||||||
|
);
|
||||||
|
$data['cacheExpiration'] = \get_parameter('cacheExpiration');
|
||||||
|
$data['cacheExpiration_units'] = \get_parameter(
|
||||||
|
'cacheExpiration_units'
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
if ($itemId === 0) {
|
// Only Create, settings default values if not enter tab general.
|
||||||
$data['isLinkEnabled'] = true;
|
if ($itemId === 0 && $type != LINE_ITEM) {
|
||||||
$data['isOnTop'] = true;
|
$class = VisualConsole::getItemClass((int) $type);
|
||||||
|
$data = $class::getDefaultGeneralValues($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['parentId'] = \get_parameter('parentId');
|
|
||||||
$data['aclGroupId'] = \get_parameter('aclGroupId');
|
|
||||||
$data['cacheExpiration_select'] = \get_parameter(
|
|
||||||
'cacheExpiration_select'
|
|
||||||
);
|
|
||||||
$data['cacheExpiration_text'] = \get_parameter('cacheExpiration_text');
|
|
||||||
$data['cacheExpiration'] = \get_parameter('cacheExpiration');
|
|
||||||
$data['cacheExpiration_units'] = \get_parameter(
|
|
||||||
'cacheExpiration_units'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Linked other VC.
|
// Linked other VC.
|
||||||
$data['linkedLayoutId'] = \get_parameter(
|
$data['linkedLayoutId'] = \get_parameter(
|
||||||
'linkedLayoutId',
|
'linkedLayoutId',
|
||||||
@ -329,6 +364,7 @@ class View extends \HTML
|
|||||||
$data['moduleId'] = \get_parameter('moduleId');
|
$data['moduleId'] = \get_parameter('moduleId');
|
||||||
$data['customGraphId'] = \get_parameter('customGraphId');
|
$data['customGraphId'] = \get_parameter('customGraphId');
|
||||||
$data['graphType'] = \get_parameter('graphType');
|
$data['graphType'] = \get_parameter('graphType');
|
||||||
|
$data['showLegend'] = \get_parameter_switch('showLegend');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIMPLE_VALUE:
|
case SIMPLE_VALUE:
|
||||||
@ -346,7 +382,6 @@ class View extends \HTML
|
|||||||
case CIRCULAR_PROGRESS_BAR:
|
case CIRCULAR_PROGRESS_BAR:
|
||||||
case CIRCULAR_INTERIOR_PROGRESS_BAR:
|
case CIRCULAR_INTERIOR_PROGRESS_BAR:
|
||||||
$data['percentileType'] = \get_parameter('percentileType');
|
$data['percentileType'] = \get_parameter('percentileType');
|
||||||
$data['width'] = \get_parameter('width');
|
|
||||||
$data['minValue'] = \get_parameter('minValue');
|
$data['minValue'] = \get_parameter('minValue');
|
||||||
$data['maxValue'] = \get_parameter('maxValue');
|
$data['maxValue'] = \get_parameter('maxValue');
|
||||||
$data['valueType'] = \get_parameter('valueType');
|
$data['valueType'] = \get_parameter('valueType');
|
||||||
@ -379,6 +414,11 @@ class View extends \HTML
|
|||||||
$data['borderColor'] = \get_parameter('borderColor');
|
$data['borderColor'] = \get_parameter('borderColor');
|
||||||
$data['borderWidth'] = \get_parameter('borderWidth');
|
$data['borderWidth'] = \get_parameter('borderWidth');
|
||||||
$data['isOnTop'] = \get_parameter_switch('isOnTop');
|
$data['isOnTop'] = \get_parameter_switch('isOnTop');
|
||||||
|
// Insert line default position ball end.
|
||||||
|
if ($itemId === 0) {
|
||||||
|
$data['height'] = 100;
|
||||||
|
$data['width'] = 100;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AUTO_SLA_GRAPH:
|
case AUTO_SLA_GRAPH:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user