diff --git a/assets/pages/jquery.explore.js b/assets/pages/jquery.explore.js
index b1437a5..7adfaab 100755
--- a/assets/pages/jquery.explore.js
+++ b/assets/pages/jquery.explore.js
@@ -679,14 +679,42 @@ function postProcessCable(){
var objPort = data.objPort;
var value = data.value;
- var optionText = $('#selectPort').find(':selected').text();
- $('#port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+objPort).addClass('populated').data('connectedGlobalId', 'port-'+responseJSON.success.peerPortID);
- if($('#port-'+responseJSON.success.peerPortID).length) {
- $('#port-'+responseJSON.success.peerPortID).addClass('populated').data('connectedGlobalId', 'port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+objPort);
- }
- if($('#port-'+responseJSON.success.oldPeerPortID).length) {
- $('#port-'+responseJSON.success.oldPeerPortID).removeClass('populated').data('connectedGlobalId', 'none');
- }
+ // Compile localPortGlobalID
+ var localPortGlobalID = 'port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+objPort;
+ var localPortGlobalIDBase64 = btoa(JSON.stringify([localPortGlobalID]));
+
+ // 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);
+ }
+ });
+
+ // 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');
portDesignation(interfaceSelectionElem, 'add', 'C');
$('#checkboxPopulated').prop("checked", true);
@@ -1001,15 +1029,20 @@ $( document ).ready(function() {
} else if ($(responseJSON.error).size() > 0){
displayError(responseJSON.error);
} else {
- $('#port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+objPort).removeClass('populated').data('connectedGlobalId', 'none');
- if(responseJSON.success.oldPeerPortID) {
- if($('#port-'+responseJSON.success.oldPeerPortID).length) {
- $('#port-'+responseJSON.success.oldPeerPortID).removeClass('populated').data('connectedGlobalId', 'none');
+
+ // Compile localPortGlobalID
+ var localPortGlobalID = 'port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+objPort;
+
+ // 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');
- //portDesignation(interfaceSelectionElem, 'remove', 'C');
$('#checkboxPopulated').prop("checked", false);
$('#checkboxPopulated').prop("disabled", false);
retrievePortPath(objID, objFace, objDepth, objPort);
diff --git a/backend/process_cabinet.php b/backend/process_cabinet.php
index d6750bd..a8ce11b 100755
--- a/backend/process_cabinet.php
+++ b/backend/process_cabinet.php
@@ -401,9 +401,11 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
// Validate trunk peers are not connected to each other
if(isset($qls->App->inventoryArray[$objectID][$objectFace][$objectDepth])) {
$peersConnected = false;
- foreach($qls->App->inventoryArray[$objectID][$objectFace][$objectDepth] as $objConnection) {
- if($objConnection['id'] == $elementID and $objConnection['face'] == $elementFace and $objConnection['depth'] == $elementDepth) {
- $peersConnected = true;
+ 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) {
+ $peersConnected = true;
+ }
}
}
if($peersConnected) {
@@ -509,26 +511,28 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
// Delete peer entries
foreach($deleteArray as $entry) {
// Delete from inventory table
- if($inventoryEntry = $qls->App->inventoryArray[$entry['id']][$entry['face']][$entry['depth']][$entry['port']]) {
- $rowID = $inventoryEntry['rowID'];
- if($inventoryEntry['localEndID'] === 0 and $inventoryEntry['remoteEndID'] === 0) {
- // If this is an unmanaged connection, delete the entry
- $qls->SQL->delete('app_inventory', array('id' => array('=', $rowID)));
- } else {
- // If this is a managed connection, just clear the data
- $attrPrefix = $inventoryEntry['localAttrPrefix'];
- $set = array(
- $attrPrefix.'_object_id' => 0,
- $attrPrefix.'_object_face' => 0,
- $attrPrefix.'_object_depth' => 0,
- $attrPrefix.'_port_id' => 0
- );
- $qls->SQL->update('app_inventory', $set, array('id' => array('=', $rowID)));
- if(isset($qls->App->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']])) {
- $qls->App->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']]['id'] = 0;
- $qls->App->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']]['face'] = 0;
- $qls->App->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']]['depth'] = 0;
- $qls->App->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']]['port'] = 0;
+ if($inventoryPort = $qls->App->inventoryArray[$entry['id']][$entry['face']][$entry['depth']][$entry['port']]) {
+ foreach($inventoryPort as $inventoryEntry) {
+ $rowID = $inventoryEntry['rowID'];
+ if($inventoryEntry['localEndID'] === 0 and $inventoryEntry['remoteEndID'] === 0) {
+ // If this is an unmanaged connection, delete the entry
+ $qls->SQL->delete('app_inventory', array('id' => array('=', $rowID)));
+ } else {
+ // If this is a managed connection, just clear the data
+ $attrPrefix = $inventoryEntry['localAttrPrefix'];
+ $set = array(
+ $attrPrefix.'_object_id' => 0,
+ $attrPrefix.'_object_face' => 0,
+ $attrPrefix.'_object_depth' => 0,
+ $attrPrefix.'_port_id' => 0
+ );
+ $qls->SQL->update('app_inventory', $set, array('id' => array('=', $rowID)));
+ if(isset($qls->App->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']])) {
+ $qls->App->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']]['id'] = 0;
+ $qls->App->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']]['face'] = 0;
+ $qls->App->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']]['depth'] = 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']]);
@@ -552,21 +556,27 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
foreach($qls->App->inventoryArray[$objectID] as $faceID => $face) {
foreach($face as $depthID => $depth) {
foreach($depth as $portID => $port) {
- $rowID = $port['rowID'];
- if($port['localEndID'] == 0 and $port['remoteEndID'] == 0) {
- // Delete entry if not managed cable
- $qls->SQL->delete('app_inventory', array('id' => array('=', $rowID)));
+ $deleteEntry = false;
+ foreach($port as $connection) {
+ $rowID = $connection['rowID'];
+ if($connection['localEndID'] == 0 and $connection['remoteEndID'] == 0) {
+ // Delete entry if not managed cable
+ $qls->SQL->delete('app_inventory', array('id' => array('=', $rowID)));
+ $deleteEntry = true;
+ } else {
+ // Clear entry if managed cable
+ $localAttrPrefix = $connection['localAttrPrefix'];
+ $set = array(
+ $localAttrPrefix.'_object_id' => 0,
+ $localAttrPrefix.'_object_face' => 0,
+ $localAttrPrefix.'_object_depth' => 0,
+ $localAttrPrefix.'_port_id' => 0
+ );
+ $qls->SQL->update('app_inventory', $set, array('id' => array('=', $rowID)));
+ }
+ }
+ if($deleteEntry) {
unset($qls->App->inventoryArray[$objectID][$faceID][$depthID][$portID]);
- } else {
- // Clear entry if managed cable
- $localAttrPrefix = $port['localAttrPrefix'];
- $set = array(
- $localAttrPrefix.'_object_id' => 0,
- $localAttrPrefix.'_object_face' => 0,
- $localAttrPrefix.'_object_depth' => 0,
- $localAttrPrefix.'_port_id' => 0
- );
- $qls->SQL->update('app_inventory', $set, array('id' => array('=', $rowID)));
}
}
}
diff --git a/backend/process_cable.php b/backend/process_cable.php
index 135df02..0b0a245 100755
--- a/backend/process_cable.php
+++ b/backend/process_cable.php
@@ -109,34 +109,30 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
// Clear any inventory entries
if (isset($qls->App->inventoryArray[$elementID][$elementFace][$elementDepth][$elementPort])) {
- $inventoryEntry = $qls->App->inventoryArray[$elementID][$elementFace][$elementDepth][$elementPort];
- $rowID = $inventoryEntry['rowID'];
- $localAttrPrefix = $inventoryEntry['localAttrPrefix'];
-
- if ($inventoryEntry['localEndID'] == 0) {
+ foreach($qls->App->inventoryArray[$elementID][$elementFace][$elementDepth][$elementPort] as $inventoryEntry) {
+ $rowID = $inventoryEntry['rowID'];
+ $localAttrPrefix = $inventoryEntry['localAttrPrefix'];
- // Found entry is not a managed cable... delete
- $qls->SQL->delete(
- 'app_inventory',
- array(
- 'id' => array('=', $rowID)
- )
- );
- } else {
-
- // Found entry is a managed cable... zeroize
- $qls->SQL->update(
- 'app_inventory',
- array(
- $localAttrPrefix.'_object_id' => 0,
- $localAttrPrefix.'_port_id' => 0,
- $localAttrPrefix.'_object_face' => 0,
- $localAttrPrefix.'_object_depth' => 0
- ),
- array(
- 'id' => array('=', $rowID)
- )
- );
+ if ($inventoryEntry['localEndID'] == 0) {
+
+ // Found entry is not a managed cable... delete
+ $qls->SQL->delete('app_inventory', array('id' => array('=', $rowID)));
+ } else {
+
+ // Found entry is a managed cable... zeroize
+ $qls->SQL->update(
+ 'app_inventory',
+ array(
+ $localAttrPrefix.'_object_id' => 0,
+ $localAttrPrefix.'_port_id' => 0,
+ $localAttrPrefix.'_object_face' => 0,
+ $localAttrPrefix.'_object_depth' => 0
+ ),
+ array(
+ 'id' => array('=', $rowID)
+ )
+ );
+ }
}
}
@@ -175,21 +171,17 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
$objFace = $data['objFace'];
$objDepth = $data['objDepth'];
$objPort = $data['objPort'];
- $obj = (isset($qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort])) ? $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort] : false;
-
- // 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 inventory table entry
- $objRowID = $obj['rowID'];
- if($obj['localEndID'] or $obj['remoteEndID']) {
- clearTableInventory($qls, $obj['localAttrPrefix'], $objRowID);
- } else {
- $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID)));
+ if(isset($qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort])) {
+ $port = $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort];
+ foreach($port as $connection) {
+ // Clear inventory table entry
+ $rowID = $connection['rowID'];
+ if($connection['localEndID'] or $connection['remoteEndID']) {
+ clearTableInventory($qls, $connection['localAttrPrefix'], $rowID);
+ } else {
+ $qls->SQL->delete('app_inventory', array('id' => array('=', $rowID)));
+ }
+ }
}
// Clear populated port entry
@@ -197,16 +189,19 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
// Log history
$localPort = $qls->App->generateObjectPortName($objID, $objFace, $objDepth, $objPort);
- $remotePortData = $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort];
- $remoteObjID = $remotePortData['id'];
- $remoteObjFace = $remotePortData['face'];
- $remoteObjDepth = $remotePortData['depth'];
- $remoteObjPort = $remotePortData['port'];
- $remotePort = $qls->App->generateObjectPortName($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort);
- $actionString = 'Deleted connection: '.$localPort.' to '.$remotePort.'';
+ $port = $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort];
+ $remotePortArray = array();
+ foreach($port as $connection) {
+ $remoteObjID = $connection['id'];
+ $remoteObjFace = $connection['face'];
+ $remoteObjDepth = $connection['depth'];
+ $remoteObjPort = $connection['port'];
+ $remotePortName = $qls->App->generateObjectPortName($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort);
+ array_push($remotePortArray, $remotePortName);
+ }
+ $remotePortString = implode('
', $remotePortArray);
+ $actionString = 'Deleted connection: '.$localPort.' to '.$remotePortString.'';
$qls->App->logAction(3, 3, $actionString);
-
- $validate->returnData['success']['oldPeerPortID'] = $oldPeerPortID;
break;
@@ -215,7 +210,6 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
$validate->returnData['success'] = array();
$value = $data['value'];
$clear = $value == 'clear' ? true : false;
- $peerPortID = '';
foreach($value as $peerPortString) {
@@ -232,8 +226,6 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
$objDepth = $data['objDepth'];
$objPort = $data['objPort'];
$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
$objIDArray = array($elementID, $objID);
@@ -253,58 +245,59 @@ 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
if($obj and $element) {
- $objRowID = $obj['rowID'];
- $elementRowID = $element['rowID'];
-
- // Are the ports connected to each other?
- if($obj['rowID'] == $element['rowID']) {
- if($obj['localEndID'] or $obj['remoteEndID']) {
- clearTableInventory($qls, 'a', $objRowID);
- clearTableInventory($qls, 'b', $objRowID);
- } else {
- $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID)));
- }
- } else {
- if($obj['localEndID'] or $obj['remoteEndID']) {
- clearTableInventory($qls, $obj['localAttrPrefix'], $objRowID);
- } else {
- $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID)));
- }
-
- if($element['localEndID'] or $element['remoteEndID']) {
- clearTableInventory($qls, $element['localAttrPrefix'], $elementRowID);
- } else {
- $qls->SQL->delete('app_inventory', array('id' => array('=', $elementRowID)));
+ foreach($obj as $objConnection) {
+ $objRowID = $objConnection['rowID'];
+ foreach($element as $elementConnection) {
+ $elementRowID = $elementConnection['rowID'];
+
+ // Are the ports connected to each other?
+ if($objConnection['rowID'] == $elementConnection['rowID']) {
+ if($objConnection['localEndID'] or $objConnection['remoteEndID']) {
+ clearTableInventory($qls, 'a', $objRowID);
+ clearTableInventory($qls, 'b', $objRowID);
+ } else {
+ $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID)));
+ }
+ } else {
+ if($objConnection['localEndID'] or $objConnection['remoteEndID']) {
+ clearTableInventory($qls, $objConnection['localAttrPrefix'], $objRowID);
+ } else {
+ $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID)));
+ }
+
+ if($elementConnection['localEndID'] or $elementConnection['remoteEndID']) {
+ clearTableInventory($qls, $elementConnection['localAttrPrefix'], $elementRowID);
+ } else {
+ $qls->SQL->delete('app_inventory', array('id' => array('=', $elementRowID)));
+ }
+ }
}
}
} else if($obj) {
- $objRowID = $obj['rowID'];
-
- if($obj['localEndID'] or $obj['remoteEndID']) {
- clearTableInventory($qls, $obj['localAttrPrefix'], $objRowID);
- } else {
- $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID)));
+ foreach($obj as $objConnection) {
+ $objRowID = $objConnection['rowID'];
+
+ if($objConnection['localEndID'] or $objConnection['remoteEndID']) {
+ clearTableInventory($qls, $objConnection['localAttrPrefix'], $objRowID);
+ } else {
+ $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID)));
+ }
}
} else if($element) {
- $elementRowID = $element['rowID'];
-
- if($element['localEndID'] or $element['remoteEndID']) {
- clearTableInventory($qls, $element['localAttrPrefix'], $elementRowID);
- } else {
- $qls->SQL->delete('app_inventory', array('id' => array('=', $elementRowID)));
+ foreach($element as $elementConnection) {
+ $elementRowID = $elementConnection['rowID'];
+
+ if($elementConnection['localEndID'] or $elementConnection['remoteEndID']) {
+ clearTableInventory($qls, $elementConnection['localAttrPrefix'], $elementRowID);
+ } else {
+ $qls->SQL->delete('app_inventory', array('id' => array('=', $elementRowID)));
+ }
}
}
@@ -323,9 +316,6 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
}
- $validate->returnData['success']['peerPortID'] = $peerPortID;
- $validate->returnData['success']['oldPeerPortID'] = $oldPeerPortID;
-
break;
}
}
diff --git a/includes/content-path.php b/includes/content-path.php
index 774b709..b57bd40 100755
--- a/includes/content-path.php
+++ b/includes/content-path.php
@@ -91,13 +91,6 @@ for($x=0; $x<2; $x++){
'connectorType' => $connection[$localAttrPrefix.'_connector']
)
);
- /*
- if($x == 0) {
- array_push($path, $workingArray);
- } else {
- array_unshift($path, $workingArray);
- }
- */
// Cable
$mediaTypeID = $connection['mediaType'];
@@ -111,13 +104,6 @@ for($x=0; $x<2; $x++){
'length' => $length
)
);
- /*
- if($x == 0) {
- array_push($path, $workingArray);
- } else {
- array_unshift($path, $workingArray);
- }
- */
// Remote Connection
$connector2WorkingArray = array(
@@ -127,13 +113,6 @@ for($x=0; $x<2; $x++){
'connectorType' => $connection[$remoteAttrPrefix.'_connector']
)
);
- /*
- if($x == 0) {
- array_push($path, $workingArray);
- } else {
- array_unshift($path, $workingArray);
- }
- */
// Object
if($connection[$remoteAttrPrefix.'_object_id'] != 0) {
@@ -172,13 +151,6 @@ for($x=0; $x<2; $x++){
'type' => 'trunk',
'data' => array()
);
- /*
- if($x == 0) {
- array_push($path, $workingArray);
- } else {
- array_unshift($path, $workingArray);
- }
- */
} else {
// No trunk peer found