diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php
index 42f848b649..90a9610b4f 100644
--- a/pandora_console/include/functions_graph.php
+++ b/pandora_console/include/functions_graph.php
@@ -3896,7 +3896,7 @@ function graph_graphic_agentevents($id_agent, $width, $height, $period=0, $homeu
* @param string homeurl
* @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 $graphic_type;
@@ -3972,7 +3972,7 @@ function graph_graphic_moduleevents($id_agent, $id_module, $width, $height, $per
$out = flot_slicesbar_graph(
$data,
$period,
- 100,
+ $width,
$height,
$full_legend,
$colors,
@@ -3985,7 +3985,8 @@ function graph_graphic_moduleevents($id_agent, $id_module, $width, $height, $per
$id_agent,
[],
true,
- 1
+ $ttl,
+ true
);
if ($return) {
diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js
index 5a8e43334a..c276ce4849 100644
--- a/pandora_console/include/graphs/flot/pandora.flot.js
+++ b/pandora_console/include/graphs/flot/pandora.flot.js
@@ -802,9 +802,9 @@ function pandoraFlotSlicebar(
full_legend = full_legend.split(separator);
}
- var font_size = parseInt(font_size);
+ font_size = parseInt(font_size);
if (font != undefined)
- var font = font
+ font = font
.split("/")
.pop()
.split(".")
@@ -884,7 +884,7 @@ function pandoraFlotSlicebar(
$.plot($("#" + graph_id), datas, options);
- if (match == null) {
+ if (match == null && not_interactive == 0) {
// Events
$("#" + graph_id).bind("plothover", function(event, pos, item) {
if (item) {
diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php
index fc544a55f8..b4d6db3f29 100644
--- a/pandora_console/include/graphs/functions_flot.php
+++ b/pandora_console/include/graphs/functions_flot.php
@@ -143,7 +143,7 @@ function flot_area_graph(
// Parent layer.
$return = "
";
- if (empty($params['title']) === false) {
+ if ($params['title'] === true && empty($params['title']) === false) {
$return .= '
'.$params['title'].'
';
}
@@ -777,15 +777,17 @@ function flot_slicesbar_graph(
// Get a unique identifier to graph
$graph_id = uniqid('graph_');
- $height = ((int) $height + 15);
-
// Set some containers to legend, graph, timestamp tooltip, etc.
if ($stat_win) {
+ $height = ((int) $height + 15);
$return = "
";
} else {
if ($widgets) {
+ $width = ((int) $width - 10);
+ $height = ((int) $height - 10);
$return = "
";
} else {
+ $height = ((int) $height + 15);
$return = "
";
}
}
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Item.php b/pandora_console/include/rest-api/models/VisualConsole/Item.php
index c310aa0a6c..dbfa80a132 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Item.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Item.php
@@ -355,10 +355,7 @@ class Item extends CachedModel
*/
private static function extractLabel(array $data)
{
- return static::notEmptyStringOr(
- static::issetInArray($data, ['label']),
- null
- );
+ return static::issetInArray($data, ['label']);
}
@@ -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.
*
@@ -1294,12 +1268,12 @@ class Item extends CachedModel
$result = [];
$id = static::getId($data);
- if ($id) {
+ if (isset($id) === true) {
$result['id'] = $id;
}
$id_layout = static::getIdLayout($data);
- if ($id_layout) {
+ if (isset($id_layout) === true) {
$result['id_layout'] = $id_layout;
}
@@ -1334,6 +1308,7 @@ class Item extends CachedModel
$result['label'] = $label;
}
+ // TODO change.
$image = static::getImageSrc($data);
if ($image !== null) {
$result['image'] = $image;
@@ -1347,6 +1322,7 @@ class Item extends CachedModel
$result['type'] = $type;
}
+ // TODO change.
$period = static::parseIntOr(
static::issetInArray($data, ['period', 'maxTime']),
null
@@ -1407,21 +1383,12 @@ class Item extends CachedModel
$result['id_group'] = $id_group;
}
- $id_custom_graph = static::extractIdCustomGraph($data);
- if ($id_custom_graph !== null) {
- $result['id_custom_graph'] = $id_custom_graph;
- }
-
+ // TODO change.
$border_width = static::getBorderWidth($data);
if ($border_width !== null) {
$result['border_width'] = $border_width;
}
- $type_graph = static::getTypeGraph($data);
- if ($type_graph !== null) {
- $result['type_graph'] = $type_graph;
- }
-
$label_position = static::notEmptyStringOr(
static::issetInArray($data, ['labelPosition', 'label_position']),
null
@@ -1430,27 +1397,18 @@ class Item extends CachedModel
$result['label_position'] = $label_position;
}
+ // TODO change.
$border_color = static::getBorderColor($data);
if ($border_color !== null) {
$result['border_color'] = $border_color;
}
+ // TODO change.
$fill_color = static::getFillColor($data);
if ($fill_color !== null) {
$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(
static::issetInArray(
$data,
@@ -1541,6 +1499,7 @@ class Item extends CachedModel
$result['show_on_top'] = static::parseBool($show_on_top);
}
+ // TODO change.
$show_last_value = static::notEmptyStringOr(
static::issetInArray($data, ['showLastValueTooltip']),
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.
*
@@ -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.
*
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/BarsGraph.php b/pandora_console/include/rest-api/models/VisualConsole/Items/BarsGraph.php
index 0b9a914f5b..cc0c3dc6e7 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Items/BarsGraph.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Items/BarsGraph.php
@@ -27,6 +27,55 @@ final class BarsGraph extends Item
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.
*
@@ -349,6 +398,9 @@ final class BarsGraph extends Item
*/
public static function getFormInputs(array $values): array
{
+ // Default values.
+ $values = static::getDefaultGeneralValues($values);
+
// Retrieve global - common inputs.
$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;
+ }
+
+
}
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Box.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Box.php
index 8d4cb26817..ea5351c772 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Items/Box.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Box.php
@@ -93,13 +93,101 @@ final class Box extends Item
*/
public static function getFormInputs(array $values): array
{
- // Retrieve global - common inputs.
- $inputs = Item::getFormInputs($values);
+ // Default values.
+ $values = static::getDefaultGeneralValues($values);
- if (is_array($inputs) !== true) {
- throw new Exception(
- '[Box]::getFormInputs parent class return is not an array'
- );
+ if ($values['tabSelected'] === 'general') {
+ $inputs[] = [
+ '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') {
@@ -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;
+ }
+
+
}
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Clock.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Clock.php
index 1015d05253..f002d924fe 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Items/Clock.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Clock.php
@@ -252,6 +252,9 @@ final class Clock extends Item
*/
public static function getFormInputs(array $values): array
{
+ // Default values.
+ $values = static::getDefaultGeneralValues($values);
+
// Retrieve global - common inputs.
$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;
+ }
+
+
}
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/DonutGraph.php b/pandora_console/include/rest-api/models/VisualConsole/Items/DonutGraph.php
index 8cd49ccafc..fd33ca652c 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Items/DonutGraph.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Items/DonutGraph.php
@@ -154,22 +154,12 @@ final class DonutGraph extends Item
\metaconsole_restore_db();
}
+ $width = (int) $data['width'];
+ $height = (int) $data['height'];
+
if ($isString === true) {
$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(
(int) $data['id'],
$width,
@@ -183,7 +173,8 @@ final class DonutGraph extends Item
$src = '../../'.$src;
}
- $data['html'] = '

';
+ $style = 'width:'.$width.'px; height:'.$height.'px;';
+ $data['html'] = '

';
}
return $data;
@@ -201,6 +192,9 @@ final class DonutGraph extends Item
*/
public static function getFormInputs(array $values): array
{
+ // Default values.
+ $values = static::getDefaultGeneralValues($values);
+
// Retrieve global - common inputs.
$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;
+ }
+
+
}
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/EventsHistory.php b/pandora_console/include/rest-api/models/VisualConsole/Items/EventsHistory.php
index adafa10587..5f9e2e8695 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Items/EventsHistory.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Items/EventsHistory.php
@@ -102,12 +102,6 @@ final class EventsHistory extends Item
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.
$html = \graph_graphic_moduleevents(
$agentId,
@@ -116,7 +110,8 @@ final class EventsHistory extends Item
(int) $data['height'],
static::extractMaxTime($data),
'',
- true
+ true,
+ 2
);
$data['html'] = $html;
@@ -167,6 +162,9 @@ final class EventsHistory extends Item
*/
public static function getFormInputs(array $values): array
{
+ // Default values.
+ $values = static::getDefaultGeneralValues($values);
+
// Retrieve global - common inputs.
$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;
+ }
+
+
}
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php
index 70c5b9a4d4..21c830f2bd 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php
@@ -34,6 +34,28 @@ final class Group extends Item
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.
*
@@ -458,6 +480,9 @@ final class Group extends Item
*/
public static function getFormInputs(array $values): array
{
+ // Default values.
+ $values = static::getDefaultGeneralValues($values);
+
// Retrieve global - common inputs.
$inputs = Item::getFormInputs($values);
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Icon.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Icon.php
index 02b41e8e76..0c83932c59 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Items/Icon.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Icon.php
@@ -140,6 +140,9 @@ final class Icon extends Item
*/
public static function getFormInputs(array $values): array
{
+ // Default values.
+ $values = static::getDefaultGeneralValues($values);
+
// Retrieve global - common inputs.
$inputs = Item::getFormInputs($values);
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Label.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Label.php
index 41c9c6c6d1..0a3a61877a 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Items/Label.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Label.php
@@ -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;
+ }
+
+
}
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php b/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php
index f69986f381..a611b6a424 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php
@@ -35,6 +35,80 @@ final class ModuleGraph extends Item
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.
*
@@ -50,6 +124,7 @@ final class ModuleGraph extends Item
$return['type'] = MODULE_GRAPH;
$return['backgroundType'] = static::extractBackgroundType($data);
$return['period'] = static::extractPeriod($data);
+ $return['showLegend'] = static::extractShowLegend($data);
$customGraphId = static::extractCustomGraphId($data);
@@ -68,7 +143,8 @@ final class ModuleGraph extends Item
*
* @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
{
@@ -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.
*
@@ -172,6 +263,7 @@ final class ModuleGraph extends Item
$backgroundType = static::extractBackgroundType($data);
$period = static::extractPeriod($data);
+ $showLegend = static::extractShowLegend($data);
$customGraphId = static::extractCustomGraphId($data);
$graphType = static::extractGraphType($data);
$linkedModule = static::extractLinkedModule($data);
@@ -208,14 +300,6 @@ final class ModuleGraph extends Item
$width = (int) $data['width'];
$height = (int) $data['height'];
- if ($width === 0) {
- $width = 440;
- }
-
- if ($height === 0) {
- $height = 220;
- }
-
// Custom graph.
if (empty($customGraphId) === false) {
$customGraph = \db_get_row('tgraph', 'id_graph', $customGraphId);
@@ -231,6 +315,8 @@ final class ModuleGraph extends Item
'vconsole' => true,
'backgroundColor' => $backgroundType,
'return_img_base_64' => true,
+ 'show_legend' => $showLegend,
+ 'show_title' => false,
];
$paramsCombined = [
@@ -269,6 +355,8 @@ final class ModuleGraph extends Item
'type_graph' => $graphType,
'vconsole' => true,
'return_img_base_64' => true,
+ 'show_legend' => $showLegend,
+ 'show_title' => false,
];
$imgbase64 = 'data:image/jpg;base64,';
@@ -323,6 +411,9 @@ final class ModuleGraph extends Item
*/
public static function getFormInputs(array $values): array
{
+ // Default values.
+ $values = static::getDefaultGeneralValues($values);
+
// Retrieve global - common inputs.
$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.
$inputsLinkedVisualConsole = self::inputsLinkedVisualConsole(
$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;
+ }
+
+
}
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Percentile.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Percentile.php
index 95e18c261b..062120b944 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Items/Percentile.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Percentile.php
@@ -190,12 +190,12 @@ final class Percentile extends Item
$color = static::encodeColor($data);
if ($border_color !== null) {
- $result['border_color'] = $color;
+ $return['border_color'] = $color;
}
$labelColor = static::encodeLabelColor($data);
if ($labelColor !== null) {
- $result['fill_color'] = $labelColor;
+ $return['fill_color'] = $labelColor;
}
return $return;
@@ -435,6 +435,9 @@ final class Percentile extends Item
*/
public static function getFormInputs(array $values): array
{
+ // Default values.
+ $values = static::getDefaultGeneralValues($values);
+
// Retrieve global - common inputs.
$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') {
// Type percentile.
$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.
// Min Value.
$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;
+ }
+
+
}
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/SimpleValue.php b/pandora_console/include/rest-api/models/VisualConsole/Items/SimpleValue.php
index 47701a8b80..be5ef19835 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Items/SimpleValue.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Items/SimpleValue.php
@@ -309,6 +309,9 @@ final class SimpleValue extends Item
*/
public static function getFormInputs(array $values): array
{
+ // Default values.
+ $values = static::getDefaultGeneralValues($values);
+
// Retrieve global - common inputs.
$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;
+ }
+
+
}
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php b/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php
index a2f75716fd..e364d92bf6 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php
@@ -252,6 +252,9 @@ final class StaticGraph extends Item
*/
public static function getFormInputs(array $values): array
{
+ // Default values.
+ $values = static::getDefaultGeneralValues($values);
+
// Retrieve global - common inputs.
$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') {
// List images VC.
if (isset($values['imageSrc']) === false) {
diff --git a/pandora_console/include/rest-api/models/VisualConsole/View.php b/pandora_console/include/rest-api/models/VisualConsole/View.php
index ba9b7c47aa..dd0f73127b 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/View.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/View.php
@@ -78,7 +78,9 @@ class View extends \HTML
],
];
+ $activetabs = 2;
if ($type === LABEL) {
+ $activetabs = 0;
$tabs = [
[
'name' => __('Label settings'),
@@ -92,7 +94,8 @@ class View extends \HTML
'img' => 'pencil.png',
],
];
- } else if ($type === LINE_ITEM || $type === BOX_ITEM) {
+ } else if ($type === LINE_ITEM) {
+ $activetabs = 0;
$tabs = [
[
'name' => __('Specific settings'),
@@ -101,6 +104,21 @@ class View extends \HTML
'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);
@@ -161,11 +179,16 @@ class View extends \HTML
theme_advanced_buttons2: "",
theme_advanced_buttons3: "",
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 .= '';
@@ -214,8 +237,6 @@ class View extends \HTML
$values = $item->toArray();
} else {
$values['type'] = $type;
- $values['isLinkEnabled'] = true;
- $values['isOnTop'] = true;
}
$values['tabSelected'] = $tabSelected;
@@ -250,8 +271,8 @@ class View extends \HTML
global $config;
// Inserted data in new item.
$vCId = \get_parameter('vCId', 0);
- $type = get_parameter('type', null);
- $itemId = (int) get_parameter('itemId', 0);
+ $type = \get_parameter('type', null);
+ $itemId = (int) \get_parameter('itemId', 0);
// Type.
$data['type'] = $type;
@@ -262,32 +283,46 @@ class View extends \HTML
// Page general for each item.
$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) {
+ // 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');
+
+ // Show on top.
$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 {
- if ($itemId === 0) {
- $data['isLinkEnabled'] = true;
- $data['isOnTop'] = true;
+ // Only Create, settings default values if not enter tab general.
+ if ($itemId === 0 && $type != LINE_ITEM) {
+ $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.
$data['linkedLayoutId'] = \get_parameter(
'linkedLayoutId',
@@ -329,6 +364,7 @@ class View extends \HTML
$data['moduleId'] = \get_parameter('moduleId');
$data['customGraphId'] = \get_parameter('customGraphId');
$data['graphType'] = \get_parameter('graphType');
+ $data['showLegend'] = \get_parameter_switch('showLegend');
break;
case SIMPLE_VALUE:
@@ -346,7 +382,6 @@ class View extends \HTML
case CIRCULAR_PROGRESS_BAR:
case CIRCULAR_INTERIOR_PROGRESS_BAR:
$data['percentileType'] = \get_parameter('percentileType');
- $data['width'] = \get_parameter('width');
$data['minValue'] = \get_parameter('minValue');
$data['maxValue'] = \get_parameter('maxValue');
$data['valueType'] = \get_parameter('valueType');
@@ -379,6 +414,11 @@ class View extends \HTML
$data['borderColor'] = \get_parameter('borderColor');
$data['borderWidth'] = \get_parameter('borderWidth');
$data['isOnTop'] = \get_parameter_switch('isOnTop');
+ // Insert line default position ball end.
+ if ($itemId === 0) {
+ $data['height'] = 100;
+ $data['width'] = 100;
+ }
break;
case AUTO_SLA_GRAPH: