diff --git a/pandora_console/include/javascript/pandora_visual_console.js b/pandora_console/include/javascript/pandora_visual_console.js index ba0a073589..fa0ea91d7f 100755 --- a/pandora_console/include/javascript/pandora_visual_console.js +++ b/pandora_console/include/javascript/pandora_visual_console.js @@ -648,41 +648,14 @@ function createVisualConsole( item.setMeta({ isUpdating: false }); - var itemRetrieved = item.props; - if (itemRetrieved["type"] == 13 || itemRetrieved["type"] == 21) { - var startIsLeft = - itemRetrieved["startPosition"]["x"] - - itemRetrieved["endPosition"]["x"] <= - 0; - var startIsTop = - itemRetrieved["startPosition"]["y"] - - itemRetrieved["endPosition"]["y"] <= - 0; - - itemRetrieved["startX"] = startIsLeft - ? itemRetrieved["x"] + 20 - : itemRetrieved["width"] + itemRetrieved["x"] + 20; - - itemRetrieved["startY"] = startIsTop - ? itemRetrieved["y"] + 20 - : itemRetrieved["height"] + itemRetrieved["y"] + 20; - - itemRetrieved["endX"] = startIsLeft - ? itemRetrieved["width"] + itemRetrieved["x"] + 20 - : itemRetrieved["x"] + 20; - - itemRetrieved["endY"] = startIsTop - ? itemRetrieved["height"] + itemRetrieved["y"] + 20 - : itemRetrieved["y"] + 20; - } else { - itemRetrieved["x"] = itemRetrieved["x"] + 20; - itemRetrieved["y"] = itemRetrieved["y"] + 20; - } - itemRetrieved["receivedAt"] = new Date(); - itemRetrieved["id"] = data; - - var newItem = visualConsole.addElement(itemRetrieved); - newItem.setMeta({ editMode: true, isSelected: true }); + var newItemData = JSON.parse(data); + newItemData["receivedAt"] = new Date(); + var newItem = visualConsole.addElement(newItemData); + newItem.setMeta({ + editMode: true, + isSelected: true, + isUpdating: false + }); visualConsole.selectItem(newItem.props.id); done(); @@ -1232,7 +1205,7 @@ function cleanupDOM() { $("#modalVCItemForm").empty(); } /* Defined in operations/visual_console/view.php */ -/* global $, load_modal, tinyMCE */ +/* global $, load_modal, UndefineTinyMCE */ function createOrUpdateVisualConsoleItem( visualConsole, asyncTaskManager, diff --git a/pandora_console/include/rest-api/index.php b/pandora_console/include/rest-api/index.php index f06ebd3a4a..743866d863 100644 --- a/pandora_console/include/rest-api/index.php +++ b/pandora_console/include/rest-api/index.php @@ -307,18 +307,19 @@ if ($getVisualConsole === true) { } unset($data['id']); - $class = VisualConsole::getItemClass((int) $data['type']); try { // Save the new item. - $result = $class::create($data); + $itemId = $class::create($data); + $item = VisualConsole::getItemFromDB($itemId); + $result = $item->toArray(); } catch (\Throwable $th) { // There is no item in the database. echo false; return; } - echo $result; + echo json_encode($result); return; } else if ($getImagesVisualConsole) { $img = get_parameter('nameImg', 'appliance'); diff --git a/pandora_console/operation/visual_console/view.php b/pandora_console/operation/visual_console/view.php index afefdefc8b..6f193c05c5 100644 --- a/pandora_console/operation/visual_console/view.php +++ b/pandora_console/operation/visual_console/view.php @@ -1149,11 +1149,6 @@ if ($edit_capable === true) { visualConsoleManager.copyItem(item); } }); - setTimeout( - function() - { - visualConsoleManager.forceUpdateVisualConsole(); - }, 500); }); $('.link-create-item').click(function (event){