Fixed form php VC

This commit is contained in:
Daniel Barbero 2019-12-20 13:58:47 +01:00
parent f08e92b6ad
commit d4207ef67c
13 changed files with 738 additions and 35 deletions

View File

@ -1420,7 +1420,6 @@ function createOrUpdateVisualConsoleItem(
title = "Update item";
}
// var props = item.props || {};
/*
var elementsVc = visualConsole.elements
.filter(function(item) {
@ -1433,7 +1432,6 @@ function createOrUpdateVisualConsoleItem(
};
});
*/
load_modal({
target: $("#modalVCItemForm"),
form: ["itemForm-label", "itemForm-general", "itemForm-specific"],
@ -1478,7 +1476,7 @@ function createOrUpdateVisualConsoleItem(
/*{
name: "elementsVc",
value: elementsVc
},*/
}*/
],
onshow: {
page: "include/rest-api/index",

View File

@ -338,4 +338,109 @@ final class BarsGraph 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(
'[BarsGraph]::getFormInputs parent class return is not an array'
);
}
if ($values['tabSelected'] === 'specific') {
// Background color.
$fields = [
'white' => __('White'),
'black' => __('Black'),
'transparent' => __('Transparent'),
];
$inputs[] = [
'label' => __('Background color'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'backgroundColor',
'selected' => $values['backgroundColor'],
'return' => true,
'sort' => false,
],
];
// Graph Type.
$fields = [
'horizontal' => __('Horizontal'),
'vertical' => __('Vertical'),
];
$inputs[] = [
'label' => __('Graph Type'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'typeGraph',
'selected' => $values['typeGraph'],
'return' => true,
],
];
// Grid color.
$inputs[] = [
'label' => __('Grid color'),
'arguments' => [
'name' => 'gridColor',
'type' => 'color',
'value' => $values['gridColor'],
'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'],
],
];
}
return $inputs;
}
}

View File

@ -82,4 +82,63 @@ final class Box 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(
'[Box]::getFormInputs parent class return is not an array'
);
}
if ($values['tabSelected'] === 'specific') {
// Border color.
$inputs[] = [
'label' => __('Border color'),
'arguments' => [
'name' => 'borderColor',
'type' => 'color',
'value' => $values['borderColor'],
'return' => true,
],
];
// Border Width.
$inputs[] = [
'label' => __('Border Width'),
'arguments' => [
'name' => 'borderWidth',
'type' => 'number',
'value' => $values['borderWidth'],
'return' => true,
],
];
// Fill color.
$inputs[] = [
'label' => __('Fill color'),
'arguments' => [
'name' => 'fillColor',
'type' => 'color',
'value' => $values['fillColor'],
'return' => true,
],
];
}
return $inputs;
}
}

View File

@ -151,4 +151,114 @@ final class Clock 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(
'[Clock]::getFormInputs parent class return is not an array'
);
}
if ($values['tabSelected'] === 'specific') {
// Clock animation.
$fields = [
'analogic' => __('Simple analogic'),
'digital' => __('Simple digital'),
];
$inputs[] = [
'label' => __('Clock animation'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'clockType',
'selected' => $values['clockType'],
'return' => true,
'sort' => false,
],
];
// Time format.
$fields = [
'time' => __('Only time'),
'datetime' => __('Time and date'),
];
$inputs[] = [
'label' => __('Time format'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'clockFormat',
'selected' => $values['clockFormat'],
'return' => true,
'sort' => false,
],
];
// Width.
$inputs[] = [
'label' => __('Width'),
'arguments' => [
'name' => 'width',
'type' => 'number',
'value' => $values['width'],
'return' => true,
],
];
// Time zone.
$fields = [
'Africa' => __('Africa'),
'America' => __('America'),
'Antarctica' => __('Antarctica'),
'Arctic' => __('Arctic'),
'Asia' => __('Asia'),
'Atlantic' => __('Atlantic'),
'Australia' => __('Australia'),
'Europe' => __('Europe'),
'Indian' => __('Indian'),
'Pacific' => __('Pacific'),
'UTC' => __('UTC'),
];
$inputs[] = [
'label' => __('Time zone'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'clockTimezone',
'selected' => $values['clockTimezone'],
'return' => true,
],
];
// Element color.
$inputs[] = [
'label' => __('Fill color'),
'arguments' => [
'name' => 'color',
'type' => 'color',
'value' => $values['color'],
'return' => true,
],
];
}
return $inputs;
}
}

View File

@ -190,4 +190,75 @@ final class DonutGraph 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(
'[DonutGraph]::getFormInputs parent class return is not an array'
);
}
if ($values['tabSelected'] === 'specific') {
// 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'],
],
];
// Resume data color.
$inputs[] = [
'label' => __('Resume data color'),
'arguments' => [
'name' => 'legendBackgroundColor',
'type' => 'color',
'value' => $values['legendBackgroundColor'],
'return' => true,
],
];
// TODO:XXXX LinkConsoleInputGroup
}
return $inputs;
}
}

View File

@ -156,4 +156,85 @@ final class EventsHistory 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(
'[EventHistory]::getFormInputs parent class return is not an array'
);
}
if ($values['tabSelected'] === 'specific') {
// 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'],
],
];
// Type percentile.
$fields = [
'86400' => __('24h'),
'43200' => __('12h'),
'28800' => __('8h'),
'7200' => __('2h'),
'3600' => __('1h'),
];
$inputs[] = [
'label' => __('Max. Time'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'maxTime',
'selected' => $values['maxTime'],
'return' => true,
'sort' => false,
],
];
// TODO:XXXX LinkConsoleInputGroup.
}
return $inputs;
}
}

View File

@ -447,4 +447,56 @@ final class Group 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(
'[Group]::getFormInputs parent class return is not an array'
);
}
if ($values['tabSelected'] === 'specific') {
// List images VC.
// TODO: Show images.
$inputs[] = [
'label' => __('Image'),
'arguments' => [
'type' => 'select',
'fields' => self::getListImagesVC(),
'name' => 'imageSrc',
'selected' => $values['imageSrc'],
'return' => true,
],
];
// Show statistics.
$inputs[] = [
'label' => __('Show statistics'),
'arguments' => [
'name' => 'showStatistics',
'id' => 'showStatistics',
'type' => 'switch',
'value' => $values['showStatistics'],
],
];
// TODO:XXXX LinkConsoleInputGroup
}
return $inputs;
}
}

View File

@ -129,4 +129,45 @@ final class Icon 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(
'[Icon]::getFormInputs parent class return is not an array'
);
}
if ($values['tabSelected'] === 'specific') {
// List images VC.
// TODO: Show images.
$inputs[] = [
'label' => __('Image'),
'arguments' => [
'type' => 'select',
'fields' => self::getListImagesVC(),
'name' => 'imageSrc',
'selected' => $values['imageSrc'],
'return' => true,
],
];
// TODO:XXXX LinkConsoleInputGroup
}
return $inputs;
}
}

View File

@ -333,7 +333,7 @@ final class ModuleGraph extends Item
}
if ($values['tabSelected'] === 'specific') {
// Type percentile.
// Background color.
$fields = [
'white' => __('White'),
'black' => __('Black'),
@ -352,15 +352,15 @@ final class ModuleGraph extends Item
],
];
$classModule = '';
$classCustom = 'displayNone';
$hiddenModule = false;
$hiddenCustom = true;
$checkedModule = true;
$checkedCustom = false;
if (isset($values['customGraphId']) === true
&& $values['customGraphId'] !== 0
) {
$classModule = 'displayNone';
$classCustom = '';
$hiddenModule = true;
$hiddenCustom = false;
$checkedModule = false;
$checkedCustom = true;
}
@ -401,7 +401,7 @@ final class ModuleGraph extends Item
// Autocomplete agents.
$inputs[] = [
'id' => 'MGautoCompleteAgent',
'class' => $classModule,
'hidden' => $hiddenModule,
'label' => __('Agent'),
'arguments' => [
'type' => 'autocomplete_agent',
@ -420,7 +420,7 @@ final class ModuleGraph extends Item
// Autocomplete module.
$inputs[] = [
'id' => 'MGautoCompleteModule',
'class' => $classModule,
'hidden' => $hiddenModule,
'label' => __('Module'),
'arguments' => [
'type' => 'autocomplete_module',
@ -438,7 +438,7 @@ final class ModuleGraph extends Item
$fields = self::getListCustomGraph();
$inputs[] = [
'id' => 'MGcustomGraph',
'class' => $classCustom,
'hidden' => $hiddenCustom,
'label' => __('Custom graph'),
'arguments' => [
'type' => 'select',

View File

@ -296,4 +296,84 @@ final class SimpleValue 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(
'[SimpleValue]::getFormInputs parent class return is not an array'
);
}
if ($values['tabSelected'] === 'specific') {
// 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'],
],
];
// Process.
$fields = [
'none' => __('None'),
'avg' => __('Avg Value'),
'max' => __('Max Value'),
'min' => __('Min Value'),
];
$inputs[] = [
'label' => __('Process'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'processValue',
'selected' => $values['processValue'],
'return' => true,
'sort' => false,
],
];
// TODO:XXXX LinkConsoleInputGroup
}
return $inputs;
}
}

View File

@ -43,14 +43,18 @@ class View extends \HTML
public function loadTabs()
{
$type = get_parameter('type', 0);
$itemId = (int) get_parameter('itemId', 0);
$type = (int) \get_parameter('type', 0);
hd($type, true);
$itemId = (int) \get_parameter('itemId', 0);
$vCId = (int) \get_parameter('vCId', 0);
// TODO:XXX;
// $elementsVc = io_safe_output(\get_parameter('elementsVc'));
$url = ui_get_full_url(false, false, false, false);
$url .= 'ajax.php?page=include/rest-api/index';
$url .= '&loadtabs=1';
$url .= '&loadtabs=2';
$url .= '&type='.$type;
$url .= '&itemId='.$itemId;
$url .= '&vCId='.$vCId;
$tabs = [
[
@ -71,6 +75,22 @@ class View extends \HTML
],
];
if ($type === LABEL) {
$tabs = [
[
'name' => __('Label settings'),
'id' => 'tab-label',
'href' => $url.'&tabSelected=label',
'img' => 'zoom.png',
],[
'name' => __('General settings'),
'id' => 'tab-general',
'href' => $url.'&tabSelected=general',
'img' => 'pencil.png',
],
];
}
$result = html_print_tabs($tabs);
// TODO:Change other place.
@ -115,6 +135,7 @@ class View extends \HTML
$type = get_parameter('type', null);
$tabSelected = get_parameter('tabSelected', 'label');
$itemId = (int) get_parameter('itemId', 0);
$vCId = (int) \get_parameter('vCId', 0);
$itemClass = VisualConsole::getItemClass($type);
@ -157,6 +178,9 @@ class View extends \HTML
// TODO:XXX very ugly.
$jsforms = '<script>';
$jsforms .= "function typeModuleGraph(type){
$('#MGautoCompleteAgent').removeClass('hidden');
$('#MGautoCompleteModule').removeClass('hidden');
$('#MGcustomGraph').removeClass('hidden');
if (type == 'module') {
$('#MGautoCompleteAgent').show();
$('#MGautoCompleteModule').show();
@ -183,6 +207,8 @@ class View extends \HTML
*/
public function processForm()
{
hd($_POST, true);
global $config;
// Inserted data in new item.
$vCId = \get_parameter('vCId', 0);
@ -219,7 +245,6 @@ class View extends \HTML
$data['imageSrc'] = \get_parameter('imageSrc');
$data['agentId'] = \get_parameter('agentId');
$data['metaconsoleId'] = \get_parameter('metaconsoleId');
$data['agentAlias'] = \get_parameter('agentAlias');
$data['showLastValueTooltip'] = \get_parameter(
'showLastValueTooltip'
);
@ -229,7 +254,6 @@ class View extends \HTML
$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');
@ -239,6 +263,10 @@ class View extends \HTML
case SIMPLE_VALUE_MAX:
case SIMPLE_VALUE_MIN:
case SIMPLE_VALUE_AVG:
$data['agentId'] = \get_parameter('agentId');
$data['metaconsoleId'] = \get_parameter('metaconsoleId');
$data['moduleId'] = \get_parameter('moduleId');
$data['processValue'] = \get_parameter('processValue');
break;
case PERCENTILE_BAR:
@ -254,45 +282,79 @@ class View extends \HTML
$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:
// Nothing. no specific items.
break;
case ICON:
$data['imageSrc'] = \get_parameter('imageSrc');
break;
// Enterprise item. It may not exist.
case SERVICE:
// TODO:Enterprise item. It may not exist.
break;
case GROUP_ITEM:
$data['imageSrc'] = \get_parameter('imageSrc');
$data['showStatistics'] = \get_parameter_switch(
'showStatistics',
0
);
break;
case BOX_ITEM:
$data['borderColor'] = \get_parameter('borderColor');
$data['borderWidth'] = \get_parameter('borderWidth');
$data['fillColor'] = \get_parameter('fillColor');
break;
case LINE_ITEM:
// Nothing. no specific items.
break;
case AUTO_SLA_GRAPH:
$data['agentId'] = \get_parameter('agentId');
$data['metaconsoleId'] = \get_parameter('metaconsoleId');
$data['agentAlias'] = \get_parameter('agentAlias');
$data['moduleId'] = \get_parameter('moduleId');
$data['maxTime'] = \get_parameter('maxTime');
break;
case DONUT_GRAPH:
$data['agentId'] = \get_parameter('agentId');
$data['metaconsoleId'] = \get_parameter('metaconsoleId');
$data['moduleId'] = \get_parameter('moduleId');
$data['legendBackgroundColor'] = \get_parameter(
'legendBackgroundColor'
);
break;
case BARS_GRAPH:
$data['backgroundColor'] = \get_parameter('backgroundColor');
$data['typeGraph'] = \get_parameter('typeGraph');
$data['gridColor'] = \get_parameter('gridColor');
$data['agentId'] = \get_parameter('agentId');
$data['metaconsoleId'] = \get_parameter('metaconsoleId');
$data['moduleId'] = \get_parameter('moduleId');
break;
case CLOCK:
$data['clockType'] = \get_parameter('clockType');
$data['clockFormat'] = \get_parameter('clockFormat');
$data['width'] = \get_parameter('width');
$data['clockTimezone'] = \get_parameter('clockTimezone');
$data['color'] = \get_parameter('color');
break;
case COLOR_CLOUD:
// TODO:XXX.
break;
default:
// Not posible.
break;
}

View File

@ -31,7 +31,7 @@ li.discovery > a label {
}
div.data_container > label {
font-family: "lato-bolder", "Open Sans", sans-serif;
font-family: "lato", "Open Sans", sans-serif;
font-weight: lighter;
}
@ -204,7 +204,9 @@ label {
width: 100%;
}
li > input[type="number"],
li > input[type="text"],
li > input[type="email"],
li > input[type="password"],
.discovery_text_input > input[type="password"],
.discovery_text_input > input[type="text"],
@ -274,17 +276,14 @@ a.ext_link {
/*
* Discovery > Wizard css global style
*/
ul.wizard {
}
ul.wizard li {
padding-bottom: 10px;
padding-top: 10px;
margin-right: 1em;
}
ul.wizard li > label:not(.p-switch) {
width: 250px;
width: auto;
vertical-align: top;
display: inline-block;
}
@ -300,8 +299,8 @@ ul.wizard li > textarea {
display: none;
}
ul.wizard li > label:not(.p-switch) {
width: auto;
form.modal ul.wizard li.hidden {
display: none;
}
form.top-action-buttons ul.wizard {
@ -309,10 +308,6 @@ form.top-action-buttons ul.wizard {
flex-direction: row;
}
ul.wizard li {
margin-right: 1em;
}
form.modal ul.wizard li {
display: flex;
flex-direction: row;
@ -329,3 +324,56 @@ ul.wizard li.flex-indep {
flex: 1;
margin: 0;
}
/* Tooltip message errors*/
div.ui-tooltip.ui-corner-all.ui-widget-shadow.ui-widget.ui-widget-content.uitooltip {
background: grey;
opacity: 0.9;
border-radius: 4px;
box-shadow: 6px 5px 9px -9px black;
padding: 6px;
}
.ui-tooltip-content {
background: transparent;
color: #fff;
font-weight: bold;
font-family: "lato-lighter", "Open Sans", sans-serif;
letter-spacing: 0.03pt;
font-size: 8pt;
}
.arrow {
width: 70px;
height: 16px;
overflow: hidden;
position: absolute;
left: 50%;
margin-left: -35px;
bottom: -16px;
}
.arrow.top {
top: -16px;
bottom: auto;
}
.arrow.left {
left: 50%;
}
.arrow:after {
background: grey;
content: "";
position: absolute;
left: 20px;
top: -20px;
width: 25px;
height: 25px;
box-shadow: 6px 5px 9px -9px black;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.arrow.top:after {
bottom: -20px;
top: auto;
}
/* END Tooltip message errors*/

View File

@ -6015,7 +6015,3 @@ form#modal_form_feedback ul.wizard li > textarea {
#controls_table > tbody > tr > td input {
margin-left: 3px;
}
.displayNone {
display: none;
}