fix rerors duplicate in CVS pandora_enterprise#9640

This commit is contained in:
daniel 2023-12-18 11:14:55 +01:00
parent 70dd1719db
commit d56e3a5496
3 changed files with 13 additions and 44 deletions

View File

@ -648,41 +648,14 @@ function createVisualConsole(
item.setMeta({ isUpdating: false }); item.setMeta({ isUpdating: false });
var itemRetrieved = item.props; var newItemData = JSON.parse(data);
if (itemRetrieved["type"] == 13 || itemRetrieved["type"] == 21) { newItemData["receivedAt"] = new Date();
var startIsLeft = var newItem = visualConsole.addElement(newItemData);
itemRetrieved["startPosition"]["x"] - newItem.setMeta({
itemRetrieved["endPosition"]["x"] <= editMode: true,
0; isSelected: true,
var startIsTop = isUpdating: false
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 });
visualConsole.selectItem(newItem.props.id); visualConsole.selectItem(newItem.props.id);
done(); done();
@ -1232,7 +1205,7 @@ function cleanupDOM() {
$("#modalVCItemForm").empty(); $("#modalVCItemForm").empty();
} }
/* Defined in operations/visual_console/view.php */ /* Defined in operations/visual_console/view.php */
/* global $, load_modal, tinyMCE */ /* global $, load_modal, UndefineTinyMCE */
function createOrUpdateVisualConsoleItem( function createOrUpdateVisualConsoleItem(
visualConsole, visualConsole,
asyncTaskManager, asyncTaskManager,

View File

@ -307,18 +307,19 @@ if ($getVisualConsole === true) {
} }
unset($data['id']); unset($data['id']);
$class = VisualConsole::getItemClass((int) $data['type']); $class = VisualConsole::getItemClass((int) $data['type']);
try { try {
// Save the new item. // Save the new item.
$result = $class::create($data); $itemId = $class::create($data);
$item = VisualConsole::getItemFromDB($itemId);
$result = $item->toArray();
} catch (\Throwable $th) { } catch (\Throwable $th) {
// There is no item in the database. // There is no item in the database.
echo false; echo false;
return; return;
} }
echo $result; echo json_encode($result);
return; return;
} else if ($getImagesVisualConsole) { } else if ($getImagesVisualConsole) {
$img = get_parameter('nameImg', 'appliance'); $img = get_parameter('nameImg', 'appliance');

View File

@ -1149,11 +1149,6 @@ if ($edit_capable === true) {
visualConsoleManager.copyItem(item); visualConsoleManager.copyItem(item);
} }
}); });
setTimeout(
function()
{
visualConsoleManager.forceUpdateVisualConsole();
}, 500);
}); });
$('.link-create-item').click(function (event){ $('.link-create-item').click(function (event){