mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
Fixed errors Form VC
This commit is contained in:
parent
7d60287018
commit
14984faaaa
@ -3640,35 +3640,34 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'autocomplete_agent':
|
case 'autocomplete_agent':
|
||||||
/*
|
|
||||||
if (is_metaconsole() === true) {
|
|
||||||
$connection = metaconsole_get_connection($server_name);
|
|
||||||
$agent_name = '';
|
|
||||||
|
|
||||||
if (metaconsole_load_external_db($connection) == NOERR) {
|
|
||||||
$agent_name = db_get_value_filter(
|
|
||||||
'alias',
|
|
||||||
'tagente',
|
|
||||||
['id_agente' => $idAgent]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append server name.
|
|
||||||
if (!empty($agent_name)) {
|
|
||||||
$agent_name .= ' ('.$server_name.')';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore db connection.
|
|
||||||
metaconsole_restore_db();
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
$agent_name = '';
|
$agent_name = '';
|
||||||
if (isset($data['id_agent_hidden']) === true
|
if (isset($data['id_agent_hidden']) === true
|
||||||
&& empty($data['id_agent_hidden']) === false
|
&& empty($data['id_agent_hidden']) === false
|
||||||
) {
|
) {
|
||||||
$agent_name = agents_get_alias($data['id_agent_hidden']);
|
if (is_metaconsole() === true) {
|
||||||
|
$connection = metaconsole_get_connection_by_id(
|
||||||
|
$data['server_id_hidden']
|
||||||
|
);
|
||||||
|
$agent_name = '';
|
||||||
|
|
||||||
|
if (metaconsole_load_external_db($connection) == NOERR) {
|
||||||
|
$agent_name = db_get_value_filter(
|
||||||
|
'alias',
|
||||||
|
'tagente',
|
||||||
|
['id_agente' => $data['id_agent_hidden']]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append server name.
|
||||||
|
if (!empty($agent_name)) {
|
||||||
|
$agent_name .= ' ('.$connection['server_name'].')';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore db connection.
|
||||||
|
metaconsole_restore_db();
|
||||||
|
} else {
|
||||||
|
$agent_name = agents_get_alias($data['id_agent_hidden']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$params = [];
|
$params = [];
|
||||||
@ -3677,36 +3676,107 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||||||
$params['input_name'] = $data['name'];
|
$params['input_name'] = $data['name'];
|
||||||
$params['value'] = $agent_name;
|
$params['value'] = $agent_name;
|
||||||
$params['javascript_is_function_select'] = true;
|
$params['javascript_is_function_select'] = true;
|
||||||
// $params['selectbox_id'] = 'id_agent_module';
|
|
||||||
// $params['add_none_module'] = true;
|
if (isset($data['module_input']) === true
|
||||||
|
&& $data['module_input'] === true
|
||||||
|
) {
|
||||||
|
$params['selectbox_id'] = $data['module_name'];
|
||||||
|
$params['add_none_module'] = $data['module_none'];
|
||||||
|
}
|
||||||
|
|
||||||
$params['use_hidden_input_idagent'] = true;
|
$params['use_hidden_input_idagent'] = true;
|
||||||
$params['hidden_input_idagent_id'] = 'hidden-'.$data['name_agent_hidden'];
|
$params['hidden_input_idagent_id'] = 'hidden-'.$data['name_agent_hidden'];
|
||||||
/*
|
if (is_metaconsole()) {
|
||||||
if (is_metaconsole()) {
|
|
||||||
$params['use_input_id_server'] = true;
|
$params['use_input_id_server'] = true;
|
||||||
$params['input_id_server_id'] = 'hidden-server_id';
|
$params['input_id_server_id'] = 'hidden-'.$data['name_server_hidden'];
|
||||||
$params['metaconsole_enabled'] = true;
|
$params['metaconsole_enabled'] = true;
|
||||||
$params['input_id'] = 'agent_autocomplete_events';
|
}
|
||||||
$params['javascript_page'] = 'include/ajax/agent';
|
|
||||||
$params['input_name'] = 'agent_text';
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
$output .= html_print_input_hidden(
|
$output .= html_print_input_hidden(
|
||||||
$data['name_agent_hidden'],
|
$data['name_agent_hidden'],
|
||||||
$data['id_agent_hidden'],
|
$data['id_agent_hidden'],
|
||||||
$data['return']
|
$data['return']
|
||||||
);
|
);
|
||||||
// $output .= html_print_input_hidden('server_name', $server_name);
|
|
||||||
$output .= html_print_input_hidden(
|
$output .= html_print_input_hidden(
|
||||||
$data['name_server_hidden'],
|
$data['name_server_hidden'],
|
||||||
$data['server_id_hidden'],
|
$data['server_id_hidden'],
|
||||||
$data['return']
|
$data['return']
|
||||||
);
|
);
|
||||||
// $output .= html_print_input_hidden('id_server', '');
|
|
||||||
$output .= ui_print_agent_autocomplete_input($params);
|
$output .= ui_print_agent_autocomplete_input($params);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'autocomplete_module':
|
||||||
|
// Module.
|
||||||
|
if (isset($data['selected']) === false || $data['selected'] === 0) {
|
||||||
|
$fields = [
|
||||||
|
0 => __('Select an Agent first'),
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$sql = sprintf(
|
||||||
|
'SELECT id_agente_modulo, nombre
|
||||||
|
FROM tagente_modulo
|
||||||
|
WHERE id_agente = %d
|
||||||
|
AND delete_pending = 0',
|
||||||
|
$data['agent_id']
|
||||||
|
);
|
||||||
|
|
||||||
|
if (is_metaconsole() === true) {
|
||||||
|
$connection = metaconsole_get_connection_id(
|
||||||
|
$data['metaconsole_id']
|
||||||
|
);
|
||||||
|
|
||||||
|
if (metaconsole_load_external_db($connection) == NOERR) {
|
||||||
|
$modules_agent = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
|
if ($modules_agent === false) {
|
||||||
|
$modules_agent = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore db connection.
|
||||||
|
metaconsole_restore_db();
|
||||||
|
} else {
|
||||||
|
$modules_agent = db_get_all_rows_sql($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
$fields = [];
|
||||||
|
if (isset($modules_agent) === true
|
||||||
|
&& is_array($modules_agent) === true
|
||||||
|
) {
|
||||||
|
$fields = array_reduce(
|
||||||
|
$modules_agent,
|
||||||
|
function ($carry, $item) {
|
||||||
|
$carry[$item['id_agente_modulo']] = $item['nombre'];
|
||||||
|
return $carry;
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= html_print_select(
|
||||||
|
$fields,
|
||||||
|
$data['name'],
|
||||||
|
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||||
|
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||||
|
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||||
|
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||||
|
((isset($data['return']) === true) ? $data['return'] : false),
|
||||||
|
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||||
|
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||||
|
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||||
|
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||||
|
((isset($data['style']) === true) ? $data['style'] : false),
|
||||||
|
((isset($data['option_style']) === true) ? $data['option_style'] : false),
|
||||||
|
((isset($data['size']) === true) ? $data['size'] : false),
|
||||||
|
((isset($data['modal']) === true) ? $data['modal'] : false),
|
||||||
|
((isset($data['message']) === true) ? $data['message'] : ''),
|
||||||
|
((isset($data['select_all']) === true) ? $data['select_all'] : false)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Ignore.
|
// Ignore.
|
||||||
break;
|
break;
|
||||||
|
@ -2161,7 +2161,13 @@ function load_modal(settings) {
|
|||||||
formdata.append(this.name, $(this).prop("files")[0]);
|
formdata.append(this.name, $(this).prop("files")[0]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
formdata.append(this.name, $(this).val());
|
if ($(this).attr("type") == "checkbox") {
|
||||||
|
if (this.checked) {
|
||||||
|
formdata.append(this.name, "on");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formdata.append(this.name, $(this).val());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -2172,7 +2178,13 @@ function load_modal(settings) {
|
|||||||
formdata.append(this.name, $(this).prop("files")[0]);
|
formdata.append(this.name, $(this).prop("files")[0]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
formdata.append(this.name, $(this).val());
|
if ($(this).attr("type") == "checkbox") {
|
||||||
|
if (this.checked) {
|
||||||
|
formdata.append(this.name, "on");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formdata.append(this.name, $(this).val());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -353,9 +353,6 @@ function createVisualConsole(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
createItem: function(typeString) {
|
createItem: function(typeString) {
|
||||||
//TODO:XXX
|
|
||||||
console.log(typeString);
|
|
||||||
|
|
||||||
var type;
|
var type;
|
||||||
switch (typeString) {
|
switch (typeString) {
|
||||||
case "STATIC_GRAPH":
|
case "STATIC_GRAPH":
|
||||||
@ -1467,12 +1464,16 @@ function createOrUpdateVisualConsoleItem(
|
|||||||
},
|
},
|
||||||
extradata: [
|
extradata: [
|
||||||
{
|
{
|
||||||
name: "item",
|
name: "type",
|
||||||
value: item
|
value: item.itemProps.type
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "vCId",
|
name: "vCId",
|
||||||
value: visualConsole.props.id
|
value: visualConsole.props.id
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "itemId",
|
||||||
|
value: item.itemProps.id ? item.itemProps.id : 0
|
||||||
}
|
}
|
||||||
/*{
|
/*{
|
||||||
name: "elementsVc",
|
name: "elementsVc",
|
||||||
|
@ -484,32 +484,7 @@ if ($getVisualConsole === true) {
|
|||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
return;
|
return;
|
||||||
} else if ($getCustomGraphVisualConsoleItem) {
|
} else if ($getCustomGraphVisualConsoleItem) {
|
||||||
include_once 'include/functions_custom_graphs.php';
|
// Remove.
|
||||||
enterprise_include_once('include/functions_metaconsole.php');
|
|
||||||
$data = [];
|
|
||||||
if (is_metaconsole()) {
|
|
||||||
$data = metaconsole_get_custom_graphs(true);
|
|
||||||
} else {
|
|
||||||
$data = custom_graphs_get_user(
|
|
||||||
$config['id_user'],
|
|
||||||
false,
|
|
||||||
true,
|
|
||||||
'RR'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = array_map(
|
|
||||||
function ($id) use ($data) {
|
|
||||||
return [
|
|
||||||
'value' => $id,
|
|
||||||
'text' => is_metaconsole() ? io_safe_output($data[$id]) : io_safe_output($data[$id]['name']),
|
|
||||||
];
|
|
||||||
},
|
|
||||||
array_keys($data)
|
|
||||||
);
|
|
||||||
|
|
||||||
echo json_encode($result);
|
|
||||||
return;
|
|
||||||
} else if ($serviceListVisualConsole) {
|
} else if ($serviceListVisualConsole) {
|
||||||
if (!enterprise_installed()) {
|
if (!enterprise_installed()) {
|
||||||
echo json_encode(false);
|
echo json_encode(false);
|
||||||
|
@ -1887,15 +1887,15 @@ class Item extends CachedModel
|
|||||||
/**
|
/**
|
||||||
* Generates inputs for form (global, common).
|
* Generates inputs for form (global, common).
|
||||||
*
|
*
|
||||||
* @param object $values Default values.
|
* @param array $values Default values.
|
||||||
*
|
*
|
||||||
* @return array Of inputs.
|
* @return array Of inputs.
|
||||||
*/
|
*/
|
||||||
public static function getFormInputs(object $values): array
|
public static function getFormInputs(array $values): array
|
||||||
{
|
{
|
||||||
$inputs = [];
|
$inputs = [];
|
||||||
|
|
||||||
switch ($values->tabSelected) {
|
switch ($values['tabSelected']) {
|
||||||
case 'label':
|
case 'label':
|
||||||
// Label.
|
// Label.
|
||||||
// TODO tinyMCE.
|
// TODO tinyMCE.
|
||||||
@ -1905,7 +1905,7 @@ class Item extends CachedModel
|
|||||||
'arguments' => [
|
'arguments' => [
|
||||||
'name' => 'label',
|
'name' => 'label',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'value' => $values->label,
|
'value' => $values['label'],
|
||||||
'return' => true,
|
'return' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@ -1926,7 +1926,7 @@ class Item extends CachedModel
|
|||||||
'arguments' => [
|
'arguments' => [
|
||||||
'name' => 'width',
|
'name' => 'width',
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'value' => $values->width,
|
'value' => $values['width'],
|
||||||
'return' => true,
|
'return' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -1935,7 +1935,7 @@ class Item extends CachedModel
|
|||||||
'arguments' => [
|
'arguments' => [
|
||||||
'name' => 'height',
|
'name' => 'height',
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'value' => $values->height,
|
'value' => $values['height'],
|
||||||
'return' => true,
|
'return' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -1956,7 +1956,7 @@ class Item extends CachedModel
|
|||||||
'arguments' => [
|
'arguments' => [
|
||||||
'name' => 'x',
|
'name' => 'x',
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'value' => $values->x,
|
'value' => $values['x'],
|
||||||
'return' => true,
|
'return' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -1965,7 +1965,7 @@ class Item extends CachedModel
|
|||||||
'arguments' => [
|
'arguments' => [
|
||||||
'name' => 'y',
|
'name' => 'y',
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'value' => $values->y,
|
'value' => $values['y'],
|
||||||
'return' => true,
|
'return' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -1979,7 +1979,7 @@ class Item extends CachedModel
|
|||||||
'name' => 'isLinkEnabled',
|
'name' => 'isLinkEnabled',
|
||||||
'id' => 'isLinkEnabled',
|
'id' => 'isLinkEnabled',
|
||||||
'type' => 'switch',
|
'type' => 'switch',
|
||||||
'value' => $values->isLinkEnabled,
|
'value' => $values['isLinkEnabled'],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -1990,7 +1990,7 @@ class Item extends CachedModel
|
|||||||
'name' => 'isOnTop',
|
'name' => 'isOnTop',
|
||||||
'id' => 'isOnTop',
|
'id' => 'isOnTop',
|
||||||
'type' => 'switch',
|
'type' => 'switch',
|
||||||
'value' => $values->isOnTop,
|
'value' => $values['isOnTop'],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -2005,7 +2005,7 @@ class Item extends CachedModel
|
|||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'fields' => $fields,
|
'fields' => $fields,
|
||||||
'name' => 'parentId',
|
'name' => 'parentId',
|
||||||
'selected' => $values->parentId,
|
'selected' => $values['parentId'],
|
||||||
'return' => true,
|
'return' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@ -2017,8 +2017,8 @@ class Item extends CachedModel
|
|||||||
'type' => 'select_groups',
|
'type' => 'select_groups',
|
||||||
'name' => 'aclGroupId',
|
'name' => 'aclGroupId',
|
||||||
'returnAllGroup' => true,
|
'returnAllGroup' => true,
|
||||||
'privilege' => $values->access,
|
'privilege' => $values['access'],
|
||||||
'selected' => $values->aclGroupId,
|
'selected' => $values['aclGroupId'],
|
||||||
'return' => true,
|
'return' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@ -2029,7 +2029,7 @@ class Item extends CachedModel
|
|||||||
'arguments' => [
|
'arguments' => [
|
||||||
'name' => 'cacheExpiration',
|
'name' => 'cacheExpiration',
|
||||||
'type' => 'interval',
|
'type' => 'interval',
|
||||||
'value' => $values->cacheExpiration,
|
'value' => $values['cacheExpiration'],
|
||||||
'nothing' => __('None'),
|
'nothing' => __('None'),
|
||||||
'nothing_value' => 0,
|
'nothing_value' => 0,
|
||||||
],
|
],
|
||||||
|
@ -209,10 +209,18 @@ final class ModuleGraph extends Item
|
|||||||
if (empty($customGraphId) === false) {
|
if (empty($customGraphId) === false) {
|
||||||
$customGraph = \db_get_row('tgraph', 'id_graph', $customGraphId);
|
$customGraph = \db_get_row('tgraph', 'id_graph', $customGraphId);
|
||||||
|
|
||||||
|
if ($data['width'] < 440) {
|
||||||
|
$data['width'] = 440;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data['height'] < 220) {
|
||||||
|
$data['height'] = 220;
|
||||||
|
}
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
'period' => $period,
|
'period' => $period,
|
||||||
'width' => (int) $data['width'],
|
'width' => (int) $data['width'],
|
||||||
'height' => ($data['height'] - 30),
|
'height' => ($data['height'] - 40),
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'unit_name' => null,
|
'unit_name' => null,
|
||||||
'show_alerts' => false,
|
'show_alerts' => false,
|
||||||
@ -241,12 +249,20 @@ final class ModuleGraph extends Item
|
|||||||
throw new \InvalidArgumentException('missing module Id');
|
throw new \InvalidArgumentException('missing module Id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($data['width'] < 440) {
|
||||||
|
$data['width'] = 440;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data['height'] < 220) {
|
||||||
|
$data['height'] = 220;
|
||||||
|
}
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
'agent_module_id' => $moduleId,
|
'agent_module_id' => $moduleId,
|
||||||
'period' => $period,
|
'period' => $period,
|
||||||
'show_events' => false,
|
'show_events' => false,
|
||||||
'width' => (int) $data['width'],
|
'width' => (int) $data['width'],
|
||||||
'height' => ($data['height'] - 30),
|
'height' => ($data['height'] - 40),
|
||||||
'title' => \modules_get_agentmodule_name($moduleId),
|
'title' => \modules_get_agentmodule_name($moduleId),
|
||||||
'unit' => \modules_get_unit($moduleId),
|
'unit' => \modules_get_unit($moduleId),
|
||||||
'only_image' => $imageOnly,
|
'only_image' => $imageOnly,
|
||||||
@ -269,4 +285,192 @@ final class ModuleGraph extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return List custom graph.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getListCustomGraph():array
|
||||||
|
{
|
||||||
|
include_once 'include/functions_custom_graphs.php';
|
||||||
|
enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
$data = [];
|
||||||
|
if (is_metaconsole() === true) {
|
||||||
|
$data = metaconsole_get_custom_graphs(true);
|
||||||
|
} else {
|
||||||
|
$data = custom_graphs_get_user(
|
||||||
|
$config['id_user'],
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
'RR'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data[0] = __('None');
|
||||||
|
|
||||||
|
return array_reverse($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
{
|
||||||
|
// Retrieve global - common inputs.
|
||||||
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
|
if (is_array($inputs) !== true) {
|
||||||
|
throw new Exception(
|
||||||
|
'[ModuleGraph]::getFormInputs parent class return is not an array'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($values['tabSelected'] === 'specific') {
|
||||||
|
// Type percentile.
|
||||||
|
$fields = [
|
||||||
|
'white' => __('White'),
|
||||||
|
'black' => __('Black'),
|
||||||
|
'transparent' => __('Transparent'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Background color'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'fields' => $fields,
|
||||||
|
'name' => 'backgroundType',
|
||||||
|
'selected' => $values['backgroundType'],
|
||||||
|
'return' => true,
|
||||||
|
'sort' => false,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$classModule = '';
|
||||||
|
$classCustom = 'displayNone';
|
||||||
|
$checkedModule = true;
|
||||||
|
$checkedCustom = false;
|
||||||
|
if (isset($values['customGraphId']) === true
|
||||||
|
&& $values['customGraphId'] !== 0
|
||||||
|
) {
|
||||||
|
$classModule = 'displayNone';
|
||||||
|
$classCustom = '';
|
||||||
|
$checkedModule = false;
|
||||||
|
$checkedCustom = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Choose Type module graph if graph normal or custom.
|
||||||
|
$inputs[] = [
|
||||||
|
'wrapper' => 'div',
|
||||||
|
'class' => 'flex-row-vcenter',
|
||||||
|
'direct' => 1,
|
||||||
|
'block_content' => [
|
||||||
|
[
|
||||||
|
'arguments' => [
|
||||||
|
'label' => __('Module Graph'),
|
||||||
|
'type' => 'radio_button',
|
||||||
|
'attributes' => 'class="btn"',
|
||||||
|
'name' => 'choosetype',
|
||||||
|
'value' => 'module',
|
||||||
|
'checkedvalue' => $checkedModule,
|
||||||
|
'script' => 'typeModuleGraph(\'module\')',
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'arguments' => [
|
||||||
|
'label' => __('Custom Graph'),
|
||||||
|
'type' => 'radio_button',
|
||||||
|
'attributes' => 'class="btn"',
|
||||||
|
'name' => 'choosetype',
|
||||||
|
'value' => 'custom',
|
||||||
|
'checkedvalue' => $checkedCustom,
|
||||||
|
'script' => 'typeModuleGraph(\'custom\')',
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Autocomplete agents.
|
||||||
|
$inputs[] = [
|
||||||
|
'id' => 'MGautoCompleteAgent',
|
||||||
|
'class' => $classModule,
|
||||||
|
'label' => __('Agent'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'autocomplete_agent',
|
||||||
|
'name' => 'agentAlias',
|
||||||
|
'id_agent_hidden' => $values['agentId'],
|
||||||
|
'name_agent_hidden' => 'agentId',
|
||||||
|
'server_id_hidden' => $values['metaconsoleId'],
|
||||||
|
'name_server_hidden' => 'metaconsoleId',
|
||||||
|
'return' => true,
|
||||||
|
'module_input' => true,
|
||||||
|
'module_name' => 'moduleId',
|
||||||
|
'module_none' => 'false',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Autocomplete module.
|
||||||
|
$inputs[] = [
|
||||||
|
'id' => 'MGautoCompleteModule',
|
||||||
|
'class' => $classModule,
|
||||||
|
'label' => __('Module'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'autocomplete_module',
|
||||||
|
'fields' => $fields,
|
||||||
|
'name' => 'moduleId',
|
||||||
|
'selected' => $values['moduleId'],
|
||||||
|
'return' => true,
|
||||||
|
'sort' => false,
|
||||||
|
'agent_id' => $values['agentId'],
|
||||||
|
'metaconsole_id' => $values['metaconsoleId'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Custom graph.
|
||||||
|
$fields = self::getListCustomGraph();
|
||||||
|
$inputs[] = [
|
||||||
|
'id' => 'MGcustomGraph',
|
||||||
|
'class' => $classCustom,
|
||||||
|
'label' => __('Custom graph'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'fields' => $fields,
|
||||||
|
'name' => 'customGraphId',
|
||||||
|
'selected' => $values['customGraphId'],
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Graph Type.
|
||||||
|
$fields = [
|
||||||
|
'line' => __('Line'),
|
||||||
|
'area' => __('Area'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Graph Type'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'fields' => $fields,
|
||||||
|
'name' => 'graphType',
|
||||||
|
'selected' => $values['graphType'],
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// TODO:XXXX LinkConsoleInputGroup
|
||||||
|
}
|
||||||
|
|
||||||
|
return $inputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,68 @@ final class Percentile extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode type item.
|
||||||
|
*
|
||||||
|
* @param array $data Data for encode.
|
||||||
|
*
|
||||||
|
* @return string Return 'PERCENTILE_BAR', 'PERCENTILE_BUBBLE',
|
||||||
|
* 'CIRCULAR_PROGRESS_BAR' or 'CIRCULAR_INTERIOR_PROGRESS_BAR'.
|
||||||
|
* 'PERCENTILE_BAR' by default.
|
||||||
|
*/
|
||||||
|
protected function encodeLabelColor(array $data): ?string
|
||||||
|
{
|
||||||
|
$labelColor = null;
|
||||||
|
if (isset($data['labelColor']) === true) {
|
||||||
|
switch ($data['labelColor']) {
|
||||||
|
case 'fillColor':
|
||||||
|
case 'fill_color':
|
||||||
|
case 'labelColor':
|
||||||
|
$labelColor = $data['labelColor'];
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$labelColor = '#444444';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $labelColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode type item.
|
||||||
|
*
|
||||||
|
* @param array $data Data for encode.
|
||||||
|
*
|
||||||
|
* @return string Return 'PERCENTILE_BAR', 'PERCENTILE_BUBBLE',
|
||||||
|
* 'CIRCULAR_PROGRESS_BAR' or 'CIRCULAR_INTERIOR_PROGRESS_BAR'.
|
||||||
|
* 'PERCENTILE_BAR' by default.
|
||||||
|
*/
|
||||||
|
protected function encodeColor(array $data): ?string
|
||||||
|
{
|
||||||
|
$color = null;
|
||||||
|
if (isset($data['color']) === true) {
|
||||||
|
switch ($data['color']) {
|
||||||
|
case 'borderColor':
|
||||||
|
case 'border_color':
|
||||||
|
case 'gridColor':
|
||||||
|
case 'color':
|
||||||
|
case 'legendBackgroundColor':
|
||||||
|
$color = $data['color'];
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$color = '#F0F0F0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a valid representation of a record in database.
|
* Return a valid representation of a record in database.
|
||||||
*
|
*
|
||||||
@ -126,6 +188,16 @@ final class Percentile extends Item
|
|||||||
$return['image'] = (string) $valueType;
|
$return['image'] = (string) $valueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$color = static::encodeColor($data);
|
||||||
|
if ($border_color !== null) {
|
||||||
|
$result['border_color'] = $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
$labelColor = static::encodeLabelColor($data);
|
||||||
|
if ($labelColor !== null) {
|
||||||
|
$result['fill_color'] = $labelColor;
|
||||||
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,30 +374,30 @@ final class Percentile extends Item
|
|||||||
// Get the value type.
|
// Get the value type.
|
||||||
$valueType = static::extractValueType($data);
|
$valueType = static::extractValueType($data);
|
||||||
|
|
||||||
if ($moduleId === null) {
|
if ($moduleId !== null && $moduleId !== 0) {
|
||||||
throw new \InvalidArgumentException('missing module Id');
|
// Maybe connect to node.
|
||||||
}
|
$nodeConnected = false;
|
||||||
|
if (\is_metaconsole() === true && $metaconsoleId !== null) {
|
||||||
|
$nodeConnected = \metaconsole_connect(
|
||||||
|
null,
|
||||||
|
$metaconsoleId
|
||||||
|
) === NOERR;
|
||||||
|
|
||||||
// Maybe connect to node.
|
if ($nodeConnected === false) {
|
||||||
$nodeConnected = false;
|
throw new \InvalidArgumentException(
|
||||||
if (\is_metaconsole() === true && $metaconsoleId !== null) {
|
'error connecting to the node'
|
||||||
$nodeConnected = \metaconsole_connect(
|
);
|
||||||
null,
|
}
|
||||||
$metaconsoleId
|
}
|
||||||
) === NOERR;
|
|
||||||
|
|
||||||
if ($nodeConnected === false) {
|
$moduleValue = \modules_get_last_value($moduleId);
|
||||||
|
if ($moduleValue === false) {
|
||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException(
|
||||||
'error connecting to the node'
|
'error fetching the module value'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
$moduleValue = 0;
|
||||||
$moduleValue = \modules_get_last_value($moduleId);
|
|
||||||
if ($moduleValue === false) {
|
|
||||||
throw new \InvalidArgumentException(
|
|
||||||
'error fetching the module value'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the module value.
|
// Store the module value.
|
||||||
@ -335,9 +407,12 @@ final class Percentile extends Item
|
|||||||
'.',
|
'.',
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
$unit = \modules_get_unit($moduleId);
|
$unit = '';
|
||||||
if (empty($unit) === false) {
|
if ($moduleId !== null && $moduleId !== 0) {
|
||||||
$data['unit'] = \io_safe_output($unit);
|
$unit = \modules_get_unit($moduleId);
|
||||||
|
if (empty($unit) === false) {
|
||||||
|
$data['unit'] = \io_safe_output($unit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore connection.
|
// Restore connection.
|
||||||
@ -349,4 +424,163 @@ final class Percentile 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
|
||||||
|
{
|
||||||
|
// Retrieve global - common inputs.
|
||||||
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
|
if (is_array($inputs) !== true) {
|
||||||
|
throw new Exception(
|
||||||
|
'[Percentile]::getFormInputs parent class return is not an array'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($values['tabSelected'] === 'specific') {
|
||||||
|
// Type percentile.
|
||||||
|
$fields = [
|
||||||
|
'progress-bar' => __('Percentile'),
|
||||||
|
'bubble' => __('Bubble'),
|
||||||
|
'circular-progress-bar' => __('Circular porgress bar'),
|
||||||
|
'circular-progress-bar-alt' => __(
|
||||||
|
'Circular progress bar (interior)'
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Type'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'fields' => $fields,
|
||||||
|
'name' => 'percentileType',
|
||||||
|
'selected' => $values['percentileType'],
|
||||||
|
'return' => true,
|
||||||
|
'sort' => false,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// 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[] = [
|
||||||
|
'label' => __('Min. Value'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'minValue',
|
||||||
|
'type' => 'number',
|
||||||
|
'value' => $values['minValue'],
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// TODO: ADD bbdd.
|
||||||
|
// Max Value.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Max. Value'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'maxValue',
|
||||||
|
'type' => 'number',
|
||||||
|
'value' => $values['maxValue'],
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Value to show.
|
||||||
|
$fields = [
|
||||||
|
'percent' => __('Percent'),
|
||||||
|
'value' => __('Value'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Value to show'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'fields' => $fields,
|
||||||
|
'name' => 'valueType',
|
||||||
|
'selected' => $values['valueType'],
|
||||||
|
'return' => true,
|
||||||
|
'sort' => false,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Element color.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Element color'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'color',
|
||||||
|
'type' => 'color',
|
||||||
|
'value' => $values['color'],
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Value color.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Value color'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'labelColor',
|
||||||
|
'type' => 'color',
|
||||||
|
'value' => $values['labelColor'],
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Autocomplete agents.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Agent'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'autocomplete_agent',
|
||||||
|
'name' => 'agentAlias',
|
||||||
|
'id_agent_hidden' => $values['agentId'],
|
||||||
|
'name_agent_hidden' => 'agentId',
|
||||||
|
'server_id_hidden' => $values['metaconsoleId'],
|
||||||
|
'name_server_hidden' => 'metaconsoleId',
|
||||||
|
'return' => true,
|
||||||
|
'module_input' => true,
|
||||||
|
'module_name' => 'moduleId',
|
||||||
|
'module_none' => 'false',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Autocomplete module.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Module'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'autocomplete_module',
|
||||||
|
'fields' => $fields,
|
||||||
|
'name' => 'moduleId',
|
||||||
|
'selected' => $values['moduleId'],
|
||||||
|
'return' => true,
|
||||||
|
'sort' => false,
|
||||||
|
'agent_id' => $values['agentId'],
|
||||||
|
'metaconsole_id' => $values['metaconsoleId'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// TODO:XXXX LinkConsoleInputGroup
|
||||||
|
}
|
||||||
|
|
||||||
|
return $inputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -244,13 +244,13 @@ final class StaticGraph extends Item
|
|||||||
/**
|
/**
|
||||||
* Generates inputs for form (specific).
|
* Generates inputs for form (specific).
|
||||||
*
|
*
|
||||||
* @param object $values Default values.
|
* @param array $values Default values.
|
||||||
*
|
*
|
||||||
* @return array Of inputs.
|
* @return array Of inputs.
|
||||||
*
|
*
|
||||||
* @throws Exception On error.
|
* @throws Exception On error.
|
||||||
*/
|
*/
|
||||||
public static function getFormInputs(object $values): array
|
public static function getFormInputs(array $values): array
|
||||||
{
|
{
|
||||||
// Retrieve global - common inputs.
|
// Retrieve global - common inputs.
|
||||||
$inputs = Item::getFormInputs($values);
|
$inputs = Item::getFormInputs($values);
|
||||||
@ -261,7 +261,7 @@ final class StaticGraph extends Item
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($values->tabSelected === 'specific') {
|
if ($values['tabSelected'] === 'specific') {
|
||||||
// List images VC.
|
// List images VC.
|
||||||
// TODO: Show images.
|
// TODO: Show images.
|
||||||
$inputs[] = [
|
$inputs[] = [
|
||||||
@ -270,7 +270,7 @@ final class StaticGraph extends Item
|
|||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'fields' => self::getListImagesVC(),
|
'fields' => self::getListImagesVC(),
|
||||||
'name' => 'imageSrc',
|
'name' => 'imageSrc',
|
||||||
'selected' => $values->imageSrc,
|
'selected' => $values['imageSrc'],
|
||||||
'return' => true,
|
'return' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@ -281,31 +281,33 @@ final class StaticGraph extends Item
|
|||||||
'arguments' => [
|
'arguments' => [
|
||||||
'type' => 'autocomplete_agent',
|
'type' => 'autocomplete_agent',
|
||||||
'name' => 'agentAlias',
|
'name' => 'agentAlias',
|
||||||
'id_agent_hidden' => $values->agentId,
|
'id_agent_hidden' => $values['agentId'],
|
||||||
'name_agent_hidden' => 'agentId',
|
'name_agent_hidden' => 'agentId',
|
||||||
'server_id_hidden' => $values->metaconsoleId,
|
'server_id_hidden' => $values['metaconsoleId'],
|
||||||
'name_server_hidden' => 'metaconsoleId',
|
'name_server_hidden' => 'metaconsoleId',
|
||||||
'return' => true,
|
'return' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Show Last Value.
|
||||||
$fields = [
|
$fields = [
|
||||||
'default' => __('Hide last value on boolean modules'),
|
'default' => __('Hide last value on boolean modules'),
|
||||||
'disabled' => __('Disabled'),
|
'disabled' => __('Disabled'),
|
||||||
'enabled' => __('Enabled'),
|
'enabled' => __('Enabled'),
|
||||||
];
|
];
|
||||||
|
|
||||||
// Show Last Value.
|
|
||||||
$inputs[] = [
|
$inputs[] = [
|
||||||
'label' => __('Show Last Value'),
|
'label' => __('Show Last Value'),
|
||||||
'arguments' => [
|
'arguments' => [
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'fields' => $fields,
|
'fields' => $fields,
|
||||||
'name' => 'showLastValueTooltip',
|
'name' => 'showLastValueTooltip',
|
||||||
'selected' => $values->showLastValueTooltip,
|
'selected' => $values['showLastValueTooltip'],
|
||||||
'return' => true,
|
'return' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// TODO:XXXX LinkConsoleInputGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
return $inputs;
|
return $inputs;
|
||||||
|
@ -32,6 +32,7 @@ use Models\VisualConsole\Container as VisualConsole;
|
|||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
require_once $config['homedir'].'/include/class/HTML.class.php';
|
require_once $config['homedir'].'/include/class/HTML.class.php';
|
||||||
|
enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global HTML generic class.
|
* Global HTML generic class.
|
||||||
@ -42,10 +43,14 @@ class View extends \HTML
|
|||||||
|
|
||||||
public function loadTabs()
|
public function loadTabs()
|
||||||
{
|
{
|
||||||
|
$type = get_parameter('type', 0);
|
||||||
|
$itemId = (int) get_parameter('itemId', 0);
|
||||||
|
|
||||||
$url = ui_get_full_url(false, false, false, false);
|
$url = ui_get_full_url(false, false, false, false);
|
||||||
$url .= 'ajax.php?page=include/rest-api/index';
|
$url .= 'ajax.php?page=include/rest-api/index';
|
||||||
$url .= '&loadtabs=1';
|
$url .= '&loadtabs=1';
|
||||||
$url .= '&item='.get_parameter('item', null);
|
$url .= '&type='.$type;
|
||||||
|
$url .= '&itemId='.$itemId;
|
||||||
|
|
||||||
$tabs = [
|
$tabs = [
|
||||||
[
|
[
|
||||||
@ -83,10 +88,11 @@ class View extends \HTML
|
|||||||
});
|
});
|
||||||
ui.jqXHR.fail(function () {
|
ui.jqXHR.fail(function () {
|
||||||
ui.panel.html(
|
ui.panel.html(
|
||||||
"Couldn\'t load Data. Plz Reload Page or Try Again Later.");
|
"Couldn\'t load Data. Plz Reload Page or Try Again Later."
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
active: 2
|
||||||
});';
|
});';
|
||||||
$js .= '});';
|
$js .= '});';
|
||||||
$js .= '</script>';
|
$js .= '</script>';
|
||||||
@ -106,18 +112,9 @@ class View extends \HTML
|
|||||||
{
|
{
|
||||||
// Load desired form based on item type.
|
// Load desired form based on item type.
|
||||||
$values = [];
|
$values = [];
|
||||||
$item = null;
|
$type = get_parameter('type', null);
|
||||||
$item_json = get_parameter('item', null);
|
$tabSelected = get_parameter('tabSelected', 'label');
|
||||||
$item = json_decode(io_safe_output($item_json));
|
$itemId = (int) get_parameter('itemId', 0);
|
||||||
|
|
||||||
$type = null;
|
|
||||||
if (isset($item) === true) {
|
|
||||||
$values = $item->itemProps;
|
|
||||||
$values->tabSelected = get_parameter('tabSelected', 'label');
|
|
||||||
$type = $values->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
hd($values->tabSelected, true);
|
|
||||||
|
|
||||||
$itemClass = VisualConsole::getItemClass($type);
|
$itemClass = VisualConsole::getItemClass($type);
|
||||||
|
|
||||||
@ -132,10 +129,19 @@ class View extends \HTML
|
|||||||
$form = [
|
$form = [
|
||||||
'action' => '#',
|
'action' => '#',
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'id' => 'itemForm-'.$values->tabSelected,
|
'id' => 'itemForm-'.$tabSelected,
|
||||||
'class' => 'discovery modal',
|
'class' => 'discovery modal',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($itemId !== 0) {
|
||||||
|
$item = VisualConsole::getItemFromDB($itemId);
|
||||||
|
$values = $item->toArray();
|
||||||
|
} else {
|
||||||
|
$values['type'] = $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
$values['tabSelected'] = $tabSelected;
|
||||||
|
|
||||||
// Retrieve inputs.
|
// Retrieve inputs.
|
||||||
$inputs = $itemClass::getFormInputs($values);
|
$inputs = $itemClass::getFormInputs($values);
|
||||||
|
|
||||||
@ -148,7 +154,24 @@ class View extends \HTML
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
return $form;
|
// TODO:XXX very ugly.
|
||||||
|
$jsforms = '<script>';
|
||||||
|
$jsforms .= "function typeModuleGraph(type){
|
||||||
|
if (type == 'module') {
|
||||||
|
$('#MGautoCompleteAgent').show();
|
||||||
|
$('#MGautoCompleteModule').show();
|
||||||
|
$('#MGcustomGraph').hide();
|
||||||
|
$('#customGraphId').val(0);
|
||||||
|
}
|
||||||
|
else if (type == 'custom') {
|
||||||
|
$('#MGautoCompleteAgent').hide();
|
||||||
|
$('#MGautoCompleteModule').hide();
|
||||||
|
$('#MGcustomGraph').show();
|
||||||
|
}
|
||||||
|
}";
|
||||||
|
$jsforms .= '</script>';
|
||||||
|
|
||||||
|
return $form.$jsforms;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,28 +184,24 @@ class View extends \HTML
|
|||||||
public function processForm()
|
public function processForm()
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
hd('++++++++++++++++++++++++++++++++++++', true);
|
|
||||||
hd($_POST, true);
|
|
||||||
hd('++++++++++++++++++++++++++++++++++++', true);
|
|
||||||
|
|
||||||
$item = json_decode(io_safe_output(\get_parameter('item')), true);
|
|
||||||
|
|
||||||
// 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);
|
||||||
|
$itemId = (int) get_parameter('itemId', 0);
|
||||||
|
|
||||||
$data['type'] = $item['itemProps']['type'];
|
// Type.
|
||||||
|
$data['type'] = $type;
|
||||||
|
|
||||||
// Page Label.
|
// Page Label for each item.
|
||||||
$data['label'] = \get_parameter('label');
|
$data['label'] = \get_parameter('label');
|
||||||
|
|
||||||
// Page general.
|
// Page general for each item.
|
||||||
$data['width'] = \get_parameter('width');
|
$data['width'] = \get_parameter('width');
|
||||||
$data['height'] = \get_parameter('height');
|
$data['height'] = \get_parameter('height');
|
||||||
$data['x'] = \get_parameter('x');
|
$data['x'] = \get_parameter('x');
|
||||||
$data['y'] = \get_parameter('y');
|
$data['y'] = \get_parameter('y');
|
||||||
$data['isLinkEnabled'] = \get_parameter('isLinkEnabled');
|
$data['isLinkEnabled'] = \get_parameter_switch('isLinkEnabled', 0);
|
||||||
$data['isOnTop'] = \get_parameter('isOnTop');
|
$data['isOnTop'] = \get_parameter_switch('isOnTop', 0);
|
||||||
$data['parentId'] = \get_parameter('parentId');
|
$data['parentId'] = \get_parameter('parentId');
|
||||||
$data['aclGroupId'] = \get_parameter('aclGroupId');
|
$data['aclGroupId'] = \get_parameter('aclGroupId');
|
||||||
$data['cacheExpiration_select'] = \get_parameter(
|
$data['cacheExpiration_select'] = \get_parameter(
|
||||||
@ -194,21 +213,97 @@ class View extends \HTML
|
|||||||
'cacheExpiration_units'
|
'cacheExpiration_units'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Page specific.
|
// Page specific data for each item.
|
||||||
$data['imageSrc'] = \get_parameter('imageSrc');
|
switch ($type) {
|
||||||
$data['agentId'] = \get_parameter('agentId');
|
case STATIC_GRAPH:
|
||||||
$data['metaconsoleId'] = \get_parameter('metaconsoleId');
|
$data['imageSrc'] = \get_parameter('imageSrc');
|
||||||
$data['agentAlias'] = \get_parameter('agentAlias');
|
$data['agentId'] = \get_parameter('agentId');
|
||||||
$data['showLastValueTooltip'] = \get_parameter('showLastValueTooltip');
|
$data['metaconsoleId'] = \get_parameter('metaconsoleId');
|
||||||
|
$data['agentAlias'] = \get_parameter('agentAlias');
|
||||||
|
$data['showLastValueTooltip'] = \get_parameter(
|
||||||
|
'showLastValueTooltip'
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
if (isset($item['itemProps']['id']) === false) {
|
case MODULE_GRAPH:
|
||||||
|
$data['backgroundType'] = \get_parameter('backgroundType');
|
||||||
|
$data['agentId'] = \get_parameter('agentId');
|
||||||
|
$data['metaconsoleId'] = \get_parameter('metaconsoleId');
|
||||||
|
$data['agentAlias'] = \get_parameter('agentAlias');
|
||||||
|
$data['moduleId'] = \get_parameter('moduleId');
|
||||||
|
$data['customGraphId'] = \get_parameter('customGraphId');
|
||||||
|
$data['graphType'] = \get_parameter('graphType');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SIMPLE_VALUE:
|
||||||
|
case SIMPLE_VALUE_MAX:
|
||||||
|
case SIMPLE_VALUE_MIN:
|
||||||
|
case SIMPLE_VALUE_AVG:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERCENTILE_BAR:
|
||||||
|
case PERCENTILE_BUBBLE:
|
||||||
|
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');
|
||||||
|
$data['color'] = \get_parameter('color');
|
||||||
|
$data['labelColor'] = \get_parameter('labelColor');
|
||||||
|
$data['agentId'] = \get_parameter('agentId');
|
||||||
|
$data['metaconsoleId'] = \get_parameter('metaconsoleId');
|
||||||
|
$data['agentAlias'] = \get_parameter('agentAlias');
|
||||||
|
$data['moduleId'] = \get_parameter('moduleId');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LABEL:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ICON:
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Enterprise item. It may not exist.
|
||||||
|
case SERVICE:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GROUP_ITEM:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BOX_ITEM:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LINE_ITEM:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUTO_SLA_GRAPH:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DONUT_GRAPH:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BARS_GRAPH:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CLOCK:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COLOR_CLOUD:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($itemId) === false || $itemId === 0) {
|
||||||
|
// TODO: ACL.
|
||||||
// CreateVC.
|
// CreateVC.
|
||||||
$class = VisualConsole::getItemClass((int) $data['type']);
|
$class = VisualConsole::getItemClass((int) $data['type']);
|
||||||
try {
|
try {
|
||||||
// Save the new item.
|
// Save the new item.
|
||||||
$data['id_layout'] = $vCId;
|
$data['id_layout'] = $vCId;
|
||||||
$itemId = $class::save($data);
|
$itemId = $class::save($data);
|
||||||
hd('he creado:'.$itemId, true);
|
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
// Bad params.
|
// Bad params.
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
@ -226,8 +321,6 @@ class View extends \HTML
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// UpdateVC.
|
// UpdateVC.
|
||||||
$itemId = $item['itemProps']['id'];
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$item = VisualConsole::getItemFromDB($itemId);
|
$item = VisualConsole::getItemFromDB($itemId);
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
@ -278,7 +371,6 @@ class View extends \HTML
|
|||||||
$data['id_layout'] = $vCId;
|
$data['id_layout'] = $vCId;
|
||||||
$data['id'] = $itemId;
|
$data['id'] = $itemId;
|
||||||
$item->save($data);
|
$item->save($data);
|
||||||
hd('he actualizado: '.$itemId, true);
|
|
||||||
$result = $item->toArray();
|
$result = $item->toArray();
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
// There is no item in the database.
|
// There is no item in the database.
|
||||||
@ -288,7 +380,6 @@ class View extends \HTML
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hd($result, true);
|
|
||||||
return json_encode($result);
|
return json_encode($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user