';
foreach ($column['inputs'] as $input) {
if (is_array($input)) {
@@ -669,15 +949,45 @@ class HTML
/**
- * Dumps html string to output.
+ * Print a big button element (huge image, big text and link).
*
- * @param mixed $html HTML content to be printed.
+ * @param array $data Element data (link, image...).
*
- * @return void
+ * @return void Only prints the element.
*/
- public function render($html)
+ public static function printBigButtonElement($data)
{
- echo $html;
+ if (isset($data['url']) === false) {
+ $data['url'] = '#';
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+ ';
+ array_map('self::printBigButtonElement', $list_data);
+ echo '';
}
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index 9bf4ae2be3..21e6dca02d 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -3793,3 +3793,25 @@ function html_print_autocomplete_users_from_integria(
echo $output;
}
}
+
+
+function html_print_tabs(array $tabs)
+{
+ $result = '
';
+ $result .= '
';
+
+ $result .= '
';
+
+ return $result;
+}
diff --git a/pandora_console/include/javascript/pandora_visual_console.js b/pandora_console/include/javascript/pandora_visual_console.js
index 8eb7a0a1a9..2710953cbd 100755
--- a/pandora_console/include/javascript/pandora_visual_console.js
+++ b/pandora_console/include/javascript/pandora_visual_console.js
@@ -1423,6 +1423,20 @@ function createOrUpdateVisualConsoleItem(
title = "Update item";
}
// var props = item.props || {};
+
+ /*
+ var elementsVc = visualConsole.elements
+ .filter(function(item) {
+ return item.props.id;
+ })
+ .map(function(item) {
+ return {
+ value: item.props.id,
+ text: VisualConsole.itemDescriptiveName(item)
+ };
+ });
+ */
+
load_modal({
target: $("#modalVCItemForm"),
form: "itemForm",
@@ -1448,11 +1462,19 @@ function createOrUpdateVisualConsoleItem(
{
name: "item",
value: item
+ },
+ /*{
+ name: "elementsVc",
+ value: elementsVc
+ },*/
+ {
+ name: "vCId",
+ value: visualConsole.props.id
}
],
onshow: {
page: "include/rest-api/index",
- method: "loadForm"
+ method: "loadTabs"
},
onsubmit: {
page: "include/rest-api/index",
diff --git a/pandora_console/include/rest-api/index.php b/pandora_console/include/rest-api/index.php
index 6a9a1e582b..20c60b2707 100644
--- a/pandora_console/include/rest-api/index.php
+++ b/pandora_console/include/rest-api/index.php
@@ -55,25 +55,29 @@ $serviceListVisualConsole = (bool) get_parameter(
'serviceListVisualConsole'
);
+$loadtabs = (bool) get_parameter('loadtabs');
+
ob_clean();
-// Retrieve the visual console.
-$visualConsole = VisualConsole::fromDB(['id' => $visualConsoleId]);
-$visualConsoleData = $visualConsole->toArray();
-$vcGroupId = $visualConsoleData['groupId'];
+if ($visualConsoleId) {
+ // Retrieve the visual console.
+ $visualConsole = VisualConsole::fromDB(['id' => $visualConsoleId]);
+ $visualConsoleData = $visualConsole->toArray();
+ $vcGroupId = $visualConsoleData['groupId'];
-// ACL.
-$aclRead = check_acl($config['id_user'], $vcGroupId, 'VR');
-$aclWrite = check_acl($config['id_user'], $vcGroupId, 'VW');
-$aclManage = check_acl($config['id_user'], $vcGroupId, 'VM');
+ // ACL.
+ $aclRead = check_acl($config['id_user'], $vcGroupId, 'VR');
+ $aclWrite = check_acl($config['id_user'], $vcGroupId, 'VW');
+ $aclManage = check_acl($config['id_user'], $vcGroupId, 'VM');
-if (!$aclRead && !$aclWrite && !$aclManage) {
- db_pandora_audit(
- 'ACL Violation',
- 'Trying to access visual console without group access'
- );
- http_response_code(403);
- return;
+ if (!$aclRead && !$aclWrite && !$aclManage) {
+ db_pandora_audit(
+ 'ACL Violation',
+ 'Trying to access visual console without group access'
+ );
+ http_response_code(403);
+ return;
+ }
}
if ($getVisualConsole === true) {
@@ -568,6 +572,11 @@ if ($getVisualConsole === true) {
);
echo io_safe_output(json_encode($services));
+ return;
+} else if ($loadtabs) {
+ $viewer = new Viewer();
+ echo $viewer->loadForm();
+
return;
}
diff --git a/pandora_console/include/rest-api/models/VisualConsole/Item.php b/pandora_console/include/rest-api/models/VisualConsole/Item.php
index 9f0c9f75bd..798c97c145 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/Item.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/Item.php
@@ -1699,18 +1699,15 @@ class Item extends CachedModel
*/
protected static function getImageSrc(array $data)
{
- $imageSrc = static::notEmptyStringOr(
- static::issetInArray(
- $data,
- [
- 'image',
- 'imageSrc',
- 'backgroundColor',
- 'backgroundType',
- 'valueType',
- ]
- ),
- null
+ $imageSrc = static::issetInArray(
+ $data,
+ [
+ 'image',
+ 'imageSrc',
+ 'backgroundColor',
+ 'backgroundType',
+ 'valueType',
+ ]
);
return $imageSrc;
@@ -1898,29 +1895,156 @@ class Item extends CachedModel
{
$inputs = [];
- // Label.
- $inputs[] = [
- 'label' => __('Label'),
- 'id' => 'div-label',
- 'arguments' => [
- 'name' => 'Label',
- 'type' => 'text',
- 'value' => $values->label,
- 'return' => true,
- ],
- ];
+ switch ($values->tabSelected) {
+ case 'label':
+ // Label.
+ // TODO tinyMCE.
+ $inputs[] = [
+ 'label' => __('Label'),
+ 'id' => 'div-label',
+ 'arguments' => [
+ 'name' => 'label',
+ 'type' => 'text',
+ 'value' => $values->label,
+ 'return' => true,
+ ],
+ ];
+ break;
- // Position.
- $inputs[] = [
- 'label' => __('Position'),
- 'id' => 'div-label',
- 'arguments' => [
- 'name' => 'position-x',
- 'type' => 'text',
- 'value' => $values->posX,
- 'return' => true,
- ],
- ];
+ case 'general':
+ // 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,
+ ],
+ ],
+ ],
+ ];
+
+ // Link enabled.
+ $inputs[] = [
+ 'label' => __('Link enabled'),
+ 'arguments' => [
+ 'name' => 'isLinkEnabled',
+ 'id' => 'isLinkEnabled',
+ 'type' => 'switch',
+ 'value' => $values->isLinkEnabled,
+ ],
+ ];
+
+ // Show on top.
+ $inputs[] = [
+ 'label' => __('Show on top'),
+ 'arguments' => [
+ 'name' => 'isOnTop',
+ 'id' => 'isOnTop',
+ 'type' => 'switch',
+ 'value' => $values->isOnTop,
+ ],
+ ];
+
+ // 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,
+ ],
+ ],
+ ],
+ ];
+
+ // Parent.
+ // TODO:XXX
+ $fields = get_parameter('elementsVc', []);
+ $fields[0] = __('None');
+
+ $inputs[] = [
+ 'label' => __('Parent'),
+ 'arguments' => [
+ 'type' => 'select',
+ 'fields' => $fields,
+ 'name' => 'parentId',
+ 'selected' => $values->parentId,
+ 'return' => true,
+ ],
+ ];
+
+ // Restrict access to group.
+ $inputs[] = [
+ 'label' => __('Restrict access to group'),
+ 'arguments' => [
+ 'type' => 'select_groups',
+ 'name' => 'aclGroupId',
+ 'returnAllGroup' => true,
+ 'privilege' => $values->access,
+ 'selected' => $values->aclGroupId,
+ 'return' => true,
+ ],
+ ];
+
+ // Cache expiration.
+ $inputs[] = [
+ 'label' => __('Cache expiration'),
+ 'arguments' => [
+ 'name' => 'cacheExpiration',
+ 'type' => 'interval',
+ 'value' => $values->cacheExpiration,
+ 'nothing' => __('None'),
+ 'nothing_value' => 0,
+ ],
+ ];
+ break;
+
+ case 'specific':
+ // Override.
+ $inputs = [];
+ break;
+
+ default:
+ // Not possible.
+ break;
+ }
return $inputs;
}
diff --git a/pandora_console/include/rest-api/models/VisualConsole/View.php b/pandora_console/include/rest-api/models/VisualConsole/View.php
index 5dbc2e5188..d423895266 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/View.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/View.php
@@ -40,6 +40,61 @@ class View extends \HTML
{
+ public function loadTabs()
+ {
+ $url = ui_get_full_url(false, false, false, false);
+ $url .= 'ajax.php?page=include/rest-api/index';
+ $url .= '&loadtabs=1';
+ $url .= '&item='.get_parameter('item', null);
+
+ $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',
+ ],[
+ 'name' => __('Specific settings'),
+ 'id' => 'tab-specific',
+ 'href' => $url.'&tabSelected=specific',
+ 'img' => 'event_responses_col.png',
+ ],
+ ];
+
+ $result = html_print_tabs($tabs);
+
+ // TODO:Change other place.
+ $js = '';
+
+ return $result.$js;
+ }
+
+
/**
* Generates a form for you <3
*
@@ -58,9 +113,12 @@ class View extends \HTML
$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);
if (!isset($itemClass)) {
@@ -72,18 +130,17 @@ class View extends \HTML
}
$form = [
- 'action' => '#',
- 'id' => 'modal_form',
- 'onsubmit' => 'return false;',
- 'class' => 'discovery modal',
- 'extra' => 'autocomplete="new-password"',
+ 'action' => '#',
+ 'method' => 'POST',
+ 'id' => 'itemForm-'.$values->tabSelected,
+ 'class' => 'discovery modal',
];
// Retrieve inputs.
$inputs = $itemClass::getFormInputs($values);
// Generate Form.
- return $this->printForm(
+ $form = $this->printForm(
[
'form' => $form,
'inputs' => $inputs,
@@ -91,6 +148,8 @@ class View extends \HTML
true
);
+ return $form;
+
}
@@ -101,7 +160,39 @@ class View extends \HTML
*/
public function processForm()
{
- $item = json_decode($_REQUEST['item'])->itemProps;
+ hd($_POST, true);
+
+ // Inserted data in new item.
+ // $data = json_decode($_REQUEST['item'])->itemProps;
+ $vCId = \get_parameter('vCId', 0);
+
+ $data['type'] = 0;
+ $data['label'] = \get_parameter('label', 'vacio');
+
+ $class = VisualConsole::getItemClass((int) $data['type']);
+ try {
+ // Save the new item.
+ $data['id_layout'] = $vCId;
+ hd($data, true);
+ $result = $class::save($data);
+ } catch (\Throwable $th) {
+ // There is no item in the database.
+ // hd($th, true);
+ echo false;
+ return;
+ }
+
+ /*
+ // Extract data new item inserted.
+ try {
+ $item = VisualConsole::getItemFromDB($result);
+ } catch (Throwable $e) {
+ // Bad params.
+ http_response_code(400);
+ return;
+ }
+ */
+
return json_encode(['error' => obhd($item)]);
}
diff --git a/pandora_console/include/visual-console-client/vc.main.css b/pandora_console/include/visual-console-client/vc.main.css
index 9e81a1afc0..ee9a674d70 100644
--- a/pandora_console/include/visual-console-client/vc.main.css
+++ b/pandora_console/include/visual-console-client/vc.main.css
@@ -13,16 +13,16 @@
display: flex;
-webkit-box-orient: initial;
-webkit-box-direction: initial;
- -ms-flex-direction: initial;
- flex-direction: initial;
+ -ms-flex-direction: initial;
+ flex-direction: initial;
justify-items: center;
-webkit-box-align: center;
- -ms-flex-align: center;
- align-items: center;
+ -ms-flex-align: center;
+ align-items: center;
-webkit-user-select: text;
- -moz-user-select: text;
- -ms-user-select: text;
- user-select: text;
+ -moz-user-select: text;
+ -ms-user-select: text;
+ user-select: text;
z-index: 1;
}
@@ -33,12 +33,12 @@
.visual-console-item.is-editing {
border: 2px dashed #b2b2b2;
-webkit-transform: translateX(-2px) translateY(-2px);
- transform: translateX(-2px) translateY(-2px);
+ transform: translateX(-2px) translateY(-2px);
cursor: move;
-webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
}
.visual-console-item.is-editing.is-selected {
@@ -62,22 +62,22 @@
@-webkit-keyframes spinner-loading {
0% {
-webkit-transform: rotate(0deg);
- transform: rotate(0deg);
+ transform: rotate(0deg);
}
to {
-webkit-transform: rotate(1turn);
- transform: rotate(1turn);
+ transform: rotate(1turn);
}
}
@keyframes spinner-loading {
0% {
-webkit-transform: rotate(0deg);
- transform: rotate(0deg);
+ transform: rotate(0deg);
}
to {
-webkit-transform: rotate(1turn);
- transform: rotate(1turn);
+ transform: rotate(1turn);
}
}
@@ -91,13 +91,13 @@
-webkit-animation-name: spinner-loading;
- animation-name: spinner-loading;
+ animation-name: spinner-loading;
-webkit-animation-duration: 0.8s;
- animation-duration: 0.8s;
+ animation-duration: 0.8s;
-webkit-animation-iteration-count: infinite;
- animation-iteration-count: infinite;
+ animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
- animation-timing-function: linear;
+ animation-timing-function: linear;
}
.visual-console-spinner,
@@ -122,8 +122,8 @@
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
- -ms-flex-align: center;
- align-items: center;
+ -ms-flex-align: center;
+ align-items: center;
opacity: 0.7;
background: rgb(212, 215, 218);
}
@@ -143,13 +143,13 @@
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
- -ms-flex-direction: row;
- flex-direction: row;
+ -ms-flex-direction: row;
+ flex-direction: row;
-ms-flex-wrap: wrap;
- flex-wrap: wrap;
+ flex-wrap: wrap;
-webkit-box-align: center;
- -ms-flex-align: center;
- align-items: center;
+ -ms-flex-align: center;
+ align-items: center;
font-size: 12pt;
font-family: "lato-bolder", "Open Sans", sans-serif;
font-weight: 600;
@@ -172,7 +172,7 @@
font-weight: lighter;
padding: 0px 0px 2px 0px;
-webkit-box-sizing: border-box;
- box-sizing: border-box;
+ box-sizing: border-box;
margin-right: 10px;
padding-left: 2px;
}
@@ -195,10 +195,10 @@
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
- -ms-flex-direction: column;
- flex-direction: column;
+ -ms-flex-direction: column;
+ flex-direction: column;
-ms-flex-wrap: wrap;
- flex-wrap: wrap;
+ flex-wrap: wrap;
}
.input-group {
@@ -213,13 +213,13 @@
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
- -ms-flex-direction: column;
- flex-direction: column;
+ -ms-flex-direction: column;
+ flex-direction: column;
-ms-flex-wrap: wrap;
- flex-wrap: wrap;
+ flex-wrap: wrap;
-webkit-box-align: start;
- -ms-flex-align: start;
- align-items: start;
+ -ms-flex-align: start;
+ align-items: start;
}
.div-ranges-input-group > div {
@@ -234,13 +234,13 @@
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
- -ms-flex-direction: row;
- flex-direction: row;
+ -ms-flex-direction: row;
+ flex-direction: row;
-ms-flex-wrap: wrap;
- flex-wrap: wrap;
+ flex-wrap: wrap;
-webkit-box-align: center;
- -ms-flex-align: center;
- align-items: center;
+ -ms-flex-align: center;
+ align-items: center;
}
.div-input-group h3 {
@@ -262,16 +262,16 @@
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
- -ms-flex-direction: column;
- flex-direction: column;
+ -ms-flex-direction: column;
+ flex-direction: column;
-ms-flex-wrap: wrap;
- flex-wrap: wrap;
+ flex-wrap: wrap;
-webkit-box-align: start;
- -ms-flex-align: start;
- align-items: start;
+ -ms-flex-align: start;
+ align-items: start;
-webkit-box-pack: justify;
- -ms-flex-pack: justify;
- justify-content: space-between;
+ -ms-flex-pack: justify;
+ justify-content: space-between;
height: 70px;
}
@@ -335,33 +335,33 @@ p.error-p-validate {
.fa-spin {
-webkit-animation: fa-spin 2s infinite linear;
- animation: fa-spin 2s infinite linear;
+ animation: fa-spin 2s infinite linear;
}
.fa-pulse {
-webkit-animation: fa-spin 1s infinite steps(8);
- animation: fa-spin 1s infinite steps(8);
+ animation: fa-spin 1s infinite steps(8);
}
@-webkit-keyframes fa-spin {
0% {
-webkit-transform: rotate(0deg);
- transform: rotate(0deg);
+ transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
- transform: rotate(360deg);
+ transform: rotate(360deg);
}
}
@keyframes fa-spin {
0% {
-webkit-transform: rotate(0deg);
- transform: rotate(0deg);
+ transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
- transform: rotate(360deg);
+ transform: rotate(360deg);
}
}
@@ -415,17 +415,17 @@ p.error-p-validate {
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
- -ms-flex-direction: column;
- flex-direction: column;
+ -ms-flex-direction: column;
+ flex-direction: column;
-webkit-box-pack: center;
- -ms-flex-pack: center;
- justify-content: center;
+ -ms-flex-pack: center;
+ justify-content: center;
justify-items: center;
-ms-flex-line-pack: center;
- align-content: center;
+ align-content: center;
-webkit-box-align: center;
- -ms-flex-align: center;
- align-items: center;
+ -ms-flex-align: center;
+ align-items: center;
}
.visual-console-item .digital-clock > span {
@@ -455,18 +455,48 @@ p.error-p-validate {
.visual-console-item .analogic-clock .hour-hand {
-webkit-animation: rotate-hour 43200s infinite linear;
- animation: rotate-hour 43200s infinite linear;
+ animation: rotate-hour 43200s infinite linear;
}
.visual-console-item .analogic-clock .minute-hand {
-webkit-animation: rotate-minute 3600s infinite linear;
- animation: rotate-minute 3600s infinite linear;
+ animation: rotate-minute 3600s infinite linear;
}
.visual-console-item .analogic-clock .second-hand {
-webkit-animation: rotate-second 60s infinite linear;
- animation: rotate-second 60s infinite linear;
+ animation: rotate-second 60s infinite linear;
}
+#html-tabs .ui-widget-header {
+ background-color: #ffffff;
+ border: 0px;
+}
-/*# sourceMappingURL=vc.main.css.map*/
\ No newline at end of file
+#html-tabs .ui-tabs-anchor {
+ float: none;
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: space-between;
+}
+
+#html-tabs .ui-tabs-anchor img {
+ margin-right: 10px;
+}
+
+#html-tabs .ui-tabs-nav li {
+ border-radius: 5px 5px 0px 0px;
+}
+
+label span.p-slider {
+ width: 30px;
+}
+
+li#li-size-item > label:not(:first-child),
+li#li-position-item > label:not(:first-child) {
+ width: initial;
+ margin-left: 15px;
+}
+
+/*# sourceMappingURL=vc.main.css.map*/