This commit is contained in:
Garrett 2020-12-29 05:27:32 +00:00
parent 1cebdf1303
commit 57bdd24fd9
4 changed files with 40 additions and 46 deletions

View File

@ -38,7 +38,7 @@ function drawConnection(elementArray){
context.strokeStyle = 'LightSkyBlue'; context.strokeStyle = 'LightSkyBlue';
context.lineWidth = 3; context.lineWidth = 3;
context.beginPath(); context.beginPath();
console.log('Debug (elementArray): '+JSON.stringify(elementArray)); //console.log('Debug (elementArray): '+JSON.stringify(elementArray));
$.each(elementArray, function(index, element){ $.each(elementArray, function(index, element){
var elemA = element[0]; var elemA = element[0];
@ -236,19 +236,15 @@ function crawlPath(selectedPort){
} }
while($(selectedPort).length) { while($(selectedPort).length) {
console.log('here1');
portArray.push(selectedPort); portArray.push(selectedPort);
// Crawl connection peer // Crawl connection peer
var connectedPortIDString = $(selectedPort).data('connectedGlobalId'); var connectedPortIDString = $(selectedPort).data('connectedGlobalId');
var connectedPortIDArray = JSON.parse(atob(connectedPortIDString)); var connectedPortIDArray = JSON.parse(atob(connectedPortIDString));
console.log('Debug (connectedPortIDString): '+atob(connectedPortIDString));
if(connectedPortIDArray.length) { if(connectedPortIDArray.length) {
var peerPortFound = false; var peerPortFound = false;
$.each(connectedPortIDArray, function(index, connectedPortID){ $.each(connectedPortIDArray, function(index, connectedPortID){
console.log('Debug (connectedPortID): '+connectedPortID);
var connectedPort = $('#'+connectedPortID); var connectedPort = $('#'+connectedPortID);
if($(connectedPort).length) { if($(connectedPort).length) {
@ -277,14 +273,10 @@ function crawlPath(selectedPort){
if(connectedPartitionPeerID != 'none') { if(connectedPartitionPeerID != 'none') {
trunkArray.push([connectedPartition, connectedPartitionPeerID]); trunkArray.push([connectedPartition, connectedPartitionPeerID]);
} }
//selectedPort = false;
//return false;
} }
} else { } else {
connectionArray.push([selectedPort, connectedPortID]); connectionArray.push([selectedPort, connectedPortID]);
//selectedPort = false;
//return false;
} }
}); });
if(peerPortFound == false) { if(peerPortFound == false) {
@ -304,6 +296,30 @@ function crawlPath(selectedPort){
}; };
} }
function crawlPathDiagram(){
var pathElementArray = {};
var connectorElementArray = $('#containerFullPath').find('.port');
$.each(connectorElementArray, function(index, element){
console.log('here1');
if($(element).data('connectionPairId') !== undefined) {
console.log('here2');
var connectionPairID = $(element).data('connectionPairId');
if(pathElementArray[connectionPairID] === undefined) {
console.log('here3');
pathElementArray[connectionPairID] = [];
}
pathElementArray[connectionPairID].push($(element));
}
});
return pathElementArray;
}
function drawPathDiagram(){
var pathElementArray = crawlPathDiagram();
console.log(JSON.stringify(pathElementArray));
drawConnection(pathElementArray);
}
function makePortsHoverable(){ function makePortsHoverable(){
resizeCanvas(); resizeCanvas();

View File

@ -261,6 +261,7 @@ function retrievePortPath(objID, objFace, partitionDepth, portID){
} else { } else {
$('#containerFullPath').html(responseJSON.success); $('#containerFullPath').html(responseJSON.success);
makeCableConnectorsClickable(); makeCableConnectorsClickable();
drawPathDiagram();
} }
}); });
} }

View File

@ -1990,17 +1990,9 @@ var $qls;
} }
$connectorTypeID = $object['data']['connectorType']; $connectorTypeID = $object['data']['connectorType'];
$connectionPairID = $object['data']['connectionPairID'];
if($connectorTypeID != 0) { $connectorTypeName = ($connectorTypeID != 0) ? $this->portTypeValueArray[$connectorTypeID]['name'] : 'Unk';
$connectorTypeName = $this->portTypeValueArray[$connectorTypeID]['name']; $htmlString = '<td><div title="'.$connectorTypeName.'" class="port '.$connectorTypeName.'" data-connection-pair-id='.$connectionPairID.'></div></td>';
$connectorHTML = '<div title="'.$connectorTypeName.'" class="port '.$connectorTypeName.'"></div>';
} else {
$connectorTypeName = 'Unk';
$connectorHTML = '<div title="'.$connectorTypeName.'" class="port '.$connectorTypeName.'"></div>';
}
// Wrap in <td> and add to row array
$htmlString = '<td>'.$connectorHTML.'</td>';
array_push($tableArray[count($tableArray)-1], $htmlString); array_push($tableArray[count($tableArray)-1], $htmlString);
if($objectIndex == count($path)-1) { if($objectIndex == count($path)-1) {
@ -2055,17 +2047,9 @@ var $qls;
if($path[$objectIndex+1]['type'] == 'trunk' or !isset($path[$objectIndex+1])) { if($path[$objectIndex+1]['type'] == 'trunk' or !isset($path[$objectIndex+1])) {
if(isset($path[$objectIndex-1])) { if(isset($path[$objectIndex-1])) {
$connectorTypeID = $path[$objectIndex-1]['data']['connectorType']; $connectorTypeID = $path[$objectIndex-1]['data']['connectorType'];
$connectionPairID = $path[$objectIndex-1]['data']['connectionPairID'];
if($connectorTypeID != 0) { $connectorTypeName = ($connectorTypeID != 0) ? $this->portTypeValueArray[$connectorTypeID]['name'] : 'Unk';
$connectorTypeName = $this->portTypeValueArray[$connectorTypeID]['name']; $htmlString = '<td><div title="'.$connectorTypeName.'" class="port '.$connectorTypeName.'" data-connection-pair-id='.$connectionPairID.'></div></td>';
$connectorHTML = '<div title="'.$connectorTypeName.'" class="port '.$connectorTypeName.'"></div>';
} else {
$connectorTypeName = 'Unk';
$connectorHTML = '<div title="'.$connectorTypeName.'" class="port '.$connectorTypeName.'"></div>';
}
// Wrap in <td> and add to row array
$htmlString = '<td>'.$connectorHTML.'</td>';
array_push($tableArray[count($tableArray)-1], $htmlString); array_push($tableArray[count($tableArray)-1], $htmlString);
array_push($tableArray[count($tableArray)-1], '<td></td>'); array_push($tableArray[count($tableArray)-1], '<td></td>');

View File

@ -44,6 +44,8 @@ if($isTrunked) {
$reversePortID = 0; $reversePortID = 0;
} }
$connectionPairID = 1;
// Discover path elements // Discover path elements
// First look outward from the far end of the cable, // First look outward from the far end of the cable,
// then look outward from the near end of the cable. // then look outward from the near end of the cable.
@ -83,25 +85,13 @@ for($x=0; $x<2; $x++){
$remoteAttrPrefix = $inventory['remoteAttrPrefix']; $remoteAttrPrefix = $inventory['remoteAttrPrefix'];
$connection = $qls->App->inventoryAllArray[$inventoryID]; $connection = $qls->App->inventoryAllArray[$inventoryID];
// Retrieve local connector type
$localObj = $qls->App->objectArray[$objID];
$localTemplateID = $localObj['template_id'];
$localConnectorType = $qls->App->compatibilityArray[$localTemplateID][$objFace][$objDepth]['portType'];
// Retrieve remote connector type
$remoteObjID = $inventory['id'];
$remoteObjFace = $inventory['face'];
$remoteObjDepth = $inventory['depth'];
$remoteObj = $qls->App->objectArray[$remoteObjID];
$remoteTemplateID = $remoteObj['template_id'];
$remoteConnectorType = $qls->App->compatibilityArray[$remoteTemplateID][$remoteObjFace][$remoteObjDepth]['portType'];
// Local Connection // Local Connection
$connector1WorkingArray = array( $connector1WorkingArray = array(
'type' => 'connector', 'type' => 'connector',
'data' => array( 'data' => array(
'code39' => $connection[$localAttrPrefix.'_code39'], 'code39' => $connection[$localAttrPrefix.'_code39'],
'connectorType' => $localConnectorType 'connectorType' => $connection[$localAttrPrefix.'_connector'],
'connectionPairID' => $connectionPairID
) )
); );
@ -123,7 +113,8 @@ for($x=0; $x<2; $x++){
'type' => 'connector', 'type' => 'connector',
'data' => array( 'data' => array(
'code39' => $connection[$remoteAttrPrefix.'_code39'], 'code39' => $connection[$remoteAttrPrefix.'_code39'],
'connectorType' => $remoteConnectorType 'connectorType' => $connection[$remoteAttrPrefix.'_connector'],
'connectionPairID' => $connectionPairID
) )
); );
@ -217,6 +208,8 @@ for($x=0; $x<2; $x++){
// No connected object // No connected object
$objID = 0; $objID = 0;
} }
$connectionPairID++;
} }
// Now that we've discovered the far side of the scanned cable, // Now that we've discovered the far side of the scanned cable,