This commit is contained in:
Garrett K 2021-01-27 05:38:08 +00:00
parent 99bd8acc97
commit 2dd3632c4e
5 changed files with 40 additions and 11 deletions

View File

@ -584,6 +584,7 @@ function makeCabCloseClickable(){
function resizePathCanvas() { function resizePathCanvas() {
$.each(pathArray, function(pathName, path){ $.each(pathArray, function(pathName, path){
var canvas = path['canvas']; var canvas = path['canvas'];
$(canvas).attr('width', $(canvas).parent().width()); $(canvas).attr('width', $(canvas).parent().width());
$(canvas).attr('height', $(canvas).parent().height()); $(canvas).attr('height', $(canvas).parent().height());
@ -627,10 +628,10 @@ function initializeCanvas() {
// Path connections // Path connections
pathArray = {}; pathArray = {};
if($('#canvasPath').length) { if($('#canvasPath').length) {
canvasPath = document.getElementById('canvasPath'); var canvas = $('#canvasPath');
pathArray['path'] = { pathArray['path'] = {
'context': canvasPath.getContext('2d'), 'context': $(canvas)[0].getContext('2d'),
'canvas': $('#canvasPath'), 'canvas': canvas,
'container' : $('#containerFullPath'), 'container' : $('#containerFullPath'),
'connections': {}, 'connections': {},
'trunks': {} 'trunks': {}
@ -638,3 +639,14 @@ function initializeCanvas() {
} }
} }
function initializeCanvasPathFinder(container) {
var canvas = $('#canvasPathFinder');
pathArray['pathFinder'] = {
'context': $(canvas)[0].getContext('2d'),
'canvas': canvas,
'container' : container,
'connections': {},
'trunks': {}
};
}

View File

@ -57,12 +57,13 @@ function clearSelectionDetails(){
} }
function makeRackObjectsClickable(){ function makeRackObjectsClickable(){
$('.port').click(function(event){ $('.port').click(function(event){
$(document).data('portClickedFlag', true); $(document).data('portClickedFlag', true);
var portIndex = $(this).data('portIndex'); var portIndex = $(this).data('portIndex');
//Store PortID //Store PortID
$(document).data('clickedObjPortID', portIndex); $(document).data('clickedObjPortID', portIndex);
}); });
@ -74,7 +75,13 @@ function makeRackObjectsClickable(){
if ($(document).data('portClickedFlag') === false) { if ($(document).data('portClickedFlag') === false) {
if ($(this).data('partitionType') == 'Connectable') { if ($(this).data('partitionType') == 'Connectable') {
// Default port selection
$(document).data('clickedObjPortID', 0); $(document).data('clickedObjPortID', 0);
// Draw cabinet connection path
$(document).data('selectedPort', $(this).find('.port').first());
drawCabinet();
} else { } else {
$(document).data('clickedObjPortID', null); $(document).data('clickedObjPortID', null);
} }
@ -717,10 +724,9 @@ $( document ).ready(function() {
$('#printPathFinder ').on('click', function(event){ $('#printPathFinder ').on('click', function(event){
event.preventDefault(); event.preventDefault();
$('#containerCablePath').printThis({ $('#containerCablePath').parent().printThis({
importStyle: true, canvas: true,
removeInline: true, importStyle: true
removeInlineSelector: "img"
}); });
}); });
@ -873,6 +879,9 @@ $( document ).ready(function() {
}); });
}); });
// Clear path connections
drawPath();
var table = ''; var table = '';
var pathID = 0; var pathID = 0;
$.each(responseJSON.success, function(pathType, pathTypeArray){ $.each(responseJSON.success, function(pathType, pathTypeArray){
@ -906,12 +915,19 @@ $( document ).ready(function() {
if($(this).hasClass('tableRowHighlight')) { if($(this).hasClass('tableRowHighlight')) {
$(this).removeClass('tableRowHighlight'); $(this).removeClass('tableRowHighlight');
$('.containerCablePath').hide(); $('.containerCablePath').hide();
// Clear path connections
drawPath();
} else { } else {
pathTable.$('tr.tableRowHighlight').removeClass('tableRowHighlight'); pathTable.$('tr.tableRowHighlight').removeClass('tableRowHighlight');
$(this).addClass('tableRowHighlight'); $(this).addClass('tableRowHighlight');
var pathIndex = $(this).attr('data-pathid'); var pathIndex = $(this).attr('data-pathid');
$('.containerCablePath').hide(); $('.containerCablePath').hide();
$('#containerCablePath'+pathIndex).show(); $('#containerCablePath'+pathIndex).show();
// Draw path connections
initializeCanvasPathFinder($('#containerCablePath'+pathIndex));
drawPath();
} }
}); });

View File

@ -304,7 +304,7 @@ $qls->Security->check_auth_page('user.php');
<blockquote class="card-blockquote"> <blockquote class="card-blockquote">
<div class="row"> <div class="row">
<!-- Canvas for drawing cabinet connections --> <!-- Canvas for drawing cabinet connections -->
<canvas id="canvasPath" class="connectionCanvas" style="z-index:1000;position:absolute; pointer-events:none;"></canvas> <canvas id="canvasPath" style="z-index:1000;position:absolute; pointer-events:none;"></canvas>
<div id="containerFullPath"></div> <div id="containerFullPath"></div>
</div> </div>
</blockquote> </blockquote>

View File

@ -18,7 +18,7 @@
<body> <body>
<!-- Canvas for drawing cabinet connections --> <!-- Canvas for drawing cabinet connections -->
<canvas id="canvasCabinet" class="connectionCanvas" style="z-index:1000;position:absolute; pointer-events:none;"></canvas> <canvas id="canvasCabinet" style="z-index:1000;position:absolute; pointer-events:none;"></canvas>
<?php require 'topbar.php'; ?> <?php require 'topbar.php'; ?>

View File

@ -161,6 +161,7 @@
</div> </div>
<div class="card-block"> <div class="card-block">
<blockquote class="card-blockquote"> <blockquote class="card-blockquote">
<canvas id="canvasPathFinder" style="z-index:1000;position:absolute; pointer-events:none;"></canvas>
<div id="containerCablePath"></div> <div id="containerCablePath"></div>
</blockquote> </blockquote>
</div> </div>