This commit is contained in:
Garrett K 2021-01-26 05:02:25 +00:00
parent 59c03f25c3
commit 15bfee5ce1
4 changed files with 45 additions and 45 deletions

View File

@ -289,17 +289,23 @@ function drawPath(){
function crawlPathConnections(){
var pathConnections = {};
var pathConnections = [];
var workingPathConnections = {};
var connectorElementArray = $('#containerFullPath').find('.port');
// Sort ports by connectionPairId
// Group connection peers
$.each(connectorElementArray, function(index, element){
if($(element).data('connectionPairId') !== '') {
var connectionPairID = $(element).data('connectionPairId');
if(pathConnections[connectionPairID] === undefined) {
pathConnections[connectionPairID] = [];
}
pathConnections[connectionPairID].push($(element));
var connectionPairID = $(element).data('connectionPairId');
if(workingPathConnections[connectionPairID] === undefined) {
workingPathConnections[connectionPairID] = [];
}
workingPathConnections[connectionPairID].push($(element));
});
// Filter out singles
$.each(workingPathConnections, function(index, element){
if(element.length == 2) {
pathConnections.push(element);
}
});
@ -309,21 +315,27 @@ function crawlPathConnections(){
function crawlPathTrunks(){
var pathTrunks = {};
var pathTrunks = [];
var workingPathTrunks = {};
var connectorElementArray = $('#containerFullPath').find('.objectBox');
// Group trunk peers
$.each(connectorElementArray, function(index, element){
var trunkPairID = $(element).data('trunkPairId');
if(workingPathTrunks[trunkPairID] === undefined) {
workingPathTrunks[trunkPairID] = [];
}
workingPathTrunks[trunkPairID].push($(element));
});
if($(element).data('trunkPairId') !== 0) {
var trunkPairID = $(element).data('trunkPairId');
if(pathTrunks[trunkPairID] === undefined) {
pathTrunks[trunkPairID] = [];
}
pathTrunks[trunkPairID].push($(element));
// Filter out singles
$.each(workingPathTrunks, function(index, element){
if(element.length == 2) {
pathTrunks.push(element);
}
});
// Store path trunk data
$(document).data('pathTrunks', pathTrunks);
}

View File

@ -321,7 +321,6 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
findPaths2($qls, $maxResults, $maxDepth, $reachable, $endpointAObj, $endpointBObj, $finalPathArray, $previousPathType);
}
error_log('Debug (finalPathArray): '.json_encode($finalPathArray));
foreach($finalPathArray as $mediaType => &$pathData) {
foreach($pathData as &$path) {
$path['pathHTML'] = $qls->App->buildPathFull($path['pathArray'], null);

View File

@ -1959,6 +1959,9 @@ var $qls;
$pathOrientation = $this->qls->user_info['pathOrientation'];
$connectionPairID = 1;
$trunkPairID = 1;
// Cable Adjacent
if($pathOrientation == 0) {
foreach($path as $objectIndex => $object) {
@ -1968,15 +1971,10 @@ var $qls;
case 'connector':
$addConnector = false;
// Should connector be added?
if(isset($path[$objectIndex+1])) {
if($path[$objectIndex+1]['type'] != 'object') {
$addConnector = true;
}
$addConnector = ($path[$objectIndex+1]['type'] != 'object') ? true : false;
} else {
$addConnector = true;
}
@ -1986,8 +1984,8 @@ var $qls;
array_push($tableArray[count($tableArray)-1], '<td>'.$this->wrapObject(0, 'None').'</td>');
}
// Generate and push connector HTML
$connectorTypeID = $object['data']['connectorType'];
$connectionPairID = $object['data']['connectionPairID'];
$connectorTypeName = ($connectorTypeID != 0) ? $this->portTypeValueArray[$connectorTypeID]['name'] : 'Unk';
$htmlString = '<td><div title="'.$connectorTypeName.'" class="port '.$connectorTypeName.'" data-connection-pair-id='.$connectionPairID.'></div></td>';
array_push($tableArray[count($tableArray)-1], $htmlString);
@ -2001,6 +1999,8 @@ var $qls;
case 'cable':
$trunkPairID++;
$cableTypeID = $object['data']['mediaTypeID'];
if($cableTypeID != 0) {
$cableTypeName = $mediaTypeClass = $this->mediaTypeValueArray[$cableTypeID]['name'];
@ -2025,7 +2025,6 @@ var $qls;
case 'object':
$trunkPairID = $object['trunkPairID'];
$objName = '';
foreach($object['data'] as $item) {
$objID = $item['id'];
@ -2045,7 +2044,6 @@ var $qls;
if($path[$objectIndex+1]['type'] == 'trunk' or !isset($path[$objectIndex+1])) {
if(isset($path[$objectIndex-1])) {
$connectorTypeID = $path[$objectIndex-1]['data']['connectorType'];
$connectionPairID = $path[$objectIndex-1]['data']['connectionPairID'];
$connectorTypeName = ($connectorTypeID != 0) ? $this->portTypeValueArray[$connectorTypeID]['name'] : 'Unk';
$htmlString = '<td><div title="'.$connectorTypeName.'" class="port '.$connectorTypeName.'" data-connection-pair-id='.$connectionPairID.'></div></td>';
array_push($tableArray[count($tableArray)-1], $htmlString);
@ -2064,6 +2062,8 @@ var $qls;
case 'trunk':
$connectionPairID++;
$htmlString = '<div title="Trunk" class="trunk adjacent">';
// Wrap in <td> and add to row array
@ -2116,7 +2116,6 @@ var $qls;
case 'connector':
$htmlPathFull .= '<tr><td>';
$connectorTypeID = $object['data']['connectorType'];
$connectionPairID = $object['data']['connectionPairID'];
if($connectorTypeID != 0) {
$connectorTypeName = $this->connectorTypeValueArray[$connectorTypeID]['name'];
@ -2152,6 +2151,9 @@ var $qls;
break;
case 'trunk':
$connectionPairID++;
$htmlPathFull .= '<td rowspan="2">';
$htmlPathFull .= '<div title="Trunk" class="trunk stacked">';
$htmlPathFull .= '</td>';

View File

@ -44,9 +44,6 @@ if($isTrunked) {
$reversePortID = 0;
}
$connectionPairID = 1;
$trunkPairID = 1;
// Discover path elements
// First look outward from the far end of the cable,
// then look outward from the near end of the cable.
@ -56,10 +53,8 @@ for($x=0; $x<2; $x++){
// Object
$selected = ($objID == $selectedObjID and $objFace == $selectedObjFace and $objDepth == $selectedObjDepth and $objPort == $selectedObjPort) ? true : false;
$trunkPairID = (isset($qls->App->peerArray[$objID][$objFace][$objDepth])) ? $qls->App->peerArray[$objID][$objFace][$objDepth]['id'] : 0;
$workingArray = array(
'type' => 'object',
'trunkPairID' => $trunkPairID,
'data' => array(
array(
'id' => $objID,
@ -93,8 +88,7 @@ for($x=0; $x<2; $x++){
'type' => 'connector',
'data' => array(
'code39' => $connection[$localAttrPrefix.'_code39'],
'connectorType' => $connection[$localAttrPrefix.'_connector'],
'connectionPairID' => $connectionPairID
'connectorType' => $connection[$localAttrPrefix.'_connector']
)
);
@ -116,8 +110,7 @@ for($x=0; $x<2; $x++){
'type' => 'connector',
'data' => array(
'code39' => $connection[$remoteAttrPrefix.'_code39'],
'connectorType' => $connection[$remoteAttrPrefix.'_connector'],
'connectionPairID' => $connectionPairID
'connectorType' => $connection[$remoteAttrPrefix.'_connector']
)
);
@ -129,9 +122,6 @@ for($x=0; $x<2; $x++){
$objDepth = $connection[$remoteAttrPrefix.'_object_depth'];
$objPort = $connection[$remoteAttrPrefix.'_port_id'];
$trunkPairID = (isset($qls->App->peerArray[$objID][$objFace][$objDepth])) ? $qls->App->peerArray[$objID][$objFace][$objDepth]['id'] : 0;
$objectWorkingArray['trunkPairID'] = $trunkPairID;
// Remote Object
$workingArray = array(
'id' => $objID,
@ -214,9 +204,6 @@ for($x=0; $x<2; $x++){
// No connected object
$objID = 0;
}
$connectionPairID++;
$trunkPairID++;
}
// Now that we've discovered the far side of the scanned cable,