This commit is contained in:
Garrett 2020-12-27 07:01:47 +00:00
parent 49dec8d17b
commit 5bb2d9d0ea
4 changed files with 182 additions and 177 deletions

View File

@ -679,14 +679,42 @@ function postProcessCable(){
var objPort = data.objPort; var objPort = data.objPort;
var value = data.value; var value = data.value;
var optionText = $('#selectPort').find(':selected').text(); // Compile localPortGlobalID
$('#port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+objPort).addClass('populated').data('connectedGlobalId', 'port-'+responseJSON.success.peerPortID); var localPortGlobalID = 'port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+objPort;
if($('#port-'+responseJSON.success.peerPortID).length) { var localPortGlobalIDBase64 = btoa(JSON.stringify([localPortGlobalID]));
$('#port-'+responseJSON.success.peerPortID).addClass('populated').data('connectedGlobalId', 'port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+objPort);
// Append each remotePortGlobalID with "port-"
var remotePortGlobalIDArray = [];
$.each(value, function(index, remotePortGlobalID){
var remotePortGlobalID = 'port-'+remotePortGlobalID;
remotePortGlobalIDArray.push(remotePortGlobalID);
});
var remotePortGlobalIDArrayBase64 = btoa(JSON.stringify(remotePortGlobalIDArray));
// Compile emptyGlobalIDArrayBase64
var emptyGlobalIDArrayBase64 = btoa(JSON.stringify([]));
// Clear previous remote port(s)
var prevRemotePortGlobalIDArray = JSON.parse(atob($('#'+localPortGlobalID).data('connectedGlobalId')));
$.each(prevRemotePortGlobalIDArray, function(index, prevRemotePortGlobalID){
if($('#'+prevRemotePortGlobalID).length) {
$('#'+prevRemotePortGlobalID).removeClass('populated').data('connectedGlobalId', emptyGlobalIDArrayBase64);
} }
if($('#port-'+responseJSON.success.oldPeerPortID).length) { });
$('#port-'+responseJSON.success.oldPeerPortID).removeClass('populated').data('connectedGlobalId', 'none');
// Update local port
$('#'+localPortGlobalID).addClass('populated').data('connectedGlobalId', remotePortGlobalIDArrayBase64);
// Update remote port(s)
$.each(remotePortGlobalIDArray, function(index, remotePortGlobalID){
console.log('Debug (remotePortGlobalID): '+remotePortGlobalID);
if($('#'+remotePortGlobalID).length) {
console.log('Debug (localPortGlobalIDBase64): '+localPortGlobalIDBase64);
$('#'+remotePortGlobalID).addClass('populated').data('connectedGlobalId', localPortGlobalIDBase64);
} }
});
var interfaceSelectionElem = $('#selectPort').find(':selected'); var interfaceSelectionElem = $('#selectPort').find(':selected');
portDesignation(interfaceSelectionElem, 'add', 'C'); portDesignation(interfaceSelectionElem, 'add', 'C');
$('#checkboxPopulated').prop("checked", true); $('#checkboxPopulated').prop("checked", true);
@ -1001,15 +1029,20 @@ $( document ).ready(function() {
} else if ($(responseJSON.error).size() > 0){ } else if ($(responseJSON.error).size() > 0){
displayError(responseJSON.error); displayError(responseJSON.error);
} else { } else {
$('#port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+objPort).removeClass('populated').data('connectedGlobalId', 'none');
if(responseJSON.success.oldPeerPortID) { // Compile localPortGlobalID
if($('#port-'+responseJSON.success.oldPeerPortID).length) { var localPortGlobalID = 'port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+objPort;
$('#port-'+responseJSON.success.oldPeerPortID).removeClass('populated').data('connectedGlobalId', 'none');
} // Update remote port(s)
var remotePortGlobalIDArray = JSON.parse(atob($('#'+localPortGlobalID).data('connectedGlobalId')));
$.each(remotePortGlobalIDArray, function(index, remotePortGlobalID){
if($('#'+remotePortGlobalID).length) {
$('#'+remotePortGlobalID).removeClass('populated').data('connectedGlobalId', btoa(JSON.stringify([])));
} }
});
$('#'+localPortGlobalID).removeClass('populated').data('connectedGlobalId', btoa(JSON.stringify([])));
var interfaceSelectionElem = $('#selectPort').find(':selected'); var interfaceSelectionElem = $('#selectPort').find(':selected');
//portDesignation(interfaceSelectionElem, 'remove', 'C');
$('#checkboxPopulated').prop("checked", false); $('#checkboxPopulated').prop("checked", false);
$('#checkboxPopulated').prop("disabled", false); $('#checkboxPopulated').prop("disabled", false);
retrievePortPath(objID, objFace, objDepth, objPort); retrievePortPath(objID, objFace, objDepth, objPort);

View File

@ -401,11 +401,13 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
// Validate trunk peers are not connected to each other // Validate trunk peers are not connected to each other
if(isset($qls->App->inventoryArray[$objectID][$objectFace][$objectDepth])) { if(isset($qls->App->inventoryArray[$objectID][$objectFace][$objectDepth])) {
$peersConnected = false; $peersConnected = false;
foreach($qls->App->inventoryArray[$objectID][$objectFace][$objectDepth] as $objConnection) { foreach($qls->App->inventoryArray[$objectID][$objectFace][$objectDepth] as $objPort) {
foreach($objPort as $objConnection) {
if($objConnection['id'] == $elementID and $objConnection['face'] == $elementFace and $objConnection['depth'] == $elementDepth) { if($objConnection['id'] == $elementID and $objConnection['face'] == $elementFace and $objConnection['depth'] == $elementDepth) {
$peersConnected = true; $peersConnected = true;
} }
} }
}
if($peersConnected) { if($peersConnected) {
$errMsg = 'Cannot trunk partitions that are connected to each other.'; $errMsg = 'Cannot trunk partitions that are connected to each other.';
array_push($validate->returnData['error'], $errMsg); array_push($validate->returnData['error'], $errMsg);
@ -509,7 +511,8 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
// Delete peer entries // Delete peer entries
foreach($deleteArray as $entry) { foreach($deleteArray as $entry) {
// Delete from inventory table // Delete from inventory table
if($inventoryEntry = $qls->App->inventoryArray[$entry['id']][$entry['face']][$entry['depth']][$entry['port']]) { if($inventoryPort = $qls->App->inventoryArray[$entry['id']][$entry['face']][$entry['depth']][$entry['port']]) {
foreach($inventoryPort as $inventoryEntry) {
$rowID = $inventoryEntry['rowID']; $rowID = $inventoryEntry['rowID'];
if($inventoryEntry['localEndID'] === 0 and $inventoryEntry['remoteEndID'] === 0) { if($inventoryEntry['localEndID'] === 0 and $inventoryEntry['remoteEndID'] === 0) {
// If this is an unmanaged connection, delete the entry // If this is an unmanaged connection, delete the entry
@ -531,6 +534,7 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
$qls->App->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']]['port'] = 0; $qls->App->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']]['port'] = 0;
} }
} }
}
unset($qls->App->inventoryArray[$entry['id']][$entry['face']][$entry['depth']][$entry['port']]); unset($qls->App->inventoryArray[$entry['id']][$entry['face']][$entry['depth']][$entry['port']]);
} }
@ -552,14 +556,16 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
foreach($qls->App->inventoryArray[$objectID] as $faceID => $face) { foreach($qls->App->inventoryArray[$objectID] as $faceID => $face) {
foreach($face as $depthID => $depth) { foreach($face as $depthID => $depth) {
foreach($depth as $portID => $port) { foreach($depth as $portID => $port) {
$rowID = $port['rowID']; $deleteEntry = false;
if($port['localEndID'] == 0 and $port['remoteEndID'] == 0) { foreach($port as $connection) {
$rowID = $connection['rowID'];
if($connection['localEndID'] == 0 and $connection['remoteEndID'] == 0) {
// Delete entry if not managed cable // Delete entry if not managed cable
$qls->SQL->delete('app_inventory', array('id' => array('=', $rowID))); $qls->SQL->delete('app_inventory', array('id' => array('=', $rowID)));
unset($qls->App->inventoryArray[$objectID][$faceID][$depthID][$portID]); $deleteEntry = true;
} else { } else {
// Clear entry if managed cable // Clear entry if managed cable
$localAttrPrefix = $port['localAttrPrefix']; $localAttrPrefix = $connection['localAttrPrefix'];
$set = array( $set = array(
$localAttrPrefix.'_object_id' => 0, $localAttrPrefix.'_object_id' => 0,
$localAttrPrefix.'_object_face' => 0, $localAttrPrefix.'_object_face' => 0,
@ -569,6 +575,10 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
$qls->SQL->update('app_inventory', $set, array('id' => array('=', $rowID))); $qls->SQL->update('app_inventory', $set, array('id' => array('=', $rowID)));
} }
} }
if($deleteEntry) {
unset($qls->App->inventoryArray[$objectID][$faceID][$depthID][$portID]);
}
}
} }
} }
} }

View File

@ -109,19 +109,14 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
// Clear any inventory entries // Clear any inventory entries
if (isset($qls->App->inventoryArray[$elementID][$elementFace][$elementDepth][$elementPort])) { if (isset($qls->App->inventoryArray[$elementID][$elementFace][$elementDepth][$elementPort])) {
$inventoryEntry = $qls->App->inventoryArray[$elementID][$elementFace][$elementDepth][$elementPort]; foreach($qls->App->inventoryArray[$elementID][$elementFace][$elementDepth][$elementPort] as $inventoryEntry) {
$rowID = $inventoryEntry['rowID']; $rowID = $inventoryEntry['rowID'];
$localAttrPrefix = $inventoryEntry['localAttrPrefix']; $localAttrPrefix = $inventoryEntry['localAttrPrefix'];
if ($inventoryEntry['localEndID'] == 0) { if ($inventoryEntry['localEndID'] == 0) {
// Found entry is not a managed cable... delete // Found entry is not a managed cable... delete
$qls->SQL->delete( $qls->SQL->delete('app_inventory', array('id' => array('=', $rowID)));
'app_inventory',
array(
'id' => array('=', $rowID)
)
);
} else { } else {
// Found entry is a managed cable... zeroize // Found entry is a managed cable... zeroize
@ -139,6 +134,7 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
); );
} }
} }
}
// Update connection in database // Update connection in database
$qls->SQL->update( $qls->SQL->update(
@ -175,21 +171,17 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
$objFace = $data['objFace']; $objFace = $data['objFace'];
$objDepth = $data['objDepth']; $objDepth = $data['objDepth'];
$objPort = $data['objPort']; $objPort = $data['objPort'];
$obj = (isset($qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort])) ? $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort] : false; if(isset($qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort])) {
$port = $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort];
// Retrieve old peer port ID so it can have the "populated" class cleared foreach($port as $connection) {
if($obj) {
$oldPeerPortID = '4-'.$obj['id'].'-'.$obj['face'].'-'.$obj['depth'].'-'.$obj['port'];
} else {
$oldPeerPortID = false;
}
// Clear inventory table entry // Clear inventory table entry
$objRowID = $obj['rowID']; $rowID = $connection['rowID'];
if($obj['localEndID'] or $obj['remoteEndID']) { if($connection['localEndID'] or $connection['remoteEndID']) {
clearTableInventory($qls, $obj['localAttrPrefix'], $objRowID); clearTableInventory($qls, $connection['localAttrPrefix'], $rowID);
} else { } else {
$qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID))); $qls->SQL->delete('app_inventory', array('id' => array('=', $rowID)));
}
}
} }
// Clear populated port entry // Clear populated port entry
@ -197,17 +189,20 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
// Log history // Log history
$localPort = $qls->App->generateObjectPortName($objID, $objFace, $objDepth, $objPort); $localPort = $qls->App->generateObjectPortName($objID, $objFace, $objDepth, $objPort);
$remotePortData = $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort]; $port = $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort];
$remoteObjID = $remotePortData['id']; $remotePortArray = array();
$remoteObjFace = $remotePortData['face']; foreach($port as $connection) {
$remoteObjDepth = $remotePortData['depth']; $remoteObjID = $connection['id'];
$remoteObjPort = $remotePortData['port']; $remoteObjFace = $connection['face'];
$remotePort = $qls->App->generateObjectPortName($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort); $remoteObjDepth = $connection['depth'];
$actionString = 'Deleted connection: <strong>'.$localPort.'</strong> to <strong>'.$remotePort.'</strong>'; $remoteObjPort = $connection['port'];
$remotePortName = $qls->App->generateObjectPortName($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort);
array_push($remotePortArray, $remotePortName);
}
$remotePortString = implode('<br>', $remotePortArray);
$actionString = 'Deleted connection: <strong>'.$localPort.'</strong> to <strong>'.$remotePortString.'</strong>';
$qls->App->logAction(3, 3, $actionString); $qls->App->logAction(3, 3, $actionString);
$validate->returnData['success']['oldPeerPortID'] = $oldPeerPortID;
break; break;
case 'connectionExplore': case 'connectionExplore':
@ -215,7 +210,6 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
$validate->returnData['success'] = array(); $validate->returnData['success'] = array();
$value = $data['value']; $value = $data['value'];
$clear = $value == 'clear' ? true : false; $clear = $value == 'clear' ? true : false;
$peerPortID = '';
foreach($value as $peerPortString) { foreach($value as $peerPortString) {
@ -233,8 +227,6 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
$objPort = $data['objPort']; $objPort = $data['objPort'];
$obj = (isset($qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort])) ? $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort] : false; $obj = (isset($qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort])) ? $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort] : false;
$peerPortID = '4-'.$elementID.'-'.$elementFace.'-'.$elementDepth.'-'.$elementPort;
// Clear trunk if this is a trunked floorplan object // Clear trunk if this is a trunked floorplan object
$objIDArray = array($elementID, $objID); $objIDArray = array($elementID, $objID);
foreach($objIDArray as $objID) { foreach($objIDArray as $objID) {
@ -253,60 +245,61 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
} }
} }
// Retrieve old peer port ID so it can have the "populated" class cleared
if($obj) {
$oldPeerPortID = '4-'.$obj['id'].'-'.$obj['face'].'-'.$obj['depth'].'-'.$obj['port'];
} else {
$oldPeerPortID = false;
}
// Clear existing connections // Clear existing connections
if($obj and $element) { if($obj and $element) {
$objRowID = $obj['rowID']; foreach($obj as $objConnection) {
$elementRowID = $element['rowID']; $objRowID = $objConnection['rowID'];
foreach($element as $elementConnection) {
$elementRowID = $elementConnection['rowID'];
// Are the ports connected to each other? // Are the ports connected to each other?
if($obj['rowID'] == $element['rowID']) { if($objConnection['rowID'] == $elementConnection['rowID']) {
if($obj['localEndID'] or $obj['remoteEndID']) { if($objConnection['localEndID'] or $objConnection['remoteEndID']) {
clearTableInventory($qls, 'a', $objRowID); clearTableInventory($qls, 'a', $objRowID);
clearTableInventory($qls, 'b', $objRowID); clearTableInventory($qls, 'b', $objRowID);
} else { } else {
$qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID))); $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID)));
} }
} else { } else {
if($obj['localEndID'] or $obj['remoteEndID']) { if($objConnection['localEndID'] or $objConnection['remoteEndID']) {
clearTableInventory($qls, $obj['localAttrPrefix'], $objRowID); clearTableInventory($qls, $objConnection['localAttrPrefix'], $objRowID);
} else { } else {
$qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID))); $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID)));
} }
if($element['localEndID'] or $element['remoteEndID']) { if($elementConnection['localEndID'] or $elementConnection['remoteEndID']) {
clearTableInventory($qls, $element['localAttrPrefix'], $elementRowID); clearTableInventory($qls, $elementConnection['localAttrPrefix'], $elementRowID);
} else { } else {
$qls->SQL->delete('app_inventory', array('id' => array('=', $elementRowID))); $qls->SQL->delete('app_inventory', array('id' => array('=', $elementRowID)));
} }
} }
}
}
} else if($obj) { } else if($obj) {
$objRowID = $obj['rowID']; foreach($obj as $objConnection) {
$objRowID = $objConnection['rowID'];
if($obj['localEndID'] or $obj['remoteEndID']) { if($objConnection['localEndID'] or $objConnection['remoteEndID']) {
clearTableInventory($qls, $obj['localAttrPrefix'], $objRowID); clearTableInventory($qls, $objConnection['localAttrPrefix'], $objRowID);
} else { } else {
$qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID))); $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID)));
} }
}
} else if($element) { } else if($element) {
$elementRowID = $element['rowID']; foreach($element as $elementConnection) {
$elementRowID = $elementConnection['rowID'];
if($element['localEndID'] or $element['remoteEndID']) { if($elementConnection['localEndID'] or $elementConnection['remoteEndID']) {
clearTableInventory($qls, $element['localAttrPrefix'], $elementRowID); clearTableInventory($qls, $elementConnection['localAttrPrefix'], $elementRowID);
} else { } else {
$qls->SQL->delete('app_inventory', array('id' => array('=', $elementRowID))); $qls->SQL->delete('app_inventory', array('id' => array('=', $elementRowID)));
} }
} }
}
// Clear populated port entry // Clear populated port entry
clearTablePopulated($qls, $objID, $objFace, $objDepth, $objPort); clearTablePopulated($qls, $objID, $objFace, $objDepth, $objPort);
@ -323,9 +316,6 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
} }
$validate->returnData['success']['peerPortID'] = $peerPortID;
$validate->returnData['success']['oldPeerPortID'] = $oldPeerPortID;
break; break;
} }
} }

View File

@ -91,13 +91,6 @@ for($x=0; $x<2; $x++){
'connectorType' => $connection[$localAttrPrefix.'_connector'] 'connectorType' => $connection[$localAttrPrefix.'_connector']
) )
); );
/*
if($x == 0) {
array_push($path, $workingArray);
} else {
array_unshift($path, $workingArray);
}
*/
// Cable // Cable
$mediaTypeID = $connection['mediaType']; $mediaTypeID = $connection['mediaType'];
@ -111,13 +104,6 @@ for($x=0; $x<2; $x++){
'length' => $length 'length' => $length
) )
); );
/*
if($x == 0) {
array_push($path, $workingArray);
} else {
array_unshift($path, $workingArray);
}
*/
// Remote Connection // Remote Connection
$connector2WorkingArray = array( $connector2WorkingArray = array(
@ -127,13 +113,6 @@ for($x=0; $x<2; $x++){
'connectorType' => $connection[$remoteAttrPrefix.'_connector'] 'connectorType' => $connection[$remoteAttrPrefix.'_connector']
) )
); );
/*
if($x == 0) {
array_push($path, $workingArray);
} else {
array_unshift($path, $workingArray);
}
*/
// Object // Object
if($connection[$remoteAttrPrefix.'_object_id'] != 0) { if($connection[$remoteAttrPrefix.'_object_id'] != 0) {
@ -172,13 +151,6 @@ for($x=0; $x<2; $x++){
'type' => 'trunk', 'type' => 'trunk',
'data' => array() 'data' => array()
); );
/*
if($x == 0) {
array_push($path, $workingArray);
} else {
array_unshift($path, $workingArray);
}
*/
} else { } else {
// No trunk peer found // No trunk peer found