Fixed items vc line

This commit is contained in:
Daniel Barbero Martin 2020-01-07 18:07:07 +01:00
parent b49dd76ce4
commit da01883902
4 changed files with 128 additions and 10 deletions

View File

@ -1408,10 +1408,6 @@ function createOrUpdateVisualConsoleItem(
name: "itemId",
value: item.itemProps.id ? item.itemProps.id : 0
}
/*{
name: "elementsVc",
value: elementsVc
}*/
],
onshow: {
page: "include/rest-api/index",

View File

@ -3,6 +3,7 @@
declare(strict_types=1);
namespace Models\VisualConsole;
use Models\VisualConsole\Container as VC;
use Models\CachedModel;
/**
@ -2003,9 +2004,91 @@ class Item extends CachedModel
];
// Parent.
// TODO:XXX
$fields = get_parameter('elementsVc', []);
// Check groups can access user.
$aclUserGroups = [];
if (!\users_can_manage_group_all('AR')) {
$aclUserGroups = array_keys(
\users_get_groups(false, 'AR')
);
}
$vcItems = VC::getItemsFromDB(
$values['vCId'],
$aclUserGroups
);
$fields = [];
$fields[0] = __('None');
foreach ($vcItems as $key => $value) {
$data = $value->toArray();
switch ($data['type']) {
case STATIC_GRAPH:
$text = __('Static graph');
$text .= ' - ';
$text .= $data['imageSrc'];
break;
case MODULE_GRAPH:
$text = __('Module graph');
break;
case CLOCK:
$text = __('Clock');
break;
case BARS_GRAPH:
$text = __('Bars graph');
break;
case AUTO_SLA_GRAPH:
$text = __('Auto SLA Graph');
break;
case PERCENTILE_BAR:
$text = __('Percentile bar');
break;
case CIRCULAR_PROGRESS_BAR:
$text = __('Circular progress bar');
break;
case CIRCULAR_INTERIOR_PROGRESS_BAR:
$text = __('Circular progress bar (interior)');
break;
case SIMPLE_VALUE:
$text = __('Simple Value');
break;
case LABEL:
$text = __('Label');
break;
case GROUP_ITEM:
$text = __('Group');
break;
case COLOR_CLOUD:
$text = __('Color cloud');
break;
case ICON:
$text = __('Icon');
break;
default:
$text = __('Item');
break;
}
if (isset($data['agentAlias']) === true
&& empty($data['agentAlias']) === false
) {
$text .= ' ('.$data['agentAlias'].')';
}
$fields[$data['id']] = $text;
}
$inputs[] = [
'label' => __('Parent'),

View File

@ -431,4 +431,37 @@ final class Line extends Model
}
/**
* Generates inputs for form (global, common).
*
* @param array $values Default values.
*
* @return array Of inputs.
*/
public static function getFormInputs(array $values): array
{
$inputs = [];
switch ($values['tabSelected']) {
// Position.
case 'label':
// Label.
// TODO tinyMCE.
$inputs[] = [
'label' => __('Label'),
'id' => 'div-label',
'arguments' => [
'name' => 'label',
'type' => 'text',
'value' => $values['label'],
'return' => true,
],
];
break;
}
return $inputs;
}
}

View File

@ -41,13 +41,17 @@ class View extends \HTML
{
/**
* Tabs.
*
* @return string
*/
public function loadTabs()
{
$type = (int) \get_parameter('type', 0);
$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=2';
@ -138,12 +142,14 @@ class View extends \HTML
$itemClass = VisualConsole::getItemClass($type);
if (!isset($itemClass)) {
if (isset($itemClass) === false) {
throw new \Exception(__('Item type not valid ['.$type.']'));
}
if (\method_exists($itemClass, 'getFormInputs') === false) {
throw new \Exception(__('Item type has no getFormInputs method ['.$type.']'));
throw new \Exception(
__('Item type has no getFormInputs method ['.$type.']')
);
}
$form = [