diff --git a/assets/pages/jquery.explore.js b/assets/pages/jquery.explore.js
index 54311ec..a180b12 100755
--- a/assets/pages/jquery.explore.js
+++ b/assets/pages/jquery.explore.js
@@ -4,6 +4,48 @@
* Tree view
*/
+function initializeEditable(){
+
+ // Port Description
+ $('#inline-portDescription').editable({
+ display: function(value){
+ $(this).text(value);
+ },
+ pk: 1,
+ mode: 'inline',
+ showbuttons: false,
+ onblure: 'submit',
+ url: 'backend/process_port.php',
+ params: function(params){
+
+ var objID = $(document).data('clickedObjID');
+ var objFace = $(document).data('clickedObjFace');
+ var objDepth = $(document).data('clickedObjPartitionDepth');
+ var portID = $(document).data('clickedObjPortID');
+ var data = {
+ 'action': 'portDescription',
+ 'objID': objID,
+ 'objFace': objFace,
+ 'objDepth': objDepth,
+ 'portID': portID,
+ 'value': params.value
+ };
+ params.data = JSON.stringify(data);
+ return params;
+ },
+ success: function(responseJSON) {
+ var response = JSON.parse(responseJSON);
+ if (response.active == 'inactive'){
+ window.location.replace("/");
+ } else if ($(response.error).size() > 0){
+ displayError(response.error);
+ } else {
+ $('#alertMsg').empty();
+ }
+ }
+ }).editable('option', 'disabled', true);
+}
+
function makeAddCabButtonClickable(addCabButton){
$(addCabButton).click(function(event){
event.preventDefault();
@@ -299,6 +341,13 @@ function retrievePortOptions(objID, objFace, partitionDepth, portID){
if($(responseJSON.error).size() > 0) {
displayError(responseJSON.error);
} else {
+
+ // Port description
+ $('#inline-portDescription')
+ .editable('option', 'value', responseJSON.success.portDescription)
+ .editable('option', 'disabled', false);
+
+ // Port populated
$('#checkboxPopulated').prop("checked", responseJSON.success.populatedChecked);
$('#checkboxPopulated').prop("disabled", responseJSON.success.populatedDisabled);
@@ -477,9 +526,19 @@ function getFloorplanObjectPeerTable(){
function selectObject(parentObject){
var objID = $('#objID').val();
- var selection = $(parentObject).find('[data-template-object-id='+objID+'][data-object-face=0]').children('.selectable:first');
+ if($('#objFace').length && $('#objDepth').length && $('#portID').length) {
+ var objFace = $('#objFace').val();
+ var objDepth = $('#objDepth').val();
+ var portID = $('#portID').val();
+ var selection = $('#port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+portID);
+ } else {
+ var selection = $(parentObject).find('[data-template-object-id='+objID+'][data-object-face=0]').children('.selectable:first');
+ }
$(selection).click();
$('#objID').remove();
+ $('#objFace').remove();
+ $('#objDepth').remove();
+ $('#portID').remove();
}
function portDesignation(elem, action, flag) {
@@ -735,6 +794,8 @@ $( document ).ready(function() {
// requires jquery.drawConnections.js
initializeCanvas();
+ initializeEditable();
+
// Export to Viso button
$('#buttonVisioExport').on('click', function(){
window.open('/backend/export-visio.php');
@@ -818,9 +879,10 @@ $( document ).ready(function() {
}
var data = {
+ action: 'portPopulated',
objID: objID,
objFace: objFace,
- partitionDepth: objDepth,
+ objDepth: objDepth,
portID: objPort,
portPopulated: portPopulated
}
@@ -828,7 +890,7 @@ $( document ).ready(function() {
data = JSON.stringify(data);
// Retrieve the selected port's path
- $.post('backend/process_port_populated.php', {data:data}, function(response){
+ $.post('backend/process_port.php', {data:data}, function(response){
var responseJSON = JSON.parse(response);
if($(responseJSON.error).size() > 0) {
displayError(responseJSON.error);
diff --git a/backend/process_port.php b/backend/process_port.php
new file mode 100755
index 0000000..2839f47
--- /dev/null
+++ b/backend/process_port.php
@@ -0,0 +1,191 @@
+Security->check_auth_page('user.php');
+
+if($_SERVER['REQUEST_METHOD'] == 'POST'){
+ require_once('../includes/Validate.class.php');
+ $validate = new Validate($qls);
+
+ if ($validate->returnData['active'] == 'inactive') {
+ echo json_encode($validate->returnData);
+ return;
+ }
+
+ $data = json_decode($_POST['data'], true);
+ validate($data, $validate);
+
+ if (!count($validate->returnData['error'])){
+
+ $action = $data['action'];
+ $objID = $data['objID'];
+ $objFace = $data['objFace'];
+ $objDepth = $data['objDepth'];
+ $portID = $data['portID'];
+
+ switch($action) {
+
+ case 'portPopulated';
+
+ $portPopulated = $data['portPopulated'];
+
+ if($portPopulated) {
+ $qls->SQL->insert(
+ 'app_populated_port',
+ array(
+ 'object_id',
+ 'object_face',
+ 'object_depth',
+ 'port_id'
+ ),
+ array(
+ $objID,
+ $objFace,
+ $objDepth,
+ $portID
+ )
+ );
+
+ // Log history
+ $portName = $qls->App->generateObjectPortName($objID, $objFace, $objDepth, $portID);
+ $actionString = 'Marked port as populated: '.$portName.'';
+ $qls->App->logAction(2, 2, $actionString);
+
+ } else {
+ $qls->SQL->delete(
+ 'app_populated_port',
+ array(
+ 'object_id' => array('=', $objID),
+ 'AND',
+ 'object_face' => array('=', $objFace),
+ 'AND',
+ 'object_depth' => array('=', $objDepth),
+ 'AND',
+ 'port_id' => array('=', $portID)
+ )
+ );
+
+ // Log history
+ $portName = $qls->App->generateObjectPortName($objID, $objFace, $objDepth, $portID);
+ $actionString = 'Marked port as unpopulated: '.$portName.'';
+ $qls->App->logAction(3, 2, $actionString);
+ }
+ break;
+
+ case 'portDescription';
+
+ $descriptionNew = $data['value'];
+ $portName = $qls->App->generateObjectPortName($objID, $objFace, $objDepth, $portID);
+
+ // Store original description
+ if(isset($qls->App->portDescriptionArray[$objID][$objFace][$objDepth][$portID])) {
+
+ $portDescription = $qls->App->portDescriptionArray[$objID][$objFace][$objDepth][$portID];
+ $descriptionID = $portDescription['id'];
+ $descriptionOrig = $portDescription['description'];
+
+ if($descriptionNew == '') {
+
+ $qls->SQL->delete('app_port_description', array('id' => array('=', $descriptionID)));
+ $actionVerb = 3;
+ $actionString = 'Deleted port description: '.$portName.' - '.$descriptionOrig.'';
+ } else {
+
+ $qls->SQL->update('app_port_description', array('description' => $descriptionNew), array('id' => array('=', $descriptionID)));
+ $actionVerb = 2;
+ $actionString = 'Changed port description: '.$portName.' - from '.$descriptionOrig.' to '.$descriptionNew.'';
+ }
+ } else {
+
+ if($descriptionNew != '') {
+ // Write new description
+ $qls->SQL->insert(
+ 'app_port_description',
+ array(
+ 'object_id',
+ 'object_face',
+ 'object_depth',
+ 'port_id',
+ 'description'
+ ),
+ array(
+ $objID,
+ $objFace,
+ $objDepth,
+ $portID,
+ $descriptionNew
+ )
+ );
+
+ $actionVerb = 1;
+ $actionString = 'Added port description: '.$portName.' - '.$descriptionNew.'';
+ }
+ }
+
+ $qls->App->logAction(3, $actionVerb, $actionString);
+ break;
+ }
+ }
+ echo json_encode($validate->returnData);
+ return;
+}
+
+function validate($data, &$validate){
+
+ $action = $data['action'];
+ $objID = $data['objID'];
+ $objFace = $data['objFace'];
+ $objDepth = $data['objDepth'];
+ $objPortID = $data['portID'];
+
+ //Validate object ID
+ $validate->validateObjectID($objID);
+
+ //Validate object face
+ $validate->validateObjectFace($objFace);
+
+ //Validate partition depth
+ $validate->validatePartitionDepth($objDepth);
+
+ //Validate port ID
+ $validate->validatePortID($objPortID, 'port ID');
+
+ //Validate endpoint port trunked
+ $portArray = array(
+ array($objID, $objFace, $objDepth, $objPortID)
+ );
+ $validate->validateTrunkedEndpoint($portArray);
+
+ // Validate action
+ $actionArray = array(
+ 'portPopulated',
+ 'portDescription'
+ );
+ $ref = 'action';
+ if($validate->validateInArray($action, $actionArray, $ref)) {
+
+ switch($action) {
+
+ case 'portPopulated':
+
+ // Validate port populated
+ $portPopulatedFlag = $data['portPopulated'];
+ $validate->validateTrueFalse($portPopulatedFlag, 'port populated flag');
+
+ break;
+
+ case 'portDescription':
+
+ // Validate port description
+ $portDescription = $data['value'];
+ $validate->validateText($portDescription, 'port description');
+
+ break;
+
+ }
+
+ }
+
+ return;
+}
+?>
diff --git a/backend/process_port_populated.php b/backend/process_port_populated.php
deleted file mode 100755
index 1c30fb3..0000000
--- a/backend/process_port_populated.php
+++ /dev/null
@@ -1,101 +0,0 @@
-Security->check_auth_page('user.php');
-
-if($_SERVER['REQUEST_METHOD'] == 'POST'){
- require_once('../includes/Validate.class.php');
- $validate = new Validate($qls);
-
- if ($validate->returnData['active'] == 'inactive') {
- echo json_encode($validate->returnData);
- return;
- }
-
- $data = json_decode($_POST['data'], true);
- validate($data, $validate);
-
- if (!count($validate->returnData['error'])){
- $objectID = $data['objID'];
- $objectFace = $data['objFace'];
- $partitionDepth = $data['partitionDepth'];
- $portID = $data['portID'];
- $portPopulated = $data['portPopulated'];
-
- if($portPopulated) {
- $qls->SQL->insert(
- 'app_populated_port',
- array(
- 'object_id',
- 'object_face',
- 'object_depth',
- 'port_id'
- ),
- array(
- $objectID,
- $objectFace,
- $partitionDepth,
- $portID
- )
- );
-
- // Log history
- $portName = $qls->App->generateObjectPortName($objectID, $objectFace, $partitionDepth, $portID);
- $actionString = 'Marked port as populated: '.$portName.'';
- $qls->App->logAction(2, 2, $actionString);
-
- } else {
- $qls->SQL->delete(
- 'app_populated_port',
- array(
- 'object_id' => array('=', $objectID),
- 'AND',
- 'object_face' => array('=', $objectFace),
- 'AND',
- 'object_depth' => array('=', $partitionDepth),
- 'AND',
- 'port_id' => array('=', $portID)
- )
- );
-
- // Log history
- $portName = $qls->App->generateObjectPortName($objectID, $objectFace, $partitionDepth, $portID);
- $actionString = 'Marked port as unpopulated: '.$portName.'';
- $qls->App->logAction(3, 2, $actionString);
- }
- }
- echo json_encode($validate->returnData);
- return;
-}
-
-function validate($data, &$validate){
-
- $objID = $data['objID'];
- $objFace = $data['objFace'];
- $objDepth = $data['partitionDepth'];
- $objPortID = $data['portID'];
-
- //Validate object ID
- $validate->validateObjectID($objID);
-
- //Validate object face
- $validate->validateObjectFace($objFace);
-
- //Validate partition depth
- $validate->validatePartitionDepth($objDepth);
-
- //Validate port ID
- $validate->validatePortID($objPortID, 'port ID');
-
- //Validate endpoint port trunked
- $portArray = array(
- array($objID, $objFace, $objDepth, $objPortID)
- );
- $validate->validateTrunkedEndpoint($portArray);
-
- //Validate port populated
- $validate->validateTrueFalse($data['portPopulated'], 'port populated flag');
-
- return;
-}
-?>
diff --git a/backend/process_search.php b/backend/process_search.php
index ed58f90..57d5617 100755
--- a/backend/process_search.php
+++ b/backend/process_search.php
@@ -12,10 +12,10 @@ if($_SERVER['REQUEST_METHOD'] == 'GET'){
foreach($qls->App->objectArray as $object) {
if(strpos(strtolower($object['name']), strtolower($term)) !== false) {
$obj = $qls->App->objectArray[$object['id']];
- $label = 'Explore - '.$obj['nameString'];
+ $label = 'Explore - '.$qls->App->unConvertHyphens($obj['nameString']);
$objID = $object['id'];
$parentID = $object['env_tree_id'];
- $value = 'explore-'.$objID.'-'.$parentID;
+ $value = 'explore-'.$parentID.'-'.$objID;
array_push($autoCompleteData, array('label'=>$label, 'value'=>$value));
}
}
@@ -37,13 +37,31 @@ if($_SERVER['REQUEST_METHOD'] == 'GET'){
foreach($qls->App->envTreeArray as $location) {
if(strpos(strtolower($location['name']), strtolower($term)) !== false) {
$locationID = $location['id'];
- $treePathString = $qls->App->buildTreePathString($locationID);
+ $treePathString = $qls->App->unConvertHyphens($qls->App->buildTreePathString($locationID));
$label = 'Environment - '.$treePathString;
$value = 'environment-'.$locationID;
array_push($autoCompleteData, array('label'=>$label, 'value'=>$value));
}
}
+ // Port Description
+ foreach($qls->App->portDescriptionAllArray as $portDescription) {
+ if(strpos(strtolower($portDescription['description']), strtolower($term)) !== false) {
+ $objID = $portDescription['object_id'];
+ $objFace = $portDescription['object_face'];
+ $objDepth = $portDescription['object_depth'];
+ $portID = $portDescription['port_id'];
+
+ $obj = $qls->App->objectArray[$objID];
+ $parentID = $obj['env_tree_id'];
+
+ $portName = $qls->App->unConvertHyphens($qls->App->generateObjectPortName($objID, $objFace, $objDepth, $portID));
+ $label = 'Port - '.$portName;
+ $value = 'port-'.$parentID.'-'.$objID.'-'.$objFace.'-'.$objDepth.'-'.$portID;
+ array_push($autoCompleteData, array('label'=>$label, 'value'=>$value));
+ }
+ }
+
echo json_encode($autoCompleteData);
} else if(isset($_GET['select'])) {
@@ -51,23 +69,30 @@ if($_SERVER['REQUEST_METHOD'] == 'GET'){
$value = $_GET['select'];
$data = explode('-', $value);
$appFunction = $data[0];
- $subjectID = $data[1];
if($appFunction == 'explore') {
- $parentID = $data[2];
- header('Location: /explore.php?objID='.$subjectID.'&parentID='.$parentID);
+ $parentID = $data[1];
+ $objID = $data[2];
+ header('Location: /explore.php?parentID='.$parentID.'&objID='.$objID);
exit();
} else if($appFunction == 'template') {
- header('Location: /templates.php?templateID='.$subjectID);
+ $templateID = $data[1];
+ header('Location: /templates.php?templateID='.$templateID);
exit();
} else if($appFunction == 'environment') {
- header('Location: /environment.php?nodeID='.$subjectID);
+ $nodeID = $data[1];
+ header('Location: /environment.php?nodeID='.$nodeID);
+ exit();
+ } else if($appFunction == 'port') {
+ $parentID = $data[1];
+ $objID = $data[2];
+ $objFace = $data[3];
+ $objDepth = $data[4];
+ $portID = $data[5];
+ header('Location: /explore.php?parentID='.$parentID.'&objID='.$objID.'&objFace='.$objFace.'&objDepth='.$objDepth.'&portID='.$portID);
exit();
}
- } else if(isset($_GET['search'])) {
- $searchTerm = $_GET['search'];
- echo 'Search Term: '.$searchTerm.'
This function is in progress
Last updated: 4-May-2019';
}
}
diff --git a/backend/retrieve_port_details.php b/backend/retrieve_port_details.php
index d11314f..6b3ddbf 100755
--- a/backend/retrieve_port_details.php
+++ b/backend/retrieve_port_details.php
@@ -29,6 +29,13 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
$peerPortArray = array();
+ // Retrieve port description
+ if(isset($qls->App->portDescriptionArray[$objID][$objFace][$objDepth][$objPort])) {
+ $portDescription = $qls->App->portDescriptionArray[$objID][$objFace][$objDepth][$objPort]['description'];
+ } else {
+ $portDescription = '';
+ }
+
// Retrieve peer port ID
if(isset($qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort])) {
$port = $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort];
@@ -92,7 +99,8 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
'portOptions' => $portOptions,
'peerPortArray' => $peerPortArray,
'populatedChecked' => $populatedChecked,
- 'populatedDisabled' => $populatedDisabled
+ 'populatedDisabled' => $populatedDisabled,
+ 'portDescription' => $portDescription
);
$validate->returnData['success'] = $returnData;
diff --git a/explore.php b/explore.php
index 0f912d0..ea3a54d 100755
--- a/explore.php
+++ b/explore.php
@@ -287,6 +287,16 @@ $qls->Security->check_auth_page('user.php');
+
| + Description:   + | ++ + | +