From 57bdd24fd9a04fff3ea979113d36ef52c527aff2 Mon Sep 17 00:00:00 2001 From: Garrett Date: Tue, 29 Dec 2020 05:27:32 +0000 Subject: [PATCH] 0.3.12 --- assets/pages/jquery.drawConnections.js | 34 +++++++++++++++++++------- assets/pages/jquery.explore.js | 1 + includes/App.class.php | 28 +++++---------------- includes/content-path.php | 23 ++++++----------- 4 files changed, 40 insertions(+), 46 deletions(-) diff --git a/assets/pages/jquery.drawConnections.js b/assets/pages/jquery.drawConnections.js index 2256740..18174cf 100755 --- a/assets/pages/jquery.drawConnections.js +++ b/assets/pages/jquery.drawConnections.js @@ -38,7 +38,7 @@ function drawConnection(elementArray){ context.strokeStyle = 'LightSkyBlue'; context.lineWidth = 3; context.beginPath(); - console.log('Debug (elementArray): '+JSON.stringify(elementArray)); + //console.log('Debug (elementArray): '+JSON.stringify(elementArray)); $.each(elementArray, function(index, element){ var elemA = element[0]; @@ -236,19 +236,15 @@ function crawlPath(selectedPort){ } while($(selectedPort).length) { - console.log('here1'); portArray.push(selectedPort); // Crawl connection peer var connectedPortIDString = $(selectedPort).data('connectedGlobalId'); var connectedPortIDArray = JSON.parse(atob(connectedPortIDString)); - console.log('Debug (connectedPortIDString): '+atob(connectedPortIDString)); - if(connectedPortIDArray.length) { var peerPortFound = false; $.each(connectedPortIDArray, function(index, connectedPortID){ - console.log('Debug (connectedPortID): '+connectedPortID); var connectedPort = $('#'+connectedPortID); if($(connectedPort).length) { @@ -277,14 +273,10 @@ function crawlPath(selectedPort){ if(connectedPartitionPeerID != 'none') { trunkArray.push([connectedPartition, connectedPartitionPeerID]); } - //selectedPort = false; - //return false; } } else { connectionArray.push([selectedPort, connectedPortID]); - //selectedPort = false; - //return 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(){ resizeCanvas(); diff --git a/assets/pages/jquery.explore.js b/assets/pages/jquery.explore.js index 938dbc5..3c6ba53 100755 --- a/assets/pages/jquery.explore.js +++ b/assets/pages/jquery.explore.js @@ -261,6 +261,7 @@ function retrievePortPath(objID, objFace, partitionDepth, portID){ } else { $('#containerFullPath').html(responseJSON.success); makeCableConnectorsClickable(); + drawPathDiagram(); } }); } diff --git a/includes/App.class.php b/includes/App.class.php index a3d31d5..f9ecbde 100755 --- a/includes/App.class.php +++ b/includes/App.class.php @@ -1990,17 +1990,9 @@ var $qls; } $connectorTypeID = $object['data']['connectorType']; - - if($connectorTypeID != 0) { - $connectorTypeName = $this->portTypeValueArray[$connectorTypeID]['name']; - $connectorHTML = '
'; - } else { - $connectorTypeName = 'Unk'; - $connectorHTML = '
'; - } - - // Wrap in and add to row array - $htmlString = ''.$connectorHTML.''; + $connectionPairID = $object['data']['connectionPairID']; + $connectorTypeName = ($connectorTypeID != 0) ? $this->portTypeValueArray[$connectorTypeID]['name'] : 'Unk'; + $htmlString = '
'; array_push($tableArray[count($tableArray)-1], $htmlString); if($objectIndex == count($path)-1) { @@ -2055,17 +2047,9 @@ var $qls; if($path[$objectIndex+1]['type'] == 'trunk' or !isset($path[$objectIndex+1])) { if(isset($path[$objectIndex-1])) { $connectorTypeID = $path[$objectIndex-1]['data']['connectorType']; - - if($connectorTypeID != 0) { - $connectorTypeName = $this->portTypeValueArray[$connectorTypeID]['name']; - $connectorHTML = '
'; - } else { - $connectorTypeName = 'Unk'; - $connectorHTML = '
'; - } - - // Wrap in and add to row array - $htmlString = ''.$connectorHTML.''; + $connectionPairID = $path[$objectIndex-1]['data']['connectionPairID']; + $connectorTypeName = ($connectorTypeID != 0) ? $this->portTypeValueArray[$connectorTypeID]['name'] : 'Unk'; + $htmlString = '
'; array_push($tableArray[count($tableArray)-1], $htmlString); array_push($tableArray[count($tableArray)-1], ''); diff --git a/includes/content-path.php b/includes/content-path.php index 6c43776..0eebeb4 100755 --- a/includes/content-path.php +++ b/includes/content-path.php @@ -44,6 +44,8 @@ if($isTrunked) { $reversePortID = 0; } +$connectionPairID = 1; + // Discover path elements // First look outward from the far 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']; $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 $connector1WorkingArray = array( 'type' => 'connector', 'data' => array( 'code39' => $connection[$localAttrPrefix.'_code39'], - 'connectorType' => $localConnectorType + 'connectorType' => $connection[$localAttrPrefix.'_connector'], + 'connectionPairID' => $connectionPairID ) ); @@ -123,7 +113,8 @@ for($x=0; $x<2; $x++){ 'type' => 'connector', 'data' => array( '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 $objID = 0; } + + $connectionPairID++; } // Now that we've discovered the far side of the scanned cable,